Add quickfix for missing properties in concourse editor
This commit is contained in:
@@ -11,12 +11,11 @@
|
||||
|
||||
package org.springframework.ide.vscode.boot.metadata.hints;
|
||||
|
||||
import java.util.List;
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.bold;
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.concat;
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.paragraph;
|
||||
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.util.Renderables;
|
||||
|
||||
import static org.springframework.ide.vscode.commons.util.Renderables.*;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
|
||||
@@ -13,13 +13,12 @@ package org.springframework.ide.vscode.boot.properties.quickfix;
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
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.quickfix.ProblemFixer;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
public class ReplaceDeprecatedPropertyQuickfix implements ICompletionProposal {
|
||||
|
||||
public static ProblemFixer FIXER = (context, problem, proposals) -> {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
// public static ProblemFixer FIXER = (context, problem, proposals) -> {
|
||||
// throw new UnsupportedOperationException("Not yet implemented");
|
||||
// PropertyInfo metadata = problem.getMetadata();
|
||||
// if (metadata!=null) {
|
||||
// String replacement = metadata.getDeprecationReplacement();
|
||||
@@ -28,7 +27,7 @@ public class ReplaceDeprecatedPropertyQuickfix implements ICompletionProposal {
|
||||
// proposals.add(new ReplaceDeprecatedYamlQuickfix(context, problem));
|
||||
// }
|
||||
// }
|
||||
};
|
||||
// };
|
||||
|
||||
@Override
|
||||
public ICompletionProposal deemphasize() {
|
||||
@@ -57,7 +56,7 @@ public class ReplaceDeprecatedPropertyQuickfix implements ICompletionProposal {
|
||||
|
||||
// private final QuickfixContext context;
|
||||
// private final SpringPropertyProblem problem;
|
||||
//
|
||||
//
|
||||
// private LazyProposalApplier applier = new LazyProposalApplier() {
|
||||
// protected ProposalApplier create() throws Exception {
|
||||
// String newName = problem.getMetadata().getDeprecationReplacement();
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.ide.vscode.boot.metadata.types.Type;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeParser;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
|
||||
import org.springframework.ide.vscode.boot.properties.quickfix.ReplaceDeprecatedPropertyQuickfix;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IReconcileEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
|
||||
@@ -72,26 +71,27 @@ public class SpringPropertiesReconcileEngine implements IReconcileEngine {
|
||||
this.fIndexProvider = provider;
|
||||
this.typeUtilProvider = typeUtilProvider;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void reconcile(IDocument doc, IProblemCollector problemCollector) {
|
||||
FuzzyMap<PropertyInfo> index = fIndexProvider.getIndex(doc);
|
||||
problemCollector.beginCollecting();
|
||||
try {
|
||||
ParseResults results = parser.parse(doc.get());
|
||||
DuplicateNameChecker duplicateNameChecker = new DuplicateNameChecker(problemCollector);
|
||||
|
||||
|
||||
results.syntaxErrors.forEach(syntaxError -> {
|
||||
problemCollector.accept(problem(PROP_SYNTAX_ERROR, syntaxError.getMessage(), syntaxError.getOffset(),
|
||||
syntaxError.getLength()));
|
||||
});
|
||||
|
||||
|
||||
if (index==null || index.isEmpty()) {
|
||||
//don't report errors when index is empty, simply don't check (otherwise we will just reprot
|
||||
// all properties as errors, but this not really useful information since the cause is
|
||||
// some problem putting information about properties into the index.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
results.ast.getNodes(KeyValuePair.class).forEach(pair -> {
|
||||
try {
|
||||
DocumentRegion propertyNameRegion = createRegion(doc, pair.getKey());
|
||||
@@ -127,7 +127,7 @@ public class SpringPropertiesReconcileEngine implements IReconcileEngine {
|
||||
problemCollector.endCollecting();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected SpringPropertyProblem problemDeprecated(DocumentRegion region, PropertyInfo property) {
|
||||
SpringPropertyProblem p = problem(PROP_DEPRECATED,
|
||||
TypeUtil.deprecatedPropertyMessage(
|
||||
@@ -139,7 +139,7 @@ public class SpringPropertiesReconcileEngine implements IReconcileEngine {
|
||||
);
|
||||
p.setPropertyName(property.getId());
|
||||
p.setMetadata(property);
|
||||
p.setProblemFixer(ReplaceDeprecatedPropertyQuickfix.FIXER);
|
||||
// p.setProblemFixer(ReplaceDeprecatedPropertyQuickfix.FIXER);
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -167,10 +167,10 @@ public class SpringPropertiesReconcileEngine implements IReconcileEngine {
|
||||
length = doc.get(value.getOffset(), value.getLength()).length();
|
||||
} catch (BadLocationException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return new DocumentRegion(doc, value.getOffset(), value.getOffset() + length);
|
||||
}
|
||||
|
||||
|
||||
private void reconcileType(DocumentRegion region, Type expectType, IProblemCollector problems) {
|
||||
TypeUtil typeUtil = typeUtilProvider.getTypeUtil(region.getDocument());
|
||||
ValueParser parser = typeUtil.getValueParser(expectType);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
package org.springframework.ide.vscode.boot.properties.reconcile;
|
||||
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.commons.languageserver.quickfix.ProblemFixer;
|
||||
//import org.springframework.ide.vscode.commons.languageserver.quickfix.ProblemFixer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.ReconcileProblemImpl;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
|
||||
@@ -22,7 +22,7 @@ import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion
|
||||
public class SpringPropertyProblem extends ReconcileProblemImpl {
|
||||
|
||||
private PropertyInfo property = null;
|
||||
private ProblemFixer fixer;
|
||||
// private ProblemFixer fixer;
|
||||
private String propertyName;
|
||||
|
||||
public SpringPropertyProblem(ProblemType type, String msg, int offset, int len) {
|
||||
@@ -39,14 +39,14 @@ public class SpringPropertyProblem extends ReconcileProblemImpl {
|
||||
}
|
||||
return new SpringPropertyProblem(type, msg, region.getStart(), region.getLength());
|
||||
}
|
||||
|
||||
|
||||
public void setMetadata(PropertyInfo property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
public void setProblemFixer(ProblemFixer fixer) {
|
||||
this.fixer = fixer;
|
||||
}
|
||||
// public void setProblemFixer(ProblemFixer fixer) {
|
||||
// this.fixer = fixer;
|
||||
// }
|
||||
|
||||
public void setPropertyName(String name) {
|
||||
propertyName = name;
|
||||
|
||||
@@ -13,13 +13,12 @@ package org.springframework.ide.vscode.boot.yaml.quickfix;
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
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.quickfix.ProblemFixer;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
public class ReplaceDeprecatedYamlQuickfix implements ICompletionProposal {
|
||||
|
||||
public static ProblemFixer FIXER = (context, problem, proposals) -> {
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
// public static ProblemFixer FIXER = (context, problem, proposals) -> {
|
||||
// throw new UnsupportedOperationException("Not yet implemented");
|
||||
// PropertyInfo metadata = problem.getMetadata();
|
||||
// if (metadata!=null) {
|
||||
// String replacement = metadata.getDeprecationReplacement();
|
||||
@@ -28,7 +27,7 @@ public class ReplaceDeprecatedYamlQuickfix implements ICompletionProposal {
|
||||
// proposals.add(new ReplaceDeprecatedYamlQuickfix(context, problem));
|
||||
// }
|
||||
// }
|
||||
};
|
||||
// };
|
||||
|
||||
@Override
|
||||
public ICompletionProposal deemphasize() {
|
||||
@@ -57,7 +56,7 @@ public class ReplaceDeprecatedYamlQuickfix implements ICompletionProposal {
|
||||
|
||||
// private final QuickfixContext context;
|
||||
// private final SpringPropertyProblem problem;
|
||||
//
|
||||
//
|
||||
// private LazyProposalApplier applier = new LazyProposalApplier() {
|
||||
// protected ProposalApplier create() throws Exception {
|
||||
// String newName = problem.getMetadata().getDeprecationReplacement();
|
||||
|
||||
@@ -26,18 +26,17 @@ import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.Type;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeParser;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypedProperty;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil.BeanPropertyNameMode;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil.EnumCaseMode;
|
||||
import org.springframework.ide.vscode.boot.yaml.quickfix.ReplaceDeprecatedYamlQuickfix;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypedProperty;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
import org.springframework.ide.vscode.commons.util.ValueParser;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.NodeRef;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.NodeUtil;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.NodeRef.Kind;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.NodeRef.TupleValueRef;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.NodeUtil;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
|
||||
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlASTReconciler;
|
||||
import org.yaml.snakeyaml.nodes.MappingNode;
|
||||
import org.yaml.snakeyaml.nodes.Node;
|
||||
@@ -350,7 +349,7 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler {
|
||||
SpringPropertyProblem problem = deprecatedPropertyProblem(property.getId(), null, keyNode,
|
||||
property.getDeprecationReplacement(), property.getDeprecationReason());
|
||||
problem.setMetadata(property);
|
||||
problem.setProblemFixer(ReplaceDeprecatedYamlQuickfix.FIXER);
|
||||
//problem.setProblemFixer(ReplaceDeprecatedYamlQuickfix.FIXER);
|
||||
problems.accept(problem);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,13 @@
|
||||
package org.springframework.ide.vscode.boot.yaml.reconcile;
|
||||
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.commons.languageserver.quickfix.ProblemFixer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.ReconcileProblemImpl;
|
||||
|
||||
public class SpringPropertyProblem extends ReconcileProblemImpl {
|
||||
|
||||
private PropertyInfo property = null;
|
||||
private ProblemFixer fixer;
|
||||
// private ProblemFixer fixer;
|
||||
private String propertyName;
|
||||
|
||||
public SpringPropertyProblem(ProblemType type, String msg, int offset, int len) {
|
||||
@@ -34,9 +33,9 @@ public class SpringPropertyProblem extends ReconcileProblemImpl {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
public void setProblemFixer(ProblemFixer fixer) {
|
||||
this.fixer = fixer;
|
||||
}
|
||||
// public void setProblemFixer(ProblemFixer fixer) {
|
||||
// this.fixer = fixer;
|
||||
// }
|
||||
|
||||
public void setPropertyName(String name) {
|
||||
propertyName = name;
|
||||
|
||||
@@ -21,31 +21,30 @@ import org.springframework.ide.vscode.commons.maven.MavenBuilder;
|
||||
import org.springframework.ide.vscode.commons.maven.MavenCore;
|
||||
import org.springframework.ide.vscode.commons.maven.java.MavenJavaProject;
|
||||
import org.springframework.ide.vscode.commons.maven.java.classpathfile.JavaProjectWithClasspathFile;
|
||||
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
/**
|
||||
* Test projects harness
|
||||
*
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
public class ProjectsHarness {
|
||||
|
||||
public static final ProjectsHarness INSTANCE = new ProjectsHarness();;
|
||||
|
||||
|
||||
public static final ProjectsHarness INSTANCE = new ProjectsHarness();;
|
||||
|
||||
public Cache<String, IJavaProject> cache = CacheBuilder.newBuilder().concurrencyLevel(1).build();
|
||||
|
||||
|
||||
private enum ProjectType {
|
||||
MAVEN,
|
||||
CLASSPATH_TXT
|
||||
}
|
||||
|
||||
|
||||
private ProjectsHarness() {
|
||||
}
|
||||
|
||||
|
||||
public IJavaProject project(ProjectType type, String name) throws Exception {
|
||||
return cache.get(type + "/" + name, () -> {
|
||||
Path testProjectPath = getProjectPath(name);
|
||||
@@ -82,7 +81,7 @@ public class ProjectsHarness {
|
||||
return getProjectPathFromClasspath(name);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
private Path getProjectPathFromClasspath(String name) throws URISyntaxException, IOException {
|
||||
URI resource = ProjectsHarness.class.getResource("/test-projects/" + name).toURI();
|
||||
// if (resource.getScheme().equalsIgnoreCase("jar")) {
|
||||
@@ -91,7 +90,7 @@ public class ProjectsHarness {
|
||||
return Paths.get(resource);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// private Path getProjectPathFromJar(URI jar) throws IOException {
|
||||
// final String[] array = jar.toString().split("!");
|
||||
// URI firstHalf = URI.create(array[0]);
|
||||
@@ -110,10 +109,10 @@ public class ProjectsHarness {
|
||||
// fs.close();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private static void recursiveCopy(Path source, Path target, CopyOption... options) throws IOException {
|
||||
// Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
|
||||
//
|
||||
//
|
||||
// Path destination = target;
|
||||
//
|
||||
// @Override
|
||||
@@ -135,13 +134,13 @@ public class ProjectsHarness {
|
||||
// destination = destination.getParent();
|
||||
// return super.postVisitDirectory(dir, exc);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private static void recursiveDelete(Path path) throws IOException {
|
||||
// Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
// Files.delete(file);
|
||||
@@ -153,10 +152,10 @@ public class ProjectsHarness {
|
||||
// Files.delete(dir);
|
||||
// return super.postVisitDirectory(dir, exc);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
public MavenJavaProject mavenProject(String name) throws Exception {
|
||||
return (MavenJavaProject) project(ProjectType.MAVEN, name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user