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 {
}
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()
......
......@@ -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) {
......
......@@ -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()
......
......@@ -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()
......
......@@ -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}}`)))
......
......@@ -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
......
......@@ -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{})
......
......@@ -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)
......
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