Skip to content

Conversation

Copy link

Copilot AI commented Jan 25, 2026

Addresses code duplication feedback: send_definition_result(), send_references_result(), and send_implementation_result() shared ~300 identical lines differing only in debug logging.

Changes

  • Consolidated into single parameterized function: Created send_location_result(params, debug_name) that handles all location-based LSP responses
  • Preserved debug logging: Optional debug_name parameter enables debug output for implementation handler while keeping definition/references handlers silent
  • Reduced surface area: 168 net lines removed (201 deletions, 33 additions)

Implementation

// Generic handler for definition, references, and implementation
static void send_location_result(const char *params, const char *debug_name) {
    // Single implementation of location parsing and LSP response formatting
    // Conditional debug logging based on debug_name parameter
}

static void send_definition_result(const char *params) {
    send_location_result(params, NULL);  // No debug logging
}

static void send_implementation_result(const char *params) {
    send_location_result(params, "send_implementation_result");  // With debug logging
}

This eliminates the risk of inconsistent bug fixes and simplifies maintenance of LSP location handling.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 25, 2026 14:33
…le parameterized function

Co-authored-by: PMassicotte <4519221+PMassicotte@users.noreply.github.com>
Co-authored-by: PMassicotte <4519221+PMassicotte@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on LSP features Refactor duplicated location-based LSP response handlers Jan 25, 2026
Copilot AI requested a review from PMassicotte January 25, 2026 14:34
@PMassicotte PMassicotte marked this pull request as ready for review January 25, 2026 14:36
@PMassicotte PMassicotte merged commit 570fba8 into lsp-goto-definition Jan 25, 2026
9 checks passed
@PMassicotte PMassicotte deleted the copilot/sub-pr-482 branch January 25, 2026 14:36
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.

2 participants