Skip to content

Commit

Permalink
Fix and simplify name containment check.
Browse files Browse the repository at this point in the history
  • Loading branch information
toinehartman committed Dec 17, 2024
1 parent 7b1b6c7 commit 2dd0f1f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions rascal-lsp/src/main/rascal/lang/rascal/lsp/refactor/Rename.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -408,22 +408,13 @@ Cursor rascalGetCursor(TModel ws, Tree cursorT) {
return cursor(kind, min(locsContainingCursor.l), cursorName);
}

private set[Tree] rascalNameToEquivalentNames(str name) {
set[Tree] equivs = {t
| T <- {#Name, #Nonterminal, #NonterminalLabel}
, just(Tree t) := tryParseAs(T, name)
};

if (!startsWith(name, "\\") && just(en) := tryParseAs(#Name, "\\<name>")) equivs += en;

return equivs;
}
private set[str] rascalNameToEquivalentNames(str name) =
{name, startsWith(name, "\\") ? name : "\\<name>"};

private bool rascalContainsName(loc l, str name) {
m = parseModuleWithSpacesCached(l);
for (n <- rascalNameToEquivalentNames(name)) {
if (/n := m) return true;
}
start[Module] m = parseModuleWithSpacesCached(l);
set[str] names = rascalNameToEquivalentNames(name);
if (/Tree t := m, "<t>" in names) return true;
return false;
}
Expand Down

0 comments on commit 2dd0f1f

Please sign in to comment.