@@ -14,12 +14,12 @@ class ParserErrorActions {
14
14
return actions ;
15
15
}
16
16
17
- if (arg .contains (" modifier is not supported for module-level fields" )) {
17
+ if (arg .contains (" modifier is not supported for module-level fields" ) && diagnostic . range != null ) {
18
18
final document = context .documents .getHaxe (params .textDocument .uri );
19
19
final nextText = document .content .substr (document .offsetAt (diagnostic .range .end ));
20
20
final isAuto = nextText .split (" {" ).length == nextText .split (" }" ).length ;
21
21
final token = document ?. tokens ?. getTokenAtOffset (document .offsetAt (diagnostic .range .end ));
22
- var range = diagnostic .range ;
22
+ var range = diagnostic .range . sure () ;
23
23
if (token != null ) {
24
24
for (sib in [token .previousSibling , token .nextSibling ]) {
25
25
if (sib == null )
@@ -44,12 +44,12 @@ class ParserErrorActions {
44
44
});
45
45
}
46
46
47
- if (arg .contains (" `final var` is not supported, use `final` instead" )) {
47
+ if (arg .contains (" `final var` is not supported, use `final` instead" ) && diagnostic . range != null ) {
48
48
final document = context .documents .getHaxe (params .textDocument .uri );
49
49
actions .push ({
50
50
title : " Change to final" ,
51
51
kind : CodeActionKind . QuickFix + " .auto" ,
52
- edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range , newText : " final" }]),
52
+ edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range . sure () , newText : " final" }]),
53
53
diagnostics : [diagnostic ],
54
54
isPreferred : true
55
55
});
@@ -59,7 +59,7 @@ class ParserErrorActions {
59
59
createMissingSemicolonAction (context , params , diagnostic , actions );
60
60
}
61
61
62
- if (arg .contains (" Expected }" )) {
62
+ if (arg .contains (" Expected }" ) && diagnostic . range != null ) {
63
63
final document = context .documents .getHaxe (params .textDocument .uri );
64
64
final token = document ?. tokens ?. getTokenAtOffset (document .offsetAt (diagnostic .range .end ));
65
65
final prevToken = getPrevNonCommentSibling (token );
@@ -70,15 +70,15 @@ class ParserErrorActions {
70
70
actions .push ({
71
71
title : " Remove redundant ;" ,
72
72
kind : CodeActionKind . QuickFix + " .auto" ,
73
- edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range , newText : " " }]),
73
+ edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range . sure () , newText : " " }]),
74
74
diagnostics : [diagnostic ],
75
75
isPreferred : true
76
76
});
77
77
case [Comma , Comma ]:
78
78
actions .push ({
79
79
title : " Remove redundant ," ,
80
80
kind : CodeActionKind . QuickFix + " .auto" ,
81
- edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range , newText : " " }]),
81
+ edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range . sure () , newText : " " }]),
82
82
diagnostics : [diagnostic ],
83
83
isPreferred : true
84
84
});
@@ -91,7 +91,7 @@ class ParserErrorActions {
91
91
actions .push ({
92
92
title : " Replace ; with ," ,
93
93
kind : CodeActionKind . QuickFix + " .auto" ,
94
- edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range , newText : " ," }]),
94
+ edit : WorkspaceEditHelper .create (context , params , [{range : diagnostic .range . sure () , newText : " ," }]),
95
95
diagnostics : [diagnostic ],
96
96
isPreferred : true
97
97
});
@@ -113,7 +113,7 @@ class ParserErrorActions {
113
113
}
114
114
}
115
115
116
- if (arg .contains (" Expected , or ]" )) {
116
+ if (arg .contains (" Expected , or ]" ) && diagnostic . range != null ) {
117
117
final document = context .documents .getHaxe (params .textDocument .uri );
118
118
final errRange : Null <Range > = getMissingSemicolonPos (document , diagnostic .range .start );
119
119
if (errRange != null ) {
@@ -136,7 +136,7 @@ class ParserErrorActions {
136
136
137
137
static function createMissingSemicolonAction (context : Context , params : CodeActionParams , diagnostic : Diagnostic , actions : Array <CodeAction >): Void {
138
138
final document = context .documents .getHaxe (params .textDocument .uri );
139
- final errRange = getMissingSemicolonPos (document , diagnostic . range .start .translate (0 , 1 ));
139
+ final errRange = Safety . let ( diagnostic . range , range -> getMissingSemicolonPos (document , range .start .translate (0 , 1 ) ));
140
140
if (errRange == null )
141
141
return ;
142
142
final errRange : Range = errRange ;
0 commit comments