Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to make sure java classes can be used in VS Code projects #401

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@
import org.rascalmpl.library.util.PathConfig;
import org.rascalmpl.shell.ShellEvaluatorFactory;
import org.rascalmpl.uri.URIUtil;
import org.rascalmpl.uri.classloaders.SourceLocationClassLoader;
import org.rascalmpl.vscode.lsp.BaseWorkspaceService;
import org.rascalmpl.vscode.lsp.IBaseLanguageClient;
import org.rascalmpl.vscode.lsp.IBaseTextDocumentService;
import org.rascalmpl.vscode.lsp.LSPIDEServices;
import org.rascalmpl.vscode.lsp.rascal.RascalLanguageServer;
import org.rascalmpl.vscode.lsp.util.concurrent.InterruptibleFuture;
import io.usethesource.vallang.IConstructor;
import io.usethesource.vallang.IList;
import io.usethesource.vallang.ISourceLocation;
import io.usethesource.vallang.IString;
import io.usethesource.vallang.IValue;
Expand Down Expand Up @@ -161,8 +163,20 @@ public static CompletableFuture<Evaluator> makeFutureEvaluator(ExecutorService e
eval.setMonitor(monitor);

eval.getConfiguration().setRascalJavaClassPathProperty(System.getProperty("rascal.compilerClasspath"));

// for the rascal-lsp jar
eval.addClassLoader(RascalLanguageServer.class.getClassLoader());

// for rascal.jar
eval.addClassLoader(IValue.class.getClassLoader());

// for loading classes from the current project and its dependencies
IList classloaders = pcfg.getClassloaders();
ClassLoader cl = new SourceLocationClassLoader(
classloaders.contains(pcfg.getBin()) ? classloaders : classloaders.append(pcfg.getBin()),
ShellEvaluatorFactory.class.getClassLoader());
eval.addClassLoader(cl);

if (addRascalCore) {
eval.addRascalSearchPath(URIUtil.correctLocation("lib", "typepal", ""));
eval.addRascalSearchPath(URIUtil.correctLocation("lib", "rascal-core", ""));
Expand Down
Loading