-
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
Open
toinehartman
wants to merge
36
commits into
main
Choose a base branch
from
fix/795-open-register-race
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
01fa185
Keep track of opened files with unknown extension.
toinehartman ec1363b
Check for valid state before getting files.
toinehartman 2d7b93c
Use dummy parser instead of separate open file bookkeeping.
toinehartman ce5aee8
Reset parser.
toinehartman ab6e7c6
Simplify updating open files.
toinehartman 1a0da53
Re-use newly introduced language helpers.
toinehartman 8d8b675
Merge remote-tracking branch 'origin/main' into fix/795-open-register…
toinehartman 65bd32f
Replace state instead of updating parser.
toinehartman e9f791a
Exception instead of incomplete future.
toinehartman bee0669
Merge remote-tracking branch 'origin/main' into fix/795-open-register…
toinehartman 37c816c
Prevent 'no such file' errors using dummy contribution.
toinehartman da179cf
Clean up declarations & imports.
toinehartman eaa412f
Prevent 'no such file' errors on analysis.
toinehartman 80b9fd3
Register extension after contibution registration is done.
toinehartman efaa03c
Merge remote-tracking branch 'origin/main' into fix/795-open-register…
toinehartman 261bf55
Extract updating file state to functions.
toinehartman cfebe65
Properly log analyzer triggers.
toinehartman b6380dd
Reset language ID to re-trigger contributions.
toinehartman eb973f0
Rewrite optional mapping.
toinehartman 74b8451
Merge remote-tracking branch 'origin/main' into fix/795-open-register…
toinehartman 252608f
Log port number when server fails.
toinehartman edb3302
Use precise replace to prevent races.
toinehartman 82b5b98
Bump log level.
toinehartman 73a479e
Document NoContributions.
toinehartman 6485415
Fix SQ issues.
toinehartman c050228
Handle case where didClose or registerLanguage races with parser update.
toinehartman f9b8582
Fixes from review by @DavyLandman.
toinehartman 4781d0c
Associate empty contributions with extension.
toinehartman 27a6410
Throw exceptions on methods that are not intended to be called.
toinehartman 756bb02
Merge remote-tracking branch 'origin/main' into fix/795-open-register…
toinehartman e20ddde
Refactor and fix SQ warnings.
toinehartman 0e1ac0d
Revert "Throw exceptions on methods that are not intended to be called."
toinehartman 6e9be85
Do not wrap exceptions in futures.
toinehartman 61108eb
Merge remote-tracking branch 'origin/main' into fix/795-open-register…
toinehartman eb1f73b
Make sure to always complete tree future.
toinehartman 93bd8ad
Revert changes to state computation.
toinehartman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
263 changes: 263 additions & 0 deletions
263
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/parametric/NoContributions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,263 @@ | ||
| /* | ||
| * Copyright (c) 2018-2025, NWO-I CWI and Swat.engineering | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
| package org.rascalmpl.vscode.lsp.parametric; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.concurrent.CompletableFuture; | ||
| import java.util.concurrent.Executor; | ||
| import java.util.concurrent.TimeUnit; | ||
| import org.apache.commons.lang3.NotImplementedException; | ||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
| import org.rascalmpl.values.parsetrees.ITree; | ||
| import org.rascalmpl.vscode.lsp.util.concurrent.InterruptibleFuture; | ||
|
|
||
| import io.usethesource.vallang.IConstructor; | ||
| import io.usethesource.vallang.IList; | ||
| import io.usethesource.vallang.ISet; | ||
| import io.usethesource.vallang.ISourceLocation; | ||
| import io.usethesource.vallang.ITuple; | ||
| import io.usethesource.vallang.IValue; | ||
|
|
||
| public class NoContributions implements ILanguageContributions { | ||
|
|
||
| private static final Logger logger = LogManager.getLogger(NoContributions.class); | ||
|
|
||
| private final Duration delay = Duration.ofSeconds(10); | ||
toinehartman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private final CompletableFuture<Boolean> falseFut = CompletableFuture.completedFuture(false); | ||
toinehartman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private Executor exec; | ||
toinehartman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public class NoContributionException extends NotImplementedException { | ||
| private NoContributionException(String message) { | ||
| super(message); | ||
| } | ||
| } | ||
|
|
||
| public NoContributions(Executor exec) { | ||
| this.exec = exec; | ||
| } | ||
|
|
||
| private <T extends IValue> CompletableFuture<T> delayed(T t) { | ||
| var delayedExec = CompletableFuture.delayedExecutor(delay.toMillis(), TimeUnit.MILLISECONDS, exec); | ||
| return CompletableFuture.supplyAsync(() -> t, delayedExec); | ||
| } | ||
|
|
||
| private <T> InterruptibleFuture<T> delayedInterruptibleFailure(String contribution) { | ||
| return new InterruptibleFuture<>(delayedFailure(contribution), () -> {}); | ||
| } | ||
|
|
||
| private <T> CompletableFuture<T> delayedFailure(String contribution) { | ||
| var delayedExec = CompletableFuture.delayedExecutor(delay.toMillis(), TimeUnit.MILLISECONDS, exec); | ||
| return CompletableFuture.supplyAsync(() -> { throw new NoContributionException("Ignoring missing contribution " + contribution); }, delayedExec); | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "Silent contributions"; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<ITree> parsing(ISourceLocation loc, String input) { | ||
| logger.debug("No contrib: parse"); | ||
| return delayedFailure("parsing"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IConstructor> analysis(ISourceLocation loc, ITree input) { | ||
| return delayedInterruptibleFailure("analysis"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IConstructor> build(ISourceLocation loc, ITree input) { | ||
| return delayedInterruptibleFailure("build"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IList> documentSymbol(ITree input) { | ||
| return delayedInterruptibleFailure("documentSymbol"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IList> codeLens(ITree input) { | ||
| return delayedInterruptibleFailure("codeLens"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IList> inlayHint(ITree input) { | ||
| return delayedInterruptibleFailure("inlayHint"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IValue> execution(String command) { | ||
| return delayedInterruptibleFailure("execution"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<ISet> hover(IList focus) { | ||
| return delayedInterruptibleFailure("hover"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<ISet> definition(IList focus) { | ||
| return delayedInterruptibleFailure("definition"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<ISet> references(IList focus) { | ||
| return delayedInterruptibleFailure("references"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<ISet> implementation(IList focus) { | ||
| return delayedInterruptibleFailure("implementation"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IList> codeAction(IList focus) { | ||
| return delayedInterruptibleFailure("codeLens"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<IList> selectionRange(IList focus) { | ||
| return delayedInterruptibleFailure("selectionRange"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<ISourceLocation> prepareRename(IList focus) { | ||
| return delayedInterruptibleFailure("prepareRename"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<ITuple> rename(IList focus, String name) { | ||
| return delayedInterruptibleFailure("rename"); | ||
| } | ||
|
|
||
| @Override | ||
| public InterruptibleFuture<ITuple> didRenameFiles(IList fileRenames) { | ||
| return delayedInterruptibleFailure("didRenameFiles"); | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<IList> parseCodeActions(String command) { | ||
| return delayedFailure("parseCodeActions"); | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasAnalysis() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasBuild() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasDocumentSymbol() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasCodeLens() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasInlayHint() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasRename() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasExecution() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasHover() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasDefinition() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasReferences() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasImplementation() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasCodeAction() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasDidRenameFiles() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> hasSelectionRange() { | ||
| return falseFut; | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Boolean> specialCaseHighlighting() { | ||
| return falseFut; | ||
| } | ||
toinehartman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Override | ||
| public CompletableFuture<SummaryConfig> getAnalyzerSummaryConfig() { | ||
| return delayedFailure("getAnalyzerSummaryConfig"); | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<SummaryConfig> getBuilderSummaryConfig() { | ||
| return delayedFailure("getBuilderSummaryConfig"); | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<SummaryConfig> getOndemandSummaryConfig() { | ||
| return delayedFailure("getOndemandSummaryConfig"); | ||
| } | ||
|
|
||
| @Override | ||
| public void cancelProgress(String progressId) { | ||
| logger.trace("Cancelling progress " + progressId + " not supported on dummy contributions."); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.