2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.refactoring
.extractSuperclass
;
18 import com
.intellij
.openapi
.project
.Project
;
19 import com
.intellij
.psi
.*;
20 import com
.intellij
.refactoring
.util
.DocCommentPolicy
;
21 import com
.intellij
.refactoring
.util
.classMembers
.MemberInfo
;
22 import com
.intellij
.util
.IncorrectOperationException
;
27 public class ExtractSuperClassProcessor
extends ExtractSuperBaseProcessor
{
29 public ExtractSuperClassProcessor(Project project
,
30 PsiDirectory targetDirectory
, String newClassName
, PsiClass aClass
, MemberInfo
[] memberInfos
, boolean replaceInstanceOf
,
31 DocCommentPolicy javaDocPolicy
) {
32 super(project
, replaceInstanceOf
, targetDirectory
, newClassName
, aClass
, memberInfos
, javaDocPolicy
);
36 protected PsiClass
extractSuper(final String superClassName
) throws IncorrectOperationException
{
37 return ExtractSuperClassUtil
.extractSuperClass(myProject
, myTargetDirectory
, superClassName
, myClass
, myMemberInfos
, myJavaDocPolicy
);
40 protected boolean isSuperInheritor(PsiClass aClass
) {
41 if (!aClass
.isInterface()) {
42 return myClass
.isInheritor(aClass
, true);
45 return doesAnyExtractedInterfaceExtends(aClass
);
49 protected boolean isInSuper(PsiElement member
) {
50 if (member
instanceof PsiField
) {
51 final PsiClass containingClass
= ((PsiField
)member
).getContainingClass();
52 if (myClass
.isInheritor(containingClass
, true)) return true;
53 final PsiField field
= ((PsiField
)member
);
54 return doMemberInfosContain(field
);
56 else if (member
instanceof PsiMethod
) {
57 PsiMethod method
= (PsiMethod
) member
;
58 final PsiClass currentSuperClass
= myClass
.getSuperClass();
59 if (currentSuperClass
!= null) {
60 final PsiMethod methodBySignature
= currentSuperClass
.findMethodBySignature(method
, true);
61 if (methodBySignature
!= null) return true;
63 return doMemberInfosContain(method
);