[cs] CPD: Fixed CPD --ignore-usings option
This commit is contained in:
@ -75,11 +75,13 @@ public class CsTokenizer extends AntlrTokenizer {
|
||||
}
|
||||
|
||||
private void skipUsingDirectives(final AntlrToken currentToken, final Iterable<AntlrToken> remainingTokens) {
|
||||
final int type = currentToken.getType();
|
||||
if (type == CSharpLexer.USING && isUsingDirective(remainingTokens)) {
|
||||
discardingUsings = true;
|
||||
} else if (type == CSharpLexer.SEMICOLON) {
|
||||
discardingUsings = false;
|
||||
if (ignoreUsings) {
|
||||
final int type = currentToken.getType();
|
||||
if (type == CSharpLexer.USING && isUsingDirective(remainingTokens)) {
|
||||
discardingUsings = true;
|
||||
} else if (type == CSharpLexer.SEMICOLON) {
|
||||
discardingUsings = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,14 @@ public class CsTokenizerTest {
|
||||
assertEquals(8, tokens.getTokens().get(14).getBeginLine());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoNotIgnoreUsingDirectives() {
|
||||
tokenizer.setIgnoreUsings(false);
|
||||
tokenizer.tokenize(toSourceCode("using System.Text;\n"), tokens);
|
||||
assertEquals(6, tokens.size());
|
||||
assertEquals("using", tokens.getTokens().get(0).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreUsingDirectives() {
|
||||
tokenizer.setIgnoreUsings(true);
|
||||
|
Reference in New Issue
Block a user