forked from phoedos/pmd
Fix groovy columns
This commit is contained in:
@ -6,6 +6,7 @@ package net.sourceforge.pmd.cpd;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.codehaus.groovy.antlr.SourceInfo;
|
||||
import org.codehaus.groovy.antlr.parser.GroovyLexer;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
||||
@ -31,8 +32,16 @@ public class GroovyTokenizer implements Tokenizer {
|
||||
|
||||
while (token.getType() != Token.EOF_TYPE) {
|
||||
String tokenText = token.getText();
|
||||
TokenEntry tokenEntry = new TokenEntry(tokenText, sourceCode.getFileName(), token.getLine(),
|
||||
token.getColumn(), tokenText.length());
|
||||
|
||||
|
||||
int lastCol;
|
||||
if (token instanceof SourceInfo) {
|
||||
lastCol = ((SourceInfo) token).getColumnLast();
|
||||
} else {
|
||||
// fallback
|
||||
lastCol = token.getColumn() + tokenText.length();
|
||||
}
|
||||
TokenEntry tokenEntry = new TokenEntry(tokenText, sourceCode.getFileName(), token.getLine(), token.getColumn(), lastCol);
|
||||
|
||||
tokenEntries.add(tokenEntry);
|
||||
token = tokenStream.nextToken();
|
||||
|
@ -87,7 +87,7 @@ public class ScalaTokenizer implements Tokenizer {
|
||||
pos.endColumn() + 1);
|
||||
tokenEntries.add(cpdToken);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (@SuppressWarnings("PMD.AvoidInstanceofChecksInCatchClause") Exception e) {
|
||||
if (e instanceof TokenizeException) {
|
||||
// cannot catch it as it's a checked exception and Scala sneaky throws
|
||||
TokenizeException tokE = (TokenizeException) e;
|
||||
|
Reference in New Issue
Block a user