mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-10 20:30:11 +08:00
some annotation type can be null, e.g. java.lang.Override
This commit is contained in:
parent
a814e51f66
commit
9e1c1b8c3b
@ -86,7 +86,7 @@ public class EnableTestableTranslator extends BaseTranslator {
|
||||
@Override
|
||||
public void visitMethodDef(JCMethodDecl jcMethodDecl) {
|
||||
for (JCAnnotation a : jcMethodDecl.mods.annotations) {
|
||||
if (ConstPool.ANNOTATION_TESTABLE_INJECT.equals(a.type.tsym.toString())) {
|
||||
if (a.type != null && ConstPool.ANNOTATION_TESTABLE_INJECT.equals(a.type.tsym.toString())) {
|
||||
ListBuffer<JCExpression> args = new ListBuffer<>();
|
||||
for (JCVariableDecl p : jcMethodDecl.params) {
|
||||
args.add(cx.treeMaker.Select(p.vartype, cx.names.fromString(ConstPool.CLASS_OF_TYPE)));
|
||||
@ -145,16 +145,6 @@ public class EnableTestableTranslator extends BaseTranslator {
|
||||
return expr;
|
||||
}
|
||||
|
||||
private List<JCAnnotation> removeAnnotation(List<JCAnnotation> annotations, String target) {
|
||||
ListBuffer<JCAnnotation> nb = new ListBuffer<>();
|
||||
for (JCAnnotation i : annotations) {
|
||||
if (!i.type.tsym.toString().equals(target)) {
|
||||
nb.add(i);
|
||||
}
|
||||
}
|
||||
return nb.toList();
|
||||
}
|
||||
|
||||
private boolean isPrivateField(JCAssign expr) {
|
||||
return expr.lhs.getClass().equals(JCFieldAccess.class) &&
|
||||
((JCFieldAccess)(expr).lhs).selected.getClass().equals(JCIdent.class) &&
|
||||
|
Loading…
Reference in New Issue
Block a user