-
Notifications
You must be signed in to change notification settings - Fork 20
bug: no J2D or find-refs of switch-case blocks over an object's type #117
Comments
Looking into this found some curious comments that are influencing this data to be missing in the graph: type types.Info struct {
// Defs maps identifiers to the objects they define (including
// package names, dots "." of dot-imports, and blank "_" identifiers).
// For identifiers that do not denote objects (e.g., the package name
// in package clauses, or symbolic variables t in t := x.(type) of
// type switch headers), the corresponding objects are nil.
//
// For an embedded field, Defs returns the field *Var it defines.
//
// Invariant: Defs[id] == nil || Defs[id].Pos() == id.Pos()
Defs map[*ast.Ident]Object
// Implicits maps nodes to their implicitly declared objects, if any.
// The following node and object types may appear:
//
// node declared object
//
// *ast.ImportSpec *PkgName for imports without renames
// *ast.CaseClause type-specific *Var for each type switch case clause (incl. default)
// *ast.Field anonymous parameter *Var (incl. unnamed results)
//
Implicits map[ast.Node]Object
} |
I'm pretty sure at this point I've followed your exact steps up to https://github.com/sourcegraph/lsif-go/compare/garo/index-specific-files#diff-1913594ad09438ab1869eafef027bcd6R311 🤦 I basically made all the same changes as in your branch. Well at least I learned a lot! |
To confirm, your understanding, @gbrik , the following code has the following (relevant portion) LSIF graph. package main
func main() {
var v interface{} = 3
switch e := v.(type) {
case int:
e++
case bool:
if e {
// TODO
}
default:
}
} Definitions and references are well-formed (all point to the top I think the only issue here is that the hover text for To explain how the worker would handle this: definition result id, reference result id, and hover result ids attached to a range will be the first reachable one (attached directly, or attached to a depth-1 result set, or attached to a depth-2 result set, etc). Every moniker reachable for a range belongs to that range (attached to the range, an attached result set, or another attached moniker). |
@efritz ohh, i didn't notice the everything you wrote SGTM, think we're on the same page. re the worker, so if e.g. multiple reference results are attached at different depths, only the shallowest will actually end up attached? specifically I'm wondering if the worker has logic for, say, range1 points to refResult1, range2 points to refResult2, range3 points to both, will it create a new merged refResult on the fly? |
New to me until 2 hours ago too!
Ranges and result set properties get "flattened" as part of canonicalization. While a range doesn't have a non-zero valued property, it will try to find one by depth as it walks the graph. After all these are flattened into the ranges we can get rid fo the concept of result sets and next edges. |
Attempted to fix this in #122. It works much better but there's a TODO note we need to figure out how to solve (missing hover text for the definition of the symbolic variable in the type switch header itself). |
Code like the following:
does not get indexed properly because when processing definitions, the definition for
v
has anil
associated def object, since there's a different def object for the v in each branch. Then when we encounter each use ofv
, there is an associated def object but since it's not indexed in our definitions we only output a hover result.Discussion:
nil
during the definitions pass, that would likely be the right way to solve.Therefore the resulting LSIF structure should be:
Thoughts?
Also how does the worker process this graph?
The text was updated successfully, but these errors were encountered: