Search in sources :

Example 6 with Identifier

use of apex.jorje.data.Identifier in project pmd by pmd.

the class ASTUserInterface method getImage.

@Override
public String getImage() {
    try {
        Field field = node.getClass().getDeclaredField("name");
        field.setAccessible(true);
        Identifier name = (Identifier) field.get(node);
        return name.getValue();
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
Also used : Field(java.lang.reflect.Field) Identifier(apex.jorje.data.Identifier)

Example 7 with Identifier

use of apex.jorje.data.Identifier in project pmd by pmd.

the class ASTUserTrigger method getImage.

@Override
public String getImage() {
    try {
        Field field = node.getClass().getDeclaredField("name");
        field.setAccessible(true);
        Identifier name = (Identifier) field.get(node);
        return name.getValue();
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
Also used : Field(java.lang.reflect.Field) Identifier(apex.jorje.data.Identifier)

Example 8 with Identifier

use of apex.jorje.data.Identifier in project pmd by pmd.

the class ASTUserClass method getImage.

@Override
public String getImage() {
    try {
        Field field = node.getClass().getDeclaredField("name");
        field.setAccessible(true);
        Identifier name = (Identifier) field.get(node);
        return name.getValue();
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
Also used : Field(java.lang.reflect.Field) Identifier(apex.jorje.data.Identifier)

Example 9 with Identifier

use of apex.jorje.data.Identifier in project pmd by pmd.

the class ApexCRUDViolationRule method visit.

@Override
public Object visit(final ASTFieldDeclaration node, Object data) {
    ASTFieldDeclarationStatements field = node.getFirstParentOfType(ASTFieldDeclarationStatements.class);
    if (field != null) {
        TypeRef a = field.getNode().getTypeName();
        List<Identifier> names = a.getNames();
        List<TypeRef> typeArgs = a.getTypeArguments();
        if (!names.isEmpty()) {
            StringBuffer sb = new StringBuffer();
            for (Identifier id : names) {
                sb.append(id.getValue()).append(".");
            }
            sb.deleteCharAt(sb.length() - 1);
            switch(sb.toString().toLowerCase(Locale.ROOT)) {
                case "list":
                case "map":
                    addParametersToMapping(node, typeArgs);
                    break;
                default:
                    varToTypeMapping.put(Helper.getFQVariableName(node), getSimpleType(sb.toString()));
                    break;
            }
        }
    }
    final ASTSoqlExpression soql = node.getFirstChildOfType(ASTSoqlExpression.class);
    if (soql != null) {
        checkForAccessibility(soql, data);
    }
    return data;
}
Also used : Identifier(apex.jorje.data.Identifier) ASTFieldDeclarationStatements(net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclarationStatements) ArrayTypeRef(apex.jorje.data.ast.TypeRefs.ArrayTypeRef) TypeRef(apex.jorje.data.ast.TypeRef) ClassTypeRef(apex.jorje.data.ast.TypeRefs.ClassTypeRef) ASTSoqlExpression(net.sourceforge.pmd.lang.apex.ast.ASTSoqlExpression)

Aggregations

Identifier (apex.jorje.data.Identifier)9 Field (java.lang.reflect.Field)3 ClassTypeRef (apex.jorje.data.ast.TypeRefs.ClassTypeRef)2 ASTReferenceExpression (net.sourceforge.pmd.lang.apex.ast.ASTReferenceExpression)2 TypeRef (apex.jorje.data.ast.TypeRef)1 ArrayTypeRef (apex.jorje.data.ast.TypeRefs.ArrayTypeRef)1 FieldDeclaration (apex.jorje.semantic.ast.statement.FieldDeclaration)1 ASTFieldDeclaration (net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclaration)1 ASTFieldDeclarationStatements (net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclarationStatements)1 ASTMethod (net.sourceforge.pmd.lang.apex.ast.ASTMethod)1 ASTMethodCallExpression (net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression)1 ASTSoqlExpression (net.sourceforge.pmd.lang.apex.ast.ASTSoqlExpression)1 ASTVariableExpression (net.sourceforge.pmd.lang.apex.ast.ASTVariableExpression)1