@@ -172,7 +172,8 @@ public List<Diagnostic> doDiagnostics(Template template, QuteValidationSettings
172172 List <Diagnostic > diagnostics = new ArrayList <Diagnostic >();
173173 try {
174174 diagnosticsForSyntax .validateWithRealQuteParser (template , diagnostics );
175- validateDataModel (template , template , resolvingJavaTypeContext , new ResolutionContext (), diagnostics );
175+ validateDataModel (template , template , validationSettings , resolvingJavaTypeContext , new ResolutionContext (),
176+ diagnostics );
176177 } catch (CancellationException e ) {
177178 throw e ;
178179 } catch (Exception e ) {
@@ -182,8 +183,9 @@ public List<Diagnostic> doDiagnostics(Template template, QuteValidationSettings
182183 return diagnostics ;
183184 }
184185
185- private void validateDataModel (Node parent , Template template , ResolvingJavaTypeContext resolvingJavaTypeContext ,
186- ResolutionContext currentContext , List <Diagnostic > diagnostics ) {
186+ private void validateDataModel (Node parent , Template template , QuteValidationSettings validationSettings ,
187+ ResolvingJavaTypeContext resolvingJavaTypeContext , ResolutionContext currentContext ,
188+ List <Diagnostic > diagnostics ) {
187189 ResolutionContext previousContext = currentContext ;
188190 List <Node > children = parent .getChildren ();
189191 for (Node node : children ) {
@@ -223,8 +225,8 @@ private void validateDataModel(Node parent, Template template, ResolvingJavaType
223225 for (Parameter parameter : parameters ) {
224226 Expression expression = parameter .getJavaTypeExpression ();
225227 if (expression != null ) {
226- ResolvedJavaTypeInfo result = validateExpression (expression , section , template , previousContext ,
227- resolvingJavaTypeContext , diagnostics );
228+ ResolvedJavaTypeInfo result = validateExpression (expression , section , template ,
229+ validationSettings , previousContext , resolvingJavaTypeContext , diagnostics );
228230 switch (section .getSectionKind ()) {
229231 case FOR :
230232 case EACH :
@@ -252,13 +254,14 @@ private void validateDataModel(Node parent, Template template, ResolvingJavaType
252254 break ;
253255 }
254256 case Expression : {
255- validateExpression ((Expression ) node , null , template , previousContext , resolvingJavaTypeContext ,
256- diagnostics );
257+ validateExpression ((Expression ) node , null , template , validationSettings , previousContext ,
258+ resolvingJavaTypeContext , diagnostics );
257259 break ;
258260 }
259261 default :
260262 }
261- validateDataModel (node , template , resolvingJavaTypeContext , currentContext , diagnostics );
263+ validateDataModel (node , template , validationSettings , resolvingJavaTypeContext , currentContext ,
264+ diagnostics );
262265 }
263266 }
264267
@@ -346,8 +349,8 @@ private static void validateIncludeSection(IncludeSection includeSection, List<D
346349 }
347350
348351 private ResolvedJavaTypeInfo validateExpression (Expression expression , Section ownerSection , Template template ,
349- ResolutionContext resolutionContext , ResolvingJavaTypeContext resolvingJavaTypeContext ,
350- List <Diagnostic > diagnostics ) {
352+ QuteValidationSettings validationSettings , ResolutionContext resolutionContext ,
353+ ResolvingJavaTypeContext resolvingJavaTypeContext , List <Diagnostic > diagnostics ) {
351354 try {
352355 String projectUri = template .getProjectUri ();
353356 String literalJavaType = expression .getLiteralJavaType ();
@@ -372,7 +375,7 @@ private ResolvedJavaTypeInfo validateExpression(Expression expression, Section o
372375 if (expressionChild .getKind () == NodeKind .ExpressionParts ) {
373376 Parts parts = (Parts ) expressionChild ;
374377 resolvedJavaType = validateExpressionParts (parts , ownerSection , template , projectUri ,
375- resolutionContext , resolvingJavaTypeContext , diagnostics );
378+ validationSettings , resolutionContext , resolvingJavaTypeContext , diagnostics );
376379 }
377380 }
378381 return resolvedJavaType ;
@@ -386,12 +389,12 @@ private ResolvedJavaTypeInfo validateExpression(Expression expression, Section o
386389 }
387390
388391 private ResolvedJavaTypeInfo validateExpressionParts (Parts parts , Section ownerSection , Template template ,
389- String projectUri , ResolutionContext resolutionContext , ResolvingJavaTypeContext resolvingJavaTypeContext ,
390- List <Diagnostic > diagnostics ) {
392+ String projectUri , QuteValidationSettings validationSettings , ResolutionContext resolutionContext ,
393+ ResolvingJavaTypeContext resolvingJavaTypeContext , List <Diagnostic > diagnostics ) {
391394 ResolvedJavaTypeInfo resolvedJavaType = null ;
392395 String namespace = null ;
393396 for (int i = 0 ; i < parts .getChildCount (); i ++) {
394- Part current = (( Part ) parts .getChild (i ) );
397+ Part current = parts .getChild (i );
395398
396399 if (current .isLast ()) {
397400 // It's the last part, check if it is not ended with '.'
@@ -423,7 +426,7 @@ private ResolvedJavaTypeInfo validateExpressionParts(Parts parts, Section ownerS
423426 case Object : {
424427 ObjectPart objectPart = (ObjectPart ) current ;
425428 resolvedJavaType = validateObjectPart (namespace , objectPart , ownerSection , template , projectUri ,
426- resolutionContext , diagnostics , resolvingJavaTypeContext );
429+ validationSettings , resolutionContext , diagnostics , resolvingJavaTypeContext );
427430 if (resolvedJavaType == null ) {
428431 // The Java type of the object part cannot be resolved, stop the validation of
429432 // property, method.
@@ -450,8 +453,8 @@ private ResolvedJavaTypeInfo validateExpressionParts(Parts parts, Section ownerS
450453 }
451454 }
452455
453- resolvedJavaType = validateMemberPart (current , ownerSection , template , projectUri , resolutionContext ,
454- resolvedJavaType , iter , diagnostics , resolvingJavaTypeContext );
456+ resolvedJavaType = validateMemberPart (current , ownerSection , template , projectUri , validationSettings ,
457+ resolutionContext , resolvedJavaType , iter , diagnostics , resolvingJavaTypeContext );
455458 if (resolvedJavaType == null ) {
456459 // The Java type of the previous part cannot be resolved, stop the validation of
457460 // followings property, method.
@@ -515,7 +518,8 @@ private String validateNamespace(NamespacePart namespacePart, String projectUri,
515518 }
516519
517520 private ResolvedJavaTypeInfo validateObjectPart (String namespace , ObjectPart objectPart , Section ownerSection ,
518- Template template , String projectUri , ResolutionContext resolutionContext , List <Diagnostic > diagnostics ,
521+ Template template , String projectUri , QuteValidationSettings validationSettings ,
522+ ResolutionContext resolutionContext , List <Diagnostic > diagnostics ,
519523 ResolvingJavaTypeContext resolvingJavaTypeContext ) {
520524 JavaMemberInfo javaMember = resolutionContext .findMemberWithObject (objectPart .getPartName (), projectUri );
521525 if (javaMember != null ) {
@@ -540,8 +544,12 @@ private ResolvedJavaTypeInfo validateObjectPart(String namespace, ObjectPart obj
540544 }
541545
542546 // ex : {item} --> undefined variable
547+ DiagnosticSeverity severity = validationSettings .getUndefinedObject ().getDiagnosticSeverity ();
548+ if (severity == null ) {
549+ return null ;
550+ }
543551 Range range = QutePositionUtility .createRange (objectPart );
544- Diagnostic diagnostic = createDiagnostic (range , DiagnosticSeverity . Warning , QuteErrorCode .UndefinedVariable ,
552+ Diagnostic diagnostic = createDiagnostic (range , severity , QuteErrorCode .UndefinedObject ,
545553 objectPart .getPartName ());
546554 // Create data information helpful for code action
547555 diagnostic .setData (DiagnosticDataFactory .createUndefinedVariableData (objectPart .getPartName (),
@@ -585,7 +593,7 @@ private ResolvedJavaTypeInfo validateObjectPart(String namespace, ObjectPart obj
585593
586594 /**
587595 * Validate the given property, method part.
588- *
596+ *
589597 * @param part the property, method part to validate.
590598 * @param ownerSection the owner section and null otherwise.
591599 * @param template the template.
@@ -595,18 +603,18 @@ private ResolvedJavaTypeInfo validateObjectPart(String namespace, ObjectPart obj
595603 * @param iterableOfType the iterable of type.
596604 * @param diagnostics the diagnostic list to fill.
597605 * @param resolvingJavaTypeContext the resolving Java type context.
598- *
606+ *
599607 * @return the Java type returned by the member part and null otherwise.
600608 */
601609 private ResolvedJavaTypeInfo validateMemberPart (Part part , Section ownerSection , Template template ,
602- String projectUri , ResolutionContext resolutionContext , ResolvedJavaTypeInfo baseType ,
603- ResolvedJavaTypeInfo iterableOfType , List <Diagnostic > diagnostics ,
610+ String projectUri , QuteValidationSettings validationSettings , ResolutionContext resolutionContext ,
611+ ResolvedJavaTypeInfo baseType , ResolvedJavaTypeInfo iterableOfType , List <Diagnostic > diagnostics ,
604612 ResolvingJavaTypeContext resolvingJavaTypeContext ) {
605613 if (part .getPartKind () == PartKind .Method ) {
606614 // Validate method part
607615 // ex : {foo.method(1, 2)}
608- return validateMethodPart ((MethodPart ) part , ownerSection , template , projectUri , resolutionContext ,
609- baseType , iterableOfType , diagnostics , resolvingJavaTypeContext );
616+ return validateMethodPart ((MethodPart ) part , ownerSection , template , projectUri , validationSettings ,
617+ resolutionContext , baseType , iterableOfType , diagnostics , resolvingJavaTypeContext );
610618 }
611619 // Validate property part
612620 // ex : {foo.property}
@@ -616,7 +624,7 @@ private ResolvedJavaTypeInfo validateMemberPart(Part part, Section ownerSection,
616624
617625 /**
618626 * Validate the given property part.
619- *
627+ *
620628 * @param part the property part to validate.
621629 * @param ownerSection the owner section and null otherwise.
622630 * @param template the template.
@@ -626,7 +634,7 @@ private ResolvedJavaTypeInfo validateMemberPart(Part part, Section ownerSection,
626634 * @param iterableOfType the iterable of type.
627635 * @param diagnostics the diagnostic list to fill.
628636 * @param resolvingJavaTypeContext the resolving Java type context.
629- *
637+ *
630638 * @return the Java type returned by the member part and null otherwise.
631639 */
632640 private ResolvedJavaTypeInfo validatePropertyPart (PropertyPart part , Section ownerSection , Template template ,
@@ -649,7 +657,7 @@ private ResolvedJavaTypeInfo validatePropertyPart(PropertyPart part, Section own
649657
650658 /**
651659 * Validate the given method part.
652- *
660+ *
653661 * @param part the method part to validate.
654662 * @param ownerSection the owner section and null otherwise.
655663 * @param template the template.
@@ -659,12 +667,12 @@ private ResolvedJavaTypeInfo validatePropertyPart(PropertyPart part, Section own
659667 * @param iterableOfType the iterable of type.
660668 * @param diagnostics the diagnostic list to fill.
661669 * @param resolvingJavaTypeContext the resolving Java type context.
662- *
670+ *
663671 * @return the Java type returned by the member part and null otherwise.
664672 */
665673 private ResolvedJavaTypeInfo validateMethodPart (MethodPart methodPart , Section ownerSection , Template template ,
666- String projectUri , ResolutionContext resolutionContext , ResolvedJavaTypeInfo resolvedJavaType ,
667- ResolvedJavaTypeInfo iter , List <Diagnostic > diagnostics ,
674+ String projectUri , QuteValidationSettings validationSettings , ResolutionContext resolutionContext ,
675+ ResolvedJavaTypeInfo resolvedJavaType , ResolvedJavaTypeInfo iter , List <Diagnostic > diagnostics ,
668676 ResolvingJavaTypeContext resolvingJavaTypeContext ) {
669677
670678 // Validate parameters of the method part
@@ -674,7 +682,7 @@ private ResolvedJavaTypeInfo validateMethodPart(MethodPart methodPart, Section o
674682 ResolvedJavaTypeInfo result = null ;
675683 Expression expression = parameter .getJavaTypeExpression ();
676684 if (expression != null ) {
677- result = validateExpression (expression , ownerSection , template , resolutionContext ,
685+ result = validateExpression (expression , ownerSection , template , validationSettings , resolutionContext ,
678686 resolvingJavaTypeContext , diagnostics );
679687 }
680688 if (result == null ) {
@@ -700,7 +708,7 @@ private ResolvedJavaTypeInfo validateMethodPart(MethodPart methodPart, Section o
700708 String arg = null ;
701709 if (namespace != null ) {
702710 // ex :{config.getXXXX()}
703- errorCode = QuteErrorCode .UnkwownNamespaceResolverMethod ;
711+ errorCode = QuteErrorCode .UnknownNamespaceResolverMethod ;
704712 arg = namespace ;
705713 } else {
706714 // ex : {@org.acme.Item item}
0 commit comments