Skip to content

Commit fafad4e

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Move the API tool so that it can generate API for other packages
Also, add some scripts to generate the analyzer_testing API, and checkin the api.txt file for analyzer_testing. In order to avoid a private analyzer import, I add `isExperimental` and `hasExperimental` support for `@experimental` annotation, and switch to using public APIs in `_dumpElement`. Change-Id: I44319270d4e6083b80973b45933268c472876232 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426282 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 86e8e24 commit fafad4e

File tree

12 files changed

+775
-709
lines changed

12 files changed

+775
-709
lines changed

pkg/analyzer/api.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,6 +3087,7 @@ package:analyzer/dart/element/element.dart:
30873087
isDeprecated (getter: bool)
30883088
isDoNotStore (getter: bool)
30893089
isDoNotSubmit (getter: bool)
3090+
isExperimental (getter: bool)
30903091
isFactory (getter: bool)
30913092
isImmutable (getter: bool)
30923093
isInternal (getter: bool)
@@ -3555,6 +3556,7 @@ package:analyzer/dart/element/element.dart:
35553556
hasDeprecated (getter: bool)
35563557
hasDoNotStore (getter: bool)
35573558
hasDoNotSubmit (getter: bool)
3559+
hasExperimental (getter: bool)
35583560
hasFactory (getter: bool)
35593561
hasImmutable (getter: bool)
35603562
hasInternal (getter: bool)

pkg/analyzer/lib/dart/element/element.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ abstract class ElementAnnotation implements ConstantEvaluationTarget {
733733
/// Whether the annotation marks the associated member as not to be used.
734734
bool get isDoNotSubmit;
735735

736+
/// Whether the annotation marks the associated element as experimental.
737+
bool get isExperimental;
738+
736739
/// Whether the annotation marks the associated member as a factory.
737740
bool get isFactory;
738741

@@ -2637,6 +2640,9 @@ abstract class Metadata {
26372640
/// Whether the receiver has an annotation of the form `@doNotSubmit`.
26382641
bool get hasDoNotSubmit;
26392642

2643+
/// Whether the receiver has an annotation of the form `@experimental`.
2644+
bool get hasExperimental;
2645+
26402646
/// Whether the receiver has an annotation of the form `@factory`.
26412647
bool get hasFactory;
26422648

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,9 @@ class ElementAnnotationImpl implements ElementAnnotation {
15111511
/// used (for ephemeral testing and debugging only).
15121512
static const String _doNotSubmitVariableName = 'doNotSubmit';
15131513

1514+
/// The name of the top-level variable used to mark a declaration as experimental.
1515+
static const String _experimentalVariableName = 'experimental';
1516+
15141517
/// The name of the top-level variable used to mark a method as being a
15151518
/// factory.
15161519
static const String _factoryVariableName = 'factory';
@@ -1723,6 +1726,9 @@ class ElementAnnotationImpl implements ElementAnnotation {
17231726
@override
17241727
bool get isDoNotSubmit => _isPackageMetaGetter(_doNotSubmitVariableName);
17251728

1729+
@override
1730+
bool get isExperimental => _isPackageMetaGetter(_experimentalVariableName);
1731+
17261732
@override
17271733
bool get isFactory => _isPackageMetaGetter(_factoryVariableName);
17281734

@@ -6924,6 +6930,18 @@ final class MetadataImpl implements Metadata {
69246930
return false;
69256931
}
69266932

6933+
@override
6934+
bool get hasExperimental {
6935+
var annotations = this.annotations;
6936+
for (var i = 0; i < annotations.length; i++) {
6937+
var annotation = annotations[i];
6938+
if (annotation.isExperimental) {
6939+
return true;
6940+
}
6941+
}
6942+
return false;
6943+
}
6944+
69276945
@override
69286946
bool get hasFactory {
69296947
var annotations = this.annotations;

0 commit comments

Comments
 (0)