-
Notifications
You must be signed in to change notification settings - Fork 12
Remember files opened as Parametric Rascal LSP
before language registration
#809
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
base: main
Are you sure you want to change the base?
Conversation
Keep track of files that are classified as 'Parametric Rascal MPL' language, but with an unknown extension. Once someone registers this extension, store the file state and update the editor as if they were opened *after* registering the language.
'Parametric Rascal MPL
before language registrationParametric Rascal MPL
before language registration
Parametric Rascal MPL
before language registrationParametric Rascal LSP
before language registration
if (extension(f).equals(extension)) { | ||
var opened = unregisteredFiles.remove(f); | ||
var doc = opened.getLeft(); | ||
var file = new TextDocumentState(contributions(f)::parsing, f, doc.getVersion(), doc.getText(), opened.getRight()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some overlap here with the work done by "didOpen" does. Maybe with a little refactoring we can merge these code paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is a bit involved, as in it requires many places to take into account possible race between registry & availability of the language. Especially if someone later adds a new capability, it'll soon be forgotten.
I'm thinking there might be a way to make a subclass of our ParsingOnlyContribution (like EmptyContribution
) and then connect that to the incoming file. and when a registry comes in, we update all the existing mappings to the new contribution?
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/parametric/ParametricTextDocumentService.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/parametric/ParametricTextDocumentService.java
Outdated
Show resolved
Hide resolved
5c9467d
to
1a0da53
Compare
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/TextDocumentState.java
Outdated
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how small this got in the end.
} | ||
|
||
private void triggerAnalyzer(ISourceLocation location, int version, Duration delay) { | ||
logger.trace("Triggering analyzer for {}", location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this log should be inside the if, and an else branch that logs why we're not triggering an analyzer?
= isLanguageRegistered(loc) | ||
? contributions(loc)::parsing | ||
// Language not (yet) registered; plug in an incomplete parse future | ||
: (l, s) -> new CompletableFuture<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this future will never complete, won't that cause issues? like any down stream jobs?
if (extensions.contains(extension(f))) { | ||
logger.trace("Open file of language {} - updating state: {}", lang.getName(), f); | ||
var c = state.getCurrentContent(); | ||
state = files.replace(f, new TextDocumentState(contributions(f)::parsing, f, c.version(), state.getCurrentContent().get(), state.getLastModified())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a function on TextDocumentState
called changeParser
or something, such that it can be responsible for passing on the right state to the new instance?
This PR keeps track of files that are open with language
Parametric Rascal LSP
, for which there is no language registered yet. Once the user registers a language, we update the associated open editors.This PR closes #795.