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

Make the current instance of SomLanguage accessible for language server #277

Merged
merged 1 commit into from Oct 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/som/interpreter/SomLanguage.java
Expand Up @@ -129,6 +129,14 @@ public final class SomLanguage extends TruffleLanguage<VM> {
@CompilationFinal private VM vm;
@CompilationFinal private VmOptions options;

/** This is used by the Language Server to get to an initialized instance easily. */
private static SomLanguage current;

/** This is used by the Language Server to get to an initialized instance easily. */
public static SomLanguage getCurrent() {
return current;
}

public static Source getSyntheticSource(final String text, final String name) {
return Source.newBuilder(LANG_ID, text, name).internal(true).mimeType(MIME_TYPE)
.build();
Expand Down Expand Up @@ -182,6 +190,7 @@ protected void initializeContext(final VM vm) throws Exception {
if (vm != null) {
vm.initalize(this);
}
current = this;
}

@Override
Expand All @@ -190,6 +199,7 @@ protected void disposeContext(final VM context) {
assert vm == context;
context.shutdown();
}
current = null;
}

public VM getVM() {
Expand Down