update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / psi / impl / compiled / ClsTypeParameterImpl.java
blobe2eb663e429555f0b0cd349b9e3f6105539f618f
1 /*
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.psi.impl.compiled;
18 import com.intellij.openapi.diagnostic.Logger;
19 import com.intellij.openapi.util.Pair;
20 import com.intellij.psi.*;
21 import com.intellij.psi.impl.InheritanceImplUtil;
22 import com.intellij.psi.impl.PsiClassImplUtil;
23 import com.intellij.psi.impl.PsiSuperMethodImplUtil;
24 import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
25 import com.intellij.psi.impl.java.stubs.PsiTypeParameterStub;
26 import com.intellij.psi.impl.light.LightEmptyImplementsList;
27 import com.intellij.psi.impl.meta.MetaRegistry;
28 import com.intellij.psi.impl.source.SourceTreeToPsiMap;
29 import com.intellij.psi.impl.source.tree.TreeElement;
30 import com.intellij.psi.javadoc.PsiDocComment;
31 import com.intellij.psi.meta.PsiMetaData;
32 import com.intellij.psi.scope.PsiScopeProcessor;
33 import com.intellij.psi.search.SearchScope;
34 import com.intellij.util.IncorrectOperationException;
35 import org.jetbrains.annotations.NonNls;
36 import org.jetbrains.annotations.NotNull;
38 import javax.swing.*;
39 import java.util.Collection;
40 import java.util.List;
42 /**
43 * @author max
45 public class ClsTypeParameterImpl extends ClsRepositoryPsiElement<PsiTypeParameterStub> implements PsiTypeParameter {
46 private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsTypeParameterImpl");
47 static final ClsTypeParameterImpl[] EMPTY_ARRAY = new ClsTypeParameterImpl[0];
48 private final LightEmptyImplementsList myLightEmptyImplementsList;
50 public ClsTypeParameterImpl(final PsiTypeParameterStub stub) {
51 super(stub);
52 myLightEmptyImplementsList = new LightEmptyImplementsList(getManager());
55 public String getQualifiedName() {
56 return null;
59 public boolean isInterface() {
60 return false;
63 public boolean isAnnotationType() {
64 return false;
67 public boolean isEnum() {
68 return false;
71 @NotNull
72 public PsiField[] getFields() {
73 return PsiField.EMPTY_ARRAY;
76 @NotNull
77 public PsiMethod[] getMethods() {
78 return PsiMethod.EMPTY_ARRAY;
81 public PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases) {
82 return PsiClassImplUtil.findMethodBySignature(this, patternMethod, checkBases);
85 @NotNull
86 public PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases) {
87 return PsiClassImplUtil.findMethodsBySignature(this, patternMethod, checkBases);
90 public PsiField findFieldByName(String name, boolean checkBases) {
91 return PsiClassImplUtil.findFieldByName(this, name, checkBases);
94 @NotNull
95 public PsiMethod[] findMethodsByName(String name, boolean checkBases) {
96 return PsiClassImplUtil.findMethodsByName(this, name, checkBases);
99 @NotNull
100 public List<Pair<PsiMethod, PsiSubstitutor>> findMethodsAndTheirSubstitutorsByName(String name, boolean checkBases) {
101 return PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases);
104 @NotNull
105 public List<Pair<PsiMethod, PsiSubstitutor>> getAllMethodsAndTheirSubstitutors() {
106 return PsiClassImplUtil.getAllWithSubstitutorsByMap(this, PsiMethod.class);
109 public PsiClass findInnerClassByName(String name, boolean checkBases) {
110 return PsiClassImplUtil.findInnerByName(this, name, checkBases);
113 public PsiTypeParameterList getTypeParameterList() {
114 return null;
117 public boolean hasTypeParameters() {
118 return false;
121 // very special method!
122 public PsiElement getScope() {
123 return getParent().getParent();
126 public boolean isInheritorDeep(PsiClass baseClass, PsiClass classToByPass) {
127 return InheritanceImplUtil.isInheritorDeep(this, baseClass, classToByPass);
130 public boolean isInheritor(@NotNull PsiClass baseClass, boolean checkDeep) {
131 return InheritanceImplUtil.isInheritor(this, baseClass, checkDeep);
134 public PsiIdentifier getNameIdentifier() {
135 return null;
138 public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
139 return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, false);
142 public String getName() {
143 return getStub().getName();
146 public PsiElement setName(@NotNull String name) throws IncorrectOperationException {
147 throw new IncorrectOperationException("Cannot change compiled classes");
150 @NotNull
151 public PsiMethod[] getConstructors() {
152 return PsiMethod.EMPTY_ARRAY;
155 public PsiDocComment getDocComment() {
156 return null;
159 public boolean isDeprecated() {
160 return false;
163 @NotNull
164 public PsiReferenceList getExtendsList() {
165 return getStub().findChildStubByType(JavaStubElementTypes.EXTENDS_BOUND_LIST).getPsi();
168 public PsiReferenceList getImplementsList() {
169 return myLightEmptyImplementsList;
172 @NotNull
173 public PsiClassType[] getExtendsListTypes() {
174 return getExtendsList().getReferencedTypes();
177 @NotNull
178 public PsiClassType[] getImplementsListTypes() {
179 return PsiClassType.EMPTY_ARRAY;
182 @NotNull
183 public PsiClass[] getInnerClasses() {
184 return PsiClass.EMPTY_ARRAY;
187 @NotNull
188 public PsiField[] getAllFields() {
189 return PsiField.EMPTY_ARRAY;
192 @NotNull
193 public PsiMethod[] getAllMethods() {
194 return PsiMethod.EMPTY_ARRAY;
197 @NotNull
198 public PsiClass[] getAllInnerClasses() {
199 return PsiClass.EMPTY_ARRAY;
202 @NotNull
203 public PsiClassInitializer[] getInitializers() {
204 return PsiClassInitializer.EMPTY_ARRAY;
207 @NotNull
208 public PsiTypeParameter[] getTypeParameters() {
209 return PsiTypeParameter.EMPTY_ARRAY;
212 public PsiClass getSuperClass() {
213 return PsiClassImplUtil.getSuperClass(this);
216 public PsiClass[] getInterfaces() {
217 return PsiClassImplUtil.getInterfaces(this);
220 @NotNull
221 public PsiClass[] getSupers() {
222 return PsiClassImplUtil.getSupers(this);
225 @NotNull
226 public PsiClassType[] getSuperTypes() {
227 return PsiClassImplUtil.getSuperTypes(this);
230 public PsiClass getContainingClass() {
231 return null;
234 @NotNull
235 public Collection<HierarchicalMethodSignature> getVisibleSignatures() {
236 return PsiSuperMethodImplUtil.getVisibleSignatures(this);
239 public PsiModifierList getModifierList() {
240 return null;
243 public boolean hasModifierProperty(@NotNull String name) {
244 return false;
247 public PsiJavaToken getLBrace() {
248 return null;
251 public PsiJavaToken getRBrace() {
252 return null;
255 public void accept(@NotNull PsiElementVisitor visitor) {
256 if (visitor instanceof JavaElementVisitor) {
257 ((JavaElementVisitor)visitor).visitTypeParameter(this);
259 else {
260 visitor.visitElement(this);
264 @NonNls
265 public String toString() {
266 return "PsiTypeParameter";
269 public void appendMirrorText(final int indentLevel, @NonNls final StringBuffer buffer) {
270 buffer.append(getName());
271 PsiJavaCodeReferenceElement[] bounds = getExtendsList().getReferenceElements();
272 if (bounds.length > 0) {
273 buffer.append(" extends ");
274 for (int i = 0; i < bounds.length; i++) {
275 PsiJavaCodeReferenceElement bound = bounds[i];
276 if (i > 0) buffer.append(" & ");
277 buffer.append(bound.getCanonicalText());
282 public void setMirror(@NotNull TreeElement element) {
283 setMirrorCheckingType(element, null);
285 PsiTypeParameter mirror = (PsiTypeParameter)SourceTreeToPsiMap.treeElementToPsi(element);
286 ((ClsReferenceListImpl)getExtendsList()).setMirror((TreeElement)SourceTreeToPsiMap.psiElementToTree(mirror.getExtendsList()));
289 @NotNull
290 public PsiElement[] getChildren() {
291 return PsiElement.EMPTY_ARRAY;
294 public PsiTypeParameterListOwner getOwner() {
295 return (PsiTypeParameterListOwner)getParent().getParent();
299 public int getIndex() {
300 final PsiTypeParameterStub st = getStub();
301 return st.getParentStub().getChildrenStubs().indexOf(st);
304 public PsiMetaData getMetaData() {
305 return MetaRegistry.getMeta(this);
308 public Icon getElementIcon(final int flags) {
309 return PsiClassImplUtil.getClassIcon(flags, this);
312 @Override
313 public boolean isEquivalentTo(final PsiElement another) {
314 return PsiClassImplUtil.isClassEquivalentTo(this, another);
317 @NotNull
318 public SearchScope getUseScope() {
319 return PsiClassImplUtil.getClassUseScope(this);
322 //todo parse annotataions
323 @NotNull
324 public PsiAnnotation[] getAnnotations() {
325 return PsiAnnotation.EMPTY_ARRAY;
328 public PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) {
329 return null;
332 @NotNull
333 public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
334 throw new IncorrectOperationException();
336 @NotNull
337 public PsiAnnotation[] getApplicableAnnotations() {
338 return getAnnotations();