Skip to content

Commit 5b8b524

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove V1 from results.
Change-Id: Ic99558ffb7bf59eebd0afc1e392209a37261480f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422841 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 5e80e70 commit 5b8b524

File tree

6 files changed

+9
-86
lines changed

6 files changed

+9
-86
lines changed

pkg/analyzer/api.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ package:analyzer/dart/analysis/results.dart:
156156
new (constructor: DisposedAnalysisContextResult Function())
157157
ElementDeclarationResult (class extends Object, deprecated):
158158
new (constructor: ElementDeclarationResult Function())
159-
element (getter: Element, deprecated)
160159
fragment (getter: Fragment)
161160
node (getter: AstNode)
162161
parsedUnit (getter: ParsedUnitResult?)
@@ -185,7 +184,6 @@ package:analyzer/dart/analysis/results.dart:
185184
new (constructor: InvalidResult Function())
186185
LibraryElementResult (class extends Object implements SomeLibraryElementResult):
187186
new (constructor: LibraryElementResult Function())
188-
element (getter: LibraryElement, deprecated)
189187
element2 (getter: LibraryElement2, experimental)
190188
NotElementOfThisSessionResult (class extends Object implements InvalidResult, SomeParsedLibraryResult, SomeResolvedLibraryResult):
191189
new (constructor: NotElementOfThisSessionResult Function())
@@ -202,23 +200,20 @@ package:analyzer/dart/analysis/results.dart:
202200
ParsedLibraryResult (class extends Object implements SomeParsedLibraryResult, AnalysisResult):
203201
new (constructor: ParsedLibraryResult Function())
204202
units (getter: List<ParsedUnitResult>)
205-
getElementDeclaration (method: ElementDeclarationResult? Function(Element), deprecated)
206203
getElementDeclaration2 (method: ElementDeclarationResult? Function(Fragment), deprecated, experimental)
207204
getFragmentDeclaration (method: FragmentDeclarationResult? Function(Fragment), experimental)
208205
ParsedUnitResult (class extends Object implements SomeParsedUnitResult, AnalysisResultWithErrors):
209206
new (constructor: ParsedUnitResult Function())
210207
unit (getter: CompilationUnit)
211208
ResolvedLibraryResult (class extends Object implements ParsedLibraryResult, SomeResolvedLibraryResult):
212209
new (constructor: ResolvedLibraryResult Function())
213-
element (getter: LibraryElement, deprecated)
214210
element2 (getter: LibraryElement2, experimental)
215211
typeProvider (getter: TypeProvider)
216212
units (getter: List<ResolvedUnitResult>)
217213
unitWithPath (method: ResolvedUnitResult? Function(String))
218214
ResolvedUnitResult (class extends Object implements ParsedUnitResult, SomeResolvedUnitResult):
219215
new (constructor: ResolvedUnitResult Function())
220216
exists (getter: bool)
221-
libraryElement (getter: LibraryElement, deprecated)
222217
libraryElement2 (getter: LibraryElement2, experimental)
223218
libraryFragment (getter: LibraryFragment, experimental)
224219
typeProvider (getter: TypeProvider)
@@ -241,7 +236,6 @@ package:analyzer/dart/analysis/results.dart:
241236
new (constructor: SomeUnitElementResult Function())
242237
UnitElementResult (class extends Object implements SomeUnitElementResult, FileResult):
243238
new (constructor: UnitElementResult Function())
244-
element (getter: CompilationUnitElement, deprecated)
245239
fragment (getter: LibraryFragment, experimental)
246240
UnspecifiedInvalidResult (class extends Object implements InvalidResult, SomeLibraryElementResult, SomeParsedLibraryResult):
247241
new (constructor: UnspecifiedInvalidResult Function())

