Skip to content

Commit 3678694

Browse files
committed
make quiet more quiet
1 parent 842a8af commit 3678694

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.peeeq.wurstscript.gui;
22

33
import de.peeeq.wurstscript.attributes.CompileError;
4+
import de.peeeq.wurstscript.attributes.CompileError.ErrorType;
45

56
/**
67
* implementation for use with cli interfaces
@@ -19,9 +20,27 @@ public WurstGuiCliImpl(boolean compactOutput) {
1920

2021
@Override
2122
public void sendError(CompileError err) {
23+
if (compactOutput && isGeneratedJassNameResolutionWarning(err)) {
24+
return;
25+
}
2226
super.sendError(err);
2327
}
2428

29+
private boolean isGeneratedJassNameResolutionWarning(CompileError err) {
30+
if (err.getErrorType() != ErrorType.WARNING) {
31+
return false;
32+
}
33+
String message = err.getMessage();
34+
if (!message.contains("Could not find variable") && !message.contains("Could not find a function")) {
35+
return false;
36+
}
37+
String source = err.getSource().getFile().replace('\\', '/').toLowerCase();
38+
return source.endsWith("war3map.j")
39+
|| source.endsWith("output.j")
40+
|| source.contains("/_build/")
41+
|| source.startsWith("_build/");
42+
}
43+
2544
@Override
2645
public void sendProgress(String msg) {
2746
}

de.peeeq.wurstscript/src/test/java/tests/wurstscript/utils/UtilsTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import de.peeeq.wurstscript.utils.Utils;
66
import de.peeeq.wurstscript.RunArgs;
77
import de.peeeq.wurstscript.attributes.CompileError;
8+
import de.peeeq.wurstscript.attributes.CompileError.ErrorType;
9+
import de.peeeq.wurstscript.gui.WurstGuiCliImpl;
810
import de.peeeq.wurstscript.parser.WPos;
911
import org.testng.Assert;
1012
import org.testng.annotations.Test;
@@ -33,6 +35,22 @@ public void compactCompileErrorIsSingleLine() {
3335
Assert.assertTrue(error.toCompactString().contains("first line second line"));
3436
}
3537

38+
@Test
39+
public void compactCliSuppressesGeneratedJassNameResolutionWarnings() {
40+
CompileError generatedWarning = new CompileError(
41+
new WPos("C:/project/_build/grill/war3map.j", null, 0, 0),
42+
"Error: e:Could not find variable silverGladeCounter.",
43+
ErrorType.WARNING);
44+
45+
WurstGuiCliImpl compactGui = new WurstGuiCliImpl(true);
46+
compactGui.sendError(generatedWarning);
47+
Assert.assertTrue(compactGui.getWarningList().isEmpty());
48+
49+
WurstGuiCliImpl regularGui = new WurstGuiCliImpl(false);
50+
regularGui.sendError(generatedWarning);
51+
Assert.assertEquals(regularGui.getWarningList().size(), 1);
52+
}
53+
3654
@Test
3755
public void array() {
3856
int[] ar1 = {1, 2, 3};

0 commit comments

Comments
 (0)