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

Side by Side Diff: compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java

Issue 11305007: Getter with parameters is error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 package com.google.dart.compiler.ast; 5 package com.google.dart.compiler.ast;
6 6
7 import com.google.dart.compiler.util.TextOutput; 7 import com.google.dart.compiler.util.TextOutput;
8 8
9 import java.util.Iterator; 9 import java.util.Iterator;
10 import java.util.List; 10 import java.util.List;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 273 }
274 // special methods 274 // special methods
275 if (x.getModifiers().isOperator()) { 275 if (x.getModifiers().isOperator()) {
276 p("operator "); 276 p("operator ");
277 } else if (x.getModifiers().isGetter()) { 277 } else if (x.getModifiers().isGetter()) {
278 p("get "); 278 p("get ");
279 } else if (x.getModifiers().isSetter()) { 279 } else if (x.getModifiers().isSetter()) {
280 p("set "); 280 p("set ");
281 } 281 }
282 // name 282 // name
283 pFunctionDeclaration(x.getName(), func); 283 pFunctionDeclaration(x.getName(), func, !x.getModifiers().isGetter());
284 p(" "); 284 p(" ");
285 // initializers 285 // initializers
286 List<DartInitializer> inits = x.getInitializers(); 286 List<DartInitializer> inits = x.getInitializers();
287 if (!inits.isEmpty()) { 287 if (!inits.isEmpty()) {
288 p(": "); 288 p(": ");
289 for (int i = 0; i < inits.size(); ++i) { 289 for (int i = 0; i < inits.size(); ++i) {
290 accept(inits.get(i)); 290 accept(inits.get(i));
291 if (i < inits.size() - 1) { 291 if (i < inits.size() - 1) {
292 p(", "); 292 p(", ");
293 } 293 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 indent(); 331 indent();
332 acceptList(x.getStatements()); 332 acceptList(x.getStatements());
333 outdent(); 333 outdent();
334 334
335 p("}"); 335 p("}");
336 if (newline) { 336 if (newline) {
337 nl(); 337 nl();
338 } 338 }
339 } 339 }
340 340
341 private void pFunctionDeclaration(DartNode name, DartFunction x) { 341 private void pFunctionDeclaration(DartNode name, DartFunction x, boolean inclu deParameters) {
342 if (name != null) { 342 if (name != null) {
343 accept(name); 343 accept(name);
344 } 344 }
345 p("("); 345 if (includeParameters) {
346 pFormalParameters(x.getParameters()); 346 p("(");
347 p(")"); 347 pFormalParameters(x.getParameters());
348 p(")");
349 }
348 } 350 }
349 351
350 private void pFormalParameters(List<DartParameter> params) { 352 private void pFormalParameters(List<DartParameter> params) {
351 boolean first = true, hasNamed = false; 353 boolean first = true, hasNamed = false;
352 for (DartParameter param : params) { 354 for (DartParameter param : params) {
353 if (!first) { 355 if (!first) {
354 p(", "); 356 p(", ");
355 } 357 }
356 if (!hasNamed && param.getModifiers().isNamed()) { 358 if (!hasNamed && param.getModifiers().isNamed()) {
357 hasNamed = true; 359 hasNamed = true;
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } 788 }
787 789
788 @Override 790 @Override
789 public Void visitFunctionExpression(DartFunctionExpression x) { 791 public Void visitFunctionExpression(DartFunctionExpression x) {
790 DartFunction func = x.getFunction(); 792 DartFunction func = x.getFunction();
791 if (func.getReturnTypeNode() != null) { 793 if (func.getReturnTypeNode() != null) {
792 accept(func.getReturnTypeNode()); 794 accept(func.getReturnTypeNode());
793 p(" "); 795 p(" ");
794 } 796 }
795 DartIdentifier name = x.getName(); 797 DartIdentifier name = x.getName();
796 pFunctionDeclaration(name, x.getFunction()); 798 pFunctionDeclaration(name, x.getFunction(), true);
797 p(" "); 799 p(" ");
798 if (x.getFunction().getBody() != null) { 800 if (x.getFunction().getBody() != null) {
799 pBlock(x.getFunction().getBody(), false); 801 pBlock(x.getFunction().getBody(), false);
800 } 802 }
801 return null; 803 return null;
802 } 804 }
803 805
804 @Override 806 @Override
805 public Void visitIdentifier(DartIdentifier x) { 807 public Void visitIdentifier(DartIdentifier x) {
806 p(x.getName()); 808 p(x.getName());
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 } 1024 }
1023 1025
1024 private void indent() { 1026 private void indent() {
1025 out.indentIn(); 1027 out.indentIn();
1026 } 1028 }
1027 1029
1028 private void outdent() { 1030 private void outdent() {
1029 out.indentOut(); 1031 out.indentOut();
1030 } 1032 }
1031 } 1033 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698