| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class ClassElementParser extends PartialParser { | 5 class ClassElementParser extends PartialParser { |
| 6 ClassElementParser(Listener listener) : super(listener); | 6 ClassElementParser(Listener listener) : super(listener); |
| 7 | 7 |
| 8 Token parseClassBody(Token token) => fullParseClassBody(token); | 8 Token parseClassBody(Token token) => fullParseClassBody(token); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 bool isConstructor(Identifier name) { | 41 bool isConstructor(Identifier name) { |
| 42 return enclosingElement !== null && | 42 return enclosingElement !== null && |
| 43 enclosingElement.kind == ElementKind.CLASS && | 43 enclosingElement.kind == ElementKind.CLASS && |
| 44 enclosingElement.name == name.source; | 44 enclosingElement.name == name.source; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void endMethod(Token beginToken, Token endToken) { | 47 void endMethod(Token beginToken, Token endToken) { |
| 48 super.endMethod(beginToken, endToken); | 48 super.endMethod(beginToken, endToken); |
| 49 FunctionExpression method = popNode(); | 49 FunctionExpression method = popNode(); |
| 50 pushNode(null); | 50 pushNode(null); |
| 51 Identifier name = method.name; // TODO(ahe): Named constructors. | 51 Expression qualified = method.name; |
| 52 Identifier name = qualified.asIdentifier(); |
| 53 if (name === null) { |
| 54 canceler.cancel('qualified names are not implemented', node: qualified); |
| 55 } |
| 52 ElementKind kind = isConstructor(name) ? | 56 ElementKind kind = isConstructor(name) ? |
| 53 ElementKind.GENERATIVE_CONSTRUCTOR : | 57 ElementKind.GENERATIVE_CONSTRUCTOR : |
| 54 ElementKind.FUNCTION; | 58 ElementKind.FUNCTION; |
| 55 Element memberElement = | 59 Element memberElement = |
| 56 new PartialFunctionElement(name.source, beginToken, endToken, | 60 new PartialFunctionElement(name.source, beginToken, endToken, |
| 57 kind, method.modifiers, enclosingElement); | 61 kind, method.modifiers, enclosingElement); |
| 58 enclosingElement.addMember(memberElement); | 62 enclosingElement.addMember(memberElement); |
| 59 } | 63 } |
| 60 | 64 |
| 61 void endFactoryMethod(Token factoryKeyword, Token periodBeforeName, | 65 void endFactoryMethod(Token factoryKeyword, Token periodBeforeName, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 new PartialFunctionElement(name.source, factoryKeyword, endToken, kind, | 77 new PartialFunctionElement(name.source, factoryKeyword, endToken, kind, |
| 74 method.modifiers, enclosingElement); | 78 method.modifiers, enclosingElement); |
| 75 enclosingElement.addMember(memberElement); | 79 enclosingElement.addMember(memberElement); |
| 76 } | 80 } |
| 77 | 81 |
| 78 void endFields(int count, Token beginToken, Token endToken) { | 82 void endFields(int count, Token beginToken, Token endToken) { |
| 79 super.endFields(count, beginToken, endToken); | 83 super.endFields(count, beginToken, endToken); |
| 80 VariableDefinitions variableDefinitions = popNode(); | 84 VariableDefinitions variableDefinitions = popNode(); |
| 81 Modifiers modifiers = variableDefinitions.modifiers; | 85 Modifiers modifiers = variableDefinitions.modifiers; |
| 82 pushNode(null); | 86 pushNode(null); |
| 83 void buildFieldElement(SourceString name, Node node, Element fields) { | 87 void buildFieldElement(SourceString name, Element fields) { |
| 84 Element element = new VariableElement( | 88 Element element = new VariableElement( |
| 85 name, node, fields, ElementKind.FIELD, enclosingElement); | 89 name, fields, ElementKind.FIELD, enclosingElement); |
| 86 enclosingElement.addMember(element); | 90 enclosingElement.addMember(element); |
| 87 } | 91 } |
| 88 buildFieldElements(modifiers, variableDefinitions.definitions, | 92 buildFieldElements(modifiers, variableDefinitions.definitions, |
| 89 buildFieldElement, beginToken, endToken); | 93 buildFieldElement, beginToken, endToken); |
| 90 } | 94 } |
| 91 | 95 |
| 92 void endInitializer(Token assignmentOperator) { | 96 void endInitializer(Token assignmentOperator) { |
| 93 // TODO(floitsch): Remove this cancel. | |
| 94 canceler.cancel("field initializers are not implemented", | |
| 95 token: assignmentOperator); | |
| 96 pushNode(null); // Super expects an expression, but | 97 pushNode(null); // Super expects an expression, but |
| 97 // ClassElementParser just skips expressions. | 98 // ClassElementParser just skips expressions. |
| 98 super.endInitializer(assignmentOperator); | 99 super.endInitializer(assignmentOperator); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void endInitializers(int count, Token beginToken, Token endToken) { | 102 void endInitializers(int count, Token beginToken, Token endToken) { |
| 102 pushNode(null); | 103 pushNode(null); |
| 103 } | 104 } |
| 104 } | 105 } |
| OLD | NEW |