Extract interface out of JavaClassifier

This commit is contained in:
Alexander Udalov
2013-08-19 16:40:52 +04:00
parent 4f99cb6999
commit 912d3426a4
5 changed files with 48 additions and 22 deletions
@@ -31,7 +31,7 @@ import java.util.Collection;
import static org.jetbrains.jet.lang.resolve.java.structure.JavaElementCollectionFromPsiArrayUtil.*;
public class JavaClass extends JavaClassifier
public class JavaClass extends JavaClassifierImpl
implements JavaNamedElement, JavaTypeParameterListOwner, JavaModifierListOwner, JavaAnnotationOwner {
public enum OriginKind {
COMPILED,
@@ -17,27 +17,10 @@
package org.jetbrains.jet.lang.resolve.java.structure;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiTypeParameter;
import org.jetbrains.annotations.NotNull;
public abstract class JavaClassifier extends JavaElementImpl {
protected JavaClassifier(@NotNull PsiClass psiClass) {
super(psiClass);
}
public interface JavaClassifier extends JavaElement {
@NotNull
@Override
public PsiClass getPsi() {
return (PsiClass) super.getPsi();
}
@NotNull
public static JavaClassifier create(@NotNull PsiClass psiClass) {
if (psiClass instanceof PsiTypeParameter) {
return new JavaTypeParameter((PsiTypeParameter) psiClass);
}
else {
return new JavaClass(psiClass);
}
}
PsiClass getPsi();
}
@@ -0,0 +1,43 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.java.structure;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiTypeParameter;
import org.jetbrains.annotations.NotNull;
public abstract class JavaClassifierImpl extends JavaElementImpl implements JavaClassifier {
protected JavaClassifierImpl(@NotNull PsiClass psiClass) {
super(psiClass);
}
@NotNull
@Override
public PsiClass getPsi() {
return (PsiClass) super.getPsi();
}
@NotNull
/* package */ static JavaClassifier create(@NotNull PsiClass psiClass) {
if (psiClass instanceof PsiTypeParameter) {
return new JavaTypeParameter((PsiTypeParameter) psiClass);
}
else {
return new JavaClass(psiClass);
}
}
}
@@ -69,7 +69,7 @@ public class JavaClassifierType extends JavaType {
PsiClassType.ClassResolveResult result = getPsi().resolveGenerics();
PsiClass psiClass = result.getElement();
resolutionResult = new ResolutionResult(
psiClass == null ? null : JavaClassifier.create(psiClass),
psiClass == null ? null : JavaClassifierImpl.create(psiClass),
new JavaTypeSubstitutor(result.getSubstitutor())
);
}
@@ -28,7 +28,7 @@ import java.util.Collection;
import static org.jetbrains.jet.lang.resolve.java.structure.JavaElementCollectionFromPsiArrayUtil.classifierTypes;
public class JavaTypeParameter extends JavaClassifier implements JavaNamedElement {
public class JavaTypeParameter extends JavaClassifierImpl implements JavaNamedElement {
public JavaTypeParameter(@NotNull PsiTypeParameter psiTypeParameter) {
super(psiTypeParameter);
}