Tableau Language Server Protocol (LSP) for VS Code
A VS Code extension that provides language server features for Tableau calculation expressions.
Features
- Syntax Highlighting: Highlights Tableau calculation syntax including functions, keywords, operators, and field references.
- Hover Information: Shows detailed, context-aware information when hovering over Tableau functions, fields, and keywords.
- Includes calculation header context (auto-detected from
// NAME – description lines) and unified undefined-field messages.
- Code Completion: Suggests functions, fields, and keywords as you type.
- Signature Help: Displays function signatures and parameter information when typing function calls.
- Document Symbols: Lists all functions and expressions in the current document.
- Validation: Validates Tableau expressions for syntax errors and provides diagnostics.
- Calculation Extraction: Extract and analyze calculations, datasources, and fields from Tableau workbooks (.twb/.twbx files) with advanced processing including XML cleaning, name resolution, normalization, and deduplication.
Enhanced Features
Enhanced Document Model
The document model has been significantly improved to:
- Parse Multi-line Expressions: Properly handles complex expressions that span multiple lines.
- Support Different Expression Types: Recognizes and processes IF, CASE, LOD, function calls, and field references.
- Extract Symbol Context: Understands the context in which symbols are used for better hover information and validation.
- Manage Document Lifecycle: Efficiently caches and updates document models as needed.
Context-Aware Hover Information
The hover provider now offers rich, context-aware information:
- Function Hover: Shows function signature, parameter details, return type, description, and examples.
- Field Hover: Shows field type and description.
- Keyword Hover: Shows usage context and description based on the expression type (IF, CASE, LOD).
- Operator Hover: Shows operator type and description.
- Performance Optimized: Implements caching for faster hover responses.
Improved Validation
The validation system has been enhanced to:
- Validate Multi-line Expressions: Checks syntax across complex multi-line expressions.
- Apply Expression-Specific Rules: Uses different validation rules based on expression type.
- Check Parameter Counts: Validates function calls with the correct number of parameters.
- Provide Detailed Diagnostics: Gives specific error messages for different types of issues.
Testing Framework
A comprehensive testing framework has been added:
- Hover Testing: Tests hover functionality for different symbol types.
- Document Model Testing: Tests parsing and symbol extraction.
- Validation Testing: Tests validation rules for different expression types.
- Performance Testing: Measures and compares performance metrics.
Usage
Working with Calculations
- Open a
.twbl file in VS Code.
- Write Tableau calculation expressions.
- Hover over functions, fields, or keywords to see detailed information.
- Use code completion to get suggestions as you type.
- View validation errors and warnings in the Problems panel.
- Open a
.twb or .twbx file in VS Code.
- Open the Command Palette (
Cmd+Shift+P on Mac, Ctrl+Shift+P on Windows/Linux).
- Type "Extract Calculations" and select "Tableau: Extract Calculations".
- The extracted data (datasources, fields, and calculations) will be saved to
Extracted_Calculations.twbl in your workspace root and opened automatically.
The output file includes three sections:
- Datasources: Lists all datasources in the workbook
- Fields: Lists all fields with their datatype and role
- Calculations: Shows normalized calculation formulas with uppercased keywords
For detailed information about the extraction feature, see the Extraction Guide.
Markdown fences with Tableau highlighting
Use a tableau code block to get syntax highlighting in Markdown:
// !My Calc – Description
IF [Sales] > 1000 THEN "High" ELSE "Low" END
Requirements
- Visual Studio Code 1.60.0 or higher
Extension Settings
This extension contributes the following settings:
tableau.enableFormatting: Enable/disable formatting for Tableau expressions.
tableau.enableSignatureHelp: Enable/disable signature help for Tableau functions.
Known Issues
- Complex nested expressions may not be fully validated.
- Some advanced Tableau features may not be fully supported.
Release Notes
2.0.0
- Added enhanced document model with multi-line expression support
- Implemented context-aware hover information with rich formatting
- Improved validation with expression-specific rules
- Added comprehensive testing framework
- Optimized performance with caching mechanisms
1.0.0
- Initial release with basic language server features
Debug & Reload Workflow
The extension ships with a Toolbox-style compile/reload loop. See docs/AUTO_RELOAD_DEBUGGER.md for the full breakdown, but the highlights are:
- Use the
Tableau LSP: Compile and Reload command to run the npm: compile task and restart/launch the Run Extension (VS Code) debugger (which opens the Tableau-LSP.code-workspace in the Extension Host window).
Tasks: Run Task exposes both npm: compile and a Compile and Reload Debugger helper, if you prefer sticking with VS Code tasks.
npm run watch keeps builds flowing automatically; pair it with Ctrl+Shift+F5 or the command above for ultra-fast iteration.
- CLI helpers
auto-reload.sh and auto-reload.cmd give you a terminal-friendly entry point that mirrors the VS Code task.