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 languageVersionSettings = resolutionFacade.getFrontendService(LanguageVersionSettings::class.java)
|
||||||
val scope = getResolutionScope(
|
val scope = getResolutionScope(
|
||||||
symbolDescriptor, symbolDescriptor,
|
symbolDescriptor, symbolDescriptor,
|
||||||
listOf(explicitImportsScope) + defaultImportsScopes, languageVersionSettings
|
listOf(explicitImportsScope), defaultImportsScopes, languageVersionSettings
|
||||||
) ?: return null
|
) ?: return null
|
||||||
|
|
||||||
val expressionTypingServices = resolutionFacade.getFrontendService(module, ExpressionTypingServices::class.java)
|
val expressionTypingServices = resolutionFacade.getFrontendService(module, ExpressionTypingServices::class.java)
|
||||||
@@ -110,7 +110,7 @@ object ReplaceWithAnnotationAnalyzer {
|
|||||||
val scope = getResolutionScope(
|
val scope = getResolutionScope(
|
||||||
symbolDescriptor,
|
symbolDescriptor,
|
||||||
symbolDescriptor,
|
symbolDescriptor,
|
||||||
listOf(explicitImportsScope) + defaultImportScopes,
|
listOf(explicitImportsScope), defaultImportScopes,
|
||||||
resolutionFacade.getFrontendService(LanguageVersionSettings::class.java)
|
resolutionFacade.getFrontendService(LanguageVersionSettings::class.java)
|
||||||
) ?: return null
|
) ?: return null
|
||||||
|
|
||||||
@@ -175,6 +175,7 @@ object ReplaceWithAnnotationAnalyzer {
|
|||||||
private fun getResolutionScope(
|
private fun getResolutionScope(
|
||||||
descriptor: DeclarationDescriptor,
|
descriptor: DeclarationDescriptor,
|
||||||
ownerDescriptor: DeclarationDescriptor,
|
ownerDescriptor: DeclarationDescriptor,
|
||||||
|
explicitScopes: Collection<ExplicitImportsScope>,
|
||||||
additionalScopes: Collection<ImportingScope>,
|
additionalScopes: Collection<ImportingScope>,
|
||||||
languageVersionSettings: LanguageVersionSettings
|
languageVersionSettings: LanguageVersionSettings
|
||||||
): LexicalScope? {
|
): LexicalScope? {
|
||||||
@@ -184,21 +185,23 @@ object ReplaceWithAnnotationAnalyzer {
|
|||||||
getResolutionScope(
|
getResolutionScope(
|
||||||
moduleDescriptor.getPackage(descriptor.fqName),
|
moduleDescriptor.getPackage(descriptor.fqName),
|
||||||
ownerDescriptor,
|
ownerDescriptor,
|
||||||
|
explicitScopes,
|
||||||
additionalScopes,
|
additionalScopes,
|
||||||
languageVersionSettings
|
languageVersionSettings
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is PackageViewDescriptor -> {
|
is PackageViewDescriptor -> {
|
||||||
|
val memberAsImportingScope = descriptor.memberScope.memberScopeAsImportingScope()
|
||||||
LexicalScope.Base(
|
LexicalScope.Base(
|
||||||
chainImportingScopes(listOf(descriptor.memberScope.memberScopeAsImportingScope()) + additionalScopes)!!,
|
chainImportingScopes(explicitScopes + listOf(memberAsImportingScope) + additionalScopes)!!,
|
||||||
ownerDescriptor
|
ownerDescriptor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ClassDescriptor -> {
|
is ClassDescriptor -> {
|
||||||
val outerScope = getResolutionScope(
|
val outerScope = getResolutionScope(
|
||||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||||
) ?: return null
|
) ?: return null
|
||||||
ClassResolutionScopesSupport(
|
ClassResolutionScopesSupport(
|
||||||
descriptor,
|
descriptor,
|
||||||
@@ -209,7 +212,7 @@ object ReplaceWithAnnotationAnalyzer {
|
|||||||
|
|
||||||
is TypeAliasDescriptor -> {
|
is TypeAliasDescriptor -> {
|
||||||
val outerScope = getResolutionScope(
|
val outerScope = getResolutionScope(
|
||||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||||
) ?: return null
|
) ?: return null
|
||||||
LexicalScopeImpl(
|
LexicalScopeImpl(
|
||||||
outerScope,
|
outerScope,
|
||||||
@@ -227,14 +230,14 @@ object ReplaceWithAnnotationAnalyzer {
|
|||||||
|
|
||||||
is FunctionDescriptor -> {
|
is FunctionDescriptor -> {
|
||||||
val outerScope = getResolutionScope(
|
val outerScope = getResolutionScope(
|
||||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||||
) ?: return null
|
) ?: return null
|
||||||
FunctionDescriptorUtil.getFunctionInnerScope(outerScope, descriptor, LocalRedeclarationChecker.DO_NOTHING)
|
FunctionDescriptorUtil.getFunctionInnerScope(outerScope, descriptor, LocalRedeclarationChecker.DO_NOTHING)
|
||||||
}
|
}
|
||||||
|
|
||||||
is PropertyDescriptor -> {
|
is PropertyDescriptor -> {
|
||||||
val outerScope = getResolutionScope(
|
val outerScope = getResolutionScope(
|
||||||
descriptor.containingDeclaration, ownerDescriptor, additionalScopes, languageVersionSettings
|
descriptor.containingDeclaration, ownerDescriptor, explicitScopes, additionalScopes, languageVersionSettings
|
||||||
) ?: return null
|
) ?: return null
|
||||||
val propertyHeader = ScopeUtils.makeScopeForPropertyHeader(outerScope, descriptor)
|
val propertyHeader = ScopeUtils.makeScopeForPropertyHeader(outerScope, descriptor)
|
||||||
LexicalScopeImpl(
|
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");
|
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 {
|
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);
|
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");
|
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 {
|
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);
|
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