Skip to content

Commit a491b8d

Browse files
committed
Adds icons for Const and Enum
1 parent 8f8a509 commit a491b8d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/ai_symbols.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ import { AI_CONSTANTS, AUTOIT_MODE, isSkippableLine, functionPattern } from './u
44
const variablePattern = /(\$\w+)/g;
55
const config = workspace.getConfiguration('autoit');
66

7+
const createVariableSymbol = (variable, variableKind, doc, line) => {
8+
return new SymbolInformation(variable, variableKind, '', new Location(doc.uri, line.range));
9+
};
10+
711
export default languages.registerDocumentSymbolProvider(AUTOIT_MODE, {
812
provideDocumentSymbols(doc) {
913
const result = [];
1014
const found = [];
1115
let funcName;
16+
let variableKind;
1217

1318
// Get the number of lines in the document to loop through
1419
const lineCount = Math.min(doc.lineCount, 10000);
@@ -41,18 +46,21 @@ export default languages.registerDocumentSymbolProvider(AUTOIT_MODE, {
4146
continue;
4247
}
4348

49+
if (/^Const/.test(text)) {
50+
variableKind = SymbolKind.Constant;
51+
} else if (/^Enum/.test(text)) {
52+
variableKind = SymbolKind.Enum;
53+
} else {
54+
variableKind = SymbolKind.Variable;
55+
}
56+
57+
// eslint-disable-next-line no-loop-func
4458
variables.forEach(variable => {
4559
if (found.includes(variable) || AI_CONSTANTS.includes(variable)) {
4660
return;
4761
}
4862

49-
const variableSymbol = new SymbolInformation(
50-
variable,
51-
SymbolKind.Variable,
52-
'',
53-
new Location(doc.uri, line.range),
54-
);
55-
result.push(variableSymbol);
63+
result.push(createVariableSymbol(variable, variableKind, doc, line));
5664
found.push(variable);
5765
});
5866
}

0 commit comments

Comments
 (0)