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

Unified Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 997203002: Add FunctionElement.isEntryPoint getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/element.dart
diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart
index 45404fc67ad938d29b1a19e690e4388860fe6b40..fb6195804713aa9084ccd831b40d3e67e918240c 100644
--- a/pkg/analyzer/lib/src/generated/element.dart
+++ b/pkg/analyzer/lib/src/generated/element.dart
@@ -3933,6 +3933,11 @@ abstract class FunctionElement implements ExecutableElement, LocalElement {
static final String CALL_METHOD_NAME = "call";
/**
+ * The name of the function used as an entry point.
+ */
+ static const String MAIN_FUNCTION_NAME = "main";
+
+ /**
* The name of the method that will be invoked if an attempt is made to invoke
* an undefined method on an object.
*/
@@ -3944,6 +3949,12 @@ abstract class FunctionElement implements ExecutableElement, LocalElement {
static final String LOAD_LIBRARY_NAME = "loadLibrary";
Brian Wilkerson 2015/03/11 17:19:23 Could you move this before MAIN... so that they're
scheglov 2015/03/11 17:20:59 Done.
/**
+ * Return `true` if the function is an entry point, i.e. a top-level function
+ * and has the name `main`.
+ */
+ bool get isEntryPoint;
+
+ /**
* Return the resolved function declaration node that declares this element.
*
* This method is expensive, because resolved AST might be evicted from cache,
@@ -4001,6 +4012,11 @@ class FunctionElementImpl extends ExecutableElementImpl
}
@override
+ bool get isEntryPoint {
+ return isStatic && displayName == FunctionElement.MAIN_FUNCTION_NAME;
+ }
+
+ @override
bool get isStatic => enclosingElement is CompilationUnitElement;
@override
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698