pmd-swift: checkstyle / formatting

This commit is contained in:
Andreas Dangel 2016-12-02 14:36:22 +01:00
parent 4d94b71ffe
commit fbb262d380
5 changed files with 25 additions and 25 deletions

View File

@ -1,9 +1,8 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import net.sourceforge.pmd.cpd.SwiftTokenizer;
package net.sourceforge.pmd.cpd;
/**
* Language implementation for Swift

View File

@ -1,10 +1,8 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
import net.sourceforge.pmd.lang.swift.antlr4.SwiftLexer;
package net.sourceforge.pmd.cpd;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.BaseErrorListener;
@ -13,6 +11,9 @@ import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.Token;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
import net.sourceforge.pmd.lang.swift.antlr4.SwiftLexer;
/**
* The Swift Tokenizer
*/
@ -32,19 +33,19 @@ public class SwiftTokenizer implements Tokenizer {
while (token.getType() != Token.EOF) {
if (token.getChannel() != Lexer.HIDDEN) {
TokenEntry tokenEntry =
new TokenEntry(token.getText(), sourceCode.getFileName(), token.getLine());
TokenEntry tokenEntry = new TokenEntry(token.getText(), sourceCode.getFileName(), token.getLine());
tokenEntries.add(tokenEntry);
}
token = lexer.nextToken();
}
} catch (ANTLRSyntaxError err) {
// Wrap exceptions of the Swift tokenizer in a TokenMgrError, so they are correctly handled
// when CPD is executed with the '--skipLexicalErrors' command line option
throw new TokenMgrError(
"Lexical error in file " + sourceCode.getFileName() + " at line " +
err.getLine() + ", column " + err.getColumn() + ". Encountered: " + err.getMessage(),
// Wrap exceptions of the Swift tokenizer in a TokenMgrError, so
// they are correctly handled
// when CPD is executed with the '--skipLexicalErrors' command line
// option
throw new TokenMgrError("Lexical error in file " + sourceCode.getFileName() + " at line " + err.getLine()
+ ", column " + err.getColumn() + ". Encountered: " + err.getMessage(),
TokenMgrError.LEXICAL_ERROR);
} finally {
tokenEntries.add(TokenEntry.getEOF());
@ -53,8 +54,8 @@ public class SwiftTokenizer implements Tokenizer {
private static class ErrorHandler extends BaseErrorListener {
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
int charPositionInLine, String msg, RecognitionException ex) {
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
String msg, RecognitionException ex) {
throw new ANTLRSyntaxError(msg, line, charPositionInLine, ex);
}
}
@ -64,7 +65,7 @@ public class SwiftTokenizer implements Tokenizer {
private final int line;
private final int column;
public ANTLRSyntaxError (String msg, int line, int column, RecognitionException cause) {
ANTLRSyntaxError(String msg, int line, int column, RecognitionException cause) {
super(msg, cause);
this.line = line;
this.column = column;

View File

@ -1,6 +1,7 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.swift;
import net.sourceforge.pmd.lang.BaseLanguageModule;

View File

@ -1,17 +1,18 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd;
import java.util.Arrays;
import java.util.Collection;
import org.junit.runners.Parameterized.Parameters;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.swift.SwiftLanguageModule;
import org.junit.runners.Parameterized.Parameters;
public class LanguageVersionTest extends AbstractLanguageVersionTest {
public LanguageVersionTest(String name, String terseName, String version, LanguageVersion expected) {
@ -20,8 +21,7 @@ public class LanguageVersionTest extends AbstractLanguageVersionTest {
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ SwiftLanguageModule.NAME, SwiftLanguageModule.TERSE_NAME, "", LanguageRegistry.getLanguage(SwiftLanguageModule.NAME).getDefaultVersion() }
});
return Arrays.asList(new Object[][] { { SwiftLanguageModule.NAME, SwiftLanguageModule.TERSE_NAME, "",
LanguageRegistry.getLanguage(SwiftLanguageModule.NAME).getDefaultVersion(), }, });
}
}

View File

@ -1,16 +1,16 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.io.IOException;
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
public class SwiftTokenizerTest extends AbstractTokenizerTest {
@ -25,8 +25,8 @@ public class SwiftTokenizerTest extends AbstractTokenizerTest {
@Override
public String getSampleCode() throws IOException {
return IOUtils.toString(SwiftTokenizer.class.getResourceAsStream(FILENAME));
}
return IOUtils.toString(SwiftTokenizer.class.getResourceAsStream(FILENAME));
}
@Test
public void tokenizeTest() throws IOException {
@ -34,4 +34,3 @@ public class SwiftTokenizerTest extends AbstractTokenizerTest {
super.tokenizeTest();
}
}