in intellij-plugin-verifier/verifier-cli/src/main/java/com/jetbrains/pluginverifier/tasks/processAllPlugins/CountUsagesOfExtensionPointsTask.kt [24:79]
override fun execute(reportage: PluginVerificationReportage, pluginDetailsCache: PluginDetailsCache): TaskResult {
val ideAndPluginsExtensionPoints = arrayListOf<IdePluginContentDescriptor.ExtensionPoint>()
for (idePlugin in params.ideDescriptor.ide.bundledPlugins) {
ideAndPluginsExtensionPoints += idePlugin.appContainerDescriptor.extensionPoints
ideAndPluginsExtensionPoints += idePlugin.projectContainerDescriptor.extensionPoints
ideAndPluginsExtensionPoints += idePlugin.moduleContainerDescriptor.extensionPoints
}
for (additionalIdePluginInfo in params.additionalIdePlugins) {
pluginDetailsCache.getPluginDetailsCacheEntry(additionalIdePluginInfo).use { cacheResult ->
if (cacheResult is PluginDetailsCache.Result.Provided) {
val idePlugin = cacheResult.pluginDetails.idePlugin
ideAndPluginsExtensionPoints += idePlugin.appContainerDescriptor.extensionPoints
ideAndPluginsExtensionPoints += idePlugin.projectContainerDescriptor.extensionPoints
ideAndPluginsExtensionPoints += idePlugin.moduleContainerDescriptor.extensionPoints
}
}
}
val extensionPointUsages = ConcurrentHashMap(ideAndPluginsExtensionPoints.map { it.extensionPointName }.associateWith { 0 })
val tasks = params.compatiblePluginsList.map { plugin ->
ExecutorWithProgress.Task("$plugin") {
pluginDetailsCache.getPluginDetailsCacheEntry(plugin).use { cacheResult ->
when (cacheResult) {
is PluginDetailsCache.Result.Provided -> {
for ((extensionPointName, elements) in cacheResult.pluginDetails.idePlugin.extensions) {
extensionPointUsages.compute(extensionPointName) { _, count ->
if (count == null) null /* Count only IDE extension points */ else count + elements.size
}
}
ProcessingOutcome.Success
}
is PluginDetailsCache.Result.Failed -> ProcessingOutcome.Failed(cacheResult.reason)
is PluginDetailsCache.Result.FileNotFound -> ProcessingOutcome.Failed(cacheResult.reason)
is PluginDetailsCache.Result.InvalidPlugin -> ProcessingOutcome.Failed("Invalid plugin: " + cacheResult.pluginErrors.filter { it.level == PluginProblem.Level.ERROR }.joinToString { it.message })
}
}
}
}
val executor = ExecutorWithProgress<ProcessingOutcome>("processAllPlugins [countUsagesOfExtensionPoints]", getConcurrencyLevel(), false) { progressData ->
val message = buildString {
append("Finished #${progressData.finishedNumber} of ${progressData.totalNumber}: ")
if (progressData.exception != null) {
append("[error] [ ${progressData.exception!!.message} ]")
} else {
when (val result = progressData.result!!) {
is ProcessingOutcome.Success -> append("[success]")
is ProcessingOutcome.Failed -> append("[bad plugin] [${result.reason}]")
}
}
append(progressData.task.presentableName)
}
reportage.logVerificationStage(message)
}
executor.executeTasks(tasks)
return CountUsagesOfExtensionPointsTaskResult(extensionPointUsages, params.outputJson)
}