Merge branch 'master' of github.com:spring-projects/sts4
This commit is contained in:
@@ -15,10 +15,10 @@ import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncKind;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.completions.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.completions.RelaxedNameConfig;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtilProvider;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.boot.common.RelaxedNameConfig;
|
||||
import org.springframework.ide.vscode.boot.properties.completions.SpringPropertiesCompletionEngine;
|
||||
import org.springframework.ide.vscode.boot.properties.hover.PropertiesHoverInfoProvider;
|
||||
import org.springframework.ide.vscode.boot.properties.reconcile.SpringPropertiesReconcileEngine;
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2015, 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.common;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ScoreableProposal;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.yaml.hover.YPropertyHoverInfo;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YType;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil;
|
||||
|
||||
public abstract class AbstractPropertyProposal extends ScoreableProposal {
|
||||
|
||||
@Override
|
||||
public String getDetail() {
|
||||
return niceTypeName(getType());
|
||||
}
|
||||
|
||||
protected final IDocument fDoc;
|
||||
private final DocumentEdits proposalApplier;
|
||||
private boolean isDeprecated = false;
|
||||
|
||||
public AbstractPropertyProposal(IDocument doc, DocumentEdits applier) {
|
||||
this.proposalApplier = applier;
|
||||
this.fDoc = doc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return getBaseDisplayString();
|
||||
}
|
||||
|
||||
// public IRegion getSelection(IDocument document) {
|
||||
// try {
|
||||
// return proposalApplier.getSelection(document);
|
||||
// } catch (Exception e) {
|
||||
// Log.log(e);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// public String getDisplayString() {
|
||||
// StyledString styledText = getStyledDisplayString();
|
||||
// return styledText.getString();
|
||||
// }
|
||||
|
||||
// public Image getImage() {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// public IContextInformation getContextInformation() {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public StyledString getStyledDisplayString() {
|
||||
// StyledString result = new StyledString();
|
||||
// result = result.append(super.getStyledDisplayString());
|
||||
// YType type = getType();
|
||||
// if (type!=null) {
|
||||
// String typeStr = niceTypeName(type);
|
||||
// result.append(" : "+typeStr, StyledString.DECORATIONS_STYLER);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
protected boolean isDeprecated() {
|
||||
return isDeprecated;
|
||||
}
|
||||
public void deprecate() {
|
||||
if (!isDeprecated()) {
|
||||
deemphasize();
|
||||
deemphasize();
|
||||
isDeprecated = true;
|
||||
}
|
||||
}
|
||||
protected abstract YType getType();
|
||||
protected abstract String getHighlightPattern();
|
||||
protected abstract String getBaseDisplayString();
|
||||
protected abstract String niceTypeName(YType type);
|
||||
|
||||
@Override
|
||||
public CompletionItemKind getKind() {
|
||||
return CompletionItemKind.Field;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getBaseDisplayString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DocumentEdits getTextEdit() {
|
||||
return this.proposalApplier;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void apply(IDocument document) {
|
||||
// try {
|
||||
// proposalApplier.apply(document);
|
||||
// } catch (Exception e) {
|
||||
// EditorSupportActivator.log(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.properties.tools;
|
||||
package org.springframework.ide.vscode.boot.common;
|
||||
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.*;
|
||||
|
||||
@@ -32,19 +32,25 @@ public abstract class AbstractPropertyRenderableProvider {
|
||||
if (type==null) {
|
||||
type = Object.class.getName();
|
||||
}
|
||||
renderableBuilder.add(lineBreak());
|
||||
actionLink(renderableBuilder, type);
|
||||
|
||||
String deflt = formatDefaultValue(getDefaultValue());
|
||||
if (deflt!=null) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
renderableBuilder.add(lineBreak());
|
||||
defaultValueRenderable(renderableBuilder, deflt);
|
||||
}
|
||||
|
||||
if (isDeprecated()) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
renderableBuilder.add(lineBreak());
|
||||
depreactionRenderable(renderableBuilder);
|
||||
}
|
||||
|
||||
Renderable description = getDescription();
|
||||
if (description!=null) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
descriptionRenderable(renderableBuilder, description);
|
||||
}
|
||||
|
||||
@@ -97,20 +103,15 @@ public abstract class AbstractPropertyRenderableProvider {
|
||||
* link then the provided runnable is to be executed.
|
||||
*/
|
||||
public void actionLink(Builder<Renderable> renderableBuilder, String displayString) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
renderableBuilder.add(link(displayString, "null"));
|
||||
}
|
||||
|
||||
private void defaultValueRenderable(Builder<Renderable> renderableBuilder, String defaultValue) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
renderableBuilder.add(lineBreak());
|
||||
protected void defaultValueRenderable(Builder<Renderable> renderableBuilder, String defaultValue) {
|
||||
renderableBuilder.add(text("Default: "));
|
||||
renderableBuilder.add(italic(text(defaultValue)));
|
||||
}
|
||||
|
||||
private void depreactionRenderable(Builder<Renderable> renderableBuilder) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
renderableBuilder.add(lineBreak());
|
||||
protected void depreactionRenderable(Builder<Renderable> renderableBuilder) {
|
||||
String reason = getDeprecationReason();
|
||||
if (StringUtil.hasText(reason)) {
|
||||
renderableBuilder.add(bold(text("Deprecated: ")));
|
||||
@@ -120,8 +121,7 @@ public abstract class AbstractPropertyRenderableProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private void descriptionRenderable(Builder<Renderable> renderableBuilder, Renderable description) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
protected void descriptionRenderable(Builder<Renderable> renderableBuilder, Renderable description) {
|
||||
renderableBuilder.add(paragraph(description));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.ide.vscode.boot.properties.tools;
|
||||
package org.springframework.ide.vscode.boot.common;
|
||||
|
||||
import static org.springframework.ide.vscode.commons.util.StringUtil.camelCaseToHyphens;
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014-2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.common;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.Type;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeParser;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypedProperty;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.util.FuzzyMap.Match;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ScoreableProposal;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.yaml.hover.YPropertyHoverInfo;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YType;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
|
||||
public class PropertyCompletionFactory {
|
||||
|
||||
public ICompletionProposal valueProposal(String value, String query, String niceTypeName, double score, DocumentEdits edits, Renderable info) {
|
||||
return new ScoreableProposal() {
|
||||
|
||||
@Override
|
||||
public DocumentEdits getTextEdit() {
|
||||
return edits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionItemKind getKind() {
|
||||
return CompletionItemKind.Value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetail() {
|
||||
return niceTypeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderable getDocumentation() {
|
||||
return info;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public ScoreableProposal property(IDocument doc, DocumentEdits applier, Match<PropertyInfo> prop, TypeUtil typeUtil) {
|
||||
return new PropertyProposal(doc, applier, prop, typeUtil);
|
||||
}
|
||||
|
||||
public ScoreableProposal beanProperty(IDocument doc, final String contextProperty, final Type contextType, final String pattern, final TypedProperty property, final double score, DocumentEdits applier, final TypeUtil typeUtil) {
|
||||
AbstractPropertyProposal proposal = new AbstractPropertyProposal(doc, applier) {
|
||||
|
||||
@Override
|
||||
public Renderable getDocumentation() {
|
||||
return YPropertyHoverInfo.create(contextProperty, contextType, property);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBaseDisplayString() {
|
||||
return property.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHighlightPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type getType() {
|
||||
return property.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String niceTypeName(YType type) {
|
||||
return typeUtil.niceTypeName((Type) type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return getBaseDisplayString();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
if (property.isDeprecated()) {
|
||||
proposal.deprecate();
|
||||
}
|
||||
return proposal;
|
||||
}
|
||||
|
||||
private JavaProjectFinder documentContextFinder;
|
||||
|
||||
public PropertyCompletionFactory(JavaProjectFinder documentContextFinder) {
|
||||
this.documentContextFinder = documentContextFinder;
|
||||
}
|
||||
|
||||
private class PropertyProposal extends AbstractPropertyProposal {
|
||||
private Match<PropertyInfo> match;
|
||||
private Type type;
|
||||
private TypeUtil typeUtil;
|
||||
private Supplier<PropertyRenderableProvider> propertyRenderable;
|
||||
|
||||
public PropertyProposal(IDocument doc, DocumentEdits applier, Match<PropertyInfo> match,
|
||||
TypeUtil typeUtil) {
|
||||
super(doc, applier);
|
||||
this.typeUtil = typeUtil;
|
||||
this.match = match;
|
||||
this.propertyRenderable = Suppliers.memoize(() -> new ShortDocumentationRenderableProvider(documentContextFinder.find(fDoc), match.data));
|
||||
if (match.data.isDeprecated()) {
|
||||
deprecate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBaseDisplayString() {
|
||||
return match.data.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseScore() {
|
||||
return match.score;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type getType() {
|
||||
if (type==null) {
|
||||
type = TypeParser.parse(match.data.getType());
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHighlightPattern() {
|
||||
return match.getPattern();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String niceTypeName(YType type) {
|
||||
return typeUtil.niceTypeName(((Type)type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return getBaseDisplayString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderable getDocumentation() {
|
||||
return propertyRenderable.get().getRenderable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.properties.tools;
|
||||
package org.springframework.ide.vscode.boot.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.springframework.ide.vscode.boot.common;
|
||||
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil.BeanPropertyNameMode;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil.EnumCaseMode;
|
||||
|
||||
/**
|
||||
* Config object that determines some aspects of how the freedom of 'relaxed name binding'
|
||||
* are taken into account when generating content-assist completions.
|
||||
*
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public class RelaxedNameConfig {
|
||||
|
||||
public static final RelaxedNameConfig ALIASSED = new RelaxedNameConfig(EnumCaseMode.ALIASED, BeanPropertyNameMode.ALIASED);
|
||||
public static final RelaxedNameConfig COMPLETION_DEFAULTS = new RelaxedNameConfig(EnumCaseMode.LOWER_CASE, BeanPropertyNameMode.HYPHENATED);
|
||||
|
||||
private EnumCaseMode enumMode = EnumCaseMode.LOWER_CASE;
|
||||
private BeanPropertyNameMode beanMode = BeanPropertyNameMode.HYPHENATED;
|
||||
|
||||
public RelaxedNameConfig(EnumCaseMode enumMode, BeanPropertyNameMode beanMode) {
|
||||
this.enumMode = enumMode;
|
||||
this.beanMode = beanMode;
|
||||
}
|
||||
public EnumCaseMode getEnumMode() {
|
||||
return enumMode;
|
||||
}
|
||||
public void setEnumMode(EnumCaseMode preferredEnumCompletions) {
|
||||
this.enumMode = preferredEnumCompletions;
|
||||
}
|
||||
public BeanPropertyNameMode getBeanMode() {
|
||||
return beanMode;
|
||||
}
|
||||
public void setBeanMode(BeanPropertyNameMode preferredBeanCompletions) {
|
||||
this.beanMode = preferredBeanCompletions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RelaxedNameConfig("+enumMode+", "+beanMode+")";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.springframework.ide.vscode.boot.common;
|
||||
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.concat;
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.lineBreak;
|
||||
|
||||
import org.springframework.ide.vscode.application.properties.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
|
||||
public class ShortDocumentationRenderableProvider extends PropertyRenderableProvider {
|
||||
|
||||
public ShortDocumentationRenderableProvider(IJavaProject project, PropertyInfo data) {
|
||||
super(project, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderable getRenderable() {
|
||||
Builder<Renderable> renderableBuilder = ImmutableList.builder();
|
||||
|
||||
Renderable description = getDescription();
|
||||
if (description!=null) {
|
||||
descriptionRenderable(renderableBuilder, description);
|
||||
}
|
||||
|
||||
String deflt = formatDefaultValue(getDefaultValue());
|
||||
if (deflt!=null) {
|
||||
if (description != null) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
}
|
||||
defaultValueRenderable(renderableBuilder, deflt);
|
||||
}
|
||||
|
||||
if (isDeprecated()) {
|
||||
if (description != null) {
|
||||
renderableBuilder.add(lineBreak());
|
||||
}
|
||||
depreactionRenderable(renderableBuilder);
|
||||
}
|
||||
|
||||
|
||||
ImmutableList<Renderable> pieces = renderableBuilder.build();
|
||||
return pieces.isEmpty() ? null : concat(pieces);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.ide.vscode.boot.properties.completions;
|
||||
|
||||
import static org.springframework.ide.vscode.boot.properties.tools.CommonLanguageTools.*;
|
||||
import static org.springframework.ide.vscode.boot.common.CommonLanguageTools.*;
|
||||
import static org.springframework.ide.vscode.commons.util.StringUtil.camelCaseToHyphens;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -9,7 +9,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ide.vscode.application.properties.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.completions.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.hints.HintProvider;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.hints.HintProviders;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.hints.StsValueHint;
|
||||
@@ -22,6 +21,7 @@ import org.springframework.ide.vscode.application.properties.metadata.types.Type
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypedProperty;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.util.FuzzyMap.Match;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.boot.properties.reconcile.PropertyNavigator;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.springframework.ide.vscode.boot.properties.completions;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.ide.vscode.application.properties.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.completions.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtilProvider;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.springframework.ide.vscode.boot.properties.hover;
|
||||
|
||||
import static org.springframework.ide.vscode.boot.properties.tools.CommonLanguageTools.SPACES;
|
||||
import static org.springframework.ide.vscode.boot.properties.tools.CommonLanguageTools.getValueHints;
|
||||
import static org.springframework.ide.vscode.boot.properties.tools.CommonLanguageTools.getValueType;
|
||||
import static org.springframework.ide.vscode.boot.common.CommonLanguageTools.SPACES;
|
||||
import static org.springframework.ide.vscode.boot.common.CommonLanguageTools.getValueHints;
|
||||
import static org.springframework.ide.vscode.boot.common.CommonLanguageTools.getValueType;
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.*;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -15,7 +15,7 @@ import org.springframework.ide.vscode.application.properties.metadata.types.Type
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil.EnumCaseMode;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.boot.properties.tools.PropertyRenderableProvider;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyRenderableProvider;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.ide.vscode.application.properties.metadata.IndexNavigator;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.completions.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.completions.RelaxedNameConfig;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.hints.HintProvider;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.hints.StsValueHint;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.hints.ValueHintHoverInfo;
|
||||
@@ -33,7 +31,9 @@ import org.springframework.ide.vscode.application.properties.metadata.types.Type
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypedProperty;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.util.FuzzyMap;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.util.FuzzyMap.Match;
|
||||
import org.springframework.ide.vscode.boot.properties.tools.PropertyRenderableProvider;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyRenderableProvider;
|
||||
import org.springframework.ide.vscode.boot.common.RelaxedNameConfig;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.LazyProposalApplier;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.ide.vscode.application.properties.metadata.types.Type
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil.BeanPropertyNameMode;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypeUtil.EnumCaseMode;
|
||||
import org.springframework.ide.vscode.boot.properties.tools.AbstractPropertyRenderableProvider;
|
||||
import org.springframework.ide.vscode.boot.common.AbstractPropertyRenderableProvider;
|
||||
import org.springframework.ide.vscode.application.properties.metadata.types.TypedProperty;
|
||||
import org.springframework.ide.vscode.commons.java.IField;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaElement;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
@Test public void testServerPortCompletion() throws Exception {
|
||||
data("server.port", INTEGER, 8080, "Port where server listens for http.");
|
||||
assertCompletion("ser<*>", "server.port=<*>");
|
||||
assertCompletionDisplayString("ser<*>", "server.port");
|
||||
assertCompletionDetails("ser<*>", "server.port", "int", null);
|
||||
}
|
||||
|
||||
@Test public void testLoggingLevelCompletion() throws Exception {
|
||||
@@ -318,10 +318,11 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
assertNotNull(p.findType("demo.Foo"));
|
||||
|
||||
assertCompletionsVariations("volder.foo.l<*>", "volder.foo.list[<*>");
|
||||
assertCompletionsDisplayString("volder.foo.list[0].<*>",
|
||||
"name : String",
|
||||
"description : String",
|
||||
"roles : List<String>");
|
||||
assertCompletionsDisplayStringAndDetail("volder.foo.list[0].<*>",
|
||||
new String[] {"description", "String"},
|
||||
new String[] {"name", "String"},
|
||||
new String[] {"roles", "List<String>"}
|
||||
);
|
||||
|
||||
assertCompletionsVariations("volder.foo.list[0].na<*>",
|
||||
"volder.foo.list[0].name=<*>"
|
||||
@@ -576,8 +577,10 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
"foo.color-names.green=<*>",
|
||||
"foo.color-names.red=<*>"
|
||||
);
|
||||
assertCompletionsDisplayString("foo.color-names.<*>",
|
||||
"red : String", "green : String", "blue : String"
|
||||
assertCompletionsDisplayStringAndDetail("foo.color-names.<*>",
|
||||
new String[] {"blue", "String"},
|
||||
new String[] {"green", "String"},
|
||||
new String[] {"red", "String"}
|
||||
);
|
||||
assertCompletionsVariations("foo.color-names.B<*>",
|
||||
"foo.color-names.BLUE=<*>"
|
||||
@@ -593,8 +596,10 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
assertCompletionsVariations("foo.color-data.B<*>",
|
||||
"foo.color-data.BLUE.<*>"
|
||||
);
|
||||
assertCompletionsDisplayString("foo.color-data.<*>",
|
||||
"blue : demo.ColorData", "green : demo.ColorData", "red : demo.ColorData"
|
||||
assertCompletionsDisplayStringAndDetail("foo.color-data.<*>",
|
||||
new String[] {"blue", "demo.ColorData"},
|
||||
new String[] {"green", "demo.ColorData"},
|
||||
new String[] {"red", "demo.ColorData"}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -627,16 +632,16 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
|
||||
assertCompletion("foo.dat<*>", "foo.data.<*>");
|
||||
|
||||
assertCompletionsDisplayString("foo.data.",
|
||||
"wavelen : double",
|
||||
"name : String",
|
||||
"next : demo.Color[BLUE, GREEN, RED]",
|
||||
"nested : demo.ColorData",
|
||||
"children : List<demo.ColorData>",
|
||||
"mapped-children : Map<String, demo.ColorData>",
|
||||
"color-children : Map<demo.Color[BLUE, GREEN, RED], demo.ColorData>",
|
||||
"tags : List<String>",
|
||||
"funky : boolean"
|
||||
assertCompletionsDisplayStringAndDetail("foo.data.",
|
||||
new String[] {"children", "List<demo.ColorData>"},
|
||||
new String[] {"color-children", "Map<demo.Color[BLUE, GREEN, RED], demo.ColorData>"},
|
||||
new String[] {"funky", "boolean"},
|
||||
new String[] {"mapped-children", "Map<String, demo.ColorData>"},
|
||||
new String[] {"name", "String"},
|
||||
new String[] {"nested", "demo.ColorData"},
|
||||
new String[] {"next", "demo.Color[BLUE, GREEN, RED]"},
|
||||
new String[] {"tags", "List<String>"},
|
||||
new String[] {"wavelen", "double"}
|
||||
);
|
||||
|
||||
assertCompletionsVariations("foo.data.wav<*>", "foo.data.wavelen=<*>");
|
||||
@@ -1099,26 +1104,29 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.<*>"
|
||||
, //==============
|
||||
"root : String",
|
||||
"root",
|
||||
//=>
|
||||
"logging.level.root=<*>"
|
||||
);
|
||||
assertCompletionDetails("logging.level.<*>", "root", "String", null);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.r<*>"
|
||||
, //==============
|
||||
"root : String",
|
||||
"root",
|
||||
//=>
|
||||
"logging.level.root=<*>"
|
||||
);
|
||||
assertCompletionDetails("logging.level.r<*>", "root", "String", null);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.ot<*>"
|
||||
, //==============
|
||||
"root : String",
|
||||
"root",
|
||||
//=>
|
||||
"logging.level.root=<*>"
|
||||
);
|
||||
assertCompletionDetails("logging.level.ot<*>", "root", "String", null);
|
||||
}
|
||||
|
||||
@Test public void testHandleAsResourceContentAssist() throws Exception {
|
||||
@@ -1508,15 +1516,16 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Ignore @Test public void testEnumJavaDocShownInValueContentAssist() throws Exception {
|
||||
@Test public void testEnumJavaDocShownInValueContentAssist() throws Exception {
|
||||
useProject(createPredefinedMavenProject("enums-boot-1.3.2-app"));
|
||||
data("my.background", "demo.Color", null, "Color to use as default background.");
|
||||
|
||||
assertCompletionWithInfoHover(
|
||||
assertCompletionDetails(
|
||||
"my.background=<*>"
|
||||
, // ==========
|
||||
"red"
|
||||
, // ==>
|
||||
"demo.Color[BLUE, GREEN, RED]",
|
||||
"Hot and delicious"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.ide.vscode.application.properties.metadata.CachingVal
|
||||
import org.springframework.ide.vscode.application.properties.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.BootPropertiesLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
@@ -42,8 +41,6 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private JavaProjectFinder javaProjectFinder;
|
||||
|
||||
@Test public void linterRunsOnDocumentOpenAndChange() throws Exception {
|
||||
Editor editor = newEditor(
|
||||
"somemap: val\n"+
|
||||
@@ -139,7 +136,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
editor.assertHoverContains("INDENT_OUTPUT", "allows enabling (or disabling) indentation");
|
||||
}
|
||||
|
||||
@Ignore @Test public void testHoverInfoForEnumValueInMapKeyCompletion() throws Exception {
|
||||
@Test public void testHoverInfoForEnumValueInMapKeyCompletion() throws Exception {
|
||||
IJavaProject project = createPredefinedMavenProject("empty-boot-1.3.0-app");
|
||||
useProject(project);
|
||||
|
||||
@@ -151,30 +148,32 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
// System.out.println(downloadSources(type));
|
||||
// System.out.println("<<< source for: "+type.getFullyQualifiedName());
|
||||
|
||||
assertCompletionWithInfoHover(
|
||||
assertCompletionDetails(
|
||||
"spring:\n" +
|
||||
" jackson:\n" +
|
||||
" serialization:\n" +
|
||||
" ind<*>"
|
||||
, // ==========
|
||||
"indent-output : boolean"
|
||||
"indent-output"
|
||||
, // ==>
|
||||
"boolean",
|
||||
"allows enabling (or disabling) indentation"
|
||||
);
|
||||
}
|
||||
|
||||
@Ignore @Test public void testHoverInfoForValueHintCompletion() throws Exception {
|
||||
@Test public void testHoverInfoForValueHintCompletion() throws Exception {
|
||||
data("my.bonus", "java.lang.String", null, "Bonus type")
|
||||
.valueHint("small", "A small bonus. For a little extra incentive.")
|
||||
.valueHint("large", "An large bonus. For the ones who deserve it.")
|
||||
.valueHint("exorbitant", "Truly outrageous. Who deserves a bonus like that?");
|
||||
|
||||
assertCompletionWithInfoHover(
|
||||
assertCompletionDetails(
|
||||
"my:\n" +
|
||||
" bonus: l<*>"
|
||||
, // ==========
|
||||
"large"
|
||||
, // ==>
|
||||
"String",
|
||||
"For the ones who deserve it"
|
||||
);
|
||||
}
|
||||
@@ -2992,12 +2991,21 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
" level:\n" +
|
||||
" <*>"
|
||||
, // =>
|
||||
"root : String"
|
||||
"root"
|
||||
,
|
||||
"logging:\n" +
|
||||
" level:\n" +
|
||||
" root: <*>"
|
||||
);
|
||||
assertCompletionDetails(
|
||||
"logging:\n" +
|
||||
" level:\n" +
|
||||
" <*>"
|
||||
, // =>
|
||||
"root",
|
||||
"String",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void testEscapeStringValueStartingWithStar() throws Exception {
|
||||
@@ -3067,12 +3075,18 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
" level:\n" +
|
||||
" boot.auto<*>"
|
||||
, //-----------------
|
||||
"org.springframework.boot.autoconfigure : String"
|
||||
"org.springframework.boot.autoconfigure"
|
||||
, // =>
|
||||
"logging:\n" +
|
||||
" level:\n" +
|
||||
" org.springframework.boot.autoconfigure: <*>"
|
||||
);
|
||||
assertCompletionDetails(
|
||||
"logging:\n" +
|
||||
" level:\n" +
|
||||
" boot.auto<*>"
|
||||
, //-----------------
|
||||
"org.springframework.boot.autoconfigure", "String", null);
|
||||
|
||||
//Finds a type:
|
||||
assertCompletionWithLabel(
|
||||
@@ -3080,12 +3094,21 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
" level:\n" +
|
||||
" MesgSource<*>"
|
||||
, //-----------------
|
||||
"org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration : String"
|
||||
"org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration"
|
||||
, // =>
|
||||
"logging:\n" +
|
||||
" level:\n" +
|
||||
" org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration: <*>"
|
||||
);
|
||||
assertCompletionDetails(
|
||||
"logging:\n" +
|
||||
" level:\n" +
|
||||
" MesgSource<*>"
|
||||
, //-----------------
|
||||
"org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration",
|
||||
"String",
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void testSimpleResourceCompletion() throws Exception {
|
||||
@@ -3432,16 +3455,17 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Ignore @Test public void testEnumJavaDocShownInValueContentAssist() throws Exception {
|
||||
@Test public void testEnumJavaDocShownInValueContentAssist() throws Exception {
|
||||
useProject(createPredefinedMavenProject("enums-boot-1.3.2-app"));
|
||||
data("my.background", "demo.Color", null, "Color to use as default background.");
|
||||
|
||||
assertCompletionWithInfoHover(
|
||||
assertCompletionDetails(
|
||||
"my:\n" +
|
||||
" background: <*>"
|
||||
, // ==========
|
||||
"red"
|
||||
, // ==>
|
||||
"demo.Color[BLUE, GREEN, RED]",
|
||||
"Hot and delicious"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user