Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/index improved sync #4

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6d3b85d
Move lower level database functions to index/schema
AdamSLevy Aug 8, 2023
25a72a2
Add debug line to examine build context
AdamSLevy Aug 8, 2023
d081118
Update sqlite
AdamSLevy Aug 17, 2023
2f89dad
Update dependencies
AdamSLevy Aug 23, 2023
266c87b
Update termenv
AdamSLevy Aug 27, 2023
6bffb4a
Update progressbar
AdamSLevy Aug 27, 2023
6291646
Update all dependencies
AdamSLevy Aug 27, 2023
03d4e1c
Add ginkgo test suite for internal/index/schema
AdamSLevy Aug 29, 2023
7c34187
Fix some tests
AdamSLevy Aug 29, 2023
4e08eec
Add SelectPackagesByParts
AdamSLevy Aug 31, 2023
169cdc8
Sync auto-prune
AdamSLevy Sep 14, 2023
0390cfe
Improved sql statement errors, fix user version
AdamSLevy Sep 14, 2023
a4dd0ac
Allow sql stmt splitter to be used without exec
AdamSLevy Sep 14, 2023
8dff9d2
Clean up tests
AdamSLevy Sep 14, 2023
6cd768a
Refactor to concurrent design
AdamSLevy Sep 14, 2023
806c662
Allow calldepth offset control in dlog with Output
AdamSLevy Sep 20, 2023
acee585
Simplify sync with sync and keep cols over temp tables and triggers
AdamSLevy Sep 20, 2023
23c388b
Integrate index/schema into index
AdamSLevy Sep 20, 2023
b0d5d6d
Refactor
AdamSLevy Sep 20, 2023
faf5b4c
Merge branch 'main' into feature/index-improved-sync
AdamSLevy Oct 11, 2023
0b4ad2d
Move internal/index/schema to internal/modpkgdb
AdamSLevy Oct 11, 2023
9ac5b7a
Reorganize modpkgdb package
AdamSLevy Oct 21, 2023
933d79e
Clean up internal/modpkg/db
AdamSLevy Nov 16, 2023
9efd36b
Move sql functions to internal/sql
AdamSLevy Nov 18, 2023
ef5006e
Move all SQL to internal/modpkg/db/sql
AdamSLevy Nov 18, 2023
a069bc5
Use named args for all sql queries
AdamSLevy Nov 18, 2023
d0fda1f
Finish modpkg integration
AdamSLevy Nov 26, 2023
30f088e
Small tweaks
AdamSLevy Nov 28, 2023
a843640
Merge branch 'feature/index-sqlite' into feature/index-improved-sync
AdamSLevy Nov 3, 2024
23978f7
WIP: massive refactor
AdamSLevy Nov 3, 2024
b9917e2
Merge branch 'feature/index-sqlite' into feature/index-improved-sync
AdamSLevy Nov 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strings"
"sync"

"aslevy.com/go-doc/internal/dlog"
"golang.org/x/mod/semver"
)

