diff options
author | George Fraser <george@fivetran.com> | 2019-01-08 20:05:17 -0800 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2019-01-08 20:05:17 -0800 |
commit | 07a4b8b44b492d18cd759022395eb3a593f42f75 (patch) | |
tree | f8d9eb874d686ed5961791a8e0c1c0e6b55b35da /src/main/java/org/javacs/JavaLanguageServer.java | |
parent | 727bd8341afc689c842385a234647b8f7b22de21 (diff) | |
download | java-language-server-07a4b8b44b492d18cd759022395eb3a593f42f75.zip |
Reduce passing of contents
Diffstat (limited to 'src/main/java/org/javacs/JavaLanguageServer.java')
-rw-r--r-- | src/main/java/org/javacs/JavaLanguageServer.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/main/java/org/javacs/JavaLanguageServer.java b/src/main/java/org/javacs/JavaLanguageServer.java index 175e4ce..65d95dc 100644 --- a/src/main/java/org/javacs/JavaLanguageServer.java +++ b/src/main/java/org/javacs/JavaLanguageServer.java @@ -332,11 +332,10 @@ class JavaLanguageServer extends LanguageServer { var started = Instant.now(); var uri = position.textDocument.uri; if (!FileStore.isJavaFile(uri)) return Optional.empty(); - var content = FileStore.contents(uri); var line = position.position.line + 1; var column = position.position.character + 1; // Figure out what kind of completion we want to do - var maybeCtx = compiler.parseFile(uri, content).completionContext(line, column); + var maybeCtx = compiler.parseFile(uri).completionContext(line, column); // TODO don't complete inside of comments if (!maybeCtx.isPresent()) { var items = new ArrayList<CompletionItem>(); @@ -353,7 +352,7 @@ class JavaLanguageServer extends LanguageServer { var ctx = maybeCtx.get(); // TODO CompileFocus should have a "patch" mechanism where we recompile the current file without creating a new // task - var focus = compiler.compileFocus(uri, content, ctx.line, ctx.character); + var focus = compiler.compileFocus(uri, ctx.line, ctx.character); // Do a specific type of completion List<Completion> cs; boolean isIncomplete; @@ -624,7 +623,7 @@ class JavaLanguageServer extends LanguageServer { || !activeFileCache.file.equals(uri) || activeFileCacheVersion != FileStore.version(uri)) { LOG.info("Recompile active file..."); - activeFileCache = compiler.compileFile(uri, FileStore.contents(uri)); + activeFileCache = compiler.compileFile(uri); activeFileCacheVersion = FileStore.version(uri); } } @@ -738,12 +737,11 @@ class JavaLanguageServer extends LanguageServer { public Optional<SignatureHelp> signatureHelp(TextDocumentPositionParams position) { var uri = position.textDocument.uri; if (!FileStore.isJavaFile(uri)) return Optional.empty(); - var content = FileStore.contents(uri); var line = position.position.line + 1; var column = position.position.character + 1; // TODO CompileFocus should have a "patch" mechanism where we recompile the current file without creating a new // task - var focus = compiler.compileFocus(uri, content, line, column); + var focus = compiler.compileFocus(uri, line, column); var help = focus.methodInvocation().map(this::asSignatureHelp); return help; } @@ -835,8 +833,7 @@ class JavaLanguageServer extends LanguageServer { if (name.equals("<init>")) name = el.getEnclosingElement().getSimpleName().toString(); var sources = new ArrayList<JavaFileObject>(); for (var f : files) { - var contents = FileStore.contents(f); - var pruned = Pruner.prune(f, contents, name); + var pruned = Pruner.prune(f, name); sources.add(new SourceFileObject(f, pruned)); } return sources; @@ -858,7 +855,7 @@ class JavaLanguageServer extends LanguageServer { private void updateCachedParse(URI file) { if (file.equals(cacheParseFile) && FileStore.version(file) == cacheParseVersion) return; LOG.info(String.format("Updating cached parse file to %s", file)); - cacheParse = compiler.parseFile(file, FileStore.contents(file)); + cacheParse = compiler.parseFile(file); cacheParseFile = file; cacheParseVersion = FileStore.version(file); } |