fix(completion): surface INCLUDE/MEMBER/OMIT/COMPILE/PRAGMA as keyword completions - #394
Open
geircodes wants to merge 1 commit into
Open
Conversation
…d completions WordCompletionProvider's keyword completion only pulled from two hardcoded local lists (BLOCK_STRUCTURES / PLAIN_KEYWORDS). Compiler directives like INCLUDE were never in either list, so they could never appear in completion -- typing "INCL" at the top of a file only surfaced unrelated variables that happened to share the prefix, with no INCLUDE entry to compete against. DirectiveService (clarion-directives.json) already exists and is wired into hover (HoverRouter) but was never consulted by word completion. Add a collectDirectives() step, following the same seen-map/JSON-service pattern already used for collectAttributes/collectBuiltins/collectDataTypes, so directive entries get their syntax/description as detail/documentation just like every other completion source in this file.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(completion): surface INCLUDE/MEMBER/OMIT/COMPILE/PRAGMA as keyword completions
What happened
Reported live: typing
INCLat column 2, near the top of a real PROGRAM file (before any procedure), never offered theINCLUDEkeyword — only unrelated variables from elsewhere in the project that happened to share theInclprefix (e.g.IncludeAddress,IncludeCriteria,IncludeIncomplete), with nothing namedINCLUDEitself to competeagainst.
Root cause
INCLUDEis modeled in this codebase as a "Compiler Directive" — it's defined inserver/src/data/clarion-directives.json(alongsideMEMBER,OMIT,COMPILE,PRAGMA,EQUATE,ITEMIZE,SECTION) and served byDirectiveService, which is already wired into hover (HoverRouter.ts:37, alongsideBuiltinFunctionService/AttributeService/PropertyService/EventService/KeywordService).WordCompletionProvider.ts, however, never queriesDirectiveServiceat all. Its keyword completion only comes from two hardcoded local collections:Neither list contains
INCLUDE(orMEMBER/OMIT/COMPILE/PRAGMA), so none of them could ever appear in word completion — a gap unrelated to any scoping/parsing logic, just a missing data source.Fix
Wire
DirectiveServiceintoWordCompletionProvider, following the exact same pattern already used forAttributeService/BuiltinFunctionService/DataTypeService/ControlServicein this same file — acollectDirectives()step added to theseen-map pipeline, run beforecollectKeywords()so directive descriptions take priority over the bare keyword fallback for anything they overlap with (e.g.SECTION/ITEMIZE, which are also inBLOCK_STRUCTURES):This also fixes the identical missing-completion gap for
MEMBER,OMIT,COMPILE, andPRAGMA— same root cause, same file, same fix.
Testing
New test in
WordCompletionProvider.test.ts: a document with anINCLUDE(...)line before any procedure — assertsINCLUDEappears in the completion list for prefixINCL.Harness against the real repro file: completion for
INCL/incl(case-insensitively) at the top of the file now returnsINCLUDE— previously returned nothing at all for that keyword. Full suite in an isolated worktree offorigin/version-1.0.1: 2341 passing, 0 failing, 4 pending (pre-existing, unrelated).Deployed and confirmed working live.
Scope
Two files:
server/src/providers/WordCompletionProvider.ts,server/src/test/WordCompletionProvider.test.ts(new test only). Independent of the companionfix/pragma-directive-misclassified-as-functionPR — different files, different bug, safe to merge in either order.Known follow-up (not part of this PR)
The
IncludeAddress/IncludeCriteria/etc. noise reported alongside this bug turned out to be two separate issues, not fixed here:PRAGMAmistyped asFunction) — see the companion PR above.ClarionAssistant'sSharedLspBridge.cs(MergeDbBarePrefix): itssolution-wide CodeGraph bare-prefix merge never filters out
local-scoped symbols, so aprocedure-private variable in one file gets merged into completion anywhere in the solution. Not
a Clarion-Extension bug — tracked separately in the
ClarionAssistantrepo.