Merge remote-tracking branch 'aosp/upstream' into master
* aosp/upstream:
Improve indentation for multi-line expressions
Disable parallel compilation when using race detector
Return an error when renaming a module that doesn't exist
Test: m blueprint_tools
Change-Id: I5446f0c6903895deca541f1ffad88051698998e1
diff --git a/microfactory/microfactory.go b/microfactory/microfactory.go
index 845238b..a70d3c5 100644
--- a/microfactory/microfactory.go
+++ b/microfactory/microfactory.go
@@ -400,7 +400,7 @@
"-o", p.output,
"-p", p.Name,
"-complete", "-pack", "-nolocalimports")
- if !isGo18 {
+ if !isGo18 && !config.Race {
cmd.Args = append(cmd.Args, "-c", fmt.Sprintf("%d", runtime.NumCPU()))
}
if config.Race {
diff --git a/name_interface.go b/name_interface.go
index 6743f0c..1849e9d 100644
--- a/name_interface.go
+++ b/name_interface.go
@@ -126,20 +126,22 @@
func (s *SimpleNameInterface) Rename(oldName string, newName string, namespace Namespace) (errs []error) {
existingGroup, exists := s.modules[newName]
if exists {
- errs = append(errs,
+ return []error{
// seven characters at the start of the second line to align with the string "error: "
fmt.Errorf("renaming module %q to %q conflicts with existing module\n"+
" %s <-- existing module defined here",
oldName, newName, existingGroup.modules[0].pos),
- )
- return errs
+ }
}
- group := s.modules[oldName]
+ group, exists := s.modules[oldName]
+ if !exists {
+ return []error{fmt.Errorf("module %q to renamed to %q doesn't exist", oldName, newName)}
+ }
s.modules[newName] = group
delete(s.modules, group.name)
group.name = newName
- return []error{}
+ return nil
}
func (s *SimpleNameInterface) AllModules() []ModuleGroup {
diff --git a/parser/printer.go b/parser/printer.go
index d3aad4a..ac7ffe1 100644
--- a/parser/printer.go
+++ b/parser/printer.go
@@ -173,15 +173,34 @@
}
func (p *printer) printOperator(operator *Operator) {
+ p.printOperatorInternal(operator, true)
+}
+
+func (p *printer) printOperatorInternal(operator *Operator, allowIndent bool) {
p.printExpression(operator.Args[0])
p.requestSpace()
p.printToken(string(operator.Operator), operator.OperatorPos)
+
+ indented := false
if operator.Args[0].End().Line == operator.Args[1].Pos().Line {
p.requestSpace()
} else {
+ if allowIndent {
+ indented = true
+ p.indent(p.curIndent() + 4)
+ }
p.requestNewline()
}
- p.printExpression(operator.Args[1])
+
+ if op, isOp := operator.Args[1].(*Operator); isOp {
+ p.printOperatorInternal(op, false)
+ } else {
+ p.printExpression(operator.Args[1])
+ }
+
+ if indented {
+ p.unindent(p.pos)
+ }
}
func (p *printer) printProperty(property *Property) {
diff --git a/parser/printer_test.go b/parser/printer_test.go
index a223fab..7289441 100644
--- a/parser/printer_test.go
+++ b/parser/printer_test.go
@@ -166,6 +166,22 @@
},
{
input: `
+foo {
+ bar: "b" +
+ "a" +
+ "z",
+}
+`,
+ output: `
+foo {
+ bar: "b" +
+ "a" +
+ "z",
+}
+`,
+ },
+ {
+ input: `
foo = "stuff"
bar = foo
baz = foo + bar
@@ -194,6 +210,18 @@
},
{
input: `
+foo = "bar " +
+ "" +
+ "baz"
+`,
+ output: `
+foo = "bar " +
+ "" +
+ "baz"
+`,
+ },
+ {
+ input: `
//test
test /* test */ {
srcs: [