| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.runner.parse_metadata; | 5 library test.runner.parse_metadata; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 /// Parses a `@Tags` annotation. | 171 /// Parses a `@Tags` annotation. |
| 172 /// | 172 /// |
| 173 /// [annotation] is the annotation. [constructorName] is the name of the named | 173 /// [annotation] is the annotation. [constructorName] is the name of the named |
| 174 /// constructor for the annotation, if any. | 174 /// constructor for the annotation, if any. |
| 175 Set<String> _parseTags(Annotation annotation, String constructorName) { | 175 Set<String> _parseTags(Annotation annotation, String constructorName) { |
| 176 _assertConstructorName(constructorName, 'Tags', annotation); | 176 _assertConstructorName(constructorName, 'Tags', annotation); |
| 177 _assertArguments(annotation.arguments, 'Tags', annotation, positional: 1); | 177 _assertArguments(annotation.arguments, 'Tags', annotation, positional: 1); |
| 178 | 178 |
| 179 return _parseList(annotation.arguments.arguments.first) | 179 return _parseList(annotation.arguments.arguments.first).map((tagExpression)
{ |
| 180 .map((tagExpression) => _parseString(tagExpression).stringValue) | 180 var name = _parseString(tagExpression).stringValue; |
| 181 .toSet(); | 181 if (name.contains(anchoredHyphenatedIdentifier)) return name; |
| 182 |
| 183 throw new SourceSpanFormatException( |
| 184 "Invalid tag name. Tags must be (optionally hyphenated) Dart " |
| 185 "identifiers.", |
| 186 _spanFor(tagExpression)); |
| 187 }).toSet(); |
| 182 } | 188 } |
| 183 | 189 |
| 184 /// Parses an `@OnPlatform` annotation. | 190 /// Parses an `@OnPlatform` annotation. |
| 185 /// | 191 /// |
| 186 /// [annotation] is the annotation. [constructorName] is the name of the named | 192 /// [annotation] is the annotation. [constructorName] is the name of the named |
| 187 /// constructor for the annotation, if any. | 193 /// constructor for the annotation, if any. |
| 188 Map<PlatformSelector, Metadata> _parseOnPlatform(Annotation annotation, | 194 Map<PlatformSelector, Metadata> _parseOnPlatform(Annotation annotation, |
| 189 String constructorName) { | 195 String constructorName) { |
| 190 _assertConstructorName(constructorName, 'OnPlatform', annotation); | 196 _assertConstructorName(constructorName, 'OnPlatform', annotation); |
| 191 _assertArguments(annotation.arguments, 'OnPlatform', annotation, | 197 _assertArguments(annotation.arguments, 'OnPlatform', annotation, |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 return fn(); | 535 return fn(); |
| 530 } on SourceSpanFormatException catch (error) { | 536 } on SourceSpanFormatException catch (error) { |
| 531 var file = new SourceFile(new File(_path).readAsStringSync(), | 537 var file = new SourceFile(new File(_path).readAsStringSync(), |
| 532 url: p.toUri(_path)); | 538 url: p.toUri(_path)); |
| 533 var span = contextualizeSpan(error.span, literal, file); | 539 var span = contextualizeSpan(error.span, literal, file); |
| 534 if (span == null) rethrow; | 540 if (span == null) rethrow; |
| 535 throw new SourceSpanFormatException(error.message, span); | 541 throw new SourceSpanFormatException(error.message, span); |
| 536 } | 542 } |
| 537 } | 543 } |
| 538 } | 544 } |
| OLD | NEW |