pkg/analyzer/lib/dart/analysis/results.dart

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:analyzer/dart/analysis/analysis_options.dart';
66
import 'package:analyzer/dart/analysis/session.dart';
77
import 'package:analyzer/dart/ast/ast.dart';
8-
import 'package:analyzer/dart/element/element.dart';
98
import 'package:analyzer/dart/element/element2.dart';
109
import 'package:analyzer/dart/element/type_provider.dart';
1110
import 'package:analyzer/dart/element/type_system.dart';
@@ -59,10 +58,6 @@ class DisposedAnalysisContextResult
5958
/// The declaration of an [Element].
6059
@Deprecated('Use FragmentDeclarationResult instead')
6160
abstract class ElementDeclarationResult {
62-
/// The [Element] that this object describes.
63-
@Deprecated('Use fragment instead')
64-
Element get element;
65-
6661
/// The [Fragment] that this object describes.
6762
Fragment get fragment;
6863

@@ -167,10 +162,6 @@ abstract class InvalidResult {}
167162
///
168163
/// Clients may not extend, implement or mix-in this class.
169164
abstract class LibraryElementResult implements SomeLibraryElementResult {
170-
/// The element of the library.
171-
@Deprecated('Use element2 instead')
172-
LibraryElement get element;
173-
174165
/// The element representing the library.
175166
@experimental
176167
LibraryElement2 get element2;
@@ -222,12 +213,6 @@ abstract class ParsedLibraryResult
222213
/// The parsed units of the library.
223214
List<ParsedUnitResult> get units;
224215

225-
/// Return the declaration of the [element], or `null` if the [element]
226-
/// is synthetic. Throw [ArgumentError] if the [element] is not defined in
227-
/// this library.
228-
@Deprecated('Use getFragmentDeclaration() instead')
229-
ElementDeclarationResult? getElementDeclaration(Element element);
230-
231216
/// Returns the declaration of the [fragment].
232217
///
233218
/// Returns `null` if the [fragment] is synthetic.
@@ -282,10 +267,6 @@ abstract class ParseStringResult {
282267
/// Clients may not extend, implement or mix-in this class.
283268
abstract class ResolvedLibraryResult
284269
implements ParsedLibraryResult, SomeResolvedLibraryResult {
285-
/// The element representing this library.
286-
@Deprecated('Use element2 instead')
287-
LibraryElement get element;
288-
289270
/// The element representing this library.
290271
@experimental
291272
LibraryElement2 get element2;
@@ -311,10 +292,6 @@ abstract class ResolvedUnitResult
311292
/// Return `true` if the file exists.
312293
bool get exists;
313294

314-
/// The element representing the library containing the compilation [unit].
315-
@Deprecated('Use libraryElement2 instead')
316-
LibraryElement get libraryElement;
317-
318295
/// The element representing the library containing the compilation [unit].
319296
@experimental
320297
LibraryElement2 get libraryElement2;
@@ -404,10 +381,6 @@ abstract class SomeUnitElementResult {}
404381
///
405382
// TODO(scheglov): Stop implementing [FileResult].
406383
abstract class UnitElementResult implements SomeUnitElementResult, FileResult {
407-
/// The element of the file.
408-
@Deprecated('Use fragment instead')
409-
CompilationUnitElement get element;
410-
411384
/// The fragment representing the content of the file.
412385
@experimental
413386
LibraryFragment get fragment;

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ class AnalysisDriver {
926926

927927
var unitResult = await getUnitElement(file.path);
928928
if (unitResult is UnitElementResultImpl) {
929-
return LibraryElementResultImpl(unitResult.element.library);
929+
return LibraryElementResultImpl(unitResult.fragment.element);
930930
}
931931

932932
// Some invalid results are invalid results for this request.
@@ -1964,7 +1964,7 @@ class AnalysisDriver {
19641964
var result = UnitElementResultImpl(
19651965
session: currentSession,
19661966
fileState: file,
1967-
element: element,
1967+
fragment: element,
19681968
);
19691969

19701970
_unitElementRequestedFiles.completeAll(path, result);

pkg/analyzer/lib/src/dart/analysis/results.dart

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:analyzer/dart/analysis/results.dart';
66
import 'package:analyzer/dart/analysis/session.dart';
77
import 'package:analyzer/dart/ast/token.dart';
88
import 'package:analyzer/dart/ast/visitor.dart';
9-
import 'package:analyzer/dart/element/element.dart';
109
import 'package:analyzer/dart/element/element2.dart';
1110
import 'package:analyzer/error/error.dart';
1211
import 'package:analyzer/file_system/file_system.dart';
@@ -187,15 +186,6 @@ class ElementDeclarationResultImpl
187186

188187
ElementDeclarationResultImpl(
189188
this.fragment, this.node, this.parsedUnit, this.resolvedUnit);
190-
191-
@Deprecated('Use fragment instead')
192-
@override
193-
Element get element {
194-
if (fragment case Element element) {
195-
return element;
196-
}
197-
throw UnsupportedError('${fragment.runtimeType}');
198-
}
199189
}
200190

201191
class ErrorsResultImpl implements ErrorsResult {
@@ -280,12 +270,9 @@ class FileResultImpl extends AnalysisResultImpl implements FileResult {
280270

281271
class LibraryElementResultImpl implements LibraryElementResult {
282272
@override
283-
final LibraryElementImpl element;
284-
285-
LibraryElementResultImpl(this.element);
273+
final LibraryElementImpl element2;
286274

287-
@override
288-
LibraryElementImpl get element2 => element;
275+
LibraryElementResultImpl(this.element2);
289276
}
290277

291278
class ParsedLibraryResultImpl extends AnalysisResultImpl
@@ -298,15 +285,6 @@ class ParsedLibraryResultImpl extends AnalysisResultImpl
298285
required this.units,
299286
});
300287

301-
@Deprecated('Use getFragmentDeclaration() instead')
302-
@override
303-
ElementDeclarationResultImpl? getElementDeclaration(Element element) {
304-
if (element case Fragment fragment) {
305-
return getFragmentDeclaration(fragment);
306-
}
307-
throw UnsupportedError('$runtimeType.getElementDeclaration($element)');
308-
}
309-
310288
@Deprecated('Use getFragmentDeclaration() instead')
311289
@override
312290
ElementDeclarationResultImpl? getElementDeclaration2(Fragment fragment) {
@@ -432,22 +410,9 @@ class ResolvedLibraryResultImpl extends AnalysisResultImpl
432410
required this.units,
433411
});
434412

435-
@Deprecated('Use element2 instead')
436-
@override
437-
LibraryElement get element => element2;
438-
439413
@override
440414
TypeProviderImpl get typeProvider => element2.typeProvider;
441415

442-
@Deprecated('Use getFragmentDeclaration() instead')
443-
@override
444-
ElementDeclarationResultImpl? getElementDeclaration(Element element) {
445-
if (element case Fragment fragment) {
446-
return getFragmentDeclaration(fragment);
447-
}
448-
throw UnsupportedError('$runtimeType.getElementDeclaration($element)');
449-
}
450-
451416
@Deprecated('Use getFragmentDeclaration() instead')
452417
@override
453418
ElementDeclarationResultImpl? getElementDeclaration2(Fragment fragment) {
@@ -512,12 +477,6 @@ class ResolvedUnitResultImpl extends FileResultImpl
512477
@override
513478
bool get exists => fileState.exists;
514479

515-
@Deprecated('Use libraryElement2 instead')
516-
@override
517-
LibraryElementImpl get libraryElement {
518-
return libraryElement2;
519-
}
520-
521480
@override
522481
LibraryElementImpl get libraryElement2 {
523482
return libraryFragment.element;
@@ -536,14 +495,11 @@ class ResolvedUnitResultImpl extends FileResultImpl
536495
class UnitElementResultImpl extends FileResultImpl
537496
implements UnitElementResult {
538497
@override
539-
final CompilationUnitElementImpl element;
498+
final CompilationUnitElementImpl fragment;
540499

541500
UnitElementResultImpl({
542501
required super.session,
543502
required super.fileState,
544-
required this.element,
503+
required this.fragment,
545504
});
546-
547-
@override
548-
CompilationUnitElementImpl get fragment => element;
549505
}

pkg/analyzer/lib/src/dart/analysis/search.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ class Search {
347347
if (searchedFiles.add(file.path, this)) {
348348
var libraryResult = await _driver.getLibraryByUri(file.uriStr);
349349
if (libraryResult is LibraryElementResultImpl) {
350-
var element = libraryResult.element;
350+
var element = libraryResult.element2;
351351
element.classes.forEach(addElements);
352352
element.enums.forEach(addElements);
353353
element.extensionTypes.forEach(addElements);
@@ -1147,7 +1147,7 @@ class _FindDeclarations {
11471147
(performance) async {
11481148
var result = await analysisDriver.getLibraryByUri('$uri');
11491149
if (result is LibraryElementResultImpl) {
1150-
return result.element;
1150+
return result.element2;
11511151
}
11521152
return null;
11531153
},

pkg/analyzer/lib/src/dart/micro/analysis_context.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class _FakeAnalysisDriver implements AnalysisDriver {
111111
var library = kind.library ?? kind.asLibrary;
112112
var element = libraryContext.computeUnitElement(library, file);
113113
return UnitElementResultImpl(
114-
element: element,
114+
fragment: element,
115115
fileState: file,
116116
session: currentSession,
117117
);

0 commit comments

Comments
 (0)