File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
main/java/com/github/_1c_syntax/bsl/languageserver/context/computer
test/java/com/github/_1c_syntax/bsl/languageserver/context/computer Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ public ParseTree visitParam(BSLParser.ParamContext ctx) {
165165 public ParseTree visitLValue (BSLParser .LValueContext ctx ) {
166166 if (
167167 ctx .getChildCount () > 1
168+ || ctx .IDENTIFIER () == null
168169 || currentMethodVariables .containsKey (ctx .getText ())
169170 || moduleVariables .containsKey (ctx .getText ())
170171 ) {
Original file line number Diff line number Diff line change 3636import java .util .stream .Collectors ;
3737
3838import static org .assertj .core .api .Assertions .assertThat ;
39+ import static org .assertj .core .api .Assertions .assertThatCode ;
3940
4041@ SpringBootTest
4142class VariableSymbolTest {
@@ -148,4 +149,24 @@ void testVariableKind() {
148149
149150 }
150151
152+ @ Test
153+ void testNoNPEOnMalformedLValue () {
154+ // Test for issue BSL-LANGUAGE-SERVER-G5
155+ // Malformed code with syntax errors should not cause NPE
156+ String code = """
157+ Процедура Тест()
158+ Переменная =;
159+ =;
160+ Док.Записать;
161+ КонецПроцедуры
162+ """ ;
163+
164+ // Symbol tree construction happens during getDocumentContext
165+ // and should not throw NullPointerException
166+ assertThatCode (() -> {
167+ var ctx = TestUtils .getDocumentContext (code );
168+ ctx .getSymbolTree ().getVariables ();
169+ }).doesNotThrowAnyException ();
170+ }
171+
151172}
You can’t perform that action at this time.
0 commit comments