Replace UastConverter with UastLanguagePlugin, allow additional checkers
This commit is contained in:
@@ -16,15 +16,15 @@
|
||||
package org.jetbrains.uast
|
||||
|
||||
interface UastContext {
|
||||
val converters: List<UastConverter>
|
||||
val languagePlugins: List<UastLanguagePlugin>
|
||||
|
||||
fun convert(element: Any?): UElement? {
|
||||
if (element == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
for (converter in converters) {
|
||||
val uelement = converter.convertWithParent(element)
|
||||
for (plugin in languagePlugins) {
|
||||
val uelement = plugin.converter.convertWithParent(element)
|
||||
if (uelement != null) {
|
||||
return uelement
|
||||
}
|
||||
|
||||
+11
-2
@@ -22,9 +22,18 @@ interface UastConverter {
|
||||
fun isFileSupported(path: String): Boolean
|
||||
}
|
||||
|
||||
interface UastLanguagePlugin {
|
||||
val converter: UastConverter
|
||||
val additionalCheckers: List<UastAdditionalChecker>
|
||||
}
|
||||
|
||||
interface UastAdditionalChecker {
|
||||
operator fun invoke(element: UElement, handler: UastHandler, context: UastContext)
|
||||
}
|
||||
|
||||
object UastConverterUtils {
|
||||
@JvmStatic
|
||||
fun isFileSupported(converters: List<UastConverter>, path: String): Boolean {
|
||||
return converters.any { it.isFileSupported(path) }
|
||||
fun isFileSupported(converters: List<UastLanguagePlugin>, path: String): Boolean {
|
||||
return converters.any { it.converter.isFileSupported(path) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user