| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index 64cbce1867033ce951f7d42a13c2268382b40c30..e2c839602f37b32f032c86fe00755fe53031bf37 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -4639,200 +4639,6 @@ class PartialResolverVisitor extends ResolverVisitor {
|
| }
|
|
|
| /**
|
| - * Instances of the class `PubVerifier` traverse an AST structure looking for deviations from
|
| - * pub best practices.
|
| - */
|
| -class PubVerifier extends RecursiveAstVisitor<Object> {
|
| -// static String _PUBSPEC_YAML = "pubspec.yaml";
|
| -
|
| - /**
|
| - * The analysis context containing the sources to be analyzed
|
| - */
|
| - final AnalysisContext _context;
|
| -
|
| - /**
|
| - * The error reporter by which errors will be reported.
|
| - */
|
| - final ErrorReporter _errorReporter;
|
| -
|
| - PubVerifier(this._context, this._errorReporter);
|
| -
|
| - @override
|
| - Object visitImportDirective(ImportDirective directive) {
|
| - return null;
|
| - }
|
| -
|
| -// /**
|
| -// * This verifies that the passed file import directive is not contained in a source inside a
|
| -// * package "lib" directory hierarchy referencing a source outside that package "lib" directory
|
| -// * hierarchy.
|
| -// *
|
| -// * @param uriLiteral the import URL (not `null`)
|
| -// * @param path the file path being verified (not `null`)
|
| -// * @return `true` if and only if an error code is generated on the passed node
|
| -// * See [PubSuggestionCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE].
|
| -// */
|
| -// bool
|
| -// _checkForFileImportInsideLibReferencesFileOutside(StringLiteral uriLiteral,
|
| -// String path) {
|
| -// Source source = _getSource(uriLiteral);
|
| -// String fullName = _getSourceFullName(source);
|
| -// if (fullName != null) {
|
| -// int pathIndex = 0;
|
| -// int fullNameIndex = fullName.length;
|
| -// while (pathIndex < path.length &&
|
| -// StringUtilities.startsWith3(path, pathIndex, 0x2E, 0x2E, 0x2F)) {
|
| -// fullNameIndex = JavaString.lastIndexOf(fullName, '/', fullNameIndex);
|
| -// if (fullNameIndex < 4) {
|
| -// return false;
|
| -// }
|
| -// // Check for "/lib" at a specified place in the fullName
|
| -// if (StringUtilities.startsWith4(
|
| -// fullName,
|
| -// fullNameIndex - 4,
|
| -// 0x2F,
|
| -// 0x6C,
|
| -// 0x69,
|
| -// 0x62)) {
|
| -// String relativePubspecPath =
|
| -// path.substring(0, pathIndex + 3) +
|
| -// _PUBSPEC_YAML;
|
| -// Source pubspecSource =
|
| -// _context.sourceFactory.resolveUri(source, relativePubspecPath);
|
| -// if (_context.exists(pubspecSource)) {
|
| -// // Files inside the lib directory hierarchy should not reference
|
| -// // files outside
|
| -// _errorReporter.reportErrorForNode(
|
| -// HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE,
|
| -// uriLiteral);
|
| -// }
|
| -// return true;
|
| -// }
|
| -// pathIndex += 3;
|
| -// }
|
| -// }
|
| -// return false;
|
| -// }
|
| -
|
| -// /**
|
| -// * This verifies that the passed file import directive is not contained in a source outside a
|
| -// * package "lib" directory hierarchy referencing a source inside that package "lib" directory
|
| -// * hierarchy.
|
| -// *
|
| -// * @param uriLiteral the import URL (not `null`)
|
| -// * @param path the file path being verified (not `null`)
|
| -// * @return `true` if and only if an error code is generated on the passed node
|
| -// * See [PubSuggestionCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE].
|
| -// */
|
| -// bool
|
| -// _checkForFileImportOutsideLibReferencesFileInside(StringLiteral uriLiteral,
|
| -// String path) {
|
| -// if (StringUtilities.startsWith4(path, 0, 0x6C, 0x69, 0x62, 0x2F)) {
|
| -// if (_checkForFileImportOutsideLibReferencesFileInsideAtIndex(
|
| -// uriLiteral,
|
| -// path,
|
| -// 0)) {
|
| -// return true;
|
| -// }
|
| -// }
|
| -// int pathIndex =
|
| -// StringUtilities.indexOf5(path, 0, 0x2F, 0x6C, 0x69, 0x62, 0x2F);
|
| -// while (pathIndex != -1) {
|
| -// if (_checkForFileImportOutsideLibReferencesFileInsideAtIndex(
|
| -// uriLiteral,
|
| -// path,
|
| -// pathIndex + 1)) {
|
| -// return true;
|
| -// }
|
| -// pathIndex =
|
| -// StringUtilities.indexOf5(path, pathIndex + 4, 0x2F, 0x6C, 0x69, 0x62, 0x2F);
|
| -// }
|
| -// return false;
|
| -// }
|
| -
|
| -// bool
|
| -// _checkForFileImportOutsideLibReferencesFileInsideAtIndex(StringLiteral uriLiteral,
|
| -// String path, int pathIndex) {
|
| -// Source source = _getSource(uriLiteral);
|
| -// String relativePubspecPath = path.substring(0, pathIndex) + _PUBSPEC_YAML;
|
| -// Source pubspecSource =
|
| -// _context.sourceFactory.resolveUri(source, relativePubspecPath);
|
| -// if (!_context.exists(pubspecSource)) {
|
| -// return false;
|
| -// }
|
| -// String fullName = _getSourceFullName(source);
|
| -// if (fullName != null) {
|
| -// if (StringUtilities.indexOf5(fullName, 0, 0x2F, 0x6C, 0x69, 0x62, 0x2F) <
|
| -// 0) {
|
| -// // Files outside the lib directory hierarchy should not reference files
|
| -// // inside ... use package: url instead
|
| -// _errorReporter.reportErrorForNode(
|
| -// HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE,
|
| -// uriLiteral);
|
| -// return true;
|
| -// }
|
| -// }
|
| -// return false;
|
| -// }
|
| -
|
| -// /**
|
| -// * This verifies that the passed package import directive does not contain ".."
|
| -// *
|
| -// * @param uriLiteral the import URL (not `null`)
|
| -// * @param path the path to be validated (not `null`)
|
| -// * @return `true` if and only if an error code is generated on the passed node
|
| -// * See [PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT].
|
| -// */
|
| -// bool _checkForPackageImportContainsDotDot(StringLiteral uriLiteral,
|
| -// String path) {
|
| -// if (StringUtilities.startsWith3(path, 0, 0x2E, 0x2E, 0x2F) ||
|
| -// StringUtilities.indexOf4(path, 0, 0x2F, 0x2E, 0x2E, 0x2F) >= 0) {
|
| -// // Package import should not to contain ".."
|
| -// _errorReporter.reportErrorForNode(
|
| -// HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT,
|
| -// uriLiteral);
|
| -// return true;
|
| -// }
|
| -// return false;
|
| -// }
|
| -
|
| -// /**
|
| -// * Answer the source associated with the compilation unit containing the given AST node.
|
| -// *
|
| -// * @param node the node (not `null`)
|
| -// * @return the source or `null` if it could not be determined
|
| -// */
|
| -// Source _getSource(AstNode node) {
|
| -// Source source = null;
|
| -// CompilationUnit unit = node.getAncestor((node) => node is CompilationUnit);
|
| -// if (unit != null) {
|
| -// CompilationUnitElement element = unit.element;
|
| -// if (element != null) {
|
| -// source = element.source;
|
| -// }
|
| -// }
|
| -// return source;
|
| -// }
|
| -
|
| -// /**
|
| -// * Answer the full name of the given source. The returned value will have all
|
| -// * [File.separatorChar] replace by '/'.
|
| -// *
|
| -// * @param source the source
|
| -// * @return the full name or `null` if it could not be determined
|
| -// */
|
| -// String _getSourceFullName(Source source) {
|
| -// if (source != null) {
|
| -// String fullName = source.fullName;
|
| -// if (fullName != null) {
|
| -// return fullName.replaceAll(r'\', '/');
|
| -// }
|
| -// }
|
| -// return null;
|
| -// }
|
| -}
|
| -
|
| -/**
|
| * Kind of the redirecting constructor.
|
| */
|
| class RedirectingConstructorKind
|
|
|