Skip to content

Filter dictionary properties by term kind - #65

Merged
barad1tos merged 3 commits into
mainfrom
refactor/dictionary-term-catalog
Aug 13, 2026
Merged

barad1tos merged 3 commits into
mainfrom
refactor/dictionary-term-catalog

Conversation

@barad1tos

@barad1tos barad1tos commented Aug 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Keep imported dictionary properties available in completion when Cocoa defines a command with the same name. Term enumeration and kind-aware Cocoa filtering now live in a small internal catalog instead of resolver-private collection branches.

Changes

  • Centralize ordered dictionary-term projection in DictionaryTermCatalog while preserving existing unfiltered and filtered ordering.
  • Match properties against Cocoa properties instead of Cocoa commands.
  • Keep resolver orchestration, fallback behavior, public JVM surfaces, and parser/grammar sources unchanged.
  • Cover both historical catalog orders, same-name cross-kind collisions, missing Cocoa terminology, no-use fallbacks, and the real code-completion path with synthetic dictionaries.

Validation

./gradlew ktlintCheck detekt check build verifyPlugin --warning-mode all
# Build, tests, coverage, static analysis, generated-source parity,
# service-graph checks, and plugin verification passed

IDE inspections reported no findings in all three touched Kotlin files.

Mutation verification confirmed that the tests fail when property-kind lookup, filtered ordering, missing-Cocoa handling, or no-use fallback behavior is regressed.

Review notes

The historical term ordering remains intentionally different between unfiltered projection and Cocoa-filtered projection. No ApplicationDictionary API, BNF, lexer, parser, generated source, or persisted user setting changed.

- Centralize term enumeration and Cocoa filtering in an internal dictionary catalog
- Cover the real completion path with a same-name property and command collision

Impact: Imported properties remain available unless Cocoa defines the same property
@sourcery-ai

sourcery-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Centralizes dictionary term collection and Cocoa filtering into DictionaryTermCatalog, updates resolver to use term-kind-aware matching, and adds regression tests for ordering and completion behavior.

Sequence diagram for Cocoa-aware dictionary term filtering via DictionaryTermCatalog

sequenceDiagram
participant Resolver as AppleScriptDictionaryResolveProcessor
participant Registry as AppleScriptProjectDictionaryService
participant Dictionary as ApplicationDictionary
participant Catalog as DictionaryTermCatalog

Resolver->>Dictionary: collectTerms(dictionaryComponents, shouldFilterCocoa)
alt shouldFilterCocoa
  Resolver->>Registry: getCocoaStandardTerminology()
  Registry-->>Resolver: cocoaStandardTerminology
  Resolver->>Catalog: missingTerms(Dictionary, cocoaStandardTerminology)
  Catalog-->>Resolver: filteredComponents
else
  Resolver->>Catalog: allTerms(Dictionary)
  Catalog-->>Resolver: allComponents
end
Loading

File-Level Changes

Change Details Files
Refactor dictionary term collection and Cocoa filtering logic to use a centralized catalog while keeping resolver orchestration and ordering semantics intact.
  • Rename and simplify resolver flags and helper methods related to Cocoa and additions filtering.
  • Replace inline collection and filtering of dictionary components with calls to DictionaryTermCatalog for both full and filtered term sets.
  • Preserve fallback behavior for scripting additions and Cocoa standard terminology while routing through the new collection helpers.
src/main/kotlin/com/intellij/plugin/applescript/lang/resolve/AppleScriptDictionaryResolveProcessor.kt
Introduce DictionaryTermCatalog to encapsulate ordered term projection and kind-aware missing-term detection between dictionaries.
  • Provide allTerms to build a single ordered list of enumerators, properties, classes, and commands from an ApplicationDictionary.
  • Provide missingTerms to compute terms present in one dictionary but absent in a baseline, matching properties against baseline properties instead of commands.
  • Ensure term enumeration order matches the historical unfiltered and filtered ordering expected by completion.
src/main/kotlin/com/intellij/plugin/applescript/lang/sdef/DictionaryTermCatalog.kt
Add focused tests to validate kind-aware property filtering, term ordering, and real completion behavior with synthetic dictionaries.
  • Verify that missingTerms keeps imported properties whose names collide with Cocoa commands while filtering properties that collide with Cocoa properties.
  • Assert that allTerms preserves expected ordering of enumerators, properties, classes, and commands.
  • Exercise the IDE completion path using cached test dictionaries to ensure imported properties remain in completion while Cocoa properties are filtered out.
src/test/kotlin/com/intellij/plugin/applescript/test/sdef/DictionaryTermCatalogTest.kt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...g/resolve/AppleScriptDictionaryResolveProcessor.kt 82.35% 0 Missing and 3 partials ⚠️
...gin/applescript/lang/sdef/DictionaryTermCatalog.kt 80.00% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

- Cover filtered ordering, missing Cocoa terminology, and no-use fallbacks
- Keep mutable dictionary and discovery state inside hermetic cleanup scopes
- Remove an inaccurate private helper comment exposed by the new coverage

Impact: Completion refactors now preserve fallback and ordering behavior under direct regression tests
- Model an unavailable Cocoa dictionary at the internal catalog boundary
- Replace process-global discovery mutation with a direct null-contract regression
- Preserve the resolver's fail-closed completion behavior without startup races

Impact: Dictionary completion tests are deterministic on clean macOS runners
@barad1tos
barad1tos marked this pull request as ready for review August 13, 2026 19:55

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @barad1tos, you have reached your weekly rate limit of 1500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@barad1tos
barad1tos merged commit e202722 into main Aug 13, 2026
11 checks 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.

1 participant