[scala] Fix compile errors and tests
This commit is contained in:
parent
346e67b3f0
commit
f9ca35bcd5
@ -11,23 +11,23 @@ import scala.meta.tokens.Token;
|
||||
/**
|
||||
* Adapts the scala.meta.tokens.Token so that it can be used with the generic BaseTokenFilter
|
||||
*/
|
||||
public class ScalaTokenAdapter implements GenericToken {
|
||||
public class ScalaTokenAdapter implements GenericToken<ScalaTokenAdapter> {
|
||||
|
||||
private Token token;
|
||||
private GenericToken previousComment;
|
||||
private ScalaTokenAdapter previousComment;
|
||||
|
||||
ScalaTokenAdapter(Token token, GenericToken comment) {
|
||||
ScalaTokenAdapter(Token token, ScalaTokenAdapter comment) {
|
||||
this.token = token;
|
||||
this.previousComment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericToken getNext() {
|
||||
public ScalaTokenAdapter getNext() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericToken getPreviousComment() {
|
||||
public ScalaTokenAdapter getPreviousComment() {
|
||||
return previousComment;
|
||||
}
|
||||
|
||||
@ -56,6 +56,11 @@ public class ScalaTokenAdapter implements GenericToken {
|
||||
return token.pos().endColumn() + 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEof() {
|
||||
return token instanceof Token.EOF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScalaTokenAdapter{"
|
||||
|
@ -13,7 +13,6 @@ import net.sourceforge.pmd.cpd.token.internal.BaseTokenFilter;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.TokenManager;
|
||||
import net.sourceforge.pmd.lang.ast.GenericToken;
|
||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
||||
import net.sourceforge.pmd.lang.scala.ScalaLanguageHandler;
|
||||
import net.sourceforge.pmd.lang.scala.ScalaLanguageModule;
|
||||
@ -80,7 +79,7 @@ public class ScalaTokenizer implements Tokenizer {
|
||||
ScalaTokenManager scalaTokenManager = new ScalaTokenManager(tokens.iterator());
|
||||
ScalaTokenFilter filter = new ScalaTokenFilter(scalaTokenManager);
|
||||
|
||||
GenericToken token;
|
||||
ScalaTokenAdapter token;
|
||||
while ((token = filter.getNextToken()) != null) {
|
||||
if (StringUtils.isEmpty(token.getImage())) {
|
||||
continue;
|
||||
@ -113,20 +112,20 @@ public class ScalaTokenizer implements Tokenizer {
|
||||
*
|
||||
* Keeps track of comments, for special comment processing
|
||||
*/
|
||||
private static class ScalaTokenManager implements TokenManager {
|
||||
private static class ScalaTokenManager implements TokenManager<ScalaTokenAdapter> {
|
||||
|
||||
Iterator<Token> tokenIter;
|
||||
Class<?>[] skippableTokens = new Class<?>[] { Token.Space.class, Token.Tab.class, Token.CR.class,
|
||||
Token.LF.class, Token.FF.class, Token.LFLF.class, Token.EOF.class, Token.Comment.class };
|
||||
|
||||
GenericToken previousComment = null;
|
||||
ScalaTokenAdapter previousComment = null;
|
||||
|
||||
ScalaTokenManager(Iterator<Token> iterator) {
|
||||
this.tokenIter = iterator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericToken getNextToken() {
|
||||
public ScalaTokenAdapter getNextToken() {
|
||||
if (!tokenIter.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
@ -155,15 +154,10 @@ public class ScalaTokenizer implements Tokenizer {
|
||||
private boolean isComment(Token token) {
|
||||
return token instanceof Token.Comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileName(String fileName) {
|
||||
throw new UnsupportedOperationException("setFileName deprecated");
|
||||
}
|
||||
}
|
||||
|
||||
private static class ScalaTokenFilter extends BaseTokenFilter<ScalaTokenAdapter> {
|
||||
ScalaTokenFilter(TokenManager tokenManager) {
|
||||
ScalaTokenFilter(TokenManager<ScalaTokenAdapter> tokenManager) {
|
||||
super(tokenManager);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,6 @@ L48
|
||||
[threadPoolSize] 17 32
|
||||
[=] 32 34
|
||||
[16] 34 37
|
||||
[// issue 194] 37 50
|
||||
L50
|
||||
[@] 3 5
|
||||
[volatile] 4 13
|
||||
|
Loading…
x
Reference in New Issue
Block a user