Skip to content

Commit 80fac65

Browse files
committed
Improve handling of ignored modules.
1 parent 4cd2920 commit 80fac65

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,14 @@ TModel tmodelForTree(Tree t, PathConfig(loc) getPathConfig) {
257257
ms = rascalTModelForNames([mname], ccfg, dummy_compile1);
258258
259259
<found, tm, ms> = getTModelForModule(mname, ms);
260-
if (!found) throw ms.messages;
260+
if (!found) {
261+
if (ms.status[mname]?) {
262+
// If a module is annotated with `@ignoreCompiler`, silently skip it
263+
if (ignored() in ms.status[mname]) return tmodel();
264+
throw "No TModel for module \'<mname>\' - status <ms.status[mname]>";
265+
}
266+
throw "No TModel for module \'<mname>\' - unknown status.";
267+
}
261268
return augmentTModel(t, tm, TModel(loc f) {
262269
// Prevent endless recursion
263270
if (f == l) return tm;

rascal-lsp/src/main/rascal/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/lang/rascal/tests/rename/TestUtils.rsc

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

5757

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

6262
data RenameException
@@ -131,7 +131,7 @@ bool testRenameOccurrences(set[TestModule] modules, str oldName = "foo", str new
131131
}
132132
133133
pcfg = getTestPathConfig(testDir);
134-
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))};
134+
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))};
135135
136136
for (m <- modulesByLocation) {
137137
try {
@@ -384,9 +384,9 @@ private tuple[loc, list[Tree]] findCursor(loc f, str id, int occ) {
384384
return <cl, computeFocusList(m, cl.begin.line, cl.begin.column + 1)>;
385385
}
386386
387-
private loc storeTestModule(loc dir, str name, str body) {
387+
private loc storeTestModule(loc dir, str name, str body, str annotations = "") {
388388
str moduleStr = "
389-
'module <name>
389+
'<annotations> module <name>
390390
'<body>
391391
";
392392

0 commit comments

Comments
 (0)