| 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 | 4 |
| 5 library analyzer_impl; | 5 library analyzer_impl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 import 'package:path/path.dart' as pathos; | 11 import 'package:path/path.dart' as pathos; |
| 12 | 12 |
| 13 import 'generated/ast.dart'; | |
| 14 import 'generated/engine.dart'; | 13 import 'generated/engine.dart'; |
| 15 import 'generated/element.dart'; | 14 import 'generated/element.dart'; |
| 16 import 'generated/error.dart'; | 15 import 'generated/error.dart'; |
| 17 import 'generated/java_io.dart'; | 16 import 'generated/java_io.dart'; |
| 18 import 'generated/sdk.dart'; | 17 import 'generated/sdk.dart'; |
| 19 import 'generated/sdk_io.dart'; | 18 import 'generated/sdk_io.dart'; |
| 20 import 'generated/source_io.dart'; | 19 import 'generated/source_io.dart'; |
| 21 import '../options.dart'; | 20 import '../options.dart'; |
| 22 | 21 |
| 23 import 'dart:collection'; | 22 import 'dart:collection'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 JavaFile sourceFile = new JavaFile(sourcePath); | 87 JavaFile sourceFile = new JavaFile(sourcePath); |
| 89 UriKind uriKind = getUriKind(sourceFile); | 88 UriKind uriKind = getUriKind(sourceFile); |
| 90 librarySource = new FileBasedSource.con2(sourceFile, uriKind); | 89 librarySource = new FileBasedSource.con2(sourceFile, uriKind); |
| 91 | 90 |
| 92 // prepare context | 91 // prepare context |
| 93 prepareAnalysisContext(sourceFile, librarySource); | 92 prepareAnalysisContext(sourceFile, librarySource); |
| 94 } | 93 } |
| 95 | 94 |
| 96 /// The sync version of analysis | 95 /// The sync version of analysis |
| 97 ErrorSeverity _analyzeSync() { | 96 ErrorSeverity _analyzeSync() { |
| 98 // don't try to analyzer parts | 97 // don't try to analyze parts |
| 99 var unit = context.parseCompilationUnit(librarySource); | 98 if (context.getKindOf(librarySource) == SourceKind.PART) { |
| 100 var hasLibraryDirective = false; | |
| 101 var hasPartOfDirective = false; | |
| 102 for (var directive in unit.directives) { | |
| 103 if (directive is LibraryDirective) hasLibraryDirective = true; | |
| 104 if (directive is PartOfDirective) hasPartOfDirective = true; | |
| 105 } | |
| 106 if (hasPartOfDirective && !hasLibraryDirective) { | |
| 107 print("Only libraries can be analyzed."); | 99 print("Only libraries can be analyzed."); |
| 108 print("$sourcePath is a part and can not be analyzed."); | 100 print("$sourcePath is a part and can not be analyzed."); |
| 109 return ErrorSeverity.ERROR; | 101 return ErrorSeverity.ERROR; |
| 110 } | 102 } |
| 111 // resolve library | 103 // resolve library |
| 112 var libraryElement = context.computeLibraryElement(librarySource); | 104 var libraryElement = context.computeLibraryElement(librarySource); |
| 113 // prepare source and errors | 105 // prepare source and errors |
| 114 prepareSources(libraryElement); | 106 prepareSources(libraryElement); |
| 115 prepareErrors(); | 107 prepareErrors(); |
| 116 | 108 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 } | 356 } |
| 365 } | 357 } |
| 366 | 358 |
| 367 @override | 359 @override |
| 368 void logInformation2(String message, Exception exception) { | 360 void logInformation2(String message, Exception exception) { |
| 369 if (log) { | 361 if (log) { |
| 370 stdout.writeln(message); | 362 stdout.writeln(message); |
| 371 } | 363 } |
| 372 } | 364 } |
| 373 } | 365 } |
| OLD | NEW |