IDEA-314469: lower JVM target level for *intellij.platform.uast*

GitOrigin-RevId: 9aa9245395c5d5b38b2b20b43ad12d0f7139506f
This commit is contained in:
Nicolay Mitropolsky
2023-03-06 19:04:21 +01:00
committed by intellij-monorepo-bot
parent d13d21509c
commit 1bc9e3ae55
27 changed files with 117 additions and 70 deletions

1
.idea/modules.xml generated
View File

@@ -915,6 +915,7 @@
<module fileurl="file://$PROJECT_DIR$/platform/tracing-ide/intellij.platform.tracing.ide.iml" filepath="$PROJECT_DIR$/platform/tracing-ide/intellij.platform.tracing.ide.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/tracing/intellij.platform.tracing.rt.iml" filepath="$PROJECT_DIR$/platform/tracing/intellij.platform.tracing.rt.iml" />
<module fileurl="file://$PROJECT_DIR$/uast/uast-common/intellij.platform.uast.iml" filepath="$PROJECT_DIR$/uast/uast-common/intellij.platform.uast.iml" />
<module fileurl="file://$PROJECT_DIR$/uast/uast-common-ide/intellij.platform.uast.ide.iml" filepath="$PROJECT_DIR$/uast/uast-common-ide/intellij.platform.uast.ide.iml" />
<module fileurl="file://$PROJECT_DIR$/uast/uast-tests/intellij.platform.uast.tests.iml" filepath="$PROJECT_DIR$/uast/uast-tests/intellij.platform.uast.tests.iml" />
<module fileurl="file://$PROJECT_DIR$/updater/intellij.platform.updater.iml" filepath="$PROJECT_DIR$/updater/intellij.platform.updater.iml" />
<module fileurl="file://$PROJECT_DIR$/platform/usageView/intellij.platform.usageView.iml" filepath="$PROJECT_DIR$/platform/usageView/intellij.platform.usageView.iml" />

View File

@@ -13,5 +13,6 @@
<orderEntry type="module" module-name="intellij.platform.projectModel" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.platform.uast" exported="" />
<orderEntry type="module" module-name="intellij.platform.uast.ide" exported="" />
</component>
</module>

View File

@@ -12,5 +12,6 @@
<orderEntry type="module" module-name="intellij.platform.analysis" exported="" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.java.analysis" />
<orderEntry type="module" module-name="intellij.platform.uast.ide" exported="" />
</component>
</module>

View File

