Skip to content

feat(vscode): hover docs for built-in IEC data types (#55)#151

Merged
thiagoralves merged 1 commit into
developmentfrom
fix/55-iec-type-hover
Jun 1, 2026
Merged

feat(vscode): hover docs for built-in IEC data types (#55)#151
thiagoralves merged 1 commit into
developmentfrom
fix/55-iec-type-hover

Conversation

@thiagoralves
Copy link
Copy Markdown
Contributor

Closes #55.

Summary

Hovering a built-in IEC 61131-3 type name (INT, TIME, LREAL, …) in a .st file 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).

  • New server/src/iec-type-docs.tsIEC_TYPE_DOCS map (26 elementary types) + getIecTypeDoc(word).
  • hover.ts getHover — 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 advertises hoverProvider: true and routes onHover → getHover (both server.ts and server-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:

  • It's closed/unmerged, based on the stale feature/vscode-extension branch.
  • It adds a standalone hover-provider.ts + direct server.ts onHover wiring — but hover has since been consolidated into hover.ts/getHover (called from register-analysis-handlers.ts). Its integration would conflict/duplicate.
  • Its data is wrong for STruC++: it documents TIME/DATE/TOD/DT as 32-bit, but src/runtime/include/iec_types.hpp defines 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: hovering INT/TIME shows the docs; hovering a variable name does not get hijacked.
  • Full extension suite green (252 tests); tsc -b build clean; additions are lint-clean.

🤖 Generated with Claude Code

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>
@thiagoralves thiagoralves merged commit 17a43f5 into development Jun 1, 2026
@thiagoralves thiagoralves deleted the fix/55-iec-type-hover branch June 1, 2026 20:13
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.

VSCode extension: add hover documentation for IEC data types

1 participant