Skip to content

Avoid duplicate reference when using synthetic .apply() constructor #564

@olafurpg

Description

@olafurpg
Contributor

To reproduce https://sourcegraph.com/github.com/sourcegraph/scip-java/-/blob/tests/minimized-scala/src/main/scala/minimized/Issue403.scala?L3:12-3:20#tab=references

Observe that there's a reference with no highlighted range

CleanShot 2023-04-24 at 18 14 33@2x

This range is from the synthetic .apply() constructor. We should extend scip-java to ensure that we only emit a single usage in this situation (which is a very common situation). I'm leaning towards making the occurrence always go to the case class constructor since I almost never want to navigate to the companion object in cases like these.

I propose we fix this issue by consolidating the following two occurrences into a single occurrence to the apply() symbol

https://github.com/sourcegraph/scip-java/blob/main/tests/snapshots/src/main/generated/tests/minimized-scala/src/main/scala/minimized/Issue403.scala#L64-L65

One way to implement this fix is to extend the code path where we generate occurrences for synthetics https://github.com/sourcegraph/scip-java/blob/main/scip-semanticdb/src/main/java/com/sourcegraph/scip_semanticdb/ScipTextDocument.java#L71

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @olafurpg@varungandhi-src

        Issue actions

          Avoid duplicate reference when using synthetic `.apply()` constructor · Issue #564 · sourcegraph/scip-java