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()); |
} |