Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Emit reference relationships for constant aliases #225

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

varungandhi-src
Copy link
Contributor

@varungandhi-src varungandhi-src commented Oct 28, 2024

Fixes GRAPH-979.

When you have "constant aliases" of the form:

module A
   X = 10
end

module B
  Y = X
end

It would be nice to merge code navigation results for X and Y so
that when you do Find references across either of them, you see
all references for either X or Y.

Part of the logic for this lives in the Sourcegraph backend,
and that needs some fixes in terms of building an extra
inverted index etc. So with this patch, current versions of
Sourcegraph (as of Oct 28 2024) will show merged
references when doing Find references on Y (but not X).

However, this fixes the indexer side of the logic by emitting
Relationships with is_reference set, so that the backend
can utilize it.

When testing against the shopify-api-ruby repo, I get the following
additional relationships.

{
          "symbol": "scip-ruby gem shopify_api 14.6.0 ShopifyAPI#LATEST_SUPPORTED_ADMIN_VERSION.",
          "documentation": [
            "```ruby\nLATEST_SUPPORTED_ADMIN_VERSION (String)\n```"
          ],
          "relationships": [
            {
              "symbol": "scip-ruby gem shopify_api 14.6.0 ShopifyAPI#AdminVersions#LATEST_SUPPORTED_ADMIN_VERSION.",
              "isReference": true
            }
          ]
        },
        {
          "symbol": "scip-ruby gem shopify_api 14.6.0 ShopifyAPI#SUPPORTED_ADMIN_VERSIONS.",
          "documentation": [
            "```ruby\nSUPPORTED_ADMIN_VERSIONS (T::Array[String])\n```"
          ],
          "relationships": [
            {
              "symbol": "scip-ruby gem shopify_api 14.6.0 ShopifyAPI#AdminVersions#SUPPORTED_ADMIN_VERSIONS.",
              "isReference": true
            }
          ]
        }

Test plan

See included automated tests.

@varungandhi-src varungandhi-src merged commit 33dad97 into scip-ruby/master Oct 28, 2024
2 checks passed
@varungandhi-src varungandhi-src deleted the vg/constant-alias branch October 28, 2024 09:03
@varungandhi-src varungandhi-src restored the vg/constant-alias branch October 28, 2024 09:03
varungandhi-src added a commit that referenced this pull request Oct 28, 2024
When you have "constant aliases" of the form:

module A
   X = 10
end

module B
  Y = X
end

It would be nice to merge code navigation results for X and Y so
that when you do Find references across either of them, you see
all references for either X or Y.

Part of the logic for this lives in the Sourcegraph backend,
and that needs some fixes in terms of building an extra
inverted index etc. So with this patch, current versions of
Sourcegraph (as of Oct 28 2024) will show merged
references when doing Find references on Y (but not X).

However, this fixes the indexer side of the logic by emitting
Relationships with `is_reference` set, so that the backend
can utilize it.
@varungandhi-src varungandhi-src deleted the vg/constant-alias branch October 28, 2024 09:23
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