Skip to content

Commit 9270f0f

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Stop implementing ConstantEvaluationTarget by ElementAnnotation.
This is an internal interface that should not have been exposed. Change-Id: I92ddc64766e3b9d183750a3406d03215275a58a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436741 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 1b4a566 commit 9270f0f

File tree

6 files changed

+19
-32
lines changed

6 files changed

+19
-32
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Remove `ElementLocation` class; its values are not returned anymore.
77
* Remove deprecated `AnalysisContext.analysisOptions`.
88
* `LibraryFragment` is not `Annotatable` anymore.
9+
* Stop implementing `ConstantEvaluationTarget` by `ElementAnnotation`.
10+
This is an internal interface that should not have been exposed.
911
* Deprecate `element2.dart` library; import `element.dart`.
1012
* Deprecate `XyzElement2` classes; use `XyzElement` instead.
1113
* Deprecate `AnalysisError.correction` field; use

pkg/analyzer/api.txt

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ package:analyzer/analysis_rule/rule_visitor_registry.dart:
291291
addYieldStatement (method: void Function(AbstractAnalysisRule, AstVisitor<dynamic>))
292292
afterLibrary (method: void Function(AbstractAnalysisRule, void Function()))
293293
package:analyzer/dart/analysis/analysis_context.dart:
294-
AnalysisContext@1 (class extends Object):
295-
new (constructor: AnalysisContext@1 Function())
294+
AnalysisContext (class extends Object):
295+
new (constructor: AnalysisContext Function())
296296
contextRoot (getter: ContextRoot)
297297
currentSession (getter: AnalysisSession)
298298
sdkRoot (getter: Folder?)
@@ -302,8 +302,8 @@ package:analyzer/dart/analysis/analysis_context.dart:
302302
package:analyzer/dart/analysis/analysis_context_collection.dart:
303303
AnalysisContextCollection (class extends Object):
304304
new (constructor: AnalysisContextCollection Function({List<String>? excludedPaths, required List<String> includedPaths, ResourceProvider? resourceProvider, String? sdkPath}))
305-
contexts (getter: List<AnalysisContext@1>)
306-
contextFor (method: AnalysisContext@1 Function(String))
305+
contexts (getter: List<AnalysisContext>)
306+
contextFor (method: AnalysisContext Function(String))
307307
dispose (method: Future<void> Function())
308308
package:analyzer/dart/analysis/analysis_options.dart:
309309
AnalysisOptions (class extends Object):
@@ -543,7 +543,7 @@ package:analyzer/dart/analysis/results.dart:
543543
package:analyzer/dart/analysis/session.dart:
544544
AnalysisSession (class extends Object):
545545
new (constructor: AnalysisSession Function())
546-
analysisContext (getter: AnalysisContext@1)
546+
analysisContext (getter: AnalysisContext)
547547
declaredVariables (getter: DeclaredVariables)
548548
resourceProvider (getter: ResourceProvider)
549549
uriConverter (getter: UriConverter)
@@ -3384,7 +3384,7 @@ package:analyzer/dart/element/element.dart:
33843384
thisOrAncestorMatching2 (method: Element? Function(bool Function(Element)))
33853385
thisOrAncestorOfType2 (method: E? Function<E extends Element>())
33863386
visitChildren2 (method: void Function<T>(ElementVisitor2<T>))
3387-
ElementAnnotation (class extends Object implements ConstantEvaluationTarget):
3387+
ElementAnnotation (class extends Object):
33883388
new (constructor: ElementAnnotation Function())
33893389
constantEvaluationErrors (getter: List<Diagnostic>?)
33903390
element2 (getter: Element?)
@@ -3420,6 +3420,7 @@ package:analyzer/dart/element/element.dart:
34203420
isVisibleForTesting (getter: bool)
34213421
isVisibleOutsideTemplate (getter: bool)
34223422
isWidgetFactory (getter: bool)
3423+
libraryFragment (getter: LibraryFragment)
34233424
computeConstantValue (method: DartObject? Function())
34243425
toSource (method: String Function())
34253426
ElementDirective (class extends Object implements Annotatable):
@@ -5152,15 +5153,6 @@ package:analyzer/src/dart/ast/ast.dart:
51525153
AttemptedConstantEvaluationResult (class extends Object):
51535154
diagnostics (getter: List<Diagnostic>)
51545155
value (getter: DartObject?)
5155-
package:analyzer/src/dart/constant/evaluation.dart:
5156-
ConstantEvaluationTarget (class extends Object):
5157-
new (constructor: ConstantEvaluationTarget Function())
5158-
context (getter: AnalysisContext@2)
5159-
isConstantEvaluated (getter: bool)
5160-
library (getter: LibraryElement?)
5161-
library2 (getter: LibraryElement?, deprecated)
5162-
librarySource (getter: Source?)
5163-
source (getter: Source?)
51645156
package:analyzer/src/dart/resolver/scope.dart:
51655157
Namespace (class extends Object):
51665158
EMPTY (static getter: Namespace)
@@ -5169,14 +5161,6 @@ package:analyzer/src/dart/resolver/scope.dart:
51695161
definedNames2 (getter: Map<String, Element>)
51705162
get2 (method: Element? Function(String))
51715163
getPrefixed2 (method: Element? Function(String, String))
5172-
package:analyzer/src/generated/engine.dart:
5173-
AnalysisContext@2 (class extends Object):
5174-
new (constructor: AnalysisContext@2 Function())
5175-
declaredVariables (getter: DeclaredVariables)
5176-
sourceFactory (getter: SourceFactory)
5177-
getAnalysisOptionsForFile (method: AnalysisOptions Function(File), experimental)
5178-
package:analyzer/src/generated/source.dart:
5179-
SourceFactory (non-public)
51805164
package:analyzer/src/generated/timestamped_data.dart:
51815165
TimestampedData (class<E> extends Object):
51825166
new (constructor: TimestampedData<E> Function(int, E))

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import 'package:analyzer/dart/element/type_system.dart';
5757
import 'package:analyzer/diagnostic/diagnostic.dart';
5858
import 'package:analyzer/source/line_info.dart';
5959
import 'package:analyzer/source/source.dart';
60-
import 'package:analyzer/src/dart/constant/evaluation.dart';
6160
import 'package:analyzer/src/dart/element/inheritance_manager3.dart' show Name;
6261
import 'package:analyzer/src/dart/resolver/scope.dart';
6362
import 'package:meta/meta.dart';
@@ -754,7 +753,7 @@ abstract class Element {
754753
/// A single annotation associated with an element.
755754
///
756755
/// Clients may not extend, implement or mix-in this class.
757-
abstract class ElementAnnotation implements ConstantEvaluationTarget {
756+
abstract class ElementAnnotation {
758757
/// The errors that were produced while computing a value for this
759758
/// annotation, or `null` if no value has been computed.
760759
///
@@ -887,6 +886,9 @@ abstract class ElementAnnotation implements ConstantEvaluationTarget {
887886
/// factory.
888887
bool get isWidgetFactory;
889888

889+
/// The library fragment that contains this annotation.
890+
LibraryFragment get libraryFragment;
891+
890892
/// Returns a representation of the value of this annotation, forcing the
891893
/// value to be computed if it had not previously been computed, or `null`
892894
/// if the value of this annotation could not be computed because of errors.

pkg/analyzer/lib/src/dart/constant/evaluation.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'dart:collection';
66

7-
import 'package:_fe_analyzer_shared/src/base/analyzer_public_api.dart';
87
import 'package:analyzer/dart/analysis/declared_variables.dart';
98
import 'package:analyzer/dart/analysis/features.dart';
109
import 'package:analyzer/dart/ast/syntactic_entity.dart';
@@ -540,10 +539,6 @@ class ConstantEvaluationEngine {
540539
}
541540

542541
/// Interface for constant evaluation targets.
543-
@AnalyzerPublicApi(
544-
message: 'exposed because it is implemented by various elements',
545-
)
546-
// TODO(scheglov): consider implementing only in Impl or removing
547542
abstract class ConstantEvaluationTarget {
548543
/// Return the [AnalysisContext] which should be used to evaluate this
549544
/// constant.

pkg/analyzer/lib/src/dart/constant/utilities.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ConstantFinder extends RecursiveAstVisitor<void> {
117117
ConstantFinder({required this.configuration});
118118

119119
@override
120-
void visitAnnotation(Annotation node) {
120+
void visitAnnotation(covariant AnnotationImpl node) {
121121
super.visitAnnotation(node);
122122
var elementAnnotation = node.elementAnnotation;
123123
if (elementAnnotation == null) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,8 @@ class DynamicFragmentImpl extends FragmentImpl implements TypeDefiningFragment {
15451545
}
15461546

15471547
/// A concrete implementation of an [ElementAnnotation].
1548-
class ElementAnnotationImpl implements ElementAnnotation {
1548+
class ElementAnnotationImpl
1549+
implements ElementAnnotation, ConstantEvaluationTarget {
15491550
/// The name of the top-level variable used to mark that a function always
15501551
/// throws, for dead code purposes.
15511552
static const String _alwaysThrowsVariableName = 'alwaysThrows';
@@ -1909,6 +1910,9 @@ class ElementAnnotationImpl implements ElementAnnotation {
19091910
@override
19101911
LibraryElementImpl get library2 => compilationUnit.library;
19111912

1913+
@override
1914+
LibraryFragmentImpl get libraryFragment => compilationUnit;
1915+
19121916
@override
19131917
Source get librarySource => compilationUnit.librarySource;
19141918

0 commit comments

Comments
 (0)