/** * Returns the members injector key for the raw type of {@code type}. * Parameterized types are not currently supported for members injection in * generated code. */ public static String rawMembersKey(TypeMirror type) { return "members/" + rawTypeToString(type, '$'); }
@Override public TypeName visitPrimitive(PrimitiveType primitiveType, Void v) { return box(primitiveType); }
private void validateProvides(Element element) { if (element.getAnnotation(Provides.class) != null && Util.getAnnotation(Module.class, element.getEnclosingElement()) == null) { error("@Provides methods must be declared in modules: " + elementToString(element), element); } }
/** Returns the provided key for {@code method}. */ public static String get(ExecutableElement method) { StringBuilder result = new StringBuilder(); AnnotationMirror qualifier = getQualifier(method.getAnnotationMirrors()); if (qualifier != null) { qualifierToString(qualifier, result); } typeToString(method.getReturnType(), result, '$'); return result.toString(); }
private CodeBlock injectsInitializer(Object[] injects) { CodeBlock.Builder result = CodeBlock.builder() .add("{ "); for (Object injectableType : injects) { TypeMirror typeMirror = (TypeMirror) injectableType; String key = isInterface(typeMirror) ? GeneratorKeys.get(typeMirror) : GeneratorKeys.rawMembersKey(typeMirror); result.add("$S, ", key); } result.add("}"); return result.build(); }
public void node(String name, String... attributes) throws IOException { name = nodeName(name); indent(); out.write(name); inlineAttributes(attributes); out.write(";\n"); }
public void beginGraph(String... attributes) throws IOException { indent(); String type = indent == 0 ? "digraph " : "subgraph "; String name = nextName(indent == 0 ? "G" : "cluster"); out.write(type); out.write(name); out.write(" {\n"); indent++; attributes(attributes); }
public void edgeDefaults(String... attributes) throws IOException { if (attributes.length == 0) return; indent(); out.write("edge"); inlineAttributes(attributes); out.write(";\n"); }
@Override public Binding<?> getAtInjectBinding( String key, String className, ClassLoader classLoader, boolean mustHaveInjections) { TypeElement type = resolveType(processingEnv.getElementUtils(), className); if (type == null) { // We've encountered a type that the compiler can't introspect. If this // causes problems in practice (due to incremental compiles, etc.) we // should return a new unresolved binding and warn about the possibility // of runtime failures. return null; } if (type.getKind() == ElementKind.INTERFACE) { return null; } return GraphAnalysisInjectBinding.create(type, mustHaveInjections); }
protected ProviderMethodBinding(String provideKey, ExecutableElement method, boolean library) { super(provideKey, method.getAnnotation(Singleton.class) != null, className(method), method.getSimpleName().toString()); this.method = method; this.parameters = new Binding[method.getParameters().size()]; setLibrary(library); }
/** Returns the provider key for {@code type}. */ public static String get(TypeMirror type) { StringBuilder result = new StringBuilder(); typeToString(type, result, '$'); return result.toString(); }
@Override public int compare(Binding<?> left, Binding<?> right) { return getStringForBinding(left).compareTo(getStringForBinding(right)); }
public void endGraph() throws IOException { indent--; indent(); out.write("}\n"); }
private void getAllElements( RoundEnvironment env, List<Element> result, Map<Element, Element> parametersToTheirMethods) { for (Element element : env.getRootElements()) { addAllEnclosed(element, result, parametersToTheirMethods); } }
/** Returns the provider key for {@code variable}. */ public static String get(VariableElement variable) { StringBuilder result = new StringBuilder(); AnnotationMirror qualifier = getQualifier(variable.getAnnotationMirrors()); if (qualifier != null) { qualifierToString(qualifier, result); } typeToString(variable.asType(), result, '$'); return result.toString(); }
public void edge(String source, String target, String... attributes) throws IOException { source = nodeName(source); target = nodeName(target); indent(); out.write(source); out.write(" -> "); out.write(target); inlineAttributes(attributes); out.write(";\n"); }
public void nodeDefaults(String... attributes) throws IOException { if (attributes.length == 0) return; indent(); out.write("node"); inlineAttributes(attributes); out.write(";\n"); }
@Override public Void visitPrimitive(PrimitiveType primitiveType, Void v) { result.append(box((PrimitiveType) type)); return null; } @Override public Void visitArray(ArrayType arrayType, Void v) {
/** Returns a string for {@code type}. Primitive types are always boxed. */ public static String typeToString(TypeMirror type) { StringBuilder result = new StringBuilder(); typeToString(type, result, '.'); return result.toString(); }
/** Returns the provided key for {@code method} wrapped by {@code Set}. */ public static String getSetKey(ExecutableElement method) { StringBuilder result = new StringBuilder(); AnnotationMirror qualifier = getQualifier(method.getAnnotationMirrors()); if (qualifier != null) { qualifierToString(qualifier, result); } result.append(SET_PREFIX); typeToString(method.getReturnType(), result, '$'); result.append(">"); return result.toString(); }