chore: extract flag parsing into declarative module#17
Open
lmn451 wants to merge 26 commits into
Open
Conversation
Updates: - css-tree: 3.1.0 → 3.2.1 (bug fixes, new parse options) - node-html-parser: 7.0.1 → 7.1.0 (new parsing options) - @types/node: 24.10.1 → 24.12.0 (type updates) - vscode-languageserver-textdocument: 1.0.11 → 1.0.12 - vscode-uri: 3.0.8 → 3.1.0
- Move all flag definitions to a single declarative registry in src/flags.ts - Supports flag types: bool, optIn, enum, pathDisplay, list, int - Simplifies adding new flags to 3 steps (add to interface, add to FLAGS, add to return) - Preserve all existing CLI and env var behavior - Add --no-color-replacement-diagnostics flag for Firefox extension
- Add CSS_LSP_COLOR_REPLACEMENT_DIAGNOSTICS=0 env var - Update parseBool to handle "0" for disabling via env - Document env var in README
- Add try-catch blocks to color replacement functions to prevent LSP crashes - Implement color index (Map<string, Set<string>>) for O(1) color lookups - Replace O(n*m) iteration with direct HashMap lookup in getVariablesByColor() - Mark index dirty when variables change, rebuild lazily on first access Performance: Color lookup now scales with number of matches (O(k)) instead of total variables (O(n*m)).
Replace O(n) linear search with O(k) line-bucketed lookup in findColorLiteralAtPosition, where k = colors on target line. Changes: - colorLiterals now uses Map<uri, Map<line, CssColorLiteral[]>> - Added getDocumentColorLiteralsByLine() method - getDocumentColorLiterals() flattens for backward compatibility - findColorLiteralAtPosition uses bucketed lookup
Move Logger interface and createLogger factory from cssVariableManager.ts to dedicated src/logger.ts module for better separation of concerns.
CssVariableManager now requires a Logger argument. Update all test files to import Logger and pass SilentLogger instance.
Update server.ts to use the new Logger interface instead of connection.console. Pass logger to colorVariableFeature functions.
- Extract SilentLogger to shared test helper (tests/helpers/silentLogger.ts) - Update 16 test files to use shared SilentLogger instead of duplicates - Add comprehensive tests for logger module (10 tests) - Add tsconfig.tsbuildinfo to .gitignore - Remove untracked files (ISSUE_TEMPLATE, run-lsp.sh)
Remove dead guard code since the parameter is always provided by callers
- Fix matchesContext() to properly check selector types instead of using substring matching - Add timeout cleanup in onDidClose to prevent memory leak - Update test files to assert correct behavior
…locks The valueRange property was incorrectly calculated when parsing CSS variables in HTML <style> blocks. For complex values (rgb(), hsl(), etc.), the code was adding an offset to css-tree positions, then using those sums to index into the CSS text - causing out-of-bounds substring access. Fix: use css-tree positions directly for substring extraction, but add offset only for document.positionAt() to get absolute positions. Added test case for HTML style blocks to prevent regression.
Use --stdio flag to force stdio transport. Without the flag, the library auto-detects transport from argv (--node-ipc for VS Code extension, --socket, --pipe for other clients). This keeps both CLI and VS Code extension working correctly.
- Remove unused htmlText field from DOMTree class - Rename unused document param to _document in createColorReplacementCompletionItem - Remove dead parseInt function from flags.ts (never called) - Add eslint-disable comments for deprecated rootUri/rootPath usage - Remove deprecated fields from debug logging in onInitialize - Export isPositionOnDefinition helper and add tests
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 free
to 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.
Summary
src/flags.tswith declarative registry--no-color-replacement-diagnosticsflag for Firefox extensionChanges
src/flags.ts- New declarative flag registrysrc/runtimeConfig.ts- Simplified to re-export from flags.tsREADME.md- Document new flagpackage.json- Version bump to 1.0.19Testing
All 182 tests pass.