Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1521)

Unified Diff: editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java

Issue 54903009: Issue 14685. Don't analyzer parts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Inform user that only libraries can be analyzed. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/analyzer_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..905d8f246b8a6d135d5623bd40c03de41b308b3d 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,26 @@ 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) {
+ System.err.println("Only libraries can be analyzed.");
+ System.err.println(sourceFile + " is a part and can not be analyzed.");
+ return ErrorSeverity.NONE;
+ }
+
+ // analyze Source
LibraryElement library = context.computeLibraryElement(librarySource);
context.resolveCompilationUnit(librarySource, library);
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/analyzer_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698