-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added code for anonymous classes and guards in cases.
- Loading branch information
1 parent
80069f0
commit c8d5786
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
languages/java/src/main/java/de/jplag/java/FixedSourcePositions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package de.jplag.java; | ||
|
||
import com.sun.source.tree.CompilationUnitTree; | ||
import com.sun.source.tree.Tree; | ||
import com.sun.source.util.SourcePositions; | ||
|
||
/** | ||
* Fixes the source positions, so that the end position is always at least the same as the start position. | ||
*/ | ||
public class FixedSourcePositions implements SourcePositions { | ||
private final SourcePositions base; | ||
|
||
/** | ||
* New instance | ||
* @param base The source positions to use as the base | ||
*/ | ||
public FixedSourcePositions(SourcePositions base) { | ||
this.base = base; | ||
} | ||
|
||
@Override | ||
public long getStartPosition(CompilationUnitTree compilationUnitTree, Tree tree) { | ||
return this.base.getStartPosition(compilationUnitTree, tree); | ||
} | ||
|
||
@Override | ||
public long getEndPosition(CompilationUnitTree compilationUnitTree, Tree tree) { | ||
return Math.max(this.getStartPosition(compilationUnitTree, tree), this.base.getEndPosition(compilationUnitTree, tree)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters