OLD | NEW |
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.parser; | 5 package com.google.dart.compiler.parser; |
6 | 6 |
7 import com.google.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
8 import com.google.common.collect.ImmutableSet; | 8 import com.google.common.collect.ImmutableSet; |
9 import com.google.common.io.CharStreams; | 9 import com.google.common.io.CharStreams; |
10 import com.google.dart.compiler.DartCompilationError; | 10 import com.google.dart.compiler.DartCompilationError; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 import com.google.dart.compiler.ast.DartTryStatement; | 89 import com.google.dart.compiler.ast.DartTryStatement; |
90 import com.google.dart.compiler.ast.DartTypeExpression; | 90 import com.google.dart.compiler.ast.DartTypeExpression; |
91 import com.google.dart.compiler.ast.DartTypeNode; | 91 import com.google.dart.compiler.ast.DartTypeNode; |
92 import com.google.dart.compiler.ast.DartTypeParameter; | 92 import com.google.dart.compiler.ast.DartTypeParameter; |
93 import com.google.dart.compiler.ast.DartUnaryExpression; | 93 import com.google.dart.compiler.ast.DartUnaryExpression; |
94 import com.google.dart.compiler.ast.DartUnit; | 94 import com.google.dart.compiler.ast.DartUnit; |
95 import com.google.dart.compiler.ast.DartUnqualifiedInvocation; | 95 import com.google.dart.compiler.ast.DartUnqualifiedInvocation; |
96 import com.google.dart.compiler.ast.DartVariable; | 96 import com.google.dart.compiler.ast.DartVariable; |
97 import com.google.dart.compiler.ast.DartVariableStatement; | 97 import com.google.dart.compiler.ast.DartVariableStatement; |
98 import com.google.dart.compiler.ast.DartWhileStatement; | 98 import com.google.dart.compiler.ast.DartWhileStatement; |
| 99 import com.google.dart.compiler.ast.HasObsoleteMetadata; |
99 import com.google.dart.compiler.ast.ImportCombinator; | 100 import com.google.dart.compiler.ast.ImportCombinator; |
100 import com.google.dart.compiler.ast.ImportHideCombinator; | 101 import com.google.dart.compiler.ast.ImportHideCombinator; |
101 import com.google.dart.compiler.ast.ImportShowCombinator; | 102 import com.google.dart.compiler.ast.ImportShowCombinator; |
102 import com.google.dart.compiler.ast.LibraryNode; | 103 import com.google.dart.compiler.ast.LibraryNode; |
103 import com.google.dart.compiler.ast.LibraryUnit; | 104 import com.google.dart.compiler.ast.LibraryUnit; |
104 import com.google.dart.compiler.ast.Modifiers; | 105 import com.google.dart.compiler.ast.Modifiers; |
105 import com.google.dart.compiler.metrics.CompilerMetrics; | 106 import com.google.dart.compiler.metrics.CompilerMetrics; |
106 import com.google.dart.compiler.parser.DartScanner.Location; | 107 import com.google.dart.compiler.parser.DartScanner.Location; |
107 import com.google.dart.compiler.resolver.Elements; | 108 import com.google.dart.compiler.resolver.Elements; |
108 import com.google.dart.compiler.util.Lists; | 109 import com.google.dart.compiler.util.Lists; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 381 |
381 /** | 382 /** |
382 * Set the metadata associated with the given node to the given annotations. | 383 * Set the metadata associated with the given node to the given annotations. |
383 * | 384 * |
384 * @param node the node with which the metadata is to be associated | 385 * @param node the node with which the metadata is to be associated |
385 * @param metadata the metadata to be associated with the node | 386 * @param metadata the metadata to be associated with the node |
386 */ | 387 */ |
387 private void setMetadata(DartNodeWithMetadata node, List<DartAnnotation> annot
ations) { | 388 private void setMetadata(DartNodeWithMetadata node, List<DartAnnotation> annot
ations) { |
388 if (annotations != null && !annotations.isEmpty()) { | 389 if (annotations != null && !annotations.isEmpty()) { |
389 node.setMetadata(annotations); | 390 node.setMetadata(annotations); |
390 if (node instanceof DartDeclaration<?>) { | 391 if (node instanceof HasObsoleteMetadata) { |
| 392 HasObsoleteMetadata declaration = (HasObsoleteMetadata) node; |
391 for (int i = 0, size = annotations.size(); i < size; i++) { | 393 for (int i = 0, size = annotations.size(); i < size; i++) { |
392 DartAnnotation annotation = annotations.get(i); | 394 DartAnnotation annotation = annotations.get(i); |
393 DartExpression nameNode = annotation.getName(); | 395 DartExpression nameNode = annotation.getName(); |
394 if (nameNode instanceof DartIdentifier) { | 396 if (nameNode instanceof DartIdentifier) { |
395 String name = ((DartIdentifier) nameNode).getName(); | 397 String name = ((DartIdentifier) nameNode).getName(); |
396 if (name.equals("deprecated")) { | 398 if (name.equals("deprecated")) { |
397 DartDeclaration<?> declaration = (DartDeclaration<?>) node; | |
398 declaration.setObsoleteMetadata(declaration.getObsoleteMetadata().
makeDeprecated()); | 399 declaration.setObsoleteMetadata(declaration.getObsoleteMetadata().
makeDeprecated()); |
399 } else if (name.equals("override")) { | 400 } else if (name.equals("override")) { |
400 DartDeclaration<?> declaration = (DartDeclaration<?>) node; | |
401 declaration.setObsoleteMetadata(declaration.getObsoleteMetadata().
makeOverride()); | 401 declaration.setObsoleteMetadata(declaration.getObsoleteMetadata().
makeOverride()); |
402 } | 402 } |
403 } | 403 } |
404 } | 404 } |
405 } | 405 } |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 private boolean looksLikeDirective() { | 409 private boolean looksLikeDirective() { |
410 switch(peek(0)) { | 410 switch(peek(0)) { |
(...skipping 5025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5436 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen
ts) { | 5436 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen
ts) { |
5437 if (node != null) { | 5437 if (node != null) { |
5438 reportError(new DartCompilationError(node, errorCode, arguments)); | 5438 reportError(new DartCompilationError(node, errorCode, arguments)); |
5439 } | 5439 } |
5440 } | 5440 } |
5441 | 5441 |
5442 private boolean currentlyParsingToplevel() { | 5442 private boolean currentlyParsingToplevel() { |
5443 return !(isParsingInterface || isTopLevelAbstract || isParsingClass); | 5443 return !(isParsingInterface || isTopLevelAbstract || isParsingClass); |
5444 } | 5444 } |
5445 } | 5445 } |
OLD | NEW |