pmd-jsp: checkstyle / formatting

This commit is contained in:
Andreas Dangel
2016-12-02 14:03:21 +01:00
parent 6370b13f01
commit e3fd103aeb
54 changed files with 1252 additions and 1362 deletions

View File

@@ -1,10 +1,11 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
public class JSPLanguage extends AbstractLanguage {
public JSPLanguage() {
super("JSP", "jsp", new JSPTokenizer(), ".jsp", ".jspx");
}
public JSPLanguage() {
super("JSP", "jsp", new JSPTokenizer(), ".jsp", ".jspx");
}
}

View File

@@ -1,6 +1,7 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.io.Reader;
@@ -17,27 +18,27 @@ import net.sourceforge.pmd.util.IOUtil;
public class JSPTokenizer implements Tokenizer {
public void tokenize(SourceCode sourceCode, Tokens tokenEntries) {
StringBuilder buffer = sourceCode.getCodeBuffer();
LanguageVersionHandler languageVersionHandler =
LanguageRegistry.getLanguage(JspLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler();
Reader reader = null;
public void tokenize(SourceCode sourceCode, Tokens tokenEntries) {
StringBuilder buffer = sourceCode.getCodeBuffer();
LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(JspLanguageModule.NAME)
.getDefaultVersion().getLanguageVersionHandler();
Reader reader = null;
try {
reader = new StringReader(buffer.toString());
reader = IOUtil.skipBOM(reader);
TokenManager tokenMgr = languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions())
.getTokenManager(sourceCode.getFileName(), reader);
Token currentToken = (Token) tokenMgr.getNextToken();
try {
reader = new StringReader(buffer.toString());
reader = IOUtil.skipBOM(reader);
TokenManager tokenMgr = languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions())
.getTokenManager(sourceCode.getFileName(), reader);
Token currentToken = (Token) tokenMgr.getNextToken();
while (currentToken.image.length() > 0) {
tokenEntries.add(new TokenEntry(String.valueOf(currentToken.kind), sourceCode.getFileName(),
currentToken.beginLine));
currentToken = (Token) tokenMgr.getNextToken();
}
} finally {
IOUtils.closeQuietly(reader);
}
tokenEntries.add(TokenEntry.getEOF());
}
while (currentToken.image.length() > 0) {
tokenEntries.add(new TokenEntry(String.valueOf(currentToken.kind), sourceCode.getFileName(),
currentToken.beginLine));
currentToken = (Token) tokenMgr.getNextToken();
}
} finally {
IOUtils.closeQuietly(reader);
}
tokenEntries.add(TokenEntry.getEOF());
}
}

View File

