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

Unified Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 141753002: Reapply "Implement new model for class members." and "Implement new model for interface members." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix dart2dart bug. Created 6 years, 11 months 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 | sdk/lib/_internal/compiler/implementation/dart_types.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 5d36f91ff8d24905a2bbe8876f551776328ce88c..d13da550c6b8a3809a3797be106b85ee7f9521e4 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -1542,6 +1542,63 @@ abstract class Compiler implements DiagnosticListener {
});
});
}
+
+ /// Debugging helper for determining whether the current element is declared
+ /// within 'user code'.
+ ///
+ /// See [inUserCode] for what defines 'user code'.
+ bool currentlyInUserCode() {
+ return inUserCode(currentElement);
+ }
+
+ /// Debugging helper for determining whether [element] is declared within
+ /// 'user code'.
+ ///
+ /// What constitutes 'user code' is defined by the URI(s) provided by the
+ /// entry point(s) of compilation or analysis:
+ ///
+ /// If an entrypoint URI uses the 'package' scheme then every library from
+ /// that same package is considered to be in user code. For instance, if
+ /// an entry point URI is 'package:foo/bar.dart' then every library whose
+ /// canonical URI starts with 'package:foo/' is in user code.
+ ///
+ /// If an entrypoint URI uses another scheme than 'package' then every library
+ /// with that scheme is in user code. For instance, an entry point URI is
+ /// 'file:///foo.dart' then every library whose canonical URI scheme is
+ /// 'file' is in user code.
+ bool inUserCode(Element element) {
+ if (element == null) return false;
+ Uri libraryUri = element.getLibrary().canonicalUri;
+ List<Uri> entrypoints = <Uri>[];
+ if (mainApp != null) {
+ entrypoints.add(mainApp.canonicalUri);
+ }
+ if (librariesToAnalyzeWhenRun != null) {
+ entrypoints.addAll(librariesToAnalyzeWhenRun);
+ }
+ if (libraryUri.scheme == 'package') {
+ for (Uri uri in entrypoints) {
+ if (uri.scheme != 'package') continue;
+ int slashPos = libraryUri.path.indexOf('/');
+ if (slashPos != -1) {
+ String packageName = libraryUri.path.substring(0, slashPos + 1);
+ if (uri.path.startsWith(packageName)) {
+ return true;
+ }
+ } else {
+ if (libraryUri.path == uri.path) {
+ return true;
+ }
+ }
+ }
+ } else {
+ for (Uri uri in entrypoints) {
+ if (libraryUri.scheme == uri.scheme) return true;
+ }
+ }
+ return false;
+ }
+
}
class CompilerTask {
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/dart_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698