Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ abstract class CompilerOptions {
abstract Diagnostic.Kind staticMemberValidationKind();
abstract boolean ignorePrivateAndStaticInjectionForComponent();
abstract ValidationType scopeCycleValidationType();
abstract boolean useFormattingFiler();

static Builder builder() {
return new AutoValue_CompilerOptions.Builder();
Expand All @@ -56,6 +57,7 @@ static CompilerOptions create(ProcessingEnvironment processingEnv, Elements elem
ignorePrivateAndStaticInjectionForComponent(processingEnv)
.equals(FeatureStatus.DISABLED))
.scopeCycleValidationType(scopeValidationType(processingEnv))
.useFormattingFiler(useFormattingFiler(processingEnv).equals(FeatureStatus.ENABLED))
.build();
}

Expand All @@ -69,11 +71,19 @@ interface Builder {
Builder ignorePrivateAndStaticInjectionForComponent(
boolean ignorePrivateAndStaticInjectionForComponent);
Builder scopeCycleValidationType(ValidationType type);
Builder useFormattingFiler(boolean useFormattingFiler);
CompilerOptions build();
}

static final String WRITE_PRODUCER_NAME_IN_TOKEN_KEY = "dagger.writeProducerNameInToken";

/**
* If true, Dagger will format generated code using a FormattingFiler.
*
* <p>This defaults to true, but can be useful for reducing compile times.
*/
static final String USE_FORMATTING_FILER = "dagger.useFormattingFiler";

static final String DISABLE_INTER_COMPONENT_SCOPE_VALIDATION_KEY =
"dagger.disableInterComponentScopeValidation";

Expand All @@ -99,7 +109,8 @@ Builder ignorePrivateAndStaticInjectionForComponent(
NULLABLE_VALIDATION_KEY,
PRIVATE_MEMBER_VALIDATION_TYPE_KEY,
STATIC_MEMBER_VALIDATION_TYPE_KEY,
IGNORE_PRIVATE_AND_STATIC_INJECTION_FOR_COMPONENT);
IGNORE_PRIVATE_AND_STATIC_INJECTION_FOR_COMPONENT,
USE_FORMATTING_FILER);

private static FeatureStatus writeProducerNameInToken(ProcessingEnvironment processingEnv) {
return valueOf(
Expand All @@ -117,6 +128,14 @@ private static ValidationType scopeValidationType(ProcessingEnvironment processi
EnumSet.allOf(ValidationType.class));
}

private static FeatureStatus useFormattingFiler(ProcessingEnvironment processingEnv) {
return valueOf(
processingEnv,
USE_FORMATTING_FILER,
FeatureStatus.ENABLED,
EnumSet.allOf(FeatureStatus.class));
}

private static ValidationType nullableValidationType(ProcessingEnvironment processingEnv) {
return valueOf(
processingEnv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ protected Iterable<? extends ProcessingStep> initSteps() {
Types types = processingEnv.getTypeUtils();
Elements elements = processingEnv.getElementUtils();
CompilerOptions compilerOptions = CompilerOptions.create(processingEnv, elements);
Filer filer = new FormattingFiler(processingEnv.getFiler());

Filer filer = compilerOptions.useFormattingFiler()
? new FormattingFiler(processingEnv.getFiler())
: processingEnv.getFiler();

KeyFormatter keyFormatter = new KeyFormatter();
MethodSignatureFormatter methodSignatureFormatter = new MethodSignatureFormatter(types);
Expand Down