| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library elements.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'elements.dart'; | 7 import 'elements.dart'; |
| 8 import '../helpers/helpers.dart'; | 8 import '../helpers/helpers.dart'; |
| 9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
| 10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 DiagnosticListener, | 21 DiagnosticListener, |
| 22 Script, | 22 Script, |
| 23 FunctionType, | 23 FunctionType, |
| 24 Selector, | 24 Selector, |
| 25 Constant, | 25 Constant, |
| 26 Compiler, | 26 Compiler, |
| 27 isPrivateName; | 27 isPrivateName; |
| 28 | 28 |
| 29 import '../dart_types.dart'; | 29 import '../dart_types.dart'; |
| 30 | 30 |
| 31 import '../scanner/scannerlib.dart' show Token, EOF_TOKEN; | 31 import '../scanner/scannerlib.dart' show |
| 32 EOF_TOKEN, |
| 33 ErrorToken, |
| 34 Token; |
| 32 | 35 |
| 33 import '../ordered_typeset.dart' show OrderedTypeSet; | 36 import '../ordered_typeset.dart' show OrderedTypeSet; |
| 34 | 37 |
| 35 import 'visitor.dart' show ElementVisitor; | 38 import 'visitor.dart' show ElementVisitor; |
| 36 | 39 |
| 37 abstract class ElementX extends Element { | 40 abstract class ElementX extends Element { |
| 38 static int elementHashCode = 0; | 41 static int elementHashCode = 0; |
| 39 | 42 |
| 40 final String name; | 43 final String name; |
| 41 final ElementKind kind; | 44 final ElementKind kind; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 static Token findNameToken(Token token, bool isConstructor, String name, | 148 static Token findNameToken(Token token, bool isConstructor, String name, |
| 146 String enclosingClassName) { | 149 String enclosingClassName) { |
| 147 // We search for the token that has the name of this element. | 150 // We search for the token that has the name of this element. |
| 148 // For constructors, that doesn't work because they may have | 151 // For constructors, that doesn't work because they may have |
| 149 // named formed out of multiple tokens (named constructors) so | 152 // named formed out of multiple tokens (named constructors) so |
| 150 // for those we search for the class name instead. | 153 // for those we search for the class name instead. |
| 151 String needle = isConstructor ? enclosingClassName : name; | 154 String needle = isConstructor ? enclosingClassName : name; |
| 152 // The unary '-' operator has a special element name (specified). | 155 // The unary '-' operator has a special element name (specified). |
| 153 if (needle == 'unary-') needle = '-'; | 156 if (needle == 'unary-') needle = '-'; |
| 154 for (Token t = token; EOF_TOKEN != t.kind; t = t.next) { | 157 for (Token t = token; EOF_TOKEN != t.kind; t = t.next) { |
| 155 if (needle == t.value) return t; | 158 if (t is !ErrorToken && needle == t.value) return t; |
| 156 } | 159 } |
| 157 return token; | 160 return token; |
| 158 } | 161 } |
| 159 | 162 |
| 160 CompilationUnitElement get compilationUnit { | 163 CompilationUnitElement get compilationUnit { |
| 161 Element element = this; | 164 Element element = this; |
| 162 while (!element.isCompilationUnit) { | 165 while (!element.isCompilationUnit) { |
| 163 element = element.enclosingElement; | 166 element = element.enclosingElement; |
| 164 } | 167 } |
| 165 return element; | 168 return element; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 class ErroneousElementX extends ElementX implements ErroneousElement { | 293 class ErroneousElementX extends ElementX implements ErroneousElement { |
| 291 final MessageKind messageKind; | 294 final MessageKind messageKind; |
| 292 final Map messageArguments; | 295 final Map messageArguments; |
| 293 | 296 |
| 294 ErroneousElementX(this.messageKind, this.messageArguments, | 297 ErroneousElementX(this.messageKind, this.messageArguments, |
| 295 String name, Element enclosing) | 298 String name, Element enclosing) |
| 296 : super(name, ElementKind.ERROR, enclosing); | 299 : super(name, ElementKind.ERROR, enclosing); |
| 297 | 300 |
| 298 bool get isErroneous => true; | 301 bool get isErroneous => true; |
| 299 | 302 |
| 303 bool get isSynthesized => true; |
| 304 |
| 300 AbstractFieldElement abstractField; | 305 AbstractFieldElement abstractField; |
| 301 | 306 |
| 302 unsupported() { | 307 unsupported() { |
| 303 throw 'unsupported operation on erroneous element'; | 308 throw 'unsupported operation on erroneous element'; |
| 304 } | 309 } |
| 305 | 310 |
| 306 Link<MetadataAnnotation> get metadata => unsupported(); | 311 Link<MetadataAnnotation> get metadata => unsupported(); |
| 307 get node => unsupported(); | 312 get node => unsupported(); |
| 308 get type => unsupported(); | 313 get type => unsupported(); |
| 309 get cachedNode => unsupported(); | 314 get cachedNode => unsupported(); |
| (...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 assert(invariant(this, this.origin == null, | 2567 assert(invariant(this, this.origin == null, |
| 2563 message: "Origin element is a patch.")); | 2568 message: "Origin element is a patch.")); |
| 2564 assert(invariant(patch, patch.origin == null, | 2569 assert(invariant(patch, patch.origin == null, |
| 2565 message: "Element is patched twice.")); | 2570 message: "Element is patched twice.")); |
| 2566 assert(invariant(patch, patch.patch == null, | 2571 assert(invariant(patch, patch.patch == null, |
| 2567 message: "Patch element is patched.")); | 2572 message: "Patch element is patched.")); |
| 2568 this.patch = patch; | 2573 this.patch = patch; |
| 2569 patch.origin = this; | 2574 patch.origin = this; |
| 2570 } | 2575 } |
| 2571 } | 2576 } |
| OLD | NEW |