[T-006] Add LSP features, comprehensive tests, and CI#3
[T-006] Add LSP features, comprehensive tests, and CI#3SuperInstance wants to merge 1 commit intomainfrom
Conversation
| 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`, |
There was a problem hiding this comment.
🔴 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
Debug
- 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
e61c10c to
a43abb7
Compare
|
Closing: superseded by merged work on main. The changes from this PR have been incorporated through other merged PRs. Thank you for the contribution! 🙏 |
Summary
Contributes to the FLUX Language Server Protocol implementation (T-006 from Oracle1 TASKS.md).
Changes
Bug Fixes
Connection.log→Connection.console.info(v9.x API change)CompletionListimportfoldingRanges→foldingRange(correct LSP API method)Definitionreturn type to allownullSignatureHelpProvidertype mismatchop.role→o.roletypo in opcode snippet generationOperandInfo | undefinedtype narrowing in parserNew Features
referencesProvider— finds all label definition sites and usage sites across the document. SupportsincludeDeclarationcontext.Tests (104 tests, 4 suites)
CI
Other
.gitignore(node_modules, dist, tsbuildinfo)jest.config.jsfor ts-jestTest Results
Files Changed
src/server.ts— Find references, API fixessrc/index.ts— Connection API fixsrc/opcode-database.ts— Snippet typo fixsrc/parser.ts— Type narrowing fixsrc/__tests__/*.test.ts— 4 new test files.github/workflows/ci.yml— CI workflowjest.config.js— Jest configuration.gitignore— Git ignore rules