use of org.jetbrains.kotlin.fileClasses.JvmFileClassInfo in project kotlin by JetBrains.
the class IdeStubIndexService method createFileStub.
@NotNull
@Override
public KotlinFileStub createFileStub(@NotNull KtFile file) {
StringRef packageFqName = StringRef.fromString(file.getPackageFqNameByTree().asString());
boolean isScript = file.isScriptByTree();
if (PackagePartClassUtils.fileHasTopLevelCallables(file)) {
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(file);
StringRef facadeSimpleName = StringRef.fromString(fileClassInfo.getFacadeClassFqName().shortName().asString());
StringRef partSimpleName = StringRef.fromString(fileClassInfo.getFileClassFqName().shortName().asString());
return new KotlinFileStubForIde(file, packageFqName, isScript, facadeSimpleName, partSimpleName, null);
}
return new KotlinFileStubForIde(file, packageFqName, isScript, null, null, null);
}
use of org.jetbrains.kotlin.fileClasses.JvmFileClassInfo in project kotlin by JetBrains.
the class KotlinCodegenFacade method doGenerateFiles.
public static void doGenerateFiles(@NotNull Collection<KtFile> files, @NotNull GenerationState state, @NotNull CompilationErrorHandler errorHandler) {
MultiMap<FqName, KtFile> filesInPackages = new MultiMap<FqName, KtFile>();
MultiMap<FqName, KtFile> filesInMultifileClasses = new MultiMap<FqName, KtFile>();
for (KtFile file : files) {
if (file == null)
throw new IllegalArgumentException("A null file given for compilation");
JvmFileClassInfo fileClassInfo = state.getFileClassesProvider().getFileClassInfo(file);
if (fileClassInfo.getWithJvmMultifileClass()) {
filesInMultifileClasses.putValue(fileClassInfo.getFacadeClassFqName(), file);
} else {
filesInPackages.putValue(file.getPackageFqName(), file);
}
}
Set<FqName> obsoleteMultifileClasses = new HashSet<FqName>(state.getObsoleteMultifileClasses());
for (FqName multifileClassFqName : Sets.union(filesInMultifileClasses.keySet(), obsoleteMultifileClasses)) {
doCheckCancelled(state);
generateMultifileClass(state, multifileClassFqName, filesInMultifileClasses.get(multifileClassFqName), errorHandler);
}
Set<FqName> packagesWithObsoleteParts = new HashSet<FqName>(state.getPackagesWithObsoleteParts());
for (FqName packageFqName : Sets.union(packagesWithObsoleteParts, filesInPackages.keySet())) {
doCheckCancelled(state);
generatePackage(state, packageFqName, filesInPackages.get(packageFqName), errorHandler);
}
doCheckCancelled(state);
state.getFactory().done();
}
use of org.jetbrains.kotlin.fileClasses.JvmFileClassInfo in project kotlin by JetBrains.
the class PackageCodegenImpl method generateFile.
private void generateFile(@NotNull KtFile file) {
JvmFileClassInfo fileClassInfo = state.getFileClassesProvider().getFileClassInfo(file);
if (fileClassInfo.getWithJvmMultifileClass()) {
return;
}
Type fileClassType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(fileClassInfo.getFileClassFqName());
PackageContext packagePartContext = state.getRootContext().intoPackagePart(packageFragment, fileClassType, file);
boolean generatePackagePart = false;
List<KtClassOrObject> classOrObjects = new ArrayList<KtClassOrObject>();
for (KtDeclaration declaration : file.getDeclarations()) {
if (declaration.hasModifier(KtTokens.HEADER_KEYWORD))
continue;
if (declaration instanceof KtProperty || declaration instanceof KtNamedFunction || declaration instanceof KtTypeAlias) {
generatePackagePart = true;
} else if (declaration instanceof KtClassOrObject) {
KtClassOrObject classOrObject = (KtClassOrObject) declaration;
if (state.getGenerateDeclaredClassFilter().shouldGenerateClass(classOrObject)) {
classOrObjects.add(classOrObject);
}
} else if (declaration instanceof KtScript) {
KtScript script = (KtScript) declaration;
if (state.getGenerateDeclaredClassFilter().shouldGenerateScript(script)) {
ScriptCodegen.createScriptCodegen(script, state, packagePartContext).generate();
}
}
}
generateClassesAndObjectsInFile(classOrObjects, packagePartContext);
if (!generatePackagePart || !state.getGenerateDeclaredClassFilter().shouldGeneratePackagePart(file))
return;
String name = fileClassType.getInternalName();
packagePartRegistry.addPart(StringsKt.substringAfterLast(name, '/', name), null);
ClassBuilder builder = state.getFactory().newVisitor(JvmDeclarationOriginKt.PackagePart(file, packageFragment), fileClassType, file);
new PackagePartCodegen(builder, file, fileClassType, packagePartContext, state).generate();
}
use of org.jetbrains.kotlin.fileClasses.JvmFileClassInfo in project kotlin by JetBrains.
the class KotlinTypeMapper method getPartSimpleNameForMangling.
@Nullable
private String getPartSimpleNameForMangling(@NotNull CallableMemberDescriptor descriptor) {
KtFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
if (containingFile != null) {
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(containingFile);
if (fileClassInfo.getWithJvmMultifileClass()) {
return fileClassInfo.getFileClassFqName().shortName().asString();
}
return null;
}
descriptor = DescriptorUtils.getDirectMember(descriptor);
assert descriptor instanceof DeserializedCallableMemberDescriptor : "Descriptor without sources should be instance of DeserializedCallableMemberDescriptor, but: " + descriptor;
ContainingClassesInfo containingClassesInfo = getContainingClassesForDeserializedCallable((DeserializedCallableMemberDescriptor) descriptor);
String facadeShortName = containingClassesInfo.getFacadeClassId().getShortClassName().asString();
String implShortName = containingClassesInfo.getImplClassId().getShortClassName().asString();
return !facadeShortName.equals(implShortName) ? implShortName : null;
}
Aggregations