Skip to content

Add comprehensive test suite covering indexes, references, and providers#55

Merged
xepozz merged 11 commits into
mainfrom
claude/intellij-platform-analysis-Uaqhj
May 24, 2026
Merged

Add comprehensive test suite covering indexes, references, and providers#55
xepozz merged 11 commits into
mainfrom
claude/intellij-platform-analysis-Uaqhj

Conversation

@xepozz

@xepozz xepozz commented May 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds a comprehensive test suite with 30 new test classes covering the plugin's core functionality: file-based indexes, PSI references, line markers, folding, run configurations, and implicit usage providers. Additionally, it includes a static code analysis directory documenting per-file findings and recommendations.

Key Changes

Test Coverage (30 new test classes)

  • Router subsystem: RouterNamesIndexTest, RouterUrlsIndexTest, RouterReferenceVariantsTest, SpiralEndpointsProviderTest, RoutesImplicitUsageProviderTest
  • CQRS subsystem: CqrsCommandIndexTest, CqrsQueryIndexTest, CqrsCommandHandlerIndexTest, CqrsQueryHandlerIndexTest, CqrsIndexUtilTest, CqrsHandlersLineMarkerProviderTest, CqrsHandlersImplicitUsageProviderTest
  • Console subsystem: ConsoleCommandNameExtractionTest, ConsoleCommandLineMarkerProviderTest, SpiralConsoleCommandRunConfigurationSettingsTest
  • Config subsystem: ConfigSectionIndexTest, PrototypedIndexTest, EnvFoldingBuilderTest
  • Views subsystem: ViewsNamespaceIndexTest, ViewFileReferenceTest, PHPLanguageInjectorTest
  • Container subsystem: ContainerReferenceContributorTest
  • Prototyped subsystem: PrototypedCompletionTest
  • References: DirectoryReferenceTest, FunctionsReferenceContributorTest
  • Core: SpiralFrameworkClassesTest, ObjectStreamDataExternalizerTest, SpellcheckingDictionaryProviderTest

Code Improvements

  • Added JSDoc comments to RouteReferenceContributor, PrototypedIndex, ConfigSectionIndex, and Route data class
  • Enhanced AbstractRouterIndex with improved logging and dumb-mode handling
  • Improved RouterIndexUtil with dumb-mode awareness and better error handling
  • Added SpiralBundle message keys for endpoints UI (endpoints.group.root, endpoints.group.name, endpoints.endpoint.method)
  • Fixed SpiralGroup to use WeakReference for project references (memory leak prevention)
  • Cleaned up unused test data files (rename/foo.xml, rename/foo_after.xml)
  • Updated PHPLanguageInjector to remove commented-out code
  • Enhanced SpiralEndpointsProvider with bundle message usage
  • Improved ContainerReferenceContributor with explicit imports
  • Updated SpiralFrameworkClasses with additional constants for container and views
  • Fixed SpiralConsoleCommandRunConfigurationSettings state delegate backing

Static Analysis Documentation

  • Added analysis/ directory with per-file code review reports
  • Created analysis/_CONTEXT.md with shared analysis context and conventions
  • Created analysis/README.md documenting the analysis structure and severity tags
  • Generated 50+ analysis markdown files covering all major source files

Configuration & Build

  • Updated gradle.properties with additional test dependencies
  • Updated CHANGELOG.md with unreleased section documenting test suite addition

Notable Implementation Details

  • All tests use BasePlatformTestCase with proper fixture configuration
  • Tests verify index behavior, reference resolution, completion variants, and line marker placement
  • Analysis reports follow a consistent structure with severity tags (DUMB-MODE, INDEX, STYLE, etc.)
  • Test coverage includes edge cases like multiple routes on same URI, handler method indexing, and run configuration property isolation

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6

claude added 11 commits May 24, 2026 09:35
Static review of every Kotlin source file under
src/main/kotlin/com/github/xepozz/spiral/, written by per-file review
subagents seeded with an IntelliJ Platform best-practices checklist.

- analysis/README.md indexes high-signal findings by severity
- analysis/_CONTEXT.md is the shared reviewer brief (project conventions
  + threading / dumb-mode / index / reference / completion guidelines)
