From a52b4d34c2abd6477ef34fff0211add17d36cbcc Mon Sep 17 00:00:00 2001 From: jupblb Date: Thu, 9 Apr 2026 17:40:21 +0200 Subject: [PATCH 1/7] Emit implementation relationships for remote type -> local interface Enable findImplementations for remote types against local interfaces, emitting the resulting SymbolInformation entries as external symbols in the SCIP index. This allows the backend to discover when dependency types implement interfaces defined in the indexed project. Fixes https://github.com/sourcegraph/scip-go/issues/64 --- internal/implementations/implementations.go | 25 ++++++++++++++------- internal/index/scip.go | 20 ++++++++++++++--- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/internal/implementations/implementations.go b/internal/implementations/implementations.go index 177ede2..675465d 100644 --- a/internal/implementations/implementations.go +++ b/internal/implementations/implementations.go @@ -108,8 +108,9 @@ func AddImplementationRelationships( pkgs loader.PackageLookup, allPackages loader.PackageLookup, symbols *lookup.Global, -) error { - return output.WithProgress("Indexing Implementations", func() error { +) ([]*scip.SymbolInformation, error) { + var externalSymbols []*scip.SymbolInformation + err := output.WithProgress("Indexing Implementations", func() error { localInterfaces, localTypes, err := extractInterfacesAndConcreteTypes(pkgs, symbols) if err != nil { return err @@ -123,7 +124,8 @@ func AddImplementationRelationships( remotePackages[pkgID] = pkg } - remoteInterfaces, _, err := extractInterfacesAndConcreteTypes(remotePackages, symbols) + remoteInterfaces, remoteTypes, err := extractInterfacesAndConcreteTypes( + remotePackages, symbols) if err != nil { return err } @@ -134,15 +136,22 @@ func AddImplementationRelationships( // local type -> remote interface findImplementations(localTypes, remoteInterfaces, symbols) - // TODO(author: tjdevries, issue: https://github.com/sourcegraph/scip-go/issues/64) - // We should consider what this would even look like? - // I don't think this makes sense the current way that we are emitting - // implementations. You wouldn't even catch these anyways when uploading // remote type -> local interface - // findImplementations(remoteTypes, localInterfaces, symbols) + // We emit these as external symbols so index consumer can merge them. + findImplementations(remoteTypes, localInterfaces, symbols) + + // Collect remote type symbols that gained relationships + for _, typ := range remoteTypes { + if sym, ok := symbols.GetSymbolInformation(typ.Pkg, typ.Ident.Pos()); ok { + if len(sym.Relationships) > 0 { + externalSymbols = append(externalSymbols, sym) + } + } + } return nil }) + return externalSymbols, err } func implementationsForType(ty ImplDef, tyMethods *intsets.Sparse, interfaceToMethodSet map[*scip.SymbolInformation]*intsets.Sparse) (matching []*scip.SymbolInformation) { diff --git a/internal/index/scip.go b/internal/index/scip.go index 3ad22b8..3cec2ee 100644 --- a/internal/index/scip.go +++ b/internal/index/scip.go @@ -98,13 +98,16 @@ func Index(writer func(proto.Message) error, opts config.IndexOpts) error { return err } + var externalSymbols []*scip.SymbolInformation pathToDocument, globalSymbols := indexVisitPackages(opts, projectPackages, allPackages) if !opts.SkipImplementations { - if err := impls.AddImplementationRelationships( + implSymbols, err := impls.AddImplementationRelationships( projectPackages, allPackages, globalSymbols, - ); err != nil { + ) + if err != nil { return err } + externalSymbols = implSymbols } pkgIDs := slices.Sorted(maps.Keys(projectPackages)) @@ -156,7 +159,18 @@ func Index(writer func(proto.Message) error, opts config.IndexOpts) error { output.WithProgressParallel(&wg, "Visiting Project Files", &count, uint64(pkgLen)) - return writeErr + if writeErr != nil { + return writeErr + } + + // Emit external symbols for remote types that implement local interfaces + for _, sym := range externalSymbols { + if err := writer(sym); err != nil { + return err + } + } + + return nil } func indexVisitPackages( From 6a50ae3d47b85d9db589ff88decf4566da7f81b3 Mon Sep 17 00:00:00 2001 From: jupblb Date: Thu, 9 Apr 2026 17:56:08 +0200 Subject: [PATCH 2/7] Add pr198 snapshot test for remote type -> local interface implementations --- .../testdata/snapshots/input/pr198/dep/dep.go | 9 +++ .../testdata/snapshots/input/pr198/dep/go.mod | 3 + .../testdata/snapshots/input/pr198/go.mod | 7 +++ .../testdata/snapshots/input/pr198/pr198.go | 17 +++++ .../testdata/snapshots/output/pr198/pr198.go | 62 +++++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 internal/testdata/snapshots/input/pr198/dep/dep.go create mode 100644 internal/testdata/snapshots/input/pr198/dep/go.mod create mode 100644 internal/testdata/snapshots/input/pr198/go.mod create mode 100644 internal/testdata/snapshots/input/pr198/pr198.go create mode 100755 internal/testdata/snapshots/output/pr198/pr198.go diff --git a/internal/testdata/snapshots/input/pr198/dep/dep.go b/internal/testdata/snapshots/input/pr198/dep/dep.go new file mode 100644 index 0000000..dd10380 --- /dev/null +++ b/internal/testdata/snapshots/input/pr198/dep/dep.go @@ -0,0 +1,9 @@ +package dep + +import "fmt" + +type T struct{} + +func (t *T) Bar() { + fmt.Println("Bar") +} diff --git a/internal/testdata/snapshots/input/pr198/dep/go.mod b/internal/testdata/snapshots/input/pr198/dep/go.mod new file mode 100644 index 0000000..e3a155c --- /dev/null +++ b/internal/testdata/snapshots/input/pr198/dep/go.mod @@ -0,0 +1,3 @@ +module github.com/example/dep + +go 1.22 diff --git a/internal/testdata/snapshots/input/pr198/go.mod b/internal/testdata/snapshots/input/pr198/go.mod new file mode 100644 index 0000000..1697c0d --- /dev/null +++ b/internal/testdata/snapshots/input/pr198/go.mod @@ -0,0 +1,7 @@ +module sg/pr198 + +go 1.22 + +require github.com/example/dep v0.0.0 + +replace github.com/example/dep => ./dep diff --git a/internal/testdata/snapshots/input/pr198/pr198.go b/internal/testdata/snapshots/input/pr198/pr198.go new file mode 100644 index 0000000..013f844 --- /dev/null +++ b/internal/testdata/snapshots/input/pr198/pr198.go @@ -0,0 +1,17 @@ +package pr198 + +import "github.com/example/dep" + +// Foo is an interface defined downstream of the type that implements it. +// The dep.T type (from a dependency) implements Foo, and scip-go should +// emit an external symbol for dep.T with an IsImplementation relationship +// pointing to Foo. +type Foo interface { + Bar() +} + +func UseFoo(f Foo) {} + +func Example() { + UseFoo(&dep.T{}) +} diff --git a/internal/testdata/snapshots/output/pr198/pr198.go b/internal/testdata/snapshots/output/pr198/pr198.go new file mode 100755 index 0000000..2cd9191 --- /dev/null +++ b/internal/testdata/snapshots/output/pr198/pr198.go @@ -0,0 +1,62 @@ + package pr198 +// ^^^^^ definition 0.1.test `sg/pr198`/ +// documentation +// > package pr198 + + import "github.com/example/dep" +// ^^^^^^^^^^^^^^^^^^^^^^ reference github.com/example/dep 0.1.test `github.com/example/dep`/ + + // Foo is an interface defined downstream of the type that implements it. + // The dep.T type (from a dependency) implements Foo, and scip-go should + // emit an external symbol for dep.T with an IsImplementation relationship + // pointing to Foo. + type Foo interface { +// ^^^ definition 0.1.test `sg/pr198`/Foo# +// documentation +// > ```go +// > type Foo interface +// > ``` +// documentation +// > Foo is an interface defined downstream of the type that implements it. +// > The dep.T type (from a dependency) implements Foo, and scip-go should +// > emit an external symbol for dep.T with an IsImplementation relationship +// > pointing to Foo. +// documentation +// > ```go +// > interface { +// > Bar() +// > } +// > ``` + Bar() +// ^^^ definition 0.1.test `sg/pr198`/Foo#Bar. +// documentation +// > ```go +// > func (Foo).Bar() +// > ``` + } + +//⌄ enclosing_range_start 0.1.test `sg/pr198`/UseFoo(). + func UseFoo(f Foo) {} +// ^^^^^^ definition 0.1.test `sg/pr198`/UseFoo(). +// documentation +// > ```go +// > func UseFoo(f Foo) +// > ``` +// ^ definition local 0 +// ^^^ reference 0.1.test `sg/pr198`/Foo# +// ⌃ enclosing_range_end 0.1.test `sg/pr198`/UseFoo(). + +//⌄ enclosing_range_start 0.1.test `sg/pr198`/Example(). + func Example() { +// ^^^^^^^ definition 0.1.test `sg/pr198`/Example(). +// documentation +// > ```go +// > func Example() +// > ``` + UseFoo(&dep.T{}) +// ^^^^^^ reference 0.1.test `sg/pr198`/UseFoo(). +// ^^^ reference github.com/example/dep 0.1.test `github.com/example/dep`/ +// ^ reference github.com/example/dep 0.1.test `github.com/example/dep`/T# + } +//⌃ enclosing_range_end 0.1.test `sg/pr198`/Example(). + From 33f03620b6210f979e87e5321beb1fe9bd898093 Mon Sep 17 00:00:00 2001 From: jupblb Date: Thu, 9 Apr 2026 21:23:11 +0200 Subject: [PATCH 3/7] Render external symbols in snapshot tests Add formatExternalSymbols to scip_test.go that emits an external_symbols.txt file when the index contains external symbols. This makes the remote type -> local interface relationships visible and verifiable in snapshot output. --- internal/index/scip_test.go | 55 +++++ .../testdata/snapshots/input/pr198/go.mod | 2 +- .../output/pr198/external_symbols.txt | 2 + .../output/testdata/external_symbols.txt | 203 ++++++++++++++++++ 4 files changed, 261 insertions(+), 1 deletion(-) create mode 100755 internal/testdata/snapshots/output/pr198/external_symbols.txt create mode 100755 internal/testdata/snapshots/output/testdata/external_symbols.txt diff --git a/internal/index/scip_test.go b/internal/index/scip_test.go index f9ad646..aa89aea 100644 --- a/internal/index/scip_test.go +++ b/internal/index/scip_test.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "path/filepath" + "sort" "strings" "testing" @@ -82,11 +83,65 @@ func TestSnapshots(t *testing.T) { t.Fatal(err) } + if len(scipIndex.ExternalSymbols) > 0 { + sourceFiles = append(sourceFiles, scip.NewSourceFile( + "external_symbols.txt", + "external_symbols.txt", + formatExternalSymbols(scipIndex.ExternalSymbols, symbolFormatter), + )) + } + return sourceFiles }, ) } +func formatExternalSymbols(symbols []*scip.SymbolInformation, formatter scip.SymbolFormatter) string { + var b strings.Builder + + sort.Slice(symbols, func(i, j int) bool { + return symbols[i].Symbol < symbols[j].Symbol + }) + + for i, sym := range symbols { + if i > 0 { + b.WriteString("\n") + } + formatted, err := formatter.Format(sym.Symbol) + if err != nil { + formatted = sym.Symbol + } + b.WriteString(formatted) + b.WriteString("\n") + + rels := make([]*scip.Relationship, len(sym.Relationships)) + copy(rels, sym.Relationships) + sort.Slice(rels, func(i, j int) bool { + return rels[i].Symbol < rels[j].Symbol + }) + + for _, rel := range rels { + relFormatted, err := formatter.Format(rel.Symbol) + if err != nil { + relFormatted = rel.Symbol + } + kind := "reference" + if rel.IsImplementation { + kind = "implementation" + } + if rel.IsReference { + kind = "reference" + } + if rel.IsTypeDefinition { + kind = "type_definition" + } + fmt.Fprintf(&b, " relationship %s %s\n", relFormatted, kind) + } + } + + return b.String() +} + // getTestdataRoot returns the absolute path to the testdata directory of this repository. func getTestdataRoot(t *testing.T) string { testdata, err := filepath.Abs("../testdata") diff --git a/internal/testdata/snapshots/input/pr198/go.mod b/internal/testdata/snapshots/input/pr198/go.mod index 1697c0d..96952a0 100644 --- a/internal/testdata/snapshots/input/pr198/go.mod +++ b/internal/testdata/snapshots/input/pr198/go.mod @@ -1,6 +1,6 @@ module sg/pr198 -go 1.22 +go 1.26 require github.com/example/dep v0.0.0 diff --git a/internal/testdata/snapshots/output/pr198/external_symbols.txt b/internal/testdata/snapshots/output/pr198/external_symbols.txt new file mode 100755 index 0000000..c9db07f --- /dev/null +++ b/internal/testdata/snapshots/output/pr198/external_symbols.txt @@ -0,0 +1,2 @@ +github.com/example/dep 0.1.test `github.com/example/dep`/T# + relationship 0.1.test `sg/pr198`/Foo# implementation diff --git a/internal/testdata/snapshots/output/testdata/external_symbols.txt b/internal/testdata/snapshots/output/testdata/external_symbols.txt new file mode 100755 index 0000000..0d91f79 --- /dev/null +++ b/internal/testdata/snapshots/output/testdata/external_symbols.txt @@ -0,0 +1,203 @@ +github.com/golang/go/src go1.22 `compress/flate`/Writer# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `compress/flate`/decompressor# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `compress/gzip`/Reader# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `compress/gzip`/Writer# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `crypto/cipher`/StreamWriter# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `crypto/tls`/Conn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `crypto/tls`/QUICConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `crypto/tls`/listener# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `encoding/base64`/encoder# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `encoding/hex`/dumper# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `encoding/pem`/lineBreaker# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `internal/fuzz`/sharedMem# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `internal/fuzz`/workerClient# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `internal/poll`/FD# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `mime/multipart`/Part# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `mime/multipart`/Writer# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `mime/multipart`/sectionReadCloser# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `mime/quotedprintable`/Writer# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http/internal`/chunkedWriter# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/ClientConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/Server# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/body# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/bodyEOFSignal# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/cancelTimerBody# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/expectContinueReader# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/gzipReader# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http1ClientConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http2ClientConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http2gzipReader# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http2missingBody# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http2netHTTPClientConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http2noBodyReader# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http2requestBody# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/http2transportResponseBody# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/ioFile# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/loggingConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/maxBytesReader# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/noBody# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/onceCloseListener# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/readTrackingBody# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/readWriteCloserBody# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/socksConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/http`/unencryptedNetConnInTLSConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/textproto`/Conn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `net/textproto`/dotWriter# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `vendor/golang.org/x/net/http2/hpack`/Decoder# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `vendor/golang.org/x/text/transform`/Writer# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 `vendor/golang.org/x/text/unicode/norm`/normWriter# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 io/PipeReader# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 io/PipeWriter# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 io/nopCloser# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 io/nopCloserWriterTo# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/IPConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/TCPConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/TCPListener# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/UDPConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/UnixConn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/UnixListener# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/conn# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/netFD# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/pipe# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/tcpConnWithoutReadFrom# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 net/tcpConnWithoutWriteTo# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 os/File# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 os/Root# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 os/fileWithoutReadFrom# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 os/fileWithoutWriteTo# + relationship 0.1.test `sg/testdata`/I3# implementation + +github.com/golang/go/src go1.22 os/root# + relationship 0.1.test `sg/testdata`/I3# implementation From d736433aebf80351a15dd49806c8ed1ec08c01fe Mon Sep 17 00:00:00 2001 From: jupblb Date: Fri, 10 Apr 2026 11:05:34 +0200 Subject: [PATCH 4/7] Simplify snapshot test to use testutil.FormatSnapshots Replace manual document iteration and custom formatExternalSymbols with testutil.FormatSnapshots from scip, which handles both document formatting and external symbol rendering. --- internal/index/scip_test.go | 73 +++++-------------- .../testdata/snapshots/input/pr198/go.mod | 2 +- .../output/pr198/external_symbols.txt | 2 +- .../output/testdata/external_symbols.txt | 69 +----------------- 4 files changed, 21 insertions(+), 125 deletions(-) diff --git a/internal/index/scip_test.go b/internal/index/scip_test.go index aa89aea..b9cd972 100644 --- a/internal/index/scip_test.go +++ b/internal/index/scip_test.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "path/filepath" - "sort" "strings" "testing" @@ -77,18 +76,28 @@ func TestSnapshots(t *testing.T) { IncludeDisambiguator: func(_ string) bool { return true }, } - sourceFiles, err := testutil.FormatSnapshots( - &scipIndex, "//", symbolFormatter, "") + // Skip documents outside of current directory (e.g. from Go build cache) + var localDocs []*scip.Document + for _, doc := range scipIndex.Documents { + if !strings.HasPrefix(doc.RelativePath, "..") { + localDocs = append(localDocs, doc) + } + } + scipIndex.Documents = localDocs + + sourceFiles, err := testutil.FormatSnapshots(&scipIndex, "//", symbolFormatter, inputDirectory) if err != nil { t.Fatal(err) } - if len(scipIndex.ExternalSymbols) > 0 { - sourceFiles = append(sourceFiles, scip.NewSourceFile( - "external_symbols.txt", - "external_symbols.txt", - formatExternalSymbols(scipIndex.ExternalSymbols, symbolFormatter), - )) + if *filter != "" { + var filtered []*scip.SourceFile + for _, sf := range sourceFiles { + if strings.Contains(sf.RelativePath, *filter) { + filtered = append(filtered, sf) + } + } + sourceFiles = filtered } return sourceFiles @@ -96,52 +105,6 @@ func TestSnapshots(t *testing.T) { ) } -func formatExternalSymbols(symbols []*scip.SymbolInformation, formatter scip.SymbolFormatter) string { - var b strings.Builder - - sort.Slice(symbols, func(i, j int) bool { - return symbols[i].Symbol < symbols[j].Symbol - }) - - for i, sym := range symbols { - if i > 0 { - b.WriteString("\n") - } - formatted, err := formatter.Format(sym.Symbol) - if err != nil { - formatted = sym.Symbol - } - b.WriteString(formatted) - b.WriteString("\n") - - rels := make([]*scip.Relationship, len(sym.Relationships)) - copy(rels, sym.Relationships) - sort.Slice(rels, func(i, j int) bool { - return rels[i].Symbol < rels[j].Symbol - }) - - for _, rel := range rels { - relFormatted, err := formatter.Format(rel.Symbol) - if err != nil { - relFormatted = rel.Symbol - } - kind := "reference" - if rel.IsImplementation { - kind = "implementation" - } - if rel.IsReference { - kind = "reference" - } - if rel.IsTypeDefinition { - kind = "type_definition" - } - fmt.Fprintf(&b, " relationship %s %s\n", relFormatted, kind) - } - } - - return b.String() -} - // getTestdataRoot returns the absolute path to the testdata directory of this repository. func getTestdataRoot(t *testing.T) string { testdata, err := filepath.Abs("../testdata") diff --git a/internal/testdata/snapshots/input/pr198/go.mod b/internal/testdata/snapshots/input/pr198/go.mod index 96952a0..6d87781 100644 --- a/internal/testdata/snapshots/input/pr198/go.mod +++ b/internal/testdata/snapshots/input/pr198/go.mod @@ -1,6 +1,6 @@ module sg/pr198 -go 1.26 +go 1.25 require github.com/example/dep v0.0.0 diff --git a/internal/testdata/snapshots/output/pr198/external_symbols.txt b/internal/testdata/snapshots/output/pr198/external_symbols.txt index c9db07f..90e850c 100755 --- a/internal/testdata/snapshots/output/pr198/external_symbols.txt +++ b/internal/testdata/snapshots/output/pr198/external_symbols.txt @@ -1,2 +1,2 @@ github.com/example/dep 0.1.test `github.com/example/dep`/T# - relationship 0.1.test `sg/pr198`/Foo# implementation + relationship 0.1.test `sg/pr198`/Foo# implementation \ No newline at end of file diff --git a/internal/testdata/snapshots/output/testdata/external_symbols.txt b/internal/testdata/snapshots/output/testdata/external_symbols.txt index 0d91f79..096efcf 100755 --- a/internal/testdata/snapshots/output/testdata/external_symbols.txt +++ b/internal/testdata/snapshots/output/testdata/external_symbols.txt @@ -1,203 +1,136 @@ github.com/golang/go/src go1.22 `compress/flate`/Writer# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `compress/flate`/decompressor# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `compress/gzip`/Reader# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `compress/gzip`/Writer# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `crypto/cipher`/StreamWriter# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `crypto/tls`/Conn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `crypto/tls`/QUICConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `crypto/tls`/listener# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `encoding/base64`/encoder# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `encoding/hex`/dumper# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `encoding/pem`/lineBreaker# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `internal/fuzz`/sharedMem# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `internal/fuzz`/workerClient# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `internal/poll`/FD# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `mime/multipart`/Part# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `mime/multipart`/Writer# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `mime/multipart`/sectionReadCloser# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `mime/quotedprintable`/Writer# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http/internal`/chunkedWriter# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/ClientConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/Server# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/body# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/bodyEOFSignal# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/cancelTimerBody# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/expectContinueReader# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/gzipReader# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http1ClientConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http2ClientConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http2gzipReader# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http2missingBody# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http2netHTTPClientConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http2noBodyReader# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http2requestBody# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/http2transportResponseBody# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/ioFile# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/loggingConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/maxBytesReader# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/noBody# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/onceCloseListener# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/readTrackingBody# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/readWriteCloserBody# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/socksConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/http`/unencryptedNetConnInTLSConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/textproto`/Conn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `net/textproto`/dotWriter# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `vendor/golang.org/x/net/http2/hpack`/Decoder# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `vendor/golang.org/x/text/transform`/Writer# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 `vendor/golang.org/x/text/unicode/norm`/normWriter# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 io/PipeReader# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 io/PipeWriter# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 io/nopCloser# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 io/nopCloserWriterTo# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/IPConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/TCPConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/TCPListener# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/UDPConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/UnixConn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/UnixListener# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/conn# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/netFD# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/pipe# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/tcpConnWithoutReadFrom# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 net/tcpConnWithoutWriteTo# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 os/File# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 os/Root# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 os/fileWithoutReadFrom# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 os/fileWithoutWriteTo# relationship 0.1.test `sg/testdata`/I3# implementation - github.com/golang/go/src go1.22 os/root# - relationship 0.1.test `sg/testdata`/I3# implementation + relationship 0.1.test `sg/testdata`/I3# implementation \ No newline at end of file From b9819cc2101e97ec7d89084f94be0e887797d75c Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 14 Apr 2026 21:06:34 +0200 Subject: [PATCH 5/7] Update snapshots for Go 1.25 --- .../testdata/snapshots/output/pr198/pr198.go | 48 ++++++++----------- .../output/testdata/external_symbols.txt | 6 --- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/internal/testdata/snapshots/output/pr198/pr198.go b/internal/testdata/snapshots/output/pr198/pr198.go index 2cd9191..abc20be 100755 --- a/internal/testdata/snapshots/output/pr198/pr198.go +++ b/internal/testdata/snapshots/output/pr198/pr198.go @@ -1,7 +1,8 @@ package pr198 // ^^^^^ definition 0.1.test `sg/pr198`/ -// documentation -// > package pr198 +// display_name pr198 +// signature_documentation +// > package pr198 import "github.com/example/dep" // ^^^^^^^^^^^^^^^^^^^^^^ reference github.com/example/dep 0.1.test `github.com/example/dep`/ @@ -12,47 +13,36 @@ // pointing to Foo. type Foo interface { // ^^^ definition 0.1.test `sg/pr198`/Foo# -// documentation -// > ```go -// > type Foo interface -// > ``` -// documentation -// > Foo is an interface defined downstream of the type that implements it. -// > The dep.T type (from a dependency) implements Foo, and scip-go should -// > emit an external symbol for dep.T with an IsImplementation relationship -// > pointing to Foo. -// documentation -// > ```go -// > interface { -// > Bar() -// > } -// > ``` +// signature_documentation +// > type Foo interface{ Bar() } +// documentation +// > Foo is an interface defined downstream of the type that implements it. +// > The dep.T type (from a dependency) implements Foo, and scip-go should +// > emit an external symbol for dep.T with an IsImplementation relationship +// > pointing to Foo. Bar() // ^^^ definition 0.1.test `sg/pr198`/Foo#Bar. -// documentation -// > ```go -// > func (Foo).Bar() -// > ``` +// signature_documentation +// > func (Foo).Bar() } //⌄ enclosing_range_start 0.1.test `sg/pr198`/UseFoo(). func UseFoo(f Foo) {} // ^^^^^^ definition 0.1.test `sg/pr198`/UseFoo(). -// documentation -// > ```go -// > func UseFoo(f Foo) -// > ``` +// signature_documentation +// > func UseFoo(f Foo) // ^ definition local 0 +// display_name f +// signature_documentation +// > var f Foo // ^^^ reference 0.1.test `sg/pr198`/Foo# // ⌃ enclosing_range_end 0.1.test `sg/pr198`/UseFoo(). //⌄ enclosing_range_start 0.1.test `sg/pr198`/Example(). func Example() { // ^^^^^^^ definition 0.1.test `sg/pr198`/Example(). -// documentation -// > ```go -// > func Example() -// > ``` +// signature_documentation +// > func Example() UseFoo(&dep.T{}) // ^^^^^^ reference 0.1.test `sg/pr198`/UseFoo(). // ^^^ reference github.com/example/dep 0.1.test `github.com/example/dep`/ diff --git a/internal/testdata/snapshots/output/testdata/external_symbols.txt b/internal/testdata/snapshots/output/testdata/external_symbols.txt index 096efcf..cf539e3 100755 --- a/internal/testdata/snapshots/output/testdata/external_symbols.txt +++ b/internal/testdata/snapshots/output/testdata/external_symbols.txt @@ -36,8 +36,6 @@ github.com/golang/go/src go1.22 `mime/quotedprintable`/Writer# relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http/internal`/chunkedWriter# relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/ClientConn# - relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/Server# relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/body# @@ -50,16 +48,12 @@ github.com/golang/go/src go1.22 `net/http`/expectContinueReader# relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/gzipReader# relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http1ClientConn# - relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/http2ClientConn# relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/http2gzipReader# relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/http2missingBody# relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http2netHTTPClientConn# - relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/http2noBodyReader# relationship 0.1.test `sg/testdata`/I3# implementation github.com/golang/go/src go1.22 `net/http`/http2requestBody# From 5638dd4862b27175247bcc44ebc67246db24aaa0 Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 14 Apr 2026 23:14:00 +0200 Subject: [PATCH 6/7] Use unique method in I3 interface to avoid platform-dependent stdlib matches Replace Close() error with ScipTestMethod() so the embedded implementation test doesn't pull in dozens of stdlib types that vary across OS/arch. The pr198 test still covers external symbol emission with a controlled dependency. --- .../input/testdata/implementations.go | 2 +- .../testdata/implementations_embedded.go | 10 +- .../output/testdata/external_symbols.txt | 130 ------------------ .../output/testdata/implementations.go | 18 +-- .../testdata/implementations_embedded.go | 40 +++--- 5 files changed, 40 insertions(+), 160 deletions(-) delete mode 100755 internal/testdata/snapshots/output/testdata/external_symbols.txt diff --git a/internal/testdata/snapshots/input/testdata/implementations.go b/internal/testdata/snapshots/input/testdata/implementations.go index 316eca0..2f4ba64 100644 --- a/internal/testdata/snapshots/input/testdata/implementations.go +++ b/internal/testdata/snapshots/input/testdata/implementations.go @@ -34,7 +34,7 @@ type Foo int func (r Foo) nonExportedMethod() {} func (r Foo) ExportedMethod() {} -func (r Foo) Close() error { return nil } +func (r Foo) ScipTestMethod() {} type SharedOne interface { Shared() diff --git a/internal/testdata/snapshots/input/testdata/implementations_embedded.go b/internal/testdata/snapshots/input/testdata/implementations_embedded.go index 2bad237..96e5fe8 100644 --- a/internal/testdata/snapshots/input/testdata/implementations_embedded.go +++ b/internal/testdata/snapshots/input/testdata/implementations_embedded.go @@ -1,11 +1,13 @@ package testdata -import "io" - type I3 interface { - Close() error + ScipTestMethod() +} + +type EmbeddedI3 interface { + ScipTestMethod() } type TClose struct { - io.Closer + EmbeddedI3 } diff --git a/internal/testdata/snapshots/output/testdata/external_symbols.txt b/internal/testdata/snapshots/output/testdata/external_symbols.txt deleted file mode 100755 index cf539e3..0000000 --- a/internal/testdata/snapshots/output/testdata/external_symbols.txt +++ /dev/null @@ -1,130 +0,0 @@ -github.com/golang/go/src go1.22 `compress/flate`/Writer# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `compress/flate`/decompressor# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `compress/gzip`/Reader# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `compress/gzip`/Writer# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `crypto/cipher`/StreamWriter# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `crypto/tls`/Conn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `crypto/tls`/QUICConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `crypto/tls`/listener# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `encoding/base64`/encoder# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `encoding/hex`/dumper# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `encoding/pem`/lineBreaker# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `internal/fuzz`/sharedMem# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `internal/fuzz`/workerClient# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `internal/poll`/FD# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `mime/multipart`/Part# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `mime/multipart`/Writer# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `mime/multipart`/sectionReadCloser# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `mime/quotedprintable`/Writer# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http/internal`/chunkedWriter# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/Server# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/body# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/bodyEOFSignal# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/cancelTimerBody# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/expectContinueReader# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/gzipReader# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http2ClientConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http2gzipReader# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http2missingBody# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http2noBodyReader# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http2requestBody# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/http2transportResponseBody# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/ioFile# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/loggingConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/maxBytesReader# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/noBody# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/onceCloseListener# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/readTrackingBody# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/readWriteCloserBody# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/socksConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/http`/unencryptedNetConnInTLSConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/textproto`/Conn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `net/textproto`/dotWriter# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `vendor/golang.org/x/net/http2/hpack`/Decoder# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `vendor/golang.org/x/text/transform`/Writer# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 `vendor/golang.org/x/text/unicode/norm`/normWriter# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 io/PipeReader# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 io/PipeWriter# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 io/nopCloser# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 io/nopCloserWriterTo# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/IPConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/TCPConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/TCPListener# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/UDPConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/UnixConn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/UnixListener# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/conn# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/netFD# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/pipe# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/tcpConnWithoutReadFrom# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 net/tcpConnWithoutWriteTo# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 os/File# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 os/Root# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 os/fileWithoutReadFrom# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 os/fileWithoutWriteTo# - relationship 0.1.test `sg/testdata`/I3# implementation -github.com/golang/go/src go1.22 os/root# - relationship 0.1.test `sg/testdata`/I3# implementation \ No newline at end of file diff --git a/internal/testdata/snapshots/output/testdata/implementations.go b/internal/testdata/snapshots/output/testdata/implementations.go index d047320..33e91c9 100755 --- a/internal/testdata/snapshots/output/testdata/implementations.go +++ b/internal/testdata/snapshots/output/testdata/implementations.go @@ -112,7 +112,7 @@ // ^^^ definition 0.1.test `sg/testdata`/Foo# // signature_documentation // > type Foo int -// relationship github.com/golang/go/src go1.22 io/Closer# implementation +// relationship 0.1.test `sg/testdata`/EmbeddedI3# implementation // relationship 0.1.test `sg/testdata`/I3# implementation // relationship 0.1.test `sg/testdata`/InterfaceWithExportedMethod# implementation // relationship 0.1.test `sg/testdata`/InterfaceWithNonExportedMethod# implementation @@ -141,19 +141,19 @@ // > func (Foo).ExportedMethod() // relationship 0.1.test `sg/testdata`/InterfaceWithExportedMethod#ExportedMethod. implementation // ⌃ enclosing_range_end 0.1.test `sg/testdata`/Foo#ExportedMethod(). -//⌄ enclosing_range_start 0.1.test `sg/testdata`/Foo#Close(). - func (r Foo) Close() error { return nil } +//⌄ enclosing_range_start 0.1.test `sg/testdata`/Foo#ScipTestMethod(). + func (r Foo) ScipTestMethod() {} // ^ definition local 5 // display_name r // signature_documentation // > var r Foo // ^^^ reference 0.1.test `sg/testdata`/Foo# -// ^^^^^ definition 0.1.test `sg/testdata`/Foo#Close(). -// signature_documentation -// > func (Foo).Close() error -// relationship github.com/golang/go/src go1.22 io/Closer#Close. implementation -// relationship 0.1.test `sg/testdata`/I3#Close. implementation -// ⌃ enclosing_range_end 0.1.test `sg/testdata`/Foo#Close(). +// ^^^^^^^^^^^^^^ definition 0.1.test `sg/testdata`/Foo#ScipTestMethod(). +// signature_documentation +// > func (Foo).ScipTestMethod() +// relationship 0.1.test `sg/testdata`/EmbeddedI3#ScipTestMethod. implementation +// relationship 0.1.test `sg/testdata`/I3#ScipTestMethod. implementation +// ⌃ enclosing_range_end 0.1.test `sg/testdata`/Foo#ScipTestMethod(). type SharedOne interface { // ^^^^^^^^^ definition 0.1.test `sg/testdata`/SharedOne# diff --git a/internal/testdata/snapshots/output/testdata/implementations_embedded.go b/internal/testdata/snapshots/output/testdata/implementations_embedded.go index 14faa1a..6d98b83 100755 --- a/internal/testdata/snapshots/output/testdata/implementations_embedded.go +++ b/internal/testdata/snapshots/output/testdata/implementations_embedded.go @@ -1,30 +1,38 @@ package testdata // ^^^^^^^^ definition 0.1.test `sg/testdata`/ - import "io" -// ^^ reference github.com/golang/go/src go1.22 io/ - type I3 interface { // ^^ definition 0.1.test `sg/testdata`/I3# // signature_documentation -// > type I3 interface{ Close() error } - Close() error -// ^^^^^ definition 0.1.test `sg/testdata`/I3#Close. -// signature_documentation -// > func (I3).Close() error +// > type I3 interface{ ScipTestMethod() } + ScipTestMethod() +// ^^^^^^^^^^^^^^ definition 0.1.test `sg/testdata`/I3#ScipTestMethod. +// signature_documentation +// > func (I3).ScipTestMethod() + } + + type EmbeddedI3 interface { +// ^^^^^^^^^^ definition 0.1.test `sg/testdata`/EmbeddedI3# +// signature_documentation +// > type EmbeddedI3 interface{ ScipTestMethod() } + ScipTestMethod() +// ^^^^^^^^^^^^^^ definition 0.1.test `sg/testdata`/EmbeddedI3#ScipTestMethod. +// signature_documentation +// > func (EmbeddedI3).ScipTestMethod() +// relationship 0.1.test `sg/testdata`/EmbeddedI3#ScipTestMethod. implementation +// relationship 0.1.test `sg/testdata`/I3#ScipTestMethod. implementation } type TClose struct { // ^^^^^^ definition 0.1.test `sg/testdata`/TClose# // signature_documentation -// > type TClose struct{ Closer } -// relationship github.com/golang/go/src go1.22 io/Closer# implementation +// > type TClose struct{ EmbeddedI3 } +// relationship 0.1.test `sg/testdata`/EmbeddedI3# implementation // relationship 0.1.test `sg/testdata`/I3# implementation - io.Closer -// ^^ reference github.com/golang/go/src go1.22 io/ -// ^^^^^^ definition 0.1.test `sg/testdata`/TClose#Closer. -// signature_documentation -// > struct field Closer io.Closer -// ^^^^^^ reference github.com/golang/go/src go1.22 io/Closer# + EmbeddedI3 +// ^^^^^^^^^^ definition 0.1.test `sg/testdata`/TClose#EmbeddedI3. +// signature_documentation +// > struct field EmbeddedI3 sg/testdata.EmbeddedI3 +// ^^^^^^^^^^ reference 0.1.test `sg/testdata`/EmbeddedI3# } From ff9fa40c1cba40467a453a1e188685715738d996 Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 14 Apr 2026 23:17:37 +0200 Subject: [PATCH 7/7] Remove redundant document filter and out-of-scope output filter --- internal/index/scip_test.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/internal/index/scip_test.go b/internal/index/scip_test.go index b9cd972..f9ad646 100644 --- a/internal/index/scip_test.go +++ b/internal/index/scip_test.go @@ -76,30 +76,12 @@ func TestSnapshots(t *testing.T) { IncludeDisambiguator: func(_ string) bool { return true }, } - // Skip documents outside of current directory (e.g. from Go build cache) - var localDocs []*scip.Document - for _, doc := range scipIndex.Documents { - if !strings.HasPrefix(doc.RelativePath, "..") { - localDocs = append(localDocs, doc) - } - } - scipIndex.Documents = localDocs - - sourceFiles, err := testutil.FormatSnapshots(&scipIndex, "//", symbolFormatter, inputDirectory) + sourceFiles, err := testutil.FormatSnapshots( + &scipIndex, "//", symbolFormatter, "") if err != nil { t.Fatal(err) } - if *filter != "" { - var filtered []*scip.SourceFile - for _, sf := range sourceFiles { - if strings.Contains(sf.RelativePath, *filter) { - filtered = append(filtered, sf) - } - } - sourceFiles = filtered - } - return sourceFiles }, )