LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "exec" | 9 "exec" |
10 "flag" | 10 "flag" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 file, err := parser.ParseFile(fset, filename, src, parserMode) | 117 file, err := parser.ParseFile(fset, filename, src, parserMode) |
118 if err != nil { | 118 if err != nil { |
119 return err | 119 return err |
120 } | 120 } |
121 | 121 |
122 // Apply all fixes to file. | 122 // Apply all fixes to file. |
123 newFile := file | 123 newFile := file |
124 fixed := false | 124 fixed := false |
125 for _, fix := range fixes { | 125 for _, fix := range fixes { |
126 » » if allowed != nil && !allowed[fix.desc] { | 126 » » if allowed != nil && !allowed[fix.name] { |
127 continue | 127 continue |
128 } | 128 } |
129 if fix.f(newFile) { | 129 if fix.f(newFile) { |
130 fixed = true | 130 fixed = true |
131 fmt.Fprintf(&fixlog, " %s", fix.name) | 131 fmt.Fprintf(&fixlog, " %s", fix.name) |
132 | 132 |
133 // AST changed. | 133 // AST changed. |
134 // Print and parse, to update any missing scoping | 134 // Print and parse, to update any missing scoping |
135 // or position information for subsequent fixers. | 135 // or position information for subsequent fixers. |
136 buf.Reset() | 136 buf.Reset() |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 f2.Write(b2) | 249 f2.Write(b2) |
250 | 250 |
251 data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOut
put() | 251 data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOut
put() |
252 if len(data) > 0 { | 252 if len(data) > 0 { |
253 // diff exits with a non-zero status when the files don't match. | 253 // diff exits with a non-zero status when the files don't match. |
254 // Ignore that failure as long as we get output. | 254 // Ignore that failure as long as we get output. |
255 err = nil | 255 err = nil |
256 } | 256 } |
257 return | 257 return |
258 } | 258 } |
LEFT | RIGHT |