Skip to content

Auto-completion for OFT coverage-tag targets in source comments #32

@redcatbear

Description

@redcatbear

Goal

Add specification item ID completion inside OpenFastTrace coverage tags in supported source/configuration files.

Today the plugin already completes OFT item IDs in Covers: sections of Markdown/RST specification files. The same typo-prevention benefit should be available when developers add coverage tags in code comments, for example:

// [impl->dsn~homework-excuse~1]

When the user is editing the right-hand side of a likely coverage tag, the IDE should suggest existing specification item IDs from the project.

Proposed Behavior

The plugin suggests existing OpenFastTrace specification item IDs when completion is invoked inside the target side of a coverage tag candidate in a supported coverage-tag file.

Completion should activate only when the surrounding text gives a strong signal that the user is editing an OFT coverage tag:

  • the caret is inside a comment
  • the file type is supported by the OFT tag importer
  • an opening [ appears before the caret in the same relevant comment/tag span
  • a left-hand artifact type and -> arrow are already present
  • the caret is on the right-hand side of the arrow, before the closing ] or before the end of an incomplete tag

Examples where completion should be available:

// [impl->dsn~home<caret>]
// [impl -> dsn~home<caret>]
// [impl -> home<caret>]
// [impl -> <caret>]

Examples where completion should not be available:

// req~home<caret>
String text = "[impl->dsn~home<caret>]";
// [impl->dsn~homework-excuse~1] <caret>

Strategy

Reuse the existing specification declaration index and completion ranking already used for Covers: completion.

The implementation should add a coverage-tag completion context detector that is more tolerant than the strict coverage-tag parser. The strict parser should keep recognizing complete, valid tags for highlighting/navigation, while completion needs to recognize incomplete tags during editing.

Suggested activation rule:

In a supported coverage-tag file, inside a comment, if the current bracketed candidate already contains a left-hand artifact token followed by ->, complete specification item IDs on the right-hand side of the arrow.

Suggested ranking should match existing Covers: completion:

  1. full ID prefix
  2. item name prefix
  3. item name substring
  4. artifact type prefix
  5. deterministic tie-breaker by full ID

Delimitation

In scope:

  • completion for the right-hand target item of OFT coverage tags
  • support optional whitespace around ->
  • support incomplete tags while editing
  • source suggestions from declared specification items only
  • reuse IntelliJ standard completion UI
  • add platform tests for positive and negative activation cases

Out of scope:

  • completion for the left-hand side of the coverage tag
  • creating new specification items from completion
  • changing coverage-tag highlighting or navigation semantics
  • adding fuzzy matching beyond the existing completion policy
  • inserting whole tag templates such as [impl->...]
  • completion in ordinary code, strings, or unsupported file types

Acceptance Criteria

  • Given a supported source file with a comment containing [impl->dsn~log<caret>], completion suggests matching declared specification item IDs.
  • Given optional spaces around the arrow, completion still works.
  • Given an incomplete tag without closing ], completion still works.
  • Given the caret before the arrow, outside a comment, in a string literal, or in an unsupported file, completion does not suggest OFT IDs.
  • Completion suggestions use the same source index and ranking policy as existing Covers: completion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions