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

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

Issue 1871103002: Support for @JS() validation (#26225). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: test fixes Created 4 years, 8 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 ba28157e559fc2fe94a66203ca79c4abd494da30..63528f1bc69e67fda9d01f61905643ab16964710 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1620,6 +1620,16 @@ class ElementAnnotationImpl implements ElementAnnotation {
static String _DEPRECATED_VARIABLE_NAME = "deprecated";
/**
+ * The name of the class used to JS annotate an element.
+ */
+ static String _JS_CLASS_NAME = "JS";
+
+ /**
+ * The name of `js` library, used to define JS annotations.
+ */
+ static String _JS_LIB_NAME = "js";
+
+ /**
* The name of `meta` library, used to define analysis annotations.
*/
static String _META_LIB_NAME = "meta";
@@ -1708,6 +1718,11 @@ class ElementAnnotationImpl implements ElementAnnotation {
}
@override
+ bool get isJS => element is ConstructorElement &&
+ element.enclosingElement.name == _JS_CLASS_NAME &&
+ element.library?.name == _JS_LIB_NAME;
+
+ @override
bool get isMustCallSuper =>
element is PropertyAccessorElement &&
element.name == _MUST_CALL_SUPER_VARIABLE_NAME &&
@@ -1923,6 +1938,16 @@ abstract class ElementImpl implements Element {
}
@override
+ bool get isJS {
+ for (ElementAnnotation annotation in metadata) {
+ if (annotation.isJS) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @override
bool get isOverride {
for (ElementAnnotation annotation in metadata) {
if (annotation.isOverride) {
@@ -4105,6 +4130,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
bool get isDeprecated => false;
@override
+ bool get isJS => false;
+
+ @override
bool get isOverride => 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