[groovy] include groovy files in all source folders when processing classes with name (IDEA-206430)

Java only includes source roots and skips resources (JavaSourceFilterScope) since 2019.1.
This commit is contained in:
Daniil Ovchinnikov
2019-02-07 17:53:32 +03:00
parent 27b10c30d3
commit d94f32e68e
@@ -1,19 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.stubs;
import com.intellij.openapi.project.Project;
@@ -42,6 +27,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static com.intellij.psi.impl.java.stubs.index.JavaStubIndexKeys.CLASS_SHORT_NAMES;
/**
* @author ilyas
*/
@@ -186,6 +173,23 @@ public class GroovyShortNamesCache extends PsiShortNamesCache {
@NotNull Processor<? super PsiClass> processor,
@NotNull GlobalSearchScope scope,
@Nullable IdFilter filter) {
return processClasses(name, processor, scope, filter) &&
processScriptClasses(name, processor, scope, filter);
}
private boolean processClasses(@NotNull String name,
@NotNull Processor<? super PsiClass> processor,
@NotNull GlobalSearchScope scope,
@Nullable IdFilter filter) {
return StubIndex.getInstance().processElements(
CLASS_SHORT_NAMES, name, myProject, new GrSourceFilterScope(scope), filter, PsiClass.class, processor
);
}
private boolean processScriptClasses(@NotNull String name,
@NotNull Processor<? super PsiClass> processor,
@NotNull GlobalSearchScope scope,
@Nullable IdFilter filter) {
for (GroovyFile file : StubIndex.getElements(GrScriptClassNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter,
GroovyFile.class)) {
PsiClass aClass = file.getScriptClass();