Skip to content

Commit 8254cfa

Browse files
committed
npe fix
1 parent 3256a32 commit 8254cfa

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,7 @@ public ParseTree visitAssignment(BSLParser.AssignmentContext ctx) {
158158
return lValue;
159159
}
160160

161-
var typeName = "";
162-
var newCtx = Trees.getNextNode(ctx.expression(), ctx.expression(), BSLParser.RULE_newExpression);
163-
if (newCtx instanceof BSLParser.NewExpressionContext) {
164-
typeName = ((BSLParser.NewExpressionContext) newCtx).typeName().getText();
165-
}
166-
updateVariablesCache(lValue.IDENTIFIER(), createDescription(lValue), typeName);
161+
updateVariablesCache(lValue.IDENTIFIER(), createDescription(lValue), typeName(ctx));
167162
return ctx;
168163
}
169164

@@ -274,4 +269,16 @@ private void updateVariablesCache(TerminalNode node, Optional<VariableDescriptio
274269
}
275270
}
276271

272+
private String typeName(BSLParser.AssignmentContext ctx) {
273+
var typeName = "";
274+
var newCtx = Trees.getNextNode(ctx.expression(), ctx.expression(), BSLParser.RULE_newExpression);
275+
if (newCtx instanceof BSLParser.NewExpressionContext) {
276+
var typeNamectx = ((BSLParser.NewExpressionContext) newCtx).typeName();
277+
if (typeNamectx != null) {
278+
typeName = typeNamectx.getText();
279+
}
280+
}
281+
return typeName;
282+
}
283+
277284
}

src/main/java/com/github/_1c_syntax/bsl/languageserver/references/OscriptReferenceFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class OscriptReferenceFinder implements ReferenceFinder {
4848
public Optional<Reference> findReference(URI uri, Position position) {
4949

5050
DocumentContext document = serverContext.getDocument(uri);
51-
if (document == null) {
51+
if (document == null || document.isComputedDataFrozen()) {
5252
return Optional.empty();
5353
}
5454

0 commit comments

Comments
 (0)