JvmName annotation support, single-file facade case (just rename file facade class)
- initial implementation of JvmFileClassesProvider
- migrate some of PackagePartClassUtil usages to JvmFileClassesProvider (mostly in Codegen)
- placeholder ("no resolve") implementation for migration period and unclear cases
- tests
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* 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.codegen
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
public class CodegenFileClassesProvider private constructor(private val bindingContext: BindingContext) : JvmFileClassesProvider() {
|
||||||
|
private val fileParts = hashMapOf<JetFile, JvmFileClassInfo>()
|
||||||
|
|
||||||
|
override fun getFileClassFqName(file: JetFile): FqName =
|
||||||
|
getFileClassInfo(file).fileClassFqName
|
||||||
|
|
||||||
|
public fun getFileClassInfo(file: JetFile): JvmFileClassInfo =
|
||||||
|
fileParts.getOrPut(file) { createFileClassInfo(file) }
|
||||||
|
|
||||||
|
private fun createFileClassInfo(file: JetFile): JvmFileClassInfo {
|
||||||
|
val fileAnnotations = JvmFileClassUtil.collectFileAnnotations(file, bindingContext)
|
||||||
|
val jvmClassNameAnnotation = JvmFileClassUtil.parseJvmFileClass(fileAnnotations)
|
||||||
|
return JvmFileClassUtil.getFileClassInfo(file, jvmClassNameAnnotation)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun addFileClassInfo(file: JetFile) {
|
||||||
|
if (fileParts.containsKey(file)) return
|
||||||
|
fileParts[file] = createFileClassInfo(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
public @jvmStatic fun createForCodegenTask(
|
||||||
|
bindingContext: BindingContext,
|
||||||
|
files: Collection<JetFile>,
|
||||||
|
packagesWithObsoleteParts: Collection<FqName>,
|
||||||
|
multifileFacadesWithObsoleteParts: Collection<FqName>
|
||||||
|
) : CodegenFileClassesProvider {
|
||||||
|
val codegenFileClassesManager = CodegenFileClassesProvider(bindingContext)
|
||||||
|
files.forEach {
|
||||||
|
codegenFileClassesManager.addFileClassInfo(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
val packagesToProcess = HashSet<FqName>(packagesWithObsoleteParts)
|
||||||
|
packagesToProcess.addAll(multifileFacadesWithObsoleteParts.map { it.parent() })
|
||||||
|
for (packageFqName in packagesToProcess) {
|
||||||
|
bindingContext.get(BindingContext.PACKAGE_TO_FILES, packageFqName)?.forEach {
|
||||||
|
codegenFileClassesManager.addFileClassInfo(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return codegenFileClassesManager
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JvmMultifileFacadeClassInfo(public val facadeFqName: FqName, public val fileParts: List<JvmFileClassInfo>)
|
||||||
@@ -44,7 +44,7 @@ public class KotlinCodegenFacade {
|
|||||||
|
|
||||||
FqName name = ScriptNameUtil.classNameForScript(script);
|
FqName name = ScriptNameUtil.classNameForScript(script);
|
||||||
Type type = AsmUtil.asmTypeByFqNameWithoutInnerClasses(name);
|
Type type = AsmUtil.asmTypeByFqNameWithoutInnerClasses(name);
|
||||||
registerClassNameForScript(state.getBindingTrace(), script, type);
|
registerClassNameForScript(state.getBindingTrace(), script, type, state.getFileClassesManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
|
|||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.name.SpecialNames;
|
import org.jetbrains.kotlin.name.SpecialNames;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
@@ -74,6 +74,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
|||||||
protected final PropertyCodegen propertyCodegen;
|
protected final PropertyCodegen propertyCodegen;
|
||||||
protected final JetTypeMapper typeMapper;
|
protected final JetTypeMapper typeMapper;
|
||||||
protected final BindingContext bindingContext;
|
protected final BindingContext bindingContext;
|
||||||
|
protected final JvmFileClassesProvider fileClassesManager;
|
||||||
private final MemberCodegen<?> parentCodegen;
|
private final MemberCodegen<?> parentCodegen;
|
||||||
private final ReifiedTypeParametersUsages reifiedTypeParametersUsages = new ReifiedTypeParametersUsages();
|
private final ReifiedTypeParametersUsages reifiedTypeParametersUsages = new ReifiedTypeParametersUsages();
|
||||||
protected final Collection<ClassDescriptor> innerClasses = new LinkedHashSet<ClassDescriptor>();
|
protected final Collection<ClassDescriptor> innerClasses = new LinkedHashSet<ClassDescriptor>();
|
||||||
@@ -94,6 +95,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
this.typeMapper = state.getTypeMapper();
|
this.typeMapper = state.getTypeMapper();
|
||||||
this.bindingContext = state.getBindingContext();
|
this.bindingContext = state.getBindingContext();
|
||||||
|
this.fileClassesManager = state.getFileClassesManager();
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.v = builder;
|
this.v = builder;
|
||||||
@@ -288,7 +290,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
|||||||
return typeMapper.mapType(((ClassContext) outermost).getContextDescriptor());
|
return typeMapper.mapType(((ClassContext) outermost).getContextDescriptor());
|
||||||
}
|
}
|
||||||
else if (outermost instanceof PackageContext && !(outermost instanceof PackageFacadeContext)) {
|
else if (outermost instanceof PackageContext && !(outermost instanceof PackageFacadeContext)) {
|
||||||
return PackagePartClassUtils.getPackagePartType(element.getContainingJetFile());
|
return fileClassesManager.getFileClassType(element.getContainingJetFile());
|
||||||
}/*disabled cause of KT-7775
|
}/*disabled cause of KT-7775
|
||||||
else if (outermost instanceof ScriptContext) {
|
else if (outermost instanceof ScriptContext) {
|
||||||
return asmTypeForScriptDescriptor(bindingContext, ((ScriptContext) outermost).getScriptDescriptor());
|
return asmTypeForScriptDescriptor(bindingContext, ((ScriptContext) outermost).getScriptDescriptor());
|
||||||
@@ -310,7 +312,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
|||||||
@NotNull
|
@NotNull
|
||||||
public NameGenerator getInlineNameGenerator() {
|
public NameGenerator getInlineNameGenerator() {
|
||||||
if (inlineNameGenerator == null) {
|
if (inlineNameGenerator == null) {
|
||||||
String prefix = InlineCodegenUtil.getInlineName(context, typeMapper);
|
String prefix = InlineCodegenUtil.getInlineName(context, typeMapper, fileClassesManager);
|
||||||
inlineNameGenerator = new NameGenerator(prefix);
|
inlineNameGenerator = new NameGenerator(prefix);
|
||||||
}
|
}
|
||||||
return inlineNameGenerator;
|
return inlineNameGenerator;
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ public class PackageCodegen {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private ClassBuilder generate(@NotNull JetFile file, @NotNull Map<CallableMemberDescriptor, Runnable> generateCallableMemberTasks) {
|
private ClassBuilder generate(@NotNull JetFile file, @NotNull Map<CallableMemberDescriptor, Runnable> generateCallableMemberTasks) {
|
||||||
boolean generatePackagePart = false;
|
boolean generatePackagePart = false;
|
||||||
Type packagePartType = PackagePartClassUtils.getPackagePartType(file);
|
Type packagePartType = state.getFileClassesManager().getFileClassType(file);
|
||||||
PackageContext packagePartContext = CodegenContext.STATIC.intoPackagePart(packageFragment, packagePartType);
|
PackageContext packagePartContext = CodegenContext.STATIC.intoPackagePart(packageFragment, packagePartType);
|
||||||
|
|
||||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||||
@@ -414,7 +414,7 @@ public class PackageCodegen {
|
|||||||
|
|
||||||
public void generateClassOrObject(@NotNull JetClassOrObject classOrObject) {
|
public void generateClassOrObject(@NotNull JetClassOrObject classOrObject) {
|
||||||
JetFile file = classOrObject.getContainingJetFile();
|
JetFile file = classOrObject.getContainingJetFile();
|
||||||
Type packagePartType = PackagePartClassUtils.getPackagePartType(file);
|
Type packagePartType = state.getFileClassesManager().getFileClassType(file);
|
||||||
CodegenContext context = CodegenContext.STATIC.intoPackagePart(packageFragment, packagePartType);
|
CodegenContext context = CodegenContext.STATIC.intoPackagePart(packageFragment, packagePartType);
|
||||||
MemberCodegen.genClassOrObject(context, classOrObject, state, null);
|
MemberCodegen.genClassOrObject(context, classOrObject, state, null);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -33,8 +33,8 @@ import org.jetbrains.kotlin.codegen.when.SwitchCodegenUtil;
|
|||||||
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
|
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor;
|
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor;
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
@@ -75,12 +75,14 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
private final BindingContext bindingContext;
|
private final BindingContext bindingContext;
|
||||||
private final GenerationState.GenerateClassFilter filter;
|
private final GenerationState.GenerateClassFilter filter;
|
||||||
private final JvmRuntimeTypes runtimeTypes;
|
private final JvmRuntimeTypes runtimeTypes;
|
||||||
|
private final JvmFileClassesProvider fileClassesManager;
|
||||||
|
|
||||||
public CodegenAnnotatingVisitor(@NotNull GenerationState state) {
|
public CodegenAnnotatingVisitor(@NotNull GenerationState state) {
|
||||||
this.bindingTrace = state.getBindingTrace();
|
this.bindingTrace = state.getBindingTrace();
|
||||||
this.bindingContext = state.getBindingContext();
|
this.bindingContext = state.getBindingContext();
|
||||||
this.filter = state.getGenerateDeclaredClassFilter();
|
this.filter = state.getGenerateDeclaredClassFilter();
|
||||||
this.runtimeTypes = state.getJvmRuntimeTypes();
|
this.runtimeTypes = state.getJvmRuntimeTypes();
|
||||||
|
this.fileClassesManager = state.getFileClassesManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -333,7 +335,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void recordClosure(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
|
private void recordClosure(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
|
||||||
CodegenBinding.recordClosure(bindingTrace, classDescriptor, peekFromStack(classStack), Type.getObjectType(name));
|
CodegenBinding.recordClosure(bindingTrace, classDescriptor, peekFromStack(classStack), Type.getObjectType(name), fileClassesManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -391,7 +393,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
else if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
else if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
||||||
JetFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
|
JetFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
|
||||||
assert containingFile != null : "File not found for " + descriptor;
|
assert containingFile != null : "File not found for " + descriptor;
|
||||||
return PackagePartClassUtils.getPackagePartInternalName(containingFile) + '$' + name;
|
return fileClassesManager.getFileClassInternalName(containingFile) + '$' + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -572,7 +574,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PackagePartClassUtils.getPackagePartInternalName(file);
|
return fileClassesManager.getFileClassInternalName(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T peekFromStack(@NotNull Stack<T> stack) {
|
private static <T> T peekFromStack(@NotNull Stack<T> stack) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
|
|||||||
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
|
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
@@ -161,7 +162,8 @@ public class CodegenBinding {
|
|||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull ClassDescriptor classDescriptor,
|
@NotNull ClassDescriptor classDescriptor,
|
||||||
@Nullable ClassDescriptor enclosing,
|
@Nullable ClassDescriptor enclosing,
|
||||||
@NotNull Type asmType
|
@NotNull Type asmType,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager
|
||||||
) {
|
) {
|
||||||
JetElement element = (JetElement) descriptorToDeclaration(classDescriptor);
|
JetElement element = (JetElement) descriptorToDeclaration(classDescriptor);
|
||||||
assert element != null : "No source element for " + classDescriptor;
|
assert element != null : "No source element for " + classDescriptor;
|
||||||
@@ -172,7 +174,7 @@ public class CodegenBinding {
|
|||||||
closure.setCaptureThis();
|
closure.setCaptureThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert PsiCodegenPredictor.checkPredictedNameFromPsi(classDescriptor, asmType);
|
assert PsiCodegenPredictor.checkPredictedNameFromPsi(classDescriptor, asmType, fileClassesManager);
|
||||||
trace.record(ASM_TYPE, classDescriptor, asmType);
|
trace.record(ASM_TYPE, classDescriptor, asmType);
|
||||||
trace.record(CLOSURE, classDescriptor, closure);
|
trace.record(CLOSURE, classDescriptor, closure);
|
||||||
|
|
||||||
@@ -197,7 +199,12 @@ public class CodegenBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SCRIPT: register asmType for script, move to ScriptingUtil
|
// SCRIPT: register asmType for script, move to ScriptingUtil
|
||||||
public static void registerClassNameForScript(@NotNull BindingTrace trace, @NotNull JetScript script, @NotNull Type asmType) {
|
public static void registerClassNameForScript(
|
||||||
|
@NotNull BindingTrace trace,
|
||||||
|
@NotNull JetScript script,
|
||||||
|
@NotNull Type asmType,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager
|
||||||
|
) {
|
||||||
ScriptDescriptor descriptor = trace.getBindingContext().get(SCRIPT, script);
|
ScriptDescriptor descriptor = trace.getBindingContext().get(SCRIPT, script);
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
throw new IllegalStateException("Script descriptor is not found for PSI: " + PsiUtilPackage.getElementTextWithContext(script));
|
throw new IllegalStateException("Script descriptor is not found for PSI: " + PsiUtilPackage.getElementTextWithContext(script));
|
||||||
@@ -210,7 +217,7 @@ public class CodegenBinding {
|
|||||||
toSourceElement(script));
|
toSourceElement(script));
|
||||||
classDescriptor.initialize(JetScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
|
classDescriptor.initialize(JetScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
|
||||||
|
|
||||||
recordClosure(trace, classDescriptor, null, asmType);
|
recordClosure(trace, classDescriptor, null, asmType, fileClassesManager);
|
||||||
|
|
||||||
trace.record(CLASS_FOR_SCRIPT, descriptor, classDescriptor);
|
trace.record(CLASS_FOR_SCRIPT, descriptor, classDescriptor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.codegen.AsmUtil;
|
import org.jetbrains.kotlin.codegen.AsmUtil;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
@@ -33,10 +33,14 @@ public final class PsiCodegenPredictor {
|
|||||||
private PsiCodegenPredictor() {
|
private PsiCodegenPredictor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkPredictedNameFromPsi(@NotNull DeclarationDescriptor descriptor, @Nullable Type nameFromDescriptors) {
|
public static boolean checkPredictedNameFromPsi(
|
||||||
|
@NotNull DeclarationDescriptor descriptor,
|
||||||
|
@Nullable Type nameFromDescriptors,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager
|
||||||
|
) {
|
||||||
PsiElement element = descriptorToDeclaration(descriptor);
|
PsiElement element = descriptorToDeclaration(descriptor);
|
||||||
if (element instanceof JetDeclaration) {
|
if (element instanceof JetDeclaration) {
|
||||||
String classNameFromPsi = getPredefinedJvmInternalName((JetDeclaration) element);
|
String classNameFromPsi = getPredefinedJvmInternalName((JetDeclaration) element, fileClassesManager);
|
||||||
assert classNameFromPsi == null || Type.getObjectType(classNameFromPsi).equals(nameFromDescriptors) :
|
assert classNameFromPsi == null || Type.getObjectType(classNameFromPsi).equals(nameFromDescriptors) :
|
||||||
String.format("Invalid algorithm for getting qualified name from psi! Predicted: %s, actual %s\n" +
|
String.format("Invalid algorithm for getting qualified name from psi! Predicted: %s, actual %s\n" +
|
||||||
"Element: %s", classNameFromPsi, nameFromDescriptors, element.getText());
|
"Element: %s", classNameFromPsi, nameFromDescriptors, element.getText());
|
||||||
@@ -49,7 +53,10 @@ public final class PsiCodegenPredictor {
|
|||||||
* @return null if no prediction can be done.
|
* @return null if no prediction can be done.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getPredefinedJvmInternalName(@NotNull JetDeclaration declaration) {
|
public static String getPredefinedJvmInternalName(
|
||||||
|
@NotNull JetDeclaration declaration,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager
|
||||||
|
) {
|
||||||
// TODO: Method won't work for declarations inside companion objects
|
// TODO: Method won't work for declarations inside companion objects
|
||||||
// TODO: Method won't give correct class name for traits implementations
|
// TODO: Method won't give correct class name for traits implementations
|
||||||
|
|
||||||
@@ -57,7 +64,7 @@ public final class PsiCodegenPredictor {
|
|||||||
|
|
||||||
String parentInternalName;
|
String parentInternalName;
|
||||||
if (parentDeclaration != null) {
|
if (parentDeclaration != null) {
|
||||||
parentInternalName = getPredefinedJvmInternalName(parentDeclaration);
|
parentInternalName = getPredefinedJvmInternalName(parentDeclaration, fileClassesManager);
|
||||||
if (parentInternalName == null) {
|
if (parentInternalName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -67,7 +74,7 @@ public final class PsiCodegenPredictor {
|
|||||||
|
|
||||||
if (declaration instanceof JetNamedFunction) {
|
if (declaration instanceof JetNamedFunction) {
|
||||||
Name name = ((JetNamedFunction) declaration).getNameAsName();
|
Name name = ((JetNamedFunction) declaration).getNameAsName();
|
||||||
return name == null ? null : PackagePartClassUtils.getPackagePartInternalName(containingFile) + "$" + name.asString();
|
return name == null ? null : fileClassesManager.getFileClassInternalName(containingFile) + "$" + name.asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
parentInternalName = AsmUtil.internalNameByFqNameWithoutInnerClasses(containingFile.getPackageFqName());
|
parentInternalName = AsmUtil.internalNameByFqNameWithoutInnerClasses(containingFile.getPackageFqName());
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ import org.jetbrains.kotlin.codegen.context.PackageContext;
|
|||||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||||
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
|
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder;
|
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder;
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
|
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
|
||||||
import org.jetbrains.kotlin.name.ClassId;
|
import org.jetbrains.kotlin.name.ClassId;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
@@ -204,11 +204,20 @@ public class InlineCodegenUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getInlineName(@NotNull CodegenContext codegenContext, @NotNull JetTypeMapper typeMapper) {
|
public static String getInlineName(
|
||||||
return getInlineName(codegenContext, codegenContext.getContextDescriptor(), typeMapper);
|
@NotNull CodegenContext codegenContext,
|
||||||
|
@NotNull JetTypeMapper typeMapper,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager
|
||||||
|
) {
|
||||||
|
return getInlineName(codegenContext, codegenContext.getContextDescriptor(), typeMapper, fileClassesManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getInlineName(@NotNull CodegenContext codegenContext, @NotNull DeclarationDescriptor currentDescriptor, @NotNull JetTypeMapper typeMapper) {
|
private static String getInlineName(
|
||||||
|
@NotNull CodegenContext codegenContext,
|
||||||
|
@NotNull DeclarationDescriptor currentDescriptor,
|
||||||
|
@NotNull JetTypeMapper typeMapper,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager
|
||||||
|
) {
|
||||||
if (currentDescriptor instanceof PackageFragmentDescriptor) {
|
if (currentDescriptor instanceof PackageFragmentDescriptor) {
|
||||||
PsiFile file = getContainingFile(codegenContext);
|
PsiFile file = getContainingFile(codegenContext);
|
||||||
|
|
||||||
@@ -218,7 +227,7 @@ public class InlineCodegenUtil {
|
|||||||
assert codegenContext instanceof PackageContext : "Expected package context but " + codegenContext;
|
assert codegenContext instanceof PackageContext : "Expected package context but " + codegenContext;
|
||||||
packagePartType = ((PackageContext) codegenContext).getPackagePartType();
|
packagePartType = ((PackageContext) codegenContext).getPackagePartType();
|
||||||
} else {
|
} else {
|
||||||
packagePartType = PackagePartClassUtils.getPackagePartType((JetFile) file);
|
packagePartType = fileClassesManager.getFileClassType((JetFile) file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packagePartType == null) {
|
if (packagePartType == null) {
|
||||||
@@ -245,7 +254,7 @@ public class InlineCodegenUtil {
|
|||||||
String suffix = currentDescriptor.getName().isSpecial() ? "" : currentDescriptor.getName().asString();
|
String suffix = currentDescriptor.getName().isSpecial() ? "" : currentDescriptor.getName().asString();
|
||||||
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return getInlineName(codegenContext, currentDescriptor.getContainingDeclaration(), typeMapper) + "$" + suffix;
|
return getInlineName(codegenContext, currentDescriptor.getContainingDeclaration(), typeMapper, fileClassesManager) + "$" + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInvokeOnLambda(@NotNull String owner, @NotNull String name) {
|
public static boolean isInvokeOnLambda(@NotNull String owner, @NotNull String name) {
|
||||||
|
|||||||
+2
-1
@@ -19,12 +19,13 @@ package org.jetbrains.kotlin.codegen.signature
|
|||||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||||
import org.jetbrains.kotlin.codegen.state.JetTypeMapper
|
import org.jetbrains.kotlin.codegen.state.JetTypeMapper
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
|
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper
|
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper
|
||||||
|
|
||||||
public class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper {
|
public class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper {
|
||||||
// We use empty BindingContext, because it is only used by JetTypeMapper for purposes irrelevant to the needs of this class
|
// We use empty BindingContext, because it is only used by JetTypeMapper for purposes irrelevant to the needs of this class
|
||||||
private val typeMapper: JetTypeMapper = JetTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES)
|
private val typeMapper: JetTypeMapper = JetTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider)
|
||||||
|
|
||||||
override fun mapToJvmMethodSignature(function: FunctionDescriptor) = typeMapper.mapSignature(function)
|
override fun mapToJvmMethodSignature(function: FunctionDescriptor) = typeMapper.mapSignature(function)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
|||||||
import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider
|
||||||
|
|
||||||
private val EXTERNAL_SOURCES_KINDS = arrayOf(
|
private val EXTERNAL_SOURCES_KINDS = arrayOf(
|
||||||
JvmDeclarationOriginKind.DELEGATION_TO_TRAIT_IMPL,
|
JvmDeclarationOriginKind.DELEGATION_TO_TRAIT_IMPL,
|
||||||
@@ -40,11 +41,12 @@ private val EXTERNAL_SOURCES_KINDS = arrayOf(
|
|||||||
class BuilderFactoryForDuplicateSignatureDiagnostics(
|
class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||||
builderFactory: ClassBuilderFactory,
|
builderFactory: ClassBuilderFactory,
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
private val diagnostics: DiagnosticSink
|
private val diagnostics: DiagnosticSink,
|
||||||
|
fileClassesProvider: JvmFileClassesProvider
|
||||||
) : SignatureCollectingClassBuilderFactory(builderFactory) {
|
) : SignatureCollectingClassBuilderFactory(builderFactory) {
|
||||||
|
|
||||||
// Avoid errors when some classes are not loaded for some reason
|
// Avoid errors when some classes are not loaded for some reason
|
||||||
private val typeMapper = JetTypeMapper(bindingContext, ClassBuilderMode.LIGHT_CLASSES)
|
private val typeMapper = JetTypeMapper(bindingContext, ClassBuilderMode.LIGHT_CLASSES, fileClassesProvider)
|
||||||
|
|
||||||
override fun handleClashingSignatures(data: ConflictingJvmDeclarationsData) {
|
override fun handleClashingSignatures(data: ConflictingJvmDeclarationsData) {
|
||||||
val noOwnImplementations = data.signatureOrigins.all { it.originKind in EXTERNAL_SOURCES_KINDS }
|
val noOwnImplementations = data.signatureOrigins.all { it.originKind in EXTERNAL_SOURCES_KINDS }
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
|
|||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider
|
||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||||
import org.jetbrains.kotlin.modules.TargetId
|
import org.jetbrains.kotlin.modules.TargetId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -81,10 +82,15 @@ public class GenerationState jvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public val fileClassesManager: CodegenFileClassesProvider =
|
||||||
|
CodegenFileClassesProvider.createForCodegenTask(bindingContext, files, packagesWithObsoleteParts,
|
||||||
|
/* TODO */ multifileFacadesWithObsoleteParts = emptySet())
|
||||||
|
|
||||||
public val classBuilderMode: ClassBuilderMode = builderFactory.getClassBuilderMode()
|
public val classBuilderMode: ClassBuilderMode = builderFactory.getClassBuilderMode()
|
||||||
public val bindingTrace: BindingTrace = DelegatingBindingTrace(bindingContext, "trace in GenerationState")
|
public val bindingTrace: BindingTrace = DelegatingBindingTrace(bindingContext, "trace in GenerationState")
|
||||||
public val bindingContext: BindingContext = bindingTrace.getBindingContext()
|
public val bindingContext: BindingContext = bindingTrace.getBindingContext()
|
||||||
public val typeMapper: JetTypeMapper = JetTypeMapperWithOutDirectory(this.bindingContext, classBuilderMode, outDirectory)
|
public val typeMapper: JetTypeMapper =
|
||||||
|
JetTypeMapperWithOutDirectory(this.bindingContext, classBuilderMode, fileClassesManager, outDirectory)
|
||||||
public val intrinsics: IntrinsicMethods = IntrinsicMethods()
|
public val intrinsics: IntrinsicMethods = IntrinsicMethods()
|
||||||
public val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this)
|
public val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this)
|
||||||
public val inlineCycleReporter: InlineCycleReporter = InlineCycleReporter(diagnostics)
|
public val inlineCycleReporter: InlineCycleReporter = InlineCycleReporter(diagnostics)
|
||||||
@@ -108,7 +114,7 @@ public class GenerationState jvmOverloads constructor(
|
|||||||
init {
|
init {
|
||||||
val optimizationClassBuilderFactory = OptimizationClassBuilderFactory(builderFactory, disableOptimization)
|
val optimizationClassBuilderFactory = OptimizationClassBuilderFactory(builderFactory, disableOptimization)
|
||||||
var interceptedBuilderFactory: ClassBuilderFactory = BuilderFactoryForDuplicateSignatureDiagnostics(
|
var interceptedBuilderFactory: ClassBuilderFactory = BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||||
optimizationClassBuilderFactory, this.bindingContext, diagnostics)
|
optimizationClassBuilderFactory, this.bindingContext, diagnostics, fileClassesManager)
|
||||||
|
|
||||||
interceptedBuilderFactory = BuilderFactoryForDuplicateClassNameDiagnostics(interceptedBuilderFactory, diagnostics);
|
interceptedBuilderFactory = BuilderFactoryForDuplicateClassNameDiagnostics(interceptedBuilderFactory, diagnostics);
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ import org.jetbrains.kotlin.codegen.binding.PsiCodegenPredictor;
|
|||||||
import org.jetbrains.kotlin.codegen.context.CodegenContext;
|
import org.jetbrains.kotlin.codegen.context.CodegenContext;
|
||||||
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
|
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
|
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
|
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
||||||
import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeDeclarationsPackage;
|
import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeDeclarationsPackage;
|
||||||
import org.jetbrains.kotlin.name.ClassId;
|
import org.jetbrains.kotlin.name.ClassId;
|
||||||
@@ -82,10 +82,16 @@ import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
|||||||
public class JetTypeMapper {
|
public class JetTypeMapper {
|
||||||
private final BindingContext bindingContext;
|
private final BindingContext bindingContext;
|
||||||
private final ClassBuilderMode classBuilderMode;
|
private final ClassBuilderMode classBuilderMode;
|
||||||
|
private final JvmFileClassesProvider fileClassesManager;
|
||||||
|
|
||||||
public JetTypeMapper(@NotNull BindingContext bindingContext, @NotNull ClassBuilderMode classBuilderMode) {
|
public JetTypeMapper(
|
||||||
|
@NotNull BindingContext bindingContext,
|
||||||
|
@NotNull ClassBuilderMode classBuilderMode,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager
|
||||||
|
) {
|
||||||
this.bindingContext = bindingContext;
|
this.bindingContext = bindingContext;
|
||||||
this.classBuilderMode = classBuilderMode;
|
this.classBuilderMode = classBuilderMode;
|
||||||
|
this.fileClassesManager = fileClassesManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -154,7 +160,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static String internalNameForPackage(
|
private String internalNameForPackage(
|
||||||
@NotNull PackageFragmentDescriptor packageFragment,
|
@NotNull PackageFragmentDescriptor packageFragment,
|
||||||
@NotNull CallableMemberDescriptor descriptor,
|
@NotNull CallableMemberDescriptor descriptor,
|
||||||
boolean insideModule
|
boolean insideModule
|
||||||
@@ -162,7 +168,7 @@ public class JetTypeMapper {
|
|||||||
///if (insideModule) {
|
///if (insideModule) {
|
||||||
JetFile file = DescriptorToSourceUtils.getContainingFile(descriptor);
|
JetFile file = DescriptorToSourceUtils.getContainingFile(descriptor);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
return PackagePartClassUtils.getPackagePartInternalName(file);
|
return fileClassesManager.getFileClassInternalName(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallableMemberDescriptor directMember = getDirectMember(descriptor);
|
CallableMemberDescriptor directMember = getDirectMember(descriptor);
|
||||||
@@ -396,7 +402,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Type asmType = Type.getObjectType(computeAsmTypeImpl(klass));
|
Type asmType = Type.getObjectType(computeAsmTypeImpl(klass));
|
||||||
assert PsiCodegenPredictor.checkPredictedNameFromPsi(klass, asmType);
|
assert PsiCodegenPredictor.checkPredictedNameFromPsi(klass, asmType, fileClassesManager);
|
||||||
return asmType;
|
return asmType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.state;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode;
|
import org.jetbrains.kotlin.codegen.ClassBuilderMode;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -32,9 +33,10 @@ public class JetTypeMapperWithOutDirectory extends JetTypeMapper {
|
|||||||
public JetTypeMapperWithOutDirectory(
|
public JetTypeMapperWithOutDirectory(
|
||||||
@NotNull BindingContext bindingContext,
|
@NotNull BindingContext bindingContext,
|
||||||
@NotNull ClassBuilderMode classBuilderMode,
|
@NotNull ClassBuilderMode classBuilderMode,
|
||||||
|
@NotNull JvmFileClassesProvider fileClassesManager,
|
||||||
@Nullable File outDirectory
|
@Nullable File outDirectory
|
||||||
) {
|
) {
|
||||||
super(bindingContext, classBuilderMode);
|
super(bindingContext, classBuilderMode, fileClassesManager);
|
||||||
this.outDirectory = outDirectory;
|
this.outDirectory = outDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ public class ReplInterpreter {
|
|||||||
|
|
||||||
PsiElement jetScript = descriptorToDeclaration(earlierDescriptor);
|
PsiElement jetScript = descriptorToDeclaration(earlierDescriptor);
|
||||||
if (jetScript != null) {
|
if (jetScript != null) {
|
||||||
registerClassNameForScript(state.getBindingTrace(), (JetScript) jetScript, earlierClassType);
|
registerClassNameForScript(state.getBindingTrace(), (JetScript) jetScript, earlierClassType, state.getFileClassesManager());
|
||||||
earlierScriptDescriptors.add(earlierDescriptor);
|
earlierScriptDescriptors.add(earlierDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ public class ReplInterpreter {
|
|||||||
@NotNull CompilationErrorHandler errorHandler
|
@NotNull CompilationErrorHandler errorHandler
|
||||||
) {
|
) {
|
||||||
registerEarlierScripts(state, earlierScripts);
|
registerEarlierScripts(state, earlierScripts);
|
||||||
registerClassNameForScript(state.getBindingTrace(), script, classType);
|
registerClassNameForScript(state.getBindingTrace(), script, classType, state.getFileClassesManager());
|
||||||
|
|
||||||
state.beforeCompile();
|
state.beforeCompile();
|
||||||
KotlinCodegenFacade.generatePackage(
|
KotlinCodegenFacade.generatePackage(
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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.fileClasses
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
|
|
||||||
|
public interface JvmFileClassInfo {
|
||||||
|
public val fileClassFqName: FqName
|
||||||
|
public val facadeClassFqName: FqName
|
||||||
|
public val kind: Kind
|
||||||
|
|
||||||
|
public enum class Kind {
|
||||||
|
FILE_CLASS,
|
||||||
|
MULTIFILE_CLASS_PART
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JvmFileFacadeInfo(
|
||||||
|
override val fileClassFqName: FqName
|
||||||
|
) : JvmFileClassInfo {
|
||||||
|
override val facadeClassFqName: FqName
|
||||||
|
get() = fileClassFqName
|
||||||
|
override val kind: JvmFileClassInfo.Kind
|
||||||
|
get() = JvmFileClassInfo.Kind.FILE_CLASS
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JvmMultifileFacadePartInfo(
|
||||||
|
override val fileClassFqName: FqName,
|
||||||
|
override val facadeClassFqName: FqName
|
||||||
|
) : JvmFileClassInfo {
|
||||||
|
override val kind: JvmFileClassInfo.Kind
|
||||||
|
get() = JvmFileClassInfo.Kind.MULTIFILE_CLASS_PART
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* 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.fileClasses
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl
|
||||||
|
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||||
|
|
||||||
|
public object JvmFileClassUtil {
|
||||||
|
public val JVM_NAME: FqName = FqName("kotlin.jvm.jvmName")
|
||||||
|
public val JVM_NAME_SHORT: String = JVM_NAME.shortName().asString()
|
||||||
|
|
||||||
|
// TODO @JvmMultifileClass
|
||||||
|
|
||||||
|
public @jvmStatic fun getFileClassInfo(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations?): JvmFileClassInfo =
|
||||||
|
if (jvmFileClassAnnotations != null)
|
||||||
|
getFileClassInfoForAnnotation(file, jvmFileClassAnnotations)
|
||||||
|
else
|
||||||
|
getDefaultFileClassInfo(file)
|
||||||
|
|
||||||
|
public @jvmStatic fun getFileClassInfoForAnnotation(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): JvmFileClassInfo =
|
||||||
|
if (jvmFileClassAnnotations.multipleFiles)
|
||||||
|
JvmMultifileFacadePartInfo(getHiddenPartFqName(file, jvmFileClassAnnotations),
|
||||||
|
getFacadeFqName(file, jvmFileClassAnnotations))
|
||||||
|
else
|
||||||
|
JvmFileFacadeInfo(getFacadeFqName(file, jvmFileClassAnnotations))
|
||||||
|
|
||||||
|
public @jvmStatic fun getDefaultFileClassInfo(file: JetFile): JvmFileClassInfo =
|
||||||
|
JvmFileFacadeInfo(PackagePartClassUtils.getPackagePartFqName(file.packageFqName, file.name))
|
||||||
|
|
||||||
|
public @jvmStatic fun getFacadeFqName(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
|
||||||
|
file.packageFqName.child(Name.identifier(jvmFileClassAnnotations.name))
|
||||||
|
|
||||||
|
public @jvmStatic fun getHiddenPartFqName(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
|
||||||
|
file.packageFqName.child(Name.identifier(manglePartName(jvmFileClassAnnotations.name, file.name)))
|
||||||
|
|
||||||
|
public @jvmStatic fun manglePartName(facadeName: String, fileName: String): String =
|
||||||
|
"${facadeName}__${PackagePartClassUtils.getFilePartShortName(fileName)}"
|
||||||
|
|
||||||
|
public @jvmStatic fun parseJvmFileClass(annotations: Annotations): ParsedJmvFileClassAnnotations? {
|
||||||
|
val jvmName = annotations.findAnnotation(JVM_NAME)
|
||||||
|
// TODO @JvmMultifileClass
|
||||||
|
return if (jvmName != null) parseJvmFileClass(jvmName) else null
|
||||||
|
}
|
||||||
|
|
||||||
|
public @jvmStatic fun parseJvmFileClass(jvmName: AnnotationDescriptor): ParsedJmvFileClassAnnotations {
|
||||||
|
val name = jvmName.allValueArguments.values().firstOrNull()?.let { (it as? StringValue)?.value }
|
||||||
|
return ParsedJmvFileClassAnnotations(name!!, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
public @jvmStatic fun getFileClassInfoNoResolve(file: JetFile): JvmFileClassInfo =
|
||||||
|
getFileClassInfo(file, parseJvmNameOnFileNoResolve(file))
|
||||||
|
|
||||||
|
public @jvmStatic fun parseJvmNameOnFileNoResolve(file: JetFile): ParsedJmvFileClassAnnotations? =
|
||||||
|
findJvmNameOnFileNoResolve(file)?.let { parseJvmNameOnFileNoResolve(it) }
|
||||||
|
|
||||||
|
public @jvmStatic fun findJvmNameOnFileNoResolve(file: JetFile): JetAnnotationEntry? =
|
||||||
|
file.fileAnnotationList?.annotationEntries?.firstOrNull {
|
||||||
|
it.calleeExpression?.constructorReferenceExpression?.getReferencedName() == JVM_NAME_SHORT
|
||||||
|
}
|
||||||
|
|
||||||
|
public @jvmStatic fun parseJvmNameOnFileNoResolve(annotationEntry: JetAnnotationEntry): ParsedJmvFileClassAnnotations? {
|
||||||
|
val nameExpr = annotationEntry.valueArguments.firstOrNull()?.getArgumentExpression() ?: return null
|
||||||
|
val name = getLiteralStringFromRestrictedConstExpression(nameExpr)
|
||||||
|
return name?.let { ParsedJmvFileClassAnnotations(it, false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private @jvmStatic fun getLiteralStringFromRestrictedConstExpression(argumentExpression: JetExpression?): String? {
|
||||||
|
val stringTemplate = argumentExpression as? JetStringTemplateExpression ?: return null
|
||||||
|
val stringTemplateEntries = stringTemplate.entries
|
||||||
|
if (stringTemplateEntries.size() != 1) return null
|
||||||
|
val singleEntry = stringTemplateEntries[0] as? JetLiteralStringTemplateEntry ?: return null
|
||||||
|
return singleEntry.text
|
||||||
|
}
|
||||||
|
|
||||||
|
public @jvmStatic fun collectFileAnnotations(file: JetFile, bindingContext: BindingContext): Annotations {
|
||||||
|
val fileAnnotationsList = file.fileAnnotationList ?: return Annotations.EMPTY
|
||||||
|
val annotationDescriptors = arrayListOf<AnnotationDescriptor>()
|
||||||
|
for (annotationEntry in fileAnnotationsList.annotationEntries) {
|
||||||
|
bindingContext.get(BindingContext.ANNOTATION, annotationEntry)?.let { annotationDescriptors.add(it) }
|
||||||
|
}
|
||||||
|
return AnnotationsImpl(annotationDescriptors)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ParsedJmvFileClassAnnotations(public val name: String, public val multipleFiles: Boolean)
|
||||||
@@ -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.fileClasses
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
|
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||||
|
import org.jetbrains.org.objectweb.asm.Type
|
||||||
|
|
||||||
|
public abstract class JvmFileClassesProvider {
|
||||||
|
public abstract fun getFileClassFqName(file: JetFile): FqName
|
||||||
|
|
||||||
|
public fun getFileClassInternalName(file: JetFile): String =
|
||||||
|
JvmClassName.byFqNameWithoutInnerClasses(getFileClassFqName(file)).internalName
|
||||||
|
|
||||||
|
public fun getFileClassType(file: JetFile): Type =
|
||||||
|
Type.getObjectType(getFileClassInternalName(file))
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.fileClasses
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
|
|
||||||
|
|
||||||
|
public object NoResolveFileClassesProvider : JvmFileClassesProvider() {
|
||||||
|
override fun getFileClassFqName(file: JetFile): FqName =
|
||||||
|
JvmFileClassUtil.getFileClassInfo(file, JvmFileClassUtil.parseJvmNameOnFileNoResolve(file)).fileClassFqName
|
||||||
|
}
|
||||||
+4
-6
@@ -28,10 +28,9 @@ import org.jetbrains.kotlin.psi.JetProperty
|
|||||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||||
import org.jetbrains.org.objectweb.asm.Type
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
public object PackagePartClassUtils {
|
public object PackagePartClassUtils {
|
||||||
public @jvmStatic fun getPathHashCode(file: VirtualFile): Int =
|
public @jvmStatic fun getPathHashCode(file: VirtualFile): Int =
|
||||||
file.path.toLowerCase().hashCode()
|
file.path.toLowerCase().hashCode()
|
||||||
|
|
||||||
@@ -66,16 +65,14 @@ import java.util.*
|
|||||||
public @jvmStatic fun isPartClassFqName(classFqName: FqName): Boolean =
|
public @jvmStatic fun isPartClassFqName(classFqName: FqName): Boolean =
|
||||||
classFqName.shortName().asString().endsWith(PART_CLASS_NAME_SUFFIX)
|
classFqName.shortName().asString().endsWith(PART_CLASS_NAME_SUFFIX)
|
||||||
|
|
||||||
public @jvmStatic fun getPackagePartType(file: JetFile): Type =
|
@deprecated("Migrate to JvmFileClassesProvider")
|
||||||
Type.getObjectType(getPackagePartInternalName(file))
|
|
||||||
|
|
||||||
public @jvmStatic fun getPackagePartInternalName(file: JetFile): String =
|
public @jvmStatic fun getPackagePartInternalName(file: JetFile): String =
|
||||||
JvmClassName.byFqNameWithoutInnerClasses(getPackagePartFqName(file)).internalName
|
JvmClassName.byFqNameWithoutInnerClasses(getPackagePartFqName(file)).internalName
|
||||||
|
|
||||||
|
@deprecated("Migrate to JvmFileClassesProvider")
|
||||||
public @jvmStatic fun getPackagePartFqName(file: JetFile): FqName =
|
public @jvmStatic fun getPackagePartFqName(file: JetFile): FqName =
|
||||||
getPackagePartFqName(file.packageFqName, file.name)
|
getPackagePartFqName(file.packageFqName, file.name)
|
||||||
|
|
||||||
|
|
||||||
public @jvmStatic fun getPackagePartFqName(callable: DeserializedCallableMemberDescriptor): FqName {
|
public @jvmStatic fun getPackagePartFqName(callable: DeserializedCallableMemberDescriptor): FqName {
|
||||||
val implClassName = callable.nameResolver.getName(callable.proto.getExtension(JvmProtoBuf.implClassName))
|
val implClassName = callable.nameResolver.getName(callable.proto.getExtension(JvmProtoBuf.implClassName))
|
||||||
val packageFqName = (callable.containingDeclaration as PackageFragmentDescriptor).fqName
|
val packageFqName = (callable.containingDeclaration as PackageFragmentDescriptor).fqName
|
||||||
@@ -93,4 +90,5 @@ import java.util.*
|
|||||||
|
|
||||||
public @jvmStatic fun getFilePartShortName(fileName: String): String =
|
public @jvmStatic fun getFilePartShortName(fileName: String): String =
|
||||||
getPartClassName(FileUtil.getNameWithoutExtension(fileName))
|
getPartClassName(FileUtil.getNameWithoutExtension(fileName))
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
public interface KotlinFileStub : PsiFileStub<JetFile> {
|
public interface KotlinFileStub : PsiFileStub<JetFile> {
|
||||||
public fun getPackageFqName(): FqName
|
public fun getPackageFqName(): FqName
|
||||||
public fun getFacadeSimpleName(): String?
|
public fun getFacadeSimpleName(): String?
|
||||||
|
public fun getPartSimpleName(): String?
|
||||||
public fun isScript(): Boolean
|
public fun isScript(): Boolean
|
||||||
public fun findImportsByAlias(alias: String): List<KotlinImportDirectiveStub>
|
public fun findImportsByAlias(alias: String): List<KotlinImportDirectiveStub>
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -69,6 +69,7 @@ public class JetFileElementType extends IStubFileElementType<KotlinFileStub> {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
dataStream.writeName(stub.getPackageFqName().asString());
|
dataStream.writeName(stub.getPackageFqName().asString());
|
||||||
dataStream.writeName(stub.getFacadeSimpleName());
|
dataStream.writeName(stub.getFacadeSimpleName());
|
||||||
|
dataStream.writeName(stub.getPartSimpleName());
|
||||||
dataStream.writeBoolean(stub.isScript());
|
dataStream.writeBoolean(stub.isScript());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +79,8 @@ public class JetFileElementType extends IStubFileElementType<KotlinFileStub> {
|
|||||||
StringRef packageFqNameAsString = dataStream.readName();
|
StringRef packageFqNameAsString = dataStream.readName();
|
||||||
boolean isScript = dataStream.readBoolean();
|
boolean isScript = dataStream.readBoolean();
|
||||||
StringRef facadeSimpleName = dataStream.readName();
|
StringRef facadeSimpleName = dataStream.readName();
|
||||||
return new KotlinFileStubImpl(null, packageFqNameAsString, facadeSimpleName, isScript);
|
StringRef partSimpleName = dataStream.readName();
|
||||||
|
return new KotlinFileStubImpl(null, packageFqNameAsString, facadeSimpleName, partSimpleName, isScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -32,15 +32,17 @@ import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes
|
|||||||
public class KotlinFileStubImpl(
|
public class KotlinFileStubImpl(
|
||||||
jetFile: JetFile?,
|
jetFile: JetFile?,
|
||||||
private val packageName: StringRef,
|
private val packageName: StringRef,
|
||||||
private val facadeShortName: StringRef?,
|
private val facadeSimpleName: StringRef?,
|
||||||
|
private val partSimpleName: StringRef?,
|
||||||
private val isScript: Boolean
|
private val isScript: Boolean
|
||||||
) : PsiFileStubImpl<JetFile>(jetFile), KotlinFileStub, PsiClassHolderFileStub<JetFile> {
|
) : PsiFileStubImpl<JetFile>(jetFile), KotlinFileStub, PsiClassHolderFileStub<JetFile> {
|
||||||
|
|
||||||
public constructor(jetFile: JetFile?, packageName: String, isScript: Boolean)
|
public constructor(jetFile: JetFile?, packageName: String, isScript: Boolean)
|
||||||
: this(jetFile, StringRef.fromString(packageName)!!, null, isScript)
|
: this(jetFile, StringRef.fromString(packageName)!!, null, null, isScript)
|
||||||
|
|
||||||
override fun getPackageFqName(): FqName = FqName(StringRef.toString(packageName)!!)
|
override fun getPackageFqName(): FqName = FqName(StringRef.toString(packageName)!!)
|
||||||
override fun getFacadeSimpleName(): String? = StringRef.toString(facadeShortName)
|
override fun getFacadeSimpleName(): String? = StringRef.toString(facadeSimpleName)
|
||||||
|
override fun getPartSimpleName(): String? = StringRef.toString(partSimpleName)
|
||||||
override fun isScript(): Boolean = isScript
|
override fun isScript(): Boolean = isScript
|
||||||
override fun getType(): IStubFileElementType<KotlinFileStub> = JetStubElementTypes.FILE
|
override fun getType(): IStubFileElementType<KotlinFileStub> = JetStubElementTypes.FILE
|
||||||
|
|
||||||
@@ -57,15 +59,17 @@ public class KotlinFileStubImpl(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public fun forPackageStub(packageFqName: FqName, isScript: Boolean): KotlinFileStubImpl =
|
public fun forPackageStub(packageFqName: FqName, isScript: Boolean): KotlinFileStubImpl =
|
||||||
KotlinFileStubImpl(null,
|
KotlinFileStubImpl(jetFile = null,
|
||||||
StringRef.fromString(packageFqName.asString())!!,
|
packageName = StringRef.fromString(packageFqName.asString())!!,
|
||||||
null,
|
facadeSimpleName = null,
|
||||||
isScript)
|
partSimpleName = null,
|
||||||
|
isScript = isScript)
|
||||||
|
|
||||||
public fun forFileFacadeStub(facadeFqName: FqName, isScript: Boolean): KotlinFileStubImpl =
|
public fun forFileFacadeStub(facadeFqName: FqName, isScript: Boolean): KotlinFileStubImpl =
|
||||||
KotlinFileStubImpl(null,
|
KotlinFileStubImpl(jetFile = null,
|
||||||
StringRef.fromString(facadeFqName.parent().asString())!!,
|
packageName = StringRef.fromString(facadeFqName.parent().asString())!!,
|
||||||
StringRef.fromString(facadeFqName.shortName().asString())!!,
|
facadeSimpleName = StringRef.fromString(facadeFqName.shortName().asString())!!,
|
||||||
isScript)
|
partSimpleName = StringRef.fromString(facadeFqName.shortName().asString())!!,
|
||||||
|
isScript = isScript)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -35,6 +35,7 @@ import org.jetbrains.annotations.NonNls
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.codegen.binding.PsiCodegenPredictor
|
import org.jetbrains.kotlin.codegen.binding.PsiCodegenPredictor
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider
|
||||||
import org.jetbrains.kotlin.idea.JetLanguage
|
import org.jetbrains.kotlin.idea.JetLanguage
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens.*
|
import org.jetbrains.kotlin.lexer.JetTokens.*
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -410,7 +411,7 @@ public open class KotlinLightClassForExplicitDeclaration(
|
|||||||
val data = getLightClassDataExactly(classOrObject)
|
val data = getLightClassDataExactly(classOrObject)
|
||||||
return data?.jvmQualifiedName
|
return data?.jvmQualifiedName
|
||||||
}
|
}
|
||||||
val internalName = PsiCodegenPredictor.getPredefinedJvmInternalName(classOrObject)
|
val internalName = PsiCodegenPredictor.getPredefinedJvmInternalName(classOrObject, NoResolveFileClassesProvider)
|
||||||
return if (internalName == null) null else JvmClassName.byInternalName(internalName).fqNameForClassNameWithoutDollars
|
return if (internalName == null) null else JvmClassName.byInternalName(internalName).fqNameForClassNameWithoutDollars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
$TESTDATA_DIR$/classAndFacadeClash.kt
|
$TESTDATA_DIR$/classAndFacadeClash.kt
|
||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$TESTDATA_DIR$/classAndFileClassClash.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
@file:jvmName("Foo")
|
||||||
|
package test
|
||||||
|
|
||||||
|
public fun foo() {}
|
||||||
|
|
||||||
|
class Foo {}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/cli/jvm/classAndFileClassClash.kt:1:1: error: duplicate JVM class name 'test/Foo' generated from: package-fragment test, Foo
|
||||||
|
@file:jvmName("Foo")
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/classAndFileClassClash.kt:6:1: error: duplicate JVM class name 'test/Foo' generated from: package-fragment test, Foo
|
||||||
|
class Foo {}
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/classAndOtherFileClassClash1.kt
|
||||||
|
$TESTDATA_DIR$/classAndOtherFileClassClash2.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/cli/jvm/classAndOtherFileClassClash1.kt:1:1: error: duplicate JVM class name 'test/Foo' generated from: Foo, package-fragment test
|
||||||
|
@file:jvmName("Foo")
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/classAndOtherFileClassClash2.kt:3:1: error: duplicate JVM class name 'test/Foo' generated from: Foo, package-fragment test
|
||||||
|
class Foo
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@file:jvmName("Foo")
|
||||||
|
package test
|
||||||
|
|
||||||
|
public fun foo() {}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class Foo
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$TESTDATA_DIR$/fileClassAndFacadeClash.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@file:jvmName("TestPackage")
|
||||||
|
package test
|
||||||
|
|
||||||
|
fun foo() {}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
compiler/testData/cli/jvm/fileClassAndFacadeClash.kt:1:1: error: duplicate JVM class name 'test/TestPackage' generated from: package-fragment test, package-fragment test
|
||||||
|
@file:jvmName("TestPackage")
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$TESTDATA_DIR$/fileClassAndTImplClash.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@file:jvmName("XXX\$\$TImpl")
|
||||||
|
package test
|
||||||
|
|
||||||
|
interface XXX
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
OK
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/fileClassClashMultipleFiles1.kt
|
||||||
|
$TESTDATA_DIR$/fileClassClashMultipleFiles2.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/cli/jvm/fileClassClashMultipleFiles1.kt:1:1: error: duplicate JVM class name 'test/Util' generated from: package-fragment test, package-fragment test
|
||||||
|
@file:jvmName("Util")
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/fileClassClashMultipleFiles2.kt:1:1: error: duplicate JVM class name 'test/Util' generated from: package-fragment test, package-fragment test
|
||||||
|
@file:jvmName("Util")
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@file:jvmName("Util")
|
||||||
|
package test
|
||||||
|
|
||||||
|
public fun foo() {}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@file:jvmName("Util")
|
||||||
|
package test
|
||||||
|
|
||||||
|
public fun bar() {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
public class Baz {
|
||||||
|
public static String baz() {
|
||||||
|
return Foo.foo() + Bar.bar();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
@file:jvmName("Bar")
|
||||||
|
public fun bar(): String = "K"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
fun box(): String = Baz.baz()
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
@file:jvmName("Foo")
|
||||||
|
public fun foo(): String = "O"
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
public class Bar {
|
||||||
|
public static String bar() {
|
||||||
|
return Foo.foo();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
@file:jvmName("Foo")
|
||||||
|
public fun foo(): String = "OK"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fun box(): String = Bar.bar()
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
@file:jvmName("Util")
|
||||||
|
package test
|
||||||
|
|
||||||
|
fun foo(): String = bar()
|
||||||
|
fun bar(): String = qux()
|
||||||
|
fun qux(): String = "OK"
|
||||||
|
|
||||||
|
fun box(): String = foo()
|
||||||
@@ -43,6 +43,18 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("classAndFileClassClash.args")
|
||||||
|
public void testClassAndFileClassClash() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/classAndFileClassClash.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("classAndOtherFileClassClash.args")
|
||||||
|
public void testClassAndOtherFileClassClash() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/classAndOtherFileClassClash.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classAndPartClash.args")
|
@TestMetadata("classAndPartClash.args")
|
||||||
public void testClassAndPartClash() throws Exception {
|
public void testClassAndPartClash() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/classAndPartClash.args");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/classAndPartClash.args");
|
||||||
@@ -97,6 +109,24 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fileClassAndFacadeClash.args")
|
||||||
|
public void testFileClassAndFacadeClash() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/fileClassAndFacadeClash.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fileClassAndTImplClash.args")
|
||||||
|
public void testFileClassAndTImplClash() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/fileClassAndTImplClash.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fileClassClashMultipleFiles.args")
|
||||||
|
public void testFileClassClashMultipleFiles() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/fileClassClashMultipleFiles.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("help.args")
|
@TestMetadata("help.args")
|
||||||
public void testHelp() throws Exception {
|
public void testHelp() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/help.args");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/help.args");
|
||||||
|
|||||||
+22
@@ -121,6 +121,28 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxWithJava/fileClasses")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class FileClasses extends AbstractBlackBoxCodegenTest {
|
||||||
|
public void testAllFilesPresentInFileClasses() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithJava/fileClasses"), Pattern.compile("^([^\\.]+)$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("differentFiles")
|
||||||
|
public void testDifferentFiles() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/fileClasses/differentFiles/");
|
||||||
|
doTestWithJava(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/fileClasses/simple/");
|
||||||
|
doTestWithJava(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxWithJava/interfaces")
|
@TestMetadata("compiler/testData/codegen/boxWithJava/interfaces")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+6
@@ -2244,6 +2244,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformNames/propertyName.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformNames/propertyName.kt");
|
||||||
doTestWithStdlib(fileName);
|
doTestWithStdlib(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("renamedFileClass.kt")
|
||||||
|
public void testRenamedFileClass() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformNames/renamedFileClass.kt");
|
||||||
|
doTestWithStdlib(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic")
|
@TestMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic")
|
||||||
|
|||||||
+2
-2
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.context.ContextPackage;
|
|||||||
import org.jetbrains.kotlin.context.MutableModuleContext;
|
import org.jetbrains.kotlin.context.MutableModuleContext;
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.NoResolveFileClassesProvider;
|
||||||
import org.jetbrains.kotlin.frontend.di.DiPackage;
|
import org.jetbrains.kotlin.frontend.di.DiPackage;
|
||||||
import org.jetbrains.kotlin.idea.stubindex.JetFullClassNameIndex;
|
import org.jetbrains.kotlin.idea.stubindex.JetFullClassNameIndex;
|
||||||
import org.jetbrains.kotlin.idea.stubindex.JetSourceFilterScope;
|
import org.jetbrains.kotlin.idea.stubindex.JetSourceFilterScope;
|
||||||
@@ -65,7 +66,6 @@ import org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM;
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer;
|
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
||||||
import org.jetbrains.kotlin.types.DynamicTypesSettings;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -378,7 +378,7 @@ public class JetSourceNavigationHelper {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static PsiClass getOriginalClass(@NotNull JetClassOrObject classOrObject) {
|
public static PsiClass getOriginalClass(@NotNull JetClassOrObject classOrObject) {
|
||||||
// Copied from JavaPsiImplementationHelperImpl:getOriginalClass()
|
// Copied from JavaPsiImplementationHelperImpl:getOriginalClass()
|
||||||
String internalName = PsiCodegenPredictor.getPredefinedJvmInternalName(classOrObject);
|
String internalName = PsiCodegenPredictor.getPredefinedJvmInternalName(classOrObject, NoResolveFileClassesProvider.INSTANCE$);
|
||||||
if (internalName == null) {
|
if (internalName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.stubindex
|
||||||
|
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import com.intellij.psi.stubs.StringStubIndexExtension
|
||||||
|
import com.intellij.psi.stubs.StubIndexKey
|
||||||
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
|
|
||||||
|
public class JetFileFacadeClassIndex private constructor() : StringStubIndexExtension<JetFile>() {
|
||||||
|
override fun getKey(): StubIndexKey<String, JetFile> = KEY
|
||||||
|
|
||||||
|
override fun get(key: String, project: Project, scope: GlobalSearchScope) =
|
||||||
|
super.get(key, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project))
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val KEY = KotlinIndexUtil.createIndexKey(JetFileFacadeClassIndex::class.java)
|
||||||
|
public val INSTANCE: JetFileFacadeClassIndex = JetFileFacadeClassIndex()
|
||||||
|
public @jvmStatic fun getInstance(): JetFileFacadeClassIndex = INSTANCE
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-6
@@ -22,17 +22,16 @@ import com.intellij.psi.stubs.StringStubIndexExtension
|
|||||||
import com.intellij.psi.stubs.StubIndexKey
|
import com.intellij.psi.stubs.StubIndexKey
|
||||||
import org.jetbrains.kotlin.psi.JetFile
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
|
|
||||||
public class JetStaticFacadeClassIndex private constructor() : StringStubIndexExtension<JetFile>() {
|
|
||||||
|
public class JetFilePartClassIndex private constructor() : StringStubIndexExtension<JetFile>() {
|
||||||
override fun getKey(): StubIndexKey<String, JetFile> = KEY
|
override fun getKey(): StubIndexKey<String, JetFile> = KEY
|
||||||
|
|
||||||
override fun get(key: String, project: Project, scope: GlobalSearchScope) =
|
override fun get(key: String, project: Project, scope: GlobalSearchScope) =
|
||||||
super.get(key, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project))
|
super.get(key, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project))
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val KEY = KotlinIndexUtil.createIndexKey(JetStaticFacadeClassIndex::class.java)
|
private val KEY = KotlinIndexUtil.createIndexKey(JetFilePartClassIndex::class.java)
|
||||||
|
public val INSTANCE: JetFilePartClassIndex = JetFilePartClassIndex()
|
||||||
public val INSTANCE: JetStaticFacadeClassIndex = JetStaticFacadeClassIndex()
|
public @jvmStatic fun getInstance(): JetFilePartClassIndex = INSTANCE
|
||||||
|
|
||||||
public @jvmStatic fun getInstance(): JetStaticFacadeClassIndex = INSTANCE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ public object StaticFacadeIndexUtil {
|
|||||||
searchScope: GlobalSearchScope,
|
searchScope: GlobalSearchScope,
|
||||||
project: Project
|
project: Project
|
||||||
) : Collection<JetFile> =
|
) : Collection<JetFile> =
|
||||||
JetStaticFacadeClassIndex.INSTANCE.get(facadeFqName.asString(), project, searchScope)
|
JetFileFacadeClassIndex.INSTANCE.get(facadeFqName.asString(), project, searchScope)
|
||||||
|
|
||||||
// TODO change as we introduce multi-file facades (this will require a separate index)
|
// TODO change as we introduce multi-file facades (this will require a separate index)
|
||||||
@jvmStatic public fun findFilesForFilePart(
|
@jvmStatic public fun findFilesForFilePart(
|
||||||
@@ -39,5 +39,5 @@ public object StaticFacadeIndexUtil {
|
|||||||
project: Project
|
project: Project
|
||||||
) : Collection<JetFile> =
|
) : Collection<JetFile> =
|
||||||
PackagePartClassUtils.getFilesWithCallables(
|
PackagePartClassUtils.getFilesWithCallables(
|
||||||
JetStaticFacadeClassIndex.INSTANCE.get(partFqName.asString(), project, searchScope))
|
JetFileFacadeClassIndex.INSTANCE.get(partFqName.asString(), project, searchScope))
|
||||||
}
|
}
|
||||||
+16
-9
@@ -17,7 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.idea.stubindex;
|
package org.jetbrains.kotlin.idea.stubindex;
|
||||||
|
|
||||||
import com.intellij.psi.stubs.IndexSink;
|
import com.intellij.psi.stubs.IndexSink;
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
|
||||||
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
|
||||||
import com.intellij.psi.stubs.StubElement;
|
import com.intellij.psi.stubs.StubElement;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
@@ -39,15 +40,21 @@ public class StubIndexServiceImpl implements StubIndexService {
|
|||||||
|
|
||||||
String facadeSimpleName = stub.getFacadeSimpleName();
|
String facadeSimpleName = stub.getFacadeSimpleName();
|
||||||
if (facadeSimpleName != null) {
|
if (facadeSimpleName != null) {
|
||||||
FqName staticFacadeFqName = packageFqName.child(Name.identifier(facadeSimpleName));
|
FqName fileFacadeFqName = packageFqName.child(Name.identifier(facadeSimpleName));
|
||||||
sink.occurrence(JetStaticFacadeClassIndex.INSTANCE.getKey(), staticFacadeFqName.asString());
|
sink.occurrence(JetFileFacadeClassIndex.INSTANCE.getKey(), fileFacadeFqName.asString());
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
JetFile psi = stub.getPsi();
|
String partSimpleName = stub.getPartSimpleName();
|
||||||
if (psi != null) {
|
if (partSimpleName != null) {
|
||||||
FqName staticFacadeFqName = PackagePartClassUtils.getPackagePartFqName(psi);
|
FqName filePartFqName = packageFqName.child(Name.identifier(partSimpleName));
|
||||||
sink.occurrence(JetStaticFacadeClassIndex.INSTANCE.getKey(), staticFacadeFqName.asString());
|
sink.occurrence(JetFilePartClassIndex.INSTANCE.getKey(), filePartFqName.asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JetFile jetFile = stub.getPsi();
|
||||||
|
if (jetFile != null) {
|
||||||
|
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(jetFile);
|
||||||
|
sink.occurrence(JetFileFacadeClassIndex.INSTANCE.getKey(), fileClassInfo.getFacadeClassFqName().asString());
|
||||||
|
sink.occurrence(JetFilePartClassIndex.INSTANCE.getKey(), fileClassInfo.getFileClassFqName().asString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -498,7 +498,8 @@
|
|||||||
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetAnnotationsIndex"/>
|
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetAnnotationsIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex"/>
|
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex"/>
|
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex"/>
|
||||||
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetStaticFacadeClassIndex"/>
|
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetFileFacadeClassIndex"/>
|
||||||
|
<stubIndex implementation="org.jetbrains.kotlin.idea.stubindex.JetFilePartClassIndex"/>
|
||||||
|
|
||||||
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.idea.decompiler.JetClassFileDecompiler"/>
|
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.idea.decompiler.JetClassFileDecompiler"/>
|
||||||
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.idea.decompiler.KotlinJavaScriptMetaFileDecompiler"/>
|
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.idea.decompiler.KotlinJavaScriptMetaFileDecompiler"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user