diff options
author | George Fraser <george@fivetran.com> | 2018-12-30 18:09:32 -0800 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2018-12-30 18:09:32 -0800 |
commit | 61642c3771d6e66c455a4723b6c077b6518bbddd (patch) | |
tree | 9ce60f6bf8ad59413528cf298832d0efd96e7c48 /src | |
parent | bf5a86da23782a0b297f4862fef9ca6597ca9cbc (diff) | |
download | java-language-server-61642c3771d6e66c455a4723b6c077b6518bbddd.zip |
Show type
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/javacs/JavaLanguageServer.java | 2 | ||||
-rw-r--r-- | src/main/java/org/javacs/ShortTypePrinter.java | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/org/javacs/JavaLanguageServer.java b/src/main/java/org/javacs/JavaLanguageServer.java index 63608f9..720da89 100644 --- a/src/main/java/org/javacs/JavaLanguageServer.java +++ b/src/main/java/org/javacs/JavaLanguageServer.java @@ -385,7 +385,7 @@ class JavaLanguageServer extends LanguageServer { i.label = c.element.getSimpleName().toString(); i.kind = completionItemKind(c.element); // Detailed name will be resolved later, using docs to fill in method names - if (!(c.element instanceof ExecutableElement)) i.detail = c.element.toString(); + if (!(c.element instanceof ExecutableElement)) i.detail = ShortTypePrinter.print(c.element.asType()); i.sortText = 2 + i.label; } else if (c.packagePart != null) { i.label = c.packagePart.name; diff --git a/src/main/java/org/javacs/ShortTypePrinter.java b/src/main/java/org/javacs/ShortTypePrinter.java index 86171af..5e143c2 100644 --- a/src/main/java/org/javacs/ShortTypePrinter.java +++ b/src/main/java/org/javacs/ShortTypePrinter.java @@ -14,6 +14,7 @@ class ShortTypePrinter extends AbstractTypeVisitor8<String, Void> { private ShortTypePrinter() {} static String print(TypeMirror type) { + // TODO allow packageContext which suppresses printing of those package prefixes return type.accept(new ShortTypePrinter(), null); } @@ -53,8 +54,8 @@ class ShortTypePrinter extends AbstractTypeVisitor8<String, Void> { result += "<" + params + ">"; } - if (result.matches("java\\.lang\\.\\w+")) return result.substring("java.lang.".length()); - else if (result.startsWith("java\\.util\\.\\w+")) return result.substring("java.util.".length()); + if (result.startsWith("java.lang")) return result.substring("java.lang.".length()); + else if (result.startsWith("java.util")) return result.substring("java.util.".length()); else return result; } |