Don't search for NonClasspathClassFinder classes and package during Kotlin resolve

This commit is contained in:
Nikolay Krasko
2015-04-22 21:57:28 +03:00
parent f972e12331
commit 3e1c3e9dfe
2 changed files with 46 additions and 5 deletions
@@ -25,10 +25,7 @@ import com.intellij.openapi.roots.PackageIndex;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElementFinder;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiElementFinderImpl;
import com.intellij.psi.impl.file.PsiPackageImpl;
import com.intellij.psi.impl.file.impl.JavaFileManager;
@@ -160,7 +157,7 @@ public class KotlinJavaPsiFacade {
getProject().getExtensions(PsiElementFinder.EP_NAME), new Function1<PsiElementFinder, Boolean>() {
@Override
public Boolean invoke(PsiElementFinder finder) {
return !(finder instanceof KotlinFinderMarker || finder instanceof PsiElementFinderImpl);
return !(finder instanceof NonClasspathClassFinder || finder instanceof KotlinFinderMarker || finder instanceof PsiElementFinderImpl);
}
});
@@ -0,0 +1,44 @@
/*
* Copyright 2010-2015 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.
*/
package org.jetbrains.kotlin.idea
import com.intellij.psi.NonClasspathClassFinder
import com.intellij.psi.PsiElementFinder
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.junit.Assert
public class RegisteredFindersTest : JetLightCodeInsightFixtureTestCase() {
override fun getProjectDescriptor() = LightCodeInsightFixtureTestCase.JAVA_LATEST
public fun testKnownNonClasspathFinder() {
val expectedFindersNames = setOf("GantClassFinder", "GradleClassFinder").toMutableSet()
getProject().getExtensions<PsiElementFinder>(PsiElementFinder.EP_NAME).forEach { finder ->
if (finder is NonClasspathClassFinder) {
val name = finder.javaClass.getSimpleName()
val removed = expectedFindersNames.remove(name)
Assert.assertTrue("Unknown finder found: $finder, class name: $name, search in $expectedFindersNames.\n" +
"Consider updating ${javaClass<KotlinJavaPsiFacade>()}",
removed)
}
}
Assert.assertTrue("Some finders wasn't found: $expectedFindersNames", expectedFindersNames.isEmpty())
}
}