(file)
| 796 | } |
| 797 | |
| 798 | function getFileLanguageId(file) { |
| 799 | if (!file) return "plaintext"; |
| 800 | const mode = file.currentMode || file.mode; |
| 801 | if (mode) { |
| 802 | const modeInfo = getMode(String(mode)); |
| 803 | if (modeInfo?.name) return String(modeInfo.name).toLowerCase(); |
| 804 | return String(mode).toLowerCase(); |
| 805 | } |
| 806 | try { |
| 807 | const guess = getModeForPath(file.filename || file.name || ""); |
| 808 | if (guess?.name) return String(guess.name).toLowerCase(); |
| 809 | } catch (error) { |
| 810 | warnRecoverable( |
| 811 | `Failed to resolve language id for ${file.filename || file.name || "untitled file"}`, |
| 812 | error, |
| 813 | "language-id-resolution", |
| 814 | ); |
| 815 | } |
| 816 | return "plaintext"; |
| 817 | } |
| 818 | |
| 819 | function resolveRootUriForContext(context = {}) { |
| 820 | const uri = context.uri || context.file?.uri; |
no test coverage detected