Package dagger.hilt.processor.internal
Class Processors
java.lang.Object
dagger.hilt.processor.internal.Processors
Static helper methods for writing a processor.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, Class<?> generatorClass) static voidaddGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, String generatorClass) static com.squareup.javapoet.ClassNameAppends the given string to the end of the class name.static com.squareup.javapoet.MethodSpec.BuildercopyMethodSpecWithoutBody(com.squareup.javapoet.MethodSpec methodSpec) static voidgenerateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass) Generates the aggregating metadata class for an aggregating annotation.static voidgenerateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass, androidx.room.compiler.processing.XFiler.Mode mode) Generates the aggregating metadata class for an aggregating annotation.static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement>getAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key) Returns a list ofXTypeElements for a class attribute on an annotation.static com.google.common.collect.ImmutableMap<String,androidx.room.compiler.processing.XAnnotationValue> getAnnotationValues(androidx.room.compiler.processing.XAnnotation annotation) Returns a map fromXAnnotationattribute name toXAnnotationValuesstatic com.squareup.javapoet.ClassNamegetEnclosedClassName(androidx.room.compiler.processing.XTypeElement typeElement) Returns an equivalent class name with the.(dots) used for inner classes replaced with_.static com.squareup.javapoet.ClassNamegetEnclosedClassName(com.squareup.javapoet.ClassName className) Returns an equivalent class name with the.(dots) used for inner classes replaced with_.static StringgetEnclosedName(com.squareup.javapoet.ClassName name) Returns the name of a class, including prefixing with enclosing class names.static StringgetFullEnclosedName(androidx.room.compiler.processing.XElement element) Returns the fully qualified class name, with _ instead of .static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation>getMapKeyAnnotations(androidx.room.compiler.processing.XElement element) Returns MapKey annotated annotations found on an element.static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement>getOptionalAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key) static com.squareup.javapoet.AnnotationSpecgetOriginatingElementAnnotation(androidx.room.compiler.processing.XTypeElement element) static Optional<androidx.room.compiler.processing.XTypeElement>getOriginatingTestElement(androidx.room.compiler.processing.XElement element) static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation>getQualifierAnnotations(androidx.room.compiler.processing.XElement element) Returns Qualifier annotated annotations found on an element.static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation>getScopeAnnotations(androidx.room.compiler.processing.XElement element) Returns Scope annotated annotations found on an element.static androidx.room.compiler.processing.XTypeElementgetTopLevelType(androidx.room.compiler.processing.XElement originalElement) static booleanhasAnnotation(Element element, com.squareup.javapoet.ClassName className) Returns true if the given element has an annotation with the given class name.static booleanhasDaggerAbstractMethodAnnotation(androidx.room.compiler.processing.XExecutableElement method) Returns true if the given method is annotated with one of the annotations Dagger recognizes for abstract methods (e.g.static booleanhasErrorTypeAnnotation(androidx.room.compiler.processing.XElement element) Returns true if the given element has an annotation that is an error kind.static booleanhasJavaPackagePrivateVisibility(androidx.room.compiler.processing.XHasModifiers element) static booleanhasVisibleEmptyConstructor(androidx.room.compiler.processing.XTypeElement type) static booleanisAssignableFrom(androidx.room.compiler.processing.XTypeElement element, com.squareup.javapoet.ClassName className) Returnstrueif element inherits directly or indirectly from the className.static booleanisAssignableFromAnyOf(androidx.room.compiler.processing.XTypeElement element, com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> classNames) Returnstrueif element inherits directly or indirectly from any of the classNames.static booleanisTopLevel(androidx.room.compiler.processing.XElement element) static com.squareup.javapoet.ClassNamePrepends the given string to the beginning of the class name.static com.squareup.javapoet.TypeNamerawTypeName(com.squareup.javapoet.TypeName typeName) Returns theTypeNamefor the raw type of the given type name.static com.squareup.javapoet.ClassNameremoveNameSuffix(androidx.room.compiler.processing.XTypeElement type, String suffix) Removes the stringsuffixfrom the simple name oftypeand returns it.static booleanrequiresModuleInstance(androidx.room.compiler.processing.XTypeElement module) static StringupperToLowerCamel(String upperCamel) Shortcut for converting from upper camel to lower camel case
-
Field Details
-
CONSTRUCTOR_NAME
- See Also:
-
STATIC_INITIALIZER_NAME
- See Also:
-
-
Method Details
-
generateAggregatingClass
public static void generateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass) Generates the aggregating metadata class for an aggregating annotation. -
generateAggregatingClass
public static void generateAggregatingClass(String aggregatingPackage, com.squareup.javapoet.AnnotationSpec aggregatingAnnotation, androidx.room.compiler.processing.XTypeElement originatingElement, Class<?> generatorClass, androidx.room.compiler.processing.XFiler.Mode mode) Generates the aggregating metadata class for an aggregating annotation. -
getAnnotationValues
public static com.google.common.collect.ImmutableMap<String,androidx.room.compiler.processing.XAnnotationValue> getAnnotationValues(androidx.room.compiler.processing.XAnnotation annotation) Returns a map fromXAnnotationattribute name toXAnnotationValues -
getAnnotationClassValues
public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement> getAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key) Returns a list ofXTypeElements for a class attribute on an annotation. -
getOptionalAnnotationClassValues
public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XTypeElement> getOptionalAnnotationClassValues(androidx.room.compiler.processing.XAnnotation annotation, String key) -
getTopLevelType
public static androidx.room.compiler.processing.XTypeElement getTopLevelType(androidx.room.compiler.processing.XElement originalElement) -
isTopLevel
public static boolean isTopLevel(androidx.room.compiler.processing.XElement element) -
hasAnnotation
Returns true if the given element has an annotation with the given class name. -
hasErrorTypeAnnotation
public static boolean hasErrorTypeAnnotation(androidx.room.compiler.processing.XElement element) Returns true if the given element has an annotation that is an error kind. -
getEnclosedName
Returns the name of a class, including prefixing with enclosing class names. i.e. for inner class Foo enclosed by Bar, returns Bar_Foo instead of just Foo -
getEnclosedClassName
public static com.squareup.javapoet.ClassName getEnclosedClassName(com.squareup.javapoet.ClassName className) Returns an equivalent class name with the.(dots) used for inner classes replaced with_. -
getEnclosedClassName
public static com.squareup.javapoet.ClassName getEnclosedClassName(androidx.room.compiler.processing.XTypeElement typeElement) Returns an equivalent class name with the.(dots) used for inner classes replaced with_. -
getFullEnclosedName
Returns the fully qualified class name, with _ instead of . For elements that are not type elements, this continues to append the simple name of elements. For example, foo_bar_Outer_Inner_fooMethod. -
append
public static com.squareup.javapoet.ClassName append(com.squareup.javapoet.ClassName name, String suffix) Appends the given string to the end of the class name. -
prepend
public static com.squareup.javapoet.ClassName prepend(com.squareup.javapoet.ClassName name, String prefix) Prepends the given string to the beginning of the class name. -
removeNameSuffix
public static com.squareup.javapoet.ClassName removeNameSuffix(androidx.room.compiler.processing.XTypeElement type, String suffix) Removes the stringsuffixfrom the simple name oftypeand returns it.- Throws:
BadInputException- if the simple name oftypedoes not end withsuffix
-
isAssignableFrom
public static boolean isAssignableFrom(androidx.room.compiler.processing.XTypeElement element, com.squareup.javapoet.ClassName className) Returnstrueif element inherits directly or indirectly from the className. -
isAssignableFromAnyOf
public static boolean isAssignableFromAnyOf(androidx.room.compiler.processing.XTypeElement element, com.google.common.collect.ImmutableSet<com.squareup.javapoet.ClassName> classNames) Returnstrueif element inherits directly or indirectly from any of the classNames. -
getMapKeyAnnotations
public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation> getMapKeyAnnotations(androidx.room.compiler.processing.XElement element) Returns MapKey annotated annotations found on an element. -
getQualifierAnnotations
public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation> getQualifierAnnotations(androidx.room.compiler.processing.XElement element) Returns Qualifier annotated annotations found on an element. -
getScopeAnnotations
public static com.google.common.collect.ImmutableList<androidx.room.compiler.processing.XAnnotation> getScopeAnnotations(androidx.room.compiler.processing.XElement element) Returns Scope annotated annotations found on an element. -
upperToLowerCamel
Shortcut for converting from upper camel to lower camel caseExample: "SomeString" => "someString"
-
copyMethodSpecWithoutBody
public static com.squareup.javapoet.MethodSpec.Builder copyMethodSpecWithoutBody(com.squareup.javapoet.MethodSpec methodSpec) - Returns:
- copy of the given MethodSpec as
MethodSpec.Builderwith method body removed
-
hasDaggerAbstractMethodAnnotation
public static boolean hasDaggerAbstractMethodAnnotation(androidx.room.compiler.processing.XExecutableElement method) Returns true if the given method is annotated with one of the annotations Dagger recognizes for abstract methods (e.g. @Binds). -
requiresModuleInstance
public static boolean requiresModuleInstance(androidx.room.compiler.processing.XTypeElement module) -
hasVisibleEmptyConstructor
public static boolean hasVisibleEmptyConstructor(androidx.room.compiler.processing.XTypeElement type) -
addGeneratedAnnotation
public static void addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, Class<?> generatorClass) -
addGeneratedAnnotation
public static void addGeneratedAnnotation(com.squareup.javapoet.TypeSpec.Builder typeSpecBuilder, androidx.room.compiler.processing.XProcessingEnv env, String generatorClass) -
getOriginatingElementAnnotation
public static com.squareup.javapoet.AnnotationSpec getOriginatingElementAnnotation(androidx.room.compiler.processing.XTypeElement element) -
rawTypeName
public static com.squareup.javapoet.TypeName rawTypeName(com.squareup.javapoet.TypeName typeName) Returns theTypeNamefor the raw type of the given type name. If the argument isn't a parameterized type, it returns the argument unchanged. -
getOriginatingTestElement
public static Optional<androidx.room.compiler.processing.XTypeElement> getOriginatingTestElement(androidx.room.compiler.processing.XElement element) -
hasJavaPackagePrivateVisibility
public static boolean hasJavaPackagePrivateVisibility(androidx.room.compiler.processing.XHasModifiers element)
-