forked from phoedos/pmd
Minor improvements
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.cpd.token;
|
||||
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.GenericToken;
|
||||
|
||||
/**
|
||||
* Generic Antlr representation of a token.
|
||||
*/
|
||||
public class AntlrToken implements GenericToken {
|
||||
|
||||
private final Token token;
|
||||
private final AntlrToken previousComment;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param token The antlr token implementation
|
||||
* @param previousComment The previous comment
|
||||
*/
|
||||
public AntlrToken(final Token token, final AntlrToken previousComment) {
|
||||
this.token = token;
|
||||
this.previousComment = previousComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericToken getNext() {
|
||||
// Antlr implementation does not require this
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericToken getPreviousComment() {
|
||||
return previousComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImage() {
|
||||
return token.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeginLine() {
|
||||
return token.getLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEndLine() {
|
||||
return token.getLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeginColumn() {
|
||||
return token.getCharPositionInLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEndColumn() {
|
||||
return token.getCharPositionInLine() + token.getStopIndex() - token.getStartIndex();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return token.getType();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return token.getChannel() == Lexer.HIDDEN;
|
||||
}
|
||||
}
|
@ -17,10 +17,10 @@ public class GoLanguageModule extends BaseLanguageModule {
|
||||
public static final String TERSE_NAME = "go";
|
||||
|
||||
/**
|
||||
* Create a new instance of Swift Language Module.
|
||||
* Create a new instance of Golang Language Module.
|
||||
*/
|
||||
public GoLanguageModule() {
|
||||
super(NAME, null, TERSE_NAME, null, "go");
|
||||
addVersion("", null, true);
|
||||
addVersion("1", null, true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user