pmd-javascript: checkstyle / formatting
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.cpd;
|
||||
|
||||
/**
|
||||
@ -8,7 +9,7 @@ package net.sourceforge.pmd.cpd;
|
||||
* @author Zev Blut zb@ubit.com
|
||||
*/
|
||||
public class EcmascriptLanguage extends AbstractLanguage {
|
||||
public EcmascriptLanguage() {
|
||||
super("JavaScript", "ecmascript", new EcmascriptTokenizer(), ".js");
|
||||
}
|
||||
public EcmascriptLanguage() {
|
||||
super("JavaScript", "ecmascript", new EcmascriptTokenizer(), ".js");
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.cpd;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersionHandler;
|
||||
import net.sourceforge.pmd.lang.TokenManager;
|
||||
@ -14,8 +17,6 @@ import net.sourceforge.pmd.lang.ecmascript.EcmascriptLanguageModule;
|
||||
import net.sourceforge.pmd.lang.ecmascript5.ast.Ecmascript5ParserConstants;
|
||||
import net.sourceforge.pmd.lang.ecmascript5.ast.Token;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
/**
|
||||
* The Ecmascript Tokenizer
|
||||
*/
|
||||
@ -29,11 +30,13 @@ public class EcmascriptTokenizer implements Tokenizer {
|
||||
LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(EcmascriptLanguageModule.NAME)
|
||||
.getDefaultVersion().getLanguageVersionHandler();
|
||||
reader = new StringReader(buffer.toString());
|
||||
TokenManager tokenManager = languageVersionHandler.getParser(
|
||||
languageVersionHandler.getDefaultParserOptions()).getTokenManager(sourceCode.getFileName(), reader);
|
||||
TokenManager tokenManager = languageVersionHandler
|
||||
.getParser(languageVersionHandler.getDefaultParserOptions())
|
||||
.getTokenManager(sourceCode.getFileName(), reader);
|
||||
Token currentToken = (Token) tokenManager.getNextToken();
|
||||
while (currentToken.image.length() > 0) {
|
||||
tokenEntries.add(new TokenEntry(getTokenImage(currentToken), sourceCode.getFileName(), currentToken.beginLine));
|
||||
tokenEntries.add(
|
||||
new TokenEntry(getTokenImage(currentToken), sourceCode.getFileName(), currentToken.beginLine));
|
||||
currentToken = (Token) tokenManager.getNextToken();
|
||||
}
|
||||
tokenEntries.add(TokenEntry.getEOF());
|
||||
@ -48,11 +51,11 @@ public class EcmascriptTokenizer implements Tokenizer {
|
||||
}
|
||||
|
||||
private String getTokenImage(Token token) {
|
||||
//Remove line continuation characters from string literals
|
||||
if (token.kind == Ecmascript5ParserConstants.STRING_LITERAL ||
|
||||
token.kind == Ecmascript5ParserConstants.UNTERMINATED_STRING_LITERAL) {
|
||||
// Remove line continuation characters from string literals
|
||||
if (token.kind == Ecmascript5ParserConstants.STRING_LITERAL
|
||||
|| token.kind == Ecmascript5ParserConstants.UNTERMINATED_STRING_LITERAL) {
|
||||
return token.image.replaceAll("(?<!\\\\)\\\\(\\r\\n|\\r|\\n)", "");
|
||||
}
|
||||
return token.image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript;
|
||||
|
||||
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.ecmascript.ast.EcmascriptNode;
|
||||
import net.sourceforge.pmd.lang.ecmascript.rule.EcmascriptRuleViolationFactory;
|
||||
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
|
||||
|
||||
import net.sf.saxon.sxpath.IndependentContext;
|
||||
|
||||
/**
|
||||
* Implementation of LanguageVersionHandler for the ECMAScript Version 3.
|
||||
*/
|
||||
@ -25,34 +27,34 @@ public class Ecmascript3Handler extends AbstractLanguageVersionHandler {
|
||||
|
||||
@Override
|
||||
public XPathHandler getXPathHandler() {
|
||||
return new AbstractASTXPathHandler() {
|
||||
public void initialize() {
|
||||
}
|
||||
return new AbstractASTXPathHandler() {
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
public void initialize(IndependentContext context) {
|
||||
}
|
||||
};
|
||||
public void initialize(IndependentContext context) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public RuleViolationFactory getRuleViolationFactory() {
|
||||
return EcmascriptRuleViolationFactory.INSTANCE;
|
||||
return EcmascriptRuleViolationFactory.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParserOptions getDefaultParserOptions() {
|
||||
return new EcmascriptParserOptions();
|
||||
return new EcmascriptParserOptions();
|
||||
}
|
||||
|
||||
public Parser getParser(ParserOptions parserOptions) {
|
||||
return new Ecmascript3Parser(parserOptions);
|
||||
return new Ecmascript3Parser(parserOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisitorStarter getDumpFacade(final Writer writer, final String prefix, final boolean recurse) {
|
||||
return new VisitorStarter() {
|
||||
public void start(Node rootNode) {
|
||||
new DumpFacade().initializeWith(writer, prefix, recurse, (EcmascriptNode<?>) rootNode);
|
||||
}
|
||||
};
|
||||
return new VisitorStarter() {
|
||||
public void start(Node rootNode) {
|
||||
new DumpFacade().initializeWith(writer, prefix, recurse, (EcmascriptNode<?>) rootNode);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript;
|
||||
|
||||
import java.io.Reader;
|
||||
@ -21,7 +22,8 @@ public class Ecmascript3Parser extends AbstractParser {
|
||||
|
||||
public Ecmascript3Parser(ParserOptions parserOptions) {
|
||||
super(parserOptions);
|
||||
ecmascriptParser = new net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParser((EcmascriptParserOptions)parserOptions);
|
||||
ecmascriptParser = new net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParser(
|
||||
(EcmascriptParserOptions) parserOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript;
|
||||
|
||||
import net.sourceforge.pmd.lang.BaseLanguageModule;
|
||||
|
@ -1,126 +1,129 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript;
|
||||
|
||||
import org.mozilla.javascript.Context;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.lang.ParserOptions;
|
||||
import net.sourceforge.pmd.lang.rule.properties.BooleanProperty;
|
||||
import net.sourceforge.pmd.lang.rule.properties.EnumeratedProperty;
|
||||
import net.sourceforge.pmd.util.StringUtil;
|
||||
|
||||
import org.mozilla.javascript.Context;
|
||||
|
||||
public class EcmascriptParserOptions extends ParserOptions {
|
||||
|
||||
public enum Version {
|
||||
VERSION_DEFAULT("default", Context.VERSION_DEFAULT),
|
||||
VERSION_1_0("1.0", Context.VERSION_1_0),
|
||||
VERSION_1_1("1.1", Context.VERSION_1_1),
|
||||
VERSION_1_2("1.2", Context.VERSION_1_2),
|
||||
VERSION_1_3("1.3", Context.VERSION_1_3),
|
||||
VERSION_1_4("1.4", Context.VERSION_1_4),
|
||||
VERSION_1_5("1.5", Context.VERSION_1_5),
|
||||
VERSION_1_6("1.6", Context.VERSION_1_6),
|
||||
VERSION_1_7("1.7", Context.VERSION_1_7),
|
||||
VERSION_1_8("1.8", Context.VERSION_1_8);
|
||||
VERSION_DEFAULT("default", Context.VERSION_DEFAULT),
|
||||
VERSION_1_0("1.0", Context.VERSION_1_0),
|
||||
VERSION_1_1("1.1", Context.VERSION_1_1),
|
||||
VERSION_1_2("1.2", Context.VERSION_1_2),
|
||||
VERSION_1_3("1.3", Context.VERSION_1_3),
|
||||
VERSION_1_4("1.4", Context.VERSION_1_4),
|
||||
VERSION_1_5("1.5", Context.VERSION_1_5),
|
||||
VERSION_1_6("1.6", Context.VERSION_1_6),
|
||||
VERSION_1_7("1.7", Context.VERSION_1_7),
|
||||
VERSION_1_8("1.8", Context.VERSION_1_8);
|
||||
|
||||
private final String name;
|
||||
private final int version;
|
||||
private final String name;
|
||||
private final int version;
|
||||
|
||||
private Version(String name, int version) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
}
|
||||
Version(String name, int version) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return name;
|
||||
}
|
||||
public String getLabel() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] VERSION_LABELS = new String[] { Version.VERSION_DEFAULT.getLabel(),
|
||||
Version.VERSION_1_0.getLabel(), Version.VERSION_1_1.getLabel(), Version.VERSION_1_2.getLabel(),
|
||||
Version.VERSION_1_3.getLabel(), Version.VERSION_1_4.getLabel(), Version.VERSION_1_5.getLabel(),
|
||||
Version.VERSION_1_6.getLabel(), Version.VERSION_1_7.getLabel(), Version.VERSION_1_8.getLabel(), };
|
||||
Version.VERSION_1_0.getLabel(), Version.VERSION_1_1.getLabel(), Version.VERSION_1_2.getLabel(),
|
||||
Version.VERSION_1_3.getLabel(), Version.VERSION_1_4.getLabel(), Version.VERSION_1_5.getLabel(),
|
||||
Version.VERSION_1_6.getLabel(), Version.VERSION_1_7.getLabel(), Version.VERSION_1_8.getLabel(), };
|
||||
|
||||
// Note: The UI order values are chosen to be larger than those built into XPathRule.
|
||||
// Note: The UI order values are chosen to be larger than those built into
|
||||
// XPathRule.
|
||||
public static final BooleanProperty RECORDING_COMMENTS_DESCRIPTOR = new BooleanProperty("recordingComments",
|
||||
"Specifies that comments are produced in the AST.", Boolean.TRUE, 3.0f);
|
||||
"Specifies that comments are produced in the AST.", Boolean.TRUE, 3.0f);
|
||||
public static final BooleanProperty RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR = new BooleanProperty(
|
||||
"recordingLocalJsDocComments", "Specifies that JsDoc comments are produced in the AST.", Boolean.TRUE, 4.0f);
|
||||
"recordingLocalJsDocComments", "Specifies that JsDoc comments are produced in the AST.", Boolean.TRUE,
|
||||
4.0f);
|
||||
public static final EnumeratedProperty<Version> RHINO_LANGUAGE_VERSION = new EnumeratedProperty<>(
|
||||
"rhinoLanguageVersion",
|
||||
"Specifies the Rhino Language Version to use for parsing. Defaults to Rhino default.", VERSION_LABELS,
|
||||
Version.values(), 0, 5.0f);
|
||||
"rhinoLanguageVersion",
|
||||
"Specifies the Rhino Language Version to use for parsing. Defaults to Rhino default.", VERSION_LABELS,
|
||||
Version.values(), 0, 5.0f);
|
||||
|
||||
private boolean recordingComments;
|
||||
private boolean recordingLocalJsDocComments;
|
||||
private Version rhinoLanguageVersion;
|
||||
|
||||
public EcmascriptParserOptions() {
|
||||
this.recordingComments = RECORDING_COMMENTS_DESCRIPTOR.defaultValue().booleanValue();
|
||||
this.recordingLocalJsDocComments = RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR.defaultValue().booleanValue();
|
||||
this.rhinoLanguageVersion = (Version) RHINO_LANGUAGE_VERSION.valueFrom((String) RHINO_LANGUAGE_VERSION
|
||||
.defaultValue());
|
||||
this.recordingComments = RECORDING_COMMENTS_DESCRIPTOR.defaultValue().booleanValue();
|
||||
this.recordingLocalJsDocComments = RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR.defaultValue().booleanValue();
|
||||
this.rhinoLanguageVersion = (Version) RHINO_LANGUAGE_VERSION
|
||||
.valueFrom((String) RHINO_LANGUAGE_VERSION.defaultValue());
|
||||
}
|
||||
|
||||
public EcmascriptParserOptions(Rule rule) {
|
||||
this.recordingComments = rule.getProperty(RECORDING_COMMENTS_DESCRIPTOR);
|
||||
this.recordingLocalJsDocComments = rule.getProperty(RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR);
|
||||
this.rhinoLanguageVersion = (Version) RHINO_LANGUAGE_VERSION.valueFrom((String) rule
|
||||
.getProperty(RHINO_LANGUAGE_VERSION));
|
||||
this.recordingComments = rule.getProperty(RECORDING_COMMENTS_DESCRIPTOR);
|
||||
this.recordingLocalJsDocComments = rule.getProperty(RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR);
|
||||
this.rhinoLanguageVersion = (Version) RHINO_LANGUAGE_VERSION
|
||||
.valueFrom((String) rule.getProperty(RHINO_LANGUAGE_VERSION));
|
||||
}
|
||||
|
||||
public boolean isRecordingComments() {
|
||||
return this.recordingComments;
|
||||
return this.recordingComments;
|
||||
}
|
||||
|
||||
public void setRecordingComments(boolean recordingComments) {
|
||||
this.recordingComments = recordingComments;
|
||||
this.recordingComments = recordingComments;
|
||||
}
|
||||
|
||||
public boolean isRecordingLocalJsDocComments() {
|
||||
return this.recordingLocalJsDocComments;
|
||||
return this.recordingLocalJsDocComments;
|
||||
}
|
||||
|
||||
public void setRecordingLocalJsDocComments(boolean recordingLocalJsDocComments) {
|
||||
this.recordingLocalJsDocComments = recordingLocalJsDocComments;
|
||||
this.recordingLocalJsDocComments = recordingLocalJsDocComments;
|
||||
}
|
||||
|
||||
public Version getRhinoLanguageVersion() {
|
||||
return this.rhinoLanguageVersion;
|
||||
return this.rhinoLanguageVersion;
|
||||
}
|
||||
|
||||
public void setRhinoLanguageVersion(Version rhinoLanguageVersion) {
|
||||
this.rhinoLanguageVersion = rhinoLanguageVersion;
|
||||
this.rhinoLanguageVersion = rhinoLanguageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (recordingComments ? 1231 : 1237);
|
||||
result = prime * result + (recordingLocalJsDocComments ? 1231 : 1237);
|
||||
result = prime * result + ((rhinoLanguageVersion == null) ? 0 : rhinoLanguageVersion.hashCode());
|
||||
return result;
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (recordingComments ? 1231 : 1237);
|
||||
result = prime * result + (recordingLocalJsDocComments ? 1231 : 1237);
|
||||
result = prime * result + ((rhinoLanguageVersion == null) ? 0 : rhinoLanguageVersion.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final EcmascriptParserOptions that = (EcmascriptParserOptions) obj;
|
||||
return StringUtil.isSame(this.suppressMarker, that.suppressMarker, false, false, false)
|
||||
&& this.recordingComments == that.recordingComments
|
||||
&& this.recordingLocalJsDocComments == that.recordingLocalJsDocComments
|
||||
&& this.rhinoLanguageVersion == that.rhinoLanguageVersion;
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final EcmascriptParserOptions that = (EcmascriptParserOptions) obj;
|
||||
return StringUtil.isSame(this.suppressMarker, that.suppressMarker, false, false, false)
|
||||
&& this.recordingComments == that.recordingComments
|
||||
&& this.recordingLocalJsDocComments == that.recordingLocalJsDocComments
|
||||
&& this.rhinoLanguageVersion == that.rhinoLanguageVersion;
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +1,40 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ArrayComprehension;
|
||||
|
||||
public class ASTArrayComprehension extends AbstractEcmascriptNode<ArrayComprehension> {
|
||||
public ASTArrayComprehension(ArrayComprehension arrayComprehension) {
|
||||
super(arrayComprehension);
|
||||
super(arrayComprehension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getResult() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public int getNumArrayComprehensionLoops() {
|
||||
return node.getLoops().size();
|
||||
return node.getLoops().size();
|
||||
}
|
||||
|
||||
public ASTArrayComprehensionLoop getArrayComprehensionLoop(int index) {
|
||||
return (ASTArrayComprehensionLoop) jjtGetChild(index + 1);
|
||||
return (ASTArrayComprehensionLoop) jjtGetChild(index + 1);
|
||||
}
|
||||
|
||||
public boolean hasFilter() {
|
||||
return node.getFilter() != null;
|
||||
return node.getFilter() != null;
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getFilter() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(jjtGetNumChildren() - 1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(jjtGetNumChildren() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ArrayComprehensionLoop;
|
||||
@ -8,21 +9,21 @@ import org.mozilla.javascript.ast.ArrayComprehensionLoop;
|
||||
public class ASTArrayComprehensionLoop extends AbstractEcmascriptNode<ArrayComprehensionLoop> {
|
||||
|
||||
public ASTArrayComprehensionLoop(ArrayComprehensionLoop arrayComprehensionLoop) {
|
||||
super(arrayComprehensionLoop);
|
||||
super(arrayComprehensionLoop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getIterator() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getIteratedObject() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,35 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ArrayLiteral;
|
||||
|
||||
public class ASTArrayLiteral extends AbstractEcmascriptNode<ArrayLiteral> implements DestructuringNode, TrailingCommaNode {
|
||||
public class ASTArrayLiteral extends AbstractEcmascriptNode<ArrayLiteral>
|
||||
implements DestructuringNode, TrailingCommaNode {
|
||||
private boolean trailingComma;
|
||||
|
||||
public ASTArrayLiteral(ArrayLiteral arrayLiteral) {
|
||||
super(arrayLiteral);
|
||||
super(arrayLiteral);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public boolean isDestructuring() {
|
||||
return node.isDestructuring();
|
||||
return node.isDestructuring();
|
||||
}
|
||||
|
||||
public boolean isTrailingComma() {
|
||||
return trailingComma;
|
||||
return trailingComma;
|
||||
}
|
||||
|
||||
public void setTrailingComma(boolean trailingComma) {
|
||||
this.trailingComma = trailingComma;
|
||||
this.trailingComma = trailingComma;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.Assignment;
|
||||
|
||||
public class ASTAssignment extends AbstractInfixEcmascriptNode<Assignment> {
|
||||
public ASTAssignment(Assignment asssignment) {
|
||||
super(asssignment);
|
||||
super(asssignment);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,6 +16,6 @@ public class ASTAssignment extends AbstractInfixEcmascriptNode<Assignment> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.AstRoot;
|
||||
|
||||
public class ASTAstRoot extends AbstractEcmascriptNode<AstRoot> {
|
||||
public ASTAstRoot(AstRoot astRoot) {
|
||||
super(astRoot);
|
||||
super(astRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,14 +16,14 @@ public class ASTAstRoot extends AbstractEcmascriptNode<AstRoot> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public int getNumComments() {
|
||||
return node.getComments() != null ? node.getComments().size() : 0;
|
||||
return node.getComments() != null ? node.getComments().size() : 0;
|
||||
}
|
||||
|
||||
public ASTComment getComment(int index) {
|
||||
return (ASTComment) jjtGetChild(jjtGetNumChildren() - 1 - getNumComments() + index);
|
||||
return (ASTComment) jjtGetChild(jjtGetNumChildren() - 1 - getNumComments() + index);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.Block;
|
||||
|
||||
public class ASTBlock extends AbstractEcmascriptNode<Block> {
|
||||
public ASTBlock(Block block) {
|
||||
super(block);
|
||||
super(block);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,6 +16,6 @@ public class ASTBlock extends AbstractEcmascriptNode<Block> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.BreakStatement;
|
||||
|
||||
public class ASTBreakStatement extends AbstractEcmascriptNode<BreakStatement> {
|
||||
public ASTBreakStatement(BreakStatement breakStatement) {
|
||||
super(breakStatement);
|
||||
super.setImage(breakStatement.getBreakLabel() != null ? breakStatement.getBreakLabel().getIdentifier() : null);
|
||||
super(breakStatement);
|
||||
super.setImage(breakStatement.getBreakLabel() != null ? breakStatement.getBreakLabel().getIdentifier() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -16,14 +17,14 @@ public class ASTBreakStatement extends AbstractEcmascriptNode<BreakStatement> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public boolean hasLabel() {
|
||||
return node.getBreakLabel() != null;
|
||||
return node.getBreakLabel() != null;
|
||||
}
|
||||
|
||||
public ASTName getLabel() {
|
||||
return (ASTName) jjtGetChild(0);
|
||||
return (ASTName) jjtGetChild(0);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.CatchClause;
|
||||
|
||||
public class ASTCatchClause extends AbstractEcmascriptNode<CatchClause> {
|
||||
public ASTCatchClause(CatchClause catchClause) {
|
||||
super(catchClause);
|
||||
super(catchClause);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,22 +16,22 @@ public class ASTCatchClause extends AbstractEcmascriptNode<CatchClause> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public ASTName getVariableName() {
|
||||
return (ASTName) jjtGetChild(0);
|
||||
return (ASTName) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public boolean isIf() {
|
||||
return node.getCatchCondition() != null;
|
||||
return node.getCatchCondition() != null;
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getCatchCondition() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
|
||||
public ASTBlock getBlock() {
|
||||
return (ASTBlock) jjtGetChild(jjtGetNumChildren() - 1);
|
||||
return (ASTBlock) jjtGetChild(jjtGetNumChildren() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.Comment;
|
||||
|
||||
public class ASTComment extends AbstractEcmascriptNode<Comment> {
|
||||
public ASTComment(Comment comment) {
|
||||
super(comment);
|
||||
super(comment);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,10 +16,10 @@ public class ASTComment extends AbstractEcmascriptNode<Comment> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return node.getValue();
|
||||
return node.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ConditionalExpression;
|
||||
|
||||
public class ASTConditionalExpression extends AbstractEcmascriptNode<ConditionalExpression> {
|
||||
public ASTConditionalExpression(ConditionalExpression conditionalExpression) {
|
||||
super(conditionalExpression);
|
||||
super(conditionalExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,18 +16,18 @@ public class ASTConditionalExpression extends AbstractEcmascriptNode<Conditional
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getTestExpression() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getTrueExpression() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getFalseExpression() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ContinueStatement;
|
||||
|
||||
public class ASTContinueStatement extends AbstractEcmascriptNode<ContinueStatement> {
|
||||
public ASTContinueStatement(ContinueStatement continueStatement) {
|
||||
super(continueStatement);
|
||||
super.setImage(continueStatement.getLabel() != null ? continueStatement.getLabel().getIdentifier() : null);
|
||||
super(continueStatement);
|
||||
super.setImage(continueStatement.getLabel() != null ? continueStatement.getLabel().getIdentifier() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -16,14 +17,14 @@ public class ASTContinueStatement extends AbstractEcmascriptNode<ContinueStateme
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public boolean hasLabel() {
|
||||
return node.getLabel() != null;
|
||||
return node.getLabel() != null;
|
||||
}
|
||||
|
||||
public ASTName getLabel() {
|
||||
return (ASTName) jjtGetChild(0);
|
||||
return (ASTName) jjtGetChild(0);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.DoLoop;
|
||||
|
||||
public class ASTDoLoop extends AbstractEcmascriptNode<DoLoop> {
|
||||
public ASTDoLoop(DoLoop doLoop) {
|
||||
super(doLoop);
|
||||
super(doLoop);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,14 +16,14 @@ public class ASTDoLoop extends AbstractEcmascriptNode<DoLoop> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getBody() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getCondition() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ElementGet;
|
||||
|
||||
public class ASTElementGet extends AbstractEcmascriptNode<ElementGet> {
|
||||
public ASTElementGet(ElementGet elementGet) {
|
||||
super(elementGet);
|
||||
super(elementGet);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,19 +16,19 @@ public class ASTElementGet extends AbstractEcmascriptNode<ElementGet> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getTarget() {
|
||||
if (jjtGetNumChildren() > 0) {
|
||||
return (EcmascriptNode<?>)jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getElement() {
|
||||
if (jjtGetNumChildren() > 1) {
|
||||
return (EcmascriptNode<?>)jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.EmptyExpression;
|
||||
|
||||
public class ASTEmptyExpression extends AbstractEcmascriptNode<EmptyExpression> {
|
||||
public ASTEmptyExpression(EmptyExpression emptyExpression) {
|
||||
super(emptyExpression);
|
||||
super(emptyExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,6 +16,6 @@ public class ASTEmptyExpression extends AbstractEcmascriptNode<EmptyExpression>
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.EmptyStatement;
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.Token;
|
||||
@ -8,7 +9,7 @@ import org.mozilla.javascript.ast.ExpressionStatement;
|
||||
|
||||
public class ASTExpressionStatement extends AbstractEcmascriptNode<ExpressionStatement> {
|
||||
public ASTExpressionStatement(ExpressionStatement expressionStatement) {
|
||||
super(expressionStatement);
|
||||
super(expressionStatement);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -16,10 +17,10 @@ public class ASTExpressionStatement extends AbstractEcmascriptNode<ExpressionSta
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public boolean hasResult() {
|
||||
return node.getType() == Token.EXPR_RESULT;
|
||||
return node.getType() == Token.EXPR_RESULT;
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,36 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ForInLoop;
|
||||
|
||||
public class ASTForInLoop extends AbstractEcmascriptNode<ForInLoop> {
|
||||
public ASTForInLoop(ForInLoop forInLoop) {
|
||||
super(forInLoop);
|
||||
super(forInLoop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getIterator() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getIteratedObject() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getBody() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
}
|
||||
|
||||
public boolean isForEach() {
|
||||
return node.isForEach();
|
||||
return node.isForEach();
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,36 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.ForLoop;
|
||||
|
||||
public class ASTForLoop extends AbstractEcmascriptNode<ForLoop> {
|
||||
public ASTForLoop(ForLoop forLoop) {
|
||||
super(forLoop);
|
||||
super(forLoop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getInitializer() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getCondition() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getIncrement() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getBody() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(3);
|
||||
return (EcmascriptNode<?>) jjtGetChild(3);
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,36 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.FunctionCall;
|
||||
|
||||
public class ASTFunctionCall extends AbstractEcmascriptNode<FunctionCall> {
|
||||
public ASTFunctionCall(FunctionCall functionCall) {
|
||||
super(functionCall);
|
||||
super(functionCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getTarget() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public int getNumArguments() {
|
||||
return node.getArguments().size();
|
||||
return node.getArguments().size();
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getArgument(int index) {
|
||||
return (EcmascriptNode<?>) jjtGetChild(index + 1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(index + 1);
|
||||
}
|
||||
|
||||
public boolean hasArguments() {
|
||||
return getNumArguments() != 0;
|
||||
return getNumArguments() != 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,41 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.FunctionNode;
|
||||
|
||||
public class ASTFunctionNode extends AbstractEcmascriptNode<FunctionNode> {
|
||||
public ASTFunctionNode(FunctionNode functionNode) {
|
||||
super(functionNode);
|
||||
super.setImage(functionNode.getName());
|
||||
super(functionNode);
|
||||
super.setImage(functionNode.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public int getNumParams() {
|
||||
return node.getParams().size();
|
||||
return node.getParams().size();
|
||||
}
|
||||
|
||||
public ASTName getFunctionName() {
|
||||
if (node.getFunctionName() != null) {
|
||||
return (ASTName) jjtGetChild(0);
|
||||
}
|
||||
return null;
|
||||
if (node.getFunctionName() != null) {
|
||||
return (ASTName) jjtGetChild(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getParam(int index) {
|
||||
int paramIndex = index;
|
||||
if (node.getFunctionName() != null) {
|
||||
paramIndex = index + 1;
|
||||
}
|
||||
return (EcmascriptNode<?>) jjtGetChild(paramIndex);
|
||||
if (node.getFunctionName() != null) {
|
||||
paramIndex = index + 1;
|
||||
}
|
||||
return (EcmascriptNode<?>) jjtGetChild(paramIndex);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getBody() {
|
||||
@ -43,19 +44,19 @@ public class ASTFunctionNode extends AbstractEcmascriptNode<FunctionNode> {
|
||||
|
||||
@Deprecated // use getBody() instead
|
||||
public EcmascriptNode<?> getBody(int index) {
|
||||
return getBody();
|
||||
return getBody();
|
||||
}
|
||||
|
||||
public boolean isClosure() {
|
||||
return node.isExpressionClosure();
|
||||
return node.isExpressionClosure();
|
||||
}
|
||||
|
||||
public boolean isGetter() {
|
||||
return node.isGetterMethod();
|
||||
return node.isGetterMethod();
|
||||
}
|
||||
|
||||
public boolean isSetter() {
|
||||
return node.isSetterMethod();
|
||||
return node.isSetterMethod();
|
||||
}
|
||||
|
||||
public boolean isGetterOrSetter() {
|
||||
|
@ -1,35 +1,36 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.IfStatement;
|
||||
|
||||
public class ASTIfStatement extends AbstractEcmascriptNode<IfStatement> {
|
||||
public ASTIfStatement(IfStatement ifStatement) {
|
||||
super(ifStatement);
|
||||
super(ifStatement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public boolean hasElse() {
|
||||
return node.getElsePart() != null;
|
||||
return node.getElsePart() != null;
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getCondition() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
return (EcmascriptNode<?>) jjtGetChild(0);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getThen() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
return (EcmascriptNode<?>) jjtGetChild(1);
|
||||
}
|
||||
|
||||
public EcmascriptNode<?> getElse() {
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
return (EcmascriptNode<?>) jjtGetChild(2);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.InfixExpression;
|
||||
|
||||
public class ASTInfixExpression extends AbstractInfixEcmascriptNode<InfixExpression> {
|
||||
public ASTInfixExpression(InfixExpression infixExpression) {
|
||||
super(infixExpression);
|
||||
super(infixExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.Token;
|
||||
@ -8,8 +9,8 @@ import org.mozilla.javascript.ast.KeywordLiteral;
|
||||
|
||||
public class ASTKeywordLiteral extends AbstractEcmascriptNode<KeywordLiteral> {
|
||||
public ASTKeywordLiteral(KeywordLiteral keywordLiteral) {
|
||||
super(keywordLiteral);
|
||||
super.setImage(Token.typeToName(keywordLiteral.getType()).toLowerCase());
|
||||
super(keywordLiteral);
|
||||
super.setImage(Token.typeToName(keywordLiteral.getType()).toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -17,22 +18,22 @@ public class ASTKeywordLiteral extends AbstractEcmascriptNode<KeywordLiteral> {
|
||||
*/
|
||||
@Override
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public boolean isBoolean() {
|
||||
return node.isBooleanLiteral();
|
||||
return node.isBooleanLiteral();
|
||||
}
|
||||
|
||||
|
||||
public boolean isThis() {
|
||||
return node.getType() == Token.THIS;
|
||||
return node.getType() == Token.THIS;
|
||||
}
|
||||
|
||||
|
||||
public boolean isNull() {
|
||||
return node.getType() == Token.NULL;
|
||||
return node.getType() == Token.NULL;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDebugger() {
|
||||
return node.getType() == Token.DEBUGGER;
|
||||
return node.getType() == Token.DEBUGGER;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.mozilla.javascript.ast.Label;
|
||||
|
||||
public class ASTLabel extends AbstractEcmascriptNode<Label> {
|
||||
public ASTLabel(Label label) {
|
||||
super(label);
|
||||
super.setImage(label.getName());
|
||||
super(label);
|
||||
super.setImage(label.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*/
|
||||
public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user