mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-11 04:40:12 +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
|
@Override
|
||||||
public void visitMethodDef(JCMethodDecl jcMethodDecl) {
|
public void visitMethodDef(JCMethodDecl jcMethodDecl) {
|
||||||
for (JCAnnotation a : jcMethodDecl.mods.annotations) {
|
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<>();
|
ListBuffer<JCExpression> args = new ListBuffer<>();
|
||||||
for (JCVariableDecl p : jcMethodDecl.params) {
|
for (JCVariableDecl p : jcMethodDecl.params) {
|
||||||
args.add(cx.treeMaker.Select(p.vartype, cx.names.fromString(ConstPool.CLASS_OF_TYPE)));
|
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;
|
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) {
|
private boolean isPrivateField(JCAssign expr) {
|
||||||
return expr.lhs.getClass().equals(JCFieldAccess.class) &&
|
return expr.lhs.getClass().equals(JCFieldAccess.class) &&
|
||||||
((JCFieldAccess)(expr).lhs).selected.getClass().equals(JCIdent.class) &&
|
((JCFieldAccess)(expr).lhs).selected.getClass().equals(JCIdent.class) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user