public boolean isJavaScriptObject(JClassType type) { if (type == null) { return false; } if (JProgram.JAVASCRIPTOBJECT.equals(type.getName())) { return true; } return isJavaScriptObject(type.getSuperClass()); }
@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; }
@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; }
@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; } } }
@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; } } }