stan-language-server 0.1.0-beta.13 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -145
- package/README.md +9 -1
- package/dist/server.js +5 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,150 +5,35 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
9
|
-
|
|
10
|
-
### Summary
|
|
11
|
-
Complete Language Server Protocol implementation for Stan with all core features:
|
|
12
|
-
- **Completion**: Keywords, distributions, functions, datatypes, constraints
|
|
13
|
-
- **Hover**: Function and distribution documentation
|
|
14
|
-
- **Diagnostics**: Compiler errors and warnings
|
|
15
|
-
- **Formatting**: Stan code formatting via native compiler
|
|
16
|
-
- **Include Resolution**: Comprehensive #include handling
|
|
17
|
-
|
|
18
|
-
Current status: 109 tests passing across 14 test files with production-ready stability.
|
|
19
|
-
|
|
20
|
-
### Added - Complete Feature Set
|
|
21
|
-
- **Formatting System**: Full document formatting using Stan compiler
|
|
22
|
-
- `src/handlers/formatting.ts`: LSP protocol conversion for formatting requests
|
|
23
|
-
- `src/language/formatting/provider.ts`: Pure formatting provider using Stan compiler
|
|
24
|
-
- `src/types/formatting.ts`: Domain types for formatting context and results
|
|
25
|
-
- Comprehensive formatting tests with includes integration
|
|
26
|
-
- Support for both `.stan` and `.stanfunctions` files
|
|
27
|
-
- **Enhanced Include Resolution**: Robust #include file handling
|
|
28
|
-
- Workspace document prioritization with filesystem fallback
|
|
29
|
-
- Proper error handling for missing include files
|
|
30
|
-
- Support for relative and absolute include paths
|
|
31
|
-
- Integration with all language features (completion, hover, diagnostics, formatting)
|
|
32
|
-
|
|
33
|
-
### Changed - Architecture Refinements
|
|
34
|
-
- **Unified Compiler Integration**: Consolidated Stan compiler usage across all features
|
|
35
|
-
- `src/stanc/provider.ts`: Unified provider interface for compilation tasks
|
|
36
|
-
- Consistent compilation handling for diagnostics and formatting
|
|
37
|
-
- Improved error handling and type safety for compiler results
|
|
38
|
-
- **Enhanced Handler System**: All LSP features follow consistent patterns
|
|
39
|
-
- `src/handlers/completion.ts`: Completion provider to LSP conversion
|
|
40
|
-
- `src/handlers/hover.ts`: Hover provider to LSP conversion
|
|
41
|
-
- `src/handlers/diagnostics.ts`: Diagnostic provider to LSP conversion
|
|
42
|
-
- `src/handlers/formatting.ts`: Formatting provider to LSP conversion
|
|
43
|
-
- `src/handlers/compilation/`: Dedicated compilation utilities
|
|
44
|
-
|
|
45
|
-
### Fixed - Production Stability
|
|
46
|
-
- **Include Resolution**: Fixed filesystem fallback when workspace documents unavailable
|
|
47
|
-
- **Test Isolation**: Enhanced test cleanup preventing cross-test interference
|
|
48
|
-
- **Type Safety**: Improved TypeScript strict mode compliance across all modules
|
|
49
|
-
- **Error Handling**: Robust error handling for edge cases in all language features
|
|
50
|
-
- All 109 tests passing with comprehensive coverage of core functionality
|
|
51
|
-
|
|
52
|
-
### Technical Improvements - Production Quality
|
|
53
|
-
- **Clean Architecture**: Complete separation of language logic from LSP protocol
|
|
54
|
-
- **Type Safety**: Comprehensive TypeScript types for all domain objects
|
|
55
|
-
- **Testability**: Pure functions with no external dependencies in language layer
|
|
56
|
-
- **Maintainability**: Clear module boundaries and single responsibility principle
|
|
57
|
-
- **Performance**: Efficient include resolution with workspace/filesystem caching
|
|
58
|
-
- **Consistency**: All features follow identical architectural patterns
|
|
59
|
-
- **Documentation**: Comprehensive inline documentation and type definitions
|
|
60
|
-
|
|
61
|
-
## [v0.5.0] - Compilation Handler Refactoring
|
|
62
|
-
|
|
63
|
-
### Changed
|
|
64
|
-
- **BREAKING**: Refactored compilation architecture to improve modularity and maintainability
|
|
65
|
-
- Replaced direct `compile()` usage with `handleCompilation()` throughout codebase
|
|
66
|
-
- Moved compilation logic from scattered locations into dedicated handlers
|
|
67
|
-
- Centralized include file resolution and compilation handling
|
|
68
|
-
- Improved integration between compilation and include resolution systems
|
|
69
|
-
|
|
70
|
-
### Added
|
|
71
|
-
- New compilation handler system in `src/handlers/compilation/`:
|
|
72
|
-
- `src/handlers/compilation/compilation.ts`: Main compilation handler with `handleCompilation()` function
|
|
73
|
-
- `src/handlers/compilation/includes.ts`: Dedicated include file resolution handler
|
|
74
|
-
- Proper TypeScript types for Stan compiler integration (`StancReturn`, `StancSuccess`, `StancFailure`)
|
|
75
|
-
- Enhanced compilation workflow:
|
|
76
|
-
- Integrated include file resolution directly into compilation process
|
|
77
|
-
- Configurable Stan compiler arguments and options
|
|
78
|
-
- Support for both `.stan` and `.stanfunctions` file types
|
|
79
|
-
|
|
80
|
-
### Technical Improvements
|
|
81
|
-
- **Modularity**: Compilation logic properly encapsulated in dedicated handlers
|
|
82
|
-
- **Maintainability**: Clear separation between compilation, includes, and diagnostics
|
|
83
|
-
- **Consistency**: All features now follow same handler-based architectural pattern
|
|
84
|
-
- **Type Safety**: Better TypeScript integration with Stan compiler results
|
|
85
|
-
- **Code Quality**: Eliminated duplicate compilation logic across codebase
|
|
86
|
-
|
|
87
|
-
## [v0.4.0] - Diagnostic System Implementation
|
|
88
|
-
|
|
89
|
-
### Added
|
|
90
|
-
- New diagnostic system architecture following completion handler pattern:
|
|
91
|
-
- `src/types/common.ts`: Shared `Position` interface used by both completion and diagnostics
|
|
92
|
-
- `src/types/diagnostics.ts`: Domain types (`Range`, `DiagnosticSeverity`, `StanDiagnostic`)
|
|
93
|
-
- `src/language/diagnostics/provider.ts`: Pure diagnostic provider returning domain types
|
|
94
|
-
- `src/language/diagnostics/linter.ts`: Message processing utilities
|
|
95
|
-
- `src/language/diagnostics/index.ts`: Barrel exports for diagnostic functionality
|
|
96
|
-
- `src/handlers/diagnostics.ts`: LSP protocol conversion layer for diagnostics
|
|
97
|
-
- Server capabilities now include `diagnosticProvider` for LSP compliance
|
|
98
|
-
|
|
99
|
-
### Changed
|
|
100
|
-
- **BREAKING**: Refactored diagnostic architecture to implement LSP-compliant diagnostics
|
|
101
|
-
- Removed automatic validation on document content changes (performance improvement)
|
|
102
|
-
- Implemented proper `textDocument/diagnostic` request handler following LSP specification
|
|
103
|
-
- Language diagnostic functions now return domain types (`StanDiagnostic[]`) instead of LSP types
|
|
104
|
-
- Eliminated LSP dependencies from language layer diagnostic code
|
|
105
|
-
|
|
106
|
-
### Technical Improvements
|
|
107
|
-
- **Performance**: Diagnostics no longer run on every keystroke, only when explicitly requested
|
|
108
|
-
- **LSP Compliance**: Proper `textDocument/diagnostic` request handling instead of automatic publishing
|
|
109
|
-
- **Resource Efficiency**: Significantly reduced CPU usage during active editing
|
|
110
|
-
- **Clean Architecture**: Complete separation between diagnostic domain logic and LSP protocol
|
|
111
|
-
|
|
112
|
-
## [v0.3.0] - Hover System Implementation
|
|
113
|
-
|
|
114
|
-
### Added
|
|
115
|
-
- Pure hover providers in `src/language/hover/`:
|
|
116
|
-
- `provider.ts`: Main hover provider that coordinates function and distribution hover
|
|
117
|
-
- `functions.ts`: Function name extraction from call contexts
|
|
118
|
-
- `distributions.ts`: Distribution function mapping from sampling contexts
|
|
119
|
-
- `util.ts`: Text parsing utilities
|
|
120
|
-
- `src/handlers/hover.ts`: LSP protocol conversion for hover responses
|
|
121
|
-
|
|
122
|
-
### Changed
|
|
123
|
-
- **BREAKING**: Refactored hover functionality following same pattern as completion
|
|
124
|
-
- Separated function hover and distribution hover logic
|
|
125
|
-
- Created shared utilities for text parsing and word boundary detection
|
|
126
|
-
|
|
127
|
-
## [v0.2.0] - Completion System Refactoring
|
|
128
|
-
|
|
129
|
-
### Changed
|
|
130
|
-
- **BREAKING**: Refactored completion providers to return domain types (`Keyword[]`, `Distribution[]`, etc.)
|
|
131
|
-
- Created handlers layer for LSP protocol conversion
|
|
132
|
-
- Established clean dependency flow: `server.ts` → `handlers` → `language/providers`
|
|
133
|
-
- Removed LSP dependencies from `src/language` modules
|
|
134
|
-
|
|
135
|
-
### Added
|
|
136
|
-
- New completion handler system in `src/handlers/`:
|
|
137
|
-
- `src/handlers/completion.ts`: Converts provider results to LSP `CompletionItem[]`
|
|
138
|
-
- `src/handlers/index.ts`: Barrel export for all handlers
|
|
139
|
-
- Common completion utilities in `src/language/completion/util.ts`
|
|
140
|
-
- Comprehensive test suite for completion utilities
|
|
141
|
-
|
|
142
|
-
### Technical Improvements
|
|
143
|
-
- **Type Safety**: Leverages existing types from `src/types/completion.ts`
|
|
144
|
-
- **Testability**: Pure functions that don't depend on LSP infrastructure
|
|
145
|
-
- **Maintainability**: Clear boundaries and single responsibility principle
|
|
146
|
-
|
|
147
|
-
## [v0.1.0] - Initial Implementation
|
|
8
|
+
## [0.1.0] - 2025-09-13
|
|
148
9
|
|
|
149
10
|
### Added
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
-
|
|
154
|
-
-
|
|
11
|
+
- **Language Server Protocol support** for Stan probabilistic programming language
|
|
12
|
+
- **Code Completion** for Stan syntax elements:
|
|
13
|
+
- Keywords (`data`, `parameters`, `model`, `generated quantities`, etc.)
|
|
14
|
+
- Built-in functions (`normal`, `bernoulli`, `exp`, `log`, etc.)
|
|
15
|
+
- Distribution functions with proper sampling syntax
|
|
16
|
+
- Data types (`int`, `real`, `vector`, `matrix`, etc.)
|
|
17
|
+
- Constraints (`lower`, `upper`, `simplex`, etc.)
|
|
18
|
+
- **Hover Information** with documentation for:
|
|
19
|
+
- Stan built-in functions
|
|
20
|
+
- Distribution functions with parameter details
|
|
21
|
+
- **Real-time Diagnostics** powered by Stan compiler:
|
|
22
|
+
- Syntax errors and warnings
|
|
23
|
+
- Type checking and semantic analysis
|
|
24
|
+
- Compilation errors with line-precise locations
|
|
25
|
+
- **Code Formatting** using native Stan compiler
|
|
26
|
+
- Consistent indentation and spacing
|
|
27
|
+
- Preservation of comments and structure
|
|
28
|
+
- **Include File Resolution** for modular Stan programs:
|
|
29
|
+
- Support for `#include` directives
|
|
30
|
+
- Workspace-aware file resolution
|
|
31
|
+
- Cross-file compilation and analysis
|
|
32
|
+
|
|
33
|
+
### Technical Features
|
|
34
|
+
- Built with TypeScript and Bun runtime
|
|
35
|
+
- Comprehensive test suite (109 tests across 14 test files)
|
|
36
|
+
- Clean architecture separating language logic from LSP protocol
|
|
37
|
+
- Support for both `.stan` and `.stanfunctions` files
|
|
38
|
+
- Incremental document synchronization for performance
|
|
39
|
+
- Robust error handling and graceful degradation
|
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# stan-language-server
|
|
2
2
|
|
|
3
|
-
A language server for the Stan probabilistic programming language written in TypeScript and using Bun to build an executable binary.
|
|
3
|
+
A language server for the Stan probabilistic programming language written in TypeScript and using Bun to build an executable binary.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Auto-completion**: Keywords, functions, distributions, data types, and constraints
|
|
8
|
+
- **Hover information**: Documentation and type information
|
|
9
|
+
- **Diagnostics**: Real-time syntax and semantic error detection
|
|
10
|
+
- **Code formatting**: Using the official Stan compiler
|
|
11
|
+
- **Include file support**: Full `#include` resolution and compilation
|
|
4
12
|
|
|
5
13
|
To install dependencies:
|
|
6
14
|
|
package/dist/server.js
CHANGED
|
@@ -89681,7 +89681,7 @@ async function getFormattingErrors(params, documents, workspaceFolders, logger)
|
|
|
89681
89681
|
return result.errors || [];
|
|
89682
89682
|
}
|
|
89683
89683
|
// src/lib.ts
|
|
89684
|
-
var
|
|
89684
|
+
var startLanguageServer = (connection) => {
|
|
89685
89685
|
connection.onInitialize((_params) => {
|
|
89686
89686
|
connection.console.info("Initializing Stan language server...");
|
|
89687
89687
|
return {
|
|
@@ -89726,12 +89726,12 @@ var setUpLanguageServer = (connection) => {
|
|
|
89726
89726
|
const folders = await connection.workspace.getWorkspaceFolders() || [];
|
|
89727
89727
|
try {
|
|
89728
89728
|
return await handleFormatting(params, documents, folders, connection.console);
|
|
89729
|
-
} catch (
|
|
89729
|
+
} catch (_error) {
|
|
89730
89730
|
const errors = await getFormattingErrors(params, documents, folders, connection.console);
|
|
89731
89731
|
if (errors.length > 0) {
|
|
89732
89732
|
connection.console.error("Formatting error:");
|
|
89733
|
-
for (const
|
|
89734
|
-
connection.console.error(
|
|
89733
|
+
for (const error of errors) {
|
|
89734
|
+
connection.console.error(error);
|
|
89735
89735
|
}
|
|
89736
89736
|
}
|
|
89737
89737
|
return [];
|
|
@@ -89747,7 +89747,7 @@ var setUpLanguageServer = (connection) => {
|
|
|
89747
89747
|
documents.listen(connection);
|
|
89748
89748
|
connection.listen();
|
|
89749
89749
|
};
|
|
89750
|
-
var lib_default =
|
|
89750
|
+
var lib_default = startLanguageServer;
|
|
89751
89751
|
|
|
89752
89752
|
// src/server.ts
|
|
89753
89753
|
var connection = import_node2.createConnection(process.stdin, process.stdout);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stan-language-server",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Language Server Protocol implementation for the Stan probabilistic programming language",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"module": "src/server.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"stan-language-server": "
|
|
9
|
+
"stan-language-server": "dist/server.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/**/*",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/bun": "latest",
|
|
57
|
-
"@types/node": "24.
|
|
57
|
+
"@types/node": "24.4.0",
|
|
58
58
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
59
59
|
"@typescript-eslint/parser": "^8.0.0",
|
|
60
60
|
"eslint": "^9.0.0",
|