Skip to content

lsif-typed: symbol reference occurrence owning scope

Administrator requested to merge nsc/lsif-typed-scope into main

Created by: Strum355

Motivation and Approach

Call-hierarchy has been a long (but somewhat lesser) requested code-intelligence feature (see: https://github.com/sourcegraph/sourcegraph/issues/2881 and https://github.com/sourcegraph/sourcegraph/issues/2882). This is a feature most prevalent in IntelliJ n co, but is also finding its way through various Language Servers (slowly but surely). It is not currently in the LSIF spec, and this PR will only tackle its addition into LSIF Typed :smugcat:

This PR attempts to plug the gap by introducing a new field to the Occurrence type, preliminarily called owner, of type string (denoting a Symbol but alas protobuf doesn't have type aliases 😢). This field would contain the Symbol value of the most logical/intuitive next higher-scoped Symbol. For example:

package com.sourcegraph.lsif-kotlin

fun banana() {
 // ^^^^^^ maven ... com/sourcegraph/lsif-kotlin/File#banana()
	sundae()
 // ^^^^^^ ... com/sourcegraph/lsif-kotlin/File#sundae()
 // This occurrence would have the `owner` field as `maven ... com/sourcegraph/lsif-kotlin/File#banana()`
}

fun sundae() { ... }

From a database schema and backend implementation perspective, it would likely be almost identical to the way the existing Find References capability is serviced by LSIF typed , for both local and cross-repo intelligence..

Call Hierarchy Examples

IntelliJ

image

Visual Studio Code

image

BNF Grammar highlighting

Screenshot

Before:

image

After:

image

Test plan

N/A docs addition

Merge request reports

Loading