private void parseExtends(Clazz clazz) { TypeRef[] inherits = clazz.getInterfaces(); if (inherits != null) { if (analyzed == null) { analyzed = new HashSet<TypeRef>(); } for (TypeRef typeRef : inherits) { if (!typeRef.isJava() && analyzed.add(typeRef)) { try { Clazz inherit = analyzer.findClass(typeRef); if (inherit != null) { inherit.parseClassFileWithCollector(this); parseExtends(inherit); } else { analyzer.error( "Could not obtain super class %s of class %s", typeRef.getFQN(), clazz.getClassName().getFQN()); } } catch (Exception e) { analyzer.error( "Could not obtain super class %s of class %s; exception %s", typeRef.getFQN(), clazz.getClassName().getFQN(), e.getMessage()); } } } } }
private DesignateDef getDef() throws Exception { clazz.parseClassFileWithCollector(this); if (pid != null && designate != null) { if (pids != null && pids.length > 1) { analyzer.error( "DS Component %s specifies multiple pids %s, and a Designate which requires exactly one pid", clazz.getClassName().getFQN(), Arrays.asList(pids)); return null; } TypeRef ocdClass = designate.get("ocd"); // ocdClass = ocdClass.substring(1, ocdClass.length() - 1); OCDDef ocd = classToOCDMap.get(ocdClass); if (ocd == null) { analyzer.error( "DS Component %s specifies ocd class %s which cannot be found; known classes %s", clazz.getClassName().getFQN(), ocdClass, classToOCDMap.keySet()); return null; } String id = ocd.id; boolean factoryPid = Boolean.TRUE == designate.get("factory"); if (def == null) def = new DesignateDef(finder); def.ocdRef = id; def.pid = pid; def.factory = factoryPid; ocd.designates.add(def); return def; } return null; }
private static Map<MethodDef, List<MethodDef>> buildCatalog(Collection<Clazz> sources) throws Exception { final Map<MethodDef, List<MethodDef>> catalog = new TreeMap<MethodDef, List<MethodDef>>( new Comparator<MethodDef>() { public int compare(MethodDef a, MethodDef b) { return a.getName().compareTo(b.getName()); } }); for (final Clazz clazz : sources) { clazz.parseClassFileWithCollector( new ClassDataCollector() { @Override public boolean classStart(int access, TypeRef name) { return clazz.isPublic(); } @Override public void method(MethodDef source) { if (source.isPublic() || source.isProtected()) catalog.put(source, new ArrayList<MethodDef>()); } }); } return catalog; }
private OCDDef getDef() throws Exception { clazz.parseClassFileWithCollector(this); if (ocd != null) { topLevel = false; parseExtends(clazz); doMethods(); } return ocd; }
private void parseOptionValues(Clazz c, final List<OptionDef> options) throws Exception { c.parseClassFileWithCollector( new ClassDataCollector() { @Override public void field(Clazz.FieldDef def) { if (def.isEnum()) { OptionDef o = new OptionDef(def.getName(), def.getName()); options.add(o); } } }); }
private static void crossRef( Collection<Clazz> source, final Map<MethodDef, List<MethodDef>> catalog) throws Exception { for (final Clazz clazz : source) { clazz.parseClassFileWithCollector( new ClassDataCollector() { // MethodDef source; @Override public void implementsInterfaces(TypeRef names[]) { MethodDef def = clazz.getMethodDef(0, "<implements>", "()V"); // TODO for (TypeRef interfaceName : names) { for (Map.Entry<MethodDef, List<MethodDef>> entry : catalog.entrySet()) { String catalogClass = entry.getKey().getContainingClass().getFQN(); List<MethodDef> references = entry.getValue(); if (catalogClass.equals(interfaceName.getFQN())) { references.add(def); } } } } // Method definitions @Override public void method(MethodDef source) { // this.source = source; } // TODO need to use different reference method // public void reference(MethodDef reference) { // List<MethodDef> references = catalog.get(reference); // if (references != null) { // references.add(source); // } // } }); } }