- one report per source file, mirroring the package layout, with
  severity-tagged findings and file:line locations

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
The original MyPluginTest.kt was a template leftover referencing
services.MyProjectService which does not exist. compileTestKotlin
failed against it, blocking any new tests. This replaces it with a
trivial sanity check and drops the matching template testData/rename
fixtures.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Add shared Spiral FQN constants so feature modules (config/env folding,
container references) no longer hardcode them. Other worktrees can
consume these from one location.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Worktree subagents use absolute paths via Edit, which resolve to the
main worktree rather than their isolated worktree path. As a result
their fixes (config/, container/, forms/, router/, scaffolder/, views/)
are accumulating here. These should be coherent with each agent's own
worktree branch and will reconcile cleanly when those branches are
merged. Console, cqrs, and prototyped+references agents are still
running; further fixes will land in subsequent commits.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Test files written by router and views worktree agents via absolute
paths landed in main rather than their isolated worktrees. Collecting
them here so the stop hook unblocks; they overlap with the same agents'
own worktree-branch commits and will reconcile at merge time.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Worktrees created for parallel subagent isolation live under
.claude/worktrees/ and should never enter version control.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Router agent finalized further router/index refactors after the WIP
commit; absolute Edit paths landed them in main. Aligns with the
worktree-agent-ac7d65370436ebfce branch.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Two compile fixes:
- Add VIEWS_RENDER_SIGNATURE constant to SpiralFrameworkClasses
  (scaffolder/views agent referenced it but its addition didn't leak).
- Add com.intellij.openapi.diagnostic.debug import to
  SpiralProjectGenerator so the lazy Logger.debug { ... } calls
  resolve.

Pull in test files written by worktree agents that did not leak to
main: foundation tests (SpellcheckingDictionaryProviderTest,
SpiralFrameworkClassesTest, ObjectStreamDataExternalizerTest), all
cqrs tests, prototyped + references tests, and console tests.

compileKotlin + compileTestKotlin -x patchPluginXml: exit 0.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Root cause of the failing test wave: gradle.properties did not declare
com.intellij.modules.json in platformBundledPlugins. Without it the
PHP plugin refused to load in the test sandbox (Plugin 'PHP' requires
plugin 'com.intellij.modules.json' to be installed), which cascaded
to every Spiral plugin extension never being registered — producing
the "Index is not created for Spiral.X" wave.

Real production bugs uncovered by the resulting tests:
- ObjectStreamDataExternalizer.read NPE on null payloads (`as T` ->
  `as T?`).
- SpiralConsoleCommandRunConfigurationSettings aliased
  workingDirectory and documentRoot onto the binary state slot.
- CqrsHandlersImplicitUsageProvider.isClassWithCustomizedInitialization
  returned true unconditionally, marking every PHP class as having
  customized init.
- CqrsHandlersLineMarkerProvider matched on PhpClass but the platform
  calls line markers on leaf elements only; re-anchored to the
  class-name identifier.

Test fixes apply BasePlatformTestCase-appropriate patterns: explicit
doHighlighting/CodeFoldingManager triggers, FileBasedIndex
ensureUpToDate / smart-mode wrappers, caret placement adjustments.

./gradlew test -x patchPluginXml: 76/76 passing, exit 0.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Code review (5 finder angles + 1-vote verification) flagged three
call sites that consume PrototypedIndex / CqrsIndexUtil without the
dumb-mode wrapper their own KDoc/contract requires:

- prototyped/PrototypedCompletion.kt:46 — completion popup at a
  PrototypeTrait site during indexing would throw
  IndexNotReadyException.
- cqrs/CqrsHandlersLineMarkerProvider.kt:30 — gutter pass over a
  Command/Query class during indexing would crash and silently drop
  every CQRS line marker.
- prototyped/PrototypedPropertyReference.kt:29 — getVariants() called
  during indexing would crash completion.

Fix: early-return when DumbService.isDumb(project), so the IDE simply
shows no result until indexes are ready, instead of erroring.

./gradlew test -x patchPluginXml: 76/76 passing, exit 0.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
Summarize the user-visible changes from the multi-agent review pass:
new test suite, settings-corruption + NPE + CQRS over-reporting +
missing gutter icons + dumb-mode guard regressions.

https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
@xepozz
xepozz merged commit 00bbc1a into main May 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants