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 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/src/dart/ast/token.dart'; | 9 import 'package:analyzer/src/dart/ast/token.dart'; |
10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 path = path.replaceAll('/', '.'); | 43 path = path.replaceAll('/', '.'); |
44 // Add separator if needed. | 44 // Add separator if needed. |
45 if (path.isNotEmpty) { | 45 if (path.isNotEmpty) { |
46 path = '.$path'; | 46 path = '.$path'; |
47 } | 47 } |
48 | 48 |
49 return '$packageName$path'; | 49 return '$packageName$path'; |
50 } | 50 } |
51 | 51 |
52 /// Returns `true` if this [fileName] is a Dart file. | 52 /// Returns `true` if this [fileName] is a Dart file. |
| 53 @deprecated // Never intended for public use. |
53 bool isDartFileName(String fileName) => fileName.endsWith('.dart'); | 54 bool isDartFileName(String fileName) => fileName.endsWith('.dart'); |
54 | 55 |
55 /// Returns `true` if this [name] is a legal Dart identifier. | 56 /// Returns `true` if this [name] is a legal Dart identifier. |
| 57 @deprecated // Never intended for public use. |
56 bool isIdentifier(String name) => _identifier.hasMatch(name); | 58 bool isIdentifier(String name) => _identifier.hasMatch(name); |
57 | 59 |
58 /// Returns `true` of the given [name] is composed only of `_`s. | 60 /// Returns `true` of the given [name] is composed only of `_`s. |
| 61 @deprecated // Never intended for public use. |
59 bool isJustUnderscores(String name) => _underscores.hasMatch(name); | 62 bool isJustUnderscores(String name) => _underscores.hasMatch(name); |
60 | 63 |
61 /// Returns `true` if this [id] is `lowerCamelCase`. | 64 /// Returns `true` if this [id] is `lowerCamelCase`. |
| 65 @deprecated // Never intended for public use. |
62 bool isLowerCamelCase(String id) => | 66 bool isLowerCamelCase(String id) => |
63 id.length == 1 && isUpperCase(id.codeUnitAt(0)) || | 67 id.length == 1 && isUpperCase(id.codeUnitAt(0)) || |
64 id == '_' || | 68 id == '_' || |
65 _lowerCamelCase.hasMatch(id); | 69 _lowerCamelCase.hasMatch(id); |
66 | 70 |
67 /// Returns `true` if this [id] is `lower_camel_case_with_underscores`. | 71 /// Returns `true` if this [id] is `lower_camel_case_with_underscores`. |
| 72 @deprecated // Never intended for public use. |
68 bool isLowerCaseUnderScore(String id) => _lowerCaseUnderScore.hasMatch(id); | 73 bool isLowerCaseUnderScore(String id) => _lowerCaseUnderScore.hasMatch(id); |
69 | 74 |
70 /// Returns `true` if this [id] is `lower_camel_case_with_underscores_or.dots`. | 75 /// Returns `true` if this [id] is `lower_camel_case_with_underscores_or.dots`. |
| 76 @deprecated // Never intended for public use. |
71 bool isLowerCaseUnderScoreWithDots(String id) => | 77 bool isLowerCaseUnderScoreWithDots(String id) => |
72 _lowerCaseUnderScoreWithDots.hasMatch(id); | 78 _lowerCaseUnderScoreWithDots.hasMatch(id); |
73 | 79 |
74 /// Returns `true` if this [fileName] is a Pubspec file. | 80 /// Returns `true` if this [fileName] is a Pubspec file. |
| 81 @deprecated // Never intended for public use. |
75 bool isPubspecFileName(String fileName) => _pubspec.hasMatch(fileName); | 82 bool isPubspecFileName(String fileName) => _pubspec.hasMatch(fileName); |
76 | 83 |
77 /// Returns `true` if the given code unit [c] is upper case. | 84 /// Returns `true` if the given code unit [c] is upper case. |
| 85 @deprecated // Never intended for public use. |
78 bool isUpperCase(int c) => c >= 0x40 && c <= 0x5A; | 86 bool isUpperCase(int c) => c >= 0x40 && c <= 0x5A; |
79 | 87 |
80 class Spelunker { | 88 class Spelunker { |
81 final String path; | 89 final String path; |
82 final IOSink sink; | 90 final IOSink sink; |
83 Spelunker(this.path, {IOSink sink}) : this.sink = sink ?? stdout; | 91 Spelunker(this.path, {IOSink sink}) : this.sink = sink ?? stdout; |
84 | 92 |
85 void spelunk() { | 93 void spelunk() { |
86 var contents = new File(path).readAsStringSync(); | 94 var contents = new File(path).readAsStringSync(); |
87 | 95 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 171 |
164 write(AstNode node) { | 172 write(AstNode node) { |
165 //EOL comments | 173 //EOL comments |
166 var comments = getPrecedingComments(node.beginToken); | 174 var comments = getPrecedingComments(node.beginToken); |
167 comments.forEach((c) => sink.writeln('${" " * indent}$c')); | 175 comments.forEach((c) => sink.writeln('${" " * indent}$c')); |
168 | 176 |
169 sink.writeln( | 177 sink.writeln( |
170 '${" " * indent}${asString(node)} ${getTrailingComment(node)}'); | 178 '${" " * indent}${asString(node)} ${getTrailingComment(node)}'); |
171 } | 179 } |
172 } | 180 } |
OLD | NEW |