[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) {
|
private void skipUsingDirectives(final AntlrToken currentToken, final Iterable<AntlrToken> remainingTokens) {
|
||||||
final int type = currentToken.getType();
|
if (ignoreUsings) {
|
||||||
if (type == CSharpLexer.USING && isUsingDirective(remainingTokens)) {
|
final int type = currentToken.getType();
|
||||||
discardingUsings = true;
|
if (type == CSharpLexer.USING && isUsingDirective(remainingTokens)) {
|
||||||
} else if (type == CSharpLexer.SEMICOLON) {
|
discardingUsings = true;
|
||||||
discardingUsings = false;
|
} else if (type == CSharpLexer.SEMICOLON) {
|
||||||
|
discardingUsings = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +116,14 @@ public class CsTokenizerTest {
|
|||||||
assertEquals(8, tokens.getTokens().get(14).getBeginLine());
|
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
|
@Test
|
||||||
public void testIgnoreUsingDirectives() {
|
public void testIgnoreUsingDirectives() {
|
||||||
tokenizer.setIgnoreUsings(true);
|
tokenizer.setIgnoreUsings(true);
|
||||||
|
Reference in New Issue
Block a user