Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not merge until that PR is.
How easy would it be to update? Assuming we don't get the other PR merged just yet, if its easy to update lets merge in and get some stuff in prod :)
// Non-standard fields. | ||
"dir": defPkg.Dir, // TODO: emit standard "file" instead? | ||
"pkg": defPkg.ImportPath, | ||
"vendor": IsVendorDir(defPkg.Dir), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these fields live in meta?
Edit: forgot to remove this comment, later commits fixed this
@@ -217,7 +217,6 @@ func (h *LangHandler) externalRefsFromPkg(ctx context.Context, bctx *build.Conte | |||
ContainerName: defContainerName, | |||
PackageName: defPkg.ImportPath, | |||
Meta: map[string]interface{}{ | |||
"dir": defPkg.Dir, // TODO: emit standard "file" instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprised you didn't need to update tests with this commit?
Edit: I see you updated in a later commit
6610dcc
to
45b2f17
Compare
according to the new specification at sourcegraph/language-server-protocol#8 - langserver: remove 'dir' from workspace/reference - It's not useful to us, and would have to be translated by the build server into a repo-relative path anyway. - simplify goRangesToLSPLocations implementation
45b2f17
to
364a072
Compare
The xreference impl has not changed much since @keegancsmith reviewed it, but the second commit / xdefinition implementation is new so I'll need to get a review on that. @keegancsmith I will ask someone else to review because I want to land this into master today, but please leave comments etc here and I will follow up tomorrow morning. |
This is useful for integration tests in the Sourcegraph core codebase.
l.Location.Range.End = l.Location.Range.Start | ||
|
||
// Determine metadata information for the node. | ||
//rootFile := pkg.Files[0] // TODO: is this correct? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(hint: it was not correct :) )
|
||
// Determine metadata information for the node. | ||
//rootFile := pkg.Files[0] // TODO: is this correct? | ||
def, err := refs.DefInfo(pkg.Pkg, &pkg.Info, pathEnclosingInterval, node.Pos()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since def
is only used within the following if-else block, a clearer way to write this would be:
if def, err := refs.DefInfo(pkg.Pkg, &pkg.Info, pathEnclosingInterval, node.Pos()); err == nil {
} else
}
@@ -189,10 +180,6 @@ func (h *LangHandler) externalRefsFromPkg(ctx context.Context, bctx *build.Conte | |||
}() | |||
span.SetTag("pkg", pkg) | |||
|
|||
pkgInWorkspace := func(path string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we now emit references to both internal and external definitions, you should change the name and docstring of this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(done)
Symbol SymbolDescriptor `json:"symbol"` | ||
} | ||
|
||
type SymbolDescriptor struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a docstring for this type and each of the fields.
// ReferenceInformation is the array response type for the `workspace/xreferences` extension | ||
// | ||
// See: https://github.com/sourcegraph/language-server-protocol/blob/master/extension-workspace-reference.md | ||
// | ||
type ReferenceInformation struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a docstring for each of these fields.
File string `json:"file,omitempty"` | ||
ContainerName string `json:"containerName,omitempty"` | ||
Vendor bool `json:"vendor,omitempty"` | ||
Meta map[string]interface{} `json:"meta,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If SymbolDescriptor
itself is "metadata", having a Meta
field inside it seems redundant. What about something like Attributes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be a spec change, too. But okay.
- Remove some useless/commented code. - Write an if-else block in a clearer way. - Cleanup documentation + wording (external -> workspace) - Add detailed docstrings for all lspext types/fields. - Rename `SymbolDescriptor.Meta` to `SymbolDescriptor.Attributes`
…parent` meta fields This give us less ambiguity.
Also see: sourcegraph/sourcegraph#2673 |
- Fix issue with `name` and `attr_parent` being reversed when `attr_parent` is present. - Remove commented-out code that was missed.
According to the new specification at sourcegraph/language-server-protocol#8
Please do not merge until that PR is.