@@ -2,6 +2,7 @@ import { BraceExpression, CompileStatement, CompilerError, ExportStatement, Expr
2
2
import { CodeAction , CodeActionKind , Range } from 'lsp-types' ;
3
3
import { dictionary } from './dictionary/dictionary.js' ;
4
4
import levenshtein from 'js-levenshtein' ;
5
+ import { subRange } from './diagnostic.js' ;
5
6
6
7
const caf = {
7
8
mk : ( keyword : string , program : ProgramStatement , range : Range , filePath : string ) : CodeAction [ ] => {
@@ -17,7 +18,7 @@ const caf = {
17
18
edit : {
18
19
changes : {
19
20
[ filePath ] : [ {
20
- range,
21
+ range : subRange ( range ) ,
21
22
newText : word
22
23
} ]
23
24
}
@@ -485,6 +486,13 @@ export namespace syxparser {
485
486
else if ( tt === TokenType . OpenSquare ) return parseSquareExpression ( put , defaultRange ) ;
486
487
else if ( tt === TokenType . OpenParen ) return parseParenExpression ( put , defaultRange ) ;
487
488
else if ( tt === TokenType . Identifier && at ( 1 ) . type === TokenType . VarSeperator ) return parsePrimitiveVariable ( put ) ;
489
+ else if ( keywords . includes ( tt ) ) {
490
+ if ( ! statements ) throw new CompilerError ( at ( ) . range , 'Statement not allowed here.' , filePath ) ;
491
+ return parseStatement ( ) ;
492
+ } else if ( tt === TokenType . Identifier && expectIdentifier ) {
493
+ const { value, range } = tokens . shift ( ) ;
494
+ return node ( { type : NodeType . String , value, range } , put ) ;
495
+ }
488
496
else throw new CompilerError ( at ( ) . range , `Unexpected expression: '${ at ( ) . value } '` , filePath ) ;
489
497
490
498
0 commit comments