diff --git a/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/ls/commons/TextDocument.java b/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/ls/commons/TextDocument.java index 19258e716..c47f6b3cb 100644 --- a/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/ls/commons/TextDocument.java +++ b/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/ls/commons/TextDocument.java @@ -194,16 +194,24 @@ public void update(List changes) { TextDocumentContentChangeEvent changeEvent = changes.get(i); Range range = changeEvent.getRange(); int length = 0; - + int startOffset = -1; if (range != null) { - length = changeEvent.getRangeLength().intValue(); + if (changeEvent.getRangeLength() != null) { + // rangeLength is defined, use it + length = changeEvent.getRangeLength().intValue(); + } else { + // rangeLength is not defined, compute it + startOffset = offsetAt(range.getStart()); + int endOffset = offsetAt(range.getEnd()); + length = endOffset - startOffset; + } } else { // range is optional and if not given, the whole file content is replaced length = buffer.length(); range = new Range(positionAt(0), positionAt(length)); } String text = changeEvent.getText(); - int startOffset = offsetAt(range.getStart()); + startOffset = startOffset != 1 ? startOffset : offsetAt(range.getStart()); buffer.replace(startOffset, startOffset + length, text); lineTracker.replace(startOffset, length, text); } diff --git a/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/services/codeactions/QuteCodeActionForUndefinedNamespace.java b/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/services/codeactions/QuteCodeActionForUndefinedNamespace.java index af318e1aa..8ca378ef8 100644 --- a/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/services/codeactions/QuteCodeActionForUndefinedNamespace.java +++ b/qute.ls/com.redhat.qute.ls/src/main/java/com/redhat/qute/services/codeactions/QuteCodeActionForUndefinedNamespace.java @@ -26,6 +26,7 @@ import com.redhat.qute.parser.template.Node; import com.redhat.qute.parser.template.Template; import com.redhat.qute.project.QuteProject; +import com.redhat.qute.services.commands.QuteClientCommandConstants; import com.redhat.qute.services.diagnostics.QuteErrorCode; /** @@ -55,10 +56,13 @@ public void doCodeActions(CodeActionRequest request, List actual = languageService.getCodeLens(template, sharedSettings, () -> { }).get(); assertCodeLens(actual, expected); @@ -647,7 +647,7 @@ private static void testInlayHintFor(String value, String fileUri, String templa Template template = createTemplate(value, fileUri, projectUri, templateBaseDir, projectRegistry); template.setTemplateId(templateId); - SharedSettings settings = createSharedSettings(); + SharedSettings settings = createSharedSettings(false); if (inlayHintSettings != null) { settings.getInlayHintSettings().update(inlayHintSettings); } @@ -689,9 +689,14 @@ public static void assertInlayHint(List actual, InlayHint.. // ------------------- CodeAction assert + public static void testCodeActionsWithConfigurationUpdateFor(String value, Diagnostic diagnostic, CodeAction... expected) + throws Exception { + testCodeActionsFor(value, diagnostic, createSharedSettings(true), expected); + } + public static void testCodeActionsFor(String value, Diagnostic diagnostic, CodeAction... expected) throws Exception { - testCodeActionsFor(value, diagnostic, new SharedSettings(), expected); + testCodeActionsFor(value, diagnostic, createSharedSettings(false), expected); } public static void testCodeActionsFor(String value, Diagnostic diagnostic, SharedSettings settings, @@ -1022,12 +1027,16 @@ private static Template createTemplate(String value, String fileUri, String proj return template; } - private static SharedSettings createSharedSettings() { + public static SharedSettings createSharedSettings(boolean withConfigurationUpdate) { SharedSettings sharedSettings = new SharedSettings(); CommandCapabilities commandCapabilities = new CommandCapabilities(); CommandKindCapabilities kinds = new CommandKindCapabilities( - Arrays.asList(QuteClientCommandConstants.COMMAND_JAVA_DEFINITION, - QuteClientCommandConstants.COMMAND_SHOW_REFERENCES)); + withConfigurationUpdate ? + Arrays.asList(QuteClientCommandConstants.COMMAND_JAVA_DEFINITION, + QuteClientCommandConstants.COMMAND_SHOW_REFERENCES, + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE) : + Arrays.asList(QuteClientCommandConstants.COMMAND_JAVA_DEFINITION, + QuteClientCommandConstants.COMMAND_SHOW_REFERENCES)); commandCapabilities.setCommandKind(kinds); sharedSettings.getCommandCapabilities().setCapabilities(commandCapabilities); return sharedSettings; diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedNamespaceTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedNamespaceTest.java index cfc33ecf3..808785430 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedNamespaceTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedNamespaceTest.java @@ -16,6 +16,7 @@ import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.te; import static com.redhat.qute.QuteAssert.testCodeActionsFor; +import static com.redhat.qute.QuteAssert.testCodeActionsWithConfigurationUpdateFor; import static com.redhat.qute.QuteAssert.testDiagnosticsFor; import org.eclipse.lsp4j.Diagnostic; @@ -27,7 +28,8 @@ import com.redhat.qute.services.diagnostics.QuteErrorCode; /** - * Test code action for similar text suggestions for {@link QuteErrorCode#UndefinedNamespace}. + * Test code action for similar text suggestions for + * {@link QuteErrorCode#UndefinedNamespace}. * */ public class QuteCodeActionForSimilarTextSuggestionsForUndefinedNamespaceTest { @@ -42,12 +44,26 @@ public void similarTextSuggestionQuickFixForUndefinedNamespace() throws Exceptio testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(0, 1, 0, 5, "inject"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(0, 1, 0, 5, "inject")), // ca(d, c("Ignore `UndefinedNamespace` problem.", // QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // "qute.validation.undefinedNamespace.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); } @@ -60,13 +76,26 @@ public void noSimilarTextSuggestionQuickFixForUndefinedNamespace() throws Except DiagnosticSeverity.Warning); testDiagnosticsFor(template, d); - testCodeActionsFor(template, d, // + testCodeActionsFor(template, d); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, c("Ignore `UndefinedNamespace` problem.", // QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // "qute.validation.undefinedNamespace.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // - d))); + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } } diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedObjectTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedObjectTest.java index 6a7efe478..13900a52d 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedObjectTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUndefinedObjectTest.java @@ -16,6 +16,7 @@ import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.te; import static com.redhat.qute.QuteAssert.testCodeActionsFor; +import static com.redhat.qute.QuteAssert.testCodeActionsWithConfigurationUpdateFor; import static com.redhat.qute.QuteAssert.testDiagnosticsFor; import org.eclipse.lsp4j.Diagnostic; @@ -45,6 +46,10 @@ public void similarTextSuggestionQuickFixForUndefinedObject() throws Exception { testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(1, 1, 1, 5, "string")), // + ca(d, te(0, 0, 0, 0, "{@java.lang.String stri}\r\n")), // + ca(d, te(1, 5, 1, 5, "??"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(1, 1, 1, 5, "string")), // ca(d, te(0, 0, 0, 0, "{@java.lang.String stri}\r\n")), // ca(d, te(1, 5, 1, 5, "??")), // @@ -53,7 +58,20 @@ public void similarTextSuggestionQuickFixForUndefinedObject() throws Exception { "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test @@ -68,6 +86,10 @@ public void similarTextSuggestionCenterQuickFixForUndefinedObject() throws Excep testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(1, 1, 1, 5, "string")), // + ca(d, te(0, 0, 0, 0, "{@java.lang.String trin}\r\n")), // + ca(d, te(1, 5, 1, 5, "??"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(1, 1, 1, 5, "string")), // ca(d, te(0, 0, 0, 0, "{@java.lang.String trin}\r\n")), // ca(d, te(1, 5, 1, 5, "??")), // @@ -76,7 +98,20 @@ public void similarTextSuggestionCenterQuickFixForUndefinedObject() throws Excep "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test @@ -90,6 +125,10 @@ public void notSmilarTextSuggestionQuickFixForUndefinedObject() throws Exception testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(0, 0, 0, 0, "{@java.lang.String abc}" + // + System.lineSeparator())), // + ca(d, te(0, 4, 0, 4, "??"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String abc}" + // System.lineSeparator())), // ca(d, te(0, 4, 0, 4, "??")), // @@ -98,7 +137,20 @@ public void notSmilarTextSuggestionQuickFixForUndefinedObject() throws Exception "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test @@ -116,6 +168,10 @@ public void smilarTextSuggestionQuickFixForUndefinedObjectInMethodPart() throws testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(2, 21, 2, 25, "index")), // + ca(d, te(0, 0, 0, 0, "{@java.lang.String inde}\r\n")), // + ca(d, te(2, 25, 2, 25, "??"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(2, 21, 2, 25, "index")), // ca(d, te(0, 0, 0, 0, "{@java.lang.String inde}\r\n")), // ca(d, te(2, 25, 2, 25, "??")), // @@ -124,7 +180,20 @@ public void smilarTextSuggestionQuickFixForUndefinedObjectInMethodPart() throws "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test @@ -140,6 +209,10 @@ public void similarTextSuggestionQuickFixForUndefinedObjectUsingLoopSectionMetad testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(2, 2, 2, 5, "item")), // + ca(d, te(0, 0, 0, 0, "{@java.lang.String ite}\r\n")), // + ca(d, te(2, 5, 2, 5, "??"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(2, 2, 2, 5, "item")), // ca(d, te(0, 0, 0, 0, "{@java.lang.String ite}\r\n")), // ca(d, te(2, 5, 2, 5, "??")), // @@ -148,6 +221,18 @@ public void similarTextSuggestionQuickFixForUndefinedObjectUsingLoopSectionMetad "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); } @@ -165,6 +250,11 @@ public void similarTextSuggestionQuickFixForUndefinedObjectUsingLoopSectionMetad testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(2, 2, 2, 5, "item")), // + ca(d, te(2, 2, 2, 5, "items")), // + ca(d, te(0, 0, 0, 0, "{@java.lang.String ite}\r\n")), // + ca(d, te(2, 5, 2, 5, "??"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(2, 2, 2, 5, "item")), // ca(d, te(2, 2, 2, 5, "items")), // ca(d, te(0, 0, 0, 0, "{@java.lang.String ite}\r\n")), // @@ -174,7 +264,19 @@ public void similarTextSuggestionQuickFixForUndefinedObjectUsingLoopSectionMetad "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // - d))); + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } } diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownMethodTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownMethodTest.java index 53475ca3c..42eff6344 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownMethodTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownMethodTest.java @@ -11,16 +11,20 @@ *******************************************************************************/ package com.redhat.qute.services.codeaction; +import static com.redhat.qute.QuteAssert.c; import static com.redhat.qute.QuteAssert.ca; import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.te; import static com.redhat.qute.QuteAssert.testCodeActionsFor; +import static com.redhat.qute.QuteAssert.testCodeActionsWithConfigurationUpdateFor; import static com.redhat.qute.QuteAssert.testDiagnosticsFor; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.DiagnosticSeverity; import org.junit.jupiter.api.Test; +import com.redhat.qute.ls.commons.client.ConfigurationItemEditType; +import com.redhat.qute.services.commands.QuteClientCommandConstants; import com.redhat.qute.services.diagnostics.JavaBaseTypeOfPartData; import com.redhat.qute.services.diagnostics.QuteErrorCode; @@ -45,6 +49,20 @@ public void similarTextSuggestionQuickFixForUndefinedMethod() throws Exception { testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // ca(d, te(1, 8, 1, 13, "charAt"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 8, 1, 13, "charAt")), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } @Test @@ -61,6 +79,20 @@ public void similarTextSuggestionQuickFixForUndefinedMethodWithResolver() throws testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // ca(d, te(1, 8, 1, 13, "orEmpty"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 8, 1, 13, "orEmpty")), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } @Test @@ -77,6 +109,20 @@ public void similarTextSuggestionQuickFixForUndefinedMethodFromExtendedType() th testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // ca(d, te(1, 6, 1, 12, "convert"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 6, 1, 12, "convert")), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } @Test @@ -92,6 +138,19 @@ public void noSimilarTextSuggestionQuickFixForUndefinedMethod() throws Exception testDiagnosticsFor(template, d); testCodeActionsFor(template, d); + testCodeActionsWithConfigurationUpdateFor(template, 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } @Test @@ -107,6 +166,21 @@ public void similarTextSuggestionQuickFixForUndefinedMethodWithNamespace() throw testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // ca(d, te(0, 10, 0, 15, "charAt"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(0, 10, 0, 15, "charAt")), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); + } @Test @@ -123,6 +197,20 @@ public void similarTextSuggestionQuickFixForUndefinedMethodFromClassWithCyclicIn testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // ca(d, te(1, 8, 1, 14, "convert"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 8, 1, 14, "convert")), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } } diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownPropertyTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownPropertyTest.java index 05ed48aac..294a13f4d 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownPropertyTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionForSimilarTextSuggestionsForUnknownPropertyTest.java @@ -11,11 +11,13 @@ *******************************************************************************/ package com.redhat.qute.services.codeaction; +import static com.redhat.qute.QuteAssert.c; import static com.redhat.qute.QuteAssert.ca; import static com.redhat.qute.QuteAssert.cad; import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.te; import static com.redhat.qute.QuteAssert.testCodeActionsFor; +import static com.redhat.qute.QuteAssert.testCodeActionsWithConfigurationUpdateFor; import static com.redhat.qute.QuteAssert.testDiagnosticsFor; import org.eclipse.lsp4j.Diagnostic; @@ -24,7 +26,9 @@ import com.redhat.qute.commons.GenerateMissingJavaMemberParams; import com.redhat.qute.commons.GenerateMissingJavaMemberParams.MemberType; +import com.redhat.qute.ls.commons.client.ConfigurationItemEditType; import com.redhat.qute.project.QuteQuickStartProject; +import com.redhat.qute.services.commands.QuteClientCommandConstants; import com.redhat.qute.services.diagnostics.JavaBaseTypeOfPartData; import com.redhat.qute.services.diagnostics.QuteErrorCode; @@ -61,6 +65,31 @@ public void similarWithJavaField() throws Exception { QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "nme", "org.acme.Item", QuteQuickStartProject.PROJECT_URI))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 6, 1, 9, "name")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Field, "nme", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Getter, "nme", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI, "org.acme.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "nme", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI)), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); + } @Test @@ -89,6 +118,30 @@ public void similarWithJavaMethod() throws Exception { "org.acme.Item", QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "avilable", "org.acme.Item", QuteQuickStartProject.PROJECT_URI))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 6, 1, 14, "available")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Field, "avilable", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Getter, "avilable", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "avilable", + "org.acme.Item", QuteQuickStartProject.PROJECT_URI, "org.acme.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "avilable", + "org.acme.Item", QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "avilable", + "org.acme.Item", QuteQuickStartProject.PROJECT_URI)), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } @Test @@ -118,6 +171,30 @@ public void similarWithResolver() throws Exception { "org.acme.Item", QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "discountedPrce", "org.acme.Item", QuteQuickStartProject.PROJECT_URI))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 6, 1, 20, "discountedPrice")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Field, "discountedPrce", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Getter, "discountedPrce", "org.acme.Item", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "discountedPrce", + "org.acme.Item", QuteQuickStartProject.PROJECT_URI, "org.acme.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "discountedPrce", + "org.acme.Item", QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "discountedPrce", + "org.acme.Item", QuteQuickStartProject.PROJECT_URI)), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } @Test @@ -140,12 +217,42 @@ public void similarWithJavaFieldWithClassWithCyclicInheritance() throws Exceptio QuteQuickStartProject.PROJECT_URI)), // cad(d, new GenerateMissingJavaMemberParams(MemberType.Getter, "nme", "org.acme.qute.cyclic.ClassA", QuteQuickStartProject.PROJECT_URI)), // - cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", "org.acme.qute.cyclic.ClassA", + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", + "org.acme.qute.cyclic.ClassA", QuteQuickStartProject.PROJECT_URI, "org.acme.TemplateExtensions")), // - cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", "org.acme.qute.cyclic.ClassA", + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", + "org.acme.qute.cyclic.ClassA", QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // - cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "nme", "org.acme.qute.cyclic.ClassA", + cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "nme", + "org.acme.qute.cyclic.ClassA", QuteQuickStartProject.PROJECT_URI))); + testCodeActionsWithConfigurationUpdateFor(template, d, // + ca(d, te(1, 8, 1, 11, "name")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Field, "nme", "org.acme.qute.cyclic.ClassA", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.Getter, "nme", "org.acme.qute.cyclic.ClassA", + QuteQuickStartProject.PROJECT_URI)), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", + "org.acme.qute.cyclic.ClassA", + QuteQuickStartProject.PROJECT_URI, "org.acme.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.AppendTemplateExtension, "nme", + "org.acme.qute.cyclic.ClassA", + QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // + cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "nme", + "org.acme.qute.cyclic.ClassA", + QuteQuickStartProject.PROJECT_URI)), + ca(d, c("Exclude this file from validation.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.excluded", // + "test.qute", // + ConfigurationItemEditType.add, "test.qute", // + d)), + ca(d, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } } diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionWithSettingsTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionWithSettingsTest.java index bd7df0261..b8a7b5691 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionWithSettingsTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteCodeActionWithSettingsTest.java @@ -16,6 +16,7 @@ import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.te; import static com.redhat.qute.QuteAssert.testCodeActionsFor; +import static com.redhat.qute.QuteAssert.testCodeActionsWithConfigurationUpdateFor; import static com.redhat.qute.QuteAssert.testDiagnosticsFor; import java.util.Arrays; @@ -51,6 +52,10 @@ public void withoutDisableValidationQuickFixUndefinedObject() throws Exception { testDiagnosticsFor(template, d); testCodeActionsFor(template, d, // + ca(d, te(0, 0, 0, 0, "{@java.lang.String item}" + // + System.lineSeparator())), // + ca(d, te(0, 5, 0, 5, "??"))); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String item}" + // System.lineSeparator())), // ca(d, te(0, 5, 0, 5, "??")), // @@ -59,7 +64,20 @@ public void withoutDisableValidationQuickFixUndefinedObject() throws Exception { "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test @@ -72,13 +90,26 @@ public void withoutDisableValidationQuickFixUndefinedNamespace() throws Exceptio DiagnosticSeverity.Warning); testDiagnosticsFor(template, d); - testCodeActionsFor(template, d, // + testCodeActionsFor(template, d); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, c("Ignore `UndefinedNamespace` problem.", // QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // "qute.validation.undefinedNamespace.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // - d))); + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // + d))); } @Test diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteGenerateMissingMemberCodeActionTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteGenerateMissingMemberCodeActionTest.java index c9a0ee10b..7116a3b39 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteGenerateMissingMemberCodeActionTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/codeaction/QuteGenerateMissingMemberCodeActionTest.java @@ -11,6 +11,8 @@ *******************************************************************************/ package com.redhat.qute.services.codeaction; +import static com.redhat.qute.QuteAssert.c; +import static com.redhat.qute.QuteAssert.ca; import static com.redhat.qute.QuteAssert.cad; import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.testCodeActionsFor; @@ -26,9 +28,11 @@ import com.redhat.qute.commons.GenerateMissingJavaMemberParams; import com.redhat.qute.commons.GenerateMissingJavaMemberParams.MemberType; +import com.redhat.qute.ls.commons.client.ConfigurationItemEditType; import com.redhat.qute.project.QuteQuickStartProject; import com.redhat.qute.services.codeactions.CodeActionResolverKind; import com.redhat.qute.services.codeactions.CodeActionUnresolvedData; +import com.redhat.qute.services.commands.QuteClientCommandConstants; import com.redhat.qute.services.diagnostics.JavaBaseTypeOfPartData; import com.redhat.qute.services.diagnostics.QuteErrorCode; import com.redhat.qute.settings.SharedSettings; @@ -58,6 +62,7 @@ public void userGeneratedClass() throws Exception { QuteQuickStartProject.PROJECT_URI, "org.acme.foo.TemplateExtensions")), // cad(d, new GenerateMissingJavaMemberParams(MemberType.CreateTemplateExtension, "asdf", "org.acme.Item", QuteQuickStartProject.PROJECT_URI))); + } @Test diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionTest.java index a0605908d..38e6a57ef 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionTest.java @@ -16,6 +16,7 @@ import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.te; import static com.redhat.qute.QuteAssert.testCodeActionsFor; +import static com.redhat.qute.QuteAssert.testCodeActionsWithConfigurationUpdateFor; import static com.redhat.qute.QuteAssert.testDiagnosticsFor; import org.eclipse.lsp4j.Diagnostic; @@ -63,13 +64,7 @@ public void booleanLiteral() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String trueX}" + // System.lineSeparator())), // - ca(d, te(0, 6, 0, 6, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 6, 0, 6, "??"))); template = "{false}"; testDiagnosticsFor(template); @@ -82,13 +77,7 @@ public void booleanLiteral() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String falseX}" + // System.lineSeparator())), // - ca(d, te(0, 7, 0, 7, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 7, 0, 7, "??"))); } @Test @@ -104,13 +93,7 @@ public void nullLiteral() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String nullX}" + // System.lineSeparator())), // - ca(d, te(0, 6, 0, 6, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 6, 0, 6, "??"))); } @Test @@ -135,13 +118,7 @@ public void integerLiteral() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String 123X}" + // System.lineSeparator())), // - ca(d, te(0, 5, 0, 5, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 5, 0, 5, "??"))); } @Test @@ -157,13 +134,7 @@ public void longLiteral() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String 123LX}" + // System.lineSeparator())), // - ca(d, te(0, 6, 0, 6, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 6, 0, 6, "??"))); } @Test @@ -179,13 +150,7 @@ public void undefinedObject() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String item}" + // System.lineSeparator())), // - ca(d, te(0, 5, 0, 5, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 5, 0, 5, "??"))); } @Test @@ -201,13 +166,7 @@ public void undefinedUnderscoreObject() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String nested-content}" + // System.lineSeparator())), // - ca(d, te(0, 15, 0, 15, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 15, 0, 15, "??"))); } @Test @@ -367,13 +326,7 @@ public void elvisOperator() throws Exception { testCodeActionsFor(template, d, // ca(d, te(0, 0, 0, 0, "{@java.lang.String person}" + // System.lineSeparator())), // - ca(d, te(0, 7, 0, 7, "??")), // - ca(d, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d))); + ca(d, te(0, 7, 0, 7, "??"))); } @Test @@ -390,12 +343,25 @@ public void undefineNamespace() throws Exception { Diagnostic d = d(1, 1, 1, 8, QuteErrorCode.UndefinedNamespace, "No namespace resolver found for: `dataXXX`.", DiagnosticSeverity.Warning); testDiagnosticsFor(template, d); - testCodeActionsFor(template, d, // + testCodeActionsFor(template, d); + testCodeActionsWithConfigurationUpdateFor(template, d, // ca(d, c("Ignore `UndefinedNamespace` problem.", // QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // "qute.validation.undefinedNamespace.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); } @@ -733,7 +699,8 @@ public void undefinedObjectPartWithKwownMethodResolver() throws Exception { testDiagnosticsFor(template, // d(0, 1, 0, 6, QuteErrorCode.UndefinedObject, "`items` cannot be resolved to an object.", DiagnosticSeverity.Warning), - d(0, 7, 0, 17, QuteErrorCode.UnknownMethod, "`getByIndex` cannot be resolved or is not a method of `null` Java type.", + d(0, 7, 0, 17, QuteErrorCode.UnknownMethod, + "`getByIndex` cannot be resolved or is not a method of `null` Java type.", DiagnosticSeverity.Error)); } } diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithForSectionTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithForSectionTest.java index 45669f63d..cc4354b31 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithForSectionTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithForSectionTest.java @@ -65,6 +65,18 @@ public void undefinedObjectInElseBlock() throws Exception { "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); } @@ -92,7 +104,20 @@ public void undefinedObject() throws Exception { "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithIfSectionTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithIfSectionTest.java index 02fa0c75e..26e1014d6 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithIfSectionTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithIfSectionTest.java @@ -11,7 +11,6 @@ *******************************************************************************/ package com.redhat.qute.services.diagnostics; -import static com.redhat.qute.QuteAssert.c; import static com.redhat.qute.QuteAssert.ca; import static com.redhat.qute.QuteAssert.d; import static com.redhat.qute.QuteAssert.te; @@ -22,9 +21,6 @@ import org.eclipse.lsp4j.DiagnosticSeverity; import org.junit.jupiter.api.Test; -import com.redhat.qute.ls.commons.client.ConfigurationItemEditType; -import com.redhat.qute.services.commands.QuteClientCommandConstants; - /** * Test with #if section * @@ -63,22 +59,7 @@ public void undefinedObject() throws Exception { testDiagnosticsFor(template, d1, d2); testCodeActionsFor(template, d1, // ca(d1, te(0, 0, 0, 0, "{@java.lang.String item}\r\n")), // - ca(d1, te(0, 9, 0, 9, "??")), // - ca(d1, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d1))); - testCodeActionsFor(template, d2, // - ca(d2, te(0, 0, 0, 0, "{@java.lang.String item}\r\n")), // - ca(d2, te(0, 28, 0, 28, "??")), // - ca(d2, c("Ignore `UndefinedObject` problem.", // - QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // - "qute.validation.undefinedObject.severity", // - "test.qute", // - ConfigurationItemEditType.update, "ignore", // - d2))); + ca(d1, te(0, 9, 0, 9, "??"))); } @Test diff --git a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithLetSectionTest.java b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithLetSectionTest.java index 3706b442f..4779f776b 100644 --- a/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithLetSectionTest.java +++ b/qute.ls/com.redhat.qute.ls/src/test/java/com/redhat/qute/services/diagnostics/QuteDiagnosticsInExpressionWithLetSectionTest.java @@ -77,7 +77,20 @@ public void undefinedObject() throws Exception { "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test @@ -105,7 +118,20 @@ public void autoClose() throws Exception { "qute.validation.undefinedObject.severity", // "test.qute", // ConfigurationItemEditType.update, "ignore", // + 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, c("Disable Qute validation for the `qute-quickstart` project.", // + QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, // + "qute.validation.enabled", // + "test.qute", // + ConfigurationItemEditType.update, false, // d))); + } @Test