| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:analyzer/context/context_root.dart'; | 9 import 'package:analyzer/context/context_root.dart'; |
| 10 import 'package:analyzer/context/declared_variables.dart'; | 10 import 'package:analyzer/context/declared_variables.dart'; |
| 11 import 'package:analyzer/dart/ast/ast.dart'; | 11 import 'package:analyzer/dart/ast/ast.dart'; |
| 12 import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement; | 12 import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement; |
| 13 import 'package:analyzer/error/error.dart'; | 13 import 'package:analyzer/error/error.dart'; |
| 14 import 'package:analyzer/error/listener.dart'; | 14 import 'package:analyzer/error/listener.dart'; |
| 15 import 'package:analyzer/exception/exception.dart'; | 15 import 'package:analyzer/exception/exception.dart'; |
| 16 import 'package:analyzer/file_system/file_system.dart'; | 16 import 'package:analyzer/file_system/file_system.dart'; |
| 17 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 17 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
| 18 import 'package:analyzer/src/dart/analysis/file_state.dart'; | 18 import 'package:analyzer/src/dart/analysis/file_state.dart'; |
| 19 import 'package:analyzer/src/dart/analysis/file_tracker.dart'; | 19 import 'package:analyzer/src/dart/analysis/file_tracker.dart'; |
| 20 import 'package:analyzer/src/dart/analysis/index.dart'; | 20 import 'package:analyzer/src/dart/analysis/index.dart'; |
| 21 import 'package:analyzer/src/dart/analysis/library_analyzer.dart'; | 21 import 'package:analyzer/src/dart/analysis/library_analyzer.dart'; |
| 22 import 'package:analyzer/src/dart/analysis/library_context.dart'; | 22 import 'package:analyzer/src/dart/analysis/library_context.dart'; |
| 23 import 'package:analyzer/src/dart/analysis/search.dart'; | 23 import 'package:analyzer/src/dart/analysis/search.dart'; |
| 24 import 'package:analyzer/src/dart/analysis/status.dart'; | 24 import 'package:analyzer/src/dart/analysis/status.dart'; |
| 25 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; | 25 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; |
| 26 import 'package:analyzer/src/generated/engine.dart' | 26 import 'package:analyzer/src/generated/engine.dart' |
| 27 show AnalysisContext, AnalysisEngine, AnalysisOptions; | 27 show AnalysisContext, AnalysisEngine, AnalysisOptions; |
| 28 import 'package:analyzer/src/generated/source.dart'; | 28 import 'package:analyzer/src/generated/source.dart'; |
| 29 import 'package:analyzer/src/services/lint.dart'; | 29 import 'package:analyzer/src/lint/registry.dart' as linter; |
| 30 import 'package:analyzer/src/summary/api_signature.dart'; | 30 import 'package:analyzer/src/summary/api_signature.dart'; |
| 31 import 'package:analyzer/src/summary/format.dart'; | 31 import 'package:analyzer/src/summary/format.dart'; |
| 32 import 'package:analyzer/src/summary/idl.dart'; | 32 import 'package:analyzer/src/summary/idl.dart'; |
| 33 import 'package:meta/meta.dart'; | 33 import 'package:meta/meta.dart'; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * This class computes [AnalysisResult]s for Dart files. | 36 * This class computes [AnalysisResult]s for Dart files. |
| 37 * | 37 * |
| 38 * Let the set of "explicitly analyzed files" denote the set of paths that have | 38 * Let the set of "explicitly analyzed files" denote the set of paths that have |
| 39 * been passed to [addFile] but not subsequently passed to [removeFile]. Let | 39 * been passed to [addFile] but not subsequently passed to [removeFile]. Let |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 String _getResolvedUnitSignature(FileState library, FileState file) { | 1169 String _getResolvedUnitSignature(FileState library, FileState file) { |
| 1170 ApiSignature signature = new ApiSignature(); | 1170 ApiSignature signature = new ApiSignature(); |
| 1171 signature.addUint32List(_salt); | 1171 signature.addUint32List(_salt); |
| 1172 signature.addString(library.transitiveSignature); | 1172 signature.addString(library.transitiveSignature); |
| 1173 signature.addString(file.contentHash); | 1173 signature.addString(file.contentHash); |
| 1174 return signature.toHex(); | 1174 return signature.toHex(); |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 /** | 1177 /** |
| 1178 * Return the lint code with the given [errorName], or `null` if there is no | 1178 * Return the lint code with the given [errorName], or `null` if there is no |
| 1179 * lint registered with that name or the lint is not enabled in the analysis | 1179 * lint registered with that name. |
| 1180 * options. | |
| 1181 */ | 1180 */ |
| 1182 ErrorCode _lintCodeByUniqueName(String errorName) { | 1181 ErrorCode _lintCodeByUniqueName(String errorName) { |
| 1183 if (errorName.startsWith('_LintCode.')) { | 1182 const String lintPrefix = 'LintCode.'; |
| 1184 String lintName = errorName.substring(10); | 1183 if (errorName.startsWith(lintPrefix)) { |
| 1185 List<Linter> lintRules = _analysisOptions.lintRules; | 1184 String lintName = errorName.substring(lintPrefix.length); |
| 1186 for (Linter linter in lintRules) { | 1185 return linter.Registry.ruleRegistry.getRule(lintName)?.lintCode; |
| 1187 if (linter.name == lintName) { | |
| 1188 return linter.lintCode; | |
| 1189 } | |
| 1190 } | |
| 1191 } | 1186 } |
| 1187 |
| 1188 const String lintPrefixOld = '_LintCode.'; |
| 1189 if (errorName.startsWith(lintPrefixOld)) { |
| 1190 String lintName = errorName.substring(lintPrefixOld.length); |
| 1191 return linter.Registry.ruleRegistry.getRule(lintName)?.lintCode; |
| 1192 } |
| 1193 |
| 1192 return null; | 1194 return null; |
| 1193 } | 1195 } |
| 1194 | 1196 |
| 1195 void _reportException(String path, exception, StackTrace stackTrace) { | 1197 void _reportException(String path, exception, StackTrace stackTrace) { |
| 1196 String contextKey = null; | 1198 String contextKey = null; |
| 1197 if (exception is _ExceptionState) { | 1199 if (exception is _ExceptionState) { |
| 1198 var state = exception as _ExceptionState; | 1200 var state = exception as _ExceptionState; |
| 1199 exception = state.exception; | 1201 exception = state.exception; |
| 1200 stackTrace = state.stackTrace; | 1202 stackTrace = state.stackTrace; |
| 1201 contextKey = state.contextKey; | 1203 contextKey = state.contextKey; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2054 libraryDeclarations.add(new TopLevelDeclarationInSource( | 2056 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 2055 file.source, declaration, isExported)); | 2057 file.source, declaration, isExported)); |
| 2056 } | 2058 } |
| 2057 } | 2059 } |
| 2058 } | 2060 } |
| 2059 | 2061 |
| 2060 // We're not done yet. | 2062 // We're not done yet. |
| 2061 return false; | 2063 return false; |
| 2062 } | 2064 } |
| 2063 } | 2065 } |
| OLD | NEW |