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

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

Issue 2096103002: Analyzer support for `@factory` methods (linter#253). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Allow decls w/o a return type. Created 4 years, 6 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 | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/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/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 790fab65fb96714bcd30b54591f33906acc031f5..7c30efe95a4b0dfd65db7df24cbeb25353eed6ac 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -2462,6 +2462,12 @@ class ElementAnnotationImpl implements ElementAnnotation {
static String _DEPRECATED_VARIABLE_NAME = "deprecated";
/**
+ * The name of the top-level variable used to mark a method as being a
+ * factory.
+ */
+ static String _FACTORY_VARIABLE_NAME = "factory";
+
+ /**
* The name of the class used to JS annotate an element.
*/
static String _JS_CLASS_NAME = "JS";
@@ -2560,6 +2566,12 @@ class ElementAnnotationImpl implements ElementAnnotation {
}
@override
+ bool get isFactory =>
+ element is PropertyAccessorElement &&
+ element.name == _FACTORY_VARIABLE_NAME &&
+ element.library?.name == _META_LIB_NAME;
+
+ @override
bool get isJS =>
element is ConstructorElement &&
element.enclosingElement.name == _JS_CLASS_NAME &&
@@ -2803,6 +2815,16 @@ abstract class ElementImpl implements Element {
}
@override
+ bool get isFactory {
+ for (ElementAnnotation annotation in metadata) {
+ if (annotation.isFactory) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @override
bool get isJS {
for (ElementAnnotation annotation in metadata) {
if (annotation.isJS) {
@@ -6482,6 +6504,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
bool get isDeprecated => false;
@override
+ bool get isFactory => false;
+
+ @override
bool get isJS => false;
@override
« no previous file with comments | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/dart/element/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698