Better presentation for non-root packages in completion
This commit is contained in:
+1
-2
@@ -205,14 +205,13 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
|
|||||||
if (isNoQualifierContext() && (completionKind.descriptorKindFilter?.kindMask ?: 0).and(DescriptorKindFilter.PACKAGES_MASK) != 0) {
|
if (isNoQualifierContext() && (completionKind.descriptorKindFilter?.kindMask ?: 0).and(DescriptorKindFilter.PACKAGES_MASK) != 0) {
|
||||||
//TODO: move this code somewhere else
|
//TODO: move this code somewhere else
|
||||||
val packageNames = PackageIndexUtil.getSubPackageFqNames(FqName.ROOT, originalSearchScope, project, prefixMatcher.asNameFilter())
|
val packageNames = PackageIndexUtil.getSubPackageFqNames(FqName.ROOT, originalSearchScope, project, prefixMatcher.asNameFilter())
|
||||||
.map { it.shortName() }
|
|
||||||
.toMutableSet()
|
.toMutableSet()
|
||||||
|
|
||||||
if (!ProjectStructureUtil.isJsKotlinModule(parameters.getOriginalFile() as JetFile)) {
|
if (!ProjectStructureUtil.isJsKotlinModule(parameters.getOriginalFile() as JetFile)) {
|
||||||
JavaPsiFacade.getInstance(project).findPackage("")?.getSubPackages(originalSearchScope)?.forEach { psiPackage ->
|
JavaPsiFacade.getInstance(project).findPackage("")?.getSubPackages(originalSearchScope)?.forEach { psiPackage ->
|
||||||
val name = psiPackage.getName()
|
val name = psiPackage.getName()
|
||||||
if (Name.isValidIdentifier(name!!)) {
|
if (Name.isValidIdentifier(name!!)) {
|
||||||
packageNames.add(Name.identifier(name))
|
packageNames.add(FqName(name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-6
@@ -141,10 +141,17 @@ public class LookupElementFactory(
|
|||||||
return element.withIconFromLookupObject()
|
return element.withIconFromLookupObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun createLookupElementForPackage(shortName: Name): LookupElement {
|
public fun createLookupElementForPackage(name: FqName): LookupElement {
|
||||||
return LookupElementBuilder.create(PackageLookupObject(shortName), shortName.asString())
|
val shortName = name.shortName()
|
||||||
.withInsertHandler(BaseDeclarationInsertHandler())
|
var element = LookupElementBuilder.create(PackageLookupObject(shortName), shortName.asString())
|
||||||
.withIconFromLookupObject()
|
|
||||||
|
element = element.withInsertHandler(BaseDeclarationInsertHandler())
|
||||||
|
|
||||||
|
if (!name.parent().isRoot()) {
|
||||||
|
element = element.appendTailText(" (${name.asString()})", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
return element.withIconFromLookupObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class PackageLookupObject(override val name: Name) : DeclarationLookupObject {
|
private data class PackageLookupObject(override val name: Name) : DeclarationLookupObject {
|
||||||
@@ -174,8 +181,11 @@ public class LookupElementFactory(
|
|||||||
return createLookupElementForJavaClass(declaration, qualifyNestedClasses, includeClassTypeArguments)
|
return createLookupElementForJavaClass(declaration, qualifyNestedClasses, includeClassTypeArguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor is PackageViewDescriptor || descriptor is PackageFragmentDescriptor) {
|
if (descriptor is PackageViewDescriptor) {
|
||||||
return createLookupElementForPackage(descriptor.getName())
|
return createLookupElementForPackage(descriptor.fqName)
|
||||||
|
}
|
||||||
|
if (descriptor is PackageFragmentDescriptor) {
|
||||||
|
return createLookupElementForPackage(descriptor.fqName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// for constructor use name and icon of containing class
|
// for constructor use name and icon of containing class
|
||||||
|
|||||||
Reference in New Issue
Block a user