diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java index 14f4929dee..217f803fd8 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java @@ -16,4 +16,15 @@ public class ASTCatchBlockStatement extends AbstractApexNode implements CanSuppressWarn @Override public String getImage() { - return node.getFieldInfo().getName(); + if (node.getFieldInfo() != null) { + return node.getFieldInfo().getName(); + } + return null; } @Override @@ -35,4 +38,8 @@ public class ASTField extends AbstractApexNode implements CanSuppressWarn } return false; } + + public String getTypeRef() { + return String.valueOf(node.getTypeRef()); + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java index 9b84e46512..5c382e3574 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java @@ -16,4 +16,16 @@ public class ASTFieldDeclaration extends AbstractApexNode { public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + @Override + public String getImage() { + if (node.getFieldInfo() != null) { + return node.getFieldInfo().getName(); + } + ASTVariableExpression variable = getFirstChildOfType(ASTVariableExpression.class); + if (variable != null) { + return variable.getImage(); + } + return null; + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java index a59df839e1..97360e3fb5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java @@ -17,6 +17,11 @@ public class ASTFormalComment extends AbstractApexNodeBase { return visitor.visit(this, data); } + @Override + public String getImage() { + return token; + } + public String getToken() { return token; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java index 35b04e7d37..42bf52ef62 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java @@ -24,4 +24,9 @@ public class ASTLiteralExpression extends AbstractApexNode { public LiteralType getLiteralType() { return node.getLiteralType(); } + + @Override + public String getImage() { + return String.valueOf(node.getLiteral()); + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java index 811cd33f66..ed9465d9b1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd.lang.apex.ast; import apex.jorje.semantic.ast.modifier.ModifierNode; +import apex.jorje.semantic.symbol.type.ModifierTypeInfos; public class ASTModifierNode extends AbstractApexNode implements AccessNode { @@ -56,4 +57,36 @@ public class ASTModifierNode extends AbstractApexNode implements A public boolean isTransient() { return (node.getModifiers().getJavaModifiers() & TRANSIENT) == TRANSIENT; } + + public boolean isTest() { + return node.getModifiers().isTest(); + } + + public boolean isTestOrTestSetup() { + return node.getModifiers().isTestOrTestSetup(); + } + + public boolean isWithSharing() { + return node.getModifiers().has(ModifierTypeInfos.WITH_SHARING); + } + + public boolean isWithoutSharing() { + return node.getModifiers().has(ModifierTypeInfos.WITHOUT_SHARING); + } + + public boolean isInheritedSharing() { + return node.getModifiers().has(ModifierTypeInfos.INHERITED_SHARING); + } + + public boolean isWebService() { + return node.getModifiers().has(ModifierTypeInfos.WEB_SERVICE); + } + + public boolean isGlobal() { + return node.getModifiers().has(ModifierTypeInfos.GLOBAL); + } + + public boolean hasOverride() { + return node.getModifiers().has(ModifierTypeInfos.OVERRIDE); + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java index a0bec8ba90..d847356a9a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java @@ -16,4 +16,11 @@ public class ASTProperty extends AbstractApexNode { public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + public String getTypeName() { + if (node.getFieldInfo() != null) { + return node.getFieldInfo().getType().getApexName(); + } + return null; + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java index ef3db237a3..3d76d4f12e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java @@ -30,4 +30,12 @@ public class ASTReferenceExpression extends AbstractApexNode public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + @Override + public String getImage() { + if (node.getIdentifier() != null) { + return node.getIdentifier().getValue(); + } + return null; + } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java index f5ad61f86e..d706474b34 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexRootNode.java @@ -21,4 +21,8 @@ public abstract class ApexRootNode extends AbstractApexNode