mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
[extract method] infer nullability for simple cases
GitOrigin-RevId: 4ff749ebc59b26de55bfe5bb24787e88352c01ca
This commit is contained in:
committed by
intellij-monorepo-bot
parent
32ae65de50
commit
5ecb68030b
@@ -221,9 +221,12 @@ class CodeFragmentAnalyzer(val elements: List<PsiElement>) {
|
||||
companion object {
|
||||
fun inferNullability(expressionGroup: List<PsiExpression>): Nullability {
|
||||
val expressionSet = expressionGroup.toHashSet()
|
||||
if (expressionSet.any { it.type == PsiTypes.nullType() }) return Nullability.NULLABLE
|
||||
|
||||
if (expressionSet.isEmpty()) return Nullability.UNKNOWN
|
||||
val types = expressionSet.map { expression -> expression.type }
|
||||
if (types.any { type -> type == PsiTypes.nullType() }) return Nullability.NULLABLE
|
||||
if (types.all { type -> type is PsiPrimitiveType }) return Nullability.NOT_NULL
|
||||
if (expressionSet.all { expression -> expression is PsiLiteralExpression }) return Nullability.NOT_NULL
|
||||
|
||||
val fragmentToAnalyze = ControlFlowUtil.findCodeFragment(expressionSet.first())
|
||||
val dfaRunner = StandardDataFlowRunner(fragmentToAnalyze.project)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user