跳到正文
cccskills
免费在 GitHub 公开中文介绍

poly-symbols

为 JetBrains IDE 的语言或框架集成添加 PolySymbols 支持,将符号连接到补全、引用解析、用法查找、文档和重命名,并协调现有 PSI 处理。

原文查看原文说明

Implement PolySymbols completion, references, and rename.

JetBrains/intellij-community星标 20,685(GitHub 20,685 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 为语言插件添加补全
  • 实现符号引用解析
  • 支持重命名和用法查找
  • 规划与现有 PSI 处理共存

中文介绍

功能

本技能说明如何将 PolySymbols 集成到 JetBrains IDE 的语言或框架支持中,并把符号定义连接到代码补全、引用解析、用法查找、文档、导航和重命名。它会介绍注册作用域、实现引用与声明提供器,以及接通补全功能。处理符号类型和数据时,应通过共享属性访问,避免强制转换为具体实现类。

适用场景

为新的语言或框架插件添加 PolySymbols 支持时,可以参考本技能。若要决定它如何与现有的 PSI 补全和引用处理共存,也可以借助已有集成案例,确定哪些功能交由 PolySymbols 处理,以及如何应对重复行为。

使用示例

  • “请整理为这个语言插件添加 PolySymbols 引用解析和补全的步骤。”
  • “请检查集成方案,避免现有 PSI 引用处理与 PolySymbols 功能重复。”

注意事项

资料将 PolySymbols 标记为实验性功能。未经用户针对具体修改明确授权,不要更改共享的 PolySymbols 平台源码。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
A良好明确要求修改共享平台源码前取得针对该修改的授权。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足默认具备 JetBrains 插件开发环境,但未提供配置步骤。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月28日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(7)

  • SKILL.md16.8 KB
  • references/case-studies.md23.6 KB
  • references/migration.md11.7 KB
  • references/patterns.md8.7 KB
  • references/query-model.md43.7 KB
  • references/testing.md15.3 KB
  • references/web-types.md6.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/poly-symbols/SKILL.md -->

PolySymbols

PolySymbols is a framework built on top of the platform's Symbol API (PolySymbol : Symbol) for sharing symbol definitions and code-insight features (completion, references, documentation, navigation, rename, find-usages, semantic highlighting) across languages and frameworks. It was called "Web Symbols" in 2022.3–2025.1 and is still marked experimental. Core modules: community/platform/polySymbols/ (shared, backend, web).

Do not modify PolySymbols platform source

Never edit anything under community/platform/polySymbols/** without the user's explicit, one-time permission for that specific change — not even a small, purely-additive generalization that looks obviously safe. This is shared framework code consumed by every PolySymbols integration in the repo (Angular, Vue, CSS, JS, GDScript, mermaid, etc.); a "safe-looking" generalization made to fix one integration's test can silently change behavior for all the others. If you hit a real gap or limitation in platform behavior while integrating a language/framework, the default response is to report it and ask, not to patch the platform — the right fix is almost always something owned by your own plugin (a plugin-registered EP implementation, e.g. its own UsageSearcher/ RenameUsageSearcher/CustomUsageSearcher, not a platform-file edit). This was learned the hard way: a session generalized PolySymbolUsageSearcher's PsiLinkedPolySymbol-only raw-PSI-reference bridge to also cover PolySymbolDeclaredInPsi, when the actual, documented platform design is that PolySymbolDeclaredInPsi intentionally does not provide that bridge (see references/query-model.md) — the fix should have stopped at "ask the user," not at "patch the framework."

Implementing a new integration typically means: build declaration/reference/completion providers on the platform side as usual, plus a handful of PolySymbols contributor classes — find-usages, documentation, and rename then work automatically through reference resolution to a PolySymbol.

Consumer code must not cast to a concrete symbol class

Code that consumes PolySymbols (annotators, inspections, completion/line-marker/parameter-info providers — and a language integration's own customizers/scopes, not just downstream callers) should never cast a PolySymbol to a concrete implementation class to detect its kind or read its data. This is explicitly documented in PolySymbol.kt's own "## Properties" doc comment ("when you get results from a PolySymbolQueryExecutor query, you should avoid casting symbols to specialized interfaces... a query may return symbols of unexpected classes contributed by some 3rd party plugins") — it is a platform convention every consumer is expected to follow, not a one-off rule:

  • Kind detection → check the kind property (symbol.kind == SomeKind), which is always available on the plain PolySymbol interface. Never is ConcreteLeafSymbolClass.
  • Any other data (a type, a signature, a navigable element, a boolean flag not expressible via kind) → define a PolySymbolProperty<T> object and annotate the concrete class's real member with @PolySymbol.Property(TheProperty::class), then read it via symbol[TheProperty] (the PolySymbol.get operator) — never (symbol as? ConcreteLeafSymbolClass)?.someMember.
  • Package the property behind a PolySymbol.xxx extension, so consumer call sites read symbol.xxx and never see the property object or a cast at all — mirror plugins/JavaScriptLanguage/web-platform/src/com/intellij/polySymbols/js/JSSymbolUtils.kt's PolySymbol.jsType/jsKind/toPropertySignature, the reference example cited in PolySymbol.kt itself. Note toPropertySignature's fallback branch (when the property is absent) builds its result purely from other plain PolySymbol members (name, modifiers, jsType) — it never casts, not even as a fallback.
  • A shared, uniformly-implemented interface across a framework's own symbol kinds (e.g. GDScript's GdClassSymbol, exposing directMemberScope/resolveSuperClassSymbol() identically from both PSI- and SDK-backed class symbols) is not what this rule targets — that's legitimate polymorphic dispatch within a framework's own resolution machinery, not "cast down to read hidden, kind/backing-specific data" in consumer code. The anti-pattern is casting to a leaf class (GdPsiMethodSymbol, GdSdkClassSymbol) or a backing-specific base (GdPsiPolySymbol vs. GdSdkPolySymbol) from outside the symbol-definition package.
  • Reflection technique worth knowing: a @PolySymbol.Property-annotated member declared once on a shared abstract base class is found by every subclass automatically — PolySymbolPropertyGetter walks superclasses/interfaces when building its per-concrete-class accessor map, and Java/Kotlin generate a bridge method (matching the base class's erased signature) for any subclass override with a covariant return type, which is exactly what Method.invoke() resolves against. So you don't need to repeat the annotation on every leaf subclass when the member is inherited unchanged.

Interface cheat sheet

Interface / classPurpose
PolySymbolCore element — kind (namespace + kindName) + name, plus optional icon/priority/modifiers/apiStatus/pattern
PolySymbolScopeA symbol that contains other symbols (an HTML element containing attributes, a JS class containing members)
PolySymbolQueryExecutor / FactoryRuns nameMatchQuery/listSymbolsQuery/codeCompletionQuery against contributed scopes
PolySymbolQueryScopeContributorRegisters PolySymbolScopes for a PSI location — the main extension point you implement
PolySymbolQueryConfiguratorSupplies PolyContext rules + symbol name-conversion rules
PsiPolySymbolReferenceProviderResolves a host PsiElement to a referenced PolySymbol — registered via EP, produces external references
PolySymbolOwnReferencesAlternative to PsiPolySymbolReferenceProvider: builds references to return from PsiElement.getOwnReferences() directly — a language's own canonical resolve, not EP-registered. Requires the host element to implement the PolySymbolOwnReferenceHost marker interface
PolySymbolDeclarationProviderSupplies PolySymbolDeclarations for a PsiElement (skip if PsiLinkedPolySymbol covers your case)
PolySymbolsCompletionProviderBaseBase class for a CompletionProvider that runs a codeCompletionQuery
PolySymbolWithPatternA symbol expanded via a microsyntax pattern into a PolySymbolMatch
PsiLinkedPolySymbolA symbol backed 1:1 by a real PsiElement — gets declarations/navigation/find-usages "for free"
ReferencingPolySymbolUtility: makes one symbol kind stand in for/alias another kind
PolyContextGates scopes/configurators here, but is a general-purpose, performance-optimized context API usable well beyond PolySymbols — see poly-context
Web TypesStatic JSON symbol definitions — see references/web-types.md

See references/query-model.md for the full query/scope/declaration/ reference/completion wiring, and references/patterns.md for the pattern DSL and microsyntax matching.

The rule: PolySymbols is additive, not automatically authoritative

Every real integration studied in this repo keeps legacy PSI-based reference/completion code running alongside PolySymbols — none resolve entirely through it. This is not a migration artifact you can ignore; it is the load-bearing design fact for anyone adding a new integration. See references/case-studies.md for full detail, but the pattern repeats everywhere:

  • JS/TS/HTML/CSS (the platform's own built-in support) grafts PolySymbols onto pre-existing extension points (XmlElementDescriptorProvider, css.elementDescriptorProvider, JSReferenceExpression.resolve()) and explicitly steps aside for standard/spec symbols — e.g. HtmlElementSymbolDescriptorsProvider.getElementDescriptor() returns null when the query result hasOnlyStandardHtmlSymbols(), deferring to the bundled RelaxNG HTML5 schema; the legacy CssElementDescriptorProviderImpl is kept registered with order="last" as the CSS fallback; TypeScriptReferenceExpressionResolver only consults PolySymbols for unqualified references inside injected/embedded expression hosts. Standard tag/attribute/property lists are not Web Types data — they're the pre-existing RelaxNG schema and webref CSS XML.
  • Vue and Angular — the docs' own "heaviest adopters" — are close to fully PolySymbols-driven for their template/markup surface (components, directives/selectors, props/inputs, slots, events, modifiers), but Vuex, <style src>/ref=/file-path references, and CSS v-bind() bindings (Vue), and the Angular2 expression-language layer, templateUrl/pipe-name references (Angular) all still run through plain PsiReferenceContributor/CompletionContributor code with no PolySymbols involvement at all.
  • GDScript, the newest integration, is explicitly dual-track by its own admission — its in-tree README (dotnet/Plugins/godot-support/gdscript/.../polySymbols/README.md) states the PSI and PolySymbols implementations both run today and produce duplicate Find Usages results until the legacy path is deleted. Local variables, parameters, for-loop bindings, resource-path references, and the entire TSCN language have no PolySymbols coverage yet.

Actionable takeaway: for every new integration or feature, decide explicitly whether PolySymbols is the resolution path of record for that PSI element/feature, or merely a supplementary layer contributing extra symbols on top of an existing mechanism. If a legacy PsiReferenceContributor/CompletionContributor and a new PolySymbols registration can both fire on the same host PsiElement, either gate one off (a feature flag, a context check, an early return null/empty-list from whichever should defer) or accept and document the overlap — don't assume the platform will pick one for you.

Wiring checklist — adding PolySymbol support

  1. Opt the language in: register polySymbols.enableInLanguage language="..." (EP com.intellij.polySymbols.enableInLanguage) so PsiExternalReferenceHosts in that language are eligible for PolySymbols reference resolution at all.
  2. Contribute scopes: implement PolySymbolQueryScopeContributor (EP com.intellij.polySymbols.queryScopeContributor) — map PSI locations to PolySymbolScopes via the registrar DSL. This is almost always the first and most important class you write. Details: references/query-model.md.
  3. Resolve references: implement PsiPolySymbolReferenceProvider per host PsiElement type (EP com.intellij.polySymbols.psiReferenceProvider, one registration per hostElementClass). Alternative: implement PsiElement.getOwnReferences() directly via the PolySymbolOwnReferences builder when PolySymbols should be the language's own canonical resolve rather than an EP-contributed layer (e.g. replacing a legacy PsiReferenceContributor) — see references/query-model.md. Don't register both for the same host — own references pre-empt external ones. Either way, the host element's own type must implement PsiExternalReferenceHost (external) or PolySymbolOwnReferenceHost (own) — PolySymbolHighlightingAnnotator only looks at elements implementing one of the two, so skipping this isn't just a missed nicety, it's silently no highlighting/diagnostics at all (own references also won't compile against the DSL without it).
  4. Supply declarations: if a symbol maps 1:1 onto a real PsiElement and lives purely in the PolySymbols model, implement PolySymbolDeclaredInPsi plus a PolySymbolDeclarationProvider (EP com.intellij.polySymbols.declarationProvider) that builds the symbol — this is the default. The provider is pure dispatch: decide which symbol(s) a PsiElement backs, instantiate them, and return symbol.declaration (the interface's own default). Don't hand-roll a PolySymbolDeclaration implementation or thread a range through the provider — a non-default declaration range is a textRangeInSourceElement override on the symbol class itself; the symbol represents itself, the provider only knows which symbol to build. Reach for PsiLinkedPolySymbol + polySymbols.psiLinkedSymbol host="..." only when that same PsiElement must also keep working as a target for a legacy, non-PolySymbols find-usages/rename mechanism you're running alongside (a bridge for partial migrations, not a general shortcut — see references/query-model.md). For symbols with no backing PsiElement at all (synthetic/SDK symbols), write a PolySymbolDeclarationProvider by hand.
  5. Wire completion: register an ordinary completion.contributor whose provider extends PolySymbolsCompletionProviderBase and calls queryExecutor.codeCompletionQuery(...).
  6. Optional: PolySymbolQueryConfigurator for context rules/name-conversion rules; PolySymbolQueryResultsCustomizerFactory to post-filter/remap query results; polySymbols.webTypes if standard-library symbols can be shipped as static JSON instead of code (see references/web-types.md); a PolySymbolFramework (polySymbols.framework) + PolyContextProvider (polySymbols.context) if you're introducing a new framework identity (see poly-context).
  7. Use PolySymbolWithPattern/the pattern DSL when the language/framework layers a microsyntax on top of base syntax (directive-style attribute names, event-modifier chains). See references/patterns.md.

Case studies

Four real integrations in this repo, each ending in an explicit PolySymbols-vs-legacy verdict — read references/case-studies.md for the full writeup with file:line evidence.

IntegrationWhereOne-line verdict
GDScriptdotnet/Plugins/godot-support/gdscript/.../polySymbols/Dual-track: SDK/engine symbols are PolySymbols-first; user-code locals, resource refs, and TSCN are legacy-only, both paths run concurrently on some elements
JS/TS, HTML, CSSplugins/JavaScriptLanguage/web-platform/, community/xml, plugins/cssPolySymbols is grafted onto legacy extension points and steps aside for anything standard/spec-defined
Vuecontrib/vuejs/vuejs-backend/src/org/jetbrains/vuejs/web/Template/markup surface (components/directives/props/slots/events) is ~fully PolySymbols; Vuex, refs, CSS bindings are not
Angularcontrib/Angular/angular-backend/src/org/angular2/web/Markup/selector surface is ~fully PolySymbols; the Angular2 expression-language layer and some file/pipe-name refs are not

Related skills

Supporting files

Load only when needed:

  • Query model — query executor, scopes, contributors, configurators, declarations, references, completion, search/rename/nav hookups.
  • Patterns — the pattern DSL, PolySymbolMatch/name segments, ReferencingPolySymbol, the Vue directive worked example.
  • Case studies — GDScript, JS/TS/HTML/CSS, Vue, Angular, in depth.
  • Web Types — static JSON symbol definitions.
  • Testing — writing tests for a PolySymbols integration: the PolySymbolsTestCase hierarchy, the PolySymbolsTestUtil.kt cheat sheet, feature-by-feature recipes.
  • Migration — migrating a PSI-based feature to PolySymbols, tests-first: the preliminary-tests-migration recipe, forbidden CodeInsightTestFixture methods, the per-kind production migration unit.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

actions

免费有简介

实现或修改 IntelliJ `AnAction`,并在 `plugin.xml` 中注册。将显示名称和说明写入消息资源文件,按需设置图标,并通过事件协程作用域启动挂起任务,避免同步处理阻塞 IDE。

  • 为 IDE 菜单添加操作
  • 修改操作注册或图标
  • 整理操作名称和说明
JetBrains/intellij-community2.1万2026年10月29日 更新

bazel-test-migration

免费有简介

将 IntelliJ JPS 测试模块迁移到 Bazel,并排查仅在 Bazel 中出现的失败。根据症状检查依赖、插件、测试数据和 runfiles,重新生成并验证目标。

  • 将 JPS 测试模块迁移到 Bazel
  • 排查仅在 Bazel 中失败的测试
  • 检查测试依赖和数据配置
JetBrains/intellij-community2.1万2026年10月29日 更新

code-style

免费有简介

按 IntelliJ 项目规范编写或审查 Kotlin 和 Java 代码,涵盖语言选择、格式、密封类型、线程注解及控制流异常处理。

  • 按 IntelliJ 规范编写 Kotlin
  • 审查 Java 代码
  • 检查异常处理和密封类型分支
JetBrains/intellij-community2.1万2026年10月29日 更新

commits

免费有简介

本指南帮助您按 IntelliJ 项目规则拆分更改并撰写提交信息:有工单时使用编号和变更说明,无工单时使用标签与子系统名,并在需要时说明原因和决定。

  • 按项目格式编写带工单号的提交信息
  • 整理测试或文档提交并选择合适标签
  • 按规则修改已有提交信息
JetBrains/intellij-community2.1万2026年10月29日 更新

使用多个 Python 类型检查器比较代码片段或文件的类型推断和报错判断,并汇总各工具的结论、耗时与诊断信息,可保存为 Markdown 报告。

  • 比较不同检查器的类型推断
  • 确认代码是否会被判为类型错误
  • 查看多个工具的诊断差异
JetBrains/intellij-community2.1万2026年10月29日 更新

整理 Compose Desktop 界面中的状态和副作用,让可组合函数负责绘制,由展示器或协调器处理应用决策。了解状态归属、Effect、可复用组件接口、延迟列表键、动画和性能,适用于单项界面修改。

  • 分离界面绘制与展示器决策
  • 整理界面状态的归属
  • 检查 Effect 键和协程用法
JetBrains/intellij-community2.1万2026年10月29日 更新

查看 JetBrains 的全部技能

报告此技能的问题