|
85 | 85 | import org.scijava.script.ScriptLanguage; |
86 | 86 |
|
87 | 87 | /** |
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. |
103 | 89 | * |
104 | 90 | * @author Gabriel Selzer |
105 | 91 | */ |
@@ -131,7 +117,7 @@ public final class ScriptSession implements AutoCloseable { |
131 | 117 | private CompletableFuture<Optional<LanguageServer>> server = |
132 | 118 | CompletableFuture.completedFuture(Optional.empty()); |
133 | 119 | /** Where the script runs, as the server is launched for. */ |
134 | | - private Optional<Environment> environment = Optional.empty(); |
| 120 | + private Environment environment = new Environment(); |
135 | 121 | /** How many servers were moved to: which one is meant, as of now. */ |
136 | 122 | private int generation; |
137 | 123 | /** The server whose messages are heard (set as it is launched). */ |
@@ -467,8 +453,8 @@ private static boolean isAccessible(final Class<?> c) { |
467 | 453 | */ |
468 | 454 | private boolean follow() { |
469 | 455 | 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; |
472 | 458 | generation++; |
473 | 459 | server = server.thenApplyAsync(old -> { |
474 | 460 | old.ifPresent(this::stop); |
|
0 commit comments