Fix symbol scope (by max)
[fedora-idea.git] / plugins / groovy / src / org / jetbrains / plugins / groovy / gotoclass / GroovyGoToSymbolContributor.java
blob93ac73684da7c4b510571897ebf3c2bcbc3ca068
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 org.jetbrains.plugins.groovy.gotoclass;
18 import com.intellij.navigation.ChooseByNameContributor;
19 import com.intellij.navigation.NavigationItem;
20 import com.intellij.openapi.project.Project;
21 import com.intellij.psi.search.GlobalSearchScope;
22 import com.intellij.psi.stubs.StubIndex;
23 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrAnnotationMethodNameIndex;
24 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrFieldNameIndex;
25 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrMethodNameIndex;
26 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrShortClassNameIndex;
28 import java.util.ArrayList;
29 import java.util.HashSet;
30 import java.util.List;
31 import java.util.Set;
33 /**
34 * @author ilyas
36 public class GroovyGoToSymbolContributor implements ChooseByNameContributor {
37 public String[] getNames(Project project, boolean includeNonProjectItems) {
38 Set<String> symbols = new HashSet<String>();
39 symbols.addAll(StubIndex.getInstance().getAllKeys(GrShortClassNameIndex.KEY, project));
40 symbols.addAll(StubIndex.getInstance().getAllKeys(GrFieldNameIndex.KEY, project));
41 symbols.addAll(StubIndex.getInstance().getAllKeys(GrMethodNameIndex.KEY, project));
42 symbols.addAll(StubIndex.getInstance().getAllKeys(GrAnnotationMethodNameIndex.KEY, project));
43 return symbols.toArray(new String[symbols.size()]);
46 public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
47 GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
49 List<NavigationItem> symbols = new ArrayList<NavigationItem>();
50 symbols.addAll(StubIndex.getInstance().get(GrShortClassNameIndex.KEY, name, project, scope));
51 symbols.addAll(StubIndex.getInstance().get(GrFieldNameIndex.KEY, name, project, scope));
52 symbols.addAll(StubIndex.getInstance().get(GrMethodNameIndex.KEY, name, project, scope));
53 symbols.addAll(StubIndex.getInstance().get(GrAnnotationMethodNameIndex.KEY, name, project, scope));
55 return symbols.toArray(new NavigationItem[symbols.size()]);