KotlinLightClassForPackage -> KotlinLightClassForFacade
(with minor changes)
This commit is contained in:
committed by
Michael Bogdanov
parent
1c81b00143
commit
47f5b55e65
+3
-2
@@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.TestOnly;
|
import org.jetbrains.annotations.TestOnly;
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration;
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration;
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage;
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade;
|
||||||
import org.jetbrains.kotlin.asJava.LightClassConstructionContext;
|
import org.jetbrains.kotlin.asJava.LightClassConstructionContext;
|
||||||
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport;
|
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
@@ -201,7 +201,8 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
if (filesWithCallables.isEmpty()) return Collections.emptyList();
|
if (filesWithCallables.isEmpty()) return Collections.emptyList();
|
||||||
|
|
||||||
//noinspection RedundantTypeArguments
|
//noinspection RedundantTypeArguments
|
||||||
return UtilsPackage.<PsiClass>emptyOrSingletonList(KotlinLightClassForPackage.Factory.create(psiManager, packageFqName, scope, filesWithCallables));
|
return UtilsPackage.<PsiClass>emptyOrSingletonList(
|
||||||
|
KotlinLightClassForFacade.Factory.createForPackageFacade(psiManager, packageFqName, scope, filesWithCallables));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ import com.intellij.psi.stubs.BinaryFileStubBuilders
|
|||||||
import com.intellij.psi.util.JavaClassSupers
|
import com.intellij.psi.util.JavaClassSupers
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.jetbrains.kotlin.asJava.JavaElementFinder
|
import org.jetbrains.kotlin.asJava.JavaElementFinder
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade
|
||||||
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
||||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
||||||
@@ -376,7 +376,7 @@ public class KotlinCoreEnvironment private constructor(
|
|||||||
with (projectEnvironment.getProject()) {
|
with (projectEnvironment.getProject()) {
|
||||||
registerService(javaClass<JetScriptDefinitionProvider>(), JetScriptDefinitionProvider())
|
registerService(javaClass<JetScriptDefinitionProvider>(), JetScriptDefinitionProvider())
|
||||||
registerService(javaClass<KotlinJavaPsiFacade>(), KotlinJavaPsiFacade(this))
|
registerService(javaClass<KotlinJavaPsiFacade>(), KotlinJavaPsiFacade(this))
|
||||||
registerService(javaClass<KotlinLightClassForPackage.FileStubCache>(), KotlinLightClassForPackage.FileStubCache(this))
|
registerService(javaClass<KotlinLightClassForFacade.FileStubCache>(), KotlinLightClassForFacade.FileStubCache(this))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -32,17 +32,17 @@ import org.jetbrains.kotlin.psi.JetFile;
|
|||||||
/**
|
/**
|
||||||
* This class serves as a workaround for usages of {@link JavaElementFinder#findClasses} which eventually only need names of files
|
* This class serves as a workaround for usages of {@link JavaElementFinder#findClasses} which eventually only need names of files
|
||||||
* containing the class. When queried for a package class (e.g. test/TestPackage), {@code findClasses} along with a
|
* containing the class. When queried for a package class (e.g. test/TestPackage), {@code findClasses} along with a
|
||||||
* {@link KotlinLightClassForPackage} would also return multiple instances of this class for each file present in the package. The client
|
* {@link KotlinLightClassForFacade} would also return multiple instances of this class for each file present in the package. The client
|
||||||
* code can make use of every file in the package then, since {@code getContainingFile} of these instances will represent the whole package.
|
* code can make use of every file in the package then, since {@code getContainingFile} of these instances will represent the whole package.
|
||||||
* <p/>
|
* <p/>
|
||||||
* See {@link LineBreakpoint#findClassCandidatesInSourceContent} for the primary usage this was introduced
|
* See {@link LineBreakpoint#findClassCandidatesInSourceContent} for the primary usage this was introduced
|
||||||
*/
|
*/
|
||||||
public class FakeLightClassForFileOfPackage extends AbstractLightClass implements KotlinLightClass, JetJavaMirrorMarker {
|
public class FakeLightClassForFileOfPackage extends AbstractLightClass implements KotlinLightClass, JetJavaMirrorMarker {
|
||||||
private final KotlinLightClassForPackage delegate;
|
private final KotlinLightClassForFacade delegate;
|
||||||
private final JetFile file;
|
private final JetFile file;
|
||||||
|
|
||||||
public FakeLightClassForFileOfPackage(
|
public FakeLightClassForFileOfPackage(
|
||||||
@NotNull PsiManager manager, @NotNull KotlinLightClassForPackage delegate, @NotNull JetFile file
|
@NotNull PsiManager manager, @NotNull KotlinLightClassForFacade delegate, @NotNull JetFile file
|
||||||
) {
|
) {
|
||||||
super(manager);
|
super(manager);
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
|||||||
+2
-2
@@ -64,8 +64,8 @@ public open class KotlinLightClassForExplicitDeclaration(
|
|||||||
|
|
||||||
var createWrapper = forceMethodWrapping
|
var createWrapper = forceMethodWrapping
|
||||||
// Use PsiClass wrapper instead of package light class to avoid names like "FooPackage" in Type Hierarchy and related views
|
// Use PsiClass wrapper instead of package light class to avoid names like "FooPackage" in Type Hierarchy and related views
|
||||||
if (containingClass is KotlinLightClassForPackage) {
|
if (containingClass is KotlinLightClassForFacade) {
|
||||||
containingClass = object : LightClass(containingClass as KotlinLightClassForPackage, JetLanguage.INSTANCE) {
|
containingClass = object : LightClass(containingClass as KotlinLightClassForFacade, JetLanguage.INSTANCE) {
|
||||||
override fun getName(): String? {
|
override fun getName(): String? {
|
||||||
return currentFileName
|
return currentFileName
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-27
@@ -37,11 +37,12 @@ import org.jetbrains.kotlin.psi.JetFile
|
|||||||
import javax.swing.*
|
import javax.swing.*
|
||||||
import org.jetbrains.kotlin.psi.JetClassOrObject
|
import org.jetbrains.kotlin.psi.JetClassOrObject
|
||||||
|
|
||||||
public class KotlinLightClassForPackage private constructor(
|
public class KotlinLightClassForFacade private constructor(
|
||||||
manager: PsiManager,
|
manager: PsiManager,
|
||||||
private val packageFqName: FqName,
|
private val facadeClassFqName: FqName,
|
||||||
private val searchScope: GlobalSearchScope,
|
private val searchScope: GlobalSearchScope,
|
||||||
files: Collection<JetFile>) : KotlinWrappingLightClass(manager), JetJavaMirrorMarker {
|
files: Collection<JetFile>
|
||||||
|
) : KotlinWrappingLightClass(manager), JetJavaMirrorMarker {
|
||||||
|
|
||||||
public class FileStubCache(private val project: Project) {
|
public class FileStubCache(private val project: Project) {
|
||||||
private data class Key(val fqName: FqName, val searchScope: GlobalSearchScope)
|
private data class Key(val fqName: FqName, val searchScope: GlobalSearchScope)
|
||||||
@@ -72,18 +73,14 @@ public class KotlinLightClassForPackage private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
assert(!files.isEmpty()) { "No files for package " + packageFqName }
|
|
||||||
}
|
|
||||||
|
|
||||||
public val files: Collection<JetFile> = files.toSet() // needed for hashCode
|
public val files: Collection<JetFile> = files.toSet() // needed for hashCode
|
||||||
|
|
||||||
private val packageClassFqName: FqName =
|
|
||||||
PackageClassUtils.getPackageClassFqName(packageFqName)
|
|
||||||
|
|
||||||
private val hashCode: Int =
|
private val hashCode: Int =
|
||||||
computeHashCode()
|
computeHashCode()
|
||||||
|
|
||||||
|
private val packageFqName: FqName =
|
||||||
|
facadeClassFqName.parent()
|
||||||
|
|
||||||
private val lightClassDataCache: CachedValue<KotlinPackageLightClassData> =
|
private val lightClassDataCache: CachedValue<KotlinPackageLightClassData> =
|
||||||
FileStubCache.getInstance(getProject()).get(packageFqName, searchScope)
|
FileStubCache.getInstance(getProject()).get(packageFqName, searchScope)
|
||||||
|
|
||||||
@@ -99,7 +96,7 @@ public class KotlinLightClassForPackage private constructor(
|
|||||||
|
|
||||||
override fun getOrigin(): JetClassOrObject? = null
|
override fun getOrigin(): JetClassOrObject? = null
|
||||||
|
|
||||||
override fun getFqName(): FqName = packageClassFqName
|
override fun getFqName(): FqName = facadeClassFqName
|
||||||
|
|
||||||
override fun getModifierList() = modifierList
|
override fun getModifierList() = modifierList
|
||||||
|
|
||||||
@@ -156,19 +153,17 @@ public class KotlinLightClassForPackage private constructor(
|
|||||||
|
|
||||||
override fun findInnerClassByName(NonNls name: String, checkBases: Boolean) = null
|
override fun findInnerClassByName(NonNls name: String, checkBases: Boolean) = null
|
||||||
|
|
||||||
override fun getName() = packageClassFqName.shortName().asString()
|
override fun getName() = facadeClassFqName.shortName().asString()
|
||||||
|
|
||||||
override fun getQualifiedName() = packageClassFqName.asString()
|
override fun getQualifiedName() = facadeClassFqName.asString()
|
||||||
|
|
||||||
override fun isValid() = files.all { it.isValid() }
|
override fun isValid() = files.all { it.isValid() }
|
||||||
|
|
||||||
override fun copy() = KotlinLightClassForPackage(getManager(), packageFqName, searchScope, files)
|
override fun copy() = KotlinLightClassForFacade(getManager(), facadeClassFqName, searchScope, files)
|
||||||
|
|
||||||
override fun getDelegate(): PsiClass {
|
override fun getDelegate(): PsiClass {
|
||||||
val psiClass = LightClassUtil.findClass(packageClassFqName, lightClassDataCache.getValue().javaFileStub)
|
val psiClass = LightClassUtil.findClass(facadeClassFqName, lightClassDataCache.getValue().javaFileStub)
|
||||||
if (psiClass == null) {
|
?: throw IllegalStateException("Facade class $facadeClassFqName not found")
|
||||||
throw IllegalStateException("Package class was not found " + packageFqName)
|
|
||||||
}
|
|
||||||
return psiClass
|
return psiClass
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +180,7 @@ public class KotlinLightClassForPackage private constructor(
|
|||||||
private fun computeHashCode(): Int {
|
private fun computeHashCode(): Int {
|
||||||
var result = getManager().hashCode()
|
var result = getManager().hashCode()
|
||||||
result = 31 * result + files.hashCode()
|
result = 31 * result + files.hashCode()
|
||||||
result = 31 * result + packageFqName.hashCode()
|
result = 31 * result + facadeClassFqName.hashCode()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,38 +189,41 @@ public class KotlinLightClassForPackage private constructor(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val lightClass = other as KotlinLightClassForPackage
|
val lightClass = other as KotlinLightClassForFacade
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
|
|
||||||
if (this.hashCode != lightClass.hashCode) return false
|
if (this.hashCode != lightClass.hashCode) return false
|
||||||
if (getManager() != lightClass.getManager()) return false
|
if (getManager() != lightClass.getManager()) return false
|
||||||
if (files != lightClass.files) return false
|
if (files != lightClass.files) return false
|
||||||
if (packageFqName != lightClass.packageFqName) return false
|
if (facadeClassFqName != lightClass.facadeClassFqName) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
try {
|
try {
|
||||||
return javaClass<KotlinLightClassForPackage>().getSimpleName() + ":" + getQualifiedName()
|
return javaClass<KotlinLightClassForFacade>().getSimpleName() + ":" + getQualifiedName()
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {
|
catch (e: Throwable) {
|
||||||
return javaClass<KotlinLightClassForPackage>().getSimpleName() + ":" + e.toString()
|
return javaClass<KotlinLightClassForFacade>().getSimpleName() + ":" + e.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object Factory {
|
companion object Factory {
|
||||||
public fun create(
|
public fun createForPackageFacade(
|
||||||
manager: PsiManager,
|
manager: PsiManager,
|
||||||
qualifiedName: FqName,
|
packageFqName: FqName,
|
||||||
searchScope: GlobalSearchScope,
|
searchScope: GlobalSearchScope,
|
||||||
files: Collection<JetFile> // this is redundant, but computing it multiple times is costly
|
files: Collection<JetFile> // this is redundant, but computing it multiple times is costly
|
||||||
): KotlinLightClassForPackage? {
|
): KotlinLightClassForFacade? {
|
||||||
if (files.any { LightClassUtil.belongsToKotlinBuiltIns(it) }) {
|
if (files.any { LightClassUtil.belongsToKotlinBuiltIns(it) }) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return KotlinLightClassForPackage(manager, qualifiedName, searchScope, files)
|
assert(files.isNotEmpty()) { "No files for package $packageFqName" }
|
||||||
|
|
||||||
|
val packageClassFqName = PackageClassUtils.getPackageClassFqName(packageFqName)
|
||||||
|
return KotlinLightClassForFacade(manager, packageClassFqName, searchScope, files)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
public fun getJvmSignatureDiagnostics(element: PsiElement, otherDiagnostics: Diagnostics, moduleScope: GlobalSearchScope): Diagnostics? {
|
public fun getJvmSignatureDiagnostics(element: PsiElement, otherDiagnostics: Diagnostics, moduleScope: GlobalSearchScope): Diagnostics? {
|
||||||
fun getDiagnosticsForPackage(file: JetFile): Diagnostics? {
|
fun getDiagnosticsForPackage(file: JetFile): Diagnostics? {
|
||||||
val project = file.getProject()
|
val project = file.getProject()
|
||||||
val cache = KotlinLightClassForPackage.FileStubCache.getInstance(project)
|
val cache = KotlinLightClassForFacade.FileStubCache.getInstance(project)
|
||||||
return cache[file.getPackageFqName(), moduleScope].getValue()?.extraDiagnostics
|
return cache[file.getPackageFqName(), moduleScope].getValue()?.extraDiagnostics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.intellij.util.containers.ContainerUtil;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration;
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration;
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage;
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade;
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.KotlinLightClassForDecompiledDeclaration;
|
import org.jetbrains.kotlin.idea.caches.resolve.KotlinLightClassForDecompiledDeclaration;
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
@@ -101,7 +101,7 @@ public class JetIconProvider extends IconProvider implements DumbAware {
|
|||||||
return PlatformIcons.PACKAGE_ICON;
|
return PlatformIcons.PACKAGE_ICON;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psiElement instanceof KotlinLightClassForPackage) {
|
if (psiElement instanceof KotlinLightClassForFacade) {
|
||||||
return JetIcons.FILE;
|
return JetIcons.FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -279,8 +279,8 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
|
|
||||||
IdeaModuleInfo moduleInfo = info.getModuleInfo();
|
IdeaModuleInfo moduleInfo = info.getModuleInfo();
|
||||||
if (moduleInfo instanceof ModuleSourceInfo) {
|
if (moduleInfo instanceof ModuleSourceInfo) {
|
||||||
KotlinLightClassForPackage lightClass =
|
KotlinLightClassForFacade lightClass =
|
||||||
KotlinLightClassForPackage.Factory.create(psiManager, packageFqName, moduleInfo.contentScope(), files);
|
KotlinLightClassForFacade.Factory.createForPackageFacade(psiManager, packageFqName, moduleInfo.contentScope(), files);
|
||||||
if (lightClass == null) continue;
|
if (lightClass == null) continue;
|
||||||
|
|
||||||
result.add(lightClass);
|
result.add(lightClass);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.intellij.openapi.roots.ProjectFileIndex
|
|||||||
import com.intellij.openapi.roots.LibraryOrderEntry
|
import com.intellij.openapi.roots.LibraryOrderEntry
|
||||||
import com.intellij.openapi.roots.JdkOrderEntry
|
import com.intellij.openapi.roots.JdkOrderEntry
|
||||||
import org.jetbrains.kotlin.asJava.FakeLightClassForFileOfPackage
|
import org.jetbrains.kotlin.asJava.FakeLightClassForFileOfPackage
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.openapi.roots.ModuleRootManager
|
import com.intellij.openapi.roots.ModuleRootManager
|
||||||
@@ -116,7 +116,7 @@ private fun KotlinLightElement<*, *>.getModuleInfoForLightElement(): IdeaModuleI
|
|||||||
}
|
}
|
||||||
val element = getOrigin() ?: when (this) {
|
val element = getOrigin() ?: when (this) {
|
||||||
is FakeLightClassForFileOfPackage -> this.getContainingFile()!!
|
is FakeLightClassForFileOfPackage -> this.getContainingFile()!!
|
||||||
is KotlinLightClassForPackage -> this.files.first()
|
is KotlinLightClassForFacade -> this.files.first()
|
||||||
else -> throw IllegalStateException("Unknown light class without origin is referenced by IDE lazy resolve: $javaClass")
|
else -> throw IllegalStateException("Unknown light class without origin is referenced by IDE lazy resolve: $javaClass")
|
||||||
}
|
}
|
||||||
return element.getModuleInfo()
|
return element.getModuleInfo()
|
||||||
|
|||||||
@@ -206,8 +206,8 @@
|
|||||||
|
|
||||||
<projectService serviceImplementation="org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerWorkspaceSettings"/>
|
<projectService serviceImplementation="org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerWorkspaceSettings"/>
|
||||||
|
|
||||||
<projectService serviceInterface="org.jetbrains.kotlin.asJava.KotlinLightClassForPackage$FileStubCache"
|
<projectService serviceInterface="org.jetbrains.kotlin.asJava.KotlinLightClassForFacade$FileStubCache"
|
||||||
serviceImplementation="org.jetbrains.kotlin.asJava.KotlinLightClassForPackage$FileStubCache"/>
|
serviceImplementation="org.jetbrains.kotlin.asJava.KotlinLightClassForFacade$FileStubCache"/>
|
||||||
|
|
||||||
<projectService serviceInterface="org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache"
|
<projectService serviceInterface="org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache"
|
||||||
serviceImplementation="org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache"/>
|
serviceImplementation="org.jetbrains.kotlin.idea.debugger.evaluate.KotlinEvaluateExpressionCache"/>
|
||||||
|
|||||||
+2
-2
@@ -37,7 +37,7 @@ import com.intellij.xdebugger.breakpoints.XLineBreakpointType
|
|||||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel
|
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.idea.JetBundle
|
import org.jetbrains.kotlin.idea.JetBundle
|
||||||
@@ -90,7 +90,7 @@ public class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakp
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = when (psiClass) {
|
result = when (psiClass) {
|
||||||
is KotlinLightClassForPackage -> {
|
is KotlinLightClassForFacade -> {
|
||||||
psiClass.files.asSequence().map { createBreakpointIfPropertyExists(it, it, className, fieldName) }.filterNotNull().firstOrNull()
|
psiClass.files.asSequence().map { createBreakpointIfPropertyExists(it, it, className, fieldName) }.filterNotNull().firstOrNull()
|
||||||
}
|
}
|
||||||
is KotlinLightClassForExplicitDeclaration -> {
|
is KotlinLightClassForExplicitDeclaration -> {
|
||||||
|
|||||||
+2
-2
@@ -18,13 +18,13 @@ package org.jetbrains.kotlin.idea.debugger.breakpoints.dialog
|
|||||||
|
|
||||||
import com.intellij.psi.PsiClass
|
import com.intellij.psi.PsiClass
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||||
import org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject
|
import org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject
|
||||||
import org.jetbrains.kotlin.psi.JetProperty
|
import org.jetbrains.kotlin.psi.JetProperty
|
||||||
|
|
||||||
fun PsiClass.collectProperties(): Array<DescriptorMemberChooserObject> {
|
fun PsiClass.collectProperties(): Array<DescriptorMemberChooserObject> {
|
||||||
if (this is KotlinLightClassForPackage) {
|
if (this is KotlinLightClassForFacade) {
|
||||||
val result = arrayListOf<DescriptorMemberChooserObject>()
|
val result = arrayListOf<DescriptorMemberChooserObject>()
|
||||||
this.files.forEach {
|
this.files.forEach {
|
||||||
it.getDeclarations().filterIsInstance<JetProperty>().forEach {
|
it.getDeclarations().filterIsInstance<JetProperty>().forEach {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.intellij.refactoring.RefactoringBundle
|
|||||||
import com.intellij.refactoring.util.CommonRefactoringUtil
|
import com.intellij.refactoring.util.CommonRefactoringUtil
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
import org.jetbrains.kotlin.asJava.KotlinLightClass
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForExplicitDeclaration
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade
|
||||||
import org.jetbrains.kotlin.idea.JetBundle
|
import org.jetbrains.kotlin.idea.JetBundle
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
|
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
|
||||||
@@ -76,7 +76,7 @@ public class RenameKotlinClassProcessor : RenameKotlinPsiProcessor() {
|
|||||||
if (element is KotlinLightClassForExplicitDeclaration) {
|
if (element is KotlinLightClassForExplicitDeclaration) {
|
||||||
element.getOrigin()
|
element.getOrigin()
|
||||||
}
|
}
|
||||||
else if (element is KotlinLightClassForPackage) {
|
else if (element is KotlinLightClassForFacade) {
|
||||||
if (showErrors) {
|
if (showErrors) {
|
||||||
CommonRefactoringUtil.showErrorHint(
|
CommonRefactoringUtil.showErrorHint(
|
||||||
element.project, editor,
|
element.project, editor,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class FakeLightClassForPackageTest extends JetLightCodeInsightFixtureTest
|
|||||||
|
|
||||||
assertEquals(3, classes.length);
|
assertEquals(3, classes.length);
|
||||||
|
|
||||||
assertInstanceOf(classes[0], KotlinLightClassForPackage.class);
|
assertInstanceOf(classes[0], KotlinLightClassForFacade.class);
|
||||||
|
|
||||||
Set<JetFile> expectedFiles = Sets.newHashSet(
|
Set<JetFile> expectedFiles = Sets.newHashSet(
|
||||||
LightClassGenerationSupport.getInstance(getProject()).findFilesForPackage(new FqName("test"), searchScope)
|
LightClassGenerationSupport.getInstance(getProject()).findFilesForPackage(new FqName("test"), searchScope)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class LightClassesClasspathSortingTest : KotlinCodeInsightTestCase() {
|
|||||||
|
|
||||||
assertNotNull(psiClass, "Can't find class for $fqName")
|
assertNotNull(psiClass, "Can't find class for $fqName")
|
||||||
psiClass!!
|
psiClass!!
|
||||||
assert(psiClass is KotlinLightClassForExplicitDeclaration || psiClass is KotlinLightClassForPackage,
|
assert(psiClass is KotlinLightClassForExplicitDeclaration || psiClass is KotlinLightClassForFacade,
|
||||||
"Should be an explicit light class, but was $fqName ${psiClass.javaClass}")
|
"Should be an explicit light class, but was $fqName ${psiClass.javaClass}")
|
||||||
assert(psiClass !is KotlinLightClassForDecompiledDeclaration,
|
assert(psiClass !is KotlinLightClassForDecompiledDeclaration,
|
||||||
"Should not be decompiled light class: $fqName ${psiClass.javaClass}")
|
"Should not be decompiled light class: $fqName ${psiClass.javaClass}")
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
|||||||
import com.intellij.testFramework.IdeaTestUtil;
|
import com.intellij.testFramework.IdeaTestUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.asJava.FakeLightClassForFileOfPackage;
|
import org.jetbrains.kotlin.asJava.FakeLightClassForFileOfPackage;
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage;
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade;
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
||||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil;
|
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil;
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
|
||||||
@@ -199,8 +199,8 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (PsiClass psiClass : psiClasses) {
|
for (PsiClass psiClass : psiClasses) {
|
||||||
if (psiClass instanceof KotlinLightClassForPackage) {
|
if (psiClass instanceof KotlinLightClassForFacade) {
|
||||||
Collection<JetFile> files = ((KotlinLightClassForPackage) psiClass).getFiles();
|
Collection<JetFile> files = ((KotlinLightClassForFacade) psiClass).getFiles();
|
||||||
for (JetFile jetFile : files) {
|
for (JetFile jetFile : files) {
|
||||||
createBreakpoints(jetFile);
|
createBreakpoints(jetFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiImportList
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||||
import com.intellij.psi.PsiJavaCodeReferenceElement
|
import com.intellij.psi.PsiJavaCodeReferenceElement
|
||||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForPackage
|
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade
|
||||||
|
|
||||||
class Import(val name: String) : Element() {
|
class Import(val name: String) : Element() {
|
||||||
override fun generateCode(builder: CodeBuilder) {
|
override fun generateCode(builder: CodeBuilder) {
|
||||||
@@ -71,7 +71,7 @@ private fun Converter.filterImport(name: String, ref: PsiJavaCodeReferenceElemen
|
|||||||
if (!JavaToKotlinClassMap.INSTANCE.mapPlatformClass(FqName(name)).isEmpty()) return null
|
if (!JavaToKotlinClassMap.INSTANCE.mapPlatformClass(FqName(name)).isEmpty()) return null
|
||||||
|
|
||||||
val target = ref.resolve()
|
val target = ref.resolve()
|
||||||
if (target is KotlinLightClassForPackage) {
|
if (target is KotlinLightClassForFacade) {
|
||||||
return quoteKeywords(target.getFqName().parent().toString()) + ".*"
|
return quoteKeywords(target.getFqName().parent().toString()) + ".*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user