Associate synthetic component function descriptors with corresponding
constructor parameters
This commit is contained in:
@@ -29,6 +29,8 @@ import java.util.*
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumEntry
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils.isSyntheticClassObject
|
||||
import org.jetbrains.jet.lang.types.error.MissingDependencyErrorClass
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver
|
||||
import org.jetbrains.jet.lang.resolve.name.isComponentFunctionName
|
||||
|
||||
public fun buildDecompiledText(
|
||||
classFile: VirtualFile,
|
||||
@@ -125,7 +127,9 @@ private fun buildDecompiledText(packageFqName: FqName, descriptors: List<Declara
|
||||
if (member.getContainingDeclaration() != descriptor) {
|
||||
continue
|
||||
}
|
||||
if (member is CallableMemberDescriptor && member.getKind() != CallableMemberDescriptor.Kind.DECLARATION) {
|
||||
if (member is CallableMemberDescriptor
|
||||
&& member.getKind() != CallableMemberDescriptor.Kind.DECLARATION
|
||||
&& !member.getName().isComponentFunctionName()) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -70,12 +70,11 @@ import org.jetbrains.jet.plugin.caches.resolve.getAnalysisResults
|
||||
import org.jetbrains.jet.plugin.caches.resolve.getBindingContext
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.jet.lang.resolve.name.COMPONENT_FUNCTION_PATTERN
|
||||
|
||||
private val TYPE_PARAMETER_LIST_VARIABLE_NAME = "typeParameterList"
|
||||
private val TEMPLATE_FROM_USAGE_FUNCTION_BODY = "New Kotlin Function Body.kt"
|
||||
private val ATTRIBUTE_FUNCTION_NAME = "FUNCTION_NAME"
|
||||
private val COMPONENT_FUNCTION_PATTERN = Pattern.compile("^component(\\d+)$")
|
||||
|
||||
|
||||
/**
|
||||
* Represents a single choice for a type (e.g. parameter type or return type).
|
||||
|
||||
@@ -24,8 +24,7 @@ import com.intellij.openapi.util.TextRange
|
||||
class JetMultiDeclarationReference(element: JetMultiDeclaration) : JetMultiReference<JetMultiDeclaration>(element) {
|
||||
override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {
|
||||
return expression.getEntries().map { entry ->
|
||||
//TODO: remove getOriginal
|
||||
context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry)?.getCandidateDescriptor()?.getOriginal()
|
||||
context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry)?.getCandidateDescriptor()
|
||||
}.filterNotNull()
|
||||
}
|
||||
|
||||
|
||||
@@ -115,12 +115,14 @@ abstract class AbstractJetReference<T : JetElement>(element: T)
|
||||
private fun resolveToPsiElements(targetDescriptor: DeclarationDescriptor): Collection<PsiElement> {
|
||||
val result = HashSet<PsiElement>()
|
||||
val project = expression.getProject()
|
||||
result.addAll(DescriptorToSourceUtils.descriptorToDeclarations(targetDescriptor))
|
||||
result.addAll(DescriptorToDeclarationUtil.findDecompiledAndBuiltInDeclarations(project, targetDescriptor))
|
||||
// todo: remove getOriginal()
|
||||
val originalDescriptor = targetDescriptor.getOriginal()
|
||||
result.addAll(DescriptorToSourceUtils.descriptorToDeclarations(originalDescriptor))
|
||||
result.addAll(DescriptorToDeclarationUtil.findDecompiledAndBuiltInDeclarations(project, originalDescriptor))
|
||||
|
||||
if (targetDescriptor is PackageViewDescriptor) {
|
||||
if (originalDescriptor is PackageViewDescriptor) {
|
||||
val psiFacade = JavaPsiFacade.getInstance(project)
|
||||
val fqName = (targetDescriptor as PackageViewDescriptor).getFqName().asString()
|
||||
val fqName = (originalDescriptor as PackageViewDescriptor).getFqName().asString()
|
||||
ContainerUtil.addIfNotNull(result, psiFacade.findPackage(fqName))
|
||||
ContainerUtil.addIfNotNull(result, psiFacade.findClass(fqName, project.allScope()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user