Fix importing scope order in ReplaceWithAnnotationAnalyzer
So #KT-22615 Fixed
This commit is contained in:
+10
-7
@@ -79,7 +79,7 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
val languageVersionSettings = resolutionFacade.getFrontendService(LanguageVersionSettings::class.java)
|
||||
val scope = getResolutionScope(
|
||||
symbolDescriptor, symbolDescriptor,
|
||||
listOf(explicitImportsScope) + defaultImportsScopes, languageVersionSettings
|
||||
listOf(explicitImportsScope), defaultImportsScopes, languageVersionSettings
|
||||
) ?: return null
|
||||
|
||||
val expressionTypingServices = resolutionFacade.getFrontendService(module, ExpressionTypingServices::class.java)
|
||||
@@ -110,7 +110,7 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
val scope = getResolutionScope(
|
||||
symbolDescriptor,
|
||||
symbolDescriptor,
|
||||
listOf(explicitImportsScope) + defaultImportScopes,
|
||||
listOf(explicitImportsScope), defaultImportScopes,
|
||||
resolutionFacade.getFrontendService(LanguageVersionSettings::class.java)
|
||||
) ?: return null
|
||||
|
||||
@@ -175,6 +175,7 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
private fun getResolutionScope(
|
||||
descriptor: DeclarationDescriptor,
|
||||
ownerDescriptor: DeclarationDescriptor,
|
||||
explicitScopes: Collection<ExplicitImportsScope>,
|
||||
additionalScopes: Collection<ImportingScope>,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): LexicalScope? {
|
||||
@@ -184,21 +185,23 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
getResolutionScope(
|
||||
moduleDescriptor.getPackage(descriptor.fqName),
|
||||
ownerDescriptor,
|
||||
explicitScopes,
|
||||
additionalScopes,
|
||||
languageVersionSettings
|
||||
)
|
||||
}
|
||||
|
||||
is PackageViewDescriptor -> {
|
||||
val memberAsImportingScope = descriptor.memberScope.memberScopeAsImportingScope()
|
||||
LexicalScope.Base(
|
||||
chainImportingScopes(listOf(descriptor.memberScope.memberScopeAsImportingScope()) + additionalScopes)!!,
|
||||
chainImportingScopes(explicitScopes + listOf(memberAsImportingScope) + additionalScopes)!!,
|
||||
ownerDescriptor
|
||||
)
|
||||
}
|
||||
|
||||
is ClassDescriptor -> {
|
||||
val outerScope = getResolutionScope(
|
||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
||||
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||
) ?: return null
|
||||
ClassResolutionScopesSupport(
|
||||
descriptor,
|
||||
@@ -209,7 +212,7 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
|
||||
is TypeAliasDescriptor -> {
|
||||
val outerScope = getResolutionScope(
|
||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
||||
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||
) ?: return null
|
||||
LexicalScopeImpl(
|
||||
outerScope,
|
||||
@@ -227,14 +230,14 @@ object ReplaceWithAnnotationAnalyzer {
|
||||
|
||||
is FunctionDescriptor -> {
|
||||
val outerScope = getResolutionScope(
|
||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
||||
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||
) ?: return null
|
||||
FunctionDescriptorUtil.getFunctionInnerScope(outerScope, descriptor, LocalRedeclarationChecker.DO_NOTHING)
|
||||
}
|
||||
|
||||
is PropertyDescriptor -> {
|
||||
val outerScope = getResolutionScope(
|
||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
||||
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||
) ?: return null
|
||||
val propertyHeader = ScopeUtils.makeScopeForPropertyHeader(outerScope, descriptor)
|
||||
LexicalScopeImpl(
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with 'gau()'" "true"
|
||||
|
||||
package test
|
||||
|
||||
import test.dependency.gau
|
||||
|
||||
@Deprecated("...", ReplaceWith("gau()", "test.dependency.gau"))
|
||||
fun gav() {
|
||||
test.dependency.gau()
|
||||
}
|
||||
|
||||
fun use() {
|
||||
gau()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package test.dependency
|
||||
|
||||
fun gau() {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with 'gau()'" "true"
|
||||
|
||||
package test
|
||||
|
||||
@Deprecated("...", ReplaceWith("gau()", "test.dependency.gau"))
|
||||
fun gav() {
|
||||
test.dependency.gau()
|
||||
}
|
||||
|
||||
fun use() {
|
||||
<caret>gav()
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with 'gau()'" "true"
|
||||
|
||||
package test
|
||||
|
||||
import test.dependency.gau
|
||||
|
||||
@Deprecated("...", ReplaceWith("gau()", "test.dependency.gau"))
|
||||
fun gau() {
|
||||
test.dependency.gau()
|
||||
}
|
||||
|
||||
fun use() {
|
||||
gau()
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package test.dependency
|
||||
|
||||
fun gau() {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with 'gau()'" "true"
|
||||
|
||||
package test
|
||||
|
||||
@Deprecated("...", ReplaceWith("gau()", "test.dependency.gau"))
|
||||
fun gau() {
|
||||
test.dependency.gau()
|
||||
}
|
||||
|
||||
fun use() {
|
||||
<caret>gau()
|
||||
}
|
||||
+10
@@ -2281,6 +2281,16 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/imports/addImports.before.Main.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addImportsSimple.before.Main.kt")
|
||||
public void testAddImportsSimple() throws Exception {
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/imports/addImportsSimple.before.Main.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addImportsWithSameName.before.Main.kt")
|
||||
public void testAddImportsWithSameName() throws Exception {
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/imports/addImportsWithSameName.before.Main.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInImports() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage/imports"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@@ -1558,6 +1558,16 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/imports/addImports.before.Main.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addImportsSimple.before.Main.kt")
|
||||
public void testAddImportsSimple() throws Exception {
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/imports/addImportsSimple.before.Main.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("addImportsWithSameName.before.Main.kt")
|
||||
public void testAddImportsWithSameName() throws Exception {
|
||||
runTest("idea/testData/quickfix/deprecatedSymbolUsage/imports/addImportsWithSameName.before.Main.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInImports() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage/imports"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user