Feat java21 p4 lsp dap - #2
Merged
Merged
Conversation
## Main project (tinyexpression) - ExecutionBackend: add P4_AST_EVALUATOR and P4_DSL_JAVA_CODE enum entries with fromRuntimeMode() aliases (p4-ast, p4-dsl-javacode) - P4AstEvaluatorCalculator: type-safe P4 parser probe with fallback to AstEvaluatorCalculator; records _tinyP4ParserUsed / _tinyP4AstNodeType - P4DslJavaCodeCalculator: P4-parser override for DslJavaCodeCalculator - CalculatorCreatorRegistry: register p4AstEvaluatorCreator() and p4DslJavaCodeCreator(); add forBackend() switch entry - TinyExpressionDapRuntimeBridge: copy _tinyP4ParserUsed and _tinyP4AstNodeType markers in parity probe (6 backends) - CommaParser: remove invalid @OverRide on expectedDisplayText() (method not in SingleCharacterParser 2.4.0) - Test compat fixes for unlaxer-common 2.4.0: ParserTestBase (getTokenString→source), StringContentsTest, TokenTest (int→CodePointIndex) - P4BackendParityTest: 7 parity tests; all PASS ## Tools (tinyexpression-p4-lsp-vscode) - UBNF grammar: tinyexpression-p4.ubnf - pom.xml: generators=Parser,AST,Mapper,Evaluator,LSP,Launcher,DAP,DAPLauncher - TinyExpressionP4LanguageServerExt: type-safe semantic tokens via instanceof (no regex), ParseFailureDiagnostics sealed interface, TE001 enriched diagnostics, keyword/variable completion - TinyExpressionP4DebugAdapterExt: captures formula/runtimeMode in launch(); adds _tinyP4ParserUsed / _tinyP4AstNodeType / _tinyP4AstNodePath to DAP variables panel using sealed interface switch - extension.ts: LSP via -jar, DAP via -cp with DapLauncherExt main class - .gitignore + .vscodeignore: exclude node_modules/out/target/vsix - server-dist/tinyexpression-p4-lsp-server.jar: fat jar (3.7 MB) ## Docs - TINYEXPRESSION-P4-LSP-DAP-IMPL-PLAN.md: implementation plan - TINYEXPRESSION-P4-LSP-DAP-TASKS.md: task tracker (89% complete) - TINYEXPRESSION-P4-PIPELINE-GUIDE.md: beginner's guide to UBNF→ParseTree→AST→Evaluator→LSP/DAP pipeline Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…LICENSE - Remove `files` field from package.json (conflicts with .vscodeignore in vsce) - Recreate .vscodeignore excluding node_modules, target, src, grammar, pom.xml - Add README.md with features, quick-start, settings table, supported file patterns, architecture - Add LICENSE (MIT) copied from calculator-lsp-vscode - Add missing package.json fields: repository, homepage, bugs, author, publisher, activationEvents, commands contribution, filenames/filenamePatterns for default/emergency files, semanticTokenScopes, tinyExpressionP4Lsp.fileExtensions setting, package script - VSIX now includes LICENSE automatically and builds cleanly at ~3.3 MB Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gging Extension (TypeScript): - Add `showServerOutput` command handler: calls outputChannel.show() so users can inspect server logs and diagnose Java startup issues - Add startup logging: logs java path, jar path and JVM args to output channel on activate() - Add startup error notification: shows VS Code error message if client.start() rejects Java LSP server: - Add `codeActionProvider: true` to ServerCapabilities (initialize response) - Implement `codeAction()` in ExtTextDocumentService: - TE001 + starts with 'if': offer "Rewrite 'if' to P4 syntax" quick fix - TE001 + bare funcName(): offer "Add 'call' keyword" quick fix - TE001 (any): offer P4 syntax reference hint action Version: 0.1.0 → 0.1.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Root cause: vscode-languageclient and its transitive deps were not included
in the VSIX, causing `require('vscode-languageclient/node')` to fail at
load time → extension silently failed → no diagnostics, no command handler.
Fix:
- Switch `vscode:prepublish` from `tsc` to `esbuild --bundle`
- esbuild inlines vscode-languageclient + all transitive deps into out/extension.js
- Only `vscode` is kept external (provided by VS Code host)
- .vscodeignore: remove node_modules exception (no longer needed)
- Move showServerOutput registerCommand before LanguageClient setup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>Problem: files with metadata headers (tags:, description:, etc.) were
causing TE001 errors on every line because the P4 parser was trying to
parse the full file content including the metadata section.
Fix:
- Add extractFormulaSection(): scans for 'formula:' line, extracts
formula content and its line-number offset within the document
- parseDocument() now routes to parseWithFormulaSection() when the
'formula:' marker is found, passing only the formula text to the parser
- publishEnrichedDiagnostics() accepts lineOffset: shifts diagnostic
range positions so they point into the correct lines in the full document
- computeSemanticTokens() accepts lineOffset: adds offset to token lines
so semantic highlighting lands on the formula section, not line 0
- ExtDocumentState gains lineOffset field
- Plain .tinyexp files (no 'formula:' marker) continue to work as before
- Windows \r\n line endings handled via .replace('\r', '') before comparison
Test:
tags:NORMAL / formula: / 1+2 / ---END_OF_PART--- → no diagnostics
tags:NORMAL / formula: / if @@@broken / --- → TE001 at line 3 ✓
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>Motivation: real-world files mix non-formula content (metadata headers, Markdown, etc.) with TinyExpression formulas. Rather than implementing a full host-language parser, a lightweight DocumentFilter wrapper can strip the non-formula parts so the P4 parser sees only valid input. New files: - FormulaSection.java — record(content, lineOffset): the extracted slice - DocumentFilter.java — @FunctionalInterface with built-in implementations: passThrough() — parse whole document (plain .tinyexp) formulaInfo() — FormulaInfo 'formula:' / '---END_OF_PART---' format fenced(open,close)— generic fence markers (e.g. "```tinyexp" / "```") autoDetect() — formulaInfo() with null fallback (default) firstMatch(...) — try multiple filters in order Changes to TinyExpressionP4LanguageServerExt: - Add DocumentFilter field + two constructors (default: autoDetect()) - parseDocument() delegates to documentFilter.extract() instead of calling extractFormulaSection() directly - Remove inline 'record FormulaSection' (now a top-level class) Usage example (custom Launcher for Markdown files): new TinyExpressionP4LanguageServerExt( DocumentFilter.fenced("```tinyexp", "```")) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extends DocumentFilter with a new legacy() strategy that preprocesses documents containing constructs not in the P4 grammar, enabling them to validate without errors: - Fenced code blocks (```java:Foo ... ```) replaced with blank lines - Import declarations (import ...;) replaced with blank lines - External invocations (external returning as TYPE name(args)) rewritten to call name(args) with space-padding to preserve character positions autoDetect() now composes formulaInfo() + legacy() via firstMatch(), so FormulaInfo files, legacy pre-P4 files, and plain P4 files are all handled by the default filter without any server configuration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds grammar-native support for pre-P4 constructs so they are properly
validated rather than silently masked:
- ImportDeclaration: import ClassName#method as alias;
Validates FQCN, '#' separator, 'as' alias syntax
- ExternalBooleanInvocation / ExternalNumberInvocation /
ExternalStringInvocation / ExternalObjectInvocation:
external returning as <type> funcName(args)
Validates return type keyword, method name, argument syntax
Formula root rule updated: { ImportDeclaration } precedes VariableDeclaration.
DocumentFilter.legacy() now only masks fenced Java blocks (```java:... ```)
since import and external are grammar-defined. Regular lines pass through
unchanged and are validated by the P4 parser.
Keywords 'import', 'external', 'returning' added to KEYWORD_SET and
COMPLETION_KEYWORDS for semantic highlighting and completion.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>…d normalize artifactId
- Generate 106 SVG railroad diagrams from complete UBNF grammar - Create GitHub-compatible README.md with complete rule documentation - Update grammar documentation to link to new railroad diagrams - All diagrams are SVG and viewable directly in GitHub markdown Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add 'References:' section to each rule diagram - References are markdown links to related NonTerminal rules - Enables single-page navigation within README.md on GitHub Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Closed
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 freeto 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.
No description provided.