From 9e5088b2c54a3bee7ad7f74be1215ef36c7f3651 Mon Sep 17 00:00:00 2001 From: Daniel Alome Date: Sat, 21 Nov 2026 21:32:46 +0100 Subject: [PATCH 1/2] style: spotless reformat, no functional change Drops the orphaned KDoc at the end of IdeTooltipService, which ktlint rejects. --- .../plugins/services/IdeTooltipService.kt | 48 ++++++------- .../plugins/manager/PluginTooltipNaming.kt | 5 +- .../manager/services/IdeTooltipServiceImpl.kt | 70 ++++++++++--------- 3 files changed, 65 insertions(+), 58 deletions(-) diff --git a/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt b/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt index afdca13ee5..1280b88d80 100644 --- a/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt +++ b/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt @@ -6,29 +6,27 @@ import android.view.View * Service that allows plugins to show tooltips using the IDE's tooltip system. */ interface IdeTooltipService { + /** + * Show a tooltip for the given category and tag. + * + * @param anchorView The view to anchor the tooltip to + * @param category The tooltip category + * @param tag The tooltip tag + */ + fun showTooltip( + anchorView: View, + category: String, + tag: String, + ) - /** - * Show a tooltip for the given category and tag. - * - * @param anchorView The view to anchor the tooltip to - * @param category The tooltip category - * @param tag The tooltip tag - */ - fun showTooltip(anchorView: View, category: String, tag: String) - - /** - * Show a tooltip for the default IDE category. - * - * @param anchorView The view to anchor the tooltip to - * @param tag The tooltip tag - */ - fun showTooltip(anchorView: View, tag: String) - - /** - * Check if a tooltip exists for the given category and tag. - * - * @param category The tooltip category - * @param tag The tooltip tag - * @return True if the tooltip exists - */ -} \ No newline at end of file + /** + * Show a tooltip for the default IDE category. + * + * @param anchorView The view to anchor the tooltip to + * @param tag The tooltip tag + */ + fun showTooltip( + anchorView: View, + tag: String, + ) +} diff --git a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt index 44226f8edf..1a83cf4e16 100644 --- a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt +++ b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt @@ -4,4 +4,7 @@ const val PLUGIN_CATEGORY_PREFIX: String = "plugin_" fun pluginCategory(pluginId: String): String = "$PLUGIN_CATEGORY_PREFIX$pluginId" -fun pluginTooltipTag(pluginId: String, itemId: String): String = "$pluginId.$itemId" +fun pluginTooltipTag( + pluginId: String, + itemId: String, +): String = "$pluginId.$itemId" diff --git a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt index 4719f9b615..5c0d2835ec 100644 --- a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt +++ b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt @@ -14,40 +14,46 @@ import com.itsaky.androidide.plugins.services.IdeTooltipService * without conflicting with them. */ class IdeTooltipServiceImpl( - private val context: Context, - private val pluginId: String, - private val activityProvider: PluginManager.ActivityProvider? + private val context: Context, + private val pluginId: String, + private val activityProvider: PluginManager.ActivityProvider?, ) : IdeTooltipService { + private val pluginCategory = pluginCategory(pluginId) - private val pluginCategory = pluginCategory(pluginId) + /** + * Returns a context suitable for inflating the tooltip layout. + * Prefers the live Activity (correct Material3 theme + dark mode configuration). + * Falls back to the app context. + */ + private fun resolvedContext(): Context { + activityProvider?.getCurrentActivity()?.let { activity -> + if (!activity.isFinishing && !activity.isDestroyed) return activity + } + return context + } - /** - * Returns a context suitable for inflating the tooltip layout. - * Prefers the live Activity (correct Material3 theme + dark mode configuration). - * Falls back to the app context. - */ - private fun resolvedContext(): Context { - activityProvider?.getCurrentActivity()?.let { activity -> - if (!activity.isFinishing && !activity.isDestroyed) return activity - } - return context - } + override fun showTooltip( + anchorView: View, + category: String, + tag: String, + ) { + try { + TooltipManager.showTooltip(resolvedContext(), anchorView, pluginCategory, tag) + } catch (e: android.view.InflateException) { + android.util.Log.e("IdeTooltipService", "Failed to inflate tooltip layout: $pluginCategory.$tag", e) + } catch (e: Exception) { + android.util.Log.e("IdeTooltipService", "Failed to show tooltip: $pluginCategory.$tag", e) + } + } - override fun showTooltip(anchorView: View, category: String, tag: String) { - try { - TooltipManager.showTooltip(resolvedContext(), anchorView, pluginCategory, tag) - } catch (e: android.view.InflateException) { - android.util.Log.e("IdeTooltipService", "Failed to inflate tooltip layout: $pluginCategory.$tag", e) - } catch (e: Exception) { - android.util.Log.e("IdeTooltipService", "Failed to show tooltip: $pluginCategory.$tag", e) - } - } - - override fun showTooltip(anchorView: View, tag: String) { - try { - TooltipManager.showTooltip(resolvedContext(), anchorView, pluginCategory, tag) - } catch (e: Exception) { - android.util.Log.e("IdeTooltipService", "Failed to show tooltip: $pluginCategory.$tag", e) - } - } + override fun showTooltip( + anchorView: View, + tag: String, + ) { + try { + TooltipManager.showTooltip(resolvedContext(), anchorView, pluginCategory, tag) + } catch (e: Exception) { + android.util.Log.e("IdeTooltipService", "Failed to show tooltip: $pluginCategory.$tag", e) + } + } } From ffb5637d66ec82ca63f31da56054dac11c99bc98 Mon Sep 17 00:00:00 2001 From: Daniel Alome Date: Sat, 21 Nov 2026 21:57:36 +0100 Subject: [PATCH 2/2] ADFA-7134: Let plugins show the IDE's own documentation IdeTooltipService.showTooltip(anchor, category, tag) ignored the category and always read the plugin's own entries, so the Layout Editor plugin could not show java/android.widget.TextView. It now reads the IDE's ide, java, kotlin and xml categories; any other category still maps to the plugin's own, which keeps plugins that pass their category under another spelling working. --- docs/PLUGIN_API_CHANGELOG.md | 9 ++++++++ .../plugins/services/IdeTooltipService.kt | 8 +++++-- .../plugins/manager/PluginTooltipNaming.kt | 15 ++++++++++++ .../manager/services/IdeTooltipServiceImpl.kt | 11 +++++---- .../manager/PluginReadableCategoryTest.kt | 23 +++++++++++++++++++ 5 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 plugin-manager/src/test/kotlin/com/itsaky/androidide/plugins/manager/PluginReadableCategoryTest.kt diff --git a/docs/PLUGIN_API_CHANGELOG.md b/docs/PLUGIN_API_CHANGELOG.md index 1986000ee7..df064b3f0d 100644 --- a/docs/PLUGIN_API_CHANGELOG.md +++ b/docs/PLUGIN_API_CHANGELOG.md @@ -35,6 +35,15 @@ need a source change, a recompile, or both · `tooling` = API-stability milestone. **[verified]** = read from the checked-in ABI dump. **[reconstructed]** = diffed from `plugin-api/src` history (predates the dump; symbol-accurate). +### 26.48 — unreleased +- **added — Show the IDE's own documentation from a plugin** _(ADFA-7134)_ + `IdeTooltipService.showTooltip(anchorView, category, tag)` now reads the IDE's documentation + when `category` is `ide`, `java`, `kotlin` or `xml`, for example + `showTooltip(view, "java", "android.widget.TextView")`. Before, every category was replaced + with the plugin's own, so those calls found nothing. Any other category still reads the + plugin's own entries, so a plugin that passes its own category under another spelling is + unaffected. Floor `plugin.min_ide_version` at `26.48` to rely on it. + ### 26.43 — unreleased - **breaking — JavaScript highlighting and the IDE's grammar names are the IDE's** _(ADFA-7084)_ The IDE now highlights `js`, `mjs`, `cjs` and `jsx` itself. A `LanguageDefinition` can still diff --git a/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt b/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt index 1280b88d80..229603fb26 100644 --- a/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt +++ b/plugin-api/src/main/kotlin/com/itsaky/androidide/plugins/services/IdeTooltipService.kt @@ -7,7 +7,11 @@ import android.view.View */ interface IdeTooltipService { /** - * Show a tooltip for the given category and tag. + * Show a tooltip from the IDE's own documentation or from this plugin's. + * + * A [category] of `ide`, `java`, `kotlin` or `xml` reads the IDE's documentation, for example + * `showTooltip(view, "java", "android.widget.TextView")`. Any other value reads this plugin's + * entries, as [showTooltip] without a category does. * * @param anchorView The view to anchor the tooltip to * @param category The tooltip category @@ -20,7 +24,7 @@ interface IdeTooltipService { ) /** - * Show a tooltip for the default IDE category. + * Show a tooltip from this plugin's own documentation entries. * * @param anchorView The view to anchor the tooltip to * @param tag The tooltip tag diff --git a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt index 1a83cf4e16..35d334aae4 100644 --- a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt +++ b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/PluginTooltipNaming.kt @@ -1,9 +1,24 @@ package com.itsaky.androidide.plugins.manager +import com.itsaky.androidide.idetooltips.TooltipCategory + const val PLUGIN_CATEGORY_PREFIX: String = "plugin_" +private val IDE_TOOLTIP_CATEGORIES = + setOf( + TooltipCategory.CATEGORY_IDE, + TooltipCategory.CATEGORY_JAVA, + TooltipCategory.CATEGORY_KOTLIN, + TooltipCategory.CATEGORY_XML, + ) + fun pluginCategory(pluginId: String): String = "$PLUGIN_CATEGORY_PREFIX$pluginId" +internal fun pluginReadableCategory( + pluginId: String, + category: String, +): String = if (category in IDE_TOOLTIP_CATEGORIES) category else pluginCategory(pluginId) + fun pluginTooltipTag( pluginId: String, itemId: String, diff --git a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt index 5c0d2835ec..e0993d294e 100644 --- a/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt +++ b/plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeTooltipServiceImpl.kt @@ -5,13 +5,15 @@ import android.view.View import com.itsaky.androidide.idetooltips.TooltipManager import com.itsaky.androidide.plugins.manager.core.PluginManager import com.itsaky.androidide.plugins.manager.pluginCategory +import com.itsaky.androidide.plugins.manager.pluginReadableCategory import com.itsaky.androidide.plugins.services.IdeTooltipService /** * Implementation of the tooltip service for plugins. * Delegates to the main TooltipManager, using "plugin_" as the category * so plugin entries are stored alongside built-in documentation in documentation.db - * without conflicting with them. + * without conflicting with them. A plugin may also read the IDE's own categories + * (ide, java, kotlin, xml), but never another plugin's. */ class IdeTooltipServiceImpl( private val context: Context, @@ -37,12 +39,13 @@ class IdeTooltipServiceImpl( category: String, tag: String, ) { + val readable = pluginReadableCategory(pluginId, category) try { - TooltipManager.showTooltip(resolvedContext(), anchorView, pluginCategory, tag) + TooltipManager.showTooltip(resolvedContext(), anchorView, readable, tag) } catch (e: android.view.InflateException) { - android.util.Log.e("IdeTooltipService", "Failed to inflate tooltip layout: $pluginCategory.$tag", e) + android.util.Log.e("IdeTooltipService", "Failed to inflate tooltip layout: $readable.$tag", e) } catch (e: Exception) { - android.util.Log.e("IdeTooltipService", "Failed to show tooltip: $pluginCategory.$tag", e) + android.util.Log.e("IdeTooltipService", "Failed to show tooltip: $readable.$tag", e) } } diff --git a/plugin-manager/src/test/kotlin/com/itsaky/androidide/plugins/manager/PluginReadableCategoryTest.kt b/plugin-manager/src/test/kotlin/com/itsaky/androidide/plugins/manager/PluginReadableCategoryTest.kt new file mode 100644 index 0000000000..9370b4a37c --- /dev/null +++ b/plugin-manager/src/test/kotlin/com/itsaky/androidide/plugins/manager/PluginReadableCategoryTest.kt @@ -0,0 +1,23 @@ +package com.itsaky.androidide.plugins.manager + +import com.google.common.truth.Truth.assertWithMessage +import org.junit.Test + +class PluginReadableCategoryTest { + private val pluginId = "org.appdevforall.codeonthego.layouteditor" + + @Test + fun aPluginReadsTheIdesOwnDocumentationCategories() { + for (category in listOf("ide", "java", "kotlin", "xml")) { + assertWithMessage(category).that(pluginReadableCategory(pluginId, category)).isEqualTo(category) + } + } + + @Test + fun anyOtherCategoryReadsThePluginsOwnEntries() { + val own = "plugin_$pluginId" + for (category in listOf(own, "plugin_keystore_generator", "plugin_com.example.other", "Java", "", "layouteditor")) { + assertWithMessage(category).that(pluginReadableCategory(pluginId, category)).isEqualTo(own) + } + } +}