Skip to content

[T-006] Add LSP features, comprehensive tests, and CI#3

Closed
SuperInstance wants to merge 1 commit intomainfrom
superz/lsp-features
Closed

[T-006] Add LSP features, comprehensive tests, and CI#3
SuperInstance wants to merge 1 commit intomainfrom
superz/lsp-features

Conversation

@SuperInstance
Copy link
Copy Markdown
Owner

@SuperInstance SuperInstance commented Apr 12, 2026

Summary

Contributes to the FLUX Language Server Protocol implementation (T-006 from Oracle1 TASKS.md).

Changes

Bug Fixes

  • Fix TypeScript compilation: 11 compilation errors resolved
    • Connection.logConnection.console.info (v9.x API change)
    • Added missing CompletionList import
    • foldingRangesfoldingRange (correct LSP API method)
    • Fixed Definition return type to allow null
    • Fixed SignatureHelpProvider type mismatch
    • Fixed op.roleo.role typo in opcode snippet generation
    • Fixed OperandInfo | undefined type narrowing in parser

New Features

  • Find References: Enabled referencesProvider — finds all label definition sites and usage sites across the document. Supports includeDeclaration context.

Tests (104 tests, 4 suites)

  • Parser tests (48 tests): Line parsing, label extraction, label references, sections, register/immediate/label-ref validation, operand count validation
  • Diagnostics tests (28 tests): Valid programs, unknown mnemonics, register range, undefined labels, immediate range, malformed values, edge cases
  • Opcode database tests (24 tests): Lookup, format markdown, completion items, register/directive items, database integrity
  • Server integration tests (4 tests): Document validation, .flux.md code block filtering, document symbols, capabilities

CI

  • Added GitHub Actions workflow: tests on Node.js 18/20/22 with TypeScript check, build, and test steps

Other

  • Added .gitignore (node_modules, dist, tsbuildinfo)
  • Added jest.config.js for ts-jest

Test Results

Test Suites: 4 passed, 4 total
Tests:       104 passed, 104 total

Files Changed

  • src/server.ts — Find references, API fixes
  • src/index.ts — Connection API fix
  • src/opcode-database.ts — Snippet typo fix
  • src/parser.ts — Type narrowing fix
  • src/__tests__/*.test.ts — 4 new test files
  • .github/workflows/ci.yml — CI workflow
  • jest.config.js — Jest configuration
  • .gitignore — Git ignore rules

Staging: Open in Devin

Copy link
Copy Markdown

@beta-devin-ai-integration beta-devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Staging: Open in Devin

Comment thread src/opcode-database.ts
insertText: op.operands.length === 0
? op.mnemonic
: `${op.mnemonic} ${op.operands.filter(o => o.role !== '-').map(o => o.role === 'imm8' ? '${1:0}' : o.role === 'imm16' ? '${1:0}' : `$\{${op.role}\``).join(', ')}$0`,
: `${op.mnemonic} ${op.operands.filter(o => o.role !== '-').map(o => o.role === 'imm8' ? '${1:0}' : o.role === 'imm16' ? '${1:0}' : `$\{${o.role}\``).join(', ')}$0`,
Copy link
Copy Markdown

@beta-devin-ai-integration beta-devin-ai-integration Bot Apr 12, 2026

Choose a reason for hiding this comment

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

🔴 Broken snippet template literal produces malformed VS Code snippet text for register operands

The inline snippet generation in getOpcodeCompletionItems produces malformed snippet text for all opcodes with register operands. The template literal `$\{${o.role}\ evaluates to `${rd\ (with a trailing backtick instead of a closing brace, and missing placeholder number), whereas VS Code snippets require the format ${1:rd}. This was verified by evaluation: for an opcode like ADD, the new code produces "ADD ${rd\, ${rs1`, ${rs2`$0"instead of the expected"ADD ${1:rd}, ${2:rs1}, ${3:rs2}$0". The old code correctly used buildOpcodeSnippet() (src/opcode-database.ts:406-425`) which is now dead code. This breaks autocompletion snippets for every opcode with operands (~200+ opcodes).

Snippet output comparison

New (broken): ADD ${rd\, ${rs1`, ${rs2`$0`

Old (correct): ADD ${1:rd}, ${2:rs1}, ${3:rs2}$0

Additionally, all immediate operands (imm8/imm16) are hardcoded to placeholder ${1:0} regardless of position, whereas the old code used incrementing placeholder numbers.

Open in Devin Review (Beta)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

- Fix TypeScript compilation errors (Connection.log, CompletionList import,
  foldingRanges API, type narrowing issues)
- Add Find References feature for label definitions and usages
- Add comprehensive test suite (104 tests covering parser, diagnostics,
  opcode database, and server integration)
- Add GitHub CI workflow with multi-node matrix
- Add .gitignore and jest.config.js
- Update capabilities: referencesProvider enabled, fix foldingRange API
@SuperInstance
Copy link
Copy Markdown
Owner Author

Closing: superseded by merged work on main. The changes from this PR have been incorporated through other merged PRs. Thank you for the contribution! 🙏

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