VirtualFileFinderFactory: introduce JvmVirtualFileFinderFactory, JsVirtualFileFinderFactory
This commit is contained in:
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder;
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
@@ -150,7 +150,7 @@ public class InlineCodegenUtil {
|
||||
|
||||
@NotNull
|
||||
public static VirtualFile getVirtualFileForCallable(@NotNull ClassId containerClassId, @NotNull GenerationState state) {
|
||||
VirtualFileFinder fileFinder = VirtualFileFinder.SERVICE.getInstance(state.getProject());
|
||||
JvmVirtualFileFinder fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(state.getProject());
|
||||
VirtualFile file = fileFinder.findVirtualFileWithHeader(containerClassId);
|
||||
if (file == null) {
|
||||
throw new IllegalStateException("Couldn't find declaration file for " + containerClassId);
|
||||
@@ -181,7 +181,7 @@ public class InlineCodegenUtil {
|
||||
public static VirtualFile findVirtualFile(@NotNull Project project, @NotNull String internalClassName) {
|
||||
FqName packageFqName = JvmClassName.byInternalName(internalClassName).getPackageFqName();
|
||||
String classNameWithDollars = substringAfterLast(internalClassName, "/", internalClassName);
|
||||
VirtualFileFinder fileFinder = VirtualFileFinder.SERVICE.getInstance(project);
|
||||
JvmVirtualFileFinder fileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project);
|
||||
//TODO: we cannot construct proper classId at this point, we need to read InnerClasses info from class file
|
||||
// we construct valid.package.name/RelativeClassNameAsSingleName that should work in compiler, but fails for inner classes in IDE
|
||||
return fileFinder.findVirtualFileWithHeader(new ClassId(packageFqName, Name.identifier(classNameWithDollars)));
|
||||
|
||||
+1
-2
@@ -17,11 +17,10 @@
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClassFinder
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
public class CliVirtualFileFinder(private val index: JvmDependenciesIndex) : VirtualFileKotlinClassFinder(), VirtualFileFinder {
|
||||
public class JvmCliVirtualFileFinder(private val index: JvmDependenciesIndex) : VirtualFileKotlinClassFinder() {
|
||||
|
||||
override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? {
|
||||
val classFileName = classId.getRelativeClassName().asString().replace('.', '$')
|
||||
+4
-6
@@ -17,11 +17,9 @@
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory
|
||||
|
||||
public class CliVirtualFileFinderFactory(private val index: JvmDependenciesIndex) : VirtualFileFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): VirtualFileFinder {
|
||||
return CliVirtualFileFinder(index)
|
||||
}
|
||||
public class JvmCliVirtualFileFinderFactory(private val index: JvmDependenciesIndex) : JvmVirtualFileFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): JvmVirtualFileFinder = JvmCliVirtualFileFinder(index)
|
||||
}
|
||||
@@ -71,8 +71,8 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.KotlinSourceRoot
|
||||
import org.jetbrains.kotlin.extensions.ExternalDeclarationsProvider
|
||||
import org.jetbrains.kotlin.idea.JetFileType
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
import org.jetbrains.kotlin.parsing.JetParserDefinition
|
||||
import org.jetbrains.kotlin.parsing.JetScriptDefinitionProvider
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
@@ -136,7 +136,7 @@ public class KotlinCoreEnvironment private(
|
||||
|
||||
JetScriptDefinitionProvider.getInstance(project).addScriptDefinitions(configuration.getList(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY))
|
||||
|
||||
project.registerService(javaClass<VirtualFileFinderFactory>(), CliVirtualFileFinderFactory(index))
|
||||
project.registerService(javaClass<JvmVirtualFileFinderFactory>(), JvmCliVirtualFileFinderFactory(index))
|
||||
|
||||
ExternalDeclarationsProvider.registerExtensionPoint(project)
|
||||
ExpressionCodegenExtension.registerExtensionPoint(project)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.load.kotlin
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
public interface JvmVirtualFileFinder : VirtualFileFinder, KotlinClassFinder {
|
||||
public object SERVICE {
|
||||
platformStatic
|
||||
public fun getInstance(project: Project): JvmVirtualFileFinder =
|
||||
ServiceManager.getService(project, javaClass<JvmVirtualFileFinderFactory>()).create(GlobalSearchScope.allScope(project))
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.load.kotlin
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
public interface JvmVirtualFileFinderFactory : VirtualFileFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): JvmVirtualFileFinder
|
||||
|
||||
public object SERVICE {
|
||||
platformStatic
|
||||
public fun getInstance(project: Project): JvmVirtualFileFinderFactory =
|
||||
ServiceManager.getService(project, javaClass<JvmVirtualFileFinderFactory>())
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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.load.kotlin;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
|
||||
public interface VirtualFileFinder extends KotlinClassFinder {
|
||||
class SERVICE {
|
||||
@NotNull
|
||||
public static VirtualFileFinder getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, VirtualFileFinderFactory.class).create(GlobalSearchScope.allScope(project));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
VirtualFile findVirtualFileWithHeader(@NotNull ClassId className);
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
public abstract class VirtualFileKotlinClassFinder : VirtualFileFinder {
|
||||
public abstract class VirtualFileKotlinClassFinder : JvmVirtualFileFinder {
|
||||
override fun findKotlinClass(classId: ClassId): KotlinJvmBinaryClass? {
|
||||
val file = findVirtualFileWithHeader(classId) ?: return null
|
||||
return KotlinBinaryClassCache.getKotlinBinaryClass(file)
|
||||
|
||||
+5
-12
@@ -14,18 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.vfilefinder;
|
||||
package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder;
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory;
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
public class IDEVirtualFileFinderFactory implements VirtualFileFinderFactory {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFileFinder create(@NotNull GlobalSearchScope scope) {
|
||||
return new IDEVirtualFileFinder(scope);
|
||||
}
|
||||
public interface VirtualFileFinder {
|
||||
public fun findVirtualFileWithHeader(classId: ClassId): VirtualFile?
|
||||
}
|
||||
+4
-15
@@ -14,21 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin;
|
||||
package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
|
||||
public interface VirtualFileFinderFactory {
|
||||
@NotNull
|
||||
VirtualFileFinder create(@NotNull GlobalSearchScope scope);
|
||||
|
||||
class SERVICE {
|
||||
@NotNull
|
||||
public static VirtualFileFinderFactory getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, VirtualFileFinderFactory.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
public fun create(scope: GlobalSearchScope): VirtualFileFinder
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.asJava.KotlinLightClass
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.JetTestUtils
|
||||
@@ -60,7 +60,7 @@ public class KotlinClassFinderTest : KotlinTestWithEnvironmentManagement() {
|
||||
assertNotNull(psiClass, "Psi class not found for $className")
|
||||
assertTrue(psiClass !is KotlinLightClass, "Kotlin light classes are not not expected");
|
||||
|
||||
val binaryClass = VirtualFileFinder.SERVICE.getInstance(project).findKotlinClass(JavaClassImpl(psiClass!!))
|
||||
val binaryClass = JvmVirtualFileFinder.SERVICE.getInstance(project).findKotlinClass(JavaClassImpl(psiClass!!))
|
||||
assertNotNull(binaryClass, "No binary class for $className")
|
||||
|
||||
assertEquals("test/A.B.C", binaryClass?.getClassId()?.toString())
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.vfilefinder
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
public interface JsVirtualFileFinder : VirtualFileFinder {
|
||||
public object SERVICE {
|
||||
platformStatic
|
||||
public fun getInstance(project: Project): JsVirtualFileFinder =
|
||||
ServiceManager.getService(project, javaClass<JsVirtualFileFinderFactory>()).create(GlobalSearchScope.allScope(project))
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.vfilefinder
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
public interface JsVirtualFileFinderFactory : VirtualFileFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): JsVirtualFileFinder
|
||||
|
||||
public object SERVICE {
|
||||
platformStatic
|
||||
public fun getInstance(project: Project): JsVirtualFileFinderFactory =
|
||||
ServiceManager.getService(project, javaClass<JsVirtualFileFinderFactory>())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.vfilefinder
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory
|
||||
|
||||
public class JvmIDEVirtualFileFinderFactory : JvmVirtualFileFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): JvmVirtualFileFinder = JvmIDEVirtualFileFinder(scope)
|
||||
}
|
||||
|
||||
public class JsIDEVirtualFileFinderFactory : JsVirtualFileFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): JsVirtualFileFinder = JsIDEVirtualFileFinder(scope)
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.vfilefinder
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.util.indexing.FileBasedIndex
|
||||
import com.intellij.util.indexing.ID
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClassFinder
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
|
||||
private fun checkScopeForFinder(scope: GlobalSearchScope, logger: Logger) {
|
||||
if (scope != GlobalSearchScope.EMPTY_SCOPE && scope.getProject() == null) {
|
||||
logger.warn("Scope with null project " + scope)
|
||||
}
|
||||
}
|
||||
|
||||
private fun findVirtualFileWithHeader(classId: ClassId, key: ID<FqName, Void>, scope: GlobalSearchScope, logger: Logger): VirtualFile? {
|
||||
val files = FileBasedIndex.getInstance().getContainingFiles<FqName, Void>(key, classId.asSingleFqName(), scope)
|
||||
if (files.isEmpty()) return null
|
||||
|
||||
if (files.size() > 1) {
|
||||
logger.warn("There are " + files.size() + " classes with same fqName: " + classId + " found.")
|
||||
}
|
||||
return files.iterator().next()
|
||||
}
|
||||
|
||||
public class JsIDEVirtualFileFinder(private val scope: GlobalSearchScope) : JsVirtualFileFinder {
|
||||
|
||||
init { checkScopeForFinder(scope, LOG) }
|
||||
|
||||
override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? =
|
||||
findVirtualFileWithHeader(classId, KotlinJavaScriptMetaFileIndex.KEY, scope, LOG)
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(javaClass<JsIDEVirtualFileFinder>())
|
||||
}
|
||||
}
|
||||
|
||||
public class JvmIDEVirtualFileFinder(private val scope: GlobalSearchScope) : VirtualFileKotlinClassFinder(), JvmVirtualFileFinder {
|
||||
|
||||
init { checkScopeForFinder(scope, LOG) }
|
||||
|
||||
override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? =
|
||||
findVirtualFileWithHeader(classId, KotlinClassFileIndex.KEY, scope, LOG)
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(javaClass<JvmIDEVirtualFileFinder>())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,8 +172,11 @@
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheService"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheService"/>
|
||||
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.vfilefinder.IDEVirtualFileFinderFactory"/>
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.vfilefinder.JvmIDEVirtualFileFinderFactory"/>
|
||||
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.idea.vfilefinder.JsVirtualFileFinderFactory"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.vfilefinder.JsIDEVirtualFileFinderFactory"/>
|
||||
|
||||
<projectService serviceInterface="org.jetbrains.kotlin.asJava.LightClassGenerationSupport"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.caches.resolve.IDELightClassGenerationSupport"/>
|
||||
|
||||
+2
-3
@@ -16,13 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler.stubBuilder
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.util.indexing.FileContentImpl
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.buildDecompiledText
|
||||
import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.JetPsiFactory
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.JetFileStubBuilder
|
||||
@@ -34,7 +33,7 @@ public class ClsStubConsistencyTest : JetLightCodeInsightFixtureTestCase() {
|
||||
|
||||
public fun testConsistencyForKotlinPackage() {
|
||||
val project = getProject()
|
||||
val virtualFileFinder = VirtualFileFinderFactory.SERVICE.getInstance(project).create(GlobalSearchScope.allScope(project))
|
||||
val virtualFileFinder = JvmVirtualFileFinder.SERVICE.getInstance(getProject())
|
||||
val kotlinPackageFile = virtualFileFinder.findVirtualFileWithHeader(PackageClassUtils.getPackageClassId(STANDARD_LIBRARY_FQNAME))!!
|
||||
|
||||
val decompiledText = buildDecompiledText(kotlinPackageFile).text
|
||||
|
||||
+2
-3
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.idea.decompiler.textBuilder
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
@@ -26,8 +25,8 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.BindingTraceContext
|
||||
@@ -43,7 +42,7 @@ public class DecompiledTextConsistencyTest : JetLightCodeInsightFixtureTestCase(
|
||||
|
||||
public fun testConsistencyWithJavaDescriptorResolver() {
|
||||
val project = getProject()
|
||||
val virtualFileFinder = VirtualFileFinderFactory.SERVICE.getInstance(project).create(GlobalSearchScope.allScope(project))
|
||||
val virtualFileFinder = JvmVirtualFileFinder.SERVICE.getInstance(getProject())
|
||||
val kotlinPackageFile = virtualFileFinder.findVirtualFileWithHeader(PackageClassUtils.getPackageClassId(STANDARD_LIBRARY_FQNAME))!!
|
||||
val projectBasedText = buildDecompiledText(kotlinPackageFile, ProjectBasedResolverForDecompiler(project)).text
|
||||
val deserializedText = buildDecompiledText(kotlinPackageFile).text
|
||||
|
||||
Reference in New Issue
Block a user