Shorten references: Group elements by file before applying transformation
This commit is contained in:
@@ -27,19 +27,17 @@ public object ShortenReferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fun process(elements: Iterable<JetElement>) {
|
public fun process(elements: Iterable<JetElement>) {
|
||||||
val first = elements.firstOrNull()
|
for ((file, fileElements) in elements.groupBy { element -> element.getContainingFile() as JetFile }) {
|
||||||
if (first == null) return
|
// first resolve all qualified references - optimization
|
||||||
val file = first.getContainingFile() as JetFile
|
val resolveAllVisitor = ResolveAllReferencesVisitor(file)
|
||||||
|
processElements(fileElements, resolveAllVisitor)
|
||||||
|
|
||||||
// first resolve all qualified references - optimization
|
val shortenTypesVisitor = ShortenTypesVisitor(file, resolveAllVisitor.result)
|
||||||
val resolveAllVisitor = ResolveAllReferencesVisitor(file)
|
processElements(fileElements, shortenTypesVisitor)
|
||||||
processElements(elements, resolveAllVisitor)
|
shortenTypesVisitor.finish()
|
||||||
|
|
||||||
val shortenTypesVisitor = ShortenTypesVisitor(file, resolveAllVisitor.result)
|
processElements(fileElements, ShortenQualifiedExpressionsVisitor(file, resolveAllVisitor.result))
|
||||||
processElements(elements, shortenTypesVisitor)
|
}
|
||||||
shortenTypesVisitor.finish()
|
|
||||||
|
|
||||||
processElements(elements, ShortenQualifiedExpressionsVisitor(file, resolveAllVisitor.result))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processElements(elements: Iterable<JetElement>, visitor: JetVisitorVoid) {
|
private fun processElements(elements: Iterable<JetElement>, visitor: JetVisitorVoid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user