-
Notifications
You must be signed in to change notification settings - Fork 9
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
Improve handling of qualified names when renaming #531
base: main
Are you sure you want to change the base?
Conversation
2e00c0b
to
046df83
Compare
046df83
to
7b62cb2
Compare
63a2866
to
9f8d64b
Compare
ab74b9e
to
2eb84b2
Compare
83be677
to
9dc8e7d
Compare
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.
Looks good, with some exceptions that I marked down.
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseWorkspaceService.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/IBaseTextDocumentService.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServer.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalWorkspaceService.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalWorkspaceService.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/rascal/lang/rascal/lsp/refactor/rename/Modules.rsc
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalWorkspaceService.java
Outdated
Show resolved
Hide resolved
05284c1
to
dd91729
Compare
This works around a more generic solution of sharing evaluators beteen the document and workspace services, whic is being tracked in #541.
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/BaseLanguageServer.java
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.
Some small changes, looks mostly fine 👍🏼
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServer.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalTextDocumentService.java
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
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.
Looks good, 2 points that we should still pay attention to:
- the work inside the eval closure should really only call the evaluator, nothing more (just to avoid deadlocks), I've left a comment where it's happening.
- the test currently fails.
ISourceLocation newLoc = sourceLocationFromUri(rename.getNewUri()); | ||
|
||
ISourceLocation currentWsFolder = findContainingWorkspaceFolder(currentLoc, sortedWorkspaceFolders) | ||
.orElseThrow(() -> new RuntimeException(String.format("Cannot automatically change uses of %s, since it is outside the current workspace.", currentLoc))); |
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.
nit: if we move this orElseThrow
into the findContainingWorkspaceFolder
we don't have to repeat it at the call site. (since it happens twice)
} | ||
|
||
private static String readFile(ISourceLocation loc) { | ||
URIResolverRegistry reg = URIResolverRegistry.getInstance(); |
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.
nit: reg
can be inlined.
|
||
return runEvaluator("Rascal module rename", semanticEvaluator, eval -> { | ||
IFunction rascalGetPathConfig = eval.getFunctionValueFactory().function(getPathConfigType, (t, u) -> addResources(getPathConfig.apply((ISourceLocation) t[0]))); | ||
ISet qualifiedNameChanges = qualfiedNameChangesFromRenames(fileRenames, workspaceFolders, getPathConfig); |
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.
ideally we keep the work inside the eval
lock as small as possible. especially since the qualifiedNameChangesFromRenames
can end up callin maven (where there is some different locking happening in the latest version of rascal) we would hate to see a deadlock there.
So I would prefer if we can move this code to a completable future "before" this one, and only after that compose that to the runEvaluator
closure.
} | ||
}) | ||
.exceptionally(e -> { | ||
client.showMessage(new MessageParams(MessageType.Error, e.getCause().getMessage())); |
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.
also add a logger.catching
call to log the original error in case we want to debug it.
.stream() | ||
.map(f -> Locations.toLoc(f.getUri())) | ||
.collect(Collectors.toSet()), getExecuter()) | ||
.thenAccept(folders -> ((RascalTextDocumentService) docService).didRenameFiles(params, folders)); |
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.
nit: I think the .thenAccept
should not be indented as a "sub" of the stream operator, but higher up. It think that the stream chain should be 2 levels of indentation, and then .thenAccept
at 1 level of indentation.
\syntax
) and v.v.