Chromium Code Reviews| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ConstructorDeclaration.java |
| =================================================================== |
| --- editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ConstructorDeclaration.java (revision 15397) |
| +++ editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ConstructorDeclaration.java (working copy) |
| @@ -47,11 +47,16 @@ |
| private Token externalKeyword; |
| /** |
| - * The token for the 'factory' or 'const' keyword. |
| + * The token for the 'const' keyword. |
| */ |
| - private Token keyword; |
| + private Token constKeyword; |
| /** |
| + * The token for the 'factory' keyword. |
| + */ |
| + private Token factoryKeyword; |
| + |
| + /** |
| * The type of object being created. This can be different than the type in which the constructor |
| * is being declared if the constructor is the implementation of a factory constructor. |
| */ |
| @@ -84,6 +89,12 @@ |
| private NodeList<ConstructorInitializer> initializers = new NodeList<ConstructorInitializer>(this); |
| /** |
| + * The name of the constructor to which this constructor will be redirected, or {@code null} if |
| + * this is not a redirecting factory constructor. |
| + */ |
| + private ConstructorName constructorName; |
|
scheglov
2012/11/27 19:00:48
Probably 3 words is too much, but I've thought ini
Brian Wilkerson
2012/11/27 19:16:14
How about "redirectedConstructor"?
scheglov
2012/11/27 19:26:55
LGTM
Brian Wilkerson
2012/11/27 19:44:06
Done
|
| + |
| + /** |
| * The body of the constructor, or {@code null} if the constructor does not have a body. |
| */ |
| private FunctionBody body; |
| @@ -100,28 +111,32 @@ |
| * @param externalKeyword the token for the 'external' keyword |
| * @param comment the documentation comment associated with this constructor |
| * @param metadata the annotations associated with this constructor |
| - * @param keyword the token for the 'factory' or 'const' keyword |
| + * @param constKeyword the token for the 'const' keyword |
| + * @param factoryKeyword the token for the 'factory' keyword |
| * @param returnType the return type of the constructor |
| * @param period the token for the period before the constructor name |
| * @param name the name of the constructor |
| * @param parameters the parameters associated with the constructor |
| * @param colon the token for the colon before the initializers |
| * @param initializers the initializers associated with the constructor |
| + * @param constructorName the name of the constructor to which this constructor will be redirected |
| * @param body the body of the constructor |
| */ |
| public ConstructorDeclaration(Comment comment, List<Annotation> metadata, Token externalKeyword, |
| - Token keyword, Identifier returnType, Token period, SimpleIdentifier name, |
| - FormalParameterList parameters, Token colon, List<ConstructorInitializer> initializers, |
| - FunctionBody body) { |
| + Token constKeyword, Token factoryKeyword, Identifier returnType, Token period, |
| + SimpleIdentifier name, FormalParameterList parameters, Token colon, |
| + List<ConstructorInitializer> initializers, ConstructorName constructorName, FunctionBody body) { |
| super(comment, metadata); |
| this.externalKeyword = externalKeyword; |
| - this.keyword = keyword; |
| + this.constKeyword = constKeyword; |
| + this.factoryKeyword = factoryKeyword; |
| this.returnType = becomeParentOf(returnType); |
| this.period = period; |
| this.name = becomeParentOf(name); |
| this.parameters = becomeParentOf(parameters); |
| this.colon = colon; |
| this.initializers.addAll(initializers); |
| + this.constructorName = becomeParentOf(constructorName); |
| this.body = becomeParentOf(body); |
| } |
| @@ -149,6 +164,25 @@ |
| return colon; |
| } |
| + /** |
| + * Return the token for the 'const' keyword. |
| + * |
| + * @return the token for the 'const' keyword |
| + */ |
| + public Token getConstKeyword() { |
| + return constKeyword; |
| + } |
| + |
| + /** |
| + * Return the name of the constructor to which this constructor will be redirected, or |
| + * {@code null} if this is not a redirecting factory constructor. |
| + * |
| + * @return the name of the constructor to which this constructor will be redirected |
| + */ |
| + public ConstructorName getConstructorName() { |
| + return constructorName; |
| + } |
| + |
| @Override |
| public Token getEndToken() { |
| if (body != null) { |
| @@ -170,21 +204,21 @@ |
| } |
| /** |
| - * Return the initializers associated with the constructor. |
| + * Return the token for the 'factory' keyword. |
| * |
| - * @return the initializers associated with the constructor |
| + * @return the token for the 'factory' keyword |
| */ |
| - public NodeList<ConstructorInitializer> getInitializers() { |
| - return initializers; |
| + public Token getFactoryKeyword() { |
| + return factoryKeyword; |
| } |
| /** |
| - * Return the token for the 'factory' or 'const' keyword. |
| + * Return the initializers associated with the constructor. |
| * |
| - * @return the token for the 'factory' or 'const' keyword |
| + * @return the initializers associated with the constructor |
| */ |
| - public Token getKeyword() { |
| - return keyword; |
| + public NodeList<ConstructorInitializer> getInitializers() { |
| + return initializers; |
| } |
| /** |
| @@ -246,6 +280,25 @@ |
| } |
| /** |
| + * Set the token for the 'const' keyword to the given token. |
| + * |
| + * @param constKeyword the token for the 'const' keyword |
| + */ |
| + public void setConstKeyword(Token constKeyword) { |
| + this.constKeyword = constKeyword; |
| + } |
| + |
| + /** |
| + * Set the name of the constructor to which this constructor will be redirected to the given |
| + * constructor name. |
| + * |
| + * @param constructorName the name of the constructor to which this constructor will be redirected |
| + */ |
| + public void setConstructorName(ConstructorName constructorName) { |
| + this.constructorName = becomeParentOf(constructorName); |
| + } |
| + |
| + /** |
| * Set the token for the 'external' keyword to the given token. |
| * |
| * @param externalKeyword the token for the 'external' keyword |
| @@ -255,12 +308,12 @@ |
| } |
| /** |
| - * Set the token for the 'factory' or 'const' keyword to the given token. |
| + * Set the token for the 'factory' keyword to the given token. |
| * |
| - * @param keyword the token for the 'factory' or 'const' keyword |
| + * @param factoryKeyword the token for the 'factory' keyword |
| */ |
| - public void setKeyword(Token keyword) { |
| - this.keyword = keyword; |
| + public void setFactoryKeyword(Token factoryKeyword) { |
| + this.factoryKeyword = factoryKeyword; |
| } |
| /** |
| @@ -311,8 +364,12 @@ |
| @Override |
| protected Token getFirstTokenAfterCommentAndMetadata() { |
| - if (keyword != null) { |
| - return keyword; |
| + if (externalKeyword != null) { |
|
messick
2012/11/27 18:51:25
Using setters to modify the keywords could invalid
Brian Wilkerson
2012/11/27 19:08:37
I'm not sure I know what you mean, but I'll take a
|
| + return externalKeyword; |
| + } else if (constKeyword != null) { |
| + return constKeyword; |
| + } else if (factoryKeyword != null) { |
| + return factoryKeyword; |
| } |
| return returnType.getBeginToken(); |
| } |