diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/plugin.xml b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/plugin.xml index dee77f961..c62ca55ac 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/plugin.xml +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/plugin.xml @@ -44,6 +44,14 @@ + + + + + + + + diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java index abf1fde68..60124385d 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java @@ -15,6 +15,8 @@ import java.util.List; +import org.eclipse.lsp4mp.commons.metadata.ValueProvider.ValueProviderDefaultName; + /** * Configuration metadata * @@ -90,7 +92,43 @@ public boolean isValidEnum(ItemMetadata metadata, String value) { if (itemHint == null) { return true; } - return itemHint.getValue(value, metadata.getConverterKinds()) != null; + if (itemHint.getValue(value, metadata.getConverterKinds()) != null) { + return true; + } + ItemHint handleAsHint = getHandleAsHint(itemHint); + if (handleAsHint != null) { + return handleAsHint.getValue(value, metadata.getConverterKinds()) != null; + } + return false; + } + + /** + * Returns the "handle-as" item hint from the given hint and false otherwise. + * + * @param hint the item hint. + * @return the "handle-as" item hint from the given hint and false otherwise. + */ + public ItemHint getHandleAsHint(ItemHint hint) { + if (hint == null) { + return null; + } + List providers = hint.getProviders(); + if (providers != null && !providers.isEmpty()) { + ValueProvider provider = providers.get(0); + if (ValueProviderDefaultName.HANDLE_AS.getName().equals(provider.getName())) { + ValueProviderParameter parameters = provider.getParameters(); + if (parameters != null) { + String target = parameters.getTarget(); + if (target != null) { + ItemHint targetHint = getHint(target); + if (targetHint != null) { + return targetHint; + } + } + } + } + } + return null; } } diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java index 98a1fc90d..e3f6db84a 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java @@ -26,6 +26,8 @@ public class ItemHint extends ItemBase { private List values; + private List providers; + public List getValues() { return values; } @@ -34,106 +36,12 @@ public void setValues(List values) { this.values = values; } - /** - * A hint for a value. - */ - public static class ValueHint { - - private String value; - - private String description; - - private String sourceType; - - /** - * Returns the value. - * - * @return the value. - */ - public String getValue() { - return value; - } - - /** - * Returns the converted value by using the given converter. - * - * @param converterKind the converter - * @return the converted value by using the given converter. - */ - public String getValue(ConverterKind converterKind) { - return ConverterKind.convert(getValue(), converterKind); - } - - /** - * Returns the preferred value according the given converters. - * - * @param converterKinds supported converters and null otherwise. - * - * @return the preferred value according the given converters. - */ - public String getPreferredValue(List converterKinds) { - ConverterKind preferredConverter = converterKinds != null && !converterKinds.isEmpty() - ? converterKinds.get(0) - : null; - return getValue(preferredConverter); - } - - public void setValue(String value) { - this.value = value; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getSourceType() { - return sourceType; - } - - public void setSourceType(String sourceType) { - this.sourceType = sourceType; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((sourceType == null) ? 0 : sourceType.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } + public void setProviders(List providers) { + this.providers = providers; + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ValueHint other = (ValueHint) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (sourceType == null) { - if (other.sourceType != null) - return false; - } else if (!sourceType.equals(other.sourceType)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } + public List getProviders() { + return providers; } /** diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueHint.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueHint.java new file mode 100644 index 000000000..28e43edb2 --- /dev/null +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueHint.java @@ -0,0 +1,118 @@ +/******************************************************************************* +* 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.commons.metadata; + +import java.util.List; + +/** + * A hint for a value. + */ +public class ValueHint { + + private String value; + + private String description; + + private String sourceType; + + /** + * Returns the value. + * + * @return the value. + */ + public String getValue() { + return value; + } + + /** + * Returns the converted value by using the given converter. + * + * @param converterKind the converter + * @return the converted value by using the given converter. + */ + public String getValue(ConverterKind converterKind) { + return ConverterKind.convert(getValue(), converterKind); + } + + /** + * Returns the preferred value according the given converters. + * + * @param converterKinds supported converters and null otherwise. + * + * @return the preferred value according the given converters. + */ + public String getPreferredValue(List converterKinds) { + ConverterKind preferredConverter = converterKinds != null && !converterKinds.isEmpty() ? converterKinds.get(0) + : null; + return getValue(preferredConverter); + } + + public void setValue(String value) { + this.value = value; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSourceType() { + return sourceType; + } + + public void setSourceType(String sourceType) { + this.sourceType = sourceType; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((sourceType == null) ? 0 : sourceType.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ValueHint other = (ValueHint) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (sourceType == null) { + if (other.sourceType != null) + return false; + } else if (!sourceType.equals(other.sourceType)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + +} diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProvider.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProvider.java new file mode 100644 index 000000000..4ba1ee7ff --- /dev/null +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProvider.java @@ -0,0 +1,56 @@ +/******************************************************************************* +* 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.commons.metadata; + +/** + * A provider for a value. + */ +public class ValueProvider { + + public static enum ValueProviderDefaultName { + + HANDLE_AS("handle-as"); + + private final String name; + + private ValueProviderDefaultName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } + + private String name; + + private ValueProviderParameter parameters; + + public String getName() { + return name; + } + + public ValueProviderParameter getParameters() { + return parameters; + } + + public void setName(String name) { + this.name = name; + } + + public void setParameters(ValueProviderParameter parameters) { + this.parameters = parameters; + } + +} diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProviderParameter.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProviderParameter.java new file mode 100644 index 000000000..af280fedd --- /dev/null +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProviderParameter.java @@ -0,0 +1,34 @@ +/******************************************************************************* +* 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.commons.metadata; + +/** + * A parameter value provider. + * + * @author Angelo ZERR + * + */ +public class ValueProviderParameter { + + private String target; + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + +} diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractPropertiesProvider.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractPropertiesProvider.java index 224c965a1..6ed39a862 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractPropertiesProvider.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractPropertiesProvider.java @@ -23,7 +23,7 @@ import org.eclipse.jdt.core.search.SearchPattern; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; /** * Abstract class for properties provider. diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractStaticPropertiesProvider.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractStaticPropertiesProvider.java index d921973c1..6e7f06646 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractStaticPropertiesProvider.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/core/AbstractStaticPropertiesProvider.java @@ -56,9 +56,15 @@ public abstract class AbstractStaticPropertiesProvider extends AbstractPropertie private ConfigurationMetadata metadata; + private final MergingStrategy mergingStrategy; + public AbstractStaticPropertiesProvider(String pluginId, String path) { + this(pluginId, path, MergingStrategy.IGNORE_IF_EXISTS); + } + public AbstractStaticPropertiesProvider(String pluginId, String path, MergingStrategy mergingStrategy) { this.pluginId = pluginId; this.path = path; + this.mergingStrategy = mergingStrategy; } @Override @@ -93,7 +99,7 @@ protected void collectStaticProperties(SearchContext context, IProgressMonitor m } } if (metadata != null) { - context.getCollector().merge(metadata, MergingStrategy.IGNORE_IF_EXISTS); + context.getCollector().merge(metadata, mergingStrategy); } } diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollector.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollector.java index 27b02c808..911625676 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollector.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollector.java @@ -23,6 +23,7 @@ import org.eclipse.lsp4mp.commons.metadata.ConfigurationMetadata; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.jdt.core.IPropertiesCollector; /** @@ -78,14 +79,9 @@ public boolean hasItemHint(String hint) { return hintsCache.containsKey(hint); } - private void addItemHint(ItemHint itemHint) { - configuration.getHints().add(itemHint); - hintsCache.put(itemHint.getName(), itemHint); - } - @Override public ItemHint getItemHint(String hint) { - ItemHint itemHint = hintsCache.get(hint); + ItemHint itemHint = getExistingItemHint(hint); if (itemHint != null) { return itemHint; } @@ -99,36 +95,37 @@ public ItemHint getItemHint(String hint) { @Override public void merge(ConfigurationMetadata metadata, MergingStrategy mergingStrategy) { List properties = metadata.getProperties(); - if (properties == null) { - return; - } - for (ItemMetadata property: properties) { - merge(property, mergingStrategy); + if (properties != null) { + for (ItemMetadata property : properties) { + merge(property, mergingStrategy); + } } List hints = metadata.getHints(); if (hints != null) { for (ItemHint itemHint : hints) { - addItemHint(itemHint); + merge(itemHint, mergingStrategy); } } } - public void merge(ItemMetadata property, MergingStrategy mergingStrategy) { + // --------------- Properties merge + + private void merge(ItemMetadata property, MergingStrategy mergingStrategy) { if (onlySources && (property.getSource() == null || !property.getSource())) { // In the case of the scopes is only sources, the property which is a binary // property must not be added. return; } switch (mergingStrategy) { - case IGNORE_IF_EXISTS: - mergeWithIgnoreIfExists(property); - break; - case REPLACE: - mergeWithReplace(property); - break; - default: - addProperty(property); - break; + case IGNORE_IF_EXISTS: + mergeWithIgnoreIfExists(property); + break; + case REPLACE: + mergeWithReplace(property); + break; + default: + addProperty(property); + break; } } @@ -142,9 +139,7 @@ private void mergeWithIgnoreIfExists(ItemMetadata property) { private Optional getExistingProperty(ItemMetadata property) { List configProperties = configuration.getProperties(); - Optional configProperty = configProperties.stream() - .filter(cp -> cp.getName().equals(property.getName())).findFirst(); - return configProperty; + return configProperties.stream().filter(cp -> cp.getName().equals(property.getName())).findFirst(); } private void mergeWithReplace(ItemMetadata property) { @@ -158,4 +153,57 @@ private void mergeWithReplace(ItemMetadata property) { private void addProperty(ItemMetadata property) { configuration.getProperties().add(property); } + + // --------------- ItemHint merge + + private void merge(ItemHint itemHint, MergingStrategy mergingStrategy) { + ItemHint existingItemHint = getItemHint(itemHint.getName()); + merge(itemHint.getValues(), existingItemHint, mergingStrategy); + if (itemHint.getProviders() != null) { + if (existingItemHint.getProviders() == null) { + existingItemHint.setProviders(new ArrayList<>()); + } + existingItemHint.getProviders().addAll(itemHint.getProviders()); + } + } + + private static void merge(List from, ItemHint to, MergingStrategy mergingStrategy) { + if (from == null || from.isEmpty()) { + return; + } + if (to.getValues() == null) { + to.setValues(new ArrayList<>()); + } + for (ValueHint fromValue : from) { + switch (mergingStrategy) { + case IGNORE_IF_EXISTS: + if (!getExistingValue(fromValue.getValue(), to.getValues()).isPresent()) { + to.getValues().add(fromValue); + } + break; + case REPLACE: + Optional existingValue = getExistingValue(fromValue.getValue(), to.getValues()); + if (existingValue.isPresent()) { + to.getValues().remove(existingValue.get()); + } + to.getValues().add(fromValue); + break; + default: + to.getValues().add(fromValue); + } + } + } + + private static Optional getExistingValue(String name, List values) { + return values.stream().filter(cp -> cp.getValue().equals(name)).findFirst(); + } + + private ItemHint getExistingItemHint(String hint) { + return hintsCache.get(hint); + } + + private void addItemHint(ItemHint itemHint) { + configuration.getHints().add(itemHint); + hintsCache.put(itemHint.getName(), itemHint); + } } diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/jul/properties/JBossLogManagerPropertyProvider.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/jul/properties/JBossLogManagerPropertyProvider.java new file mode 100644 index 000000000..92b96e627 --- /dev/null +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/jul/properties/JBossLogManagerPropertyProvider.java @@ -0,0 +1,49 @@ +/******************************************************************************* +* 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.jdt.internal.jul.properties; + +import java.util.logging.Level; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.lsp4mp.jdt.core.AbstractStaticPropertiesProvider; +import org.eclipse.lsp4mp.jdt.core.IPropertiesCollector.MergingStrategy; +import org.eclipse.lsp4mp.jdt.core.MicroProfileCorePlugin; +import org.eclipse.lsp4mp.jdt.core.SearchContext; +import org.eclipse.lsp4mp.jdt.core.utils.JDTTypeUtils; + +/** + * JBoss Logging Manager provider for {@link Level}. + * + * @author Angelo ZERR + * + * @see https://github.com/jboss-logging/jboss-logmanager/blob/master/core/src/main/java/org/jboss/logmanager/Level.java + * + */ +public class JBossLogManagerPropertyProvider extends AbstractStaticPropertiesProvider { + + private static final String JBOSS_LOGMANAGER_LEVEL_CLASS = "org.jboss.logmanager.Level"; + + public JBossLogManagerPropertyProvider() { + super(MicroProfileCorePlugin.PLUGIN_ID, "/static-properties/jboss-logmanager-metadata.json", + MergingStrategy.REPLACE /* JUL 'INFO' must be overrided with JBossLogManager 'INFO' */); + } + + @Override + protected boolean isAdaptedFor(SearchContext context, IProgressMonitor monitor) { + // Check if JBoss LogManager exists in classpath + IJavaProject javaProject = context.getJavaProject(); + return JDTTypeUtils.findType(javaProject, JBOSS_LOGMANAGER_LEVEL_CLASS) != null; + } +} diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/jul/properties/JULPropertyProvider.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/jul/properties/JULPropertyProvider.java new file mode 100644 index 000000000..c74e50b3a --- /dev/null +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/jul/properties/JULPropertyProvider.java @@ -0,0 +1,39 @@ +/******************************************************************************* +* 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.jdt.internal.jul.properties; + +import java.util.logging.Level; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.lsp4mp.jdt.core.AbstractStaticPropertiesProvider; +import org.eclipse.lsp4mp.jdt.core.MicroProfileCorePlugin; +import org.eclipse.lsp4mp.jdt.core.SearchContext; + +/** + * Java Util Logging properties provider for {@link Level}. + * + * @author Angelo ZERR + * + */ +public class JULPropertyProvider extends AbstractStaticPropertiesProvider { + + public JULPropertyProvider() { + super(MicroProfileCorePlugin.PLUGIN_ID, "/static-properties/jul-metadata.json"); + } + + @Override + protected boolean isAdaptedFor(SearchContext context, IProgressMonitor monitor) { + return true; + } +} diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/reactivemessaging/properties/MicroProfileReactiveMessagingProvider.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/reactivemessaging/properties/MicroProfileReactiveMessagingProvider.java index 27418508d..dc31f62de 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/reactivemessaging/properties/MicroProfileReactiveMessagingProvider.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/reactivemessaging/properties/MicroProfileReactiveMessagingProvider.java @@ -33,7 +33,7 @@ import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.jdt.core.AbstractAnnotationTypeReferencePropertiesProvider; import org.eclipse.lsp4mp.jdt.core.SearchContext; diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/restclient/properties/MicroProfileRegisterRestClientProvider.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/restclient/properties/MicroProfileRegisterRestClientProvider.java index b0138d53d..8bd64bd3d 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/restclient/properties/MicroProfileRegisterRestClientProvider.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/restclient/properties/MicroProfileRegisterRestClientProvider.java @@ -23,7 +23,7 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.jdt.core.AbstractAnnotationTypeReferencePropertiesProvider; import org.eclipse.lsp4mp.jdt.core.IPropertiesCollector; import org.eclipse.lsp4mp.jdt.core.SearchContext; diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/static-properties/jboss-logmanager-metadata.json b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/static-properties/jboss-logmanager-metadata.json new file mode 100644 index 000000000..50da4c70c --- /dev/null +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/static-properties/jboss-logmanager-metadata.json @@ -0,0 +1,34 @@ +{ + "hints": [ + { + "name": "java.util.logging.Level", + "sourceType": "org.jboss.logmanager.Level", + "values": [ + { + "value": "FATAL", + "description": "Use the `FATAL` level priority for events that indicate a critical service failure. If a service issues a FATAL error it is completely unable to service requests of any kind." + }, + { + "value": "ERROR", + "description": "Use the `ERROR` level priority for events that indicate a disruption in a request or the ability to service a request. A service should have some capacity to continue to service requests in the presence of ERRORs." + }, + { + "value": "WARN", + "description": "Use the `WARN` level priority for events that may indicate a non-critical service error. Resumable errors, or minor breaches in request expectations fall into this category. The distinction between WARN and ERROR may be hard to discern and so its up to the developer to judge. The simplest criterion is would this failure result in a user support call. If it would use ERROR. If it would not use WARN." + }, + { + "value": "INFO", + "description": "Use the `INFO` level priority for service life-cycle events and other crucial related information. Looking at the INFO messages for a given service category should tell you exactly what state the service is in." + }, + { + "value": "DEBUG", + "description": "Use the `DEBUG` level priority for log messages that convey extra information regarding life-cycle events. Developer or in depth information required for support is the basis for this priority. The important point is that when the DEBUG level priority is enabled, the JBoss server log should not grow proportionally with the number of server requests. Looking at the DEBUG and INFO messages for a given service category should tell you exactly what state the service is in, as well as what server resources it is using: ports, interfaces, log files, etc." + }, + { + "value": "TRACE", + "description": "Use `TRACE` the level priority for log messages that are directly associated with activity that corresponds requests. Further, such messages should not be submitted to a Logger unless the Logger category priority threshold indicates that the message will be rendered. Use the Logger.isTraceEnabled() method to determine if the category priority threshold is enabled. The point of the TRACE priority is to allow for deep probing of the JBoss server behavior when necessary. When the TRACE level priority is enabled, you can expect the number of messages in the JBoss server log to grow at least a x N, where N is the number of requests received by the server, a some constant. The server log may well grow as power of N depending on the request-handling layer being traced." + } + ] + } + ] +} diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/static-properties/jul-metadata.json b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/static-properties/jul-metadata.json new file mode 100644 index 000000000..2519e7680 --- /dev/null +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/static-properties/jul-metadata.json @@ -0,0 +1,46 @@ +{ + "hints": [ + { + "name": "java.util.logging.Level", + "sourceType": "java.util.logging.Level", + "values": [ + { + "value": "OFF", + "description": "`OFF` is a special level that can be used to turn off logging.\nThis level is initialized to `Integer.MAX_VALUE`." + }, + { + "value": "SEVERE", + "description": "`SEVERE` is a message level indicating a serious failure.\n\nIn general SEVERE messages should describe events that are of considerable importance and which will prevent normal program execution. They should be reasonably intelligible to end users and to system administrators. This level is initialized to `1000`." + }, + { + "value": "WARNING", + "description": "`WARNING` is a message level indicating a potential problem.\n\nIn general WARNING messages should describe events that will be of interest to end users or system managers, or which indicate potential problems. This level is initialized to `900`." + }, + { + "value": "INFO", + "description": "`INFO` is a message level for informational messages.\n\nTypically INFO messages will be written to the console or its equivalent. So the INFO level should only be used for reasonably significant messages that will make sense to end users and system administrators. This level is initialized to `800`." + }, + { + "value": "CONFIG", + "description": "`CONFIG` is a message level for static configuration messages.\n\nCONFIG messages are intended to provide a variety of static configuration information, to assist in debugging problems that may be associated with particular configurations. For example, CONFIG message might include the CPU type, the graphics depth, the GUI look-and-feel, etc. This level is initialized to `700`." + }, + { + "value": "FINE", + "description": "`FINE` is a message level providing tracing information.\n\nAll of FINE, FINER, and FINEST are intended for relatively detailed tracing. The exact meaning of the three levels will vary between subsystems, but in general, FINEST should be used for the most voluminous detailed output, FINER for somewhat less detailed output, and FINE for the lowest volume (and most important) messages.\n\nIn general the FINE level should be used for information that will be broadly interesting to developers who do not have a specialized interest in the specific subsystem.\n\nFINE messages might include things like minor (recoverable) failures. Issues indicating potential performance problems are also worth logging as FINE. This level is initialized to `500`." + }, + { + "value": "FINER", + "description": "`FINER` indicates a fairly detailed tracing message. By default logging calls for entering, returning, or throwing an exception are traced at this level. This level is initialized to `400`." + }, + { + "value": "FINEST", + "description": "`FINEST` indicates a highly detailed tracing message. This level is initialized to `300`." + }, + { + "value": "ALL", + "description": "`ALL` indicates that all messages should be logged. This level is initialized to `Integer.MIN_VALUE`." + } + ] + } + ] +} diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/GenerateAllPropertiesAndDefinition.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/GenerateAllPropertiesAndDefinition.java index 860e590e5..4822e73fc 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/GenerateAllPropertiesAndDefinition.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/GenerateAllPropertiesAndDefinition.java @@ -38,8 +38,7 @@ import org.eclipse.lsp4mp.commons.MicroProfilePropertiesScope; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; -import org.eclipse.lsp4mp.jdt.core.PropertiesManager; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.jdt.core.utils.IJDTUtils; import org.junit.Ignore; import org.junit.Test; diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/restclient/MicroProfileRegisterRestClientTest.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/restclient/MicroProfileRegisterRestClientTest.java index 74872c310..6fcaadaba 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/restclient/MicroProfileRegisterRestClientTest.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/core/restclient/MicroProfileRegisterRestClientTest.java @@ -81,7 +81,7 @@ public void restClientQuickstart() throws Exception { assertPropertiesDuplicate(infoFromClasspath); // mp-rest Hints - assertHints(infoFromClasspath, 1, + assertHints(infoFromClasspath, (Integer) null, h("${mp.register.rest.client.class}", null, false, null, vh("org.acme.restclient.CountriesService", null, "org.acme.restclient.CountriesService"), // diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/MicroProfileAssert.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/MicroProfileAssert.java index 05ea863b3..7da04a98f 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/MicroProfileAssert.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/MicroProfileAssert.java @@ -22,7 +22,7 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.junit.Assert; /** diff --git a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollectorTest.java b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollectorTest.java index 6a240ac40..3f53f5f31 100644 --- a/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollectorTest.java +++ b/microprofile.jdt/org.eclipse.lsp4mp.jdt.test/src/main/java/org/eclipse/lsp4mp/jdt/internal/core/PropertiesCollectorTest.java @@ -13,13 +13,19 @@ *******************************************************************************/ package org.eclipse.lsp4mp.jdt.internal.core; +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.eclipse.lsp4mp.jdt.core.IPropertiesCollector.MergingStrategy; import org.eclipse.lsp4mp.commons.MicroProfilePropertiesScope; import org.eclipse.lsp4mp.commons.metadata.ConfigurationMetadata; +import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.junit.Assert; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; +import org.eclipse.lsp4mp.jdt.core.IPropertiesCollector.MergingStrategy; import org.junit.Test; /** @@ -30,6 +36,8 @@ */ public class PropertiesCollectorTest { + // ------------ Test with properties merge + @Test public void merge() { ConfigurationMetadata configuration = new ConfigurationMetadata(); @@ -39,12 +47,12 @@ public void merge() { ConfigurationMetadata toMerge = createToMerge(); collector.merge(toMerge); - Assert.assertEquals(2, configuration.getProperties().size()); + assertEquals(2, configuration.getProperties().size()); ConfigurationMetadata dupMerge = createDuplicateMerge(); collector.merge(dupMerge); // implicitly using MergingStrategy.FORCE - Assert.assertEquals(3, configuration.getProperties().size()); + assertEquals(3, configuration.getProperties().size()); } @Test @@ -56,7 +64,7 @@ public void mergeWithOnlySources() { ConfigurationMetadata toMerge = createToMerge(); collector.merge(toMerge); - Assert.assertEquals(1, configuration.getProperties().size()); + assertEquals(1, configuration.getProperties().size()); } @Test @@ -68,14 +76,14 @@ public void mergeWithReplace() { ConfigurationMetadata toMerge = createToMerge(); collector.merge(toMerge, MergingStrategy.REPLACE); - Assert.assertEquals(2, configuration.getProperties().size()); - Assert.assertNull(configuration.getProperties().get(0).getDescription()); + assertEquals(2, configuration.getProperties().size()); + assertNull(configuration.getProperties().get(0).getDescription()); ConfigurationMetadata dupMerge = createDuplicateMerge(); collector.merge(dupMerge, MergingStrategy.REPLACE); - Assert.assertEquals(2, configuration.getProperties().size()); - Assert.assertNotNull(configuration.getProperties().get(1).getDescription()); + assertEquals(2, configuration.getProperties().size()); + assertNotNull(configuration.getProperties().get(1).getDescription()); } @Test @@ -87,14 +95,14 @@ public void mergeWithIgnore() { ConfigurationMetadata toMerge = createToMerge(); collector.merge(toMerge, MergingStrategy.IGNORE_IF_EXISTS); - Assert.assertEquals(2, configuration.getProperties().size()); - Assert.assertNull(configuration.getProperties().get(0).getDescription()); + assertEquals(2, configuration.getProperties().size()); + assertNull(configuration.getProperties().get(0).getDescription()); ConfigurationMetadata dupMerge = createDuplicateMerge(); collector.merge(dupMerge, MergingStrategy.IGNORE_IF_EXISTS); - Assert.assertEquals(2, configuration.getProperties().size()); - Assert.assertNull(configuration.getProperties().get(0).getDescription()); + assertEquals(2, configuration.getProperties().size()); + assertNull(configuration.getProperties().get(0).getDescription()); } private static ConfigurationMetadata createToMerge() { @@ -124,4 +132,101 @@ private static ConfigurationMetadata createDuplicateMerge() { return dupMerge; } + // ------------ Test with hint merge + + @Test + public void mergeHintsWithIgnore() { + + ConfigurationMetadata configuration1 = new ConfigurationMetadata(); + PropertiesCollector collector = new PropertiesCollector(configuration1, + MicroProfilePropertiesScope.SOURCES_AND_DEPENDENCIES); + + ItemHint hint1 = collector.getItemHint("logging"); + hint1.getValues().add(vh("OFF", "OFF [1]")); + hint1.getValues().add(vh("SEVERE", "SEVERE [1]")); + hint1.getValues().add(vh("INFO", "INFO [1]")); + + ConfigurationMetadata configuration2 = new ConfigurationMetadata(); + ItemHint hint2 = new ItemHint(); + hint2.setName("logging"); + hint2.setValues( + new ArrayList<>(Arrays.asList(vh("DEBUG", "DEBUG [2]"), vh("INFO", "INFO [2]"), vh("OFF", "OFF [2]")))); + configuration2.setHints(new ArrayList<>(Arrays.asList(hint2))); + + collector.merge(configuration2, MergingStrategy.IGNORE_IF_EXISTS); + + assertEquals(1, configuration1.getHints().size()); + assertEquals(4, configuration1.getHints().get(0).getValues().size()); + assertEquals("OFF [1]", configuration1.getHints().get(0).getValues().get(0).getDescription()); + assertEquals("SEVERE [1]", configuration1.getHints().get(0).getValues().get(1).getDescription()); + assertEquals("INFO [1]", configuration1.getHints().get(0).getValues().get(2).getDescription()); + assertEquals("DEBUG [2]", configuration1.getHints().get(0).getValues().get(3).getDescription()); + } + + @Test + public void mergeHintsWithReplace() { + + ConfigurationMetadata configuration1 = new ConfigurationMetadata(); + PropertiesCollector collector = new PropertiesCollector(configuration1, + MicroProfilePropertiesScope.SOURCES_AND_DEPENDENCIES); + + ItemHint hint1 = collector.getItemHint("logging"); + hint1.getValues().add(vh("OFF", "OFF [1]")); + hint1.getValues().add(vh("SEVERE", "SEVERE [1]")); + hint1.getValues().add(vh("INFO", "INFO [1]")); + + ConfigurationMetadata configuration2 = new ConfigurationMetadata(); + ItemHint hint2 = new ItemHint(); + hint2.setName("logging"); + hint2.setValues( + new ArrayList<>(Arrays.asList(vh("DEBUG", "DEBUG [2]"), vh("INFO", "INFO [2]"), vh("OFF", "OFF [2]")))); + configuration2.setHints(new ArrayList<>(Arrays.asList(hint2))); + + collector.merge(configuration2, MergingStrategy.REPLACE); + + assertEquals(1, configuration1.getHints().size()); + assertEquals(4, configuration1.getHints().get(0).getValues().size()); + assertEquals("SEVERE [1]", configuration1.getHints().get(0).getValues().get(0).getDescription()); + assertEquals("DEBUG [2]", configuration1.getHints().get(0).getValues().get(1).getDescription()); + assertEquals("INFO [2]", configuration1.getHints().get(0).getValues().get(2).getDescription()); + assertEquals("OFF [2]", configuration1.getHints().get(0).getValues().get(3).getDescription()); + } + + @Test + public void mergeHintsWithForce() { + + ConfigurationMetadata configuration1 = new ConfigurationMetadata(); + PropertiesCollector collector = new PropertiesCollector(configuration1, + MicroProfilePropertiesScope.SOURCES_AND_DEPENDENCIES); + + ItemHint hint1 = collector.getItemHint("logging"); + hint1.getValues().add(vh("OFF", "OFF [1]")); + hint1.getValues().add(vh("SEVERE", "SEVERE [1]")); + hint1.getValues().add(vh("INFO", "INFO [1]")); + + ConfigurationMetadata configuration2 = new ConfigurationMetadata(); + ItemHint hint2 = new ItemHint(); + hint2.setName("logging"); + hint2.setValues( + new ArrayList<>(Arrays.asList(vh("DEBUG", "DEBUG [2]"), vh("INFO", "INFO [2]"), vh("OFF", "OFF [2]")))); + configuration2.setHints(new ArrayList<>(Arrays.asList(hint2))); + + collector.merge(configuration2, MergingStrategy.FORCE); + + assertEquals(1, configuration1.getHints().size()); + assertEquals(6, configuration1.getHints().get(0).getValues().size()); + assertEquals("OFF [1]", configuration1.getHints().get(0).getValues().get(0).getDescription()); + assertEquals("SEVERE [1]", configuration1.getHints().get(0).getValues().get(1).getDescription()); + assertEquals("INFO [1]", configuration1.getHints().get(0).getValues().get(2).getDescription()); + assertEquals("DEBUG [2]", configuration1.getHints().get(0).getValues().get(3).getDescription()); + assertEquals("INFO [2]", configuration1.getHints().get(0).getValues().get(4).getDescription()); + assertEquals("OFF [2]", configuration1.getHints().get(0).getValues().get(5).getDescription()); + } + + private static ValueHint vh(String value, String description) { + ValueHint debug = new ValueHint(); + debug.setValue(value); + debug.setDescription(description); + return debug; + } } diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java index abf1fde68..60124385d 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ConfigurationMetadata.java @@ -15,6 +15,8 @@ import java.util.List; +import org.eclipse.lsp4mp.commons.metadata.ValueProvider.ValueProviderDefaultName; + /** * Configuration metadata * @@ -90,7 +92,43 @@ public boolean isValidEnum(ItemMetadata metadata, String value) { if (itemHint == null) { return true; } - return itemHint.getValue(value, metadata.getConverterKinds()) != null; + if (itemHint.getValue(value, metadata.getConverterKinds()) != null) { + return true; + } + ItemHint handleAsHint = getHandleAsHint(itemHint); + if (handleAsHint != null) { + return handleAsHint.getValue(value, metadata.getConverterKinds()) != null; + } + return false; + } + + /** + * Returns the "handle-as" item hint from the given hint and false otherwise. + * + * @param hint the item hint. + * @return the "handle-as" item hint from the given hint and false otherwise. + */ + public ItemHint getHandleAsHint(ItemHint hint) { + if (hint == null) { + return null; + } + List providers = hint.getProviders(); + if (providers != null && !providers.isEmpty()) { + ValueProvider provider = providers.get(0); + if (ValueProviderDefaultName.HANDLE_AS.getName().equals(provider.getName())) { + ValueProviderParameter parameters = provider.getParameters(); + if (parameters != null) { + String target = parameters.getTarget(); + if (target != null) { + ItemHint targetHint = getHint(target); + if (targetHint != null) { + return targetHint; + } + } + } + } + } + return null; } } diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java index 98a1fc90d..e3f6db84a 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ItemHint.java @@ -26,6 +26,8 @@ public class ItemHint extends ItemBase { private List values; + private List providers; + public List getValues() { return values; } @@ -34,106 +36,12 @@ public void setValues(List values) { this.values = values; } - /** - * A hint for a value. - */ - public static class ValueHint { - - private String value; - - private String description; - - private String sourceType; - - /** - * Returns the value. - * - * @return the value. - */ - public String getValue() { - return value; - } - - /** - * Returns the converted value by using the given converter. - * - * @param converterKind the converter - * @return the converted value by using the given converter. - */ - public String getValue(ConverterKind converterKind) { - return ConverterKind.convert(getValue(), converterKind); - } - - /** - * Returns the preferred value according the given converters. - * - * @param converterKinds supported converters and null otherwise. - * - * @return the preferred value according the given converters. - */ - public String getPreferredValue(List converterKinds) { - ConverterKind preferredConverter = converterKinds != null && !converterKinds.isEmpty() - ? converterKinds.get(0) - : null; - return getValue(preferredConverter); - } - - public void setValue(String value) { - this.value = value; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getSourceType() { - return sourceType; - } - - public void setSourceType(String sourceType) { - this.sourceType = sourceType; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((sourceType == null) ? 0 : sourceType.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } + public void setProviders(List providers) { + this.providers = providers; + } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ValueHint other = (ValueHint) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (sourceType == null) { - if (other.sourceType != null) - return false; - } else if (!sourceType.equals(other.sourceType)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } + public List getProviders() { + return providers; } /** diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueHint.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueHint.java new file mode 100644 index 000000000..28e43edb2 --- /dev/null +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueHint.java @@ -0,0 +1,118 @@ +/******************************************************************************* +* 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.commons.metadata; + +import java.util.List; + +/** + * A hint for a value. + */ +public class ValueHint { + + private String value; + + private String description; + + private String sourceType; + + /** + * Returns the value. + * + * @return the value. + */ + public String getValue() { + return value; + } + + /** + * Returns the converted value by using the given converter. + * + * @param converterKind the converter + * @return the converted value by using the given converter. + */ + public String getValue(ConverterKind converterKind) { + return ConverterKind.convert(getValue(), converterKind); + } + + /** + * Returns the preferred value according the given converters. + * + * @param converterKinds supported converters and null otherwise. + * + * @return the preferred value according the given converters. + */ + public String getPreferredValue(List converterKinds) { + ConverterKind preferredConverter = converterKinds != null && !converterKinds.isEmpty() ? converterKinds.get(0) + : null; + return getValue(preferredConverter); + } + + public void setValue(String value) { + this.value = value; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSourceType() { + return sourceType; + } + + public void setSourceType(String sourceType) { + this.sourceType = sourceType; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((sourceType == null) ? 0 : sourceType.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ValueHint other = (ValueHint) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (sourceType == null) { + if (other.sourceType != null) + return false; + } else if (!sourceType.equals(other.sourceType)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + +} diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProvider.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProvider.java new file mode 100644 index 000000000..4ba1ee7ff --- /dev/null +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProvider.java @@ -0,0 +1,56 @@ +/******************************************************************************* +* 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.commons.metadata; + +/** + * A provider for a value. + */ +public class ValueProvider { + + public static enum ValueProviderDefaultName { + + HANDLE_AS("handle-as"); + + private final String name; + + private ValueProviderDefaultName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } + + private String name; + + private ValueProviderParameter parameters; + + public String getName() { + return name; + } + + public ValueProviderParameter getParameters() { + return parameters; + } + + public void setName(String name) { + this.name = name; + } + + public void setParameters(ValueProviderParameter parameters) { + this.parameters = parameters; + } + +} diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProviderParameter.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProviderParameter.java new file mode 100644 index 000000000..af280fedd --- /dev/null +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/commons/metadata/ValueProviderParameter.java @@ -0,0 +1,34 @@ +/******************************************************************************* +* 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.commons.metadata; + +/** + * A parameter value provider. + * + * @author Angelo ZERR + * + */ +public class ValueProviderParameter { + + private String target; + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + +} diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfo.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfo.java index ab8dcc755..904711afb 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfo.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfo.java @@ -24,8 +24,8 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ItemBase; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.model.PropertiesModel; /** diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/ParentProcessWatcher.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/ParentProcessWatcher.java index 2fe6ab50e..ec8c39542 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/ParentProcessWatcher.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/ParentProcessWatcher.java @@ -22,11 +22,11 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.google.common.io.Closeables; - import org.eclipse.lsp4j.jsonrpc.MessageConsumer; import org.eclipse.lsp4j.services.LanguageServer; +import com.google.common.io.Closeables; + /** * Watches the parent process PID and invokes exit if it is no longer available. * This implementation waits for periods of inactivity to start querying the diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistry.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistry.java index 3a683cab3..c873b9794 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistry.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistry.java @@ -28,12 +28,6 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonIOException; -import com.google.gson.JsonSyntaxException; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; - import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionItemKind; import org.eclipse.lsp4j.InsertTextFormat; @@ -43,6 +37,12 @@ import org.eclipse.lsp4j.TextEdit; import org.eclipse.lsp4j.jsonrpc.messages.Either; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonIOException; +import com.google.gson.JsonSyntaxException; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; + /** * A registry for snippets which uses the same format than vscode snippet. * diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/PropertyGraph.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/PropertyGraph.java index 7248fbd9f..67525bddf 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/PropertyGraph.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/PropertyGraph.java @@ -20,6 +20,8 @@ import java.util.List; import java.util.Set; +import org.eclipse.lsp4mp.model.Node.NodeType; + import com.google.common.base.Optional; import com.google.common.graph.EndpointPair; import com.google.common.graph.Graph; @@ -28,8 +30,6 @@ import com.google.common.graph.MutableGraph; import com.google.common.graph.Traverser; -import org.eclipse.lsp4mp.model.Node.NodeType; - /** * Represents the graph of dependencies between properties defined in a * MicroProfile properties file. diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesDefinition.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesDefinition.java index c80d13408..41c31cecf 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesDefinition.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesDefinition.java @@ -15,7 +15,7 @@ import java.util.List; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; /** * Definition for values. A values definition gives the capability to share diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRule.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRule.java index e957e33eb..9798f85a5 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRule.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRule.java @@ -16,8 +16,8 @@ import java.util.List; import java.util.stream.Collectors; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.model.PropertiesModel; /** diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRulesDescriptor.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRulesDescriptor.java deleted file mode 100644 index 0d1a4bb1d..000000000 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRulesDescriptor.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2019 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.model.values; - -import java.util.List; - -/** - * Descriptor which declares list of values rules {@link ValuesRule}. - * - * @author Angelo ZERR - * - */ -public class ValuesRulesDescriptor { - - private List definitions; - - private List rules; - - public List getDefinitions() { - return definitions; - } - - public void setDefinitions(List definitions) { - this.definitions = definitions; - } - - /** - * Returns the values rules list. - * - * @return the values rules list. - */ - public List getRules() { - return rules; - } - - /** - * Set the values rules list. - * - * @param rules the values rules list. - */ - public void setRules(List rules) { - this.rules = rules; - } - -} diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRulesManager.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRulesManager.java deleted file mode 100644 index 8b5ac7bbd..000000000 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/model/values/ValuesRulesManager.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2019 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.model.values; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.google.gson.Gson; - -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; -import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.eclipse.lsp4mp.model.PropertiesModel; - -/** - * Values rules manager. - * - * @author Angelo ZERR - * - */ -public class ValuesRulesManager { - - private final Map> definitionsMap; - private final List rules; - private boolean withDefault; - - public ValuesRulesManager(boolean withDefault) { - this.definitionsMap = new HashMap<>(); - this.rules = new ArrayList<>(); - this.withDefault = withDefault; - } - - private void load(InputStream in) { - ValuesRulesDescriptor descriptor = new Gson().fromJson(new InputStreamReader(in), ValuesRulesDescriptor.class); - if (descriptor.getDefinitions() != null) { - registerDefinitions(descriptor.getDefinitions()); - } - if (descriptor.getRules() != null) { - registerRules(descriptor.getRules()); - } - } - - public void registerDefinitions(List definitions) { - definitions.forEach(def -> definitionsMap.put(def.getId(), def.getValues())); - } - - public void registerRules(List rules) { - this.rules.addAll(rules); - rules.stream() // - .filter(rule -> rule.getValuesRef() != null) // - .forEach(rule -> rule.getValuesRef() // - .forEach(ref -> { - List values = new ArrayList<>(); - List staticValues = rule.getValues(); - if (staticValues != null) { - values.addAll(staticValues); - } - List refValues = definitionsMap.get(ref); - if (refValues != null) { - values.addAll(refValues); - } - rule.setValues(values); // - }) // - ); - } - - public void unregisterRules(List rules) { - this.rules.removeAll(rules); - } - - /** - * Returns the values {@link ValueHint} from the given metadata property and - * null otherwise. - * - * @param metadata the metadata property to match - * @param model the properties model - * @return the values {@link ValueHint} from the given metadata property and - * null otherwise. - */ - public List getValues(ItemMetadata metadata, PropertiesModel model) { - for (ValuesRule rule : getRules()) { - if (rule.match(metadata, model)) { - return rule.getValues(); - } - } - return null; - } - - /** - * Returns true if the given value is valid for the given metadata property and - * false otherwise. - * - * @param metadata the metadata property to match - * @param model the properties model - * @param propertyValue the property value to validate - * @return true if the given value is valid for the given metadata property and - * false otherwise. - */ - public boolean isValidEnum(ItemMetadata metadata, PropertiesModel model, String propertyValue) { - List enums = getValues(metadata, model); - return enums == null || getValueHint(propertyValue, metadata, model) != null; - } - - /** - * Returns the {@link ValueHint} from the given property value for the given - * metadata property and null otherwise. - * - * @param metadata the metadata property to match - * @param model the properties model - * @return the {@link ValueHint} from the given property value for the given - * metadata property and null otherwise. - */ - public ValueHint getValueHint(String propertyValue, ItemMetadata metadata, PropertiesModel model) { - List enums = getValues(metadata, model); - return getValue(propertyValue, enums); - } - - private ValueHint getValue(String value, List values) { - if (values == null || value == null) { - return null; - } - for (ValueHint valueHint : values) { - if (value.equals(valueHint.getValue())) { - return valueHint; - } - } - return null; - } - - private List getRules() { - if (isDefaultNotLoaded()) { - synchronized (rules) { - if (isDefaultNotLoaded()) { - load(ValuesRulesManager.class.getResourceAsStream("quarkus-values-rules.json")); - } - } - } - return rules; - } - - private boolean isDefaultNotLoaded() { - return withDefault && rules.isEmpty(); - } -} diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCodeActions.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCodeActions.java index 5f8b97e82..b9e6f3716 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCodeActions.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCodeActions.java @@ -30,8 +30,8 @@ import org.eclipse.lsp4j.Range; import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ConverterKind; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.ls.commons.BadLocationException; import org.eclipse.lsp4mp.ls.commons.CodeActionFactory; import org.eclipse.lsp4mp.ls.commons.TextDocument; @@ -43,7 +43,6 @@ import org.eclipse.lsp4mp.model.Property; import org.eclipse.lsp4mp.model.PropertyKey; import org.eclipse.lsp4mp.model.PropertyValue; -import org.eclipse.lsp4mp.model.values.ValuesRulesManager; import org.eclipse.lsp4mp.settings.MicroProfileCommandCapabilities; import org.eclipse.lsp4mp.settings.MicroProfileFormattingSettings; import org.eclipse.lsp4mp.utils.MicroProfilePropertiesUtils; @@ -76,8 +75,8 @@ class MicroProfileCodeActions { * @return the result of the code actions. */ public List doCodeActions(CodeActionContext context, Range range, PropertiesModel document, - MicroProfileProjectInfo projectInfo, ValuesRulesManager valuesRulesManager, - MicroProfileFormattingSettings formattingSettings, MicroProfileCommandCapabilities commandCapabilities) { + MicroProfileProjectInfo projectInfo, MicroProfileFormattingSettings formattingSettings, + MicroProfileCommandCapabilities commandCapabilities) { List codeActions = new ArrayList<>(); if (context.getDiagnostics() != null) { doCodeActionForAllRequired(context.getDiagnostics(), document, formattingSettings, codeActions); @@ -87,8 +86,7 @@ public List doCodeActions(CodeActionContext context, Range range, Pr // Manage code action for unknown doCodeActionsForUnknown(diagnostic, document, projectInfo, commandCapabilities, codeActions); } else if (ValidationType.value.isValidationType(diagnostic.getCode())) { - doCodeActionsForUnknownEnumValue(diagnostic, document, projectInfo, valuesRulesManager, - codeActions); + doCodeActionsForUnknownEnumValue(diagnostic, document, projectInfo, codeActions); } } } @@ -152,24 +150,23 @@ private void doCodeActionsForUnknown(Diagnostic diagnostic, PropertiesModel docu * @param diagnostic the diagnostic * @param document the properties model * @param projectInfo the MicroProfile properties - * @param valuesRulesManager the ValueRulesManager * @param codeActions the code actions list to fill */ private void doCodeActionsForUnknownEnumValue(Diagnostic diagnostic, PropertiesModel document, - MicroProfileProjectInfo projectInfo, ValuesRulesManager valuesRulesManager, List codeActions) { + MicroProfileProjectInfo projectInfo, List codeActions) { try { Node node = document.findNodeAt((diagnostic.getRange().getStart())); PropertyValue propertyValue = null; switch (node.getNodeType()) { - case PROPERTY_VALUE: - propertyValue = (PropertyValue) document.findNodeAt(diagnostic.getRange().getStart()); - break; - case PROPERTY_VALUE_EXPRESSION: - case PROPERTY_VALUE_LITERAL: - propertyValue = (PropertyValue) document.findNodeAt(diagnostic.getRange().getStart()).getParent(); - break; - default: - assert false; + case PROPERTY_VALUE: + propertyValue = (PropertyValue) document.findNodeAt(diagnostic.getRange().getStart()); + break; + case PROPERTY_VALUE_EXPRESSION: + case PROPERTY_VALUE_LITERAL: + propertyValue = (PropertyValue) document.findNodeAt(diagnostic.getRange().getStart()).getParent(); + break; + default: + assert false; } PropertyKey propertyKey = ((Property) propertyValue.getParent()).getKey(); String value = propertyValue.getValue(); @@ -180,8 +177,7 @@ private void doCodeActionsForUnknownEnumValue(Diagnostic diagnostic, PropertiesM return; } - Collection enums = MicroProfilePropertiesUtils.getEnums(metaProperty, projectInfo, document, - valuesRulesManager); + Collection enums = MicroProfilePropertiesUtils.getEnums(metaProperty, projectInfo, document); if (enums == null || enums.isEmpty()) { return; } @@ -257,7 +253,8 @@ private void doCodeActionForIgnoreUnknownValidation(String propertyName, Diagnos /** * Returns a code action for diagnostic that causes * item to be added to - * microprofile.tools.validation.unknown.excluded client configuration + * microprofile.tools.validation.unknown.excluded client + * configuration * * @param item the item to add to the client configuration array * @param diagnostic the diagnostic for the CodeAction @@ -268,8 +265,8 @@ private void doCodeActionForIgnoreUnknownValidation(String propertyName, Diagnos private CodeAction createAddToExcludedCodeAction(String item, Diagnostic diagnostic) { CodeAction insertCodeAction = new CodeAction("Exclude '" + item + "' from unknown property validation?"); - ConfigurationItemEdit configItemEdit = new ConfigurationItemEdit("microprofile.tools.validation.unknown.excluded", - ConfigurationItemEditType.add, item); + ConfigurationItemEdit configItemEdit = new ConfigurationItemEdit( + "microprofile.tools.validation.unknown.excluded", ConfigurationItemEditType.add, item); Command command = new Command("Add " + item + " to unknown excluded array", CommandKind.COMMAND_CONFIGURATION_UPDATE, Collections.singletonList(configItemEdit)); diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCompletions.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCompletions.java index cb9500878..af2aa4f5d 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCompletions.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileCompletions.java @@ -34,8 +34,8 @@ import org.eclipse.lsp4j.jsonrpc.CancelChecker; import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ConverterKind; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.ls.commons.BadLocationException; import org.eclipse.lsp4mp.ls.commons.SnippetsBuilder; import org.eclipse.lsp4mp.ls.commons.TextDocument; @@ -47,7 +47,6 @@ import org.eclipse.lsp4mp.model.PropertyGraph; import org.eclipse.lsp4mp.model.PropertyKey; import org.eclipse.lsp4mp.model.PropertyValueExpression; -import org.eclipse.lsp4mp.model.values.ValuesRulesManager; import org.eclipse.lsp4mp.settings.MicroProfileCompletionSettings; import org.eclipse.lsp4mp.settings.MicroProfileFormattingSettings; import org.eclipse.lsp4mp.snippets.LanguageId; @@ -73,14 +72,13 @@ class MicroProfileCompletions { * @param document the properties model document * @param position the position where completion was triggered * @param projectInfo the MicroProfile project information - * @param valuesRulesManager manager for values rules * @param completionSettings the completion settings * @param cancelChecker the cancel checker * @return completion list for the given position */ public CompletionList doComplete(PropertiesModel document, Position position, MicroProfileProjectInfo projectInfo, - ValuesRulesManager valuesRulesManager, MicroProfileCompletionSettings completionSettings, - MicroProfileFormattingSettings formattingSettings, CancelChecker cancelChecker) { + MicroProfileCompletionSettings completionSettings, MicroProfileFormattingSettings formattingSettings, + CancelChecker cancelChecker) { CompletionList list = new CompletionList(); int offset = -1; Node node = null; @@ -103,28 +101,28 @@ public CompletionList doComplete(PropertiesModel document, Position position, Mi case PROPERTY_VALUE_EXPRESSION: PropertyValueExpression propExpr = (PropertyValueExpression) node; if (offset == propExpr.getStart() || (propExpr.isClosed() && propExpr.getEnd() == offset)) { - collectPropertyValueSuggestions(node, document, projectInfo, valuesRulesManager, completionSettings, list); + collectPropertyValueSuggestions(node, document, projectInfo, completionSettings, list); } else { - collectPropertyValueExpressionSuggestions(node, document, projectInfo, valuesRulesManager, completionSettings, list); + collectPropertyValueExpressionSuggestions(node, document, projectInfo, completionSettings, list); } break; case ASSIGN: // Only collect if on right side of = if (offset >= node.getEnd()) { - collectPropertyValueSuggestions(node, document, projectInfo, valuesRulesManager, completionSettings, list); + collectPropertyValueSuggestions(node, document, projectInfo, completionSettings, list); } break; case PROPERTY_VALUE: case PROPERTY_VALUE_LITERAL: // completion on property value - collectPropertyValueSuggestions(node, document, projectInfo, valuesRulesManager, completionSettings, list); + collectPropertyValueSuggestions(node, document, projectInfo, completionSettings, list); break; default: // completion on property key - collectPropertyKeySuggestions(offset, node, document, projectInfo, valuesRulesManager, completionSettings, - formattingSettings, list); + collectPropertyKeySuggestions(offset, node, document, projectInfo, completionSettings, formattingSettings, + list); // Collect completion items with snippet collectSnippetSuggestions(offset, node, document, projectInfo, completionSettings, getSnippetRegistry(), list); @@ -139,14 +137,12 @@ public CompletionList doComplete(PropertiesModel document, Position position, Mi * @param offset the offset where completion was invoked * @param node the property key node * @param projectInfo the MicroProfile project information - * @param valuesRulesManager the values rules manager * @param completionSettings the completion settings * @param list the completion list to fill */ private static void collectPropertyKeySuggestions(int offset, Node node, PropertiesModel model, - MicroProfileProjectInfo projectInfo, ValuesRulesManager valuesRulesManager, - MicroProfileCompletionSettings completionSettings, MicroProfileFormattingSettings formattingSettings, - CompletionList list) { + MicroProfileProjectInfo projectInfo, MicroProfileCompletionSettings completionSettings, + MicroProfileFormattingSettings formattingSettings, CompletionList list) { boolean snippetsSupported = completionSettings.isCompletionSnippetsSupported(); boolean markdownSupported = completionSettings.isDocumentationFormatSupported(MarkupKind.MARKDOWN); @@ -192,8 +188,7 @@ private static void collectPropertyKeySuggestions(int offset, Node node, Propert item.setKind(CompletionItemKind.Property); String defaultValue = property.getDefaultValue(); - Collection enums = MicroProfilePropertiesUtils.getEnums(property, projectInfo, model, - valuesRulesManager); + Collection enums = MicroProfilePropertiesUtils.getEnums(property, projectInfo, model); StringBuilder insertText = new StringBuilder(); if (profile != null) { @@ -367,30 +362,29 @@ private static FormattedPropertyResult getPropertyName(String propertyName, bool * @param list the completion list to fill */ private static void collectPropertyValueSuggestions(Node node, PropertiesModel model, - MicroProfileProjectInfo projectInfo, ValuesRulesManager valuesRulesManager, - MicroProfileCompletionSettings completionSettings, CompletionList list) { + MicroProfileProjectInfo projectInfo, MicroProfileCompletionSettings completionSettings, + CompletionList list) { Property property = null; switch (node.getNodeType()) { - case ASSIGN: - case PROPERTY_VALUE: - property = (Property) node.getParent(); - break; - case PROPERTY_VALUE_LITERAL: - case PROPERTY_VALUE_EXPRESSION: - property = (Property) node.getParent().getParent(); - break; - default: - assert false; + case ASSIGN: + case PROPERTY_VALUE: + property = (Property) node.getParent(); + break; + case PROPERTY_VALUE_LITERAL: + case PROPERTY_VALUE_EXPRESSION: + property = (Property) node.getParent().getParent(); + break; + default: + assert false; } String propertyName = property.getPropertyName(); ItemMetadata item = MicroProfilePropertiesUtils.getProperty(propertyName, projectInfo); if (item != null) { - Collection enums = MicroProfilePropertiesUtils.getEnums(item, projectInfo, model, - valuesRulesManager); + Collection enums = MicroProfilePropertiesUtils.getEnums(item, projectInfo, model); if (enums != null && !enums.isEmpty()) { boolean markdownSupported = completionSettings.isDocumentationFormatSupported(MarkupKind.MARKDOWN); for (ValueHint e : enums) { @@ -401,24 +395,27 @@ private static void collectPropertyValueSuggestions(Node node, PropertiesModel m } } - private static void collectPropertyValueExpressionSuggestions(Node node, - PropertiesModel model, MicroProfileProjectInfo projectInfo, ValuesRulesManager valuesRulesManager, - MicroProfileCompletionSettings completionSettings, CompletionList list) { + private static void collectPropertyValueExpressionSuggestions(Node node, PropertiesModel model, + MicroProfileProjectInfo projectInfo, MicroProfileCompletionSettings completionSettings, + CompletionList list) { PropertyGraph graph = new PropertyGraph(node.getOwnerModel()); - // Find properties that won't make a circular dependency and suggest them for completion + // Find properties that won't make a circular dependency and suggest them for + // completion String completionPropertyName = ((Property) node.getParent().getParent()).getPropertyKey(); List independentProperties = graph.getIndependentProperties(completionPropertyName); // Add all independent properties as completion items for (String independentProperty : independentProperties) { list.getItems().add(getPropertyCompletionItem(independentProperty, (PropertyValueExpression) node, model)); } - // Add all properties not referenced in the properties file as completion options + // Add all properties not referenced in the properties file as completion + // options for (ItemMetadata candidateCompletion : projectInfo.getProperties()) { String candidateCompletionName = candidateCompletion.getName(); if (!graph.hasNode(candidateCompletionName)) { - list.getItems().add(getPropertyCompletionItem(candidateCompletionName, (PropertyValueExpression) node, model)); + list.getItems() + .add(getPropertyCompletionItem(candidateCompletionName, (PropertyValueExpression) node, model)); } } } @@ -470,12 +467,14 @@ private static CompletionItem getValueCompletionItem(ValueHint item, List doDiagnostics(PropertiesModel document, MicroProfileProjectInfo projectInfo, - ValuesRulesManager valuesRulesManager, MicroProfileValidationSettings validationSettings, - CancelChecker cancelChecker) { + MicroProfileValidationSettings validationSettings, CancelChecker cancelChecker) { if (validationSettings == null) { validationSettings = MicroProfileValidationSettings.DEFAULT; } List diagnostics = new ArrayList(); if (validationSettings.isEnabled()) { - MicroProfileValidator validator = new MicroProfileValidator(projectInfo, valuesRulesManager, diagnostics, - validationSettings); + MicroProfileValidator validator = new MicroProfileValidator(projectInfo, diagnostics, validationSettings); validator.validate(document, cancelChecker); } return diagnostics; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileDocumentHighlight.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileDocumentHighlight.java index 062e5e90c..acf7ff0f7 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileDocumentHighlight.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileDocumentHighlight.java @@ -23,11 +23,11 @@ import org.eclipse.lsp4j.Position; import org.eclipse.lsp4mp.ls.commons.BadLocationException; import org.eclipse.lsp4mp.model.Node; +import org.eclipse.lsp4mp.model.Node.NodeType; import org.eclipse.lsp4mp.model.PropertiesModel; import org.eclipse.lsp4mp.model.Property; import org.eclipse.lsp4mp.model.PropertyKey; import org.eclipse.lsp4mp.model.PropertyValueExpression; -import org.eclipse.lsp4mp.model.Node.NodeType; import org.eclipse.lsp4mp.utils.PositionUtils; /** diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileHover.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileHover.java index 0fa053f64..37908c7b4 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileHover.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileHover.java @@ -24,8 +24,8 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ConfigurationMetadata; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.ls.commons.BadLocationException; import org.eclipse.lsp4mp.model.Node; import org.eclipse.lsp4mp.model.Node.NodeType; @@ -35,7 +35,6 @@ import org.eclipse.lsp4mp.model.PropertyKey; import org.eclipse.lsp4mp.model.PropertyValue; import org.eclipse.lsp4mp.model.PropertyValueExpression; -import org.eclipse.lsp4mp.model.values.ValuesRulesManager; import org.eclipse.lsp4mp.settings.MicroProfileHoverSettings; import org.eclipse.lsp4mp.utils.DocumentationUtils; import org.eclipse.lsp4mp.utils.MicroProfilePropertiesUtils; @@ -51,15 +50,14 @@ class MicroProfileHover { /** * Returns Hover object for the currently hovered token * - * @param document the properties model document - * @param position the hover position - * @param projectInfo the MicroProfile project information - * @param valuesRulesManager manager for values rules - * @param hoverSettings the hover settings + * @param document the properties model document + * @param position the hover position + * @param projectInfo the MicroProfile project information + * @param hoverSettings the hover settings * @return Hover object for the currently hovered token */ public Hover doHover(PropertiesModel document, Position position, MicroProfileProjectInfo projectInfo, - ValuesRulesManager valuesRulesManager, MicroProfileHoverSettings hoverSettings) { + MicroProfileHoverSettings hoverSettings) { Node node = null; int offset = -1; @@ -75,29 +73,29 @@ public Hover doHover(PropertiesModel document, Position position, MicroProfilePr } switch (node.getNodeType()) { - case COMMENTS: - // no hover documentation - return null; - case PROPERTY_VALUE_EXPRESSION: - return getPropertyValueExpressionHover(node, projectInfo, hoverSettings); - case PROPERTY_VALUE_LITERAL: - // no hover documentation - return getPropertyValueHover(node.getParent(), projectInfo, valuesRulesManager, hoverSettings); - case PROPERTY_VALUE: - // no hover documentation - return getPropertyValueHover(node, projectInfo, valuesRulesManager, hoverSettings); - case PROPERTY_KEY: - PropertyKey key = (PropertyKey) node; - if (key.isBeforeProfile(offset)) { - // hover documentation on profile - return getProfileHover(key, hoverSettings); - } else { - // hover documentation on property key - return getPropertyKeyHover(key, projectInfo, hoverSettings); - } + case COMMENTS: + // no hover documentation + return null; + case PROPERTY_VALUE_EXPRESSION: + return getPropertyValueExpressionHover(node, projectInfo, hoverSettings); + case PROPERTY_VALUE_LITERAL: + // no hover documentation + return getPropertyValueHover(node.getParent(), projectInfo, hoverSettings); + case PROPERTY_VALUE: + // no hover documentation + return getPropertyValueHover(node, projectInfo, hoverSettings); + case PROPERTY_KEY: + PropertyKey key = (PropertyKey) node; + if (key.isBeforeProfile(offset)) { + // hover documentation on profile + return getProfileHover(key, hoverSettings); + } else { + // hover documentation on property key + return getPropertyKeyHover(key, projectInfo, hoverSettings); + } - default: - return null; + default: + return null; } } @@ -182,7 +180,7 @@ private static Hover getPropertyKeyHover(PropertyKey key, MicroProfileProjectInf * @return the documentation hover for property key represented by token */ private static Hover getPropertyValueHover(Node node, MicroProfileProjectInfo projectInfo, - ValuesRulesManager valuesRulesManager, MicroProfileHoverSettings hoverSettings) { + MicroProfileHoverSettings hoverSettings) { PropertyValue value = ((PropertyValue) node); boolean markdownSupported = hoverSettings.isContentFormatSupported(MarkupKind.MARKDOWN); // retrieve MicroProfile property from the project information @@ -192,7 +190,7 @@ private static Hover getPropertyValueHover(Node node, MicroProfileProjectInfo pr } String propertyName = ((Property) (value.getParent())).getPropertyName(); ItemMetadata item = MicroProfilePropertiesUtils.getProperty(propertyName, projectInfo); - ValueHint enumItem = getValueHint(propertyValue, item, projectInfo, valuesRulesManager, value.getOwnerModel()); + ValueHint enumItem = getValueHint(propertyValue, item, projectInfo, value.getOwnerModel()); if (enumItem != null) { // MicroProfile property enumeration item, found, display its documentation as // hover @@ -273,7 +271,7 @@ private static Range getProfileHoverRange(PropertyKey key) { } private static ValueHint getValueHint(String propertyValue, ItemMetadata metadata, - ConfigurationMetadata configuration, ValuesRulesManager valuesRulesManager, PropertiesModel model) { + ConfigurationMetadata configuration, PropertiesModel model) { if (metadata == null) { return null; } @@ -284,6 +282,6 @@ private static ValueHint getValueHint(String propertyValue, ItemMetadata metadat return valueHint; } } - return valuesRulesManager.getValueHint(propertyValue, metadata, model); + return null; } } \ No newline at end of file diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileLanguageService.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileLanguageService.java index 0e2733c4d..30c500fad 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileLanguageService.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileLanguageService.java @@ -36,7 +36,6 @@ import org.eclipse.lsp4mp.extensions.ExtendedMicroProfileProjectInfo; import org.eclipse.lsp4mp.ls.api.MicroProfilePropertyDefinitionProvider; import org.eclipse.lsp4mp.model.PropertiesModel; -import org.eclipse.lsp4mp.model.values.ValuesRulesManager; import org.eclipse.lsp4mp.settings.MicroProfileCommandCapabilities; import org.eclipse.lsp4mp.settings.MicroProfileCompletionSettings; import org.eclipse.lsp4mp.settings.MicroProfileFormattingSettings; @@ -59,13 +58,8 @@ public class MicroProfileLanguageService { private final MicroProfileFormatter formatter; private final MicroProfileCodeActions codeActions; private final MicroProfileDocumentHighlight documentHighlight; - private final ValuesRulesManager valuesRulesManager; public MicroProfileLanguageService() { - this(new ValuesRulesManager(true)); - } - - public MicroProfileLanguageService(ValuesRulesManager valuesRulesManger) { this.completions = new MicroProfileCompletions(); this.symbolsProvider = new MicroProfileSymbolsProvider(); this.hover = new MicroProfileHover(); @@ -74,7 +68,6 @@ public MicroProfileLanguageService(ValuesRulesManager valuesRulesManger) { this.formatter = new MicroProfileFormatter(); this.codeActions = new MicroProfileCodeActions(); this.documentHighlight = new MicroProfileDocumentHighlight(); - this.valuesRulesManager = valuesRulesManger; } /** @@ -91,8 +84,8 @@ public CompletionList doComplete(PropertiesModel document, Position position, Mi MicroProfileCompletionSettings completionSettings, MicroProfileFormattingSettings formattingSettings, CancelChecker cancelChecker) { updateProperties(projectInfo, document); - return completions.doComplete(document, position, projectInfo, getValuesRulesManager(), completionSettings, - formattingSettings, cancelChecker); + return completions.doComplete(document, position, projectInfo, completionSettings, formattingSettings, + cancelChecker); } /** @@ -107,7 +100,7 @@ public CompletionList doComplete(PropertiesModel document, Position position, Mi public Hover doHover(PropertiesModel document, Position position, MicroProfileProjectInfo projectInfo, MicroProfileHoverSettings hoverSettings) { updateProperties(projectInfo, document); - return hover.doHover(document, position, projectInfo, getValuesRulesManager(), hoverSettings); + return hover.doHover(document, position, projectInfo, hoverSettings); } /** @@ -151,7 +144,8 @@ public CompletableFuture, List> definitionLocationLinks = definition.findDefinition(document, position, projectInfo, provider); + CompletableFuture> definitionLocationLinks = definition.findDefinition(document, position, + projectInfo, provider); if (definitionLinkSupport) { return definitionLocationLinks.thenApply((List resolvedLinks) -> { return Either.forRight(resolvedLinks); @@ -205,8 +199,7 @@ public List doRangeFormat(PropertiesModel document, Range ra public List doDiagnostics(PropertiesModel document, MicroProfileProjectInfo projectInfo, MicroProfileValidationSettings validationSettings, CancelChecker cancelChecker) { updateProperties(projectInfo, document); - return diagnostics.doDiagnostics(document, projectInfo, getValuesRulesManager(), validationSettings, - cancelChecker); + return diagnostics.doDiagnostics(document, projectInfo, validationSettings, cancelChecker); } /** @@ -226,23 +219,14 @@ public List doCodeActions(CodeActionContext context, Range range, Pr MicroProfileProjectInfo projectInfo, MicroProfileFormattingSettings formattingSettings, MicroProfileCommandCapabilities commandCapabilities) { updateProperties(projectInfo, document); - return codeActions.doCodeActions(context, range, document, projectInfo, getValuesRulesManager(), - formattingSettings, commandCapabilities); + return codeActions.doCodeActions(context, range, document, projectInfo, formattingSettings, + commandCapabilities); } public List findDocumentHighlight(PropertiesModel document, Position position) { return documentHighlight.findDocumentHighlight(document, position); } - /** - * Returns the manager for values rules. - * - * @return the manager for values rules. - */ - private ValuesRulesManager getValuesRulesManager() { - return valuesRulesManager; - } - private void updateProperties(MicroProfileProjectInfo projectInfo, PropertiesModel document) { if (projectInfo instanceof ExtendedMicroProfileProjectInfo) { ((ExtendedMicroProfileProjectInfo) projectInfo).updateCustomProperties(document); diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileValidator.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileValidator.java index d38f354fe..dc71d4108 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileValidator.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/MicroProfileValidator.java @@ -37,7 +37,6 @@ import org.eclipse.lsp4mp.model.PropertiesModel; import org.eclipse.lsp4mp.model.Property; import org.eclipse.lsp4mp.model.PropertyValueExpression; -import org.eclipse.lsp4mp.model.values.ValuesRulesManager; import org.eclipse.lsp4mp.settings.MicroProfileValidationSettings; import org.eclipse.lsp4mp.utils.MicroProfilePropertiesUtils; import org.eclipse.lsp4mp.utils.PositionUtils; @@ -55,17 +54,16 @@ class MicroProfileValidator { private static final String MICROPROFILE_DIAGNOSTIC_SOURCE = "microprofile"; private final MicroProfileProjectInfo projectInfo; - private final ValuesRulesManager valuesRulesManager; + private final List diagnostics; private final MicroProfileValidationSettings validationSettings; private final Map> existingProperties; private Set allProperties; - public MicroProfileValidator(MicroProfileProjectInfo projectInfo, ValuesRulesManager valuesRulesManager, - List diagnostics, MicroProfileValidationSettings validationSettings) { + public MicroProfileValidator(MicroProfileProjectInfo projectInfo, List diagnostics, + MicroProfileValidationSettings validationSettings) { this.projectInfo = projectInfo; - this.valuesRulesManager = valuesRulesManager; this.diagnostics = diagnostics; this.validationSettings = validationSettings; this.existingProperties = new HashMap>(); @@ -215,7 +213,8 @@ private void validatePropertyValueExpressions(Property property) { } String refdProp = propValExpr.getReferencedPropertyName(); if (!allProperties.contains(refdProp)) { - Range range = PositionUtils.createAdjustedRange(propValExpr, 2, propValExpr.isClosed()? -1 : 0); + Range range = PositionUtils.createAdjustedRange(propValExpr, 2, + propValExpr.isClosed() ? -1 : 0); if (range != null) { addDiagnostic("Unknown referenced property '" + refdProp + "'", range, expressionSeverity, ValidationType.expression.name()); @@ -240,8 +239,7 @@ private void validatePropertyValueExpressions(Property property) { */ private String getErrorIfInvalidEnum(ItemMetadata metadata, ConfigurationMetadata configuration, PropertiesModel model, String value) { - if (!configuration.isValidEnum(metadata, value) - || (valuesRulesManager != null && !valuesRulesManager.isValidEnum(metadata, model, value))) { + if (!configuration.isValidEnum(metadata, value)) { return "Invalid enum value: '" + value + "' is invalid for type " + metadata.getType(); } return null; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/QuarkusModel.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/QuarkusModel.java index dfbef22c0..c1a420b66 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/QuarkusModel.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/services/QuarkusModel.java @@ -18,7 +18,7 @@ import java.util.stream.Collectors; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; /** * Maintains default profiles and boolean types. diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/AllMicroProfileSettings.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/AllMicroProfileSettings.java index 9841a0fce..ed5f5bd99 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/AllMicroProfileSettings.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/AllMicroProfileSettings.java @@ -13,11 +13,11 @@ *******************************************************************************/ package org.eclipse.lsp4mp.settings; -import com.google.gson.annotations.JsonAdapter; - import org.eclipse.lsp4j.jsonrpc.json.adapters.JsonElementTypeAdapter; import org.eclipse.lsp4mp.utils.JSONUtility; +import com.google.gson.annotations.JsonAdapter; + /** * Represents all settings under the 'microprofile' key * diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/InitializationOptionsSettings.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/InitializationOptionsSettings.java index ca1451fdb..4f678d558 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/InitializationOptionsSettings.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/InitializationOptionsSettings.java @@ -13,12 +13,12 @@ *******************************************************************************/ package org.eclipse.lsp4mp.settings; -import com.google.gson.annotations.JsonAdapter; - import org.eclipse.lsp4j.InitializeParams; import org.eclipse.lsp4j.jsonrpc.json.adapters.JsonElementTypeAdapter; import org.eclipse.lsp4mp.utils.JSONUtility; +import com.google.gson.annotations.JsonAdapter; + /** * Represents all settings sent from the server * diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilityManager.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilityManager.java index d23f50c0c..6887c1e0d 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilityManager.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/settings/capabilities/MicroProfileCapabilityManager.java @@ -18,20 +18,20 @@ import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.COMPLETION_ID; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_COMPLETION_OPTIONS; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.DEFINITION_ID; +import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.DOCUMENT_HIGHLIGHT_ID; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.DOCUMENT_SYMBOL_ID; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.FORMATTING_ID; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.HOVER_ID; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.RANGE_FORMATTING_ID; -import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.DOCUMENT_HIGHLIGHT_ID; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_CODE_ACTION; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_CODE_LENS; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_COMPLETION; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_DEFINITION; +import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_DOCUMENT_HIGHLIGHT; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_DOCUMENT_SYMBOL; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_FORMATTING; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_HOVER; import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_RANGE_FORMATTING; -import static org.eclipse.lsp4mp.settings.capabilities.ServerCapabilitiesConstants.TEXT_DOCUMENT_DOCUMENT_HIGHLIGHT; import java.util.ArrayList; import java.util.Collections; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForJava.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForJava.java index 567bc681a..8b6bc51ab 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForJava.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForJava.java @@ -17,14 +17,14 @@ import java.util.ArrayList; import java.util.List; +import org.eclipse.lsp4mp.commons.ProjectLabelInfoEntry; +import org.eclipse.lsp4mp.ls.commons.snippets.ISnippetContext; + import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; -import org.eclipse.lsp4mp.commons.ProjectLabelInfoEntry; -import org.eclipse.lsp4mp.ls.commons.snippets.ISnippetContext; - /** * A snippet context for Java files which matches java scope and dependency. * diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForProperties.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForProperties.java index 4e08aa2c4..fc3bba8d5 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForProperties.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/snippets/SnippetContextForProperties.java @@ -17,16 +17,16 @@ import java.util.ArrayList; import java.util.List; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.google.gson.stream.JsonWriter; - import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; import org.eclipse.lsp4mp.ls.commons.snippets.ISnippetContext; import org.eclipse.lsp4mp.utils.MicroProfilePropertiesUtils; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; + /** * A snippet context properties which matches properties. You can write a vscode * snippet that declares a context like this: diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/DocumentationUtils.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/DocumentationUtils.java index 35dff41dc..49073e009 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/DocumentationUtils.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/DocumentationUtils.java @@ -18,8 +18,8 @@ import org.eclipse.lsp4j.MarkupContent; import org.eclipse.lsp4j.MarkupKind; import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; /** * Utility for documentation. diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONSchemaUtils.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONSchemaUtils.java index 4c82e3163..4b2bd923c 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONSchemaUtils.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONSchemaUtils.java @@ -15,15 +15,15 @@ import java.util.List; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ConfigurationMetadata; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; /** * JSON Schema utilities. diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONUtility.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONUtility.java index bb36e6014..c44868e9a 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONUtility.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/JSONUtility.java @@ -13,12 +13,12 @@ *******************************************************************************/ package org.eclipse.lsp4mp.utils; +import org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter; + import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; -import org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter; - /** * JSONUtility */ diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/MicroProfilePropertiesUtils.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/MicroProfilePropertiesUtils.java index 8ad5fc178..23aaf519e 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/MicroProfilePropertiesUtils.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/utils/MicroProfilePropertiesUtils.java @@ -19,11 +19,10 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ConfigurationMetadata; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.ls.commons.SnippetsBuilder; import org.eclipse.lsp4mp.model.PropertiesModel; -import org.eclipse.lsp4mp.model.values.ValuesRulesManager; import org.eclipse.lsp4mp.services.QuarkusModel; /** @@ -87,24 +86,24 @@ public int getParameterCount() { /** * Returns the enums values according the property type. * - * @param property the property - * @param projectInfo - * @param valuesRulesManager - * @param model + * @param property the property. + * @param configuration the configuration. + * @param model the properties model. * @return the enums values according the property type */ public static Collection getEnums(ItemMetadata property, ConfigurationMetadata configuration, - PropertiesModel model, ValuesRulesManager valuesRulesManager) { + PropertiesModel model) { ItemHint hint = configuration.getHint(property); if (hint != null) { + ItemHint handleAsHint = configuration.getHandleAsHint(hint); + if (handleAsHint != null) { + return handleAsHint.getValues(); + } return hint.getValues(); } if (property.isBooleanType()) { return QuarkusModel.BOOLEAN_ENUMS.getValues(); } - if (valuesRulesManager != null) { - return valuesRulesManager.getValues(property, model); - } return null; } diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/resources/org/eclipse/lsp4mp/model/values/quarkus-values-rules.json b/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/resources/org/eclipse/lsp4mp/model/values/quarkus-values-rules.json deleted file mode 100644 index 0ab338395..000000000 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/resources/org/eclipse/lsp4mp/model/values/quarkus-values-rules.json +++ /dev/null @@ -1,78 +0,0 @@ - -{ - "definitions": [ - { - "id": "#logginglevel", - "values": [ - { - "value": "OFF", - "description": "OFF is a special level that can be used to turn off logging.\nThis level is initialized to `Integer.MAX_VALUE`." - }, - { - "value": "SEVERE", - "description": "SEVERE is a message level indicating a serious failure.\n\nIn general SEVERE messages should describe events that are of considerable importance and which will prevent normal program execution. They should be reasonably intelligible to end users and to system administrators. This level is initialized to `1000`." - }, - { - "value": "WARNING", - "description": "WARNING is a message level indicating a potential problem.\n\nIn general WARNING messages should describe events that will be of interest to end users or system managers, or which indicate potential problems. This level is initialized to `900`." - }, - { - "value": "INFO", - "description": "INFO is a message level for informational messages.\n\nTypically INFO messages will be written to the console or its equivalent. So the INFO level should only be used for reasonably significant messages that will make sense to end users and system administrators. This level is initialized to `800`." - }, - { - "value": "CONFIG", - "description": "CONFIG is a message level for static configuration messages.\n\nCONFIG messages are intended to provide a variety of static configuration information, to assist in debugging problems that may be associated with particular configurations. For example, CONFIG message might include the CPU type, the graphics depth, the GUI look-and-feel, etc. This level is initialized to `700`." - }, - { - "value": "FINE", - "description": "FINE is a message level providing tracing information.\n\nAll of FINE, FINER, and FINEST are intended for relatively detailed tracing. The exact meaning of the three levels will vary between subsystems, but in general, FINEST should be used for the most voluminous detailed output, FINER for somewhat less detailed output, and FINE for the lowest volume (and most important) messages.\n\nIn general the FINE level should be used for information that will be broadly interesting to developers who do not have a specialized interest in the specific subsystem.\n\nFINE messages might include things like minor (recoverable) failures. Issues indicating potential performance problems are also worth logging as FINE. This level is initialized to `500`." - }, - { - "value": "FINER", - "description": "FINER indicates a fairly detailed tracing message. By default logging calls for entering, returning, or throwing an exception are traced at this level. This level is initialized to `400`." - }, - { - "value": "FINEST", - "description": "FINEST indicates a highly detailed tracing message. This level is initialized to `300`." - }, - { - "value": "ALL", - "description": "ALL indicates that all messages should be logged. This level is initialized to `Integer.MIN_VALUE`." - } - ] - } - ], - "rules": [ - { - "matcher": { - "types": [ - "java.util.logging.Level", - "java.util.Optional" - ] - }, - "valuesRef": [ - "#logginglevel" - ] - }, - { - "matcher": { - "names": [ - "quarkus.log.category.{*}.level", - "quarkus.log.category.{*}.min-level" - ] - }, - "valuesRef": [ - "#logginglevel" - ], - "values": [ - { - "value": "DEBUG" - }, - { - "value": "ERROR" - } - ] - } - ] -} \ No newline at end of file diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/commons/MicroProfileProjectInfoTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/commons/MicroProfileProjectInfoTest.java index f7948b7f2..887c63c1c 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/commons/MicroProfileProjectInfoTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/commons/MicroProfileProjectInfoTest.java @@ -13,7 +13,6 @@ import static org.eclipse.lsp4mp.utils.MicroProfilePropertiesUtils.formatPropertyForCompletion; import static org.eclipse.lsp4mp.utils.MicroProfilePropertiesUtils.formatPropertyForMarkdown; -import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.model.PropertiesModel; import org.eclipse.lsp4mp.model.Property; import org.eclipse.lsp4mp.model.PropertyKey; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfoTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfoTest.java index 3ccb98f0f..0ee1e53e6 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfoTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/extensions/ExtendedMicroProfileProjectInfoTest.java @@ -13,8 +13,8 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.junit.Assert; import org.junit.Test; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentSnippetRegistryTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentSnippetRegistryTest.java index 9b51a9c67..d2558bba2 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentSnippetRegistryTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentSnippetRegistryTest.java @@ -16,7 +16,6 @@ import java.util.Optional; import org.eclipse.lsp4mp.commons.ProjectLabelInfoEntry; -import org.eclipse.lsp4mp.ls.JavaTextDocumentSnippetRegistry; import org.eclipse.lsp4mp.ls.commons.snippets.ISnippetContext; import org.eclipse.lsp4mp.ls.commons.snippets.Snippet; import org.eclipse.lsp4mp.ls.commons.snippets.SnippetRegistry; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentsTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentsTest.java index 762bba23b..833cbd883 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentsTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/JavaTextDocumentsTest.java @@ -19,7 +19,6 @@ import org.eclipse.lsp4j.TextDocumentItem; import org.eclipse.lsp4mp.commons.MicroProfileJavaProjectLabelsParams; import org.eclipse.lsp4mp.commons.ProjectLabelInfoEntry; -import org.eclipse.lsp4mp.ls.JavaTextDocuments; import org.eclipse.lsp4mp.ls.JavaTextDocuments.JavaTextDocument; import org.eclipse.lsp4mp.ls.api.MicroProfileJavaProjectLabelsProvider; import org.junit.Assert; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServerScopeChangedTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServerScopeChangedTest.java index 64f529603..f1ff5ed2e 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServerScopeChangedTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileLanguageServerScopeChangedTest.java @@ -25,8 +25,7 @@ import org.eclipse.lsp4j.TextDocumentItem; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; -import org.eclipse.lsp4mp.ls.MicroProfileLanguageServer; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.ls.api.MicroProfileLanguageClientAPI; import org.junit.Assert; import org.junit.Test; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileProjectInfoCacheTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileProjectInfoCacheTest.java index 1ed58956d..a91c723fa 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileProjectInfoCacheTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MicroProfileProjectInfoCacheTest.java @@ -20,7 +20,6 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfoParams; import org.eclipse.lsp4mp.commons.MicroProfilePropertiesChangeEvent; import org.eclipse.lsp4mp.commons.MicroProfilePropertiesScope; -import org.eclipse.lsp4mp.ls.MicroProfileProjectInfoCache; import org.eclipse.lsp4mp.ls.api.MicroProfileProjectInfoProvider; import org.junit.Assert; import org.junit.Test; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MockMicroProfileLanguageClient.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MockMicroProfileLanguageClient.java index 6ff8b5a73..d46264bc0 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MockMicroProfileLanguageClient.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/MockMicroProfileLanguageClient.java @@ -30,7 +30,6 @@ import org.eclipse.lsp4mp.commons.metadata.ItemBase; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.eclipse.lsp4mp.ls.MicroProfileLanguageServer; import org.eclipse.lsp4mp.ls.api.MicroProfileLanguageClientAPI; import org.eclipse.lsp4mp.ls.api.MicroProfilePropertyDefinitionProvider; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistryTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistryTest.java index 7fe8088ac..819fa7006 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistryTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/ls/commons/snippets/SnippetRegistryTest.java @@ -19,9 +19,6 @@ import java.io.StringReader; import java.util.Arrays; -import org.eclipse.lsp4mp.ls.commons.snippets.Snippet; -import org.eclipse.lsp4mp.ls.commons.snippets.SnippetRegistry; -import org.eclipse.lsp4mp.ls.commons.snippets.TextDocumentSnippetRegistry; import org.junit.Assert; import org.junit.Test; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/parser/PropertiesModelTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/parser/PropertiesModelTest.java index 8c24a6297..329a8d9fc 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/parser/PropertiesModelTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/parser/PropertiesModelTest.java @@ -10,11 +10,11 @@ package org.eclipse.lsp4mp.parser; import org.eclipse.lsp4mp.model.Node; +import org.eclipse.lsp4mp.model.Node.NodeType; import org.eclipse.lsp4mp.model.PropertiesModel; import org.eclipse.lsp4mp.model.Property; import org.eclipse.lsp4mp.model.PropertyValueExpression; import org.eclipse.lsp4mp.model.PropertyValueLiteral; -import org.eclipse.lsp4mp.model.Node.NodeType; import org.junit.Assert; import org.junit.Test; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCodeActionsTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCodeActionsTest.java index a1b1530fd..71d4d6686 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCodeActionsTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCodeActionsTest.java @@ -156,7 +156,8 @@ public void codeActionsForUnknownLogLevelStartsWith() throws BadLocationExceptio testDiagnosticsFor(value, d); testCodeActionsFor(value, d, ca("Did you mean 'FINE'?", te(0, 18, 0, 19, "FINE"), d), ca("Did you mean 'FINER'?", te(0, 18, 0, 19, "FINER"), d), - ca("Did you mean 'FINEST'?", te(0, 18, 0, 19, "FINEST"), d)); + ca("Did you mean 'FINEST'?", te(0, 18, 0, 19, "FINEST"), d), + ca("Did you mean 'FATAL'?", te(0, 18, 0, 19, "FATAL"), d)); }; @Test diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCompletionTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCompletionTest.java index 9d9fd41a0..25f9ef6f5 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCompletionTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesCompletionTest.java @@ -63,7 +63,7 @@ public void completionOnKeyMap() throws BadLocationException { testCompletionFor(value, false, c("quarkus.log.category.{*}.level", "quarkus.log.category.{*}.level=inherit", r(0, 0, 20))); testCompletionFor(value, true, c("quarkus.log.category.{*}.level", - "quarkus.log.category.${1:key}.level=${2|DEBUG,ERROR,OFF,SEVERE,WARNING,INFO,CONFIG,FINE,FINER,FINEST,ALL|}", + "quarkus.log.category.${1:key}.level=${2|OFF,SEVERE,WARNING,CONFIG,FINE,FINER,FINEST,ALL,FATAL,ERROR,WARN,INFO,DEBUG,TRACE|}", r(0, 0, 20))); } @@ -75,7 +75,7 @@ public void completionOnEmptyLine() throws BadLocationException { testCompletionFor(value, false, c("quarkus.log.category.{*}.level", "quarkus.log.category.{*}.level=inherit", r(1, 0, 0))); testCompletionFor(value, true, c("quarkus.log.category.{*}.level", - "quarkus.log.category.${1:key}.level=${2|DEBUG,ERROR,OFF,SEVERE,WARNING,INFO,CONFIG,FINE,FINER,FINEST,ALL|}", + "quarkus.log.category.${1:key}.level=${2|OFF,SEVERE,WARNING,CONFIG,FINE,FINER,FINEST,ALL,FATAL,ERROR,WARN,INFO,DEBUG,TRACE|}", r(1, 0, 0))); } 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 f12158432..d0bc1c9c7 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 @@ -22,8 +22,8 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ConverterKind; import org.eclipse.lsp4mp.commons.metadata.ItemHint; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.eclipse.lsp4mp.ls.commons.BadLocationException; import org.eclipse.lsp4mp.settings.MicroProfileValidationSettings; import org.eclipse.lsp4mp.settings.MicroProfileValidationTypeSettings; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDocumentHighlightTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDocumentHighlightTest.java index 48cc38f14..cae60afbc 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDocumentHighlightTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesDocumentHighlightTest.java @@ -14,12 +14,11 @@ package org.eclipse.lsp4mp.services; -import org.junit.Test; - -import static org.eclipse.lsp4mp.services.MicroProfileAssert.r; import static org.eclipse.lsp4mp.services.MicroProfileAssert.assertDocumentHighlight; +import static org.eclipse.lsp4mp.services.MicroProfileAssert.r; import org.eclipse.lsp4mp.ls.commons.BadLocationException; +import org.junit.Test; /** * Tests for the document highlight in MicroProfile properties files diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesHoverTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesHoverTest.java index 94e1f4857..79729ea70 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesHoverTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesHoverTest.java @@ -174,15 +174,12 @@ public void hoverWithEnums() throws BadLocationException { @Test public void hoverOnValueForLevelBasedOnRule() throws BadLocationException { - // quarkus.log.file.level has 'java.util.logging.Level' which has no - // enumeration - // to fix it, quarkus-values-rules.json defines the Level enumerations + // quarkus.log.file.level has 'java.util.logging.Level' String value = "quarkus.log.file.level=OF|F "; String hoverLabel = "**OFF**" + // System.lineSeparator() + // System.lineSeparator() + // - "OFF is a special level that can be used to turn off logging.\nThis level is initialized to `Integer.MAX_VALUE`." - + // + "`OFF` is a special level that can be used to turn off logging.\nThis level is initialized to `Integer.MAX_VALUE`." + // System.lineSeparator(); assertHoverMarkdown(value, hoverLabel, 23); } @@ -222,8 +219,7 @@ public void hoverResolveTwoSteps() throws BadLocationException { String value = "property.one = hello\n" + // "property.two = ${property.one}\n" + // "property.three = ${property.two}\n" + // - "property.four = ${property.three}\n" + - "property.five = ${property|.four}"; + "property.four = ${property.three}\n" + "property.five = ${property|.four}"; String hoverLabel = "hello"; assertHoverMarkdown(value, hoverLabel, 16); } @@ -295,15 +291,21 @@ public void hoverMultilineReferencePropertyExpression() throws BadLocationExcept @Test public void hoverKeyWithReference() throws BadLocationException { - String value = "value = value\n" + // + String value = "value = value\n" + // "mp.metri|cs.appName=${value}"; assertHoverMarkdown(value, // - "**mp.metrics.appName**\n" + // - "\nThe app name.\n\n" + // - " * Type: `java.lang.String`\n" + // - " * Value: `value`\n" + // - " * Extension: `microprofile-metrics-api`" - , 0); + "**mp.metrics.appName**" + // + System.lineSeparator() + // + System.lineSeparator() + // + "The app name." + // + System.lineSeparator() + // + System.lineSeparator() + // + " * Type: `java.lang.String`" + // + System.lineSeparator() + // + " * Value: `value`" + // + System.lineSeparator() + // + " * Extension: `microprofile-metrics-api`", + 0); } @Test @@ -321,15 +323,21 @@ public void hoverKeyUndefinedPropertyWithReference() throws BadLocationException @Test public void hoverKeyWithReferenceAndSelfLoop() throws BadLocationException { - String value = "value = ${value}\n" + // + String value = "value = ${value}\n" + // "mp.metri|cs.appName=${value}"; assertHoverMarkdown(value, // - "**mp.metrics.appName**\n" + // - "\nThe app name.\n\n" + // - " * Type: `java.lang.String`\n" + // - " * Value: `${value}`\n" + // - " * Extension: `microprofile-metrics-api`" - , 0); + "**mp.metrics.appName**" + // + System.lineSeparator() + // + System.lineSeparator() + // + "The app name." + // + System.lineSeparator() + // + System.lineSeparator() + // + " * Type: `java.lang.String`" + // + System.lineSeparator() + // + " * Value: `${value}`" + // + System.lineSeparator() + // + " * Extension: `microprofile-metrics-api`", + 0); } @Test @@ -337,11 +345,16 @@ public void hoverKeyWithReferenceToEmptyProperty() throws BadLocationException { String value = "value =\n" + // "mp.metri|cs.appName = ${value}"; assertHoverMarkdown(value, // - "**mp.metrics.appName**\n" + // - "\nThe app name.\n\n" + // - " * Type: `java.lang.String`\n" + // - " * Extension: `microprofile-metrics-api`" - , 0); + "**mp.metrics.appName**" + // + System.lineSeparator() + // + System.lineSeparator() + // + "The app name." + // + System.lineSeparator() + // + System.lineSeparator() + // + " * Type: `java.lang.String`" + // + System.lineSeparator() + // + " * Extension: `microprofile-metrics-api`", + 0); } @Test @@ -349,11 +362,16 @@ public void hoverKeyWithReferenceToBlankProperty() throws BadLocationException { String value = "value = \n" + // "mp.metri|cs.appName = ${value}"; assertHoverMarkdown(value, // - "**mp.metrics.appName**\n" + // - "\nThe app name.\n\n" + // - " * Type: `java.lang.String`\n" + // - " * Extension: `microprofile-metrics-api`" - , 0); + "**mp.metrics.appName**" + // + System.lineSeparator() + // + System.lineSeparator() + // + "The app name." + // + System.lineSeparator() + // + System.lineSeparator() + // + " * Type: `java.lang.String`" + // + System.lineSeparator() + // + " * Extension: `microprofile-metrics-api`", + 0); } @Test diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredCodeActionTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredCodeActionTest.java index 4f6c8df16..fb80fca8d 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredCodeActionTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredCodeActionTest.java @@ -23,7 +23,6 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; import org.eclipse.lsp4mp.ls.commons.BadLocationException; -import org.eclipse.lsp4mp.services.ValidationType; import org.eclipse.lsp4mp.settings.MicroProfileFormattingSettings; import org.eclipse.lsp4mp.settings.MicroProfileValidationSettings; import org.eclipse.lsp4mp.settings.MicroProfileValidationTypeSettings; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredDiagnosticsTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredDiagnosticsTest.java index aedd170ad..14d3aabb3 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredDiagnosticsTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/ApplicationPropertiesRequiredDiagnosticsTest.java @@ -19,7 +19,6 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; import org.eclipse.lsp4mp.ls.commons.BadLocationException; -import org.eclipse.lsp4mp.services.ValidationType; import org.eclipse.lsp4mp.settings.MicroProfileValidationSettings; import org.eclipse.lsp4mp.settings.MicroProfileValidationTypeSettings; import org.junit.BeforeClass; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/MicroProfileAssert.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/MicroProfileAssert.java index 1349dc67f..1d50ff957 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/MicroProfileAssert.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/services/MicroProfileAssert.java @@ -28,7 +28,6 @@ import org.eclipse.lsp4j.CompletionList; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.DiagnosticSeverity; -import org.eclipse.lsp4j.DocumentHighlight; import org.eclipse.lsp4j.DocumentSymbol; import org.eclipse.lsp4j.Hover; import org.eclipse.lsp4j.HoverCapabilities; 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..67a297a07 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; 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..f87de35a7 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; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/utils/JSONSchemaUtilsTest.java b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/utils/JSONSchemaUtilsTest.java index 6f320a2e8..1abddeb90 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/utils/JSONSchemaUtilsTest.java +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/java/org/eclipse/lsp4mp/utils/JSONSchemaUtilsTest.java @@ -16,8 +16,7 @@ import org.eclipse.lsp4mp.commons.MicroProfileProjectInfo; import org.eclipse.lsp4mp.commons.metadata.ItemHint; import org.eclipse.lsp4mp.commons.metadata.ItemMetadata; -import org.eclipse.lsp4mp.commons.metadata.ItemHint.ValueHint; -import org.eclipse.lsp4mp.utils.JSONSchemaUtils; +import org.eclipse.lsp4mp.commons.metadata.ValueHint; import org.junit.Assert; import org.junit.Test; diff --git a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/resources/org/eclipse/lsp4mp/services/all-quarkus-properties.json b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/resources/org/eclipse/lsp4mp/services/all-quarkus-properties.json index a74fbc0e6..27985902f 100644 --- a/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/resources/org/eclipse/lsp4mp/services/all-quarkus-properties.json +++ b/microprofile.ls/org.eclipse.lsp4mp.ls/src/test/resources/org/eclipse/lsp4mp/services/all-quarkus-properties.json @@ -15907,6 +15907,79 @@ ], "name": "io.smallrye.jwt.KeyFormat", "sourceType": "io.smallrye.jwt.KeyFormat" - } + }, + { + "name": "java.util.logging.Level", + "sourceType": "java.util.logging.Level", + "values": [ + { + "value": "OFF", + "description": "`OFF` is a special level that can be used to turn off logging.\nThis level is initialized to `Integer.MAX_VALUE`." + }, + { + "value": "SEVERE", + "description": "`SEVERE` is a message level indicating a serious failure.\n\nIn general SEVERE messages should describe events that are of considerable importance and which will prevent normal program execution. They should be reasonably intelligible to end users and to system administrators. This level is initialized to `1000`." + }, + { + "value": "WARNING", + "description": "`WARNING` is a message level indicating a potential problem.\n\nIn general WARNING messages should describe events that will be of interest to end users or system managers, or which indicate potential problems. This level is initialized to `900`." + }, + { + "value": "CONFIG", + "description": "`CONFIG` is a message level for static configuration messages.\n\nCONFIG messages are intended to provide a variety of static configuration information, to assist in debugging problems that may be associated with particular configurations. For example, CONFIG message might include the CPU type, the graphics depth, the GUI look-and-feel, etc. This level is initialized to `700`." + }, + { + "value": "FINE", + "description": "`FINE` is a message level providing tracing information.\n\nAll of FINE, FINER, and FINEST are intended for relatively detailed tracing. The exact meaning of the three levels will vary between subsystems, but in general, FINEST should be used for the most voluminous detailed output, FINER for somewhat less detailed output, and FINE for the lowest volume (and most important) messages.\n\nIn general the FINE level should be used for information that will be broadly interesting to developers who do not have a specialized interest in the specific subsystem.\n\nFINE messages might include things like minor (recoverable) failures. Issues indicating potential performance problems are also worth logging as FINE. This level is initialized to `500`." + }, + { + "value": "FINER", + "description": "`FINER` indicates a fairly detailed tracing message. By default logging calls for entering, returning, or throwing an exception are traced at this level. This level is initialized to `400`." + }, + { + "value": "FINEST", + "description": "`FINEST` indicates a highly detailed tracing message. This level is initialized to `300`." + }, + { + "value": "ALL", + "description": "`ALL` indicates that all messages should be logged. This level is initialized to `Integer.MIN_VALUE`." + }, + { + "value": "FATAL", + "description": "Use the `FATAL` level priority for events that indicate a critical service failure. If a service issues a FATAL error it is completely unable to service requests of any kind." + }, + { + "value": "ERROR", + "description": "Use the `ERROR` level priority for events that indicate a disruption in a request or the ability to service a request. A service should have some capacity to continue to service requests in the presence of ERRORs." + }, + { + "value": "WARN", + "description": "Use the `WARN` level priority for events that may indicate a non-critical service error. Resumable errors, or minor breaches in request expectations fall into this category. The distinction between WARN and ERROR may be hard to discern and so its up to the developer to judge. The simplest criterion is would this failure result in a user support call. If it would use ERROR. If it would not use WARN." + }, + { + "value": "INFO", + "description": "Use the `INFO` level priority for service life-cycle events and other crucial related information. Looking at the INFO messages for a given service category should tell you exactly what state the service is in." + }, + { + "value": "DEBUG", + "description": "Use the `DEBUG` level priority for log messages that convey extra information regarding life-cycle events. Developer or in depth information required for support is the basis for this priority. The important point is that when the DEBUG level priority is enabled, the JBoss server log should not grow proportionally with the number of server requests. Looking at the DEBUG and INFO messages for a given service category should tell you exactly what state the service is in, as well as what server resources it is using: ports, interfaces, log files, etc." + }, + { + "value": "TRACE", + "description": "Use `TRACE` the level priority for log messages that are directly associated with activity that corresponds requests. Further, such messages should not be submitted to a Logger unless the Logger category priority threshold indicates that the message will be rendered. Use the Logger.isTraceEnabled() method to determine if the category priority threshold is enabled. The point of the TRACE priority is to allow for deep probing of the JBoss server behavior when necessary. When the TRACE level priority is enabled, you can expect the number of messages in the JBoss server log to grow at least a x N, where N is the number of requests received by the server, a some constant. The server log may well grow as power of N depending on the request-handling layer being traced." + } + ] + }, + { + "name": "quarkus.log.category.{*}.level", + "providers": [ + { + "name": "handle-as", + "parameters": { + "target": "java.util.logging.Level" + } + } + ] + } ] } \ No newline at end of file