Skip to content

Commit

Permalink
Swap rename param order.
Browse files Browse the repository at this point in the history
  • Loading branch information
toinehartman committed Dec 19, 2024
1 parent 136090c commit d56c958
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
} catch (Throw e) {
if (e.getException() instanceof IConstructor) {
var exception = (IConstructor)e.getException();
Expand Down
35 changes: 16 additions & 19 deletions rascal-lsp/src/main/rascal/lang/rascal/lsp/refactor/Rename.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -528,22 +528,19 @@ ProjectFiles rascalAllWorkspaceFiles(TModel tm, Cursor cur, set[loc] workspaceFo
2. It does not change the semantics of the application.
3. It does not change definitions outside of the current workspace.
}
Edits rascalRenameSymbol(Tree cursorT, set[loc] workspaceFolders, str newName, PathConfig(loc) getPathConfig) {
RenameSymbolF rascalRename = renameSymbolFramework(
CheckResult(Tree c, str nn, set[loc] _, PathConfig(loc) _) { return rascalCheckLegalNameByType(nn, typeOf(c)); }
, CheckResult(TModel tm, loc moduleLoc, str nn, set[RenameLocation] defs, set[RenameLocation] uses) {
start[Module] m = parseModuleWithSpacesCached(moduleLoc);
return rascalCollectIllegalRenames(tm, m, defs.l, uses.l, nn);
}
, rascalPreloadFiles
, rascalAllWorkspaceFiles
, rascalTModels
, rascalEscapeName
, rascalGetCursor
, DefsUsesRenames(TModel tm, Cursor cur, ChangeAnnotationRegister regChangeAnno, PathConfigF gpcfg) {
return rascalGetDefsUses(tm, cur, rascalMayOverloadSameName, regChangeAnno, gpcfg);
}
, rascalFindNamesInUseDefs
);
return rascalRename(cursorT, newName, workspaceFolders, getPathConfig);
}
public RenameSymbolF rascalRenameSymbol = renameSymbolFramework(
CheckResult(Tree c, str nn, set[loc] _, PathConfig(loc) _) { return rascalCheckLegalNameByType(nn, typeOf(c)); }
, CheckResult(TModel tm, loc moduleLoc, str nn, set[RenameLocation] defs, set[RenameLocation] uses) {
start[Module] m = parseModuleWithSpacesCached(moduleLoc);
return rascalCollectIllegalRenames(tm, m, defs.l, uses.l, nn);
}
, rascalPreloadFiles
, rascalAllWorkspaceFiles
, rascalTModels
, rascalEscapeName
, rascalGetCursor
, DefsUsesRenames(TModel tm, Cursor cur, ChangeAnnotationRegister regChangeAnno, PathConfigF gpcfg) {
return rascalGetDefsUses(tm, cur, rascalMayOverloadSameName, regChangeAnno, gpcfg);
}
, rascalFindNamesInUseDefs
);
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ bool testRenameOccurrences(set[TestModule] modules, str oldName = "foo", str new
cursorT = findCursor([m.file | m <- modulesByLocation, getModuleName(m.file, pcfg) == mm.name][0], oldName, cursorOcc);
println("Renaming \'<oldName>\' from <cursorT.src>");
edits = rascalRenameSymbol(cursorT, toSet(pcfg.srcs), newName, PathConfig(loc _) { return pcfg; });
edits = rascalRenameSymbol(cursorT, newName, toSet(pcfg.srcs), PathConfig(loc _) { return pcfg; });
renamesPerModule = (
beforeRename: afterRename
Expand Down Expand Up @@ -225,7 +225,7 @@ PathConfig getPathConfig(loc project) {
Edits getEdits(loc singleModule, set[loc] projectDirs, int cursorAtOldNameOccurrence, str oldName, str newName, PathConfig(loc) getPathConfig) {
Tree cursor = findCursor(singleModule, oldName, cursorAtOldNameOccurrence);
return rascalRenameSymbol(cursor, projectDirs, newName, getPathConfig);
return rascalRenameSymbol(cursor, newName, projectDirs, getPathConfig);
}
tuple[Edits, set[int]] getEditsAndOccurrences(loc singleModule, loc projectDir, int cursorAtOldNameOccurrence, str oldName, str newName, PathConfig pcfg = getTestPathConfig(projectDir)) {
Expand Down

0 comments on commit d56c958

Please sign in to comment.