Search in sources :

Example 1 with SharedSettings

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

the class QuteCodeActionWithSettingsTest method withDisableValidationQuickFixUndefinedObject.

@Test
public void withDisableValidationQuickFixUndefinedObject() throws Exception {
    String template = "{item}";
    Diagnostic d = d(// 
    0, // 
    1, // 
    0, // 
    5, // 
    QuteErrorCode.UndefinedObject, // 
    "`item` cannot be resolved to an object.", DiagnosticSeverity.Warning);
    d.setData(DiagnosticDataFactory.createUndefinedObjectData("item", false));
    testDiagnosticsFor(template, d);
    SharedSettings settings = createSharedSettings(QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE);
    testCodeActionsFor(// 
    template, // 
    d, // 
    settings, ca(d, c(// 
    "Disable Qute validation for the `qute-quickstart` project.", // 
    QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // 
    "qute.validation.enabled", // 
    "test.qute", // 
    ConfigurationItemEditType.update, // 
    false, // 
    d)), ca(d, c(// 
    "Exclude this file from validation.", // 
    QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // 
    "qute.validation.excluded", // 
    "test.qute", // 
    ConfigurationItemEditType.add, // 
    "test.qute", // 
    d)), ca(d, te(0, 0, 0, 0, // 
    "{@java.lang.String item}" + // 
    System.lineSeparator())), ca(d, c(// 
    "Ignore `UndefinedObject` problem.", // 
    QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // 
    "qute.validation.undefinedObject.severity", // 
    "test.qute", // 
    ConfigurationItemEditType.update, // 
    "ignore", d)));
}
Also used : SharedSettings(com.redhat.qute.settings.SharedSettings) Diagnostic(org.eclipse.lsp4j.Diagnostic) Test(org.junit.jupiter.api.Test)

Example 2 with SharedSettings

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

the class QuteGenerateTemplateContentCommandHandlerTest method generateItem.

@Test
public void generateItem() throws InterruptedException, ExecutionException, Exception {
    QuteGenerateTemplateContentCommandHandler command = new QuteGenerateTemplateContentCommandHandler(createJavaDataModelCache());
    ExecuteCommandParams params = new ExecuteCommandParams("", Arrays.asList(createItemInfo()));
    String result = (String) // 
    command.executeCommand(// 
    params, // 
    new SharedSettings(), () -> {
    }).get();
    System.err.println(result);
}
Also used : SharedSettings(com.redhat.qute.settings.SharedSettings) ExecuteCommandParams(org.eclipse.lsp4j.ExecuteCommandParams) Test(org.junit.jupiter.api.Test)

Example 3 with SharedSettings

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

the class QuteAssert method assertHover.

public static void assertHover(String value, String fileURI, String templateId, String expectedHoverLabel, Range expectedHoverRange) throws Exception {
    SharedSettings sharedSettings = new SharedSettings();
    HoverCapabilities capabilities = new HoverCapabilities(Arrays.asList(MarkupKind.MARKDOWN), false);
    sharedSettings.getHoverSettings().setCapabilities(capabilities);
    assertHover(value, fileURI, templateId, PROJECT_URI, TEMPLATE_BASE_DIR, expectedHoverLabel, expectedHoverRange, sharedSettings);
}
Also used : HoverCapabilities(org.eclipse.lsp4j.HoverCapabilities) SharedSettings(com.redhat.qute.settings.SharedSettings)

Example 4 with SharedSettings

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

the class QuteAssert method testCodeLensFor.

private static void testCodeLensFor(String value, String fileUri, String templateId, String projectUri, String templateBaseDir, CodeLens... expected) throws Exception {
    QuteProjectRegistry projectRegistry = new MockQuteProjectRegistry();
    Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry);
    template.setTemplateId(templateId);
    QuteLanguageService languageService = new QuteLanguageService(new JavaDataModelCache(projectRegistry));
    SharedSettings sharedSettings = new SharedSettings();
    CommandCapabilities commandCapabilities = new CommandCapabilities();
    CommandKindCapabilities kinds = new CommandKindCapabilities(Arrays.asList(QuteClientCommandConstants.COMMAND_JAVA_DEFINITION));
    commandCapabilities.setCommandKind(kinds);
    sharedSettings.getCommandCapabilities().setCapabilities(commandCapabilities);
    List<? extends CodeLens> actual = languageService.getCodeLens(template, sharedSettings, () -> {
    }).get();
    assertCodeLens(actual, expected);
}
Also used : JavaDataModelCache(com.redhat.qute.project.datamodel.JavaDataModelCache) SharedSettings(com.redhat.qute.settings.SharedSettings) QuteProjectRegistry(com.redhat.qute.project.QuteProjectRegistry) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) CommandCapabilities(com.redhat.qute.ls.commons.client.CommandCapabilities) QuteLanguageService(com.redhat.qute.services.QuteLanguageService) CommandKindCapabilities(com.redhat.qute.ls.commons.client.CommandKindCapabilities) MockQuteProjectRegistry(com.redhat.qute.project.MockQuteProjectRegistry) Template(com.redhat.qute.parser.template.Template)

Example 5 with SharedSettings

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

the class QuteCodeActionWithSettingsTest method createSharedSettings.

private static SharedSettings createSharedSettings(String... commandIds) {
    SharedSettings settings = new SharedSettings();
    CommandCapabilities commandCapabilities = new CommandCapabilities();
    CommandKindCapabilities kinds = new CommandKindCapabilities(commandIds != null ? Arrays.asList(commandIds) : Collections.emptyList());
    commandCapabilities.setCommandKind(kinds);
    settings.getCommandCapabilities().setCapabilities(commandCapabilities);
    return settings;
}
Also used : SharedSettings(com.redhat.qute.settings.SharedSettings) CommandCapabilities(com.redhat.qute.ls.commons.client.CommandCapabilities) CommandKindCapabilities(com.redhat.qute.ls.commons.client.CommandKindCapabilities)

Aggregations

SharedSettings (com.redhat.qute.settings.SharedSettings)7 Test (org.junit.jupiter.api.Test)4 CommandCapabilities (com.redhat.qute.ls.commons.client.CommandCapabilities)2 CommandKindCapabilities (com.redhat.qute.ls.commons.client.CommandKindCapabilities)2 Diagnostic (org.eclipse.lsp4j.Diagnostic)2 ExecuteCommandParams (org.eclipse.lsp4j.ExecuteCommandParams)2 Template (com.redhat.qute.parser.template.Template)1 MockQuteProjectRegistry (com.redhat.qute.project.MockQuteProjectRegistry)1 QuteProjectRegistry (com.redhat.qute.project.QuteProjectRegistry)1 JavaDataModelCache (com.redhat.qute.project.datamodel.JavaDataModelCache)1 QuteLanguageService (com.redhat.qute.services.QuteLanguageService)1 HoverCapabilities (org.eclipse.lsp4j.HoverCapabilities)1