Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
API docs: indexer: do not include Go blank const/var identifiers (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Gutekanst authored Jun 16, 2021
1 parent 55b2a79 commit ce30aee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 97 deletions.
6 changes: 5 additions & 1 deletion internal/indexer/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ func (d *docsIndexer) indexGenDecl(p *packages.Package, f *ast.File, node *ast.G
case *ast.ValueSpec:
// Variable or constant, potentially of the form `var x, y = 1, 2` - we emit each
// separately.
for i := range t.Names {
for i, name := range t.Names {
if name.Name == "_" {
// Not only is it not exported, it cannot be referenced outside this package at all.
continue
}
switch node.Tok {
case token.CONST:
constDocs := d.indexConstVar(p, t, i, "const", isTestFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ testdata is a small package containing sample Go source code used for testing th
- [var BigVar](#github.com-sourcegraph-lsif-go-internal-testdata---BigVar)
- [var VarBlock1](#github.com-sourcegraph-lsif-go-internal-testdata---VarBlock1)
- [var VarBlock2](#github.com-sourcegraph-lsif-go-internal-testdata---VarBlock2)
- [var _](#github.com-sourcegraph-lsif-go-internal-testdata---_)
- [var wg](#github.com-sourcegraph-lsif-go-internal-testdata---wg)
- [Types](#github.com-sourcegraph-lsif-go-internal-testdata---type)
- [type Embedded struct](#github.com-sourcegraph-lsif-go-internal-testdata---Embedded)
Expand Down Expand Up @@ -1083,101 +1082,6 @@ ZZZzz /,`.-'`' -. ;-;;,_
```
It's sleeping! Some people write that as `sleeping` but Markdown isn't allowed in Go docstrings, right? right?!

#### <a name="github.com-sourcegraph-lsif-go-internal-testdata---_">var _</a>

<details><summary>hover</summary>

> ```go
> var _ invalid type
> ```
>
> ---
>
> Yeah this is some Go magic incantation which is common.
>
> ```
> ,_ _
> |\\_,-~/
> / _ _ | ,--.
> ( @ @ ) / ,-'
> \ _T_/-._( (
> / `. \
> | _ \ |
> \ \ , / |
> || |-_\__ /
> ((_/`(____,-'
>
> ```

</details>

<details><summary>definitions</summary>

```json
[
{
"Document": "/child_symbols.go",
"Ranges": [
{
"start": {
"line": 116,
"character": 4
},
"end": {
"line": 116,
"character": 5
}
}
]
}
]
```

</details>

<details><summary>references</summary>

```json
[
{
"Document": "/child_symbols.go",
"Ranges": [
{
"start": {
"line": 116,
"character": 4
},
"end": {
"line": 116,
"character": 5
}
}
]
}
]
```

</details>

```Go
var _ = Interface(&Struct{})
```

Yeah this is some Go magic incantation which is common.

```
,_ _
|\\_,-~/
/ _ _ | ,--.
( @ @ ) / ,-'
\ _T_/-._( (
/ `. \
| _ \ |
\ \ , / |
|| |-_\__ /
((_/`(____,-'

```
#### <a name="github.com-sourcegraph-lsif-go-internal-testdata---wg">var wg</a>

<details><summary>hover</summary>
Expand Down

0 comments on commit ce30aee

Please sign in to comment.