Skip to content

Commit ec9282e

Browse files
committed
Add friendlier error message for HidingEnclosingType
1 parent 76fef4b commit ec9282e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

build/shared/lib/languages/PDE.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ editor.status.type_mismatch = Type mismatch, "%s" does not match with "%s"
370370
editor.status.unused_variable = The value of the local variable "%s" is not used
371371
editor.status.uninitialized_variable = The local variable "%s" may not have been initialized
372372
editor.status.no_effect_assignment = The assignment to variable "%s" has no effect
373+
editor.status.hiding_enclosing_type = The class "%s" cannot have the same name as the name of your sketch
373374

374375
# Footer buttons
375376
editor.footer.errors = Errors

java/src/processing/mode/java/pdex/ErrorMessageSimplifier.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ public static String getSimplifiedErrorMessage(Problem problem) {
254254
result = Language.interpolate("editor.status.no_effect_assignment", args[0]);
255255
}
256256
break;
257+
258+
case IProblem.HidingEnclosingType:
259+
if (args.length > 0 && args[0].equals(problem.getClassName())) {
260+
result = Language.interpolate("editor.status.hiding_enclosing_type", args[0]);
261+
}
257262
}
258263

259264
//log("Simplified Error Msg: " + result);

java/src/processing/mode/java/pdex/Problem.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public class Problem implements ErrorTable.Entry {
3737
* The IProblem which is being wrapped
3838
*/
3939
private IProblem iProblem;
40+
/**
41+
* The class name for the current sketch
42+
*/
43+
private String className;
4044
/**
4145
* The tab number to which the error belongs to
4246
*/
@@ -83,6 +87,7 @@ else if(iProblem.isWarning()) {
8387
}
8488
this.tabIndex = tabIndex;
8589
this.lineNumber = lineNumber;
90+
this.className = iProblem.getArguments()[0];
8691
this.message = process(iProblem);
8792
this.message = ErrorMessageSimplifier.getSimplifiedErrorMessage(this);
8893
//ErrorMessageSimplifier.getSimplifiedErrorMessage(this);
@@ -123,6 +128,10 @@ public IProblem getIProblem() {
123128
return iProblem;
124129
}
125130

131+
public String getClassName() {
132+
return className;
133+
}
134+
126135
public int getTabIndex() {
127136
return tabIndex;
128137
}

0 commit comments

Comments
 (0)