| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of analyzer; | 4 |
| 5 library analyzer_impl; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:io'; |
| 9 |
| 10 import 'generated/java_io.dart'; |
| 11 import 'generated/engine.dart'; |
| 12 import 'generated/error.dart'; |
| 13 import 'generated/source_io.dart'; |
| 14 import 'generated/sdk.dart'; |
| 15 import 'generated/sdk_io.dart'; |
| 16 import 'generated/ast.dart'; |
| 17 import 'generated/element.dart'; |
| 18 import '../options.dart'; |
| 5 | 19 |
| 6 /// Analyzes single library [File]. | 20 /// Analyzes single library [File]. |
| 7 class _AnalyzerImpl { | 21 class AnalyzerImpl { |
| 8 final CommandLineOptions options; | 22 final CommandLineOptions options; |
| 9 DartSdk sdk; | 23 DartSdk sdk; |
| 10 | 24 |
| 11 ContentCache contentCache = new ContentCache(); | 25 ContentCache contentCache = new ContentCache(); |
| 12 SourceFactory sourceFactory; | 26 SourceFactory sourceFactory; |
| 13 AnalysisContext context; | 27 AnalysisContext context; |
| 14 | 28 |
| 15 /// All [Source]s references by the analyzed library. | 29 /// All [Source]s references by the analyzed library. |
| 16 final Set<Source> sources = new Set<Source>(); | 30 final Set<Source> sources = new Set<Source>(); |
| 17 | 31 |
| 18 /// All [AnalysisErrorInfo]s in the analyzed library. | 32 /// All [AnalysisErrorInfo]s in the analyzed library. |
| 19 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>(); | 33 final List<AnalysisErrorInfo> errorInfos = new List<AnalysisErrorInfo>(); |
| 20 | 34 |
| 21 _AnalyzerImpl(CommandLineOptions this.options) { | 35 AnalyzerImpl(CommandLineOptions this.options) { |
| 22 sdk = new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath)); | 36 sdk = new DirectoryBasedDartSdk(new JavaFile(options.dartSdkPath)); |
| 23 } | 37 } |
| 24 | 38 |
| 25 /** | 39 /** |
| 26 * Treats the [sourcePath] as the top level library and analyzes it. | 40 * Treats the [sourcePath] as the top level library and analyzes it. |
| 27 */ | 41 */ |
| 28 void analyze(String sourcePath) { | 42 void analyze(String sourcePath) { |
| 29 sources.clear(); | 43 sources.clear(); |
| 30 errorInfos.clear(); | 44 errorInfos.clear(); |
| 31 if (sourcePath == null) { | 45 if (sourcePath == null) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 139 |
| 126 static JavaFile getPackageDirectoryFor(JavaFile sourceFile) { | 140 static JavaFile getPackageDirectoryFor(JavaFile sourceFile) { |
| 127 JavaFile sourceFolder = sourceFile.getParentFile(); | 141 JavaFile sourceFolder = sourceFile.getParentFile(); |
| 128 JavaFile packagesFolder = new JavaFile.relative(sourceFolder, "packages"); | 142 JavaFile packagesFolder = new JavaFile.relative(sourceFolder, "packages"); |
| 129 if (packagesFolder.exists()) { | 143 if (packagesFolder.exists()) { |
| 130 return packagesFolder; | 144 return packagesFolder; |
| 131 } | 145 } |
| 132 return null; | 146 return null; |
| 133 } | 147 } |
| 134 } | 148 } |
| OLD | NEW |