diff --git a/microprofile.ls/README.md b/microprofile.ls/README.md index 49081518c..c258acfab 100644 --- a/microprofile.ls/README.md +++ b/microprofile.ls/README.md @@ -50,13 +50,24 @@ Here are some clients consuming the MicroProfile language server: * Eclipse with [quarkus-lsp4e (POC)](https://github.com/angelozerr/quarkus-lsp4e) * IntelliJ with [intellij-quarkus](https://github.com/jeffmaury/intellij-quarkus) * Visual Studio Code with [vscode-quarkus](https://github.com/redhat-developer/vscode-quarkus) - -Code Snippets + +LSPMP - LS - extensions ------- +The MicroProfile language server can be extensable: + + * to add your own [code snippets](#code-snippets). + * to manage [complex properties](#managing-complex-properties). + * to [contribute to settings](#contribute-to-settings). + +Those contribution must be hosted in an external JAR and must be added in the MicroProfile language server classpath. +If you are using [vscode-microprofile](https://github.com/redhat-developer/vscode-microprofile), see the [Contributing to properties and Java support](https://github.com/redhat-developer/vscode-microprofile#contributing-to-properties-and-java-support) section. + +## Code Snippets + Java and properties completion snippets are managed by the MicroProfile LS (snippets on server side) by using Java SPI. -## Describing snippets in JSON +### Describing snippets in JSON `Snippets` are described in JSON files using the [vscode snippet format](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets). @@ -98,14 +109,14 @@ means that the snippet is shown only if the project has the `quarkus.datasource. means that the snippet is shown only if the project has the `org.eclipse.microprofile.openapi.annotations.Operation` Java Annotation in the classpath. In other words, only when the Java project has a dependency on MicroProfile Open API. -## Adding new internal snippets +### Adding new internal snippets To register a snippet, it must be added in: * [MicroProfileJavaSnippetRegistryLoader](https://github.com/eclipse/lsp4mp/blob/master/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/MicroProfileJavaSnippetRegistryLoader.java) if the new snippet is for Java files. * [MicroProfilePropertiesSnippetRegistryLoader](https://github.com/eclipse/lsp4mp/blob/master/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/MicroProfilePropertiesSnippetRegistryLoader.java) if the new snippet is for properties files. -## Adding new external snippets +### Adding new external snippets To add external snippets (like Quarkus snippets) an implementation of `ISnippetRegistryLoader` must be created and registered with Java SPI. See for the [quarkus.ls.ext](https://github.com/redhat-developer/quarkus-ls/tree/master/quarkus.ls.ext) for Quarkus snippets: @@ -113,8 +124,7 @@ To add external snippets (like Quarkus snippets) an implementation of `ISnippetR * [JSON Quarkus snippet](https://github.com/redhat-developer/quarkus-ls/tree/master/quarkus.ls.ext/com.redhat.quarkus.ls/src/main/resources/com/redhat/quarkus/snippets). * Java Quarkus snippets loader must be declared in [META-INF/services/org.eclipse.lsp4mp.ls.commons.snippets.ISnippetRegistryLoader](https://github.com/redhat-developer/quarkus-ls/blob/master/quarkus.ls.ext/com.redhat.quarkus.ls/src/main/resources/META-INF/services/org.eclipse.lsp4mp.ls.commons.snippets.ISnippetRegistryLoader) - Managing complex properties -------- +## Managing complex properties The properties available in `microprofile-config.properties` come from the external component (ex: MicroProfile JDT LS extension). In some case a property cannot be computed on the external component and must be computed on MicroProfile LS side. @@ -134,6 +144,27 @@ In other words, `mp.messaging.outgoing.generated-price.topic` exists only if there is the declaration `mp.messaging.outgoing.generated-price.connector=smallrye-kafka` The `mp.messaging.outgoing.generated-price.topic` property cannot be computed on the external component side because it depends on the value of -`mp.messaging.outgoing.generated-price.connector`. The comput tion is done on MicroProfile LS side with custom builder by using Java SPI [ItemMetadataProviderFactory](/src/main/java/org/eclipse/lsp4mp/extensions/ItemMetadataProviderFactory). +`mp.messaging.outgoing.generated-price.connector`. The computation is done on MicroProfile LS side with custom builder by using Java SPI [ItemMetadataProviderFactory](https://github.com/eclipse/lsp4mp/blob/master/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/extensions/ItemMetadataProviderFactory.java). + +Please see the [sample of MicroProfile Reactive Messaging](https://github.com/eclipse/lsp4mp/blob/master/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/extensions/reactivemessaging). + +## Contribute to settings + +In microprofile-config.properties file when a property doesn't exists, there is an unkwown error. The user can configure which unknown property errors to hide in the client settings. +It's possible to ignore this error with contribution (ex : camel toolings can ignore validation for all `camel.*` properties). + +To do that in the JAR extension, create the `META-INF/lsp4mp/settings.json` like this: + +```json +{ + "validation": { + "unknown": { + "excluded": [ + "camel.*" + ] + } + } +} +``` -Please see the [sample of MicroProfile Reactive Messaging](/src/main/java/org/eclipse/lsp4mp/extensions/reactivemessaging). \ No newline at end of file +In this sample all camel properties will be ignored during the validation. \ No newline at end of file diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServer.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServer.java index 9b2724716..dad6ce518 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServer.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServer.java @@ -42,6 +42,7 @@ import org.eclipse.lsp4mp.settings.AllMicroProfileSettings; import org.eclipse.lsp4mp.settings.InitializationOptionsSettings; import org.eclipse.lsp4mp.settings.MicroProfileCodeLensSettings; +import org.eclipse.lsp4mp.settings.MicroProfileExtensionSettings; import org.eclipse.lsp4mp.settings.MicroProfileFormattingSettings; import org.eclipse.lsp4mp.settings.MicroProfileGeneralClientSettings; import org.eclipse.lsp4mp.settings.MicroProfileSymbolSettings; @@ -62,6 +63,8 @@ public class MicroProfileLanguageServer implements LanguageServer, ProcessLangua private final MicroProfileTextDocumentService textDocumentService; private final WorkspaceService workspaceService; + private final MicroProfileExtensionSettings extensionSettings; + private Integer parentProcessId; private MicroProfileLanguageClientAPI languageClient; private MicroProfileCapabilityManager capabilityManager; @@ -70,6 +73,7 @@ public MicroProfileLanguageServer() { microProfileLanguageService = new MicroProfileLanguageService(); textDocumentService = new MicroProfileTextDocumentService(this); workspaceService = new MicroProfileWorkspaceService(this); + this.extensionSettings = new MicroProfileExtensionSettings(); } @Override @@ -120,6 +124,8 @@ public synchronized void updateSettings(Object initializationOptionsSettings) { MicroProfileGeneralClientSettings clientSettings = MicroProfileGeneralClientSettings .getGeneralMicroProfileSettings(initializationOptionsSettings); if (clientSettings != null) { + // Merge client settings with extension settings + extensionSettings.merge(clientSettings); MicroProfileSymbolSettings newSymbols = clientSettings.getSymbols(); if (newSymbols != null) { textDocumentService.updateSymbolSettings(newSymbols); diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/MicroProfileExtensionSettings.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/MicroProfileExtensionSettings.java new file mode 100644 index 000000000..1fd1d8315 --- /dev/null +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/MicroProfileExtensionSettings.java @@ -0,0 +1,160 @@ +/******************************************************************************* +* Copyright (c) 2020 Red Hat Inc. and others. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v. 2.0 which is available at +* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +* which is available at https://www.apache.org/licenses/LICENSE-2.0. +* +* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +* +* Contributors: +* Red Hat Inc. - initial API and implementation +*******************************************************************************/ +package org.eclipse.lsp4mp.settings; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.lsp4mp.services.ValidationType; + +import com.google.gson.Gson; + +/** + * Contribute to {@link MicroProfileGeneralClientSettings} with extension. + * + */ +public class MicroProfileExtensionSettings { + + private static final Logger LOGGER = Logger.getLogger(MicroProfileExtensionSettings.class.getName()); + + private static final String SETTINGS_JSON = "META-INF/lsp4mp/settings.json"; + private List extensionSettings; + + /** + * Merge the settings from list of {@link MicroProfileGeneralClientSettings} + * loaded from "META-INF/lsp4mp/settings.json" files included in the classpath. + * + *

+ * The merge takes only excluded validation for unknown property. + *

+ * + * @param settings + */ + public void merge(MicroProfileGeneralClientSettings settings) { + getExtensionSettings().forEach(extensionSettings -> { + merge(settings, extensionSettings); + }); + } + + /** + * + * @param settings + * @param extensionSettings + */ + private void merge(MicroProfileGeneralClientSettings settings, + MicroProfileGeneralClientSettings extensionSettings) { + // Merge validation unknown excluded + List extensionValidationUnknownExcluded = getValidationExcluded(extensionSettings, + ValidationType.unknown, false); + if (extensionValidationUnknownExcluded != null && !extensionValidationUnknownExcluded.isEmpty()) { + List validationUnknownExcluded = getValidationExcluded(settings, ValidationType.unknown, true); + merge(extensionValidationUnknownExcluded, validationUnknownExcluded); + } + } + + private void merge(List from, List to) { + for (String value : from) { + if (!to.contains(value)) { + to.add(value); + } + } + } + + private static List getValidationExcluded(MicroProfileGeneralClientSettings settings, ValidationType type, + boolean create) { + MicroProfileValidationSettings validation = settings.getValidation(); + if (validation == null && create) { + validation = new MicroProfileValidationSettings(); + settings.setValidation(validation); + } + if (validation == null) { + return null; + } + MicroProfileValidationTypeSettings validationType = null; + switch (type) { + case unknown: + validationType = validation.getUnknown(); + if (validationType == null && create) { + validationType = new MicroProfileValidationTypeSettings(); + validation.setUnknown(validationType); + } + break; + default: + break; + } + if (validationType == null) { + return null; + } + List excluded = validationType.getExcluded(); + if (excluded == null && create) { + excluded = new ArrayList<>(); + validationType.setExcluded(excluded); + } + return excluded; + } + + /** + * Returns the list of {@link MicroProfileGeneralClientSettings} loaded from + * "META-INF/lsp4mp/settings.json" files included in the classpath. + * + * @return the list of {@link MicroProfileGeneralClientSettings} loaded from + * "META-INF/lsp4mp/settings.json" files included in the classpath + */ + public List getExtensionSettings() { + if (extensionSettings == null) { + extensionSettings = loadExtensionSettings(); + } + return extensionSettings; + } + + /** + * Load all "META-INF/lsp4mp/settings.json" files from the classpath. + * + * @return list of {@link MicroProfileGeneralClientSettings}. + */ + private synchronized List loadExtensionSettings() { + if (extensionSettings != null) { + return extensionSettings; + } + List extensionSettings = new ArrayList<>(); + try { + URL url = null; + Enumeration resources = this.getClass().getClassLoader().getResources(SETTINGS_JSON); + while (resources.hasMoreElements()) { + try { + url = resources.nextElement(); + MicroProfileGeneralClientSettings settings = new Gson().fromJson( + new InputStreamReader((InputStream) url.getContent()), + MicroProfileGeneralClientSettings.class); + extensionSettings.add(settings); + } catch (Exception e) { + LOGGER.log(Level.SEVERE, + "Error while loading settings extension from '" + url != null ? url.toExternalForm() + : SETTINGS_JSON + "'", + e); + } + } + } catch (IOException e) { + LOGGER.log(Level.SEVERE, "Error while loading settings extensions '" + SETTINGS_JSON + "'", e); + } + return extensionSettings; + } +} diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/MicroProfileValidationTypeSettings.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/MicroProfileValidationTypeSettings.java index 092ec0fd0..4cd1a0376 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/MicroProfileValidationTypeSettings.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/MicroProfileValidationTypeSettings.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.eclipse.lsp4j.DiagnosticSeverity; import org.eclipse.lsp4mp.utils.AntPathMatcher; @@ -30,7 +29,7 @@ public class MicroProfileValidationTypeSettings { private String severity; - private String[] excluded; + private List excluded; private transient List excludedProperties; @@ -87,7 +86,7 @@ public void setSeverity(String severity) { * * @return the array of properties to ignore for this validation type. */ - public String[] getExcluded() { + public List getExcluded() { return excluded; } @@ -96,7 +95,7 @@ public String[] getExcluded() { * * @param excluded the array of properties to ignore for this validation type. */ - public void setExcluded(String[] excluded) { + public void setExcluded(List excluded) { this.excluded = excluded; } @@ -170,7 +169,7 @@ private synchronized List createExcludedProperties() { } AntPathMatcher matcher = new AntPathMatcher(); matcher.setCachePatterns(true); - return Stream.of(excluded) // + return excluded.stream() // .map(p -> new ExcludedProperty(p, matcher)) // .collect(Collectors.toList()); } diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDiagnosticsTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDiagnosticsTest.java index b2ca2a172..a3e9954c8 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDiagnosticsTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDiagnosticsTest.java @@ -59,7 +59,7 @@ public void validateUnknownProperties() throws BadLocationException { d(8, 0, 16, "Unknown property 'unknown.property'", DiagnosticSeverity.Warning, ValidationType.unknown), // d(10, 0, 53, "Unknown property 'quarkus.log.category.XXXXXXXXXXXXX.YYYYYYYYYYYY.level'", DiagnosticSeverity.Warning, ValidationType.unknown)); - }; + } @Test public void validateUnknownPropertyMissingEquals() throws BadLocationException { @@ -74,7 +74,7 @@ public void validateUnknownPropertyMissingEquals() throws BadLocationException { d(0, 0, 16, "Missing equals sign after 'unknown.property'", DiagnosticSeverity.Error, ValidationType.syntax), d(0, 0, 16, "Unknown property 'unknown.property'", DiagnosticSeverity.Warning, ValidationType.unknown)); - }; + } @Test public void validateUnknownPropertiesAsError() throws BadLocationException { @@ -104,7 +104,7 @@ public void validateUnknownPropertiesAsError() throws BadLocationException { d(8, 0, 16, "Unknown property 'unknown.property'", DiagnosticSeverity.Error, ValidationType.unknown), // d(10, 0, 53, "Unknown property 'quarkus.log.category.XXXXXXXXXXXXX.YYYYYYYYYYYY.level'", DiagnosticSeverity.Error, ValidationType.unknown)); - }; + } @Test public void validateUnknownPropertiesExcluded() throws BadLocationException { @@ -128,13 +128,13 @@ public void validateUnknownPropertiesExcluded() throws BadLocationException { MicroProfileValidationSettings settings = new MicroProfileValidationSettings(); MicroProfileValidationTypeSettings unknown = new MicroProfileValidationTypeSettings(); unknown.setSeverity("error"); - unknown.setExcluded(new String[] { "unknown.property" }); + unknown.setExcluded(Arrays.asList("unknown.property")); settings.setUnknown(unknown); testDiagnosticsFor(value, 1, getDefaultMicroProfileProjectInfo(), settings, d(10, 0, 53, "Unknown property 'quarkus.log.category.XXXXXXXXXXXXX.YYYYYYYYYYYY.level'", DiagnosticSeverity.Error, ValidationType.unknown)); - }; + } @Test public void validateUnknownPropertiesExcludedWithPattern() throws BadLocationException { @@ -149,18 +149,16 @@ public void validateUnknownPropertiesExcludedWithPattern() throws BadLocationExc // */mp-rest/url pattern --> only // com.mycompany.remoteServices.MyServiceClient/mp-rest/url is ignored - unknown.setExcluded(new String[] { "*/mp-rest/url" }); + unknown.setExcluded(Arrays.asList("*/mp-rest/url")); testDiagnosticsFor(value, 2, getDefaultMicroProfileProjectInfo(), settings, d(1, 0, 56, "Unknown property 'com.mycompany.remoteServices.MyServiceClient/mp-rest/uri'", DiagnosticSeverity.Error, ValidationType.unknown), - d(2, 0, 17, "Unknown property 'com.mycompany.foo'", - DiagnosticSeverity.Error, ValidationType.unknown)); + d(2, 0, 17, "Unknown property 'com.mycompany.foo'", DiagnosticSeverity.Error, ValidationType.unknown)); // */mp-rest/* pattern --> all errors containing path 'mp-rest' are ignored - unknown.setExcluded(new String[] { "*/mp-rest/*" }); + unknown.setExcluded(Arrays.asList("*/mp-rest/*")); testDiagnosticsFor(value, 1, getDefaultMicroProfileProjectInfo(), settings, - d(2, 0, 17, "Unknown property 'com.mycompany.foo'", - DiagnosticSeverity.Error, ValidationType.unknown)); + d(2, 0, 17, "Unknown property 'com.mycompany.foo'", DiagnosticSeverity.Error, ValidationType.unknown)); value = "com.mycompany.remoteServices.MyServiceClient/mp-rest/url/foo=url\n" + // "com.mycompany.remoteServices.MyServiceClient/mp-rest/uri/bar=uri\n" + // @@ -169,22 +167,22 @@ public void validateUnknownPropertiesExcludedWithPattern() throws BadLocationExc "com.mycompany.foo=bar"; // com.mycompany.* pattern --> all errors are ignored - unknown.setExcluded(new String[] { "com.mycompany.*" }); + unknown.setExcluded(Arrays.asList("com.mycompany.*")); testDiagnosticsFor(value, 0, getDefaultMicroProfileProjectInfo(), settings); - // com.mycompany.remoteServices.MyServiceClient/**/ --> all 'MyServiceClient' errors are ignored - unknown.setExcluded(new String[] { "com.mycompany.remoteServices.MyServiceClient/**/" }); + // com.mycompany.remoteServices.MyServiceClient/**/ --> all 'MyServiceClient' + // errors are ignored + unknown.setExcluded(Arrays.asList("com.mycompany.remoteServices.MyServiceClient/**/")); testDiagnosticsFor(value, 3, getDefaultMicroProfileProjectInfo(), settings, d(2, 0, 58, "Unknown property 'com.mycompany.remoteServices.MyOtherClient/mp-rest/url/foo'", DiagnosticSeverity.Error, ValidationType.unknown), d(3, 0, 58, "Unknown property 'com.mycompany.remoteServices.MyOtherClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), - d(4, 0, 17, "Unknown property 'com.mycompany.foo'", - DiagnosticSeverity.Error, ValidationType.unknown)); + d(4, 0, 17, "Unknown property 'com.mycompany.foo'", DiagnosticSeverity.Error, ValidationType.unknown)); // com.mycompany.remoteServices.MyServiceClient/**/foo --> all errors // for 'MyServiceClient' properties ending with path 'foo' are ignored - unknown.setExcluded(new String[] { "com.mycompany.remoteServices.MyServiceClient/**/foo" }); + unknown.setExcluded(Arrays.asList("com.mycompany.remoteServices.MyServiceClient/**/foo")); testDiagnosticsFor(value, 4, getDefaultMicroProfileProjectInfo(), settings, d(1, 0, 60, "Unknown property 'com.mycompany.remoteServices.MyServiceClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), @@ -192,23 +190,21 @@ public void validateUnknownPropertiesExcludedWithPattern() throws BadLocationExc DiagnosticSeverity.Error, ValidationType.unknown), d(3, 0, 58, "Unknown property 'com.mycompany.remoteServices.MyOtherClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), - d(4, 0, 17, "Unknown property 'com.mycompany.foo'", - DiagnosticSeverity.Error, ValidationType.unknown)); + d(4, 0, 17, "Unknown property 'com.mycompany.foo'", DiagnosticSeverity.Error, ValidationType.unknown)); // com.mycompany.*/**/foo --> all errors for properties // ending with path 'foo' are ignored - unknown.setExcluded(new String[] { "com.mycompany.*/**/foo" }); + unknown.setExcluded(Arrays.asList("com.mycompany.*/**/foo")); testDiagnosticsFor(value, 3, getDefaultMicroProfileProjectInfo(), settings, d(1, 0, 60, "Unknown property 'com.mycompany.remoteServices.MyServiceClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), d(3, 0, 58, "Unknown property 'com.mycompany.remoteServices.MyOtherClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), - d(4, 0, 17, "Unknown property 'com.mycompany.foo'", - DiagnosticSeverity.Error, ValidationType.unknown)); + d(4, 0, 17, "Unknown property 'com.mycompany.foo'", DiagnosticSeverity.Error, ValidationType.unknown)); // com*MyService*/**/foo --> all errors for 'MyService' properties // ending with path 'foo' are ignored - unknown.setExcluded(new String[] { "com*MyService*/**/foo" }); + unknown.setExcluded(Arrays.asList("com*MyService*/**/foo")); testDiagnosticsFor(value, 4, getDefaultMicroProfileProjectInfo(), settings, d(1, 0, 60, "Unknown property 'com.mycompany.remoteServices.MyServiceClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), @@ -216,11 +212,10 @@ public void validateUnknownPropertiesExcludedWithPattern() throws BadLocationExc DiagnosticSeverity.Error, ValidationType.unknown), d(3, 0, 58, "Unknown property 'com.mycompany.remoteServices.MyOtherClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), - d(4, 0, 17, "Unknown property 'com.mycompany.foo'", - DiagnosticSeverity.Error, ValidationType.unknown)); + d(4, 0, 17, "Unknown property 'com.mycompany.foo'", DiagnosticSeverity.Error, ValidationType.unknown)); // *foo --> all errors ending with 'foo' are ignored - unknown.setExcluded(new String[] { "*foo" }); + unknown.setExcluded(Arrays.asList("*foo")); testDiagnosticsFor(value, 2, getDefaultMicroProfileProjectInfo(), settings, d(1, 0, 60, "Unknown property 'com.mycompany.remoteServices.MyServiceClient/mp-rest/uri/bar'", DiagnosticSeverity.Error, ValidationType.unknown), @@ -228,10 +223,10 @@ public void validateUnknownPropertiesExcludedWithPattern() throws BadLocationExc DiagnosticSeverity.Error, ValidationType.unknown)); // * pattern --> all errors are ignored - unknown.setExcluded(new String[] { "*" }); + unknown.setExcluded(Arrays.asList("*")); testDiagnosticsFor(value, 0, getDefaultMicroProfileProjectInfo(), settings); - }; + } @Test public void validateUnknownPropertiesWithProfileExcludedWithPattern() throws BadLocationException { @@ -246,9 +241,9 @@ public void validateUnknownPropertiesWithProfileExcludedWithPattern() throws Bad settings.setUnknown(unknown); // kafka-streams.* --> properties for a profile are ignored - unknown.setExcluded(new String[] { "kafka-streams.*" }); + unknown.setExcluded(Arrays.asList("kafka-streams.*")); testDiagnosticsFor(value, 0, getDefaultMicroProfileProjectInfo(), settings); - }; + } @Test public void validateSyntaxMissingEquals() throws BadLocationException { @@ -263,7 +258,7 @@ public void validateSyntaxMissingEquals() throws BadLocationException { ValidationType.syntax), // d(2, 0, 27, "Missing equals sign after 'quarkus.datasource.username'", DiagnosticSeverity.Error, ValidationType.syntax)); - }; + } @Test public void validateSyntaxMissingEqualsComment() throws BadLocationException { @@ -275,7 +270,7 @@ public void validateSyntaxMissingEqualsComment() throws BadLocationException { testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings, d(1, 0, 24, "Missing equals sign after 'quarkus.application.name'", DiagnosticSeverity.Error, ValidationType.syntax)); - }; + } @Test public void validateDuplicateProperty() throws BadLocationException { @@ -292,7 +287,7 @@ public void validateDuplicateProperty() throws BadLocationException { ValidationType.duplicate), d(3, 0, 17, "Duplicate property 'quarkus.http.port'", DiagnosticSeverity.Warning, ValidationType.duplicate)); - }; + } @Test public void validateDuplicateProperties() throws BadLocationException { @@ -313,7 +308,7 @@ public void validateDuplicateProperties() throws BadLocationException { ValidationType.duplicate), d(5, 0, 17, "Duplicate property 'quarkus.http.port'", DiagnosticSeverity.Warning, ValidationType.duplicate)); - }; + } @Test public void validateDifferentDuplicateProperties() throws BadLocationException { @@ -339,7 +334,7 @@ public void validateDifferentDuplicateProperties() throws BadLocationException { ValidationType.duplicate), d(4, 0, 17, "Duplicate property 'quarkus.http.port'", DiagnosticSeverity.Warning, ValidationType.duplicate)); - }; + } @Test public void validateDuplicatePropertyDifferentProfile() throws BadLocationException { @@ -352,7 +347,7 @@ public void validateDuplicatePropertyDifferentProfile() throws BadLocationExcept MicroProfileValidationSettings settings = new MicroProfileValidationSettings(); testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings); - }; + } @Test public void validateDuplicatePropertySameProfile() throws BadLocationException { @@ -368,7 +363,7 @@ public void validateDuplicatePropertySameProfile() throws BadLocationException { ValidationType.duplicate), d(2, 0, 22, "Duplicate property '%dev.quarkus.http.port'", DiagnosticSeverity.Warning, ValidationType.duplicate)); - }; + } @Test public void validateEnumValueNoError() throws BadLocationException { @@ -378,7 +373,7 @@ public void validateEnumValueNoError() throws BadLocationException { MicroProfileValidationSettings settings = new MicroProfileValidationSettings(); testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings); - }; + } @Test public void validateEnumValueError() throws BadLocationException { @@ -393,7 +388,7 @@ public void validateEnumValueError() throws BadLocationException { d(1, 34, 39, "Invalid enum value: 'error' is invalid for type org.jboss.logmanager.handlers.AsyncHandler.OverflowAction", DiagnosticSeverity.Error, ValidationType.value)); - }; + } @Test public void validateIntValueNoError() throws BadLocationException { @@ -405,7 +400,7 @@ public void validateIntValueNoError() throws BadLocationException { MicroProfileValidationSettings settings = new MicroProfileValidationSettings(); testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings); - }; + } @Test public void validateIntValueError() throws BadLocationException { @@ -453,12 +448,16 @@ public void validateBooleanError() throws BadLocationException { MicroProfileValidationSettings settings = new MicroProfileValidationSettings(); testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings, - d(0, 23, 30, "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'", DiagnosticSeverity.Error, ValidationType.value), - d(1, 31, 35, "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'", DiagnosticSeverity.Error, ValidationType.value), - d(2, 21, 26, "Type mismatch: java.util.Optional expected. By default, this value will be interpreted as 'false'", DiagnosticSeverity.Error, - ValidationType.value), - d(3, 35, 38, "Type mismatch: java.lang.Boolean expected. By default, this value will be interpreted as 'false'", DiagnosticSeverity.Error, - ValidationType.value)); + d(0, 23, 30, "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'", + DiagnosticSeverity.Error, ValidationType.value), + d(1, 31, 35, "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'", + DiagnosticSeverity.Error, ValidationType.value), + d(2, 21, 26, + "Type mismatch: java.util.Optional expected. By default, this value will be interpreted as 'false'", + DiagnosticSeverity.Error, ValidationType.value), + d(3, 35, 38, + "Type mismatch: java.lang.Boolean expected. By default, this value will be interpreted as 'false'", + DiagnosticSeverity.Error, ValidationType.value)); } @Test @@ -537,14 +536,18 @@ public void validateBigDecimalError() throws BadLocationException { value = "quarkus.BigDecimal=hello world\n" + // "quarkus.Optional.BigDecimal=hello world"; testDiagnosticsFor(value, projectInfo, settings, - d(0, 19, 30, "Type mismatch: java.math.BigDecimal expected", DiagnosticSeverity.Error, ValidationType.value), - d(1, 28, 39, "Type mismatch: java.util.Optional expected", DiagnosticSeverity.Error, ValidationType.value)); + d(0, 19, 30, "Type mismatch: java.math.BigDecimal expected", DiagnosticSeverity.Error, + ValidationType.value), + d(1, 28, 39, "Type mismatch: java.util.Optional expected", + DiagnosticSeverity.Error, ValidationType.value)); value = "quarkus.BigDecimal=true\n" + // "quarkus.Optional.BigDecimal=true"; testDiagnosticsFor(value, projectInfo, settings, - d(0, 19, 23, "Type mismatch: java.math.BigDecimal expected", DiagnosticSeverity.Error, ValidationType.value), - d(1, 28, 32, "Type mismatch: java.util.Optional expected", DiagnosticSeverity.Error, ValidationType.value)); + d(0, 19, 23, "Type mismatch: java.math.BigDecimal expected", DiagnosticSeverity.Error, + ValidationType.value), + d(1, 28, 32, "Type mismatch: java.util.Optional expected", + DiagnosticSeverity.Error, ValidationType.value)); } @Test @@ -574,26 +577,34 @@ public void validateBigIntegerError() throws BadLocationException { value = "quarkus.BigInteger=hello world\n" + // "quarkus.Optional.BigInteger=hello world"; testDiagnosticsFor(value, projectInfo, settings, - d(0, 19, 30, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, ValidationType.value), - d(1, 28, 39, "Type mismatch: java.util.Optional expected", DiagnosticSeverity.Error, ValidationType.value)); + d(0, 19, 30, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, + ValidationType.value), + d(1, 28, 39, "Type mismatch: java.util.Optional expected", + DiagnosticSeverity.Error, ValidationType.value)); value = "quarkus.BigInteger=true\n" + // "quarkus.Optional.BigInteger=true"; testDiagnosticsFor(value, projectInfo, settings, - d(0, 19, 23, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, ValidationType.value), - d(1, 28, 32, "Type mismatch: java.util.Optional expected", DiagnosticSeverity.Error, ValidationType.value)); + d(0, 19, 23, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, + ValidationType.value), + d(1, 28, 32, "Type mismatch: java.util.Optional expected", + DiagnosticSeverity.Error, ValidationType.value)); value = "quarkus.BigInteger=3.14159\n" + // "quarkus.Optional.BigInteger=3.14159"; testDiagnosticsFor(value, projectInfo, settings, - d(0, 19, 26, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, ValidationType.value), - d(1, 28, 35, "Type mismatch: java.util.Optional expected", DiagnosticSeverity.Error, ValidationType.value)); + d(0, 19, 26, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, + ValidationType.value), + d(1, 28, 35, "Type mismatch: java.util.Optional expected", + DiagnosticSeverity.Error, ValidationType.value)); value = "quarkus.BigInteger=314.159e-2\n" + // "quarkus.Optional.BigInteger=314.159e-2"; testDiagnosticsFor(value, projectInfo, settings, - d(0, 19, 29, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, ValidationType.value), - d(1, 28, 38, "Type mismatch: java.util.Optional expected", DiagnosticSeverity.Error, ValidationType.value)); + d(0, 19, 29, "Type mismatch: java.math.BigInteger expected", DiagnosticSeverity.Error, + ValidationType.value), + d(1, 28, 38, "Type mismatch: java.util.Optional expected", + DiagnosticSeverity.Error, ValidationType.value)); } @Test @@ -603,9 +614,12 @@ public void validateBuildTimeInjectValues() throws BadLocationException { "quarkus.ssl.native= ${value-three}"; MicroProfileValidationSettings settings = new MicroProfileValidationSettings(); testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings, // - d(0, 22, 31, "Unknown referenced property 'value.one'", DiagnosticSeverity.Error, ValidationType.expression), // - d(1, 20, 29, "Unknown referenced property 'value_two'", DiagnosticSeverity.Error, ValidationType.expression), // - d(2, 25, 36, "Unknown referenced property 'value-three'", DiagnosticSeverity.Error, ValidationType.expression)); + d(0, 22, 31, "Unknown referenced property 'value.one'", DiagnosticSeverity.Error, + ValidationType.expression), // + d(1, 20, 29, "Unknown referenced property 'value_two'", DiagnosticSeverity.Error, + ValidationType.expression), // + d(2, 25, 36, "Unknown referenced property 'value-three'", DiagnosticSeverity.Error, + ValidationType.expression)); } @Test @@ -724,8 +738,8 @@ public void validateRegexPatternValue() { value = "mp.opentracing.server.skip-pattern=("; testDiagnosticsFor(value, projectInfo, settings, // - d(0, 35, 36, "Unclosed group near index 1" + ls + "(" + ls + "", - DiagnosticSeverity.Error, ValidationType.value)); + d(0, 35, 36, "Unclosed group near index 1" + ls + "(" + ls + "", DiagnosticSeverity.Error, + ValidationType.value)); value = "mp.opentracing.server.skip-pattern=["; testDiagnosticsFor(value, projectInfo, settings, // @@ -734,8 +748,8 @@ public void validateRegexPatternValue() { value = "mp.opentracing.server.skip-pattern=\\"; testDiagnosticsFor(value, projectInfo, settings, // - d(0, 35, 36, "Unexpected internal error near index 1" + ls + "\\" + ls + "", - DiagnosticSeverity.Error, ValidationType.value)); + d(0, 35, 36, "Unexpected internal error near index 1" + ls + "\\" + ls + "", DiagnosticSeverity.Error, + ValidationType.value)); value = "mp.opentracing.server.skip-pattern={"; @@ -746,29 +760,22 @@ public void validateRegexPatternValue() { message.append(ls).append("{").append(ls); testDiagnosticsFor(value, projectInfo, settings, // - d(0, 35, 36, message.toString(), - DiagnosticSeverity.Error, ValidationType.value)); + d(0, 35, 36, message.toString(), DiagnosticSeverity.Error, ValidationType.value)); } @Test public void validateMultilineKey() { - String value = "quarkus.\\\n" + - "application.\\\n" + - "name=name"; + String value = "quarkus.\\\n" + "application.\\\n" + "name=name"; MicroProfileValidationSettings settings = new MicroProfileValidationSettings(); testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings); - value = "quarkus.\\\r\n" + - "application.\\\r\n" + - "name=name"; + value = "quarkus.\\\r\n" + "application.\\\r\n" + "name=name"; testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings); - value = "qu.\\\n" + - "application.\\\n" + - "name=name"; + value = "qu.\\\n" + "application.\\\n" + "name=name"; testDiagnosticsFor(value, getDefaultMicroProfileProjectInfo(), settings, // - d(0, 0, 2, 4, "Unknown property 'qu.application.name'", - DiagnosticSeverity.Warning, ValidationType.unknown)); + d(0, 0, 2, 4, "Unknown property 'qu.application.name'", DiagnosticSeverity.Warning, + ValidationType.unknown)); } @Test @@ -785,7 +792,8 @@ public void undefinedPropertyInPropertyExpression() { String value = "test.property = ${doesnt.exist.property}"; testDiagnosticsFor(value, // d(0, 0, 13, "Unknown property 'test.property'", DiagnosticSeverity.Warning, ValidationType.unknown), // - d(0, 18, 39, "Unknown referenced property 'doesnt.exist.property'", DiagnosticSeverity.Error, ValidationType.expression)); + d(0, 18, 39, "Unknown referenced property 'doesnt.exist.property'", DiagnosticSeverity.Error, + ValidationType.expression)); } @Test @@ -810,7 +818,8 @@ public void validateUnknownPropertyInPropertyExpressionAndMissingBrace() { String value = "test.property = ${other.property"; testDiagnosticsFor(value, // d(0, 0, 13, "Unknown property 'test.property'", DiagnosticSeverity.Warning, ValidationType.unknown), // - d(0, 18, 32, "Unknown referenced property 'other.property'", DiagnosticSeverity.Error, ValidationType.expression), // + d(0, 18, 32, "Unknown referenced property 'other.property'", DiagnosticSeverity.Error, + ValidationType.expression), // d(0, 16, 32, "Missing '}'", DiagnosticSeverity.Error, ValidationType.syntax)); } @@ -823,11 +832,14 @@ public void validateMultipleInvalidPropertyExpressions() { testDiagnosticsFor(value, // d(0, 0, 12, "Unknown property 'property.one'", DiagnosticSeverity.Warning, ValidationType.unknown), // d(1, 0, 12, "Unknown property 'property.two'", DiagnosticSeverity.Warning, ValidationType.unknown), // - d(1, 17, 28, "Unknown referenced property 'property.on'", DiagnosticSeverity.Error, ValidationType.expression), // + d(1, 17, 28, "Unknown referenced property 'property.on'", DiagnosticSeverity.Error, + ValidationType.expression), // d(2, 0, 14, "Unknown property 'property.three'", DiagnosticSeverity.Warning, ValidationType.unknown), // - d(2, 19, 30, "Unknown referenced property 'property.tw'", DiagnosticSeverity.Error, ValidationType.expression), // + d(2, 19, 30, "Unknown referenced property 'property.tw'", DiagnosticSeverity.Error, + ValidationType.expression), // d(3, 0, 13, "Unknown property 'property.four'", DiagnosticSeverity.Warning, ValidationType.unknown), // - d(3, 18, 29, "Unknown referenced property 'property.th'", DiagnosticSeverity.Error, ValidationType.expression)); + d(3, 18, 29, "Unknown referenced property 'property.th'", DiagnosticSeverity.Error, + ValidationType.expression)); } } diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/MicroProfileExtensionSettingsTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/MicroProfileExtensionSettingsTest.java new file mode 100644 index 000000000..73541749f --- /dev/null +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/MicroProfileExtensionSettingsTest.java @@ -0,0 +1,77 @@ +/******************************************************************************* +* Copyright (c) 2020 Red Hat Inc. and others. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v. 2.0 which is available at +* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +* which is available at https://www.apache.org/licenses/LICENSE-2.0. +* +* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +* +* Contributors: +* Red Hat Inc. - initial API and implementation +*******************************************************************************/ +package org.eclipse.lsp4mp.settings; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.ArrayList; +import java.util.Arrays; + +import org.junit.Test; + +/** + * Test for {@link MicroProfileExtensionSettings} + * + */ +public class MicroProfileExtensionSettingsTest { + + @Test + public void withoutValidationUserSettings() { + // This test uses the src\test\resources\META-INF\lsp4mp\settings.json + // which defines an exclusion for 'camel.*' property + + MicroProfileGeneralClientSettings clientSettings = new MicroProfileGeneralClientSettings(); + MicroProfileExtensionSettings extensionSettings = new MicroProfileExtensionSettings(); + // Here client settings has none validation settings + assertNull(clientSettings.getValidation()); + + extensionSettings.merge(clientSettings); + assertNotNull(clientSettings.getValidation()); + assertNotNull(clientSettings.getValidation().getUnknown()); + assertNotNull(clientSettings.getValidation().getUnknown().getExcluded()); + assertEquals(1, clientSettings.getValidation().getUnknown().getExcluded().size()); + assertEquals("camel.*", clientSettings.getValidation().getUnknown().getExcluded().get(0)); + } + + @Test + public void withValidationUserSettings() { + // This test uses the src\test\resources\META-INF\lsp4mp\settings.json + // which defines an exclusion for 'camel.*' property + + MicroProfileGeneralClientSettings clientSettings = new MicroProfileGeneralClientSettings(); + clientSettings.setValidation(new MicroProfileValidationSettings()); + clientSettings.getValidation().setUnknown(new MicroProfileValidationTypeSettings()); + clientSettings.getValidation().getUnknown().setExcluded(new ArrayList<>(Arrays.asList("mp.*"))); + + MicroProfileExtensionSettings extensionSettings = new MicroProfileExtensionSettings(); + // Here client settings has user validation settings + assertNotNull(clientSettings.getValidation()); + // Here client settings has just one excluded property + assertNotNull(clientSettings.getValidation()); + assertNotNull(clientSettings.getValidation().getUnknown()); + assertNotNull(clientSettings.getValidation().getUnknown().getExcluded()); + assertEquals(1, clientSettings.getValidation().getUnknown().getExcluded().size()); + + extensionSettings.merge(clientSettings); + assertNotNull(clientSettings.getValidation()); + assertNotNull(clientSettings.getValidation().getUnknown()); + assertNotNull(clientSettings.getValidation().getUnknown().getExcluded()); + assertEquals(2, clientSettings.getValidation().getUnknown().getExcluded().size()); + assertEquals("mp.*", clientSettings.getValidation().getUnknown().getExcluded().get(0)); + assertEquals("camel.*", clientSettings.getValidation().getUnknown().getExcluded().get(1)); + } + +} diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/SettingsTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/SettingsTest.java index 5d15b386b..b7e942fa1 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/SettingsTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/SettingsTest.java @@ -13,9 +13,6 @@ import static org.junit.Assert.assertNotNull; import org.eclipse.lsp4j.InitializeParams; -import org.eclipse.lsp4mp.settings.AllMicroProfileSettings; -import org.eclipse.lsp4mp.settings.InitializationOptionsSettings; -import org.eclipse.lsp4mp.settings.MicroProfileGeneralClientSettings; import org.junit.Test; import com.google.gson.Gson; @@ -26,41 +23,43 @@ */ public class SettingsTest { - private final String json = "{\r\n" + - " \"settings\": {\r\n" + - " \"microprofile\": {\r\n" + - " \"tools\": {\r\n" + - " \"trace\": {\r\n" + - " \"server\": \"verbose\"\r\n" + - " },\r\n" + - " \"symbols\": {\r\n" + - " \"showAsTree\": true\r\n" + - " },\r\n" + - " \"validation\": {\r\n" + - " \"enabled\": \"true\",\r\n" + - " \"unknown\": {\r\n" + - " \"severity\": \"error\",\r\n" + - " \"excluded\": [\r\n" + - " \"abcd\"\r\n" + - " ]\r\n" + - " }\r\n" + - " }\r\n" + - " }\r\n" + - " }\r\n" + - " }\r\n" + + private final String json = "{\r\n" + // + " \"settings\": {\r\n" + // + " \"microprofile\": {\r\n" + // + " \"tools\": {\r\n" + // + " \"trace\": {\r\n" + // + " \"server\": \"verbose\"\r\n" + // + " },\r\n" + // + " \"symbols\": {\r\n" + // + " \"showAsTree\": true\r\n" + // + " },\r\n" + // + " \"validation\": {\r\n" + // + " \"enabled\": \"true\",\r\n" + // + " \"unknown\": {\r\n" + // + " \"severity\": \"error\",\r\n" + // + " \"excluded\": [\r\n" + // + " \"abcd\"\r\n" + // + " ]\r\n" + // + " }\r\n" + // + " }\r\n" + // + " }\r\n" + // + " }\r\n" + // + " }\r\n" + // "}"; @Test public void initializationOptionsSettings() { // Emulate InitializeParams#getInitializationOptions() object created as - // JSONObject when MicroProfileLanguageServer#initialize(InitializeParams params) is + // JSONObject when MicroProfileLanguageServer#initialize(InitializeParams + // params) is // called InitializeParams params = createInitializeParams(json); Object initializationOptionsSettings = InitializationOptionsSettings.getSettings(params); // Test client commons settings - initializationOptionsSettings = AllMicroProfileSettings.getMicroProfileToolsSettings(initializationOptionsSettings); + initializationOptionsSettings = AllMicroProfileSettings + .getMicroProfileToolsSettings(initializationOptionsSettings); MicroProfileGeneralClientSettings settings = MicroProfileGeneralClientSettings .getGeneralMicroProfileSettings(initializationOptionsSettings); assertNotNull(settings); diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilitiesTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilitiesTest.java index 1bd8baf2a..8a7ef9482 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilitiesTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilitiesTest.java @@ -29,8 +29,6 @@ import org.eclipse.lsp4j.TextDocumentClientCapabilities; import org.eclipse.lsp4j.WorkspaceClientCapabilities; import org.eclipse.lsp4j.services.LanguageClient; -import org.eclipse.lsp4mp.settings.capabilities.MicroProfileCapabilityManager; -import org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesInitializer; import org.junit.Before; import org.junit.Test; @@ -48,13 +46,11 @@ public class MicroProfileCapabilitiesTest { @Before public void startup() { - textDocument = new TextDocumentClientCapabilities(); workspace = new WorkspaceClientCapabilities(); manager = new MicroProfileCapabilityManager(languageClient); clientCapabilities = new ClientCapabilities(); capabilityIDs = null; - } @Test diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/resources/META-INF/lsp4mp/settings.json b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/resources/META-INF/lsp4mp/settings.json new file mode 100644 index 000000000..0c256993e --- /dev/null +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/resources/META-INF/lsp4mp/settings.json @@ -0,0 +1,9 @@ +{ + "validation": { + "unknown": { + "excluded": [ + "camel.*" + ] + } + } +} \ No newline at end of file