forked from pmd/pmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASTFieldDeclarationStatements.java
82 lines (67 loc) · 2.45 KB
/
ASTFieldDeclarationStatements.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.pmd.Rule;
import com.google.summit.ast.declaration.FieldDeclarationGroup;
public class ASTFieldDeclarationStatements extends AbstractApexNode.Single<FieldDeclarationGroup>
implements CanSuppressWarnings {
ASTFieldDeclarationStatements(FieldDeclarationGroup fieldDeclarationStatements) {
super(fieldDeclarationStatements);
}
@Override
public Object jjtAccept(ApexParserVisitor visitor, Object data) {
return visitor.visit(this, data);
}
@Override
public boolean hasSuppressWarningsAnnotationFor(Rule rule) {
for (ASTModifierNode modifier : findChildrenOfType(ASTModifierNode.class)) {
for (ASTAnnotation a : modifier.findChildrenOfType(ASTAnnotation.class)) {
if (a.suppresses(rule)) {
return true;
}
}
}
return false;
}
public ASTModifierNode getModifiers() {
return getFirstChildOfType(ASTModifierNode.class);
}
/**
* Returns the type name.
*
* This includes any type arguments.
* If the type is a primitive, its case will be normalized.
*/
public String getTypeName() {
return caseNormalizedTypeIfPrimitive(node.getType().asCodeString());
}
/*
private static String identifiersToString(List<Identifier> identifiers) {
return identifiers.stream().map(Identifier::getValue).collect(Collectors.joining("."));
}
*/
// TODO(b/239648780)
public List<String> getTypeArguments() {
/*
List<String> result = new ArrayList<>();
if (node.getTypeName() != null) {
List<TypeRef> typeArgs = node.getTypeName().getTypeArguments();
for (TypeRef arg : typeArgs) {
if (arg instanceof ClassTypeRef) {
result.add(identifiersToString(arg.getNames()));
} else if (arg instanceof ArrayTypeRef) {
ArrayTypeRef atr = (ArrayTypeRef) arg;
if (atr.getHeldType() instanceof ClassTypeRef) {
result.add(identifiersToString(atr.getHeldType().getNames()));
}
}
}
}
*/
// TODO(b/239648780)
return new ArrayList<>();
}
}