Skip to content

feat: add O-spec sub-type support for fixed-format column assist#520

Open
bobcozzi wants to merge 4 commits into
codefori:mainfrom
bobcozzi:feat/o-spec-column-assist
Open

feat: add O-spec sub-type support for fixed-format column assist#520
bobcozzi wants to merge 4 commits into
codefori:mainfrom
bobcozzi:feat/o-spec-column-assist

Conversation

@bobcozzi
Copy link
Copy Markdown
Contributor

Summary

This PR adds correct column ruler and Column Assistant support for all Output (O) spec line types in fixed-format RPGLE. It supersedes #507 (@supravi96) which was a good idea but had incorrect column positions and was missing sub-type detection logic.


What was wrong with #507

  • The O-spec column positions were off — the definitions didn't match the actual fixed-format column layout
  • A single O-spec entry was used for all O-spec lines, but the ILE O-spec actually has five structurally distinct line types, each with different fields at different positions

O-spec line types

Fixed-format Output specs have five distinct line layouts. This PR adds a SpecRulers entry and full SpecFieldDef array for each:

Key Description Distinguishing characteristic
O File/Record header line Has filename (cols 7–16) and/or record type (col 17)
OAnd AND/OR continuation line Cols 16–20 contain AND or OR
OF Field output line Has an end position (cols 47–51) alongside a field name or constant
OFC Constant-only line No field name; constant/edit word starts at col 53
OXF Field-name-only line Has a field name but no end position

Updated Rulers

Each sub-type gets its own reference ruler that reflects only the fields relevant to that line:

O    : .....OFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa+.Constant/Editword/DateFormat
OAnd : .....O.........And++N01N02N03ExceptName+++++++++++++++++++++++++++++++++++++++++
OF   : .....O..............N01N02N03FieldName+++++BEcEndPoDConstant/Editword+++++++++++
OFC  : .....O..................................................Constant/Editword+++++++++++
OXF  : .....O..............N01N02N03FieldName++++++B+++++++++++++++++++++++++++++++++++

How sub-type detection works

A new resolveSpecKey(line) function in columnAssist.ts inspects the content of the current line to determine which O-spec sub-type it is, and returns the appropriate key for specs and SpecRulers lookup:

function resolveSpecKey(line: string): string {
  const specLetter = line[5]?.toUpperCase() ?? ``;
  if (specLetter !== `O`) return specLetter;

  const paddedLine = line.padEnd(80);
  const andOrKeyword = paddedLine.substring(15, 20).trim().toUpperCase();
  if (andOrKeyword === `AND` || andOrKeyword === `OR`) return `OAnd`;

  const filename  = paddedLine.substring(6,  16).trim();
  const type      = paddedLine.substring(16, 17).trim();
  const fieldName = paddedLine.substring(29, 43).trim();
  const endPos    = paddedLine.substring(46, 51).trim();
  const constant  = paddedLine.substring(52).trim();

  if (endPos && (fieldName || constant)) return `OF`;
  if (filename || type)                  return `O`;
  if (!fieldName && constant)            return `OFC`;
  if (fieldName)                         return `OXF`;
  return `O`;
}

This is called from both getAreasForLine (ruler decoration) and promptLine (Column Assistant UI), so both the visual ruler and the interactive field editor show the correct fields for whichever O-spec line type the cursor is on.


Files changed

  • extension/client/src/schemas/specs.ts — added SpecRulers entries and SpecFieldDef arrays for O, OAnd, OF, OFC, OXF
  • extension/client/src/language/columnAssist.ts — added resolveSpecKey(), updated getAreasForLine and promptLine to use it

Closes #507

bobcozzi and others added 3 commits May 19, 2026 15:22
Detect O-spec sub-types (OAnd, OF, OFC, OXF) so the column ruler and
Column Assistant UI show the correct field definitions for each O-spec
line variant, rather than always using the generic O-spec layout.

Changes:
- specs.ts: add SpecRulers entries and SpecFieldDef arrays for O, OAnd,
  OF, OFC, OXF with correct 0-indexed column positions
- columnAssist.ts: add resolveSpecKey() that inspects column content to
  determine which O-spec sub-type a line belongs to; use it in both
  getAreasForLine and promptLine

Supersedes PR codefori#507 (supravi96:O-spec_feature) which had incorrect
column positions and was missing the sub-type detection logic.
@bobcozzi bobcozzi mentioned this pull request May 19, 2026
6 tasks
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