Skip to content

Commit 612210c

Browse files
committed
Extract monitor from otherwise unused LSPIDEServices
1 parent dfeff8b commit 612210c

File tree

3 files changed

+10
-31
lines changed

3 files changed

+10
-31
lines changed

rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/parametric/InterpretedLanguageContributions.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import org.rascalmpl.vscode.lsp.parametric.model.RascalADTs.LanguageContributions;
5454
import org.rascalmpl.vscode.lsp.rascal.conversion.KeywordParameter;
5555
import org.rascalmpl.vscode.lsp.util.EvaluatorUtil;
56-
import org.rascalmpl.vscode.lsp.util.EvaluatorUtil.LSPContext;
5756
import org.rascalmpl.vscode.lsp.util.concurrent.InterruptibleFuture;
5857

5958
import io.usethesource.vallang.IBool;
@@ -140,8 +139,7 @@ public InterpretedLanguageContributions(LanguageParameter lang, IBaseTextDocumen
140139

141140
monitor = new RascalLSPMonitor(client, LogManager.getLogger(logger.getName() + "[" + lang.getName() + "]"), lang.getName() + ": ");
142141

143-
this.eval = EvaluatorUtil.makeFutureEvaluator(new LSPContext(exec, docService, workspaceService, client),
144-
"evaluator for " + lang.getName(), monitor, pcfg, lang.getMainModule());
142+
this.eval = EvaluatorUtil.makeFutureEvaluator("evaluator for " + lang.getName(), monitor, pcfg, exec, lang.getMainModule());
145143
var contributions = EvaluatorUtil.runEvaluator(name + ": loading contributions", eval,
146144
e -> loadContributions(e, lang),
147145
ValueFactoryFactory.getValueFactory().set(),

rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import org.rascalmpl.vscode.lsp.IBaseLanguageClient;
6868
import org.rascalmpl.vscode.lsp.RascalLSPMonitor;
6969
import org.rascalmpl.vscode.lsp.util.EvaluatorUtil;
70-
import org.rascalmpl.vscode.lsp.util.EvaluatorUtil.LSPContext;
7170
import org.rascalmpl.vscode.lsp.util.RascalServices;
7271
import org.rascalmpl.vscode.lsp.util.concurrent.InterruptibleFuture;
7372
import org.rascalmpl.vscode.lsp.util.locations.Locations;
@@ -120,11 +119,9 @@ public RascalLanguageServices(RascalTextDocumentService docService, BaseWorkspac
120119
var pcfg = EvaluatorUtil.addLSPSources(new PathConfig(URIUtil.rootLocation("cwd")), true);
121120
var compilerPcfg = EvaluatorUtil.addRascalCompilerSources(pcfg);
122121

123-
var context = new LSPContext(exec, docService, workspaceService, client);
124-
125-
shortRunningTaskEvaluator = makeFutureEvaluator(context, "Rascal tasks", monitor, pcfg, "lang::rascal::lsp::DocumentSymbols", "lang::rascal::lsp::Templates");
126-
semanticEvaluator = makeFutureEvaluator(context, "Rascal semantics", monitor, compilerPcfg, "lang::rascalcore::check::Summary", "lang::rascal::lsp::refactor::Rename", "lang::rascal::lsp::Actions");
127-
compilerEvaluator = makeFutureEvaluator(context, "Rascal compiler", monitor, compilerPcfg, "lang::rascal::lsp::IDECheckerWrapper");
122+
shortRunningTaskEvaluator = makeFutureEvaluator("Rascal tasks", monitor, pcfg, exec, "lang::rascal::lsp::DocumentSymbols", "lang::rascal::lsp::Templates");
123+
semanticEvaluator = makeFutureEvaluator("Rascal semantics", monitor, compilerPcfg, exec, "lang::rascalcore::check::Summary", "lang::rascal::lsp::refactor::Rename", "lang::rascal::lsp::Actions");
124+
compilerEvaluator = makeFutureEvaluator("Rascal compiler", monitor, compilerPcfg, exec, "lang::rascal::lsp::IDECheckerWrapper");
128125
actionStore = semanticEvaluator.thenApply(e -> ((ModuleEnvironment) e.getModule("lang::rascal::lsp::Actions")).getStore());
129126
rascalTextDocumentService = docService;
130127
this.workspaceService = workspaceService;

rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/util/EvaluatorUtil.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -356,52 +356,36 @@ public static PathConfig addRascalCompilerSources(PathConfig pcfg) {
356356
}
357357
}
358358

359-
public static class LSPContext {
360-
private final ExecutorService exec;
361-
private final IBaseTextDocumentService docService;
362-
private final BaseWorkspaceService workspaceService;
363-
private final IBaseLanguageClient client;
364-
365-
public LSPContext(ExecutorService exec, IBaseTextDocumentService docService,
366-
BaseWorkspaceService workspaceService, IBaseLanguageClient client) {
367-
this.exec = exec;
368-
this.docService = docService;
369-
this.workspaceService = workspaceService;
370-
this.client = client;
371-
}
372-
}
373-
374359
/**
375360
* This function is used to construct evaluators used by LSP servers, not the terminal REPL
376361
*/
377-
public static CompletableFuture<Evaluator> makeFutureEvaluator(LSPContext context, String label, IRascalMonitor monitor, PathConfig pcfg, final String... imports) {
362+
public static CompletableFuture<Evaluator> makeFutureEvaluator(String label, IRascalMonitor monitor, PathConfig pcfg, ExecutorService exec, final String... imports) {
378363
return CompletableFuture.supplyAsync(() -> {
379364
Logger customLog = LogManager.getLogger("Evaluator: " + label);
380-
IDEServices services = new LSPIDEServices(context.client, context.docService, context.workspaceService, monitor);
381365
boolean jobSuccess = false;
382366
String jobName = "Loading " + label;
383367
try {
384-
services.jobStart(jobName, imports.length);
368+
monitor.jobStart(jobName, imports.length);
385369
var eval = ShellEvaluatorFactory.getDefaultEvaluatorForPathConfig(
386370
pcfg.getProjectRoot(),
387371
pcfg,
388372
Reader.nullReader(),
389373
logWriter(customLog, Level.INFO),
390374
logWriter(customLog, Level.ERROR),
391-
services
375+
monitor
392376
);
393377

394378
eval.addClassLoader(RascalLanguageServer.class.getClassLoader());
395379

396-
eval.doImport(services, imports);
380+
eval.doImport(monitor, imports);
397381

398382
jobSuccess = true;
399383
return eval;
400384
}
401385
finally {
402-
services.jobEnd(jobName, jobSuccess);
386+
monitor.jobEnd(jobName, jobSuccess);
403387
}
404-
}, context.exec);
388+
}, exec);
405389
}
406390

407391
private static PrintWriter logWriter(Logger customLog, Level level) {

0 commit comments

Comments
 (0)