clean: simplify method and move duplicates to upper class

GitOrigin-RevId: c542568e7d50b00df6fa00668a31537462a8dc51
This commit is contained in:
Alexandr Suhinin
2020-04-24 14:29:14 +03:00
committed by intellij-monorepo-bot
parent e2e7ecd91e
commit 3edf214b65
2 changed files with 5 additions and 17 deletions

View File

@@ -48,7 +48,11 @@ public abstract class DuplicatesProfile {
return null;
}
public abstract boolean isMyDuplicate(@NotNull DupInfo info, int index);
public boolean isMyDuplicate(@NotNull DupInfo info, int index) {
PsiFragment[] fragments = info.getFragmentOccurences(index);
Language language = fragments.length > 0 ? fragments[0].getLanguage() : null;
return language != null && isMyLanguage(language);
}
public boolean supportIndex() {
return true;
@@ -95,7 +99,6 @@ public abstract class DuplicatesProfile {
return null;
}
@Nullable
public static DuplicatesProfile findProfileForDuplicate(@NotNull DupInfo dupInfo, int index) {
for (DuplicatesProfile profile : EP_NAME.getExtensionList()) {

View File

@@ -30,19 +30,4 @@ public abstract class DuplicatesProfileBase extends DuplicatesProfile {
return DuplocatorUtil.registerAndGetState(language);
}
@Override
public boolean isMyDuplicate(@NotNull DupInfo info, int index) {
PsiFragment[] fragments = info.getFragmentOccurences(index);
if (fragments.length > 0) {
PsiElement[] elements = fragments[0].getElements();
if (elements.length > 0) {
final PsiElement first = elements[0];
if (first != null) {
Language language = first.getLanguage();
return isMyLanguage(language);
}
}
}
return false;
}
}