@@ -1,11 +1,11 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp;
import java.io.Writer;
import net.sf.saxon.sxpath.IndependentContext;
import net.sourceforge.pmd.lang.AbstractLanguageVersionHandler;
import net.sourceforge.pmd.lang.Parser;
import net.sourceforge.pmd.lang.ParserOptions;
@@ -18,6 +18,8 @@ import net.sourceforge.pmd.lang.jsp.ast.JspNode;
import net.sourceforge.pmd.lang.jsp.rule.JspRuleViolationFactory;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
import net.sf.saxon.sxpath.IndependentContext;
/**
* Implementation of LanguageVersionHandler for the JSP parser.
*

View File

@@ -1,3 +1,4 @@
package net.sourceforge.pmd.lang.jsp;
import net.sourceforge.pmd.lang.BaseLanguageModule;

View File

@@ -1,6 +1,7 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp;
import java.io.Reader;
@@ -21,24 +22,24 @@ import net.sourceforge.pmd.lang.ast.SimpleCharStream;
public class JspParser extends AbstractParser {
public JspParser(ParserOptions parserOptions) {
super(parserOptions);
super(parserOptions);
}
@Override
public TokenManager createTokenManager(Reader source) {
return new JspTokenManager(source);
return new JspTokenManager(source);
}
public boolean canParse() {
return true;
return true;
}
public Node parse(String fileName, Reader source) throws ParseException {
AbstractTokenManager.setFileName(fileName);
return new net.sourceforge.pmd.lang.jsp.ast.JspParser(new SimpleCharStream(source)).CompilationUnit();
AbstractTokenManager.setFileName(fileName);
return new net.sourceforge.pmd.lang.jsp.ast.JspParser(new SimpleCharStream(source)).CompilationUnit();
}
public Map<Integer, String> getSuppressMap() {
return new HashMap<>(); // FIXME
return new HashMap<>(); // FIXME
}
}

View File

@@ -1,6 +1,7 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.jsp;
import java.io.Reader;
@@ -16,11 +17,11 @@ public class JspTokenManager implements TokenManager {
private final JspParserTokenManager tokenManager;
public JspTokenManager(Reader source) {
tokenManager = new JspParserTokenManager(new JavaCharStream(source));
tokenManager = new JspParserTokenManager(new JavaCharStream(source));
}
public Object getNextToken() {
return tokenManager.getNextToken();
return tokenManager.getNextToken();
}
public void setFileName(String fileName) {

View File

@@ -16,7 +16,7 @@ public class ASTAttribute extends AbstractJspNode {
public ASTAttribute(JspParser p, int id) {
super(p, id);
}
/**
* @return Returns the name.
*/
@@ -25,38 +25,38 @@ public class ASTAttribute extends AbstractJspNode {
}
/**
* @param name The name to set.
* @param name
* The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return boolean - true if the element has a namespace-prefix, false otherwise
* @return boolean - true if the element has a namespace-prefix, false
* otherwise
*/
public boolean isHasNamespacePrefix() {
return name.indexOf(':') >= 0;
}
/**
* @return String - the part of the name that is before the (first) colon (":")
* @return String - the part of the name that is before the (first) colon
* (":")
*/
public String getNamespacePrefix() {
int colonIndex = name.indexOf(':');
return colonIndex >= 0
? name.substring(0, colonIndex)
: "";
return colonIndex >= 0 ? name.substring(0, colonIndex) : "";
}
/**
* @return String - The part of the name that is after the first colon (":").
* If the name does not contain a colon, the full name is returned.
* @return String - The part of the name that is after the first colon
* (":"). If the name does not contain a colon, the full name is
* returned.
*/
public String getLocalName() {
int colonIndex = name.indexOf(':');
return colonIndex >= 0
? name.substring(colonIndex + 1)
: name;
return colonIndex >= 0 ? name.substring(colonIndex + 1) : name;
}
/**

View File

@@ -14,7 +14,6 @@ public class ASTAttributeValue extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTCData extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTCommentTag extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -16,7 +16,6 @@ public class ASTCompilationUnit extends AbstractJspNode implements RootNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTContent extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -25,7 +25,8 @@ public class ASTDeclaration extends AbstractJspNode {
}
/**
* @param name The name to set.
* @param name
* The name to set.
*/
public void setName(String name) {
this.name = name;

View File

@@ -28,7 +28,8 @@ public class ASTDoctypeDeclaration extends AbstractJspNode {
}
/**
* @param name The name to set.
* @param name
* The name to set.
*/
public void setName(String name) {
this.name = name;

View File

@@ -37,22 +37,24 @@ public class ASTDoctypeExternalId extends AbstractJspNode {
}
/**
* @param name The name to set.
* @param name
* The name to set.
*/
public void setUri(String name) {
this.uri = name;
}
/**
* @return Returns the publicId (or an empty string if there is none
* for this external entity id).
* @return Returns the publicId (or an empty string if there is none for
* this external entity id).
*/
public String getPublicId() {
return null == publicId ? "" : publicId;
}
/**
* @param publicId The publicId to set.
* @param publicId
* The publicId to set.
*/
public void setPublicId(String publicId) {
this.publicId = publicId;

View File

@@ -14,7 +14,6 @@ public class ASTElExpression extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -16,10 +16,10 @@ public class ASTElement extends AbstractJspNode {
* Flag indicating that the element consists of one tag ("<... />").
*/
private boolean empty; //
/**
* Flag indicating that the parser did not find a proper ending marker
* or ending tag for this element
* Flag indicating that the parser did not find a proper ending marker or
* ending tag for this element
*/
private boolean unclosed;
@@ -31,32 +31,31 @@ public class ASTElement extends AbstractJspNode {
super(p, id);
}
/**
* @return boolean - true if the element has a namespace-prefix, false otherwise
/**
* @return boolean - true if the element has a namespace-prefix, false
* otherwise
*/
public boolean isHasNamespacePrefix() {
return name.indexOf(':') >= 0;
}
/**
* @return String - the part of the name that is before the (first) colon (":")
* @return String - the part of the name that is before the (first) colon
* (":")
*/
public String getNamespacePrefix() {
int colonIndex = name.indexOf(':');
return colonIndex >= 0
? name.substring(0, colonIndex)
: "";
return colonIndex >= 0 ? name.substring(0, colonIndex) : "";
}
/**
* @return String - The part of the name that is after the first colon (":").
* If the name does not contain a colon, the full name is returned.
* @return String - The part of the name that is after the first colon
* (":"). If the name does not contain a colon, the full name is
* returned.
*/
public String getLocalName() {
int colonIndex = name.indexOf(':');
return colonIndex >= 0
? name.substring(colonIndex + 1)
: name;
return colonIndex >= 0 ? name.substring(colonIndex + 1) : name;
}
/**
@@ -67,7 +66,8 @@ public class ASTElement extends AbstractJspNode {
}
/**
* @param name The name to set.
* @param name
* The name to set.
*/
public void setName(String name) {
this.name = name;
@@ -81,15 +81,16 @@ public class ASTElement extends AbstractJspNode {
}
public boolean isUnclosed() {
return unclosed;
}
return unclosed;
}
public void setUnclosed(boolean unclosed) {
this.unclosed = unclosed;
}
public void setUnclosed(boolean unclosed) {
this.unclosed = unclosed;
}
/**
* @param empty The empty to set.
* @param empty
* The empty to set.
*/
public void setEmpty(boolean empty) {
this.empty = empty;

View File

@@ -3,20 +3,21 @@
*/
/* Generated By:JJTree: Do not edit this line. ASTHtmlScript.java Version 4.1 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY= */
package net.sourceforge.pmd.lang.jsp.ast;
public class ASTHtmlScript extends AbstractJspNode {
public ASTHtmlScript(int id) {
super(id);
super(id);
}
public ASTHtmlScript(JspParser p, int id) {
super(p, id);
super(p, id);
}
/** Accept the visitor. **/
@Override
public Object jjtAccept(JspParserVisitor visitor, Object data) {
return visitor.visit(this, data);
return visitor.visit(this, data);
}
}

View File

@@ -14,7 +14,6 @@ public class ASTJspComment extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTJspDeclaration extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTJspDeclarations extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -28,7 +28,8 @@ public class ASTJspDirective extends AbstractJspNode {
}
/**
* @param name The name to set.
* @param name
* The name to set.
*/
public void setName(String name) {
this.name = name;

View File

@@ -26,7 +26,8 @@ public class ASTJspDirectiveAttribute extends AbstractJspNode {
}
/**
* @param name The name to set.
* @param name
* The name to set.
*/
public void setName(String name) {
this.name = name;
@@ -40,7 +41,8 @@ public class ASTJspDirectiveAttribute extends AbstractJspNode {
}
/**
* @param value The value to set.
* @param value
* The value to set.
*/
public void setValue(String value) {
this.value = value;

View File

@@ -14,7 +14,6 @@ public class ASTJspDocument extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTJspExpression extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTJspExpressionInAttribute extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTJspScriptlet extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTText extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTUnparsedText extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

View File

@@ -14,7 +14,6 @@ public class ASTValueBinding extends AbstractJspNode {
super(p, id);
}
/**
* Accept the visitor. *
*/

Some files were not shown because too many files have changed in this diff Show More