Search in sources :

Example 1 with QuteProjectRegistry

use of com.redhat.qute.project.QuteProjectRegistry 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 2 with QuteProjectRegistry

use of com.redhat.qute.project.QuteProjectRegistry 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 3 with QuteProjectRegistry

use of com.redhat.qute.project.QuteProjectRegistry 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)

Example 4 with QuteProjectRegistry

use of com.redhat.qute.project.QuteProjectRegistry in project quarkus-ls by redhat-developer.

the class QuteAssert method testDocumentLinkFor.

public static void testDocumentLinkFor(String value, String fileUri, String projectUri, String templateBaseDir, DocumentLink... expected) {
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    List<DocumentLink> actual = languageService.findDocumentLinks(template);
    assertDocumentLinks(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) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) DocumentLink(org.eclipse.lsp4j.DocumentLink) Template(com.redhat.qute.parser.template.Template)

Example 5 with QuteProjectRegistry

use of com.redhat.qute.project.QuteProjectRegistry in project quarkus-ls by redhat-developer.

the class QuteAssert method testReferencesFor.

public static void testReferencesFor(String value, String fileUri, String projectUri, String templateBaseDir, Location... expected) throws BadLocationException {
    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);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    Position position = template.positionAt(offset);
    List<? extends Location> actual = languageService.findReferences(template, position, new ReferenceContext(), () -> {
    });
    assertLocation(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) ReferenceContext(org.eclipse.lsp4j.ReferenceContext) QuteLanguageService(com.redhat.qute.services.QuteLanguageService) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) Template(com.redhat.qute.parser.template.Template)

Aggregations

MockQuteProjectRegistry (com.redhat.qute.project.MockQuteProjectRegistry)12 QuteProjectRegistry (com.redhat.qute.project.QuteProjectRegistry)12 JavaDataModelCache (com.redhat.qute.project.datamodel.JavaDataModelCache)12 Template (com.redhat.qute.parser.template.Template)11 QuteLanguageService (com.redhat.qute.services.QuteLanguageService)11 Position (org.eclipse.lsp4j.Position)7 MarkedString (org.eclipse.lsp4j.MarkedString)2 ProjectInfo (com.redhat.qute.commons.ProjectInfo)1 TextDocument (com.redhat.qute.ls.commons.TextDocument)1 CommandCapabilities (com.redhat.qute.ls.commons.client.CommandCapabilities)1 CommandKindCapabilities (com.redhat.qute.ls.commons.client.CommandKindCapabilities)1 ResolvingJavaTypeContext (com.redhat.qute.services.diagnostics.ResolvingJavaTypeContext)1 QuteCompletionSettings (com.redhat.qute.settings.QuteCompletionSettings)1 QuteFormattingSettings (com.redhat.qute.settings.QuteFormattingSettings)1 SharedSettings (com.redhat.qute.settings.SharedSettings)1 CodeAction (org.eclipse.lsp4j.CodeAction)1 CodeActionContext (org.eclipse.lsp4j.CodeActionContext)1 CompletionCapabilities (org.eclipse.lsp4j.CompletionCapabilities)1 CompletionItem (org.eclipse.lsp4j.CompletionItem)1 CompletionItemCapabilities (org.eclipse.lsp4j.CompletionItemCapabilities)1