From e61cfd625f88c5ce4a44cb5a7dc3051b7e67de93 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Thu, 18 Sep 2025 12:39:58 +0200 Subject: [PATCH] Java: minor UAST optimization (IDEA-375485) GitOrigin-RevId: 3551a8a0af9f2eb7428da63a1e5f83aa7bc81778 --- .../uast/kotlin/declarations/KotlinUEnumConstant.kt | 4 ++-- .../org/jetbrains/uast/java/declarations/JavaUVariable.kt | 5 ++--- .../uast/java/expressions/JavaUObjectLiteralExpression.kt | 6 +++--- .../jetbrains/uast/java/expressions/javaUCallExpressions.kt | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/plugins/kotlin/uast/uast-kotlin-base/src/org/jetbrains/uast/kotlin/declarations/KotlinUEnumConstant.kt b/plugins/kotlin/uast/uast-kotlin-base/src/org/jetbrains/uast/kotlin/declarations/KotlinUEnumConstant.kt index 14737e995193..7d70cb3c444d 100644 --- a/plugins/kotlin/uast/uast-kotlin-base/src/org/jetbrains/uast/kotlin/declarations/KotlinUEnumConstant.kt +++ b/plugins/kotlin/uast/uast-kotlin-base/src/org/jetbrains/uast/kotlin/declarations/KotlinUEnumConstant.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.uast.kotlin import com.intellij.psi.* @@ -66,7 +66,7 @@ class KotlinUEnumConstant( get() = emptyList() override val valueArgumentCount: Int - get() = psi.argumentList?.expressions?.size ?: 0 + get() = psi.argumentList?.expressionCount ?: 0 override val valueArguments: List get() = valueArgumentsPart.getOrBuild { diff --git a/uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt b/uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt index e0c09573dd57..2090943ac7a6 100644 --- a/uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt +++ b/uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt @@ -1,5 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. - +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.uast.java import com.intellij.psi.* @@ -275,7 +274,7 @@ class JavaUEnumConstant( override val typeArguments: List get() = emptyList() override val valueArgumentCount: Int - get() = sourcePsi.argumentList?.expressions?.size ?: 0 + get() = sourcePsi.argumentList?.expressionCount ?: 0 override val valueArguments: List get() = valueArgumentsPart.getOrBuild { diff --git a/uast/uast-java/src/org/jetbrains/uast/java/expressions/JavaUObjectLiteralExpression.kt b/uast/uast-java/src/org/jetbrains/uast/java/expressions/JavaUObjectLiteralExpression.kt index bb2974a58f40..b49f5c28577f 100644 --- a/uast/uast-java/src/org/jetbrains/uast/java/expressions/JavaUObjectLiteralExpression.kt +++ b/uast/uast-java/src/org/jetbrains/uast/java/expressions/JavaUObjectLiteralExpression.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.uast.java import com.intellij.psi.PsiMethod @@ -29,7 +29,7 @@ class JavaUObjectLiteralExpression( } override val valueArgumentCount: Int - get() = sourcePsi.argumentList?.expressions?.size ?: 0 + get() = sourcePsi.argumentList?.expressionCount ?: 0 override val valueArguments: List get() = valueArgumentsPart.getOrBuild { @@ -41,7 +41,7 @@ class JavaUObjectLiteralExpression( override val typeArgumentCount: Int get() { if (typeArgumentCountLazy == Int.MIN_VALUE) { - typeArgumentCountLazy = sourcePsi.classReference?.typeParameters?.size ?: 0 + typeArgumentCountLazy = sourcePsi.classReference?.typeParameterCount ?: 0 } return typeArgumentCountLazy } diff --git a/uast/uast-java/src/org/jetbrains/uast/java/expressions/javaUCallExpressions.kt b/uast/uast-java/src/org/jetbrains/uast/java/expressions/javaUCallExpressions.kt index ef631d7f716d..0c625101ee91 100644 --- a/uast/uast-java/src/org/jetbrains/uast/java/expressions/javaUCallExpressions.kt +++ b/uast/uast-java/src/org/jetbrains/uast/java/expressions/javaUCallExpressions.kt @@ -177,7 +177,7 @@ class JavaConstructorUCallExpression( return when { initializer != null -> initializer.initializers.size sourcePsi.arrayDimensions.isNotEmpty() -> sourcePsi.arrayDimensions.size - else -> sourcePsi.argumentList?.expressions?.size ?: 0 + else -> sourcePsi.argumentList?.expressionCount ?: 0 } } @@ -196,7 +196,7 @@ class JavaConstructorUCallExpression( override val typeArgumentCount: Int get() { if (typeArgumentCountLazy == Int.MIN_VALUE) { - typeArgumentCountLazy = sourcePsi.classReference?.typeParameters?.size ?: 0 + typeArgumentCountLazy = sourcePsi.classReference?.typeParameterCount ?: 0 } return typeArgumentCountLazy