Skip to content

Commit 9bd9f05

Browse files
committed
Improve handling of ignored modules.
1 parent 8401109 commit 9bd9f05

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,14 @@ public Edits rascalRenameSymbol(loc cursorLoc, list[Tree] cursor, str newName, s
227227
ms = rascalTModelForNames([mname], ccfg, dummy_compile1);
228228
229229
<found, tm, ms> = getTModelForModule(mname, ms);
230-
if (!found) throw "No TModel for module \'<mname>\'";
230+
if (!found) {
231+
if (ms.status[mname]?) {
232+
// If a module is annotated with `@ignoreCompiler`, silently skip it
233+
if (MStatus::ignored() in ms.status[mname]) return tmodel();
234+
throw "No TModel for module \'<mname>\'";
235+
}
236+
throw "No TModel for module \'<mname>\'";
237+
}
231238
return tm;
232239
}
233240

rascal-lsp/src/main/rascal/lsp/lang/rascal/tests/rename/Performance.rsc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,10 @@ test bool incrementalTypeCheck() {
7777
remove(procLoc);
7878
return res;
7979
}
80+
81+
test bool ignoredModule() = testRenameOccurrences({
82+
byText("Ignored", "
83+
'import Main;
84+
'int quz() = foo();", {}, annotations = "@ignoreCompiler{For test purposes.}"),
85+
byText("Main", "int foo() = 8;", {0})
86+
});

rascal-lsp/src/main/rascal/lsp/lang/rascal/tests/rename/TestUtils.rsc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import util::Util;
5757

5858

5959
//// Fixtures and utility functions
60-
data TestModule = byText(str name, str body, set[int] nameOccs, str newName = name, set[int] skipCursors = {})
60+
data TestModule = byText(str name, str body, set[int] nameOccs, str newName = name, set[int] skipCursors = {}, str annotations = "")
6161
| byLoc(str name, loc file, set[int] nameOccs, str newName = name, set[int] skipCursors = {});
6262

6363
data RenameException
@@ -134,7 +134,7 @@ bool testRenameOccurrences(set[TestModule] modules, str oldName = "foo", str new
134134
}
135135
136136
pcfg = getTestPathConfig(testDir);
137-
modulesByLocation = {mByLoc | m <- modules, mByLoc := (m is byLoc ? m : byLoc(m.name, storeTestModule(testDir, m.name, m.body), m.nameOccs, newName = m.newName, skipCursors = m.skipCursors))};
137+
modulesByLocation = {mByLoc | m <- modules, mByLoc := (m is byLoc ? m : byLoc(m.name, storeTestModule(testDir, m.name, m.body, annotations = m.annotations), m.nameOccs, newName = m.newName, skipCursors = m.skipCursors))};
138138
139139
for (m <- modulesByLocation) {
140140
try {
@@ -391,9 +391,9 @@ private tuple[loc, list[Tree]] findCursor(loc f, str id, int occ) {
391391
return <cl, computeFocusList(m, cl.begin.line, cl.begin.column + 1)>;
392392
}
393393
394-
private loc storeTestModule(loc dir, str name, str body) {
394+
private loc storeTestModule(loc dir, str name, str body, str annotations = "") {
395395
str moduleStr = "
396-
'module <name>
396+
'<annotations> module <name>
397397
'<body>
398398
";
399399

0 commit comments

Comments
 (0)