| 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. | |
| 54 bool isDartFileName(String fileName) => fileName.endsWith('.dart'); | 53 bool isDartFileName(String fileName) => fileName.endsWith('.dart'); |
| 55 | 54 |
| 56 /// Returns `true` if this [name] is a legal Dart identifier. | 55 /// Returns `true` if this [name] is a legal Dart identifier. |
| 57 @deprecated // Never intended for public use. | 56 @deprecated // Never intended for public use. |
| 58 bool isIdentifier(String name) => _identifier.hasMatch(name); | 57 bool isIdentifier(String name) => _identifier.hasMatch(name); |
| 59 | 58 |
| 60 /// Returns `true` of the given [name] is composed only of `_`s. | 59 /// Returns `true` of the given [name] is composed only of `_`s. |
| 61 @deprecated // Never intended for public use. | 60 @deprecated // Never intended for public use. |
| 62 bool isJustUnderscores(String name) => _underscores.hasMatch(name); | 61 bool isJustUnderscores(String name) => _underscores.hasMatch(name); |
| 63 | 62 |
| 64 /// Returns `true` if this [id] is `lowerCamelCase`. | 63 /// Returns `true` if this [id] is `lowerCamelCase`. |
| 65 @deprecated // Never intended for public use. | 64 @deprecated // Never intended for public use. |
| 66 bool isLowerCamelCase(String id) => | 65 bool isLowerCamelCase(String id) => |
| 67 id.length == 1 && isUpperCase(id.codeUnitAt(0)) || | 66 id.length == 1 && isUpperCase(id.codeUnitAt(0)) || |
| 68 id == '_' || | 67 id == '_' || |
| 69 _lowerCamelCase.hasMatch(id); | 68 _lowerCamelCase.hasMatch(id); |
| 70 | 69 |
| 71 /// Returns `true` if this [id] is `lower_camel_case_with_underscores`. | 70 /// Returns `true` if this [id] is `lower_camel_case_with_underscores`. |
| 72 @deprecated // Never intended for public use. | 71 @deprecated // Never intended for public use. |
| 73 bool isLowerCaseUnderScore(String id) => _lowerCaseUnderScore.hasMatch(id); | 72 bool isLowerCaseUnderScore(String id) => _lowerCaseUnderScore.hasMatch(id); |
| 74 | 73 |
| 75 /// Returns `true` if this [id] is `lower_camel_case_with_underscores_or.dots`. | 74 /// Returns `true` if this [id] is `lower_camel_case_with_underscores_or.dots`. |
| 76 @deprecated // Never intended for public use. | 75 @deprecated // Never intended for public use. |
| 77 bool isLowerCaseUnderScoreWithDots(String id) => | 76 bool isLowerCaseUnderScoreWithDots(String id) => |
| 78 _lowerCaseUnderScoreWithDots.hasMatch(id); | 77 _lowerCaseUnderScoreWithDots.hasMatch(id); |
| 79 | 78 |
| 80 /// Returns `true` if this [fileName] is a Pubspec file. | 79 /// Returns `true` if this [fileName] is a Pubspec file. |
| 81 @deprecated // Never intended for public use. | |
| 82 bool isPubspecFileName(String fileName) => _pubspec.hasMatch(fileName); | 80 bool isPubspecFileName(String fileName) => _pubspec.hasMatch(fileName); |
| 83 | 81 |
| 84 /// Returns `true` if the given code unit [c] is upper case. | 82 /// Returns `true` if the given code unit [c] is upper case. |
| 85 @deprecated // Never intended for public use. | 83 @deprecated // Never intended for public use. |
| 86 bool isUpperCase(int c) => c >= 0x40 && c <= 0x5A; | 84 bool isUpperCase(int c) => c >= 0x40 && c <= 0x5A; |
| 87 | 85 |
| 88 class Spelunker { | 86 class Spelunker { |
| 89 final String path; | 87 final String path; |
| 90 final IOSink sink; | 88 final IOSink sink; |
| 91 Spelunker(this.path, {IOSink sink}) : this.sink = sink ?? stdout; | 89 Spelunker(this.path, {IOSink sink}) : this.sink = sink ?? stdout; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 169 |
| 172 write(AstNode node) { | 170 write(AstNode node) { |
| 173 //EOL comments | 171 //EOL comments |
| 174 var comments = getPrecedingComments(node.beginToken); | 172 var comments = getPrecedingComments(node.beginToken); |
| 175 comments.forEach((c) => sink.writeln('${" " * indent}$c')); | 173 comments.forEach((c) => sink.writeln('${" " * indent}$c')); |
| 176 | 174 |
| 177 sink.writeln( | 175 sink.writeln( |
| 178 '${" " * indent}${asString(node)} ${getTrailingComment(node)}'); | 176 '${" " * indent}${asString(node)} ${getTrailingComment(node)}'); |
| 179 } | 177 } |
| 180 } | 178 } |
| OLD | NEW |