@@ -12,6 +12,7 @@ import (
12
12
"testing"
13
13
"time"
14
14
15
+ "golang.org/x/tools/gopls/internal/cache/parsego"
15
16
"golang.org/x/tools/gopls/internal/file"
16
17
"golang.org/x/tools/gopls/internal/protocol"
17
18
)
@@ -31,12 +32,12 @@ func TestParseCache(t *testing.T) {
31
32
fset := token .NewFileSet ()
32
33
33
34
cache := newParseCache (0 )
34
- pgfs1 , err := cache .parseFiles (ctx , fset , ParseFull , false , fh )
35
+ pgfs1 , err := cache .parseFiles (ctx , fset , parsego . Full , false , fh )
35
36
if err != nil {
36
37
t .Fatal (err )
37
38
}
38
39
pgf1 := pgfs1 [0 ]
39
- pgfs2 , err := cache .parseFiles (ctx , fset , ParseFull , false , fh )
40
+ pgfs2 , err := cache .parseFiles (ctx , fset , parsego . Full , false , fh )
40
41
pgf2 := pgfs2 [0 ]
41
42
if err != nil {
42
43
t .Fatal (err )
@@ -50,7 +51,7 @@ func TestParseCache(t *testing.T) {
50
51
files := []file.Handle {fh }
51
52
files = append (files , dummyFileHandles (parseCacheMinFiles - 1 )... )
52
53
53
- pgfs3 , err := cache .parseFiles (ctx , fset , ParseFull , false , files ... )
54
+ pgfs3 , err := cache .parseFiles (ctx , fset , parsego . Full , false , files ... )
54
55
if err != nil {
55
56
t .Fatal (err )
56
57
}
@@ -68,13 +69,13 @@ func TestParseCache(t *testing.T) {
68
69
// Now overwrite the cache, after which we should get new results.
69
70
cache .gcOnce ()
70
71
files = dummyFileHandles (parseCacheMinFiles )
71
- _ , err = cache .parseFiles (ctx , fset , ParseFull , false , files ... )
72
+ _ , err = cache .parseFiles (ctx , fset , parsego . Full , false , files ... )
72
73
if err != nil {
73
74
t .Fatal (err )
74
75
}
75
76
// force a GC, which should collect the recently parsed files
76
77
cache .gcOnce ()
77
- pgfs4 , err := cache .parseFiles (ctx , fset , ParseFull , false , fh )
78
+ pgfs4 , err := cache .parseFiles (ctx , fset , parsego . Full , false , fh )
78
79
if err != nil {
79
80
t .Fatal (err )
80
81
}
@@ -98,7 +99,7 @@ func TestParseCache_Reparsing(t *testing.T) {
98
99
99
100
// Parsing should succeed even though we overflow the padding.
100
101
cache := newParseCache (0 )
101
- _ , err := cache .parseFiles (context .Background (), token .NewFileSet (), ParseFull , false , files ... )
102
+ _ , err := cache .parseFiles (context .Background (), token .NewFileSet (), parsego . Full , false , files ... )
102
103
if err != nil {
103
104
t .Fatal (err )
104
105
}
@@ -118,7 +119,7 @@ func TestParseCache_Issue59097(t *testing.T) {
118
119
119
120
// Parsing should succeed even though we overflow the padding.
120
121
cache := newParseCache (0 )
121
- _ , err := cache .parseFiles (context .Background (), token .NewFileSet (), ParseFull , false , files ... )
122
+ _ , err := cache .parseFiles (context .Background (), token .NewFileSet (), parsego . Full , false , files ... )
122
123
if err != nil {
123
124
t .Fatal (err )
124
125
}
@@ -136,19 +137,19 @@ func TestParseCache_TimeEviction(t *testing.T) {
136
137
cache := newParseCache (gcDuration )
137
138
cache .stop () // we'll manage GC manually, for testing.
138
139
139
- pgfs0 , err := cache .parseFiles (ctx , fset , ParseFull , false , fh , fh )
140
+ pgfs0 , err := cache .parseFiles (ctx , fset , parsego . Full , false , fh , fh )
140
141
if err != nil {
141
142
t .Fatal (err )
142
143
}
143
144
144
145
files := dummyFileHandles (parseCacheMinFiles )
145
- _ , err = cache .parseFiles (ctx , fset , ParseFull , false , files ... )
146
+ _ , err = cache .parseFiles (ctx , fset , parsego . Full , false , files ... )
146
147
if err != nil {
147
148
t .Fatal (err )
148
149
}
149
150
150
151
// Even after filling up the 'min' files, we get a cache hit for our original file.
151
- pgfs1 , err := cache .parseFiles (ctx , fset , ParseFull , false , fh , fh )
152
+ pgfs1 , err := cache .parseFiles (ctx , fset , parsego . Full , false , fh , fh )
152
153
if err != nil {
153
154
t .Fatal (err )
154
155
}
@@ -158,14 +159,14 @@ func TestParseCache_TimeEviction(t *testing.T) {
158
159
}
159
160
160
161
// But after GC, we get a cache miss.
161
- _ , err = cache .parseFiles (ctx , fset , ParseFull , false , files ... ) // mark dummy files as newer
162
+ _ , err = cache .parseFiles (ctx , fset , parsego . Full , false , files ... ) // mark dummy files as newer
162
163
if err != nil {
163
164
t .Fatal (err )
164
165
}
165
166
time .Sleep (gcDuration )
166
167
cache .gcOnce ()
167
168
168
- pgfs2 , err := cache .parseFiles (ctx , fset , ParseFull , false , fh , fh )
169
+ pgfs2 , err := cache .parseFiles (ctx , fset , parsego . Full , false , fh , fh )
169
170
if err != nil {
170
171
t .Fatal (err )
171
172
}
@@ -183,7 +184,7 @@ func TestParseCache_Duplicates(t *testing.T) {
183
184
fh := makeFakeFileHandle (uri , []byte ("package p\n \n const _ = \" foo\" " ))
184
185
185
186
cache := newParseCache (0 )
186
- pgfs , err := cache .parseFiles (ctx , token .NewFileSet (), ParseFull , false , fh , fh )
187
+ pgfs , err := cache .parseFiles (ctx , token .NewFileSet (), parsego . Full , false , fh , fh )
187
188
if err != nil {
188
189
t .Fatal (err )
189
190
}
0 commit comments