diff --git a/tools/ideabuck/src/com/facebook/buck/intellij/ideabuck/autodeps/BuckAutoDepsQuickFixProvider.java b/tools/ideabuck/src/com/facebook/buck/intellij/ideabuck/autodeps/BuckAutoDepsQuickFixProvider.java index 3ab1c25556b..635fe0ff821 100644 --- a/tools/ideabuck/src/com/facebook/buck/intellij/ideabuck/autodeps/BuckAutoDepsQuickFixProvider.java +++ b/tools/ideabuck/src/com/facebook/buck/intellij/ideabuck/autodeps/BuckAutoDepsQuickFixProvider.java @@ -43,30 +43,37 @@ public class BuckAutoDepsQuickFixProvider private static Logger LOGGER = Logger.getInstance(BuckAutoDepsQuickFixProvider.class); + private static final String KEEP_DEFAULT_AUTODEPS = "ideabuck.quickfix.autodeps.showdefault"; + @Override public void registerFixes( @NotNull PsiJavaCodeReferenceElement referenceElement, @NotNull QuickFixActionRegistrar quickFixActionRegistrar) { List fixes = findFixesForReference(referenceElement); fixes.forEach(quickFixActionRegistrar::register); - if (!fixes.isEmpty()) { - // If we think we can add both a Buck dependency and an IntelliJ module dependency, - // unregister the default fix, which only adds an IntelliJ module dependency. - quickFixActionRegistrar.unregister( - new Condition() { - private static final String ADD_MODULE_DEPENDENCY_FIX_CLASSNAME = - "com.intellij.codeInsight.daemon.impl.quickfix.AddModuleDependencyFix"; + if (fixes.isEmpty() || Boolean.parseBoolean(System.getProperty(KEEP_DEFAULT_AUTODEPS))) { + // Don't unregister the default if: + // 1) We can't replace it with anything. + // 2) The user has requested to keep it. + return; + } - @Override - public boolean value(IntentionAction intentionAction) { - String className = intentionAction.getClass().getName(); - if (ADD_MODULE_DEPENDENCY_FIX_CLASSNAME.equals(className)) { - return true; - } - return false; + // If we think we can add both a Buck dependency and an IntelliJ module dependency, + // unregister the default fix, which only adds an IntelliJ module dependency. + quickFixActionRegistrar.unregister( + new Condition() { + private static final String ADD_MODULE_DEPENDENCY_FIX_CLASSNAME = + "com.intellij.codeInsight.daemon.impl.quickfix.AddModuleDependencyFix"; + + @Override + public boolean value(IntentionAction intentionAction) { + String className = intentionAction.getClass().getName(); + if (ADD_MODULE_DEPENDENCY_FIX_CLASSNAME.equals(className)) { + return true; } - }); - } + return false; + } + }); } private List findFixesForReference(