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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java

Issue 11348291: Analyze Dart scripts in HTML files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Analyze in builder thread Created 8 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
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java
index d2bf1cdc57c311512bd03a135f22bcbc1fa2dc6b..c956c6bb17d09f516c80119e99214fd30fbedef3 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisUtility.java
@@ -29,6 +29,7 @@ import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.parser.DartParser;
import com.google.dart.compiler.parser.DartPrefixParser;
import com.google.dart.tools.core.DartCore;
+import com.google.dart.tools.core.html.HtmlAnalyzeHelper;
import com.google.dart.tools.core.internal.builder.CachingArtifactProvider;
import com.google.dart.tools.core.internal.model.PackageLibraryManagerProvider;
import com.google.dart.tools.core.model.DartSdkManager;
@@ -210,8 +211,29 @@ class AnalysisUtility {
*
* @return the library source (not <code>null</code>)
*/
- static UrlLibrarySource toLibrarySource(Context context, File libraryFile) {
- URI libUri = toLibraryUri(context, libraryFile);
+ static UrlLibrarySource toLibrarySource(Context context, final File libraryFile) {
+ final URI libUri = toLibraryUri(context, libraryFile);
+ // may be this library is actually Dart script extracted form HTML file
+ {
+ final File htmlFile = HtmlAnalyzeHelper.getSourceHtmlFile(libraryFile);
+ if (htmlFile != libraryFile) {
+ return new UrlLibrarySource(libUri, context.getLibraryManager()) {
+ @Override
+ public DartSource getSourceFor(String relPath) {
+ if (libraryFile.getName().equals(relPath)) {
+ return createDartSource(libUri, relPath, this, packageLibraryManager);
+ }
+ return super.getSourceFor(relPath);
+ }
+
+ @Override
+ protected URI getImportBaseUri() {
+ return htmlFile.toURI();
+ }
+ };
+ }
+ }
+ // normal library
return new UrlLibrarySource(libUri, context.getLibraryManager());
}

Powered by Google App Engine
This is Rietveld 408576698