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
.scope
.processor
;
18 import com
.intellij
.openapi
.util
.Key
;
19 import com
.intellij
.psi
.*;
20 import com
.intellij
.psi
.filters
.ElementFilter
;
21 import com
.intellij
.psi
.infos
.CandidateInfo
;
22 import com
.intellij
.psi
.scope
.ElementClassFilter
;
23 import com
.intellij
.psi
.scope
.ElementClassHint
;
24 import com
.intellij
.psi
.scope
.JavaScopeProcessorEvent
;
25 import com
.intellij
.psi
.scope
.PsiConflictResolver
;
26 import com
.intellij
.util
.SmartList
;
29 * Created by IntelliJ IDEA.
33 * To change this template use Options | File Templates.
35 public abstract class MethodsProcessor
extends ConflictFilterProcessor
implements ElementClassHint
{
36 private static final ElementFilter ourFilter
= ElementClassFilter
.METHOD
;
38 private boolean myStaticScopeFlag
= false;
39 private boolean myIsConstructor
= false;
40 protected PsiElement myCurrentFileContext
= null;
41 protected PsiClass myAccessClass
= null;
42 private PsiExpressionList myArgumentList
;
43 private PsiType
[] myTypeArguments
;
45 public MethodsProcessor(PsiConflictResolver
[] resolvers
, SmartList
<CandidateInfo
> container
, final PsiElement place
) {
46 super(null, ourFilter
, resolvers
, container
, place
);
49 public PsiExpressionList
getArgumentList() {
50 return myArgumentList
;
53 public void setArgumentList(PsiExpressionList argList
) {
54 myArgumentList
= argList
;
57 public void obtainTypeArguments(PsiCallExpression callExpression
) {
58 final PsiType
[] typeArguments
= callExpression
.getTypeArguments();
59 if (typeArguments
.length
> 0) {
60 setTypeArguments(typeArguments
);
64 protected void setTypeArguments(PsiType
[] typeParameters
) {
65 myTypeArguments
= typeParameters
;
68 public PsiType
[] getTypeArguments() {
69 return myTypeArguments
;
72 public boolean isInStaticScope() {
73 return myStaticScopeFlag
;
76 public void handleEvent(Event event
, Object associated
) {
77 if (event
== JavaScopeProcessorEvent
.START_STATIC
) {
78 myStaticScopeFlag
= true;
80 else if (JavaScopeProcessorEvent
.SET_CURRENT_FILE_CONTEXT
.equals(event
)) {
81 myCurrentFileContext
= (PsiElement
)associated
;
85 public void setAccessClass(PsiClass accessClass
) {
86 /* if (isConstructor() && accessClass instanceof PsiAnonymousClass) {
87 myAccessClass = ((PsiAnonymousClass)accessClass).getBaseClassType().resolve();
90 myAccessClass
= accessClass
;
92 /*if (isConstructor() && myAccessClass != null) {
93 setName(myAccessClass.getName());
97 public boolean isConstructor() {
98 return myIsConstructor
;
101 public void setIsConstructor(boolean myIsConstructor
) {
102 this.myIsConstructor
= myIsConstructor
;
105 public void forceAddResult(PsiMethod method
) {
106 add(new CandidateInfo(method
, PsiSubstitutor
.EMPTY
, false, false, myCurrentFileContext
));
110 public <T
> T
getHint(Key
<T
> hintKey
) {
111 if (hintKey
== ElementClassHint
.KEY
) {
115 return super.getHint(hintKey
);
118 public boolean shouldProcess(DeclaractionKind kind
) {
119 return kind
== DeclaractionKind
.METHOD
;