Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #825 - Showing wrong errors' line numbers for .java files #937

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions java/src/processing/mode/java/ErrorChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,29 @@ static private boolean isIgnorableProblem(IProblem iproblem) {


static private JavaProblem convertIProblem(IProblem iproblem, PreprocSketch ps) {
SketchInterval in = ps.mapJavaToSketch(iproblem);
if (in != SketchInterval.BEFORE_START) {
String badCode = ps.getPdeCode(in);
int line = ps.tabOffsetToTabLine(in.tabIndex, in.startTabOffset);
JavaProblem p = JavaProblem.fromIProblem(iproblem, in.tabIndex, line, badCode);
String originalFileName = new String(iproblem.getOriginatingFileName());
boolean isJavaTab = ps.isJavaTab(originalFileName);

// Java tabs' content isn't stored in a sketch's combined source code file,
// so they are processed differently
if (!isJavaTab) {
SketchInterval in = ps.mapJavaToSketch(iproblem);
if (in != SketchInterval.BEFORE_START) {
String badCode = ps.getPdeCode(in);
int line = ps.tabOffsetToTabLine(in.tabIndex, in.startTabOffset);
JavaProblem p = JavaProblem.fromIProblem(iproblem, in.tabIndex, line, badCode);
p.setPDEOffsets(0, -1);
return p;
}
} else {
int tabIndex = ps.getJavaTabIndex(originalFileName);
int line = iproblem.getSourceLineNumber() - 1;

JavaProblem p = JavaProblem.fromIProblem(iproblem, tabIndex, line, "");
p.setPDEOffsets(0, -1);
return p;
}

return null;
}

Expand Down
10 changes: 10 additions & 0 deletions java/src/processing/mode/java/PreprocSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public SketchInterval mapJavaToSketch(ASTNode node) {
}


public boolean isJavaTab(String fileName) {
return javaFileMapping.containsKey(fileName);
}


public int getJavaTabIndex(String fileName) {
return javaFileMapping.get(fileName);
}


public SketchInterval mapJavaToSketch(IProblem iproblem) {
String originalFile = new String(iproblem.getOriginatingFileName());
boolean isJavaTab = javaFileMapping.containsKey(originalFile);
Expand Down
Loading