@@ -4,11 +4,16 @@ import { AI_CONSTANTS, AUTOIT_MODE, isSkippableLine, functionPattern } from './u
4
4
const variablePattern = / ( \$ \w + ) / g;
5
5
const config = workspace . getConfiguration ( 'autoit' ) ;
6
6
7
+ const createVariableSymbol = ( variable , variableKind , doc , line ) => {
8
+ return new SymbolInformation ( variable , variableKind , '' , new Location ( doc . uri , line . range ) ) ;
9
+ } ;
10
+
7
11
export default languages . registerDocumentSymbolProvider ( AUTOIT_MODE , {
8
12
provideDocumentSymbols ( doc ) {
9
13
const result = [ ] ;
10
14
const found = [ ] ;
11
15
let funcName ;
16
+ let variableKind ;
12
17
13
18
// Get the number of lines in the document to loop through
14
19
const lineCount = Math . min ( doc . lineCount , 10000 ) ;
@@ -41,18 +46,21 @@ export default languages.registerDocumentSymbolProvider(AUTOIT_MODE, {
41
46
continue ;
42
47
}
43
48
49
+ if ( / ^ C o n s t / . test ( text ) ) {
50
+ variableKind = SymbolKind . Constant ;
51
+ } else if ( / ^ E n u m / . test ( text ) ) {
52
+ variableKind = SymbolKind . Enum ;
53
+ } else {
54
+ variableKind = SymbolKind . Variable ;
55
+ }
56
+
57
+ // eslint-disable-next-line no-loop-func
44
58
variables . forEach ( variable => {
45
59
if ( found . includes ( variable ) || AI_CONSTANTS . includes ( variable ) ) {
46
60
return ;
47
61
}
48
62
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 ) ) ;
56
64
found . push ( variable ) ;
57
65
} ) ;
58
66
}
0 commit comments