summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-04-02 00:21:23 -0700
committerGeorge Fraser <george@fivetran.com>2019-04-02 00:21:23 -0700
commit90f212e59a2cbe8b49fcc8d50c4f3bc2bba932ae (patch)
tree57507102d6f093503bd20d9884fe94cba69e4449 /src
parenta6a2bd74b2621e1789898511498a5e2032a3b5d4 (diff)
downloadjava-language-server-master.zip
Dead codeHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/javacs/FileStore.java56
-rw-r--r--src/main/java/org/javacs/Main.java6
-rw-r--r--src/main/java/org/javacs/ParseFile.java2
-rw-r--r--src/main/java/org/javacs/ShortTypePrinter.java6
-rw-r--r--src/main/java/org/javacs/TemplatePrinter.java4
5 files changed, 3 insertions, 71 deletions
diff --git a/src/main/java/org/javacs/FileStore.java b/src/main/java/org/javacs/FileStore.java
index 61488a7..1b5a217 100644
--- a/src/main/java/org/javacs/FileStore.java
+++ b/src/main/java/org/javacs/FileStore.java
@@ -18,7 +18,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Logger;
@@ -320,60 +319,5 @@ class FileStore {
return uri.getScheme().equals("file") && isJavaFile(Paths.get(uri));
}
- private static Set<Path> allJavaFilesInDirs(Set<Path> dirs) {
- var all = new HashSet<Path>();
- for (var dir : dirs) {
- try {
- Files.walk(dir).filter(FileStore::isJavaFile).forEach(all::add);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- return all;
- }
-
- private static Set<Path> sourcePath(Set<Path> workspaceRoots) {
- LOG.info("Searching for source roots in " + workspaceRoots);
-
- var certaintyThreshold = 10;
- var sourceRoots = new HashMap<Path, Integer>();
- fileLoop:
- for (var file : allJavaFilesInDirs(workspaceRoots)) {
- // First, check if we already have a high-confidence source root containing file
- for (var root : sourceRoots.keySet()) {
- var confidence = sourceRoots.get(root);
- if (file.startsWith(root) && confidence > certaintyThreshold) {
- continue fileLoop;
- }
- }
- // Otherwise, parse the file and look at its package declaration
- var parse = Parser.parse(file);
- var packageName = Objects.toString(parse.getPackageName(), "");
- var packagePath = packageName.replace('.', File.separatorChar);
- // If file has no package declaration, don't try to guess a source root
- // This is probably a new file that the user will add a package declaration to later
- if (packagePath.isEmpty()) {
- LOG.warning("Ignoring file with missing package declaration " + file);
- continue fileLoop;
- }
- // If path to file contradicts package declaration, give up
- var dir = file.getParent();
- if (!dir.endsWith(packagePath)) {
- LOG.warning("Java source file " + file + " is not in " + packagePath);
- continue fileLoop;
- }
- // Otherwise, use the package declaration to guess the source root
- var up = Paths.get(packagePath).getNameCount();
- var sourceRoot = dir;
- for (int i = 0; i < up; i++) {
- sourceRoot = sourceRoot.getParent();
- }
- // Increment our confidence in sourceRoot as a source root
- var count = sourceRoots.getOrDefault(sourceRoot, 0);
- sourceRoots.put(sourceRoot, count + 1);
- }
- return sourceRoots.keySet();
- }
-
private static final Logger LOG = Logger.getLogger("main");
}
diff --git a/src/main/java/org/javacs/Main.java b/src/main/java/org/javacs/Main.java
index e8dc57a..9db891e 100644
--- a/src/main/java/org/javacs/Main.java
+++ b/src/main/java/org/javacs/Main.java
@@ -14,15 +14,11 @@ public class Main {
for (var h : root.getHandlers()) h.setFormatter(new LogFormat());
}
- private JavaLanguageServer createServer(LanguageClient client) {
- return new JavaLanguageServer(client);
- }
-
public static void main(String[] args) {
boolean quiet = Arrays.stream(args).anyMatch("--quiet"::equals);
if (quiet) {
- LOG.setLevel(Level.OFF);
+ LOG.setLevel(Level.OFF);
}
try {
diff --git a/src/main/java/org/javacs/ParseFile.java b/src/main/java/org/javacs/ParseFile.java
index fe83637..3ef7435 100644
--- a/src/main/java/org/javacs/ParseFile.java
+++ b/src/main/java/org/javacs/ParseFile.java
@@ -15,7 +15,7 @@ public class ParseFile {
private static final JavaCompiler COMPILER = ServiceLoader.load(JavaCompiler.class).iterator().next();
/** Create a task that compiles a single file */
- static JavacTask singleFileTask(JavaCompilerService parent, URI file, String contents) {
+ private static JavacTask singleFileTask(JavaCompilerService parent, URI file, String contents) {
// TODO could eliminate the connection to parent
parent.diags.clear();
return (JavacTask)
diff --git a/src/main/java/org/javacs/ShortTypePrinter.java b/src/main/java/org/javacs/ShortTypePrinter.java
index 5e143c2..c20e447 100644
--- a/src/main/java/org/javacs/ShortTypePrinter.java
+++ b/src/main/java/org/javacs/ShortTypePrinter.java
@@ -1,7 +1,6 @@
package org.javacs;
import java.util.StringJoiner;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
@@ -9,8 +8,6 @@ import javax.lang.model.type.*;
import javax.lang.model.util.AbstractTypeVisitor8;
class ShortTypePrinter extends AbstractTypeVisitor8<String, Void> {
- private static final Logger LOG = Logger.getLogger("main");
-
private ShortTypePrinter() {}
static String print(TypeMirror type) {
@@ -67,8 +64,7 @@ class ShortTypePrinter extends AbstractTypeVisitor8<String, Void> {
@Override
public String visitTypeVariable(TypeVariable t, Void aVoid) {
String result = t.asElement().toString();
- TypeMirror upper = t.getUpperBound();
-
+ // TypeMirror upper = t.getUpperBound();
// NOTE this can create infinite recursion
// if (!upper.toString().equals("java.lang.Object"))
// result += " extends " + print(upper);
diff --git a/src/main/java/org/javacs/TemplatePrinter.java b/src/main/java/org/javacs/TemplatePrinter.java
index a7892ef..e68d6f9 100644
--- a/src/main/java/org/javacs/TemplatePrinter.java
+++ b/src/main/java/org/javacs/TemplatePrinter.java
@@ -3,7 +3,6 @@ package org.javacs;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
@@ -11,8 +10,6 @@ import javax.lang.model.type.*;
import javax.lang.model.util.AbstractTypeVisitor8;
class TemplatePrinter extends AbstractTypeVisitor8<String, Void> {
- private final Logger LOG = Logger.getLogger("main");
-
private Map<TypeMirror, Integer> parameters = new HashMap<>();
private int parameter(TypeMirror t) {
@@ -100,7 +97,6 @@ class TemplatePrinter extends AbstractTypeVisitor8<String, Void> {
private String printArguments(ExecutableElement e) {
var result = new StringJoiner(", ");
for (var p : e.getParameters()) {
- var s = new StringBuilder();
result.add(print(p.asType()) + " " + p.getSimpleName());
}
return result.toString();