diff --git a/build.gradle.kts b/build.gradle.kts index bd92829fc11..b7ff13f09e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -301,6 +301,7 @@ extra["compilerArtifactsForIde"] = listOf( ":prepare:ide-plugin-dependencies:high-level-api-for-ide", ":prepare:ide-plugin-dependencies:high-level-api-fir-for-ide", ":prepare:ide-plugin-dependencies:high-level-api-fir-tests-for-ide", + ":prepare:ide-plugin-dependencies:kotlin-scripting-ide-common-for-ide", ":kotlin-script-runtime", ":kotlin-script-util", ":kotlin-scripting-common", diff --git a/plugins/scripting/scripting-ide-common/build.gradle.kts b/plugins/scripting/scripting-ide-common/build.gradle.kts new file mode 100644 index 00000000000..1934743be32 --- /dev/null +++ b/plugins/scripting/scripting-ide-common/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +jvmTarget = "1.8" + +dependencies { + compileOnly(project(":compiler:util")) + compileOnly(project(":compiler:frontend")) + compileOnly(project(":compiler:frontend.java")) + compileOnly(project(":js:js.frontend")) + compileOnly(project(":js:js.serializer")) + compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) } + +} + +sourceSets { + "main" { projectDefault() } + "test" { } +} diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt index 6124878609c..10163052a42 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/ResolutionFacade.kt @@ -10,26 +10,17 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.analyzer.ResolverForProject -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.idea.FrontendInternals -import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode interface ResolutionFacade { val project: Project - fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext - fun analyze(elements: Collection, bodyResolveMode: BodyResolveMode): BindingContext - fun analyzeWithAllCompilerChecks(elements: Collection, callback: DiagnosticSink.DiagnosticsCallback? = null): AnalysisResult - fun resolveToDescriptor(declaration: KtDeclaration, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): DeclarationDescriptor - val moduleDescriptor: ModuleDescriptor // get service for the module this resolution was created for @@ -53,5 +44,3 @@ interface ResolutionFacade { @FrontendInternals inline fun ResolutionFacade.frontendService(): T = this.getFrontendService(T::class.java) - -inline fun ResolutionFacade.ideService(): T = this.getIdeService(T::class.java) \ No newline at end of file diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/frontendServiceHelpers.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/frontendServiceHelpers.kt index b356ba2ea91..71f821f6ecf 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/frontendServiceHelpers.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/resolve/frontendServiceHelpers.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt index a3bbaedede7..8b82c750a7d 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt @@ -229,8 +229,10 @@ data class ReceiverType( val receiverIndex: Int, val implicitValue: ReceiverValue? = null ) { + @Suppress("unused") // Used in intellij-community val implicit: Boolean get() = implicitValue != null + @Suppress("unused") // Used in intellij-community fun extractDslMarkers() = implicitValue?.let(DslMarkerUtils::extractDslMarkerFqNames)?.all() ?: DslMarkerUtils.extractDslMarkerFqNames(type) diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index b19ba14be7b..3701709561e 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -18,40 +18,10 @@ import org.jetbrains.kotlin.types.checker.StrictEqualityTypeChecker import org.jetbrains.kotlin.types.typeUtil.* import java.util.* -fun CallableDescriptor.fuzzyReturnType() = returnType?.toFuzzyType(typeParameters) fun CallableDescriptor.fuzzyExtensionReceiverType() = extensionReceiverParameter?.type?.toFuzzyType(typeParameters) -fun FuzzyType.makeNotNullable() = type.makeNotNullable().toFuzzyType(freeParameters) -fun FuzzyType.makeNullable() = type.makeNullable().toFuzzyType(freeParameters) fun FuzzyType.nullability() = type.nullability() -fun FuzzyType.isAlmostEverything(): Boolean { - if (freeParameters.isEmpty()) return false - val typeParameter = type.constructor.declarationDescriptor as? TypeParameterDescriptor ?: return false - if (typeParameter !in freeParameters) return false - return typeParameter.upperBounds.singleOrNull()?.isAnyOrNullableAny() ?: false -} - -/** - * Replaces free parameters inside the type with corresponding type parameters of the class (when possible) - */ -fun FuzzyType.presentationType(): KotlinType { - if (freeParameters.isEmpty()) return type - - val map = HashMap() - for ((argument, typeParameter) in type.arguments.zip(type.constructor.parameters)) { - if (argument.projectionKind == Variance.INVARIANT) { - val equalToFreeParameter = freeParameters.firstOrNull { - StrictEqualityTypeChecker.strictEqualTypes(it.defaultType, argument.type.unwrap()) - } ?: continue - - map[equalToFreeParameter.typeConstructor] = createProjection(typeParameter.defaultType, Variance.INVARIANT, null) - } - } - val substitutor = TypeSubstitutor.create(map) - return substitutor.substitute(type, Variance.INVARIANT)!! -} - fun KotlinType.toFuzzyType(freeParameters: Collection) = FuzzyType(this, freeParameters) class FuzzyType( @@ -101,10 +71,13 @@ class FuzzyType( } } + @Suppress("MemberVisibilityCanBePrivate") // Used in intellij-community fun checkIsSubtypeOf(otherType: FuzzyType): TypeSubstitutor? = matchedSubstitutor(otherType, MatchKind.IS_SUBTYPE) + @Suppress("MemberVisibilityCanBePrivate") // Used in intellij-community fun checkIsSuperTypeOf(otherType: FuzzyType): TypeSubstitutor? = matchedSubstitutor(otherType, MatchKind.IS_SUPERTYPE) + @Suppress("unused") // Used in intellij-community fun checkIsSubtypeOf(otherType: KotlinType): TypeSubstitutor? = checkIsSubtypeOf(otherType.toFuzzyType(emptyList())) fun checkIsSuperTypeOf(otherType: KotlinType): TypeSubstitutor? = checkIsSuperTypeOf(otherType.toFuzzyType(emptyList())) @@ -174,21 +147,3 @@ class FuzzyType( return TypeConstructorSubstitution.createByConstructorsMap(substitutionMap, approximateCapturedTypes = true).buildSubstitutor() } } - - -fun TypeSubstitution.hasConflictWith(other: TypeSubstitution, freeParameters: Collection): Boolean { - return freeParameters.any { parameter -> - val type = parameter.defaultType - val substituted1 = this[type] ?: return@any false - val substituted2 = other[type] ?: return@any false - !StrictEqualityTypeChecker.strictEqualTypes( - substituted1.type.unwrap(), - substituted2.type.unwrap() - ) || substituted1.projectionKind != substituted2.projectionKind - } -} - -fun TypeSubstitutor.combineIfNoConflicts(other: TypeSubstitutor, freeParameters: Collection): TypeSubstitutor? { - if (this.substitution.hasConflictWith(other.substitution, freeParameters)) return null - return TypeSubstitutor.createChainedSubstitutor(this.substitution, other.substitution) -} diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderersScripting.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderersScripting.kt new file mode 100644 index 00000000000..33f690d3198 --- /dev/null +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderersScripting.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.scripting.ide_common.idea.util + +import org.jetbrains.kotlin.renderer.* +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor +import org.jetbrains.kotlin.types.isDynamic +import org.jetbrains.kotlin.types.typeUtil.builtIns + +// Copy-pasted from IdeDescriptorRenderers in intellij-community +object IdeDescriptorRenderersScripting { + @JvmField + val APPROXIMATE_FLEXIBLE_TYPES: (KotlinType) -> KotlinType = { it.approximateFlexibleTypes(preferNotNull = false) } + + private fun unwrapAnonymousType(type: KotlinType): KotlinType { + if (type.isDynamic()) return type + if (type.constructor is NewCapturedTypeConstructor) return type + + val classifier = type.constructor.declarationDescriptor + if (classifier != null && !classifier.name.isSpecial) return type + + type.constructor.supertypes.singleOrNull()?.let { return it } + + val builtIns = type.builtIns + return if (type.isMarkedNullable) + builtIns.nullableAnyType + else + builtIns.anyType + } + + private val BASE: DescriptorRenderer = DescriptorRenderer.withOptions { + normalizedVisibilities = true + withDefinedIn = false + renderDefaultVisibility = false + overrideRenderingPolicy = OverrideRenderingPolicy.RENDER_OVERRIDE + unitReturnType = false + enhancedTypes = true + modifiers = DescriptorRendererModifier.ALL + renderUnabbreviatedType = false + annotationArgumentsRenderingPolicy = AnnotationArgumentsRenderingPolicy.UNLESS_EMPTY + } + + @JvmField + val SOURCE_CODE: DescriptorRenderer = BASE.withOptions { + classifierNamePolicy = ClassifierNamePolicy.SOURCE_CODE_QUALIFIED + typeNormalizer = { APPROXIMATE_FLEXIBLE_TYPES(unwrapAnonymousType(it)) } + } +} diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt index 26aea01d9ed..82117d65807 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @file:JvmName("ImportsUtils") @@ -19,18 +8,13 @@ package org.jetbrains.kotlin.idea.imports import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.psi.KtImportDirective import org.jetbrains.kotlin.psi.KtReferenceExpression -import org.jetbrains.kotlin.psi.KtSimpleNameExpression -import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.KotlinType val DeclarationDescriptor.importableFqName: FqName? @@ -71,9 +55,3 @@ fun KtReferenceExpression.getImportableTargets(bindingContext: BindingContext): ?: getReferenceTargets(bindingContext) return targets.map { it.getImportableDescriptor() }.toSet() } - -fun KtImportDirective.canResolve(facade: ResolutionFacade): Boolean { - return (importedReference?.getQualifiedElementSelector() as? KtSimpleNameExpression)?.let { nameExpression -> - nameExpression.getImportableTargets(facade.analyze(nameExpression, BodyResolveMode.PARTIAL)).isNotEmpty() - } ?: false -} \ No newline at end of file diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/NotPropertyList.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/NotPropertyList.kt index a2db2379782..63370c4ce24 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/NotPropertyList.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/NotPropertyList.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt index 41b3af83645..9b8f2b0083d 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt @@ -66,39 +66,14 @@ class ShadowedDeclarationsFilter( fun filter(declarations: Collection): Collection = declarations.groupBy { signature(it) }.values.flatMap { group -> filterEqualSignatureGroup(group) } - fun createNonImportedDeclarationsFilter( - importedDeclarations: Collection - ): (Collection) -> Collection { - val importedDeclarationsSet = importedDeclarations.toSet() - val importedDeclarationsBySignature = importedDeclarationsSet.groupBy { signature(it) } - - return filter@{ declarations -> - // optimization - if (declarations.size == 1 && importedDeclarationsBySignature[signature(declarations.single())] == null) return@filter declarations - - val nonImportedDeclarations = declarations.filter { it !in importedDeclarationsSet } - - val notShadowed = HashSet() - // same signature non-imported declarations from different packages do not shadow each other - for ((pair, group) in nonImportedDeclarations.groupBy { signature(it) to packageName(it) }) { - val imported = importedDeclarationsBySignature[pair.first] - val all = if (imported != null) group + imported else group - notShadowed.addAll(filterEqualSignatureGroup(all, descriptorsToImport = group)) - } - declarations.filter { it in notShadowed } - } - } - - private fun signature(descriptor: DeclarationDescriptor): Any = when (descriptor) { + fun signature(descriptor: DeclarationDescriptor): Any = when (descriptor) { is SimpleFunctionDescriptor -> FunctionSignature(descriptor) is VariableDescriptor -> descriptor.name is ClassDescriptor -> descriptor.importableFqName ?: descriptor else -> descriptor } - private fun packageName(descriptor: DeclarationDescriptor) = descriptor.importableFqName?.parent() - - private fun filterEqualSignatureGroup( + fun filterEqualSignatureGroup( descriptors: Collection, descriptorsToImport: Collection = emptyList() ): Collection { @@ -253,4 +228,4 @@ class ShadowedDeclarationsFilter( override fun hashCode() = function.name.hashCode() * 17 + function.valueParameters.size } -} \ No newline at end of file +} diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt index ca3cc352c78..7f9ab6c6248 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -7,40 +7,14 @@ package org.jetbrains.kotlin.idea.util -import com.intellij.psi.* -import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType -import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper -import org.jetbrains.kotlin.builtins.replaceReturnType -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl -import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor -import org.jetbrains.kotlin.idea.FrontendInternals -import org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport -import org.jetbrains.kotlin.idea.resolve.ResolutionFacade -import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.load.java.components.TypeUsage -import org.jetbrains.kotlin.load.java.lazy.JavaResolverComponents -import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext -import org.jetbrains.kotlin.load.java.lazy.TypeParameterResolver -import org.jetbrains.kotlin.load.java.lazy.child -import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaTypeParameterDescriptor -import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeAttributes -import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeResolver -import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter -import org.jetbrains.kotlin.load.java.structure.impl.JavaTypeImpl -import org.jetbrains.kotlin.load.java.structure.impl.JavaTypeParameterImpl -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -import org.jetbrains.kotlin.resolve.scopes.LexicalScope -import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier -import org.jetbrains.kotlin.storage.LockBasedStorageManager +import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.types.* -import org.jetbrains.kotlin.types.typeUtil.* -import org.jetbrains.kotlin.utils.SmartSet +import org.jetbrains.kotlin.types.typeUtil.TypeNullability +import org.jetbrains.kotlin.types.typeUtil.nullability +import org.jetbrains.kotlin.types.typeUtil.substitute +// Copy-pasted from Kotlin plugin in intellij-community fun KotlinType.approximateFlexibleTypes( preferNotNull: Boolean = false, preferStarForRaw: Boolean = false @@ -49,6 +23,7 @@ fun KotlinType.approximateFlexibleTypes( return unwrapEnhancement().approximateNonDynamicFlexibleTypes(preferNotNull, preferStarForRaw) } +// Copy-pasted from Kotlin plugin in intellij-community private fun KotlinType.approximateNonDynamicFlexibleTypes( preferNotNull: Boolean = false, preferStarForRaw: Boolean = false @@ -95,167 +70,3 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes( ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true) ) } - -fun KotlinType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolean, allowIntersections: Boolean = false): Boolean { - if (constructor is IntersectionTypeConstructor) { - if (!allowIntersections) return false - return constructor.supertypes.all { it.isResolvableInScope(scope, checkTypeParameters, allowIntersections) } - } - - if (canBeReferencedViaImport()) return true - - val descriptor = constructor.declarationDescriptor - if (descriptor == null || descriptor.name.isSpecial) return false - if (!checkTypeParameters && descriptor is TypeParameterDescriptor) return true - - return scope != null && scope.findClassifier(descriptor.name, NoLookupLocation.FROM_IDE) == descriptor -} - -fun KotlinType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KotlinType { - if (isError || isResolvableInScope(scope, checkTypeParameters)) return this - return supertypes().firstOrNull { it.isResolvableInScope(scope, checkTypeParameters) } - ?: builtIns.anyType -} - -fun KotlinType.anonymousObjectSuperTypeOrNull(): KotlinType? { - val classDescriptor = constructor.declarationDescriptor - if (classDescriptor != null && DescriptorUtils.isAnonymousObject(classDescriptor)) { - return immediateSupertypes().firstOrNull() ?: classDescriptor.builtIns.anyType - } - return null -} - -fun KotlinType.getResolvableApproximations( - scope: LexicalScope?, - checkTypeParameters: Boolean, - allowIntersections: Boolean = false -): Sequence { - return (listOf(this) + TypeUtils.getAllSupertypes(this)) - .asSequence() - .mapNotNull { - it.asTypeProjection() - .fixTypeProjection(scope, checkTypeParameters, allowIntersections, isOutVariance = true) - ?.type - } -} - -private fun TypeProjection.fixTypeProjection( - scope: LexicalScope?, - checkTypeParameters: Boolean, - allowIntersections: Boolean, - isOutVariance: Boolean -): TypeProjection? { - if (!type.isResolvableInScope(scope, checkTypeParameters, allowIntersections)) return null - if (type.arguments.isEmpty()) return this - - val resolvableArgs = type.arguments.filterTo(SmartSet.create()) { typeProjection -> - typeProjection.type.isResolvableInScope(scope, checkTypeParameters, allowIntersections) - } - - if (resolvableArgs.containsAll(type.arguments)) { - fun fixArguments(type: KotlinType): KotlinType? = type.replace( - (type.arguments zip type.constructor.parameters).map { (arg, param) -> - if (arg.isStarProjection) arg - else arg.fixTypeProjection( - scope, - checkTypeParameters, - allowIntersections, - isOutVariance = isOutVariance && param.variance == Variance.OUT_VARIANCE - ) ?: when { - !isOutVariance -> return null - param.variance == Variance.OUT_VARIANCE -> arg.type.approximateWithResolvableType( - scope, - checkTypeParameters - ).asTypeProjection() - else -> type.replaceArgumentsWithStarProjections().arguments.first() - } - }) - - return if (type.isBuiltinFunctionalType) { - val returnType = type.getReturnTypeFromFunctionType() - type.replaceReturnType(fixArguments(returnType) ?: return null).asTypeProjection() - } else fixArguments(type)?.asTypeProjection() - } - - if (!isOutVariance) return null - - val newArguments = (type.arguments zip type.constructor.parameters).map { (arg, param) -> - when { - arg in resolvableArgs -> arg - - arg.projectionKind == Variance.OUT_VARIANCE || - param.variance == Variance.OUT_VARIANCE -> TypeProjectionImpl( - arg.projectionKind, - arg.type.approximateWithResolvableType(scope, checkTypeParameters) - ) - - else -> return if (isOutVariance) type.replaceArgumentsWithStarProjections().asTypeProjection() else null - } - } - - return type.replace(newArguments).asTypeProjection() -} - -fun KotlinType.isAbstract(): Boolean { - val modality = (constructor.declarationDescriptor as? ClassDescriptor)?.modality - return modality == Modality.ABSTRACT || modality == Modality.SEALED -} - -/** - * NOTE: this is a very shaky implementation of [PsiType] to [KotlinType] conversion, - * produced types are fakes and are usable only for code generation. Please be careful using this method. - */ -@OptIn(FrontendInternals::class) -fun PsiType.resolveToKotlinType(resolutionFacade: ResolutionFacade): KotlinType { - if (this == PsiType.NULL) { - return resolutionFacade.moduleDescriptor.builtIns.nullableAnyType - } - - val typeParameters = collectTypeParameters() - val components = resolutionFacade.getFrontendService(JavaResolverComponents::class.java) - val rootContext = LazyJavaResolverContext(components, TypeParameterResolver.EMPTY) { null } - val dummyPackageDescriptor = MutablePackageFragmentDescriptor(resolutionFacade.moduleDescriptor, FqName("dummy")) - val dummyClassDescriptor = ClassDescriptorImpl( - dummyPackageDescriptor, - Name.identifier("Dummy"), - Modality.FINAL, - ClassKind.CLASS, - emptyList(), - SourceElement.NO_SOURCE, - false, - LockBasedStorageManager.NO_LOCKS - ) - val typeParameterResolver = object : TypeParameterResolver { - override fun resolveTypeParameter(javaTypeParameter: JavaTypeParameter): TypeParameterDescriptor? { - val psiTypeParameter = (javaTypeParameter as JavaTypeParameterImpl).psi - val index = typeParameters.indexOf(psiTypeParameter) - if (index < 0) return null - return LazyJavaTypeParameterDescriptor(rootContext.child(this), javaTypeParameter, index, dummyClassDescriptor) - } - } - val typeResolver = JavaTypeResolver(rootContext, typeParameterResolver) - val attributes = JavaTypeAttributes(TypeUsage.COMMON) - return typeResolver.transformJavaType(JavaTypeImpl.create(this), attributes).approximateFlexibleTypes(preferNotNull = true) -} - - -private fun PsiType.collectTypeParameters(): List { - val results = ArrayList() - accept( - object : PsiTypeVisitor() { - override fun visitArrayType(arrayType: PsiArrayType) { - arrayType.componentType.accept(this) - } - - override fun visitClassType(classType: PsiClassType) { - (classType.resolve() as? PsiTypeParameter)?.let { results += it } - classType.parameters.forEach { it.accept(this) } - } - - override fun visitWildcardType(wildcardType: PsiWildcardType) { - wildcardType.bound?.accept(this) - } - } - ) - return results -} diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt index 39210db908a..de04f9acdbd 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/Utils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.types.FlexibleType import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.checker.KotlinTypeChecker - fun SmartCastManager.getSmartCastVariantsWithLessSpecificExcluded( receiverToCast: ReceiverValue, bindingContext: BindingContext, diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt index 39f3bcb2b16..2b1ae250396 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -8,14 +8,6 @@ package org.jetbrains.kotlin.idea.util import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.psi.KtPsiUtil -import org.jetbrains.kotlin.psi.KtReferenceExpression -import org.jetbrains.kotlin.psi.KtThisExpression -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver -import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver -import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.types.typeUtil.makeNotNullable @@ -49,30 +41,3 @@ fun TCallable.substituteExtensionIfCallable( .toList() } } - -fun ReceiverValue?.getThisReceiverOwner(bindingContext: BindingContext): DeclarationDescriptor? { - return when (this) { - is ExpressionReceiver -> { - val thisRef = (KtPsiUtil.deparenthesize(this.expression) as? KtThisExpression)?.instanceReference ?: return null - bindingContext[BindingContext.REFERENCE_TARGET, thisRef] - } - - is ImplicitReceiver -> this.declarationDescriptor - - else -> null - } -} - -fun ReceiverValue?.getReceiverTargetDescriptor(bindingContext: BindingContext): DeclarationDescriptor? = when (this) { - is ExpressionReceiver -> when (val expression = KtPsiUtil.deparenthesize(this.expression)) { - is KtThisExpression -> expression.instanceReference - is KtReferenceExpression -> expression - else -> null - }?.let { referenceExpression -> - bindingContext[BindingContext.REFERENCE_TARGET, referenceExpression] - } - - is ImplicitReceiver -> this.declarationDescriptor - - else -> null -} diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt index 0c2b50031de..9db1ab463f0 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/implicitReceiversUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -78,7 +78,7 @@ fun LexicalScope.getImplicitReceiversWithInstanceToExpression( else thisWithLabel to false } else if (owner is ClassDescriptor && owner.kind.isSingleton) { - IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(owner) to false + IdeDescriptorRenderersScripting.SOURCE_CODE.renderClassifierName(owner) to false } else { continue } diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt index 652b9ebd7e4..e2369291dd7 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/idea/util/scopeUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -9,47 +9,16 @@ package org.jetbrains.kotlin.idea.util import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.ClassDescriptorWithResolutionScopes -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.idea.FrontendInternals -import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.resolve.frontendService -import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtClassBody import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.scopes.LexicalScope -import org.jetbrains.kotlin.resolve.scopes.utils.collectFunctions -import org.jetbrains.kotlin.resolve.scopes.utils.collectVariables - - -fun LexicalScope.getAllAccessibleVariables(name: Name): Collection { - return getVariablesFromImplicitReceivers(name) + collectVariables(name, NoLookupLocation.FROM_IDE) -} - -fun LexicalScope.getAllAccessibleFunctions(name: Name): Collection { - return getImplicitReceiversWithInstance().flatMap { - it.type.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE) - } + collectFunctions(name, NoLookupLocation.FROM_IDE) -} - -fun LexicalScope.getVariablesFromImplicitReceivers(name: Name): Collection = - getImplicitReceiversWithInstance().flatMap { - it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE) - } - -fun LexicalScope.getVariableFromImplicitReceivers(name: Name): VariableDescriptor? { - getImplicitReceiversWithInstance().forEach { - it.type.memberScope.getContributedVariables(name, NoLookupLocation.FROM_IDE).singleOrNull()?.let { return it } - } - return null -} fun PsiElement.getResolutionScope(bindingContext: BindingContext): LexicalScope? { for (parent in parentsWithSelf) { @@ -80,12 +49,6 @@ fun PsiElement.getResolutionScope( else -> error("Not in KtFile") } -fun KtElement.getResolutionScope(): LexicalScope { - val resolutionFacade = getResolutionFacade() - val context = resolutionFacade.analyze(this, BodyResolveMode.FULL) - return getResolutionScope(context, resolutionFacade) -} - @OptIn(FrontendInternals::class) fun ResolutionFacade.getFileResolutionScope(file: KtFile): LexicalScope { return frontendService().getFileResolutionScope(file) diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt index 34347c16210..5ee6fc017dc 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ diff --git a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt index 60ff18cf662..ac9e2bdcae7 100644 --- a/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt +++ b/plugins/scripting/scripting-ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -57,21 +57,6 @@ fun descriptorsEqualWithSubstitution( return true } -fun ClassDescriptor.findCallableMemberBySignature( - signature: CallableMemberDescriptor, - allowOverridabilityConflicts: Boolean = false -): CallableMemberDescriptor? { - val descriptorKind = if (signature is FunctionDescriptor) DescriptorKindFilter.FUNCTIONS else DescriptorKindFilter.VARIABLES - return defaultType.memberScope - .getContributedDescriptors(descriptorKind) - .filterIsInstance() - .firstOrNull { - if (it.containingDeclaration != this) return@firstOrNull false - val overridability = OverridingUtil.DEFAULT.isOverridableBy(it as CallableDescriptor, signature, null).result - overridability == OVERRIDABLE || (allowOverridabilityConflicts && overridability == CONFLICT) - } -} - fun TypeConstructor.supertypesWithAny(): Collection { val supertypes = supertypes val noSuperClass = supertypes.map { it.constructor.declarationDescriptor as? ClassDescriptor }.all { diff --git a/plugins/scripting/scripting-ide-services-embeddable/build.gradle.kts b/plugins/scripting/scripting-ide-services-embeddable/build.gradle.kts index 87ab721485d..ae49a090327 100644 --- a/plugins/scripting/scripting-ide-services-embeddable/build.gradle.kts +++ b/plugins/scripting/scripting-ide-services-embeddable/build.gradle.kts @@ -4,7 +4,7 @@ plugins { java } dependencies { embedded(project(":kotlin-scripting-ide-services-unshaded")) { isTransitive = false } - embedded(project(":idea:ide-common")) { isTransitive = false } + embedded(project(":kotlin-scripting-ide-common")) { isTransitive = false } runtimeOnly(project(":kotlin-script-runtime")) runtimeOnly(kotlinStdlib()) runtimeOnly(project(":kotlin-scripting-common")) diff --git a/plugins/scripting/scripting-ide-services-test/build.gradle.kts b/plugins/scripting/scripting-ide-services-test/build.gradle.kts index 668f39bd7a6..d4d61d127a7 100644 --- a/plugins/scripting/scripting-ide-services-test/build.gradle.kts +++ b/plugins/scripting/scripting-ide-services-test/build.gradle.kts @@ -27,7 +27,7 @@ dependencies { testRuntimeOnly(project(":kotlin-compiler")) testRuntimeOnly(commonDep("org.jetbrains.intellij.deps", "trove4j")) - testRuntimeOnly(project(":idea:ide-common")) { isTransitive = false } + testRuntimeOnly(project(":kotlin-scripting-ide-common")) { isTransitive = false } embeddableTestRuntime(project(":kotlin-scripting-ide-services", configuration="runtimeElements")) embeddableTestRuntime(project(":kotlin-scripting-compiler-impl-embeddable", configuration="runtimeElements")) diff --git a/plugins/scripting/scripting-ide-services/build.gradle.kts b/plugins/scripting/scripting-ide-services/build.gradle.kts index 9e722c59398..ce30f6acaa1 100644 --- a/plugins/scripting/scripting-ide-services/build.gradle.kts +++ b/plugins/scripting/scripting-ide-services/build.gradle.kts @@ -13,7 +13,7 @@ publish() dependencies { compile(project(":kotlin-script-runtime")) compile(kotlinStdlib()) - compileOnly(project(":idea:ide-common")) + compileOnly(project(":kotlin-scripting-ide-common")) compile(project(":kotlin-scripting-common")) compile(project(":kotlin-scripting-jvm")) compileOnly(project(":kotlin-scripting-compiler")) diff --git a/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KJvmReplCompleter.kt b/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KJvmReplCompleter.kt index dc1d5cfb82f..84d897aa0ec 100644 --- a/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KJvmReplCompleter.kt +++ b/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KJvmReplCompleter.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper import org.jetbrains.kotlin.idea.util.CallTypeAndReceiver -import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers +import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderersScripting import org.jetbrains.kotlin.idea.util.getResolutionScope import org.jetbrains.kotlin.lexer.KtKeywordToken import org.jetbrains.kotlin.lexer.KtTokens @@ -414,11 +414,11 @@ private class KJvmReplCompleter( } private val RENDERER = - IdeDescriptorRenderers.SOURCE_CODE.withOptions { + IdeDescriptorRenderersScripting.SOURCE_CODE.withOptions { this.classifierNamePolicy = ClassifierNamePolicy.SHORT this.typeNormalizer = - IdeDescriptorRenderers.APPROXIMATE_FLEXIBLE_TYPES + IdeDescriptorRenderersScripting.APPROXIMATE_FLEXIBLE_TYPES this.parameterNameRenderingPolicy = ParameterNameRenderingPolicy.NONE this.renderDefaultAnnotationArguments = false diff --git a/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KotlinResolutionFacadeForRepl.kt b/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KotlinResolutionFacadeForRepl.kt index a4865652e55..9f23bfe227a 100644 --- a/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KotlinResolutionFacadeForRepl.kt +++ b/plugins/scripting/scripting-ide-services/src/org/jetbrains/kotlin/scripting/ide_services/compiler/impl/KotlinResolutionFacadeForRepl.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode class KotlinResolutionFacadeForRepl( private val environment: KotlinCoreEnvironment, @@ -31,13 +30,6 @@ class KotlinResolutionFacadeForRepl( override val project: Project get() = environment.project - override fun analyze( - element: KtElement, - bodyResolveMode: BodyResolveMode - ): BindingContext { - throw UnsupportedOperationException() - } - override val moduleDescriptor: ModuleDescriptor = provider.getService(ModuleDescriptor::class.java) @FrontendInternals @@ -69,10 +61,6 @@ class KotlinResolutionFacadeForRepl( throw UnsupportedOperationException() } - override fun analyze(elements: Collection, bodyResolveMode: BodyResolveMode): BindingContext { - throw UnsupportedOperationException() - } - override fun analyzeWithAllCompilerChecks( elements: Collection, callback: DiagnosticSink.DiagnosticsCallback? @@ -80,8 +68,4 @@ class KotlinResolutionFacadeForRepl( throw UnsupportedOperationException() } - override fun resolveToDescriptor(declaration: KtDeclaration, bodyResolveMode: BodyResolveMode): DeclarationDescriptor { - throw UnsupportedOperationException() - } - } \ No newline at end of file diff --git a/prepare/ide-plugin-dependencies/kotlin-scripting-ide-common-for-ide/build.gradle.kts b/prepare/ide-plugin-dependencies/kotlin-scripting-ide-common-for-ide/build.gradle.kts new file mode 100644 index 00000000000..07f82e391a1 --- /dev/null +++ b/prepare/ide-plugin-dependencies/kotlin-scripting-ide-common-for-ide/build.gradle.kts @@ -0,0 +1,5 @@ +plugins { + kotlin("jvm") +} + +publishJarsForIde(listOf(":kotlin-scripting-ide-common")) diff --git a/settings.gradle b/settings.gradle index 54295a67cb3..b1dab0a0d71 100644 --- a/settings.gradle +++ b/settings.gradle @@ -284,6 +284,11 @@ include ":compiler:fir:cones", ":compiler:fir:analysis-tests", ":compiler:fir:analysis-tests:legacy-fir-tests" +include ":kotlin-scripting-ide-services-unshaded", + ":kotlin-scripting-ide-services-test", + ":kotlin-scripting-ide-services", + ":kotlin-scripting-ide-common" + include ":compiler:test-infrastructure", ":compiler:test-infrastructure-utils", ":compiler:tests-common-new" @@ -319,7 +324,8 @@ if (!buildProperties.inJpsBuildIdeaSync) { ":prepare:ide-plugin-dependencies:low-level-api-fir-for-ide", ":prepare:ide-plugin-dependencies:high-level-api-for-ide", ":prepare:ide-plugin-dependencies:high-level-api-fir-for-ide", - ":prepare:ide-plugin-dependencies:high-level-api-fir-tests-for-ide" + ":prepare:ide-plugin-dependencies:high-level-api-fir-tests-for-ide", + ":prepare:ide-plugin-dependencies:kotlin-scripting-ide-common-for-ide" } void kotlinIde(String imlPath) { @@ -461,9 +467,6 @@ if (!buildProperties.getBoolean("disableKotlinPluginModules", false) && attached ":noarg-ide-plugin", ":allopen-ide-plugin", ":jps-plugin", - ":kotlin-scripting-ide-services-unshaded", - ":kotlin-scripting-ide-services-test", - ":kotlin-scripting-ide-services", ":kotlinx-serialization-ide-plugin", ":kotlin-jps-plugin", ":generators:idea-generator", @@ -492,9 +495,6 @@ if (!buildProperties.getBoolean("disableKotlinPluginModules", false) && attached project(':plugins:kapt3-idea').projectDir = "$rootDir/plugins/kapt3/kapt3-idea" as File project(':allopen-ide-plugin').projectDir = "$rootDir/plugins/allopen/allopen-ide" as File project(':noarg-ide-plugin').projectDir = "$rootDir/plugins/noarg/noarg-ide" as File - project(':kotlin-scripting-ide-services-unshaded').projectDir = "$rootDir/plugins/scripting/scripting-ide-services" as File - project(':kotlin-scripting-ide-services-test').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-test" as File - project(':kotlin-scripting-ide-services').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-embeddable" as File project(':kotlinx-serialization-ide-plugin').projectDir = file("$rootDir/plugins/kotlin-serialization/kotlin-serialization-ide") project(':kotlin-jps-plugin').projectDir = "$rootDir/prepare/jps-plugin" as File project(':sam-with-receiver-ide-plugin').projectDir = "$rootDir/plugins/sam-with-receiver/sam-with-receiver-ide" as File @@ -690,6 +690,10 @@ project(":idea-frontend-fir:idea-frontend-fir-generator").projectDir = "$rootDir project(":idea-frontend-fir").projectDir = "$rootDir/idea/idea-frontend-fir" as File project(":idea-frontend-api").projectDir = "$rootDir/idea/idea-frontend-api" as File +project(':kotlin-scripting-ide-services-unshaded').projectDir = "$rootDir/plugins/scripting/scripting-ide-services" as File +project(':kotlin-scripting-ide-services-test').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-test" as File +project(':kotlin-scripting-ide-services').projectDir = "$rootDir/plugins/scripting/scripting-ide-services-embeddable" as File +project(':kotlin-scripting-ide-common').projectDir = "$rootDir/plugins/scripting/scripting-ide-common" as File // Uncomment to use locally built protobuf-relocated // includeBuild("dependencies/protobuf")