Skip to content

Commit ed59d58

Browse files
committed
Исправлена ошибка с одинаковыми именами параметров
Ошибка возникала при построении дерева переменных по параметрам, если не удается определить метод к которому относиться параметр и мы его привязываем к модулю целиком.
1 parent 0726849 commit ed59d58

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.antlr.v4.runtime.tree.ParseTree;
3838
import org.antlr.v4.runtime.tree.TerminalNode;
3939
import org.eclipse.lsp4j.Range;
40+
import org.eclipse.lsp4j.SymbolKind;
4041

4142
import java.util.ArrayList;
4243
import java.util.Collections;
@@ -129,6 +130,11 @@ public ParseTree visitParam(BSLParser.ParamContext ctx) {
129130
return ctx;
130131
}
131132

133+
// При ошибках в разборе может получиться, что два параметра с одним именем в модуле
134+
if (currentMethod.getSymbolKind() == SymbolKind.Module && moduleVariables.containsKey(ctx.IDENTIFIER().getText())) {
135+
return ctx;
136+
}
137+
132138
var variable = VariableSymbol.builder()
133139
.name(ctx.IDENTIFIER().getText().intern())
134140
.scope(currentMethod)
@@ -141,7 +147,11 @@ public ParseTree visitParam(BSLParser.ParamContext ctx) {
141147
.build();
142148
variables.add(variable);
143149

144-
currentMethodVariables.put(ctx.IDENTIFIER().getText(), ctx.IDENTIFIER().getText());
150+
if (currentMethod.getSymbolKind() == SymbolKind.Module) {
151+
moduleVariables.put(ctx.IDENTIFIER().getText(), ctx.IDENTIFIER().getText());
152+
} else {
153+
currentMethodVariables.put(ctx.IDENTIFIER().getText(), ctx.IDENTIFIER().getText());
154+
}
145155
return ctx;
146156
}
147157

0 commit comments

Comments
 (0)