mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Added registry key "Highlight duplicate code only when it can be extracted into a method" (IDEA-175727)
This commit is contained in:
+8
-1
@@ -33,6 +33,7 @@ import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.roots.TestSourcesFilter;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWithId;
|
||||
@@ -109,8 +110,14 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
|
||||
|
||||
int hash2 = (int)(hash >> 32);
|
||||
LocalQuickFix viewAllDupesFix = isOnTheFly && hash != 0 ? createShowOtherDupesFix(virtualFile, offset, (int)hash, hash2) : null;
|
||||
|
||||
boolean onlyExtractable = Registry.is("duplicates.inspection.only.extractable");
|
||||
LocalQuickFix extractMethodFix =
|
||||
isOnTheFly && hash != 0 ? createExtractMethodFix(targetElement, rangeInElement, (int)hash, hash2) : null;
|
||||
(isOnTheFly || onlyExtractable) && hash != 0 ? createExtractMethodFix(targetElement, rangeInElement, (int)hash, hash2) : null;
|
||||
if (onlyExtractable) {
|
||||
if (extractMethodFix == null) return null;
|
||||
if (!isOnTheFly) extractMethodFix = null;
|
||||
}
|
||||
|
||||
ProblemDescriptor descriptor = manager
|
||||
.createProblemDescriptor(targetElement, rangeInElement, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly, fix,
|
||||
|
||||
@@ -1227,3 +1227,6 @@ batch.inspections.process.by.default.jvm.languages.description=When building gra
|
||||
|
||||
junit4.search.4.tests.in.classpath=true
|
||||
junit4.search.4.tests.in.classpath.description=Search for tests in the module output
|
||||
|
||||
duplicates.inspection.only.extractable=false
|
||||
duplicates.inspection.only.extractable.description=Highlight duplicate code only if it can be extracted into a method
|
||||
|
||||
Reference in New Issue
Block a user