Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java

Issue 11309011: Issue 4289. Separate optional positional and named parameters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java
diff --git a/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java b/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java
index 2d4d80a536a7ff813d670e82ec7b209fbd0475a4..57fd177b9d624022ecbb1a49456769ba759d4853 100644
--- a/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java
+++ b/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java
@@ -255,7 +255,12 @@ public class DartToSourceVisitor extends ASTVisitor<Void> {
p(")");
}
if (x.getDefaultExpr() != null) {
- p(" = ");
+ if (x.getModifiers().isOptional()) {
+ p(" = ");
+ }
+ if (x.getModifiers().isNamed()) {
+ p(" : ");
+ }
accept(x.getDefaultExpr());
}
return null;
@@ -348,21 +353,28 @@ public class DartToSourceVisitor extends ASTVisitor<Void> {
}
private void pFormalParameters(List<DartParameter> params) {
- boolean first = true, hasNamed = false;
+ boolean first = true, hasPositional = false, hasNamed = false;
for (DartParameter param : params) {
if (!first) {
p(", ");
}
+ if (!hasPositional && param.getModifiers().isOptional()) {
+ hasPositional = true;
+ p("[");
+ }
if (!hasNamed && param.getModifiers().isNamed()) {
hasNamed = true;
- p("[");
+ p("{");
}
accept(param);
first = false;
}
- if (hasNamed) {
+ if (hasPositional) {
p("]");
}
+ if (hasNamed) {
+ p("}");
+ }
}
@Override

Powered by Google App Engine
This is Rietveld 408576698