mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-10 20:30:11 +08:00
fix generated static new class structure
This commit is contained in:
parent
3d98eb4c8a
commit
b9796e0397
@ -27,7 +27,6 @@ public class StaticNewClassGenerator {
|
|||||||
TypeVariableName typeVariable = TypeVariableName.get("T");
|
TypeVariableName typeVariable = TypeVariableName.get("T");
|
||||||
MethodSpec.Builder builder = MethodSpec.methodBuilder(ConstPool.SN_METHOD)
|
MethodSpec.Builder builder = MethodSpec.methodBuilder(ConstPool.SN_METHOD)
|
||||||
.addModifiers(Modifier.PUBLIC).addModifiers(Modifier.STATIC)
|
.addModifiers(Modifier.PUBLIC).addModifiers(Modifier.STATIC)
|
||||||
.addException(Exception.class)
|
|
||||||
.addTypeVariable(typeVariable)
|
.addTypeVariable(typeVariable)
|
||||||
.varargs(true)
|
.varargs(true)
|
||||||
.addParameter(ParameterizedTypeName.get(ClassName.get(Class.class), typeVariable), "type")
|
.addParameter(ParameterizedTypeName.get(ClassName.get(Class.class), typeVariable), "type")
|
||||||
|
@ -58,9 +58,10 @@ public class TestableClassTranslator extends TreeTranslator {
|
|||||||
nameTable.fromString("class"), null);
|
nameTable.fromString("class"), null);
|
||||||
ListBuffer<JCTree.JCExpression> args = ListBuffer.of(classType);
|
ListBuffer<JCTree.JCExpression> args = ListBuffer.of(classType);
|
||||||
args.addAll(newClassExpr.args);
|
args.addAll(newClassExpr.args);
|
||||||
|
TestableFieldAccess ne = new TestableFieldAccess(treeMaker.Ident(nameTable.fromString(ConstPool.SN_PKG)),
|
||||||
|
nameTable.fromString(ConstPool.SN_CLS), null);
|
||||||
jcExpressionStatement.expr = new TestableMethodInvocation(null,
|
jcExpressionStatement.expr = new TestableMethodInvocation(null,
|
||||||
new TestableFieldAccess(treeMaker.Ident(nameTable.fromString(ConstPool.SN_PKG_CLS)),
|
new TestableFieldAccess(ne, nameTable.fromString(ConstPool.SN_METHOD), null), args.toList());
|
||||||
nameTable.fromString(ConstPool.SN_METHOD), null), args.toList());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user