forked from bazelbuild/buildtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding `CompactConstantDefinitions` boolean flag to `tables/tables.go`. * Can be set via tables json file (`--add_tables` / `--tables` command line or `tables` / `addTables` json config option). * Updating `compactStmt()` in `build/print.go`. * If `CompactConstantDefinitions` is true and both statements are assignments (for const definitions), then the extra line should be removed. * Lower precedence than various other checks (like comment checks) to still allow extra lines when necessary. * Updating `setFlags()` in `build/print_test.go`. * Checking golden filenames for ".compactconst." to set `CompactConstantDefinitions` to true. * Adding `CompactConstantDefinitions` reset back to false in returned (deferred) func. * Copying various golden files (which contain constant definitions) to be ".compactconst." files. * Removing extra lines between const definitions as applicable. Fixes bazelbuild#108.
- Loading branch information
1 parent
03bf520
commit 895be84
Showing
13 changed files
with
289 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
JAVA_FILES = [ | ||
"Foo.java", | ||
"Bar.java", | ||
"Baz.java", | ||
"Quux.java", | ||
] |
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,7 @@ | ||
JAVA_FILES = [ | ||
# Comment regarding Foo.java | ||
"Foo.java", | ||
"Bar.java", | ||
"Baz.java", # Comment regarding Baz.java | ||
"Quux.java", | ||
] |
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,30 @@ | ||
set = { | ||
1, | ||
2, | ||
3, | ||
} | ||
multiline_set = { | ||
4, | ||
5, | ||
[6], | ||
} | ||
plus = lambda x, y: x + y | ||
two = (lambda x: x(x))(lambda z: lambda y: z)(1)(2)(3) | ||
make_one = lambda: 1 | ||
l = lambda x, y, *args, **kwargs: f( | ||
y, | ||
key = x, | ||
*args, | ||
**kwargs | ||
) | ||
|
||
TriggerActionAfterProbe( | ||
action = lambda State, response: None, | ||
predicate = lambda State, response: all([ | ||
response["request"]["method"] == "GET", | ||
response["request"]["url"].find("/posts/") != -1, | ||
response["request"]["url"].endswith("/comments"), | ||
response["status_code"] in range(200, 299), | ||
]), | ||
probe = ("http", "response"), | ||
) |
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,21 @@ | ||
set = {1, 2, 3} | ||
multiline_set = { | ||
4, | ||
5, | ||
[6], | ||
} | ||
plus = lambda x, y: x + y | ||
two = (lambda x: x(x))(lambda z: lambda y: z)(1)(2)(3) | ||
make_one = lambda: 1 | ||
l = lambda x, y, *args, **kwargs: f(y, key = x, *args, **kwargs) | ||
|
||
TriggerActionAfterProbe( | ||
probe = ("http", "response"), | ||
predicate = lambda State, response: all([ | ||
response["request"]["method"] == "GET", | ||
response["request"]["url"].find("/posts/") != -1, | ||
response["request"]["url"].endswith("/comments"), | ||
response["status_code"] in range(200, 299), | ||
]), | ||
action = lambda State, response: None, | ||
) |
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,37 @@ | ||
# c1 | ||
greeting = "hello " + \ | ||
"world" # c2 | ||
# c3 | ||
|
||
# c4 | ||
greeting = "hello " + \ | ||
"world" # c5 | ||
# c6 | ||
|
||
# c7 | ||
greeting = "hello " + \ | ||
"world" # c8 | ||
# c9 | ||
|
||
# c10 | ||
greeting = ("hello " + # c11 | ||
"world") # c12 | ||
# c13 | ||
|
||
# c14 | ||
greeting = ("hello " + # c15 | ||
"world") # c16 | ||
# c17 | ||
|
||
# c18 | ||
greeting = ("hello" + # c19 | ||
# c20 | ||
"world") # c21 | ||
# c22 | ||
|
||
greeting = "hello " + \ | ||
"world" # c23 | ||
greeting = ("hello " + # c24 | ||
"world") | ||
greeting = ("hello " + # c25 | ||
"world") |
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,12 @@ | ||
bar = "bar" | ||
|
||
# This gets an empty expr_opt in the parser, causing a nil to appear. | ||
b = bar[:-2] | ||
|
||
# Test that slices and partial slices are parsed properly | ||
f = foo[-1:-2:-3] | ||
f = foo[1::] | ||
f = foo[:1:] | ||
f = foo[::1] | ||
f = foo[::] | ||
f = 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,31 @@ | ||
st1 = "abc" | ||
st2 = """ | ||
multiline""" | ||
st3 = ( | ||
"multi" | ||
) | ||
n = 123 | ||
id = a | ||
fct1 = foo(1) | ||
fct2 = foo( | ||
arg = 1, | ||
) | ||
fct3 = ( | ||
foo( | ||
arg = 1, | ||
) | ||
) | ||
|
||
macro( | ||
name = "foo", | ||
arg = ["a"], | ||
) | ||
|
||
nested = 1 | ||
comments = [ | ||
"a", | ||
("b"), # end of line comment | ||
|
||
# before comment | ||
("c"), | ||
] # comment |
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,31 @@ | ||
st1 = ("abc") | ||
st2 = (""" | ||
multiline""") | ||
st3 = ( | ||
"multi" | ||
) | ||
n = (123) | ||
id = (a) | ||
fct1 = (foo(1)) | ||
fct2 = (foo( | ||
arg = 1, | ||
)) | ||
fct3 = ( | ||
foo( | ||
arg = 1, | ||
) | ||
) | ||
|
||
(macro( | ||
name = ("foo"), | ||
arg = ([("a")]), | ||
)) | ||
|
||
nested = (((((1))))) | ||
comments = ([ | ||
"a", | ||
("b"), # end of line comment | ||
|
||
# before comment | ||
("c"), | ||
]) # comment |
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,53 @@ | ||
load( | ||
# A | ||
"foo.bzl", | ||
# B | ||
"bar", | ||
) | ||
load(":a", "b") | ||
|
||
cc_binary( | ||
# A | ||
name = "bin", | ||
# B | ||
srcs = ["bin.cc"], | ||
# C | ||
) | ||
|
||
cc_binary( | ||
name = "wibble", | ||
srcs = ["wibble.cc"], | ||
) | ||
|
||
my_list = [ | ||
1, | ||
# A | ||
2, | ||
# B | ||
] | ||
my_1tuple = ( | ||
# A | ||
1, | ||
# B | ||
) | ||
my_2tuple = ( | ||
# A | ||
1, | ||
# B | ||
2, | ||
# C | ||
) | ||
my_dict = { | ||
"a": 1, | ||
# A | ||
"b": 2, | ||
# B | ||
} | ||
|
||
func(a) | ||
|
||
func(b) | ||
|
||
func(c, d) | ||
|
||
func(e, f) |
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,46 @@ | ||
load( | ||
# A | ||
"foo.bzl", | ||
# B | ||
"bar", | ||
) | ||
load(":a", "b") | ||
|
||
cc_binary( | ||
# A | ||
name = "bin", | ||
# B | ||
srcs = ["bin.cc"], | ||
# C | ||
) | ||
cc_binary(name = "wibble", srcs = ["wibble.cc"]) | ||
|
||
my_list = [ | ||
1, | ||
# A | ||
2, | ||
# B | ||
] | ||
my_1tuple = ( | ||
# A | ||
1, | ||
# B | ||
) | ||
my_2tuple = ( | ||
# A | ||
1, | ||
# B | ||
2, | ||
# C | ||
) | ||
my_dict = { | ||
"a": 1, | ||
# A | ||
"b": 2, | ||
# B | ||
} | ||
|
||
func(a) | ||
func(b) | ||
func(c, d) | ||
func(e, f) |
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