Search in sources :

Example 6 with JavaDataModelCache

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

the class QuteAssert method testHighlightsFor.

public static void testHighlightsFor(String value, String fileUri, String projectUri, String templateBaseDir, DocumentHighlight... 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 DocumentHighlight> actual = languageService.findDocumentHighlights(template, position, () -> {
    });
    assertDocumentHighlight(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 7 with JavaDataModelCache

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

the class QuteGenerateTemplateContentCommandHandlerTest method createJavaDataModelCache.

private JavaDataModelCache createJavaDataModelCache() {
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    projectRegistry.getProject(new ProjectInfo(PROJECT_URI, TEMPLATE_BASE_DIR));
    return new JavaDataModelCache(projectRegistry);
}
Also used : JavaDataModelCache(com.redhat.qute.project.datamodel.JavaDataModelCache) QuteProjectRegistry(com.redhat.qute.project.QuteProjectRegistry) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) ProjectInfo(com.redhat.qute.commons.ProjectInfo) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry)

Example 8 with JavaDataModelCache

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

the class QuteAssert method testLinkedEditingFor.

public static void testLinkedEditingFor(String value, String fileUri, String projectUri, String templateBaseDir, LinkedEditingRanges 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);
    LinkedEditingRanges actual = languageService.findLinkedEditingRanges(template, position, () -> {
    });
    assertLinkedEditing(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) LinkedEditingRanges(org.eclipse.lsp4j.LinkedEditingRanges)

Example 9 with JavaDataModelCache

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

the class QuteAssert method testDiagnosticsFor.

public static void testDiagnosticsFor(String value, String fileUri, String templateId, String projectUri, String templateBaseDir, boolean filter, QuteValidationSettings validationSettings, Diagnostic... expected) {
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
    template.setTemplateId(templateId);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    List<Diagnostic> actual = languageService.doDiagnostics(template, validationSettings, new ResolvingJavaTypeContext(template), () -> {
    });
    if (expected == null) {
        assertTrue(actual.isEmpty());
        return;
    }
    assertDiagnostics(actual, Arrays.asList(expected), filter);
}
Also used : JavaDataModelCache(com.redhat.qute.project.datamodel.JavaDataModelCache) QuteProjectRegistry(com.redhat.qute.project.QuteProjectRegistry) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) ResolvingJavaTypeContext(com.redhat.qute.services.diagnostics.ResolvingJavaTypeContext) Diagnostic(org.eclipse.lsp4j.Diagnostic) QuteLanguageService(com.redhat.qute.services.QuteLanguageService) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) Template(com.redhat.qute.parser.template.Template)

Example 10 with JavaDataModelCache

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

the class QuteAssert method testCodeActionsFor.

private static void testCodeActionsFor(String value, Diagnostic diagnostic, String fileUri, String projectUri, String templateBaseDir, SharedSettings settings, CodeAction... expected) throws Exception {
    int offset = value.indexOf('|');
    Range range = null;
    if (offset != -1) {
        value = value.substring(0, offset) + value.substring(offset + 1);
    }
    TextDocument document = new TextDocument(value.toString(), FILE_URI);
    if (offset != -1) {
        Position position = document.positionAt(offset);
        range = new Range(position, position);
    } else {
        range = diagnostic.getRange();
    }
    CodeActionContext context = new CodeActionContext();
    context.setDiagnostics(Arrays.asList(diagnostic));
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    List<CodeAction> actual = languageService.doCodeActions(template, context, range, settings).get();
    assertCodeActions(actual, expected);
}
Also used : JavaDataModelCache(com.redhat.qute.project.datamodel.JavaDataModelCache) TextDocument(com.redhat.qute.ls.commons.TextDocument) CodeActionContext(org.eclipse.lsp4j.CodeActionContext) Position(org.eclipse.lsp4j.Position) QuteProjectRegistry(com.redhat.qute.project.QuteProjectRegistry) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) CodeAction(org.eclipse.lsp4j.CodeAction) QuteLanguageService(com.redhat.qute.services.QuteLanguageService) Range(org.eclipse.lsp4j.Range) 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