Expand All @@ -41,6 +42,7 @@ var dirs Dirs
// dirsInit starts the scanning of package directories in GOROOT and GOPATH. Any
// extra paths passed to it are included in the channel.
func dirsInit(extra ...Dir) {
dlog.Printf("GOROOT: %s", buildCtx.GOROOT)
if buildCtx.GOROOT == "" {
stdout, err := exec.Command("go", "env", "GOROOT").Output()
if err != nil {
Expand Down
24 changes: 24 additions & 0 deletions dirsextra.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
package main

import (
"bytes"
"log"
"os/exec"

"aslevy.com/go-doc/internal/godoc"
)

var GOMODCACHE, GOMOD string

func init() {
stdout, err := exec.Command("go", "env", "GOROOT", "GOMODCACHE", "GOMOD").Output()
if err != nil {
if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 {
log.Fatalf("failed to determine GOROOT: 'go env GOROOT' failed:\n%s", ee.Stderr)
}
log.Fatalf("failed to determine GOROOT: $GOROOT is not set and could not run 'go env GOROOT':\n\t%s", err)
}

lines := bytes.Split(stdout, []byte("\n"))
if len(lines) < 3 {
panic("failed to parse stdout from `go env GOROOT GOMODCACHE GOMOD`\n" + string(stdout))
}
buildCtx.GOROOT = string(bytes.TrimSpace(lines[0]))
GOMODCACHE = string(bytes.TrimSpace(lines[1]))
GOMOD = string(bytes.TrimSpace(lines[2]))
}

var xdirs godoc.Dirs = dirs.PackageDirs()

func (dirs *Dirs) PackageDirs() *PackageDirs { return (*PackageDirs)(dirs) }
Expand Down
8 changes: 4 additions & 4 deletions doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"
"testing"

"aslevy.com/go-doc/internal/index"
"aslevy.com/go-doc/internal/modpkg"
)

func TestMain(m *testing.M) {
Expand All @@ -31,9 +31,9 @@ func TestMain(m *testing.M) {
panic(err)
}

os.Setenv("GODOC_FORMAT", "text") // Use the text format.
os.Setenv("GODOC_PAGER", "-") // Disable paging.
os.Setenv(index.SyncEnvVar, index.ModeOff) // Disable index.
os.Setenv("GODOC_FORMAT", "text") // Use the text format.
os.Setenv("GODOC_PAGER", "-") // Disable paging.
os.Setenv(modpkg.SyncEnvVar, modpkg.ModeOff) // Disable modpkg.

dirsInit(
Dir{importPath: "testdata", dir: testdataDir},
Expand Down
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/muesli/reflow v0.3.0
github.com/muesli/termenv v0.13.0
github.com/onsi/ginkgo/v2 v2.12.0
github.com/onsi/gomega v1.27.10
github.com/schollz/progressbar/v3 v3.13.1
github.com/stretchr/testify v1.8.1
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
Expand All @@ -19,10 +21,14 @@ require (
)

require (
github.com/aymanbagabas/go-osc52 v1.2.1 // indirect
github.com/aymanbagabas/go-osc52 v1.0.3 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
Expand All @@ -41,6 +47,8 @@ require (
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.26.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20241004144649-1aea3fae8852 // indirect
modernc.org/libc v1.61.0 // indirect
Expand Down
20 changes: 18 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ github.com/alecthomas/assert/v2 v2.2.0 h1:f6L/b7KE2bfA+9O4FL3CM/xJccDEwPVYd5fALB
github.com/alecthomas/assert/v2 v2.2.0/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/aymanbagabas/go-osc52 v1.0.3 h1:DTwqENW7X9arYimJrPeGZcV0ln14sGMt3pHZspWD+Mg=
github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4=
github.com/aymanbagabas/go-osc52 v1.2.1 h1:q2sWUyDcozPLcLabEMd+a+7Ea2DitxZVN9hTxab9L4E=
github.com/aymanbagabas/go-osc52 v1.2.1/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -19,6 +18,14 @@ github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand Down Expand Up @@ -53,6 +60,10 @@ github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdh
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI=
github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
Expand All @@ -67,6 +78,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
Expand Down Expand Up @@ -96,9 +108,13 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
57 changes: 30 additions & 27 deletions internal/completion/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const indent = " "
// using Zsh parameter expansion and avoids external dependencies like jq for
// parsing JSON.
type Match struct {
Tag Tag

Pkg string
Type string
Match string
Expand All @@ -22,16 +24,14 @@ type Match struct {
DisplayIndent bool

Describe string

Tag string
}

// String returns the string representation of the match which is the following
// format. Empty fields are omitted if shown in [brackets].
//
// [<tag>:][[<pkg>.]<type>.]<match>:<display>:<describe>
// [<tag>:][[<pkg>.]<type>.]<match>:<display>:<describe>
//
// Note: If m.Tag is TagStructFields or TagInterfaceMethods, `<type>.` is also
// Note: If m.Tag is TagStructField or TagInterfaceMethod, `<type>.` is also
// prepended to `<display>`.
func (m Match) String() string {
var match string
Expand All @@ -50,7 +50,7 @@ func (m Match) String() string {
display = indent
}
switch m.Tag {
case TagStructFields, TagInterfaceMethods:
case TagStructField, TagInterfaceMethod:
// Because of the way struct fields and interface methods are
// rendered, there is nothing which identifies their associated
// type, so we need to add the type prefix so the user can
Expand Down Expand Up @@ -124,60 +124,63 @@ func WithTag(tag Tag) MatchOption {
type Tag = string

const (
// TagPackages contains matches for packages.
TagPackages Tag = "packages"
// TagPackage contains matches for packages.
TagPackage Tag = "package"

// TagPackageDir contains matches for package directories.
TagPackageDir Tag = "package-dir"

// TagConsts contains the first const in each non-typed const group
// TagConst contains the first const in each non-typed const group
// declaration, just as go doc displays consts in the package summary.
//
// Typed const groups are shown under the types tag with the given
// type, just as go doc organizes them.
TagConsts Tag = "consts"
TagConst Tag = "const"

// TagAllConsts contains all consts, including subsequent names in
// TagConstAll contains all consts, including subsequent names in
// grouped const declarations, and typed consts.
//
// Since any const name in a const group will return the same output
// from go doc, this tag should only be checked last as a fallback.
TagAllConsts Tag = "all-consts"
TagConstAll Tag = "const-all"

// TagVars contains the first var in each non-typed var group
// TagVar contains the first var in each non-typed var group
// declaration, just as go doc displays vars in the package summary.
//
// Typed var groups are shown under the types tag with the given type,
// just as go doc organizes them.
TagVars Tag = "vars"
TagVar Tag = "var"

// TagAllVars contains all vars, including subsequent names in grouped
// TagVarAll contains all vars, including subsequent names in grouped
// var declarations, and typed vars.
//
// Since any var name in a var group will return the same output from
// go doc, this tag should only be checked last as a fallback.
TagAllVars Tag = "all-vars"
TagVarAll Tag = "var-all"

// TagFuncs contains all functions in the package, except for factory
// TagFunc contains all functions in the package, except for factory
// functions for exported types, which are listed under the types tag
// with the type they provide.
TagFuncs Tag = "funcs"
TagFunc Tag = "func"

// TagTypes contains all types with their associated var and const
// TagType contains all types with their associated var and const
// declarations and factory functions.
TagTypes Tag = "types"
TagType Tag = "type"

// TagTypeMethods contains all methods in the form "<type>.<method>".
TagTypeMethods Tag = "type-methods"
// TagTypeMethod contains all methods in the form "<type>.<method>".
TagTypeMethod Tag = "type-method"

// TagInterfaceMethods contains all interface methods in the form
// TagInterfaceMethod contains all interface methods in the form
// "<type>.<method>"
TagInterfaceMethods Tag = "interface-methods"
TagInterfaceMethod Tag = "interface-method"

// TagStructFields contains all struct fields in the form
// TagStructField contains all struct fields in the form
// "<type>.<field>"
TagStructFields Tag = "struct-fields"
TagStructField Tag = "struct-field"

// TagMethods contains all methods without the preceding "<type>."
// TagMethod contains all methods without the preceding "<type>."
//
// Usually these should only be shown after no other matches have been
// found.
TagMethods Tag = "methods"
TagMethod Tag = "method"
)
4 changes: 2 additions & 2 deletions internal/completion/pkgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c Completer) completePackageImportPaths(partial string) (matched bool) {
match,
WithDisplay(dir.ImportPath),
WithDescription(desc),
WithTag(TagPackages),
WithTag(TagPackage),
))
}
return
Expand Down Expand Up @@ -196,7 +196,7 @@ func (c Completer) completePackageFilePaths(partial string) (matched bool) {
pkgDir = "." + sep + pkgDir
}

c.suggest(NewMatch(pkgDir, WithDescription(desc), WithTag(TagPackages)))
c.suggest(NewMatch(pkgDir, WithDescription(desc), WithTag(TagPackage)))
}
return
}
Expand Down
20 changes: 10 additions & 10 deletions internal/completion/symbols.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func (c Completer) completeSymbol(pkg godoc.PackageInfo, partialSymbol string) (
values := make([]*doc.Value, 0, len(pkgDoc.Consts)+len(pkgDoc.Vars))
values = append(values, pkgDoc.Consts...)
values = append(values, pkgDoc.Vars...)
tag := TagConsts
tag := TagConst
for i, value := range values {
if i == len(pkgDoc.Consts) {
tag = TagVars
tag = TagVar
}
tag := tag
var passName bool
Expand Down Expand Up @@ -56,22 +56,22 @@ func (c Completer) completeSymbol(pkg godoc.PackageInfo, partialSymbol string) (
// their respective type.
continue
}
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, fnc.Name, fnc.Doc, fnc.Decl, false, WithTag(TagFuncs)) || matched
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, fnc.Name, fnc.Doc, fnc.Decl, false, WithTag(TagFunc)) || matched
}

// TYPES
for _, typ := range pkgDoc.Types {
// Suggest the type itself.
typSpec := pkg.FindTypeSpec(typ.Decl, typ.Name)
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, typ.Name, typ.Doc, typSpec, false, WithTag(TagTypes)) || matched
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, typ.Name, typ.Doc, typSpec, false, WithTag(TagType)) || matched

// Typed consts and vars.
values := make([]*doc.Value, 0, len(typ.Consts)+len(typ.Vars))
values = append(values, typ.Consts...)
values = append(values, typ.Vars...)
for _, value := range values {
for _, name := range value.Names {
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, name, value.Doc, value.Decl, false, WithTag(TagTypes), WithDisplayIndent(true)) || matched
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, name, value.Doc, value.Decl, false, WithTag(TagType), WithDisplayIndent(true)) || matched
// Remaining names were already suggested under
// all-consts and all-vars above.
break
Expand All @@ -80,7 +80,7 @@ func (c Completer) completeSymbol(pkg godoc.PackageInfo, partialSymbol string) (

// Constructors
for _, fnc := range typ.Funcs {
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, fnc.Name, fnc.Doc, fnc.Decl, false, WithTag(TagTypes), WithDisplayIndent(true)) || matched
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, fnc.Name, fnc.Doc, fnc.Decl, false, WithTag(TagType), WithDisplayIndent(true)) || matched
}

if !c.isExported(typ.Name) {
Expand All @@ -90,7 +90,7 @@ func (c Completer) completeSymbol(pkg godoc.PackageInfo, partialSymbol string) (

// Methods without the preceding `<type>.`
for _, method := range typ.Methods {
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, method.Name, method.Doc, method.Decl, false, WithTag(TagMethods)) || matched
matched = c.suggestIfMatchPrefix(pkg, partialSymbol, method.Name, method.Doc, method.Decl, false, WithTag(TagMethod)) || matched
}
}

Expand Down Expand Up @@ -128,7 +128,7 @@ func (c Completer) completeTypeDotMethodOrField(pkg godoc.PackageInfo, docTyp *d

// Type Methods (<type>.<method>)
for _, method := range docTyp.Methods {
matched = c.suggestIfMatchPrefix(pkg, partial, method.Name, method.Doc, method.Decl, false, withType, WithTag(TagTypeMethods)) || matched
matched = c.suggestIfMatchPrefix(pkg, partial, method.Name, method.Doc, method.Decl, false, withType, WithTag(TagTypeMethod)) || matched
}

// Interface and struct types require special handling.
Expand All @@ -141,7 +141,7 @@ func (c Completer) completeTypeDotMethodOrField(pkg godoc.PackageInfo, docTyp *d
continue
}
name := iMethod.Names[0].Name
matched = c.suggestIfMatchPrefix(pkg, partial, name, iMethod.Doc.Text(), iMethod, false, withType, WithTag(TagInterfaceMethods)) || matched
matched = c.suggestIfMatchPrefix(pkg, partial, name, iMethod.Doc.Text(), iMethod, false, withType, WithTag(TagInterfaceMethod)) || matched
}
// An interface has no fields or other methods so we are done
// with this type.
Expand All @@ -152,7 +152,7 @@ func (c Completer) completeTypeDotMethodOrField(pkg godoc.PackageInfo, docTyp *d
for _, field := range typ.Fields.List {
docs := field.Doc.Text()
for _, name := range field.Names {
matched = c.suggestIfMatchPrefix(pkg, partial, name.Name, docs, field, false, withType, WithTag(TagStructFields)) || matched
matched = c.suggestIfMatchPrefix(pkg, partial, name.Name, docs, field, false, withType, WithTag(TagStructField)) || matched
}
}
}
Expand Down
Loading