OLD | NEW |
1 // Copyright (c) 2011, 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 | |
8 /** | 7 /** |
9 * Common supertype for most declarations. A declaration introduces a new name | 8 * Common supertype for most declarations. A declaration introduces a new name i
n a scope. Certain |
10 * in a scope. Certain tools, such as the IDE, need to know the location of this | 9 * tools, such as the IDE, need to know the location of this name, but the name
should otherwise be |
11 * name, but the name should otherwise be considered a part of the declaration, | 10 * considered a part of the declaration, not an independent node. So the name is
not visited when |
12 * not an independent node. So the name is not visited when traversing the AST. | 11 * traversing the AST. |
13 */ | 12 */ |
14 public abstract class DartDeclaration<N extends DartExpression> extends DartNode
{ | 13 public abstract class DartDeclaration<N extends DartExpression> extends DartNode
{ |
15 | 14 |
16 private N name; // Not visited. | 15 private N name; // Not visited. |
17 private DartComment dartDoc; | 16 private DartComment dartDoc; |
| 17 private DartMetadata metadata = DartMetadata.EMPTY; |
18 | 18 |
19 protected DartDeclaration(N name) { | 19 protected DartDeclaration(N name) { |
20 this.name = becomeParentOf(name); | 20 this.name = becomeParentOf(name); |
21 } | 21 } |
22 | 22 |
23 public final N getName() { | 23 public final N getName() { |
24 return name; | 24 return name; |
25 } | 25 } |
26 | 26 |
27 public final void setName(N newName) { | 27 public final void setName(N newName) { |
28 name = becomeParentOf(newName); | 28 name = becomeParentOf(newName); |
29 } | 29 } |
30 | 30 |
31 public DartComment getDartDoc() { | 31 public DartComment getDartDoc() { |
32 return dartDoc; | 32 return dartDoc; |
33 } | 33 } |
34 | 34 |
35 public void setDartDoc(DartComment dartDoc) { | 35 public void setDartDoc(DartComment dartDoc) { |
36 // dartDoc is still parented by the containing DartUnit. | 36 // dartDoc is still parented by the containing DartUnit. |
37 this.dartDoc = dartDoc; | 37 this.dartDoc = dartDoc; |
38 } | 38 } |
39 | 39 |
| 40 public DartMetadata getMetadata() { |
| 41 return metadata; |
| 42 } |
| 43 |
| 44 public void setMetadata(DartMetadata metadata) { |
| 45 this.metadata = metadata; |
| 46 } |
| 47 |
40 @Override | 48 @Override |
41 public void visitChildren(ASTVisitor<?> visitor) { | 49 public void visitChildren(ASTVisitor<?> visitor) { |
42 if (name != null) { | 50 if (name != null) { |
43 name.accept(visitor); | 51 name.accept(visitor); |
44 } | 52 } |
45 } | 53 } |
46 } | 54 } |
OLD | NEW |