@Override public boolean visit(JClassType x, Context ctx) { for (JInterfaceType i : x.getImplements()) { if (i.getName().equals("EntryPoint")) { if (logger.isLoggable(logLevel)) { logger.log(logLevel, "Using entry point class "+x.getName()+" for gwt-reflection module defaults"); } result = x; return false; } } return true; }
public boolean isJavaScriptObject(JClassType type) { if (type == null) { return false; } if (JProgram.JAVASCRIPTOBJECT.equals(type.getName())) { return true; } return isJavaScriptObject(type.getSuperClass()); }
private void processThisCallThisArgs(ReferenceBinding binding, JMethodCall call) { if (binding.syntheticEnclosingInstanceTypes() != null) { Iterator<JParameter> paramIt = curMethod.method.getParams().iterator(); if (curClass.classType.isEnumOrSubclass() != null) { // Skip past the enum args. paramIt.next(); paramIt.next(); } for (@SuppressWarnings("unused") ReferenceBinding argType : binding.syntheticEnclosingInstanceTypes()) { JParameter param = paramIt.next(); call.addArg(new JParameterRef(call.getSourceInfo(), param)); } } }
@Override public boolean visit(JConstructor x, Context ctx) { if (pastRebound) { for (JMethod m : x.getEnclosingType().getMethods()) { if (m.getName().equals("createNewTestCase")) { for (JStatement statement : ((JMethodBody)m.getBody()).getBlock().getStatements()) { if (statement instanceof JIfStatement) { pastConstructor = true; ((JIfStatement)statement).getThenStmt().traverse(this, ctx); return false; } } } } } return super.visit(x, ctx); }
JClassType mapClass = new JClassType(info, intern(type.getName() + "$Map"), false, true); mapClass.setSuperClass(javaLangObject); mapClass.setEnclosingType(type); newTypes.add(mapClass); mapClass.addField(mapField);
private boolean isJso(JClassType type) { if (type == null) { return false; } return type == program.getJavaScriptObject() || isJso(type.getSuperClass()); }
@Override public void onUnifyAstStart(TreeLogger logger, UnifyAstView ast, UnifyVisitor visitor, Queue<JMethod> todo) { for (final JMethod method : ast.getProgram().getEntryMethods()) { if (method.getBody() instanceof JMethodBody) { JMethodBody body = (JMethodBody) method.getBody(); // obtain the entry point EntryPointFinder finder = findEntryPoint(logger); body.traverse(finder, finder.getContext()); // find a default strategy if (finder.result == null) { strategy = MagicClassGenerator.class.getAnnotation(ReflectionStrategy.class); } else { com.google.gwt.core.ext.typeinfo.JClassType type = ast.getTypeOracle().findType(finder.result.getName()); strategy = type.getAnnotation(ReflectionStrategy.class); if (strategy == null) { strategy = type.getPackage().getAnnotation(ReflectionStrategy.class); if (strategy == null) { // Nothing on the entry point or it's package; // use a default instance of the ReflectionStrategy annotation strategy = MagicClassGenerator.class.getAnnotation(ReflectionStrategy.class); } } } assert strategy != null; } } }
private void resolveType(JDeclaredType type) { assert !type.isExternal(); if (type instanceof JClassType && type.getSuperClass() != null) { ((JClassType) type).setSuperClass(translate(type.getSuperClass())); } List<JInterfaceType> resolvedInterfaces = new ArrayList<JInterfaceType>(); for (JInterfaceType intf : type.getImplements()) { resolvedInterfaces.add((JInterfaceType) translate(intf)); } List<JNode> resolvedRescues = new ArrayList<JNode>(); for (JNode node : type.getArtificialRescues()) { if (node instanceof JType) { node = translate((JType) node); } else if (node instanceof JField) { node = translate((JField) node); } else if (node instanceof JMethod) { node = translate((JMethod) node); } else { assert false : "Unknown artificial rescue node."; } resolvedRescues.add(node); } type.resolve(resolvedInterfaces, resolvedRescues); }
@Override public boolean visit(JPermutationDependentValue x, Context ctx) { JType type = x.getType(); if (type instanceof JClassType) { for (JInterfaceType iface : ((JClassType)type).getImplements()) { if (iface.getName().equals(EntryPoint.class.getName())) { pastRebound = true; break; } } } return super.visit(x, ctx); }
JDeclaredType type; if (binding.isClass()) { type = new JClassType(info, name, binding.isAbstract(), binding.isFinal()); } else if (binding.isInterface() || binding.isAnnotationType()) { type = new JInterfaceType(info, name); if (binding.isAnonymousType()) { type = new JClassType(info, name, false, true); } else { type = new JEnumType(info, name, binding.isAbstract());
@Override public boolean visit(JConstructor x, Context ctx) { if (pastRebound) { for (JMethod m : x.getEnclosingType().getMethods()) { if (m.getName().equals("createNewTestCase")) { for (JStatement statement : ((JMethodBody)m.getBody()).getBlock().getStatements()) { if (statement instanceof JIfStatement) { pastConstructor = true; ((JIfStatement)statement).getThenStmt().traverse(this, ctx); return false; } } } } } return super.visit(x, ctx); }
@Override public void endVisit(SuperReference x, BlockScope scope) { try { assert (typeMap.get(x.resolvedType) == curClass.classType.getSuperClass()); // Super refs can be modeled as a this ref. push(makeThisRef(makeSourceInfo(x))); } catch (Throwable e) { throw translateException(x, e); } }
@Override public void onUnifyAstStart(final TreeLogger logger, final UnifyAstView ast, final UnifyVisitor visitor, final Queue<JMethod> todo) { for (final JMethod method : ast.getProgram().getEntryMethods()) { if (method.getBody() instanceof JMethodBody) { final JMethodBody body = (JMethodBody) method.getBody(); // obtain the entry point final EntryPointFinder finder = findEntryPoint(logger); body.traverse(finder, finder.getContext()); // find a default strategy if (finder.result == null) { strategy = MagicClassGenerator.class.getAnnotation(ReflectionStrategy.class); } else { final com.google.gwt.core.ext.typeinfo.JClassType type = ast.getTypeOracle().findType(finder.result.getName()); strategy = type.getAnnotation(ReflectionStrategy.class); if (strategy == null) { strategy = type.getPackage().getAnnotation(ReflectionStrategy.class); if (strategy == null) { // Nothing on the entry point or it's package; // use a default instance of the ReflectionStrategy annotation strategy = MagicClassGenerator.class.getAnnotation(ReflectionStrategy.class); } } } assert strategy != null; } } }
assert (binding.superclass().isClass() || binding.superclass().isEnum()); JClassType superClass = (JClassType) typeMap.get(superClassBinding); ((JClassType) type).setSuperClass(superClass);
for (JMethod method : type.getMethods()) { flowInto(method); for (JMethod method : program.getTypeJavaLangClass().getMethods()) { if (method.isStatic() && method.getName().startsWith("createFor")) { flowInto(method);
@Override public boolean visit(JClassType x, Context ctx) { for (JInterfaceType i : x.getImplements()) { if (i.getName().equals("EntryPoint")) { if (logger.isLoggable(logLevel)) { logger.log(logLevel, "Using entry point class "+x.getName()+" for gwt-reflection module defaults"); } result = x; return false; } } return true; }
if (curClass.classType.isEnumOrSubclass() != null) {
final SourceInfo info = methodCall.getSourceInfo().makeChild(); JExpression inst = null; for (final JMethod method : uiType.getMethods()) { if ("newUi".equals(method.getName())) { inst = new JMethodCall(info, null, method);
@Override public void endVisit(JClassLiteral x, Context ctx) { JType refType = translate(x.getRefType()); x.resolve(refType); // ImplementClassLiteralsAsFields: rescue enumType.values()/valueOf(). if (refType instanceof JArrayType) { JType leafType = ((JArrayType) refType).getLeafType(); if (leafType instanceof JReferenceType) { refType = leafType; } } if (refType instanceof JClassType) { JClassType classType = (JClassType) refType; JEnumType enumType = classType.isEnumOrSubclass(); if (enumType != null) { for (JMethod method : enumType.getMethods()) { if (method.isStatic()) { if (method.getSignature().startsWith("values()")) { flowInto(method); } else if (method.getSignature().startsWith("valueOf(Ljava/lang/String;)")) { flowInto(method); } } } } } }
List<JExpression> callArgs = popCallArgs(info, x.arguments, x.binding); if (curClass.classType.isEnumOrSubclass() != null) {