update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / psi / impl / light / LightMethod.java
blob1e493e1b6d9a6083022d71b04e3fe6af7f26f5d7
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.light;
18 import com.intellij.psi.*;
19 import com.intellij.psi.impl.ElementPresentationUtil;
20 import com.intellij.psi.impl.PsiClassImplUtil;
21 import com.intellij.psi.impl.PsiImplUtil;
22 import com.intellij.psi.javadoc.PsiDocComment;
23 import com.intellij.psi.search.SearchScope;
24 import com.intellij.psi.util.MethodSignature;
25 import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
26 import com.intellij.ui.RowIcon;
27 import com.intellij.util.Icons;
28 import com.intellij.util.IncorrectOperationException;
29 import com.intellij.openapi.fileTypes.StdFileTypes;
30 import org.jetbrains.annotations.NotNull;
32 import javax.swing.*;
33 import java.util.List;
35 /**
36 * @author ven
38 public class LightMethod extends LightElement implements PsiMethod {
39 private final PsiMethod myMethod;
40 private final PsiClass myContainingClass;
42 public LightMethod(PsiManager manager, PsiMethod method, PsiClass containingClass) {
43 super(manager, StdFileTypes.JAVA.getLanguage());
44 myMethod = method;
45 myContainingClass = containingClass;
49 public boolean hasTypeParameters() {
50 return myMethod.hasTypeParameters();
53 @NotNull public PsiTypeParameter[] getTypeParameters() {
54 return myMethod.getTypeParameters();
57 public PsiTypeParameterList getTypeParameterList() {
58 return myMethod.getTypeParameterList();
61 public PsiDocComment getDocComment() {
62 return myMethod.getDocComment();
65 public boolean isDeprecated() {
66 return myMethod.isDeprecated();
69 public PsiElement setName(@NotNull String name) throws IncorrectOperationException {
70 return myMethod.setName(name);
73 @NotNull
74 public String getName() {
75 return myMethod.getName();
78 @NotNull
79 public HierarchicalMethodSignature getHierarchicalMethodSignature() {
80 return myMethod.getHierarchicalMethodSignature();
83 public boolean hasModifierProperty(@NotNull String name) {
84 return myMethod.hasModifierProperty(name);
87 @NotNull
88 public PsiModifierList getModifierList() {
89 return myMethod.getModifierList();
92 public PsiType getReturnType() {
93 return myMethod.getReturnType();
96 public PsiTypeElement getReturnTypeElement() {
97 return myMethod.getReturnTypeElement();
100 @NotNull
101 public PsiParameterList getParameterList() {
102 return myMethod.getParameterList();
105 @NotNull
106 public PsiReferenceList getThrowsList() {
107 return myMethod.getThrowsList();
110 public PsiCodeBlock getBody() {
111 return myMethod.getBody();
114 public boolean isConstructor() {
115 return myMethod.isConstructor();
118 public boolean isVarArgs() {
119 return myMethod.isVarArgs();
122 @NotNull
123 public MethodSignature getSignature(@NotNull PsiSubstitutor substitutor) {
124 return myMethod.getSignature(substitutor);
127 public PsiIdentifier getNameIdentifier() {
128 return myMethod.getNameIdentifier();
131 @NotNull
132 public PsiMethod[] findSuperMethods() {
133 return myMethod.findSuperMethods();
136 @NotNull
137 public PsiMethod[] findSuperMethods(boolean checkAccess) {
138 return myMethod.findSuperMethods(checkAccess);
141 @NotNull
142 public PsiMethod[] findSuperMethods(PsiClass parentClass) {
143 return myMethod.findSuperMethods(parentClass);
146 @NotNull
147 public List<MethodSignatureBackedByPsiMethod> findSuperMethodSignaturesIncludingStatic(boolean checkAccess) {
148 return myMethod.findSuperMethodSignaturesIncludingStatic(checkAccess);
151 public PsiMethod findDeepestSuperMethod() {
152 return myMethod.findDeepestSuperMethod();
155 @NotNull
156 public PsiMethod[] findDeepestSuperMethods() {
157 return myMethod.findDeepestSuperMethods();
160 public String getText() {
161 return myMethod.getText();
164 public void accept(@NotNull PsiElementVisitor visitor) {
165 myMethod.accept(visitor);
168 public PsiElement copy() {
169 return new LightMethod(myManager, (PsiMethod)myMethod.copy(), myContainingClass);
172 public boolean isValid() {
173 return myContainingClass.isValid();
176 public PsiClass getContainingClass() {
177 return myContainingClass;
180 public String toString() {
181 return "PsiMethod:" + getName();
184 public Icon getElementIcon(final int flags) {
185 Icon methodIcon = hasModifierProperty(PsiModifier.ABSTRACT) ? Icons.ABSTRACT_METHOD_ICON : Icons.METHOD_ICON;
186 RowIcon baseIcon = createLayeredIcon(methodIcon, ElementPresentationUtil.getFlags(this, false));
187 return ElementPresentationUtil.addVisibilityIcon(this, flags, baseIcon);
190 @Override
191 public boolean isEquivalentTo(final PsiElement another) {
192 return PsiClassImplUtil.isMethodEquivalentTo(this, another);
195 @NotNull
196 public SearchScope getUseScope() {
197 return PsiImplUtil.getMemberUseScope(this);
200 @Override
201 public PsiElement getContext() {
202 return getContainingClass();
205 public PsiMethodReceiver getMethodReceiver() {
206 return null;
208 public PsiType getReturnTypeNoResolve() {
209 return getReturnType();