diff --git a/changelogs/unreleased/pb-remove-process-lsif-references-flag.yml b/changelogs/unreleased/pb-remove-process-lsif-references-flag.yml new file mode 100644 index 0000000000000000000000000000000000000000..52e5ad1a44f0be1962b5e0376e2669f543c8efb5 --- /dev/null +++ b/changelogs/unreleased/pb-remove-process-lsif-references-flag.yml @@ -0,0 +1,5 @@ +--- +title: Remove ProcessReferences flag +merge_request: 543 +author: +type: changed diff --git a/internal/lsif_transformer/parser/docs_test.go b/internal/lsif_transformer/parser/docs_test.go index fbb88aaf7425bd77eac6ed3b4d65d30eee141765..ff19dd561bb24e25e9206bb3955a93f4cf3dcf47 100644 --- a/internal/lsif_transformer/parser/docs_test.go +++ b/internal/lsif_transformer/parser/docs_test.go @@ -12,7 +12,7 @@ func createLine(id, label, uri string) []byte { } func TestRead(t *testing.T) { - d, err := NewDocs(Config{ProcessReferences: true}) + d, err := NewDocs(Config{}) require.NoError(t, err) defer d.Close() @@ -29,7 +29,7 @@ func TestRead(t *testing.T) { } func TestReadContainsLine(t *testing.T) { - d, err := NewDocs(Config{ProcessReferences: true}) + d, err := NewDocs(Config{}) require.NoError(t, err) defer d.Close() diff --git a/internal/lsif_transformer/parser/parser.go b/internal/lsif_transformer/parser/parser.go index 84fd9ccda25def7c38b5d6488565976276def655..8687e1243d78b6990548c656a0f2174cf3e77708 100644 --- a/internal/lsif_transformer/parser/parser.go +++ b/internal/lsif_transformer/parser/parser.go @@ -19,8 +19,7 @@ type Parser struct { } type Config struct { - TempPath string - ProcessReferences bool + TempPath string } func NewParser(r io.Reader, config Config) (*Parser, error) { diff --git a/internal/lsif_transformer/parser/parser_test.go b/internal/lsif_transformer/parser/parser_test.go index 212d58e88a50afaab73c50a3af1762fa2805b8f7..5bc34d69f32ac8ca943569c95981793380118144 100644 --- a/internal/lsif_transformer/parser/parser_test.go +++ b/internal/lsif_transformer/parser/parser_test.go @@ -41,7 +41,7 @@ func createFiles(t *testing.T, filePath, tmpDir string) { file, err := os.Open(filePath) require.NoError(t, err) - p, err := NewParser(file, Config{ProcessReferences: true}) + p, err := NewParser(file, Config{}) require.NoError(t, err) r, err := p.ZipReader() diff --git a/internal/lsif_transformer/parser/performance_test.go b/internal/lsif_transformer/parser/performance_test.go index 89a2ec0311a444aeb67a865721226c6dd1e1affd..de79e621ba43347ebd6a0000949ba19404e9d07d 100644 --- a/internal/lsif_transformer/parser/performance_test.go +++ b/internal/lsif_transformer/parser/performance_test.go @@ -19,7 +19,7 @@ func BenchmarkGenerate(b *testing.B) { file, err := os.Open(filePath) require.NoError(b, err) - p, err := NewParser(file, Config{ProcessReferences: true}) + p, err := NewParser(file, Config{}) require.NoError(b, err) _, err = p.ZipReader() diff --git a/internal/lsif_transformer/parser/ranges_test.go b/internal/lsif_transformer/parser/ranges_test.go index 3bf405e8c0d9a3a7a18c3f47ab4c00c8b6196d10..f6d26026e3faa15e35d45344247eb8735f04a6ba 100644 --- a/internal/lsif_transformer/parser/ranges_test.go +++ b/internal/lsif_transformer/parser/ranges_test.go @@ -8,7 +8,7 @@ import ( ) func TestRangesRead(t *testing.T) { - r, cleanup := setup(t, true) + r, cleanup := setup(t) defer cleanup() firstRange := Range{Line: 1, Character: 2, RefId: 3} @@ -23,7 +23,7 @@ func TestRangesRead(t *testing.T) { } func TestSerialize(t *testing.T) { - r, cleanup := setup(t, true) + r, cleanup := setup(t) defer cleanup() docs := map[Id]string{6: "def-path", 7: "ref-path"} @@ -36,22 +36,8 @@ func TestSerialize(t *testing.T) { require.Equal(t, want, buf.String()) } -func TestSerializeWithoutProcessingReferences(t *testing.T) { - r, cleanup := setup(t, false) - defer cleanup() - - docs := map[Id]string{6: "def-path", 7: "ref-path"} - - var buf bytes.Buffer - err := r.Serialize(&buf, []Id{1}, docs) - want := `[{"start_line":1,"start_char":2,"definition_path":"def-path#L2","hover":null}` + "\n]" - - require.NoError(t, err) - require.Equal(t, want, buf.String()) -} - -func setup(t *testing.T, processReferences bool) (*Ranges, func()) { - r, err := NewRanges(Config{ProcessReferences: processReferences}) +func setup(t *testing.T) (*Ranges, func()) { + r, err := NewRanges(Config{}) require.NoError(t, err) require.NoError(t, r.Read("range", []byte(`{"id":1,"label":"range","start":{"line":1,"character":2}}`))) diff --git a/internal/lsif_transformer/parser/references.go b/internal/lsif_transformer/parser/references.go index e51019a3fd90f51a6b4048cc7d0f8b4e53e337ae..491454c2a62cf663d7a257373707c062322f5f82 100644 --- a/internal/lsif_transformer/parser/references.go +++ b/internal/lsif_transformer/parser/references.go @@ -10,10 +10,9 @@ type ReferencesOffset struct { } type References struct { - Items *cache - Offsets *cache - CurrentOffsetId Id - ProcessReferences bool + Items *cache + Offsets *cache + CurrentOffsetId Id } type SerializedReference struct { @@ -34,10 +33,9 @@ func NewReferences(config Config) (*References, error) { } return &References{ - Items: items, - Offsets: offsets, - CurrentOffsetId: 0, - ProcessReferences: config.ProcessReferences, + Items: items, + Offsets: offsets, + CurrentOffsetId: 0, }, nil } @@ -51,7 +49,7 @@ func NewReferences(config Config) (*References, error) { func (r *References) Store(refId Id, references []Item) error { size := len(references) - if !r.ProcessReferences || size == 0 { + if size == 0 { return nil } @@ -67,10 +65,6 @@ func (r *References) Store(refId Id, references []Item) error { } func (r *References) For(docs map[Id]string, refId Id) []SerializedReference { - if !r.ProcessReferences { - return nil - } - references := r.getItems(refId) if references == nil { return nil diff --git a/internal/lsif_transformer/parser/references_test.go b/internal/lsif_transformer/parser/references_test.go index 525d722c41614f445444bf4af932dee69f66abd0..7b47513bc53977013b8625c1b0c1a7872a5ba92b 100644 --- a/internal/lsif_transformer/parser/references_test.go +++ b/internal/lsif_transformer/parser/references_test.go @@ -12,7 +12,7 @@ func TestReferencesStore(t *testing.T) { refId = 3 ) - r, err := NewReferences(Config{ProcessReferences: true}) + r, err := NewReferences(Config{}) require.NoError(t, err) err = r.Store(refId, []Item{{Line: 2, DocId: docId}, {Line: 3, DocId: docId}}) @@ -30,7 +30,7 @@ func TestReferencesStore(t *testing.T) { func TestReferencesStoreEmpty(t *testing.T) { const refId = 3 - r, err := NewReferences(Config{ProcessReferences: true}) + r, err := NewReferences(Config{}) require.NoError(t, err) err = r.Store(refId, []Item{}) diff --git a/internal/upload/rewrite.go b/internal/upload/rewrite.go index e9a4d94e0962ed9ce9c5b3b17c01d0e48d3d8ce2..938ecef164f50a57d1dcb452c8b15f69aea90986 100644 --- a/internal/upload/rewrite.go +++ b/internal/upload/rewrite.go @@ -176,8 +176,7 @@ func handleExifUpload(ctx context.Context, r io.Reader, filename string) (io.Rea func handleLsifUpload(ctx context.Context, reader io.Reader, tempPath, filename string, preauth *api.Response) (io.Reader, error) { parserConfig := parser.Config{ - TempPath: tempPath, - ProcessReferences: preauth.ProcessLsifReferences, + TempPath: tempPath, } p, err := parser.NewParser(reader, parserConfig)