File tree 2 files changed +21
-3
lines changed
test/marker/testdata/rename
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -866,9 +866,17 @@ func (r *renamer) satisfy() map[satisfy.Constraint]bool {
866
866
//
867
867
// Only proceed if all packages have no errors.
868
868
if len (pkg .ParseErrors ()) > 0 || len (pkg .TypeErrors ()) > 0 {
869
+ var filename string
870
+ if len (pkg .ParseErrors ()) > 0 {
871
+ err := pkg .ParseErrors ()[0 ][0 ]
872
+ filename = filepath .Base (err .Pos .Filename )
873
+ } else if len (pkg .TypeErrors ()) > 0 {
874
+ err := pkg .TypeErrors ()[0 ]
875
+ filename = filepath .Base (err .Fset .File (err .Pos ).Name ())
876
+ }
869
877
r .errorf (token .NoPos , // we don't have a position for this error.
870
- "renaming %q to %q not possible because %q has errors" ,
871
- r .from , r .to , pkg .Metadata ().PkgPath )
878
+ "renaming %q to %q not possible because %q in %q has errors" ,
879
+ r .from , r .to , filename , pkg .Metadata ().PkgPath )
872
880
return nil
873
881
}
874
882
f .Find (pkg .TypesInfo (), pkg .Syntax ())
Original file line number Diff line number Diff line change @@ -11,9 +11,19 @@ package bad
11
11
type myStruct struct {
12
12
}
13
13
14
- func (s *myStruct) sFunc() bool { //@renameerr("sFunc", "rFunc", re "not possible")
14
+ func (s *myStruct) sFunc() bool { //@renameerr("sFunc", "rFunc", "not possible because \"bad.go\" in \"golang.org/lsptests/bad\" has errors ")
15
15
return s.Bad //@diag("Bad", re"no field or method")
16
16
}
17
17
18
18
-- bad_test.go --
19
19
package bad
20
+
21
+
22
+ -- badsyntax/badsyntax.go --
23
+ package badsyntax
24
+
25
+ type S struct {}
26
+
27
+ func (s *S) sFunc() bool { //@renameerr("sFunc", "rFunc", "not possible because \"badsyntax.go\" in \"golang.org/lsptests/bad/badsyntax\" has errors")
28
+ # //@diag("#", re"expected statement, found")
29
+ }
You can’t perform that action at this time.
0 commit comments