MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / collectFormatterExtensions

Function collectFormatterExtensions

src/cm/lsp/formatter.ts:82–121  ·  view source on GitHub ↗
(languages: Set<string>)

Source from the content-addressed store, hash-verified

80}
81
82function collectFormatterExtensions(languages: Set<string>): string[] {
83 const extensions = new Set<string>();
84 const modeMap = new Map<string, Mode>();
85
86 try {
87 const modes = getModes() as Mode[];
88 modes.forEach((mode) => {
89 const key = String(mode?.name ?? "")
90 .trim()
91 .toLowerCase();
92 if (key) modeMap.set(key, mode);
93 });
94 } catch (_) {
95 // Ignore mode loading errors
96 }
97
98 languages.forEach((language) => {
99 const key = String(language ?? "")
100 .trim()
101 .toLowerCase();
102 if (!key) return;
103 extensions.add(key);
104 const mode = modeMap.get(key);
105 if (!mode?.extensions) return;
106 String(mode.extensions)
107 .split("|")
108 .forEach((part) => {
109 const ext = part.trim();
110 if (ext && !ext.startsWith("^")) {
111 extensions.add(ext);
112 }
113 });
114 });
115
116 if (!extensions.size) {
117 return ["*"];
118 }
119
120 return Array.from(extensions);
121}

Callers 1

registerLspFormatterFunction · 0.85

Calls 5

getModesFunction · 0.90
StringInterface · 0.85
setMethod · 0.80
addMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected