Skip to content

Commit 213d72d

Browse files
committed
suppress warnings from dependencies
1 parent f71b504 commit 213d72d

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/gui/WurstGui.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,22 @@ public abstract class WurstGui {
2121
public abstract void showInfoMessage(String message);
2222

2323
public void sendError(CompileError err) {
24+
if (shouldSuppressWarning(err)) {
25+
return;
26+
}
2427
errors.add(err);
2528
}
2629

30+
private boolean shouldSuppressWarning(CompileError err) {
31+
if (err.getErrorType() != ErrorType.WARNING) {
32+
return false;
33+
}
34+
String file = err.getSource().getFile();
35+
String normalized = file.replace('\\', '/').toLowerCase();
36+
return normalized.contains("/_build/dependencies/")
37+
|| normalized.startsWith("_build/dependencies/");
38+
}
39+
2740
public void clearErrors() {
2841
errors.clear();
2942
}

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/BugTests.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,39 @@ public void classVarInitOrderShouldError_770() {
176176
"endpackage");
177177
}
178178

179+
@Test
180+
public void dependencyDiagnosticsAreMuted() {
181+
CompilationResult res = test()
182+
.setStopOnFirstError(false)
183+
.withCu(compilationUnit("_build/dependencies/dep/Dep.wurst",
184+
"package dep",
185+
"init",
186+
" if true",
187+
"endpackage"))
188+
.run();
189+
190+
Assert.assertTrue(res.getGui().getErrorList().isEmpty(), "Expected no errors.");
191+
Assert.assertTrue(res.getGui().getWarningList().isEmpty(),
192+
"Expected no warnings from _build/dependencies sources.");
193+
}
194+
195+
@Test
196+
public void projectDiagnosticsStayVisible() {
197+
CompilationResult res = test()
198+
.setStopOnFirstError(false)
199+
.withCu(compilationUnit("wurst/Local.wurst",
200+
"package local",
201+
"init",
202+
" if true",
203+
"endpackage"))
204+
.run();
205+
206+
Assert.assertTrue(res.getGui().getErrorList().isEmpty(), "Expected no errors.");
207+
Assert.assertTrue(res.getGui().getWarningList().stream()
208+
.anyMatch(w -> w.getMessage().contains("empty then-block")),
209+
"Expected warning for project sources.");
210+
}
211+
179212

180213
@Test
181214
public void test_for_from() {

0 commit comments

Comments
 (0)