MCPcopy Index your code
hub / github.com/Acode-Foundation/Acode / getModeForPath

Function getModeForPath

src/cm/modelist.ts:98–114  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

96 * Get mode for file path
97 */
98export function getModeForPath(path: string): Mode {
99 let mode = modesByName.text;
100 const fileName = path.split(/[/\\]/).pop() || "";
101
102 // Sort modes by specificity (descending) to check most specific first
103 const sortedModes = [...modes].sort((a, b) => {
104 return getModeSpecificityScore(b) - getModeSpecificityScore(a);
105 });
106
107 for (const iMode of sortedModes) {
108 if (iMode.supportsFile?.(fileName)) {
109 mode = iMode;
110 break;
111 }
112 }
113 return mode;
114}
115
116/**
117 * Calculates a specificity score for a mode.

Callers 11

toAceModeFunction · 0.90
getModeForPathFunction · 0.90
getLanguageParserFunction · 0.90
editorFile.jsFile · 0.90
constructorMethod · 0.90
formatMethod · 0.90
getFileLanguageIdFunction · 0.90
EditorManagerFunction · 0.90
showRecommendationMethod · 0.90
findPluginModeFunction · 0.90

Calls 2

getModeSpecificityScoreFunction · 0.85
supportsFileMethod · 0.80

Tested by

no test coverage detected