forked from golang/tools
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor/eg: Add support for multi line after statements to eg.
The semantics of this change are that the last line will be subsituted in place of the expression, where as the lines before that will undergo variable substitution and be prepended before the lowest (in the AST tree sense) statement which included the expression. Change-Id: Ie2571934dcc1b0a30b5cec157e690924a4ac2c5a Reviewed-on: https://go-review.googlesource.com/77730 Reviewed-by: Alan Donovan <adonovan@google.com>
- Loading branch information
Showing
10 changed files
with
211 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// +build ignore | ||
|
||
package templates | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
func before(s string) error { return fmt.Errorf("%s", s) } | ||
func after(s string) error { | ||
n := fmt.Sprintf("error - %s", s) | ||
return errors.New(n) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// +build ignore | ||
|
||
package I1 | ||
|
||
import "fmt" | ||
|
||
func example() { | ||
_ = fmt.Errorf("%s", "foo") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// +build ignore | ||
|
||
package I1 | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
func example() { | ||
|
||
n := fmt.Sprintf("error - %s", "foo") | ||
_ = errors.New(n) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// +build ignore | ||
|
||
package templates | ||
|
||
import () | ||
|
||
func before(x int) int { return x + x + x } | ||
func after(x int) int { | ||
temp := x + x | ||
return temp + x | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// +build ignore | ||
|
||
package I1 | ||
|
||
import "fmt" | ||
|
||
func example() { | ||
temp := 5 | ||
fmt.Print(temp + temp + temp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// +build ignore | ||
|
||
package I1 | ||
|
||
import "fmt" | ||
|
||
func example() { | ||
temp := 5 | ||
temp := temp + temp | ||
fmt.Print(temp + temp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
package template | ||
|
||
const shouldFail = "after: must contain a single statement" | ||
|
||
func before() int { return 0 } | ||
func after() int { println(); return 0 } |