VirtualFileFinderFactory: introduce JvmVirtualFileFinderFactory, JsVirtualFileFinderFactory
This commit is contained in:
+10
-14
@@ -14,21 +14,17 @@
|
||||
* 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.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
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 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)
|
||||
|
||||
Reference in New Issue
Block a user