Skip to content

Commit 96f93a0

Browse files
committed
Do not throw an exception on ignored modules.
1 parent 4ded307 commit 96f93a0

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/refactor/Rename.rsc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,13 @@ public Edits rascalRenameSymbol(loc cursorLoc, list[Tree] cursor, str newName, s
247247
if (!found) {
248248
if (ms.status[mname]?) {
249249
// If a module is annotated with `@ignoreCompiler`, silently skip it
250-
if (MStatus::ignored() in ms.status[mname]) return tmodel();
250+
if (MStatus::ignored() in ms.status[mname]) {
251+
// We just need a way to map the TModel back to the module location, so let's artificially add that
252+
return tmodel()
253+
[modelName = mname]
254+
[moduleLocs = (mname: l)]
255+
;
256+
}
251257
throw "No TModel for module \'<mname>\'";
252258
}
253259
throw "No TModel for module \'<mname>\'";
@@ -402,7 +408,7 @@ private loc nameSuffix(loc l, set[Define] defs, Renamer r) {
402408

403409
void renameUses(set[Define] defs, str newName, TModel tm, Renamer r) {
404410
escName = normalizeEscaping(newName);
405-
tm = getConditionallyAugmentedTModel(getModuleScopes(tm)[tm.modelName].top, defs, {augmentUses()}, r);
411+
tm = getConditionallyAugmentedTModel(getModuleFile(tm), defs, {augmentUses()}, r);
406412

407413
definitions = {<d.defined, d> | d <- defs};
408414
useDefs = toMap(tm.useDef o definitions);

rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/refactor/rename/Common.rsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool isContainedInScope(loc l, loc scope, TModel tm) {
6666
return any(loc fromScope <- reachableFrom, isContainedIn(l, fromScope));
6767
}
6868

69-
loc getModuleFile(TModel tm) = getModuleScopes(tm)[tm.modelName].top;
69+
loc getModuleFile(TModel tm) = tm.moduleLocs[tm.modelName] when tm.moduleLocs[tm.modelName]?;
7070

7171
private set[str] reservedNames = getRascalReservedIdentifiers();
7272

rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/refactor/rename/Constructors.rsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ set[Define] findAdditionalConstructorDefinitions(set[Define] cursorDefs, Tree tr
6767
return {};
6868
}
6969

70-
loc localScope = getModuleScopes(tm)[tm.modelName];
70+
loc localScope = getModuleFile(tm);
7171
if (!any(Define d <- cursorDefs, isContainedInScope(d.defined, localScope, tm) || isContainedInScope(localScope, d.scope, tm))) {
7272
return {};
7373
}

rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/refactor/rename/Fields.rsc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ bool isUnsupportedCursor(list[Tree] _: [*_, Name n1, *_, (Expression) `<Expressi
167167
void renameAdditionalUses(set[Define] fieldDefs, str newName, TModel tm, Renamer r) {
168168
if (any(role <- fieldDefs.idRole, !isFieldRole(role)) || {} := fieldDefs) fail renameAdditionalUses;
169169

170-
loc mloc = getModuleScopes(tm)[tm.modelName].top;
171-
Tree tr = r.getConfig().parseLoc(mloc);
170+
Tree tr = r.getConfig().parseLoc(getModuleFile(tm));
172171
visit (tr) {
173172
case (Expression) `<Expression e> has <Name n>`: {
174173
eFieldDefs = getFieldDefinitions(e, "<n>", tm, r.getConfig().tmodelForLoc);

rascal-lsp/src/main/rascal/lsp/lang/rascal/lsp/refactor/rename/Parameters.rsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ tuple[set[loc], set[loc], set[loc]] findOccurrenceFilesUnchecked(set[Define] _:{
5151
TModel augmentFormalUses(Tree tr, TModel tm, TModel(loc) getModel) {
5252
rel[loc funcDef, str kwName, loc kwLoc] keywordFormalDefs = {
5353
*(fileTm.defines<idRole, scope, id, defined>)[keywordFormalId()]
54-
| loc f <- getModuleFile(tm) + (tm.paths<to>)
54+
| loc f <- tr.src + (tm.paths<to>)
5555
, fileTm := getModel(f.top)
5656
};
5757
visit (tr) {

0 commit comments

Comments
 (0)