@@ -278,7 +278,7 @@ export function validateAlg(
278278 diagnostics . push ( diagnostic ) ;
279279 return diagnostics ;
280280 }
281- const visitor = new AlgVisitor ( true ) ;
281+ const visitor = new AlgVisitor ( ) ;
282282 visitor . visit ( expr ) ;
283283 visitor . calcs . forEach ( ( calc ) => {
284284 diagnostics . push (
@@ -289,9 +289,8 @@ export function validateAlg(
289289 diagnostics . push (
290290 ...validateAlgVariable (
291291 variable ,
292- doc ,
293292 contextProvider ,
294- offsetStartAlg ,
293+ algPositionTransformer ,
295294 ) ,
296295 ) ;
297296 } ) ;
@@ -300,9 +299,8 @@ export function validateAlg(
300299
301300export function validateAlgVariable (
302301 variable : AlgLiteral ,
303- doc : TextDocument ,
304302 contextProvider : SepticContext ,
305- offsetStartAlg : number ,
303+ algPositionTransformer : AlgPositionTransformer ,
306304) : SepticDiagnostic [ ] {
307305 if ( isPureJinja ( variable . value ) ) {
308306 return [ ] ;
@@ -317,10 +315,7 @@ export function validateAlgVariable(
317315 return [
318316 createDiagnostic (
319317 SepticDiagnosticLevel . warning ,
320- {
321- start : doc . positionAt ( offsetStartAlg + variable . start ) ,
322- end : doc . positionAt ( offsetStartAlg + variable . end ) ,
323- } ,
318+ algPositionTransformer ( variable . start , variable . end ) ,
324319 `Reference to undefined variable: ${ variable . value } ` ,
325320 SepticDiagnosticCode . missingReference ,
326321 ) ,
@@ -333,10 +328,7 @@ export function validateAlgVariable(
333328 return [
334329 createDiagnostic (
335330 SepticDiagnosticLevel . error ,
336- {
337- start : doc . positionAt ( offsetStartAlg + variable . end - 1 ) ,
338- end : doc . positionAt ( offsetStartAlg + variable . end ) ,
339- } ,
331+ algPositionTransformer ( variable . end - 1 , variable . end ) ,
340332 `Missing public property for variable` ,
341333 SepticDiagnosticCode . missingPublicProperty ,
342334 ) ,
@@ -358,21 +350,15 @@ export function validateAlgVariable(
358350 return [
359351 createDiagnostic (
360352 SepticDiagnosticLevel . error ,
361- {
362- start : doc . positionAt (
363- offsetStartAlg +
364- variable . start +
365- variableParts [ 0 ] ! . length +
366- 1 ,
367- ) ,
368- end : doc . positionAt ( offsetStartAlg + variable . end ) ,
369- } ,
353+ algPositionTransformer (
354+ variable . end - variableParts [ 1 ] ! . length ,
355+ variable . end ,
356+ ) ,
370357 `Unknown public property ${ variableParts [ 1 ] } for ${ referencedObjects [ 0 ] ! . type } '` ,
371358 SepticDiagnosticCode . unknownPublicProperty ,
372359 ) ,
373360 ] ;
374361 }
375-
376362 return [ ] ;
377363}
378364
@@ -593,11 +579,7 @@ function validateParamType(
593579 algPositionTransformer : AlgPositionTransformer ,
594580) : SepticDiagnostic [ ] {
595581 if ( types [ 0 ] ! . startsWith ( "value" ) ) {
596- return validateValueParamType (
597- expr ,
598- contextProvider ,
599- algPositionTransformer ,
600- ) ;
582+ return [ ] ;
601583 }
602584 return validateObjectParamType (
603585 expr ,
@@ -642,36 +624,6 @@ function validateObjectParamType(
642624 ] ;
643625}
644626
645- function validateValueParamType (
646- expr : AlgExpr ,
647- contextProvider : SepticContext ,
648- algPositionTransformer : AlgPositionTransformer ,
649- ) : SepticDiagnostic [ ] {
650- if ( ! isAlgExprObjectReference ( expr ) ) {
651- return [ ] ;
652- }
653- const exprLiteral = expr as AlgLiteral ;
654- if ( isPureJinja ( exprLiteral . value ) ) {
655- return [ ] ;
656- }
657- if (
658- contextProvider . validateReferences (
659- exprLiteral . value . split ( "." ) [ 0 ] ! ,
660- defaultRefValidationFunction ,
661- )
662- ) {
663- return [ ] ;
664- }
665- return [
666- createDiagnostic (
667- SepticDiagnosticLevel . warning ,
668- algPositionTransformer ( expr . start , expr . end ) ,
669- `Reference to undefined variable: ${ exprLiteral . value } ` ,
670- SepticDiagnosticCode . missingReference ,
671- ) ,
672- ] ;
673- }
674-
675627function isAlgExprObjectReference ( expr : AlgExpr ) {
676628 return expr instanceof AlgLiteral && expr . type === AlgTokenType . identifier ;
677629}
0 commit comments