-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect extracted JSON plugin for Platform 2024.3+ (#1173)
* Extract bytecode manipulation in tests to base class * Test access to unavailable classes * Allow to build core plugins in the 'lib' directory * Support artifact name in mock plugin along with product-info.json and module-descriptors.jar * Add dump of a sample class from `com.intellij` package * Provide at least 1 class in the `com.intellij` package in mock IDEs * Add a new problem for undeclared dependencies * Verify declaration of JSON plugin in the 243+ Platforms * Extract product info-based resolver to a separate class * Introduce named class resolver with a delegate * Introduce class resolver for product-info.json-based IDEs * Create mock IDE version * Support 'depends' in the plugin specification * Provide assertion for no compatibility * Introduce IDE that contains type-safe product-info.json model * Generate type-safe IDE when parsed product info is available * Plugin classpath is built with dependencies overlapping bundled plugins in the IDE * Use classpath resolution logic for nonexistent layout elements * When discovering plugin dependencies, module may expose itself as a plugin * Pickup dependency tree calculation implementation * Support ByteBuddy in structure tests * Support classpath filtering for transitive dependencies
- Loading branch information
Showing
59 changed files
with
3,331 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...sses/src/main/java/com/jetbrains/plugin/structure/classes/resolvers/EmptyNamedResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.jetbrains.plugin.structure.classes.resolvers | ||
|
||
import org.objectweb.asm.tree.ClassNode | ||
import java.util.* | ||
|
||
class EmptyNamedResolver(val name: String) : Resolver() { | ||
override val readMode | ||
get() = ReadMode.FULL | ||
|
||
override fun processAllClasses(processor: (ResolutionResult<ClassNode>) -> Boolean) = true | ||
|
||
override fun resolveClass(className: String) = ResolutionResult.NotFound | ||
|
||
override fun resolveExactPropertyResourceBundle(baseName: String, locale: Locale) = ResolutionResult.NotFound | ||
|
||
override fun containsClass(className: String) = false | ||
|
||
override fun containsPackage(packageName: String) = false | ||
|
||
override val allClasses get() = emptySet<String>() | ||
|
||
override val allPackages get() = emptySet<String>() | ||
|
||
override val allBundleNameSet: ResourceBundleNameSet get() = ResourceBundleNameSet(emptyMap()) | ||
|
||
override fun toString() = "$name (empty resolver)" | ||
|
||
override fun close() = Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...lasses/src/main/java/com/jetbrains/plugin/structure/ide/classes/resolver/NamedResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.jetbrains.plugin.structure.ide.classes.resolver | ||
|
||
import com.jetbrains.plugin.structure.classes.resolvers.ResolutionResult | ||
import com.jetbrains.plugin.structure.classes.resolvers.Resolver | ||
import org.objectweb.asm.tree.ClassNode | ||
import java.util.* | ||
|
||
class NamedResolver(val name: String, val delegateResolver: Resolver) : Resolver() { | ||
|
||
override val readMode get() = delegateResolver.readMode | ||
|
||
override val allClasses get() = delegateResolver.allClasses | ||
|
||
override val allPackages get() = delegateResolver.allPackages | ||
|
||
override val allBundleNameSet get() = delegateResolver.allBundleNameSet | ||
|
||
override fun resolveClass(className: String) = delegateResolver.resolveClass(className) | ||
|
||
override fun resolveExactPropertyResourceBundle(baseName: String, locale: Locale) = | ||
delegateResolver.resolveExactPropertyResourceBundle(baseName, locale) | ||
|
||
override fun containsClass(className: String) = delegateResolver.containsClass(className) | ||
|
||
override fun containsPackage(packageName: String) = delegateResolver.containsPackage(packageName) | ||
|
||
override fun processAllClasses(processor: (ResolutionResult<ClassNode>) -> Boolean) = | ||
delegateResolver.processAllClasses(processor) | ||
|
||
override fun close() = delegateResolver.close() | ||
} |
62 changes: 62 additions & 0 deletions
62
...a/com/jetbrains/plugin/structure/ide/classes/resolver/PluginDependencyFilteredResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.jetbrains.plugin.structure.ide.classes.resolver | ||
|
||
import com.jetbrains.plugin.structure.classes.resolvers.CompositeResolver | ||
import com.jetbrains.plugin.structure.classes.resolvers.ResolutionResult | ||
import com.jetbrains.plugin.structure.classes.resolvers.Resolver | ||
import com.jetbrains.plugin.structure.intellij.plugin.IdePlugin | ||
import com.jetbrains.plugin.structure.intellij.plugin.dependencies.DefaultDependenciesProvider | ||
import com.jetbrains.plugin.structure.intellij.plugin.dependencies.DependenciesProvider | ||
import org.objectweb.asm.tree.ClassNode | ||
import java.util.* | ||
|
||
/** | ||
* A classpath resolver that matches plugin dependencies against bundled plugins of an `product-info.json`-based IDE. | ||
* | ||
* This resolver functions as a classpath filter. | ||
* It takes classes and resource bundles from the IDE | ||
* and includes only those that are declared as dependencies in the plugin. | ||
*/ | ||
class PluginDependencyFilteredResolver( | ||
plugin: IdePlugin, | ||
productInfoClassResolver: ProductInfoClassResolver, | ||
private val dependenciesProvider: DependenciesProvider = DefaultDependenciesProvider(productInfoClassResolver.ide) | ||
) : Resolver() { | ||
val filteredResolvers: List<NamedResolver> = getResolvers(plugin, productInfoClassResolver) | ||
|
||
private fun getResolvers(plugin: IdePlugin, productInfoClassResolver: ProductInfoClassResolver): List<NamedResolver> { | ||
return dependenciesProvider | ||
.getDependencies(plugin) | ||
.map { dependency -> | ||
productInfoClassResolver.layoutComponentResolvers.firstOrNull { component -> dependency.matches(component.name) } | ||
?: productInfoClassResolver.bootClasspathResolver | ||
} | ||
} | ||
|
||
private val delegateResolver = filteredResolvers.asResolver() | ||
|
||
override val readMode get() = delegateResolver.readMode | ||
|
||
override val allClasses get() = delegateResolver.allClasses | ||
|
||
override val allPackages get() = delegateResolver.allPackages | ||
|
||
override val allBundleNameSet get() = delegateResolver.allBundleNameSet | ||
|
||
override fun resolveClass(className: String) = delegateResolver.resolveClass(className) | ||
|
||
override fun resolveExactPropertyResourceBundle(baseName: String, locale: Locale) = | ||
delegateResolver.resolveExactPropertyResourceBundle(baseName, locale) | ||
|
||
override fun containsClass(className: String) = delegateResolver.containsClass(className) | ||
|
||
override fun containsPackage(packageName: String) = delegateResolver.containsPackage(packageName) | ||
|
||
override fun processAllClasses(processor: (ResolutionResult<ClassNode>) -> Boolean) = | ||
delegateResolver.processAllClasses(processor) | ||
|
||
override fun close() = delegateResolver.close() | ||
|
||
private fun List<Resolver>.asResolver(): Resolver { | ||
return CompositeResolver.create(this) | ||
} | ||
} |
Oops, something went wrong.