PRO/II Language Server
Intelligent editing for PRO/II process simulation input decks.
A Language Server Protocol implementation that brings IDE-grade tooling to
PRO/II .inp files — hover documentation, go-to-definition, find-references,
rename, diagnostics, flowsheet analysis, formatting and more.
Why this exists
A PRO/II input deck is a dense, column-aligned text file. A single character
typo can silently disconnect a unit operation from the flowsheet, and the
simulator will not tell you why — it just fails to converge, or converges to
the wrong answer.
This extension reads the deck the way PRO/II does, builds a symbol table and a
flowsheet graph, and reports what is actually wrong.
One typo, five symptoms
671: PRODOCT L=FPOU ← should be PRODUCT
The language server reports:
| Line |
Diagnostic |
Message |
| 671 |
unknown-statement |
Unknown statement 'PRODOCT' in UNIT OPERATIONS |
| 669 |
missing-required-parameter |
PUMP is missing required parameter(s): PRODUCT |
| 669 |
unit-without-product |
PUMP 'FPUM' has no product stream |
| 669 |
disconnected-flowsheet |
Unit 'FPUM' is not connected to the main flowsheet |
| 676 |
undefined-stream |
Stream 'FPOU' is used but never defined |
Five diagnostics, one root cause. Without the chain you would hunt for a
missing NAME entry for FPOU; the real fix is one character.
Features
Hover documentation
Hover a keyword to see what PRO/II expects. For column hydraulics, TSIZE and TRATE hovers explain section ranges, tray types (including VALVE as a tray type), passes, spacing, and DPCALC. Column PRINT PROPTABLES= (also PROPTABLE=) hovers explain BRIEF, PART, and ALL. Tray efficiency hovers cover TEFF, CEFF, and EFACTOR; DPCOL documents the separate column pressure drop. OPER (or OPERATION) describes unit-specific operating conditions, including heat exchanger HTEMP. Heat exchanger hovers also distinguish the overall coefficient U from effective AREA, explain how XOPTION=STOP handles temperature crossover, and distinguish COUNTER/COUNTERCURRENT from COCURRENT. CONFIG hover also explains pass defaults for TPASS and SPASS and why they cannot be combined with FT. CONREACTOR provides conversion reactor documentation and is recognized as a unit in stream navigation.
- Unit operations — description, operating types, required and optional
parameters, worked example, engineering notes (FLASH, COLUMN, HX, PUMP,
COMPRESSOR, REACTOR, EQUIREACTOR, SPLITTER, VALVE, PIPE, CONTROLLER, …)
- Thermodynamic methods — suited-for, applicable range, when to avoid
(SRK, PR, NRTL, UNIQUAC, BWRS, GRAYSON, …)
- Parameters — units, typical ranges, practical tips
- Product specifications —
PRODUCT, OVHD, BTMS, phase selectors
(M/V/L/W/S), and the rate/fraction family (FOVHD, FBTMS,
FPROD, ROVHD, RBTMS, RPROD, XOVHD, XBTMS, XPROD, DT, DTBB,
DTAD, DP, FACTOR, DUTY)
- Streams — description, temperature, pressure, rate and phase, read from
PROP, PROPERTY, TBP, SPGR, MW and LIGHTEND statements
- Components — LIBID index and name
Navigation
- Go-to-Definition / Peek Definition — show every producing statement for a stream in
UNIT OPERATIONS, including outlets such as BTMS, even from a continued FEED list. The stream declaration is only a fallback when no producer is found. Unit IDs and components still go to their declarations.
- Find All References — every use of a symbol
- Document Highlight — all occurrences of the symbol under the cursor
- Rename — rename streams, units and components across the document
- Document Symbols — structured Outline (sections → units → streams)
- Workspace Symbols —
Ctrl+T search across open documents
Overlap identifiers are resolved by context. TGAS can be both a unit and a
stream; UID=TGAS resolves to the unit, FEED TGAS to the stream.
Diagnostics
| Code |
Meaning |
unknown-unit-operation |
Unit keyword not in the PRO/II dataset |
unknown-statement |
Misspelled statement keyword (e.g. PRODOCT) |
missing-required-parameter |
Unit lacks a parameter PRO/II requires |
undefined-stream |
Stream used but never declared |
unused-stream |
Stream declared but never used |
duplicate-definition |
Stream declared twice |
duplicate-unit |
Unit UID declared twice |
downstream-reference |
Stream consumed before it is produced |
invalid-component-index |
Component index past the end of the LIBID list |
disconnected-flowsheet |
Unit not connected to the main flowsheet |
unit-without-feed |
Unit has no inlet |
unit-without-product |
Unit has no outlet |
unconsumed-product |
Stream produced but never consumed (opt-in) |
missing-source |
Stream consumed but never produced (opt-in) |
recycle-stream |
Stream lies on a recycle loop (opt-in) |
Stream-level checks are opt-in because final products are legitimately
unconsumed, fresh feeds legitimately unproduced, and tear streams are normal.
Flowsheet analysis
The server builds a directed graph of units connected by process streams and
reports structural problems that are hard to spot by eye:
- Connectivity — union-find over shared streams. Calculation blocks
(
STCALC, CALCULATOR, CONTROLLER, HCURVE) are excluded from reported
components but still connect the units around them.
- Recycle detection — Tarjan strongly-connected components. A stream is a
recycle only when its producer and consumer share an SCC, i.e. the stream
genuinely lies on a cycle.
Completion
- Context-aware keyword suggestions
- Unit operation snippets with tab stops
- Section headers, parameters, thermodynamic methods
- Stream names in
FEED / PROD / PRODUCT / STRM= / REFS= positions,
excluding names already used on the line
Signature help
Fires inside basis qualifiers and describes each argument:
RATE(W,TM/D) basis, units
PRES(BAR) units
TEMP(3) tray index
OVHD(W) basis
COMP(M) basis
CEFF(VAPORIZATION) efficiency basis
CPCT(W,1,2) basis, component, component
SRXSTR(SWR,FOSE,FOSE) reaction, stream, stream
A numeric first argument to TEMP / PRES / FEED is described as a tray or
stage index; a symbolic one as a basis.
Aligns the UNIT OPERATIONS section to the column conventions measured from real
decks:
| Element |
Column |
| Unit operation keyword |
3 |
| Parameter keyword |
5 |
| Value |
15 |
Trailing $ comment |
43 |
Formatting is whitespace-only — it can never change the meaning of a deck.
Continuation lines keep their own indentation, and KEYWORD=value stays
compact. Idempotent: a second pass produces zero edits.
Tabs are always converted to spaces on save
This is not optional, and it is not a style preference.
A tab is one character but occupies several columns. PRO/II reads a
deck by fixed column position, so a single tab shifts every column after it:
FLASH<TAB>UID=F1 ← UID= appears at column 6 to a text editor,
but at column 15 to PRO/II
Leave one tab in a deck and the alignment silently drifts. The formatter
therefore expands every tab on every line before doing anything else,
using proii.format.tabSize (default 4). This applies to all sections —
COMPONENT DATA, STREAM DATA, THERMODYNAMIC DATA and UNIT OPERATIONS — and to
continuation lines, blank lines and comment lines.
Because the columns are then recomputed from scratch, alignment is correct
regardless of what the tabs were doing:
Input Output
FLASH<TAB>UID=F1 FLASH UID=F1 ← UID= at column 15
FEED<TAB>A FEED A ← A at column 15
PROD<TAB>M=B PROD M=B ← M= at column 15
There is no setting to disable this. A deck containing tabs is not a valid
PRO/II deck, so the extension will not produce one.
Editor integration
- Folding — sections, unit blocks, multi-line statements, comment banners
- Selection ranges — word → line → statement → unit → section → document
- Code lens — unit type and feed/product counts (off by default)
- Inlay hints — resolved stream descriptions inline (off by default)
- Semantic tokens — stream names, unit IDs, name descriptions
- 80-column limiter — warning plus quick fixes (truncate,
& continuation,
move to comment, $ noqa suppress)
Settings
| Setting |
Default |
Description |
proii.validation.checkFlowsheet |
true |
Disconnected flowsheets, units without feed/product |
proii.validation.checkUnconsumedProducts |
false |
Streams produced but never consumed |
proii.validation.checkMissingSources |
false |
Streams consumed but never produced |
proii.validation.checkRecycles |
false |
Recycle loops (tear streams) |
proii.inlayHints.enabled |
false |
Inline stream descriptions and unit types |
proii.codeLens.enabled |
false |
Annotations above units and stream declarations |
proii.format.valueColumn |
15 |
Column where parameter values start |
proii.format.commentColumn |
43 |
Column where trailing comments align |
proii.format.tabSize |
4 |
Spaces used when expanding tabs (always applied on save) |
proii.format.alignColumnsOnSave |
true |
Run the formatter on save |
proii.columnLimiter.enabled |
true |
80-column width limiter |
proii.columnLimiter.columnLimit |
80 |
Maximum column width |
Commands
| Command |
Description |
PRO/II: Refresh Stream Name Highlighting |
Recompute semantic tokens |
PRO/II: Toggle Column Limiter |
Enable/disable the 80-column limit |
PRO/II: Toggle Column Ruler |
Show/hide the column ruler |
PRO/II: Show Component Definition |
Jump to a component's LIBID entry |
Supported files
.inp, .std, .out, .sdf, .p2i
Note: the parser understands input-deck syntax. Results files
(.out) and output data (.sdf) will not produce meaningful diagnostics.
Architecture
proii-language-server/
├── client/ # VS Code extension (thin LSP client)
├── server/ # Language server (LSP implementation)
└── shared/ # Shared types and utilities
Server modules
| Module |
Responsibility |
lexer.ts |
Tokenizer — keywords, numbers, comments, continuations |
parser.ts |
Recursive-descent parser producing an AST |
statementScanner.ts |
Line-oriented view: sections, unit blocks, continuations |
symbolTable.ts |
Stream / unit / component symbols and references |
validator.ts |
Semantic diagnostics |
flowsheetGraph.ts |
Connectivity, recycle detection, structural issues |
formatter.ts |
Whitespace-only column alignment |
*Provider.ts |
One module per LSP feature |
The AST's endLine stops at the first non-FEED/PROD line, so anything needing
real block extents (folding, selection ranges, required-parameter checks) works
from statementScanner.ts instead.
Development
Prerequisites
- Node.js 18+
- VS Code 1.105+
Build
npm install
npm run compile
Test
cd server
npm run test:jest
306 tests across 20 suites, including a real TextMate tokenizer harness
(vscode-textmate + vscode-oniguruma) that verifies syntax highlighting
against actual source.
Package
.\build-vsix.ps1
Produces a .vsix without requiring vsce. The script ships exactly the
runtime dependency closure of client/package.json and server/package.json
and fails the build if any of those packages is missing from the staged output,
so a runtime dependency can never be dropped from the package by accident.
Install locally
code --install-extension .\proii-language-server-1.0.2.vsix --force
Reload the VS Code window afterwards. If hover or another feature appears dead,
check the extension host log first — a client-side activation failure (for
example a missing runtime module) looks identical to a broken provider:
Get-Content "$env:APPDATA\Code\logs\<session>\window1\exthost\exthost.log" |
Select-String "proii"
Debug logging
$env:PROII_LSP_DEBUG = "1"
Known limitations
READ, OUTPUT and FORMAT statements are skipped — they carry no
stream properties.
- Rename and find-references are document-scoped, not workspace-scoped.
- Workspace symbols search open documents only.
- No numeric range validation —
EFF=150 is not flagged.
UIDD= style typos are swallowed as parameters rather than reported.
Contributing
Contributions welcome. The highest-value areas are parser coverage for the
remaining STREAM DATA statements and workspace-scoped rename.
License
MIT — see LICENSE.