diff --git a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java index 5e527127..d46144ef 100644 --- a/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java +++ b/rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java @@ -213,7 +213,7 @@ public InterruptibleFuture 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(); diff --git a/rascal-lsp/src/main/rascal/lang/rascal/lsp/refactor/Rename.rsc b/rascal-lsp/src/main/rascal/lang/rascal/lsp/refactor/Rename.rsc index ca6e73c5..9f5b304c 100644 --- a/rascal-lsp/src/main/rascal/lang/rascal/lsp/refactor/Rename.rsc +++ b/rascal-lsp/src/main/rascal/lang/rascal/lsp/refactor/Rename.rsc @@ -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 +); diff --git a/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc b/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc index 46dc4955..df91949f 100644 --- a/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc +++ b/rascal-lsp/src/main/rascal/lang/rascal/tests/rename/TestUtils.rsc @@ -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 \'\' from "); - 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 @@ -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)) {