@@ -49,7 +49,7 @@ const (
49
49
// Parse parses a buffer of Go source, repairing the tree if necessary.
50
50
//
51
51
// The provided ctx is used only for logging.
52
- func Parse (ctx context.Context , fset * token.FileSet , uri protocol.DocumentURI , src []byte , mode parser.Mode , purgeFuncBodies bool ) (res * File , fixes []fixType ) {
52
+ func Parse (ctx context.Context , fset * token.FileSet , uri protocol.DocumentURI , src []byte , mode parser.Mode , purgeFuncBodies bool ) (res * File , fixes []FixType ) {
53
53
if purgeFuncBodies {
54
54
src = astutil .PurgeFuncBodies (src )
55
55
}
@@ -147,13 +147,13 @@ func Parse(ctx context.Context, fset *token.FileSet, uri protocol.DocumentURI, s
147
147
//
148
148
// If fixAST returns true, the resulting AST is considered "fixed", meaning
149
149
// positions have been mangled, and type checker errors may not make sense.
150
- func fixAST (n ast.Node , tok * token.File , src []byte ) (fixes []fixType ) {
150
+ func fixAST (n ast.Node , tok * token.File , src []byte ) (fixes []FixType ) {
151
151
var err error
152
152
walkASTWithParent (n , func (n , parent ast.Node ) bool {
153
153
switch n := n .(type ) {
154
154
case * ast.BadStmt :
155
155
if fixDeferOrGoStmt (n , parent , tok , src ) {
156
- fixes = append (fixes , fixedDeferOrGo )
156
+ fixes = append (fixes , FixedDeferOrGo )
157
157
// Recursively fix in our fixed node.
158
158
moreFixes := fixAST (parent , tok , src )
159
159
fixes = append (fixes , moreFixes ... )
@@ -163,7 +163,7 @@ func fixAST(n ast.Node, tok *token.File, src []byte) (fixes []fixType) {
163
163
return false
164
164
case * ast.BadExpr :
165
165
if fixArrayType (n , parent , tok , src ) {
166
- fixes = append (fixes , fixedArrayType )
166
+ fixes = append (fixes , FixedArrayType )
167
167
// Recursively fix in our fixed node.
168
168
moreFixes := fixAST (parent , tok , src )
169
169
fixes = append (fixes , moreFixes ... )
@@ -177,7 +177,7 @@ func fixAST(n ast.Node, tok *token.File, src []byte) (fixes []fixType) {
177
177
// for i := foo
178
178
//
179
179
if fixInitStmt (n , parent , tok , src ) {
180
- fixes = append (fixes , fixedInit )
180
+ fixes = append (fixes , FixedInit )
181
181
}
182
182
return false
183
183
case * ast.SelectorExpr :
@@ -186,7 +186,7 @@ func fixAST(n ast.Node, tok *token.File, src []byte) (fixes []fixType) {
186
186
// foo.var<> // want to complete to "foo.variance"
187
187
//
188
188
if fixPhantomSelector (n , tok , src ) {
189
- fixes = append (fixes , fixedPhantomSelector )
189
+ fixes = append (fixes , FixedPhantomSelector )
190
190
}
191
191
return true
192
192
@@ -196,7 +196,7 @@ func fixAST(n ast.Node, tok *token.File, src []byte) (fixes []fixType) {
196
196
// Adjust closing curly brace of empty switch/select
197
197
// statements so we can complete inside them.
198
198
if fixEmptySwitch (n , tok , src ) {
199
- fixes = append (fixes , fixedEmptySwitch )
199
+ fixes = append (fixes , FixedEmptySwitch )
200
200
}
201
201
}
202
202
@@ -235,24 +235,24 @@ func walkASTWithParent(n ast.Node, f func(n ast.Node, parent ast.Node) bool) {
235
235
236
236
// TODO(rfindley): revert this intrumentation once we're certain the crash in
237
237
// #59097 is fixed.
238
- type fixType int
238
+ type FixType int
239
239
240
240
const (
241
- noFix fixType = iota
242
- fixedCurlies
243
- fixedDanglingSelector
244
- fixedDeferOrGo
245
- fixedArrayType
246
- fixedInit
247
- fixedPhantomSelector
248
- fixedEmptySwitch
241
+ noFix FixType = iota
242
+ FixedCurlies
243
+ FixedDanglingSelector
244
+ FixedDeferOrGo
245
+ FixedArrayType
246
+ FixedInit
247
+ FixedPhantomSelector
248
+ FixedEmptySwitch
249
249
)
250
250
251
251
// fixSrc attempts to modify the file's source code to fix certain
252
252
// syntax errors that leave the rest of the file unparsed.
253
253
//
254
254
// fixSrc returns a non-nil result if and only if a fix was applied.
255
- func fixSrc (f * ast.File , tf * token.File , src []byte ) (newSrc []byte , fix fixType ) {
255
+ func fixSrc (f * ast.File , tf * token.File , src []byte ) (newSrc []byte , fix FixType ) {
256
256
walkASTWithParent (f , func (n , parent ast.Node ) bool {
257
257
if newSrc != nil {
258
258
return false
@@ -262,12 +262,12 @@ func fixSrc(f *ast.File, tf *token.File, src []byte) (newSrc []byte, fix fixType
262
262
case * ast.BlockStmt :
263
263
newSrc = fixMissingCurlies (f , n , parent , tf , src )
264
264
if newSrc != nil {
265
- fix = fixedCurlies
265
+ fix = FixedCurlies
266
266
}
267
267
case * ast.SelectorExpr :
268
268
newSrc = fixDanglingSelector (n , tf , src )
269
269
if newSrc != nil {
270
- fix = fixedDanglingSelector
270
+ fix = FixedDanglingSelector
271
271
}
272
272
}
273
273
0 commit comments