2 * Copyright 2000-2007 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.
17 package com
.intellij
.psi
.search
.searches
;
19 import com
.intellij
.openapi
.util
.Pair
;
20 import com
.intellij
.psi
.PsiClass
;
21 import com
.intellij
.psi
.PsiMethod
;
22 import com
.intellij
.psi
.PsiModifier
;
23 import com
.intellij
.psi
.search
.SearchScope
;
24 import com
.intellij
.psi
.search
.GlobalSearchScope
;
25 import com
.intellij
.util
.EmptyQuery
;
26 import com
.intellij
.util
.Query
;
30 * Searches deeply for all overriding methods of all methods in a class, processing pairs
31 * (method in original class, overriding method)
33 public class AllOverridingMethodsSearch
extends ExtensibleQueryFactory
<Pair
<PsiMethod
, PsiMethod
>, AllOverridingMethodsSearch
.SearchParameters
> {
34 public static final AllOverridingMethodsSearch INSTANCE
= new AllOverridingMethodsSearch();
36 public static class SearchParameters
{
37 private final PsiClass myClass
;
38 private final SearchScope myScope
;
40 public SearchParameters(final PsiClass aClass
, SearchScope scope
) {
45 public PsiClass
getPsiClass() {
49 public SearchScope
getScope() {
54 private AllOverridingMethodsSearch() {
57 public static Query
<Pair
<PsiMethod
, PsiMethod
>> search(final PsiClass aClass
, SearchScope scope
) {
58 if (aClass
.hasModifierProperty(PsiModifier
.FINAL
)) return EmptyQuery
.getEmptyQuery(); // Optimization
59 return INSTANCE
.createUniqueResultsQuery(new SearchParameters(aClass
, scope
));
62 public static Query
<Pair
<PsiMethod
, PsiMethod
>> search(final PsiClass aClass
) {
63 return search(aClass
, GlobalSearchScope
.allScope(aClass
.getProject()));