Revert "Support decapitilized obsolete annotations in resolve"
This reverts commit 4159c83282.
This commit is contained in:
+3
-7
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.serialization.PackageData
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
@@ -125,12 +124,9 @@ public class IncrementalPackageFragmentProvider(
|
||||
}
|
||||
else {
|
||||
val scopes = dataOfPackageParts.map { IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(it)) }
|
||||
DecapitalizedAnnotationScope.wrapIfNeeded(
|
||||
ChainedScope(this,
|
||||
"Member scope for incremental compilation: union of package parts data",
|
||||
*scopes.toTypedArray<JetScope>()
|
||||
),
|
||||
fqName
|
||||
ChainedScope(this,
|
||||
"Member scope for incremental compilation: union of package parts data",
|
||||
*scopes.toTypedArray<JetScope>()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.PackageMemberDeclarationProvider;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
|
||||
public class LazyPackageDescriptor extends PackageFragmentDescriptorImpl implements LazyEntity {
|
||||
@@ -42,8 +41,7 @@ public class LazyPackageDescriptor extends PackageFragmentDescriptorImpl impleme
|
||||
super(module, fqName);
|
||||
this.declarationProvider = declarationProvider;
|
||||
|
||||
// Wrapping is just a temporary hack to inject deprecated decapitalized annotation
|
||||
this.memberScope = DecapitalizedAnnotationScope.Companion.wrapIfNeeded(new LazyPackageMemberScope(resolveSession, declarationProvider, this), fqName);
|
||||
this.memberScope = new LazyPackageMemberScope(resolveSession, declarationProvider, this);
|
||||
|
||||
for (JetFile file : declarationProvider.getPackageFiles()) {
|
||||
resolveSession.getTrace().record(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file, this);
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class LazyJavaPackageFragmentProvider(
|
||||
override fun getPackageFragments(fqName: FqName) = emptyOrSingletonList(getPackageFragment(fqName))
|
||||
|
||||
override fun getSubPackagesOf(fqName: FqName, nameFilter: (Name) -> Boolean) =
|
||||
getPackageFragment(fqName)?.scope?.getSubPackages().orEmpty()
|
||||
getPackageFragment(fqName)?.getMemberScope()?.getSubPackages().orEmpty()
|
||||
|
||||
fun getClass(javaClass: JavaClass): ClassDescriptor? = c.javaClassResolver.resolveClass(javaClass)
|
||||
|
||||
|
||||
+2
-6
@@ -23,17 +23,13 @@ import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinarySourceElement
|
||||
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.storage.get
|
||||
|
||||
class LazyJavaPackageFragment(
|
||||
private val c: LazyJavaResolverContext,
|
||||
private val jPackage: JavaPackage
|
||||
) : PackageFragmentDescriptorImpl(c.module, jPackage.getFqName()) {
|
||||
val scope: LazyJavaPackageScope by lazy { LazyJavaPackageScope(c, jPackage, this) }
|
||||
// Just a temporary hack to inject deprecated decapitalized annotation
|
||||
private val wrappedScope by lazy { DecapitalizedAnnotationScope.wrapIfNeeded(scope, jPackage.getFqName()) }
|
||||
private val scope by lazy { LazyJavaPackageScope(c, jPackage, this) }
|
||||
|
||||
private val topLevelClasses = c.storageManager.createMemoizedFunctionWithNullableValues {
|
||||
javaClass: JavaClass ->
|
||||
@@ -46,7 +42,7 @@ class LazyJavaPackageFragment(
|
||||
|
||||
internal fun resolveTopLevelClass(javaClass: JavaClass) = topLevelClasses(javaClass)
|
||||
|
||||
override fun getMemberScope(): JetScope = wrappedScope
|
||||
override fun getMemberScope() = scope
|
||||
|
||||
override fun toString() = "lazy java package fragment: $fqName"
|
||||
|
||||
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
|
||||
val DECAPITALIZED_DEPRECATED_ANNOTATIONS = arrayOf(
|
||||
"Deprecated", "Extension", "Suppress",
|
||||
"jvm.Volatile", "jvm.Transient", "jvm.Strictfp", "jvm.Synchronized",
|
||||
"jvm.JvmOverloads", "jvm.JvmName", "jvm.JvmStatic", "annotation.Target"
|
||||
).map { FqName("kotlin.$it") }.toSet()
|
||||
|
||||
val DECAPITALIZED_SHORT_NAMES = DECAPITALIZED_DEPRECATED_ANNOTATIONS.map { it.shortName().asString().decapitalize() }.toSet()
|
||||
|
||||
public class DecapitalizedAnnotationScope(override val workerScope: JetScope) : AbstractScopeAdapter() {
|
||||
override fun getClassifier(name: Name, location: LookupLocation)
|
||||
= super.getClassifier(name, location)
|
||||
?: findDecapitalizedAnnotation(name, location)
|
||||
|
||||
private fun findDecapitalizedAnnotation(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
val nameAsString = name.asString()
|
||||
|
||||
if (nameAsString.length() == 0 || nameAsString[0].isUpperCase() || nameAsString !in DECAPITALIZED_SHORT_NAMES) return null
|
||||
val capitalizedIdentifier = Name.identifier(nameAsString.capitalize())
|
||||
|
||||
val capitalizedClassifier = getClassifier(capitalizedIdentifier, location) ?: return null
|
||||
|
||||
return if (capitalizedClassifier.fqNameSafe in DECAPITALIZED_DEPRECATED_ANNOTATIONS)
|
||||
capitalizedClassifier
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
companion object {
|
||||
public fun wrapIfNeeded(scope: JetScope, fqName: FqName): JetScope {
|
||||
if (fqName.firstSegmentIs(KotlinBuiltIns.BUILT_INS_PACKAGE_NAME)) {
|
||||
return DecapitalizedAnnotationScope(scope)
|
||||
}
|
||||
return scope
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-11
@@ -20,8 +20,6 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DecapitalizedAnnotationScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.SerializedResourcePaths
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||
@@ -58,17 +56,10 @@ public abstract class DeserializedPackageFragment(
|
||||
DeserializedPackageMemberScope(this, packageProto, nameResolver, components, classNames = { loadClassNames(packageProto) })
|
||||
}
|
||||
|
||||
// Just a temporary hack to inject deprecated decapitalized annotation
|
||||
internal val deserializedMemberScopeWrapped by storageManager.createLazyValue {
|
||||
DecapitalizedAnnotationScope.wrapIfNeeded(deserializedMemberScope, fqName)
|
||||
}
|
||||
|
||||
override fun getMemberScope(): JetScope {
|
||||
return deserializedMemberScopeWrapped
|
||||
}
|
||||
override fun getMemberScope() = deserializedMemberScope
|
||||
|
||||
internal fun hasTopLevelClass(name: Name): Boolean {
|
||||
return name in deserializedMemberScope.classNames
|
||||
return name in getMemberScope().classNames
|
||||
}
|
||||
|
||||
protected abstract fun loadClassNames(packageProto: ProtoBuf.Package): Collection<Name>
|
||||
|
||||
Reference in New Issue
Block a user