@@ -49,7 +49,8 @@ object JavaPluginLayout {
"intellij.java.psi",
"intellij.java",
"intellij.jsp",
"intellij.platform.uast"
"intellij.platform.uast",
"intellij.platform.uast.ide",
))
spec.withModules(listOf(

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.platform.lang" />
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
<orderEntry type="module" module-name="intellij.platform.uast" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="library" name="StreamEx" level="project" />
</component>
</module>

View File

@@ -1,14 +1,15 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:JvmName("UastPatterns")
package com.intellij.patterns.uast
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.util.Key
import com.intellij.patterns.*
import com.intellij.patterns.ElementPattern
import com.intellij.patterns.ObjectPattern
import com.intellij.patterns.PatternCondition
import com.intellij.patterns.PsiJavaPatterns.psiClass
import com.intellij.patterns.PsiNamePatternCondition
import com.intellij.patterns.StandardPatterns.string
import com.intellij.psi.*
import com.intellij.util.ProcessingContext

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 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-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi
import com.intellij.codeInsight.AnnotationCacheOwnerNormalizer

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi
import com.intellij.util.ProcessingContext

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi
import com.intellij.openapi.diagnostic.logger

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi
import com.intellij.codeInsight.completion.CompletionUtilCoreImpl
@@ -86,7 +86,8 @@ fun getReferencesForDirectUsagesOfVariable(element: PsiElement, targetHint: PsiE
val uParentVariable = getUsageVariableTargetForInitializer(uElement) ?: return PsiReference.EMPTY_ARRAY
val registrar = ReferenceProvidersRegistry.getInstance().getRegistrar(Language.findLanguageByID("UAST")!!)
val providerInfos = (registrar as PsiReferenceRegistrarImpl).getPairsByElement(originalElement, PsiReferenceService.Hints(targetHint, null))
val providerInfos = (registrar as PsiReferenceRegistrarImpl).getPairsByElement(originalElement,
PsiReferenceService.Hints(targetHint, null))
// by-usage providers must implement acceptsTarget correctly, we rely on fact that they accept targetHint
val suitableProviders = providerInfos.asSequence()

View File

@@ -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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:JvmName("UastReferenceByUsageResolver")
package com.intellij.psi

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi
import com.intellij.util.ProcessingContext

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi
import com.intellij.openapi.progress.impl.CancellationCheck

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:JvmName("UastReferenceRegistrar")
package com.intellij.psi

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:JvmName("UastSemRegistrar")
@file:ApiStatus.Experimental

View File

@@ -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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import com.intellij.openapi.diagnostic.Attachment
@@ -613,7 +613,7 @@ private class LocalScopeContext(
fun createChild(isInlined: Boolean = false) = LocalScopeContext(this, inlinedId, isInlined)
fun setLastPotentialUpdate(variable: String, updateElement: UElement) {
lastPotentialUpdatesOf[variable] = CandidatesTree.fromCandidate(
lastPotentialUpdatesOf[variable] = Dependency.PotentialSideEffectDependency.CandidatesTree.fromCandidate(
SideEffectChangeCandidate(
updateElement,
DependencyEvidence(),
@@ -624,13 +624,15 @@ private class LocalScopeContext(
val (evidence, witness) = evidenceAndWitness
val newCandidate = SideEffectChangeCandidate(updateElement, evidence, witness)
val candidatesForReference = lastPotentialUpdatesOf[reference]
lastPotentialUpdatesOf[reference] = candidatesForReference?.addToBegin(newCandidate) ?: CandidatesTree.fromCandidate(newCandidate)
lastPotentialUpdatesOf[reference] = candidatesForReference?.addToBegin(newCandidate)
?: Dependency.PotentialSideEffectDependency.CandidatesTree.fromCandidate(
newCandidate)
}
}
fun setLastPotentialUpdateAsAssignment(variable: String, updateElements: Collection<UElement>) {
if (updateElements.size == 1) {
lastPotentialUpdatesOf[variable] = CandidatesTree.fromCandidate(
lastPotentialUpdatesOf[variable] = Dependency.PotentialSideEffectDependency.CandidatesTree.fromCandidate(
SideEffectChangeCandidate(
updateElements.first(),
DependencyEvidence(),
@@ -638,7 +640,7 @@ private class LocalScopeContext(
)
}
else {
lastPotentialUpdatesOf[variable] = CandidatesTree.fromCandidates(
lastPotentialUpdatesOf[variable] = Dependency.PotentialSideEffectDependency.CandidatesTree.fromCandidates(
updateElements.mapTo(mutableSetOf()) {
SideEffectChangeCandidate(it, DependencyEvidence(), dependencyWitnessValues = referencesModel.getAllTargetsForReference(variable))
}
@@ -685,7 +687,7 @@ private class LocalScopeContext(
}
}
}.takeUnless { it.isEmpty() }?.let { candidates ->
lastPotentialUpdatesOf[variableName] = CandidatesTree.merge(candidates)
lastPotentialUpdatesOf[variableName] = Dependency.PotentialSideEffectDependency.CandidatesTree.merge(candidates)
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import com.intellij.psi.PsiReference

View File

@@ -1,11 +1,14 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import com.intellij.openapi.util.TextRange
import com.intellij.psi.util.PartiallyKnownString
import com.intellij.psi.util.StringEntry
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.uast.*
import org.jetbrains.uast.UElement
import org.jetbrains.uast.ULiteralExpression
import org.jetbrains.uast.UPolyadicExpression
import org.jetbrains.uast.UastBinaryOperator
@Suppress("FunctionName")
@ApiStatus.Experimental

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import com.intellij.openapi.diagnostic.debug
@@ -14,8 +14,6 @@ import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiModificationTracker
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.uast.*
import kotlin.collections.ArrayList
import kotlin.collections.HashSet
/**
* Dependency graph of UElements in some scope.

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import com.intellij.openapi.util.TextRange
@@ -8,7 +8,10 @@ import com.intellij.patterns.uast.callExpression
import com.intellij.psi.PsiMethod
import com.intellij.psi.util.PartiallyKnownString
import com.intellij.psi.util.StringEntry
import org.jetbrains.uast.*
import org.jetbrains.uast.UReferenceExpression
import org.jetbrains.uast.USimpleNameReferenceExpression
import org.jetbrains.uast.UThisExpression
import org.jetbrains.uast.getQualifiedChain
object UStringBuilderEvaluator : BuilderLikeExpressionEvaluator<PartiallyKnownString> {
override val buildMethod: ElementPattern<PsiMethod>

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import com.intellij.openapi.util.UserDataHolderBase
@@ -44,7 +44,7 @@ sealed class Dependency : UserDataHolderBase() {
data class BranchingDependency(
override val elements: Set<UElement>,
override val referenceInfo: DependencyOfReference.ReferenceInfo? = null
) : Dependency(), DependencyOfReference {
) : Dependency(), DependencyOfReference {
fun unwrapIfSingle(): Dependency =
if (elements.size == 1) {
CommonDependency(elements.single(), referenceInfo)

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import org.jetbrains.uast.*
@@ -38,34 +38,3 @@ private val UExpression.lastExpression: UExpression?
if (expression is UYieldExpression) expression.expression else expression
}
@Suppress("MemberVisibilityCanBePrivate")
object KotlinExtensionConstants {
const val STANDARD_CLASS = "kotlin.StandardKt__StandardKt"
const val LET_METHOD = "let"
const val ALSO_METHOD = "also"
const val RUN_METHOD = "run"
const val APPLY_METHOD = "apply"
const val LAMBDA_THIS_PARAMETER_NAME = "<this>"
fun isExtensionWithSideEffect(call: UCallExpression): Boolean =
call.methodName == ALSO_METHOD || call.methodName == APPLY_METHOD
fun isLetOrRunCall(call: UCallExpression): Boolean =
call
.takeIf { it.methodName == LET_METHOD || it.methodName == RUN_METHOD }
?.resolve()
?.containingClass?.qualifiedName == STANDARD_CLASS
fun isAlsoOrApplyCall(call: UCallExpression): Boolean =
call
.takeIf { it.methodName == ALSO_METHOD || it.methodName == APPLY_METHOD }
?.resolve()
?.containingClass?.qualifiedName == STANDARD_CLASS
fun isExtensionFunctionToIgnore(call: UCallExpression): Boolean =
call
.takeIf { it.methodName == LET_METHOD || it.methodName == ALSO_METHOD || it.methodName == RUN_METHOD || it.methodName == APPLY_METHOD }
?.resolve()
?.containingClass?.qualifiedName == STANDARD_CLASS
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 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-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import com.intellij.patterns.ElementPattern

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.expressions
import com.intellij.openapi.util.TextRange

View File

@@ -1,18 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="5" platform="JVM 11" allPlatforms="JVM [11]" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-Xjvm-default=all -opt-in=com.intellij.openapi.util.IntellijInternalApi" />
</compilerSettings>
<compilerArguments>
<stringArguments>
<stringArg name="jvmTarget" arg="11" />
<stringArg name="apiVersion" arg="1.8" />
<stringArg name="languageVersion" arg="1.8" />
</stringArguments>
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.java.psi" exported="" />
<orderEntry type="module" module-name="intellij.java.psi.impl" />
<orderEntry type="module" module-name="intellij.platform.util.ex" />
<orderEntry type="module" module-name="intellij.platform.lang" />
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.platform.util" />
</component>
</module>

View File

@@ -0,0 +1,36 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.uast.analysis
import org.jetbrains.uast.UCallExpression
@Suppress("MemberVisibilityCanBePrivate")
object KotlinExtensionConstants {
const val STANDARD_CLASS = "kotlin.StandardKt__StandardKt"
const val LET_METHOD = "let"
const val ALSO_METHOD = "also"
const val RUN_METHOD = "run"
const val APPLY_METHOD = "apply"
const val LAMBDA_THIS_PARAMETER_NAME = "<this>"
fun isExtensionWithSideEffect(call: UCallExpression): Boolean =
call.methodName == ALSO_METHOD || call.methodName == APPLY_METHOD
fun isLetOrRunCall(call: UCallExpression): Boolean =
call
.takeIf { it.methodName == LET_METHOD || it.methodName == RUN_METHOD }
?.resolve()
?.containingClass?.qualifiedName == STANDARD_CLASS
fun isAlsoOrApplyCall(call: UCallExpression): Boolean =
call
.takeIf { it.methodName == ALSO_METHOD || it.methodName == APPLY_METHOD }
?.resolve()
?.containingClass?.qualifiedName == STANDARD_CLASS
fun isExtensionFunctionToIgnore(call: UCallExpression): Boolean =
call
.takeIf { it.methodName == LET_METHOD || it.methodName == ALSO_METHOD || it.methodName == RUN_METHOD || it.methodName == APPLY_METHOD }
?.resolve()
?.containingClass?.qualifiedName == STANDARD_CLASS
}