@@ -15,12 +15,11 @@ import { closest, distance } from 'fastest-levenshtein';
1515
1616import type { VariableDeclaration } from '@nasa-jpl/seq-json-schema/types' ;
1717import type { EditorView } from 'codemirror' ;
18- import { get } from 'svelte/store' ;
1918import { TOKEN_COMMAND , TOKEN_ERROR , TOKEN_REPEAT_ARG , TOKEN_REQUEST } from '../../constants/seq-n-grammar-constants' ;
2019import { TimeTypes } from '../../enums/time' ;
21- import { getGlobals , sequenceAdaptation } from '../../stores/sequence-adaptation' ;
20+ import { getGlobals } from '../../stores/sequence-adaptation' ;
2221import { CustomErrorCodes } from '../../workers/customCodes' ;
23- import { addDefaultArgs , quoteEscape } from '../codemirror/codemirror-utils' ;
22+ import { addDefaultArgs , isHexValue , parseNumericArg , quoteEscape } from '../codemirror/codemirror-utils' ;
2423import { closeSuggestion , computeBlocks , openSuggestion } from '../codemirror/custom-folder' ;
2524import {
2625 getBalancedDuration ,
@@ -74,7 +73,7 @@ export function sequenceLinter(
7473 const tree = syntaxTree ( view . state ) ;
7574 const treeNode = tree . topNode ;
7675 const docText = view . state . doc . toString ( ) ;
77- let diagnostics : Diagnostic [ ] = [ ] ;
76+ const diagnostics : Diagnostic [ ] = [ ] ;
7877
7978 diagnostics . push ( ...validateParserErrors ( tree ) ) ;
8079
@@ -155,12 +154,6 @@ export function sequenceLinter(
155154 ...conditionalAndLoopKeywordsLinter ( treeNode . getChild ( 'Commands' ) ?. getChildren ( TOKEN_COMMAND ) || [ ] , view . state ) ,
156155 ) ;
157156
158- const inputLinter = get ( sequenceAdaptation ) ?. inputFormat . linter ;
159-
160- if ( inputLinter !== undefined && commandDictionary !== null ) {
161- diagnostics = inputLinter ( diagnostics , commandDictionary , view , treeNode ) ;
162- }
163-
164157 return diagnostics ;
165158}
166159
@@ -191,7 +184,6 @@ function validateParserErrors(tree: Tree) {
191184
192185function conditionalAndLoopKeywordsLinter ( commandNodes : SyntaxNode [ ] , state : EditorState ) : Diagnostic [ ] {
193186 const diagnostics : Diagnostic [ ] = [ ] ;
194-
195187 const blocks = computeBlocks ( state ) ;
196188
197189 if ( blocks ) {
@@ -1185,13 +1177,12 @@ function validateArgument(
11851177 break ;
11861178 }
11871179 const { max, min } = dictArg . range ;
1188- const nodeTextAsNumber = parseFloat ( argText ) ;
1189-
1180+ const nodeTextAsNumber = parseNumericArg ( argText , dictArgType ) ;
11901181 if ( nodeTextAsNumber < min || nodeTextAsNumber > max ) {
11911182 const message =
11921183 max !== min
1193- ? `Number out of range. Range is between ${ min } and ${ max } inclusive.`
1194- : `Number out of range. Range is ${ min } .` ;
1184+ ? `Number out of range. Range is between ${ numFormat ( argText , min ) } and ${ numFormat ( argText , max ) } inclusive.`
1185+ : `Number out of range. Range is ${ numFormat ( argText , min ) } .` ;
11951186 diagnostics . push ( {
11961187 actions :
11971188 max === min
@@ -1356,6 +1347,10 @@ function validateArgument(
13561347 return diagnostics ;
13571348}
13581349
1350+ function numFormat ( argText : string , num : number ) : number | string {
1351+ return isHexValue ( argText ) ? `0x${ num . toString ( 16 ) . toUpperCase ( ) } ` : num ;
1352+ }
1353+
13591354function validateId ( commandNode : SyntaxNode , text : string ) : Diagnostic [ ] {
13601355 const diagnostics : Diagnostic [ ] = [ ] ;
13611356 const idNodes = commandNode . getChildren ( 'IdDeclaration' ) ;
0 commit comments