Skip to content

Commit cf28ca5

Browse files
committed
Clean up ScriptSession
1 parent bcebd59 commit cf28ca5

1 file changed

Lines changed: 4 additions & 18 deletions

File tree

‎scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptSession.java‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,7 @@
8585
import org.scijava.script.ScriptLanguage;
8686

8787
/**
88-
* A {@link LanguageServerService} session for a given SciJava script.
89-
* <p>
90-
* A session controls its own {@link LanguageServer}: it a server of its own, which it shuts down when closed; it
91-
* keeps the server's copy of the script up to date when mutated by the
92-
* client. The server sees the script as plain code of its language (see
93-
* {@link ScriptDialect}); the session maps positions in its answers back,
94-
* leaving out what concerns only the lines it added.
95-
* </p>
96-
* <p>
97-
* The server analyzes the script where it runs, as its dialect says (see
98-
* {@link ScriptDialect#environment}). As that changes (e.g. as the script's
99-
* declared environment is edited), the session moves to a new server, of the
100-
* new environment. It talks to its server off the caller's thread, telling
101-
* and asking it everything in order.
102-
* </p>
88+
* A {@link LanguageServer} session for a SciJava script.
10389
*
10490
* @author Gabriel Selzer
10591
*/
@@ -131,7 +117,7 @@ public final class ScriptSession implements AutoCloseable {
131117
private CompletableFuture<Optional<LanguageServer>> server =
132118
CompletableFuture.completedFuture(Optional.empty());
133119
/** Where the script runs, as the server is launched for. */
134-
private Optional<Environment> environment = Optional.empty();
120+
private Environment environment = new Environment();
135121
/** How many servers were moved to: which one is meant, as of now. */
136122
private int generation;
137123
/** The server whose messages are heard (set as it is launched). */
@@ -467,8 +453,8 @@ private static boolean isAccessible(final Class<?> c) {
467453
*/
468454
private boolean follow() {
469455
final Environment env = doc.environment(file.get());
470-
if (closed || environment.equals(Optional.of(env))) return false;
471-
environment = Optional.of(env);
456+
if (closed || environment.equals(env)) return false;
457+
environment = env;
472458
generation++;
473459
server = server.thenApplyAsync(old -> {
474460
old.ifPresent(this::stop);

0 commit comments

Comments
 (0)