23
23
24
24
import com .github ._1c_syntax .bsl .languageserver .context .DocumentContext ;
25
25
import com .github ._1c_syntax .bsl .languageserver .context .symbol .SourceDefinedSymbol ;
26
+ import com .github ._1c_syntax .bsl .languageserver .context .symbol .Symbol ;
27
+ import com .github ._1c_syntax .bsl .languageserver .context .symbol .VariableSymbol ;
28
+ import com .github ._1c_syntax .bsl .languageserver .context .symbol .variable .VariableKind ;
26
29
import org .eclipse .lsp4j .DocumentSymbol ;
30
+ import org .eclipse .lsp4j .SymbolKind ;
27
31
import org .springframework .stereotype .Component ;
28
32
33
+ import java .util .EnumSet ;
29
34
import java .util .List ;
35
+ import java .util .Set ;
30
36
import java .util .stream .Collectors ;
31
37
32
38
@ Component
@@ -37,8 +43,14 @@ public final class DocumentSymbolProvider {
37
43
*/
38
44
public static final String LABEL = "BSL Language Server" ;
39
45
46
+ private static final Set <VariableKind > supportedVariableKinds = EnumSet .of (
47
+ VariableKind .MODULE ,
48
+ VariableKind .GLOBAL
49
+ );
50
+
40
51
public List <DocumentSymbol > getDocumentSymbols (DocumentContext documentContext ) {
41
52
return documentContext .getSymbolTree ().getChildren ().stream ()
53
+ .filter (DocumentSymbolProvider ::isSupported )
42
54
.map (DocumentSymbolProvider ::toDocumentSymbol )
43
55
.collect (Collectors .toList ());
44
56
}
@@ -61,4 +73,11 @@ private static DocumentSymbol toDocumentSymbol(SourceDefinedSymbol symbol) {
61
73
return documentSymbol ;
62
74
}
63
75
76
+ public static boolean isSupported (Symbol symbol ) {
77
+ var symbolKind = symbol .getSymbolKind ();
78
+ if (symbolKind == SymbolKind .Variable ) {
79
+ return supportedVariableKinds .contains (((VariableSymbol ) symbol ).getKind ());
80
+ }
81
+ return true ;
82
+ }
64
83
}
0 commit comments