UastKotlinPsiVariable: factory methods reformatting
This commit is contained in:
committed by
xiexed
parent
81615fa551
commit
8e17bab56f
@@ -71,8 +71,8 @@ class UastKotlinPsiVariable private constructor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(
|
fun create(
|
||||||
declaration: KtVariableDeclaration,
|
declaration: KtVariableDeclaration,
|
||||||
parent: PsiElement?,
|
parent: PsiElement?,
|
||||||
containingElement: KotlinUDeclarationsExpression,
|
containingElement: KotlinUDeclarationsExpression,
|
||||||
initializer: KtExpression? = null
|
initializer: KtExpression? = null
|
||||||
): PsiLocalVariable {
|
): PsiLocalVariable {
|
||||||
@@ -89,32 +89,38 @@ class UastKotlinPsiVariable private constructor(
|
|||||||
ktElement = declaration)
|
ktElement = declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun create(declaration: KtDestructuringDeclaration, containingElement: UElement): PsiLocalVariable = UastKotlinPsiVariable(
|
fun create(declaration: KtDestructuringDeclaration, containingElement: UElement): PsiLocalVariable =
|
||||||
manager = declaration.manager,
|
UastKotlinPsiVariable(
|
||||||
name = "var" + Integer.toHexString(declaration.getHashCode()),
|
manager = declaration.manager,
|
||||||
typeProducer = { declaration.getType(containingElement) ?: UastErrorType },
|
name = "var" + Integer.toHexString(declaration.getHashCode()),
|
||||||
ktInitializer = declaration.initializer,
|
typeProducer = { declaration.getType(containingElement) ?: UastErrorType },
|
||||||
psiParentProducer = { containingElement.getParentOfType<UDeclaration>()?.psi ?: declaration.parent },
|
ktInitializer = declaration.initializer,
|
||||||
containingElement = containingElement,
|
psiParentProducer = { containingElement.getParentOfType<UDeclaration>()?.psi ?: declaration.parent },
|
||||||
ktElement = declaration)
|
containingElement = containingElement,
|
||||||
|
ktElement = declaration
|
||||||
|
)
|
||||||
|
|
||||||
fun create(initializer: KtExpression, containingElement: UElement, parent: PsiElement): PsiLocalVariable = UastKotlinPsiVariable(
|
fun create(initializer: KtExpression, containingElement: UElement, parent: PsiElement): PsiLocalVariable =
|
||||||
manager = initializer.manager,
|
UastKotlinPsiVariable(
|
||||||
name = "var" + Integer.toHexString(initializer.getHashCode()),
|
manager = initializer.manager,
|
||||||
typeProducer = { initializer.getType(containingElement) ?: UastErrorType },
|
name = "var" + Integer.toHexString(initializer.getHashCode()),
|
||||||
ktInitializer = initializer,
|
typeProducer = { initializer.getType(containingElement) ?: UastErrorType },
|
||||||
psiParentProducer = { containingElement.getParentOfType<UDeclaration>()?.psi ?: parent },
|
ktInitializer = initializer,
|
||||||
containingElement = containingElement,
|
psiParentProducer = { containingElement.getParentOfType<UDeclaration>()?.psi ?: parent },
|
||||||
ktElement = initializer)
|
containingElement = containingElement,
|
||||||
|
ktElement = initializer
|
||||||
|
)
|
||||||
|
|
||||||
fun create(name: String, localFunction: KtFunction, containingElement: UElement): PsiLocalVariable = UastKotlinPsiVariable(
|
fun create(name: String, localFunction: KtFunction, containingElement: UElement): PsiLocalVariable =
|
||||||
manager = localFunction.manager,
|
UastKotlinPsiVariable(
|
||||||
name = name,
|
manager = localFunction.manager,
|
||||||
typeProducer = { localFunction.getFunctionType(containingElement) ?: UastErrorType },
|
name = name,
|
||||||
ktInitializer = localFunction,
|
typeProducer = { localFunction.getFunctionType(containingElement) ?: UastErrorType },
|
||||||
psiParentProducer = { containingElement.getParentOfType<UDeclaration>()?.psi ?: localFunction.parent },
|
ktInitializer = localFunction,
|
||||||
containingElement = containingElement,
|
psiParentProducer = { containingElement.getParentOfType<UDeclaration>()?.psi ?: localFunction.parent },
|
||||||
ktElement = localFunction)
|
containingElement = containingElement,
|
||||||
|
ktElement = localFunction
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,9 +147,9 @@ private fun KtExpression.getType(parent: UElement): PsiType? =
|
|||||||
|
|
||||||
private fun KtDeclaration.getType(parent: UElement): PsiType? {
|
private fun KtDeclaration.getType(parent: UElement): PsiType? {
|
||||||
return (analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? CallableDescriptor)
|
return (analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? CallableDescriptor)
|
||||||
?.returnType
|
?.returnType
|
||||||
?.takeIf { !it.isError }
|
?.takeIf { !it.isError }
|
||||||
?.toPsiType(parent, this, false)
|
?.toPsiType(parent, this, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PsiElement.getHashCode(): Int {
|
private fun PsiElement.getHashCode(): Int {
|
||||||
|
|||||||
Reference in New Issue
Block a user