feat(vscode): hover docs for built-in IEC data types (#55)#151
Merged
Conversation
Hovering a built-in IEC 61131-3 type name (INT, TIME, LREAL, …) now shows a markdown tooltip with the full name, category, value range, bit size, and literal syntax where applicable. - New server/src/iec-type-docs.ts: IEC_TYPE_DOCS map (26 elementary types) + getIecTypeDoc(word). Sizes reflect how STruC++ actually lowers each type per src/runtime/include/iec_types.hpp. - hover.ts getHover: resolve a built-in type name from the source word at the cursor (type names are reserved keywords, so they never collide with user symbols and often have no AST symbol node). The server already advertises hoverProvider and routes onHover → getHover, so no wiring change was needed. Implemented fresh against the current hover architecture rather than reviving the closed PR #56, which targeted a stale feature branch, added a separate hover-provider.ts that doesn't fit today's getHover/handler flow, and — critically — documented TIME/DATE/TOD/DT as 32-bit, whereas STruC++ represents all temporal types as signed int64 (TIME/LTIME/TOD/DT in ns, DATE in days). The new docs are corrected accordingly. Tests: unit coverage for getIecTypeDoc (all 26 types, case-insensitivity, null cases, int64 temporal regression guard) + getHover integration (hovering INT/TIME shows docs; hovering a variable name does not). Full extension suite green (252 tests); tsc build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #55.
Summary
Hovering a built-in IEC 61131-3 type name (
INT,TIME,LREAL, …) in a.stfile now shows a markdown tooltip with the full name, category, value range, bit size, and literal syntax. Hovering a non-type word returns nothing (or the normal symbol hover).server/src/iec-type-docs.ts—IEC_TYPE_DOCSmap (26 elementary types) +getIecTypeDoc(word).hover.tsgetHover— resolves a built-in type name from the source word at the cursor. Type names are reserved keywords, so they never collide with user symbols and often have no AST symbol node; doing a direct text lookup is the reliable approach. The server already advertiseshoverProvider: trueand routesonHover → getHover(bothserver.tsandserver-browser.ts), so no wiring change was needed.Does PR #56 address this on the current codebase? No.
PR #56 was the right idea but doesn't fit today's code:
feature/vscode-extensionbranch.hover-provider.ts+ directserver.tsonHoverwiring — but hover has since been consolidated intohover.ts/getHover(called fromregister-analysis-handlers.ts). Its integration would conflict/duplicate.TIME/DATE/TOD/DTas 32-bit, butsrc/runtime/include/iec_types.hppdefines all of them as signed int64 (TIME/LTIME/TOD/DT in nanoseconds, DATE in days). The new docs are corrected to match the actual implementation.So I implemented it fresh against the current architecture and salvaged only the accurate parts of #56's type table.
Tests
iec-type-docs.test.ts— all 26 types return docs, case-insensitivity, null cases, and a regression guard that the temporal types are documented as int64 (not 32-bit ms).hover.test.ts— integration: hoveringINT/TIMEshows the docs; hovering a variable name does not get hijacked.tsc -bbuild clean; additions are lint-clean.🤖 Generated with Claude Code