Commit 78c75826 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'pb-remove-process-lsif-references-flag' into 'master'

Remove ProcessReferences flag

See merge request gitlab-org/gitlab-workhorse!543
parents a4937ce2 c694aa5e
---
title: Remove ProcessReferences flag
merge_request: 543
author:
type: changed
...@@ -12,7 +12,7 @@ func createLine(id, label, uri string) []byte { ...@@ -12,7 +12,7 @@ func createLine(id, label, uri string) []byte {
} }
func TestRead(t *testing.T) { func TestRead(t *testing.T) {
d, err := NewDocs(Config{ProcessReferences: true}) d, err := NewDocs(Config{})
require.NoError(t, err) require.NoError(t, err)
defer d.Close() defer d.Close()
...@@ -29,7 +29,7 @@ func TestRead(t *testing.T) { ...@@ -29,7 +29,7 @@ func TestRead(t *testing.T) {
} }
func TestReadContainsLine(t *testing.T) { func TestReadContainsLine(t *testing.T) {
d, err := NewDocs(Config{ProcessReferences: true}) d, err := NewDocs(Config{})
require.NoError(t, err) require.NoError(t, err)
defer d.Close() defer d.Close()
......
...@@ -19,8 +19,7 @@ type Parser struct { ...@@ -19,8 +19,7 @@ type Parser struct {
} }
type Config struct { type Config struct {
TempPath string TempPath string
ProcessReferences bool
} }
func NewParser(r io.Reader, config Config) (*Parser, error) { func NewParser(r io.Reader, config Config) (*Parser, error) {
......
...@@ -41,7 +41,7 @@ func createFiles(t *testing.T, filePath, tmpDir string) { ...@@ -41,7 +41,7 @@ func createFiles(t *testing.T, filePath, tmpDir string) {
file, err := os.Open(filePath) file, err := os.Open(filePath)
require.NoError(t, err) require.NoError(t, err)
p, err := NewParser(file, Config{ProcessReferences: true}) p, err := NewParser(file, Config{})
require.NoError(t, err) require.NoError(t, err)
r, err := p.ZipReader() r, err := p.ZipReader()
......
...@@ -19,7 +19,7 @@ func BenchmarkGenerate(b *testing.B) { ...@@ -19,7 +19,7 @@ func BenchmarkGenerate(b *testing.B) {
file, err := os.Open(filePath) file, err := os.Open(filePath)
require.NoError(b, err) require.NoError(b, err)
p, err := NewParser(file, Config{ProcessReferences: true}) p, err := NewParser(file, Config{})
require.NoError(b, err) require.NoError(b, err)
_, err = p.ZipReader() _, err = p.ZipReader()
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
) )
func TestRangesRead(t *testing.T) { func TestRangesRead(t *testing.T) {
r, cleanup := setup(t, true) r, cleanup := setup(t)
defer cleanup() defer cleanup()
firstRange := Range{Line: 1, Character: 2, RefId: 3} firstRange := Range{Line: 1, Character: 2, RefId: 3}
...@@ -23,7 +23,7 @@ func TestRangesRead(t *testing.T) { ...@@ -23,7 +23,7 @@ func TestRangesRead(t *testing.T) {
} }
func TestSerialize(t *testing.T) { func TestSerialize(t *testing.T) {
r, cleanup := setup(t, true) r, cleanup := setup(t)
defer cleanup() defer cleanup()
docs := map[Id]string{6: "def-path", 7: "ref-path"} docs := map[Id]string{6: "def-path", 7: "ref-path"}
...@@ -36,22 +36,8 @@ func TestSerialize(t *testing.T) { ...@@ -36,22 +36,8 @@ func TestSerialize(t *testing.T) {
require.Equal(t, want, buf.String()) require.Equal(t, want, buf.String())
} }
func TestSerializeWithoutProcessingReferences(t *testing.T) { func setup(t *testing.T) (*Ranges, func()) {
r, cleanup := setup(t, false) r, err := NewRanges(Config{})
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})
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, r.Read("range", []byte(`{"id":1,"label":"range","start":{"line":1,"character":2}}`))) require.NoError(t, r.Read("range", []byte(`{"id":1,"label":"range","start":{"line":1,"character":2}}`)))
......
...@@ -10,10 +10,9 @@ type ReferencesOffset struct { ...@@ -10,10 +10,9 @@ type ReferencesOffset struct {
} }
type References struct { type References struct {
Items *cache Items *cache
Offsets *cache Offsets *cache
CurrentOffsetId Id CurrentOffsetId Id
ProcessReferences bool
} }
type SerializedReference struct { type SerializedReference struct {
...@@ -34,10 +33,9 @@ func NewReferences(config Config) (*References, error) { ...@@ -34,10 +33,9 @@ func NewReferences(config Config) (*References, error) {
} }
return &References{ return &References{
Items: items, Items: items,
Offsets: offsets, Offsets: offsets,
CurrentOffsetId: 0, CurrentOffsetId: 0,
ProcessReferences: config.ProcessReferences,
}, nil }, nil
} }
...@@ -51,7 +49,7 @@ func NewReferences(config Config) (*References, error) { ...@@ -51,7 +49,7 @@ func NewReferences(config Config) (*References, error) {
func (r *References) Store(refId Id, references []Item) error { func (r *References) Store(refId Id, references []Item) error {
size := len(references) size := len(references)
if !r.ProcessReferences || size == 0 { if size == 0 {
return nil return nil
} }
...@@ -67,10 +65,6 @@ func (r *References) Store(refId Id, references []Item) error { ...@@ -67,10 +65,6 @@ func (r *References) Store(refId Id, references []Item) error {
} }
func (r *References) For(docs map[Id]string, refId Id) []SerializedReference { func (r *References) For(docs map[Id]string, refId Id) []SerializedReference {
if !r.ProcessReferences {
return nil
}
references := r.getItems(refId) references := r.getItems(refId)
if references == nil { if references == nil {
return nil return nil
......
...@@ -12,7 +12,7 @@ func TestReferencesStore(t *testing.T) { ...@@ -12,7 +12,7 @@ func TestReferencesStore(t *testing.T) {
refId = 3 refId = 3
) )
r, err := NewReferences(Config{ProcessReferences: true}) r, err := NewReferences(Config{})
require.NoError(t, err) require.NoError(t, err)
err = r.Store(refId, []Item{{Line: 2, DocId: docId}, {Line: 3, DocId: docId}}) err = r.Store(refId, []Item{{Line: 2, DocId: docId}, {Line: 3, DocId: docId}})
...@@ -30,7 +30,7 @@ func TestReferencesStore(t *testing.T) { ...@@ -30,7 +30,7 @@ func TestReferencesStore(t *testing.T) {
func TestReferencesStoreEmpty(t *testing.T) { func TestReferencesStoreEmpty(t *testing.T) {
const refId = 3 const refId = 3
r, err := NewReferences(Config{ProcessReferences: true}) r, err := NewReferences(Config{})
require.NoError(t, err) require.NoError(t, err)
err = r.Store(refId, []Item{}) err = r.Store(refId, []Item{})
......
...@@ -176,8 +176,7 @@ func handleExifUpload(ctx context.Context, r io.Reader, filename string) (io.Rea ...@@ -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) { func handleLsifUpload(ctx context.Context, reader io.Reader, tempPath, filename string, preauth *api.Response) (io.Reader, error) {
parserConfig := parser.Config{ parserConfig := parser.Config{
TempPath: tempPath, TempPath: tempPath,
ProcessReferences: preauth.ProcessLsifReferences,
} }
p, err := parser.NewParser(reader, parserConfig) p, err := parser.NewParser(reader, parserConfig)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment