1212package com .redhat .qute .services ;
1313
1414import static com .redhat .qute .services .diagnostics .DiagnosticDataFactory .createDiagnostic ;
15+ import static com .redhat .qute .services .diagnostics .DiagnosticDataFactory .createDiagnosticWithTags ;
1516
1617import java .nio .file .Files ;
1718import java .nio .file .Path ;
2627
2728import org .eclipse .lsp4j .Diagnostic ;
2829import org .eclipse .lsp4j .DiagnosticSeverity ;
30+ import org .eclipse .lsp4j .DiagnosticTag ;
2931import org .eclipse .lsp4j .Range ;
3032import org .eclipse .lsp4j .jsonrpc .CancelChecker ;
3133
5456import com .redhat .qute .parser .template .Template ;
5557import com .redhat .qute .parser .template .sections .IncludeSection ;
5658import com .redhat .qute .parser .template .sections .LoopSection ;
59+ import com .redhat .qute .parser .template .sections .WithSection ;
5760import com .redhat .qute .project .JavaMemberResult ;
5861import com .redhat .qute .project .QuteProject ;
5962import com .redhat .qute .project .datamodel .JavaDataModelCache ;
@@ -246,6 +249,9 @@ private void validateDataModel(Node parent, Template template, ResolvingJavaType
246249 case INCLUDE :
247250 validateIncludeSection ((IncludeSection ) section , diagnostics );
248251 break ;
252+ case WITH :
253+ validateWithSection ((WithSection ) section , diagnostics );
254+ break ;
249255 default :
250256 validateSectionTag (section , template , resolvingJavaTypeContext , diagnostics );
251257 }
@@ -345,6 +351,22 @@ private static void validateIncludeSection(IncludeSection includeSection, List<D
345351 }
346352 }
347353
354+ /**
355+ * Report that `#with` section is deprecated.
356+ *
357+ * @param withSection the with section
358+ * @param diagnostics the diagnostics to fill
359+ */
360+ private static void validateWithSection (WithSection withSection , List <Diagnostic > diagnostics ) {
361+ if (withSection != null ) {
362+ List <DiagnosticTag > tags = Collections .singletonList (DiagnosticTag .Deprecated );
363+ Range range = QutePositionUtility .selectStartTagName (withSection );
364+ Diagnostic diagnostic = createDiagnosticWithTags (range , DiagnosticSeverity .Warning ,
365+ QuteErrorCode .DeprecatedWithSection , tags );
366+ diagnostics .add (diagnostic );
367+ }
368+ }
369+
348370 private ResolvedJavaTypeInfo validateExpression (Expression expression , Section ownerSection , Template template ,
349371 ResolutionContext resolutionContext , ResolvingJavaTypeContext resolvingJavaTypeContext ,
350372 List <Diagnostic > diagnostics ) {
@@ -391,7 +413,7 @@ private ResolvedJavaTypeInfo validateExpressionParts(Parts parts, Section ownerS
391413 ResolvedJavaTypeInfo resolvedJavaType = null ;
392414 String namespace = null ;
393415 for (int i = 0 ; i < parts .getChildCount (); i ++) {
394- Part current = (( Part ) parts .getChild (i ));
416+ Part current = (parts .getChild (i ));
395417
396418 if (current .isLast ()) {
397419 // It's the last part, check if it is not ended with '.'
@@ -586,7 +608,7 @@ private ResolvedJavaTypeInfo validateObjectPart(ObjectPart objectPart, Section o
586608
587609 /**
588610 * Validate the given property, method part.
589- *
611+ *
590612 * @param part the property, method part to validate.
591613 * @param ownerSection the owner section and null otherwise.
592614 * @param template the template.
@@ -596,7 +618,7 @@ private ResolvedJavaTypeInfo validateObjectPart(ObjectPart objectPart, Section o
596618 * @param iterableOfType the iterable of type.
597619 * @param diagnostics the diagnostic list to fill.
598620 * @param resolvingJavaTypeContext the resolving Java type context.
599- *
621+ *
600622 * @return the Java type returned by the member part and null otherwise.
601623 */
602624 private ResolvedJavaTypeInfo validateMemberPart (Part part , Section ownerSection , Template template ,
@@ -617,7 +639,7 @@ private ResolvedJavaTypeInfo validateMemberPart(Part part, Section ownerSection,
617639
618640 /**
619641 * Validate the given property part.
620- *
642+ *
621643 * @param part the property part to validate.
622644 * @param ownerSection the owner section and null otherwise.
623645 * @param template the template.
@@ -627,7 +649,7 @@ private ResolvedJavaTypeInfo validateMemberPart(Part part, Section ownerSection,
627649 * @param iterableOfType the iterable of type.
628650 * @param diagnostics the diagnostic list to fill.
629651 * @param resolvingJavaTypeContext the resolving Java type context.
630- *
652+ *
631653 * @return the Java type returned by the member part and null otherwise.
632654 */
633655 private ResolvedJavaTypeInfo validatePropertyPart (PropertyPart part , Section ownerSection , Template template ,
@@ -650,7 +672,7 @@ private ResolvedJavaTypeInfo validatePropertyPart(PropertyPart part, Section own
650672
651673 /**
652674 * Validate the given method part.
653- *
675+ *
654676 * @param part the method part to validate.
655677 * @param ownerSection the owner section and null otherwise.
656678 * @param template the template.
@@ -660,7 +682,7 @@ private ResolvedJavaTypeInfo validatePropertyPart(PropertyPart part, Section own
660682 * @param iterableOfType the iterable of type.
661683 * @param diagnostics the diagnostic list to fill.
662684 * @param resolvingJavaTypeContext the resolving Java type context.
663- *
685+ *
664686 * @return the Java type returned by the member part and null otherwise.
665687 */
666688 private ResolvedJavaTypeInfo validateMethodPart (MethodPart methodPart , Section ownerSection , Template template ,
0 commit comments