[FIR] Change scheme of generating declarations by plugins
Methods `needToGenerateAdditionalMembersInClass` and `needToGenerateNestedClassifiersInClass` are removed, now compiler uses `get...Names` and `getTopLevel...` methods to determine which extension may generate declaration with specific classId/callableId This is needed to simplify API of FirDeclarationGenerationExtension and provide guarantee that `generate...` method will be called with specific classId/callableId only if specific extensions returned name for this id from `getName...` functions
This commit is contained in:
committed by
teamcityserver
parent
40d8451698
commit
cb0705ec03
@@ -208,3 +208,30 @@ inline fun <T> Boolean.ifTrue(body: () -> T?): T? =
|
||||
|
||||
inline fun <T> Boolean.ifFalse(body: () -> T?): T? =
|
||||
if (!this) body() else null
|
||||
|
||||
inline fun <T, K> List<T>.flatGroupBy(keySelector: (T) -> Collection<K>): Map<K, List<T>> {
|
||||
return flatGroupBy(keySelector, keyTransformer = { it }, valueTransformer = { it })
|
||||
}
|
||||
|
||||
inline fun <T, U, K, V> List<T>.flatGroupBy(
|
||||
keySelector: (T) -> Collection<U>,
|
||||
keyTransformer: (U) -> K,
|
||||
valueTransformer: (T) -> V
|
||||
): Map<K, List<V>> {
|
||||
val result = mutableMapOf<K, MutableList<V>>()
|
||||
for (element in this) {
|
||||
val keys = keySelector(element)
|
||||
val value = valueTransformer(element)
|
||||
for (key in keys) {
|
||||
val transformedKey = keyTransformer(key)
|
||||
// Map.computeIfAbsent is missing in JDK 1.6
|
||||
var list = result[transformedKey]
|
||||
if (list == null) {
|
||||
list = mutableListOf()
|
||||
result[transformedKey] = list
|
||||
}
|
||||
list += value
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user