-
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
Parameterize rename framework #547
base: main
Are you sure you want to change the base?
Conversation
d56c958
to
580c61c
Compare
|
||
private tuple[set[IllegalRenameReason] reasons, list[TextEdit] edits] computeTextEdits(TModel ws, loc moduleLoc, set[RenameLocation] defs, set[RenameLocation] uses, str name, ChangeAnnotationRegister registerChangeAnnotation) = | ||
computeTextEdits(ws, parseModuleWithSpacesCached(moduleLoc), defs, uses, name, registerChangeAnnotation); | ||
|
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.
Moved to parametric util::refactor::Rename
} | ||
|
||
set[TModel] tmodelsForProjectFiles(ProjectFiles projectFiles, set[TModel](set[loc], PathConfig) tmodelsForFiles, PathConfig(loc) getPathConfig) = | ||
({} | it + tmodelsForFiles(projectFiles[pf, true], pcfg) | pf <- projectFiles.projectFolder, pcfg := getPathConfig(pf)); |
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.
Moved to parametric util::refactor::Rename
import lang::rascalcore::check::Checker; | ||
import lang::rascalcore::check::ATypeBase; | ||
import lang::rascalcore::check::BasicRascalConfig; | ||
import lang::rascalcore::check::RascalConfig; |
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.
Use some more specific imports here to speed up type-checking
|
||
set[loc] getDefs(TModel ws, loc use) = ws.useDef[use]; | ||
|
||
Maybe[AType] getFact(TModel ws, loc l) = l in ws.facts ? just(ws.facts[l]) : nothing(); |
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.
Moved to parametric util::refactor::WorkspaceInfo
@@ -168,9 +107,6 @@ set[loc] rascalReachableModules(TModel ws, set[loc] froms) { | |||
return {s.top | s <- reachable.modScope}; | |||
} | |||
|
|||
@memo{maximumSize(1), expireAfter(minutes=5)} | |||
rel[loc, Define] definitionsRel(TModel ws) = toRel(ws.definitions); | |||
|
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.
Moved to parametric util::refactor::WorkspaceInfo
@@ -213,7 +213,7 @@ public InterruptibleFuture<ITuple> getRename(ITree module, Position cursor, Set< | |||
return runEvaluator("Rascal rename", semanticEvaluator, eval -> { | |||
try { | |||
IFunction rascalGetPathConfig = eval.getFunctionValueFactory().function(getPathConfigType, (t, u) -> addResources(getPathConfig.apply((ISourceLocation) t[0]))); | |||
return (ITuple) eval.call("rascalRenameSymbol", cursorTree, VF.set(workspaceFolders.toArray(ISourceLocation[]::new)), VF.string(newName), rascalGetPathConfig); | |||
return (ITuple) eval.call("rascalRenameSymbol", cursorTree, VF.string(newName), VF.set(workspaceFolders.toArray(ISourceLocation[]::new)), rascalGetPathConfig); |
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.
Swap parameter order to make more sense
@@ -77,9 +73,9 @@ void throwAnyErrors(program(_, msgs)) { | |||
throwAnyErrors(msgs); | |||
} | |||
|
|||
private set[IllegalRenameReason] rascalCheckLegalName(str name, set[IdRole] roles) { | |||
private set[IllegalRenameReason] rascalCheckLegalNameByRoles(str name, set[IdRole] roles) { |
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.
Renamed (like rascalCheckLegalNameByType
below) to be able to pass as argument.
, CursorF getCursor | ||
, DefsUsesF getDefsUses | ||
, FindNamesF findNames | ||
) { |
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.
A more Rascal-y way would maybe be to define failing variants of these functions here, and extend them in the language specific module?
@synopsis{ | ||
A cached wrapper for the Rascal whole-module parse function. | ||
} | ||
start[Module] parseModuleWithSpacesCached(loc l) { |
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.
Moved to lang::rascal::lsp::refactor::WorkspaceInfo
return bool(&T t1, &T t2) { | ||
return f(t2, t1); | ||
}; | ||
} |
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.
All unused -> removed.
Quality Gate passedIssues Measures |
Paramterized rename framework + Rascal implementation.
This introduces a general framework for renaming refactorings. It rearranges existing code to separate generic renaming plumbing from Rascal-specific implementations, therefore increasing readability and increasing the amount of type-checkable (i.e. not dependent on
rascal-core
) code.