Refactoring: Extract method

This commit is contained in:
Alexey Sedunov
2014-01-23 16:26:54 +04:00
parent c137167290
commit 1e7297015a
@@ -121,25 +121,13 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
JetProperty property = (JetProperty) element; JetProperty property = (JetProperty) element;
if (property.isLocal()) return findKotlinDeclarationUsages(property, allElementsToDelete, result); if (property.isLocal()) return findKotlinDeclarationUsages(property, allElementsToDelete, result);
return new NonCodeUsageSearchInfo( return delegateToJavaProcessor(property, allElementsToDelete, result);
delegateToJavaProcessorAndCombineConditions(
LightClassUtil.getLightClassPropertyMethods(property),
getCondition(Arrays.asList(allElementsToDelete)),
allElementsToDelete,
result
),
element
);
} }
if (element instanceof JetTypeParameter) { if (element instanceof JetTypeParameter) {
Condition<PsiElement> insideDeleted = delegateToJavaProcessorAndCombineConditions( JetTypeParameter typeParameter = (JetTypeParameter) element;
AsJavaPackage.toPsiTypeParameters((JetTypeParameter) element),
getCondition(Arrays.asList(allElementsToDelete)), findTypeParameterUsages(typeParameter, result);
allElementsToDelete, return delegateToJavaProcessor(typeParameter, allElementsToDelete, result);
result
);
findTypeParameterUsages((JetTypeParameter) element, result);
return new NonCodeUsageSearchInfo(insideDeleted, element);
} }
if (element instanceof JetParameter) { if (element instanceof JetParameter) {
JetParameter jetParameter = (JetParameter) element; JetParameter jetParameter = (JetParameter) element;
@@ -155,6 +143,22 @@ public class KotlinSafeDeleteProcessor extends JavaSafeDeleteProcessor {
return getSearchInfo(element, allElementsToDelete); return getSearchInfo(element, allElementsToDelete);
} }
private NonCodeUsageSearchInfo delegateToJavaProcessor(
JetDeclaration jetDeclaration,
PsiElement[] allElementsToDelete,
List<UsageInfo> result
) {
return new NonCodeUsageSearchInfo(
delegateToJavaProcessorAndCombineConditions(
AsJavaPackage.toLightElements(jetDeclaration),
getCondition(Arrays.asList(allElementsToDelete)),
allElementsToDelete,
result
),
jetDeclaration
);
}
private Condition<PsiElement> delegateToJavaProcessorAndCombineConditions( private Condition<PsiElement> delegateToJavaProcessorAndCombineConditions(
Iterable<? extends PsiElement> elements, Iterable<? extends PsiElement> elements,
Condition<PsiElement> insideDeleted, Condition<PsiElement> insideDeleted,