Chromium Code Reviews| Index: editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java |
| diff --git a/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java b/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java |
| index 620937bf42a536bca534679f4420d3b79798f1a8..340d9ea9fa3102a7e89bdbc75e9109e23c8a7dde 100644 |
| --- a/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java |
| +++ b/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java |
| @@ -14,6 +14,10 @@ |
| package com.google.dart.command.analyze; |
| import com.google.dart.engine.AnalysisEngine; |
| +import com.google.dart.engine.ast.CompilationUnit; |
| +import com.google.dart.engine.ast.Directive; |
| +import com.google.dart.engine.ast.LibraryDirective; |
| +import com.google.dart.engine.ast.PartOfDirective; |
| import com.google.dart.engine.context.AnalysisContext; |
| import com.google.dart.engine.context.AnalysisException; |
| import com.google.dart.engine.element.CompilationUnitElement; |
| @@ -134,10 +138,24 @@ class AnalyzerImpl { |
| context.setSourceFactory(sourceFactory); |
| context.setAnalysisOptions(contextOptions); |
| - // analyze the given file |
| + // prepare Source |
| sourceFile = sourceFile.getAbsoluteFile(); |
| UriKind uriKind = getUriKind(sourceFile); |
| Source librarySource = new FileBasedSource(sourceFactory.getContentCache(), sourceFile, uriKind); |
| + |
| + // don't try to analyzer parts |
| + CompilationUnit unit = context.parseCompilationUnit(librarySource); |
| + boolean hasLibraryDirective = false; |
| + boolean hasPartOfDirective = false; |
| + for (Directive directive : unit.getDirectives()) { |
| + hasLibraryDirective |= directive instanceof LibraryDirective; |
| + hasPartOfDirective |= directive instanceof PartOfDirective; |
| + } |
| + if (hasPartOfDirective && !hasLibraryDirective) { |
| + return ErrorSeverity.NONE; |
|
Brian Wilkerson
2013/11/01 23:02:20
If I understand correctly, this will silently igno
|
| + } |
| + |
| + // analyze Source |
| LibraryElement library = context.computeLibraryElement(librarySource); |
| context.resolveCompilationUnit(librarySource, library); |