static void rawTypeToString(StringBuilder result, TypeElement type, char innerClassSeparator) { String packageName = getPackage(type).getQualifiedName().toString(); String qualifiedName = type.getQualifiedName().toString(); if (packageName.isEmpty()) { result.append(qualifiedName.replace('.', innerClassSeparator)); } else { result.append(packageName); result.append('.'); result.append( qualifiedName.substring(packageName.length() + 1).replace('.', innerClassSeparator)); } }
void writeDotFile(TypeElement module, Map<String, Binding<?>> bindings) throws IOException { JavaFileManager.Location location = StandardLocation.SOURCE_OUTPUT; String path = getPackage(module).getQualifiedName().toString(); String file = module.getQualifiedName().toString().substring(path.length() + 1) + ".dot"; FileObject resource = processingEnv.getFiler().createResource(location, path, file, module); Writer writer = resource.openWriter(); GraphVizWriter dotWriter = new GraphVizWriter(writer); new GraphVisualizer().write(bindings, dotWriter); dotWriter.close(); }
/** * Write a companion class for {@code type} that extends {@link StaticInjection}. */ private void generateStaticInjection(TypeElement type, List<Element> fields) throws IOException { ClassName typeName = ClassName.get(type); ClassName adapterClassName = adapterName(ClassName.get(type), STATIC_INJECTION_SUFFIX); TypeSpec.Builder result = TypeSpec.classBuilder(adapterClassName.simpleName()) .addOriginatingElement(type) .addJavadoc(AdapterJavadocs.STATIC_INJECTION_TYPE, type) .addModifiers(PUBLIC, FINAL) .superclass(StaticInjection.class); for (Element field : fields) { result.addField(memberBindingField(false, field)); } result.addMethod(attachMethod(null, fields, false, typeName, null, true)); result.addMethod(staticInjectMethod(fields, typeName)); String packageName = getPackage(type).getQualifiedName().toString(); JavaFile javaFile = JavaFile.builder(packageName, result.build()) .addFileComment(AdapterJavadocs.GENERATED_BY_DAGGER) .build(); javaFile.writeTo(processingEnv.getFiler()); }
String packageName = getPackage(type).getQualifiedName().toString(); TypeMirror supertype = getApplicationSupertype(type); if (supertype != null) {