summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-04-01 20:33:30 -0700
committerGeorge Fraser <george@fivetran.com>2019-04-01 20:33:30 -0700
commit1e3eca864c38afca7f9bf7a68de0965b01d9cdf6 (patch)
treed701cfb24afb6af4e009c6ba8def720ce9f0fb65
parent2c9c8b7797280de3587a4233cfb2ba8bbb0ac1ff (diff)
downloadjava-language-server-1e3eca864c38afca7f9bf7a68de0965b01d9cdf6.zip
Dead code
-rw-r--r--src/main/java/org/javacs/CompileFile.java92
-rw-r--r--src/test/java/org/javacs/CodeLensTest.java14
2 files changed, 0 insertions, 106 deletions
diff --git a/src/main/java/org/javacs/CompileFile.java b/src/main/java/org/javacs/CompileFile.java
index bbe7b47..7d00270 100644
--- a/src/main/java/org/javacs/CompileFile.java
+++ b/src/main/java/org/javacs/CompileFile.java
@@ -5,10 +5,8 @@ import com.sun.source.util.*;
import java.io.IOException;
import java.net.URI;
import java.util.*;
-import java.util.function.Predicate;
import java.util.logging.Logger;
import javax.lang.model.element.*;
-import org.javacs.lsp.*;
public class CompileFile implements AutoCloseable {
private final JavaCompilerService parent;
@@ -86,60 +84,6 @@ public class CompileFile implements AutoCloseable {
return Optional.of(el);
}
- public Optional<TreePath> path(Element e) {
- return Optional.ofNullable(trees.getPath(e));
- }
-
- public Optional<TreePath> find(Ptr target) {
- class FindPtr extends TreePathScanner<Void, Void> {
- TreePath found = null;
-
- boolean toStringEquals(Object left, Object right) {
- return Objects.equals(Objects.toString(left, ""), Objects.toString(right, ""));
- }
-
- /** Check if the declaration at the current path is the same symbol as `e` */
- boolean sameSymbol() {
- var path = getCurrentPath();
- var el = trees.getElement(path);
- return new Ptr(el).equals(target);
- }
-
- void check() {
- if (sameSymbol()) {
- found = getCurrentPath();
- }
- }
-
- @Override
- public Void visitClass(ClassTree node, Void aVoid) {
- check();
- return super.visitClass(node, aVoid);
- }
-
- @Override
- public Void visitMethod(MethodTree node, Void aVoid) {
- check();
- // Ptr can't point inside a method
- return null;
- }
-
- @Override
- public Void visitVariable(VariableTree node, Void aVoid) {
- check();
- // Ptr can't point inside a method
- return null;
- }
- }
- var find = new FindPtr();
- find.scan(root, null);
- return Optional.ofNullable(find.found);
- }
-
- public Optional<Range> range(TreePath path) {
- return ParseFile.range(borrow.task, contents, path);
- }
-
private List<Element> overrides(ExecutableElement method) {
var elements = borrow.task.getElements();
var types = borrow.task.getTypes();
@@ -270,41 +214,5 @@ public class CompileFile implements AutoCloseable {
return sorted;
}
- public List<String> allClassNames() {
- var result = new ArrayList<String>();
- class FindClasses extends TreeScanner<Void, Void> {
- @Override
- public Void visitClass(ClassTree classTree, Void __) {
- var className = Objects.toString(classTree.getSimpleName(), "");
- result.add(className);
- return null;
- }
- }
- root.accept(new FindClasses(), null);
- return result;
- }
-
- public Predicate<List<Ptr>> signatureMatches() {
- // Precompute qualified names of all classes in this file
- var thisClasses = new ArrayList<String>();
- for (var c : root.getTypeDecls()) {
- var path = trees.getPath(root, c);
- var el = (TypeElement) trees.getElement(path);
- var name = el.getQualifiedName().toString();
- thisClasses.add(name);
- }
- return i -> {
- // For each pointer, check if it refers to something in this file that no longer exists
- for (var ptr : i) {
- if (thisClasses.contains(ptr.qualifiedClassName()) && !find(ptr).isPresent()) {
- LOG.info(
- String.format("`%s` refers to signature that no longer exists in %s", ptr, file.getPath()));
- return false;
- }
- }
- return true;
- };
- }
-
private static final Logger LOG = Logger.getLogger("main");
}
diff --git a/src/test/java/org/javacs/CodeLensTest.java b/src/test/java/org/javacs/CodeLensTest.java
index 48f8803..9da33d2 100644
--- a/src/test/java/org/javacs/CodeLensTest.java
+++ b/src/test/java/org/javacs/CodeLensTest.java
@@ -73,20 +73,6 @@ public class CodeLensTest {
}
@Test
- public void signatureMatches() {
- var file = "/org/javacs/example/ConstructorRefs.java";
- var uri = FindResource.uri(file);
- var compile = server.compiler.compileFile(uri);
- var signatureMatches = compile.signatureMatches();
-
- var good = List.of(new Ptr("org.javacs.example/ConstructorRefs#<init>(int)"));
- assertTrue(signatureMatches.test(good));
-
- var bad = List.of(new Ptr("org.javacs.example/ConstructorRefs#<init>(int,int)"));
- assertFalse(signatureMatches.test(bad));
- }
-
- @Test
public void placement() {
var lenses = lenses("/org/javacs/example/CodeLensPlacement.java");
var titles = titles(lenses);