Search in sources :

Example 6 with Template

use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.

the class QutePositionUtility method selectEndTagName.

public static Range selectEndTagName(Section sectionTag) {
    Template template = sectionTag.getOwnerTemplate();
    // {|\each
    int startOffset = sectionTag.getEndTagNameOpenOffset();
    // // {\each|
    int endOffset = sectionTag.getEndTagCloseOffset();
    return createRange(startOffset, endOffset, template);
}
Also used : Template(com.redhat.qute.parser.template.Template)

Example 7 with Template

use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.

the class QutePositionUtility method selectStartTagName.

public static Range selectStartTagName(Section section) {
    Template template = section.getOwnerTemplate();
    // {|#each
    int startOffset = section.getStartTagNameOpenOffset();
    // {#each|
    int endOffset = section.getStartTagNameCloseOffset();
    return createRange(startOffset, endOffset, template);
}
Also used : Template(com.redhat.qute.parser.template.Template)

Example 8 with Template

use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.

the class QuteAssert method assertHover.

private static void assertHover(String value, String fileUri, String templateId, String projectUri, String templateBaseDir, String expectedHoverLabel, Range expectedHoverRange, SharedSettings sharedSettings) throws Exception {
    int offset = value.indexOf("|");
    value = value.substring(0, offset) + value.substring(offset + 1);
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
    template.setTemplateId(templateId);
    Position position = template.positionAt(offset);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    Hover hover = languageService.doHover(template, position, sharedSettings, () -> {
    }).get();
    if (expectedHoverLabel == null) {
        assertNull(hover);
    } else {
        String actualHoverLabel = getHoverLabel(hover);
        assertEquals(expectedHoverLabel, actualHoverLabel);
        if (expectedHoverRange != null) {
            assertEquals(expectedHoverRange, hover.getRange());
        }
    }
}
Also used : JavaDataModelCache(com.redhat.qute.project.datamodel.JavaDataModelCache) Position(org.eclipse.lsp4j.Position) QuteProjectRegistry(com.redhat.qute.project.QuteProjectRegistry) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) Hover(org.eclipse.lsp4j.Hover) QuteLanguageService(com.redhat.qute.services.QuteLanguageService) MarkedString(org.eclipse.lsp4j.MarkedString) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) Template(com.redhat.qute.parser.template.Template)

Example 9 with Template

use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.

the class QuteAssert method testDefinitionFor.

public static void testDefinitionFor(String value, String fileUri, String projectUri, String templateBaseDir, LocationLink... expected) throws Exception {
    int offset = value.indexOf("|");
    value = value.substring(0, offset) + value.substring(offset + 1);
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
    Position position = template.positionAt(offset);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    List<? extends LocationLink> actual = languageService.findDefinition(template, position, () -> {
    }).get();
    assertLocationLink(actual, expected);
}
Also used : JavaDataModelCache(com.redhat.qute.project.datamodel.JavaDataModelCache) Position(org.eclipse.lsp4j.Position) QuteProjectRegistry(com.redhat.qute.project.QuteProjectRegistry) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) QuteLanguageService(com.redhat.qute.services.QuteLanguageService) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) Template(com.redhat.qute.parser.template.Template)

Example 10 with Template

use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.

the class QuteAssert method testDocumentSymbolsFor.

public static void testDocumentSymbolsFor(String value, String fileUri, String projectUri, String templateBaseDir, DocumentSymbol... expected) throws BadLocationException {
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    List<DocumentSymbol> actual = languageService.findDocumentSymbols(template, () -> {
    });
    assertDocumentSymbols(actual, expected);
}
Also used : JavaDataModelCache(com.redhat.qute.project.datamodel.JavaDataModelCache) QuteProjectRegistry(com.redhat.qute.project.QuteProjectRegistry) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) QuteLanguageService(com.redhat.qute.services.QuteLanguageService) DocumentSymbol(org.eclipse.lsp4j.DocumentSymbol) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) Template(com.redhat.qute.parser.template.Template)

Aggregations

Template (com.redhat.qute.parser.template.Template)29 JavaDataModelCache (com.redhat.qute.project.datamodel.JavaDataModelCache)13 MockQuteProjectRegistry (com.redhat.qute.project.MockQuteProjectRegistry)11 QuteProjectRegistry (com.redhat.qute.project.QuteProjectRegistry)11 QuteLanguageService (com.redhat.qute.services.QuteLanguageService)11 Position (org.eclipse.lsp4j.Position)8 Node (com.redhat.qute.parser.template.Node)6 Range (org.eclipse.lsp4j.Range)6 ArrayList (java.util.ArrayList)5 Parameter (com.redhat.qute.parser.template.Parameter)4 BadLocationException (com.redhat.qute.ls.commons.BadLocationException)3 Section (com.redhat.qute.parser.template.Section)3 LoopSection (com.redhat.qute.parser.template.sections.LoopSection)3 QuteProject (com.redhat.qute.project.QuteProject)3 CompletionItem (org.eclipse.lsp4j.CompletionItem)3 ResolvedJavaTypeInfo (com.redhat.qute.commons.ResolvedJavaTypeInfo)2 NamespacePart (com.redhat.qute.parser.expression.NamespacePart)2 Part (com.redhat.qute.parser.expression.Part)2 Parts (com.redhat.qute.parser.expression.Parts)2 Expression (com.redhat.qute.parser.template.Expression)2