Skip to content

chore: Simplify extension#24

Closed
attitude wants to merge 2 commits into
mainfrom
chore/simplify-source
Closed

chore: Simplify extension#24
attitude wants to merge 2 commits into
mainfrom
chore/simplify-source

Conversation

@attitude
Copy link
Copy Markdown
Owner

Summary

  • providers.ts: Extracted delegateLocationProvider() helper shared by PHPXDefinitionProvider, PHPXTypeDefinitionProvider, and PHPXImplementationProvider — eliminated ~60 lines of triplicated boilerplate. Simplified mapLocationLinkToSource using a single remapUri variable instead of three mutable lets. Removed dead PHPXWorkspaceSymbolProvider class (exported but never registered in extension.ts).
  • compiler.ts: Moved stderrOverflow declaration above its handler (was declared one line after use). Added stderrOverflow to the close handler's overflow branch (previously only truncated was checked, leaving stderr-overflow kills to fall into the code !== 0 path and attempt JSON.parse on a truncated buffer). Removed dead compilationErrors map and getCompilationError() method (the map was written but never read externally). Fixed err.message || err.stack order in compileAndWrite catch — stack is now used for logging, message for the user-facing error.
  • diagnostics.ts: Removed shouldForwardDiagnostic() stub (always returned true) and its no-op .filter() call site.
  • positionMapper.ts: Removed /g flag from module-level PHP_WORD_PATTERN constant — the flag implies mutable lastIndex state, but all use sites correctly create fresh instances via new RegExp(PHP_WORD_PATTERN.source, 'g'); the constant is used only as a source holder. Fixed double-statSync on cache miss: now does statSync first, then readFileSync (one syscall saved per cold-cache file access).
  • languageClient.ts: Removed redundant ?? undefined from optional-chain expression.
  • extension.ts: Deduplicated the three identical vendorWatcher event handlers into a shared clearCompilerCache callback.

Test plan

  • TypeScript compilation passes (npm run compile — no errors)
  • Go-to-definition, type definition, and find implementation still work in .phpx files
  • stderr overflow during compilation now produces "Compilation output exceeded size limit" instead of a JSON parse error
  • No regression in diagnostics forwarding from PHP language server to .phpx files

🤖 Generated with Claude Code

@attitude
Copy link
Copy Markdown
Owner Author

Superseded by #25

@attitude attitude closed this Apr 12, 2026
@attitude attitude deleted the chore/simplify-source branch April 12, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant