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
.filters
.classes
;
18 import com
.intellij
.psi
.JavaPsiFacade
;
19 import com
.intellij
.psi
.PsiClass
;
20 import com
.intellij
.psi
.PsiElement
;
21 import com
.intellij
.psi
.PsiManager
;
22 import com
.intellij
.psi
.filters
.ElementFilter
;
23 import com
.intellij
.psi
.search
.GlobalSearchScope
;
24 import com
.intellij
.reference
.SoftReference
;
25 import com
.intellij
.util
.ReflectionCache
;
28 * Created by IntelliJ IDEA.
32 * To change this template use Options | File Templates.
34 public abstract class ClassAssignableFilter
implements ElementFilter
{
35 protected String myClassName
= null;
36 protected PsiClass myClass
= null;
37 private SoftReference myCachedClass
= new SoftReference(null);
39 public abstract boolean isAcceptable(Object aClass
, PsiElement context
);
40 public abstract String
toString();
42 public boolean isClassAcceptable(Class hintClass
){
43 return ReflectionCache
.isAssignable(PsiClass
.class, hintClass
);
46 protected PsiClass
getPsiClass(PsiManager manager
, GlobalSearchScope scope
){
51 if(myCachedClass
.get() == null && manager
!= null){
52 myCachedClass
= new SoftReference(JavaPsiFacade
.getInstance(manager
.getProject()).findClass(myClassName
, scope
));
54 return (PsiClass
) myCachedClass
.get();