Skip to content

Commit 86f13a9

Browse files
committed
gopls/internal/analysis/gofix: rename local
Trivial: rename a local from fcon (forwardable const) to incon (inlinable const) to match terminology. For golang/go#32816. Change-Id: I7d61f055c7057c30b240c076b8710f47f2bf86d1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/648715 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 5762944 commit 86f13a9

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

gopls/internal/analysis/gofix/gofix.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,15 @@ func run(pass *analysis.Pass) (any, error) {
220220
case *ast.Ident:
221221
// If the identifier is a use of an inlinable constant, suggest inlining it.
222222
if con, ok := pass.TypesInfo.Uses[n].(*types.Const); ok {
223-
fcon, ok := inlinableConsts[con]
223+
incon, ok := inlinableConsts[con]
224224
if !ok {
225225
var fact goFixInlineConstFact
226226
if pass.ImportObjectFact(con, &fact) {
227-
fcon = &fact
228-
inlinableConsts[con] = fcon
227+
incon = &fact
228+
inlinableConsts[con] = incon
229229
}
230230
}
231-
if fcon == nil {
231+
if incon == nil {
232232
continue // nope
233233
}
234234

@@ -248,30 +248,30 @@ func run(pass *analysis.Pass) (any, error) {
248248
// If the RHS is not in the current package, AddImport will handle
249249
// shadowing, so we only need to worry about when both expressions
250250
// are in the current package.
251-
if pass.Pkg.Path() == fcon.RHSPkgPath {
251+
if pass.Pkg.Path() == incon.RHSPkgPath {
252252
// fcon.rhsObj is the object referred to by B in the definition of A.
253253
scope := pass.TypesInfo.Scopes[curFile].Innermost(n.Pos()) // n's scope
254-
_, obj := scope.LookupParent(fcon.RHSName, n.Pos()) // what "B" means in n's scope
254+
_, obj := scope.LookupParent(incon.RHSName, n.Pos()) // what "B" means in n's scope
255255
if obj == nil {
256256
// Should be impossible: if code at n can refer to the LHS,
257257
// it can refer to the RHS.
258-
panic(fmt.Sprintf("no object for inlinable const %s RHS %s", n.Name, fcon.RHSName))
258+
panic(fmt.Sprintf("no object for inlinable const %s RHS %s", n.Name, incon.RHSName))
259259
}
260-
if obj != fcon.rhsObj {
260+
if obj != incon.rhsObj {
261261
// "B" means something different here than at the inlinable const's scope.
262262
continue
263263
}
264-
} else if !analysisinternal.CanImport(pass.Pkg.Path(), fcon.RHSPkgPath) {
264+
} else if !analysisinternal.CanImport(pass.Pkg.Path(), incon.RHSPkgPath) {
265265
// If this package can't see the RHS's package, we can't inline.
266266
continue
267267
}
268268
var (
269269
importPrefix string
270270
edits []analysis.TextEdit
271271
)
272-
if fcon.RHSPkgPath != pass.Pkg.Path() {
272+
if incon.RHSPkgPath != pass.Pkg.Path() {
273273
_, importPrefix, edits = analysisinternal.AddImport(
274-
pass.TypesInfo, curFile, fcon.RHSPkgName, fcon.RHSPkgPath, fcon.RHSName, n.Pos())
274+
pass.TypesInfo, curFile, incon.RHSPkgName, incon.RHSPkgPath, incon.RHSName, n.Pos())
275275
}
276276
var (
277277
pos = n.Pos()
@@ -287,7 +287,7 @@ func run(pass *analysis.Pass) (any, error) {
287287
edits = append(edits, analysis.TextEdit{
288288
Pos: pos,
289289
End: end,
290-
NewText: []byte(importPrefix + fcon.RHSName),
290+
NewText: []byte(importPrefix + incon.RHSName),
291291
})
292292
pass.Report(analysis.Diagnostic{
293293
Pos: pos,

0 commit comments

Comments
 (0)