Version 2.19.0-48.0.dev
Merge commit '5f96a8c7fb23018ae35400bd12b2b7c4914be90c' into 'dev'
diff --git a/DEPS b/DEPS
index 6756097..5c90859 100644
--- a/DEPS
+++ b/DEPS
@@ -108,7 +108,7 @@
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "d7b73536a8079331c888b7da539b80e6825270ea", # manually rev'd
- "dartdoc_rev": "e476b1a11547163b76ac26381b90488f417bb261",
+ "dartdoc_rev": "d7513b2ee0a9bad6c9526f6b0ba970b4fcca17d0",
"devtools_rev": "d131d19091f6b89ac89486bd92440a25a523e8b0",
"ffi_rev": "18b2b549d55009ff594600b04705ff6161681e07",
"file_rev": "0132eeedea2933513bf230513a766a8baeab0c4f",
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
index 78dffce..550849a 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/combinator_contributor.dart
@@ -5,6 +5,7 @@
import 'package:analysis_server/src/protocol_server.dart'
hide Element, ElementKind;
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
+import 'package:analysis_server/src/utilities/extensions/ast.dart';
import 'package:analyzer/dart/ast/ast.dart';
/// A contributor that produces suggestions based on the members of a library
@@ -21,7 +22,7 @@
// Build the list of suggestions.
var directive = node.thisOrAncestorOfType<NamespaceDirective>();
if (directive is NamespaceDirective) {
- var library = directive.uriElement;
+ var library = directive.referencedLibrary;
if (library != null) {
var existingNames = _getCombinatorNames(directive);
for (var element in library.exportNamespace.definedNames.values) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart
index 74ef3fc..8fad506 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart
@@ -6,6 +6,7 @@
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer_plugin/utilities/assist/assist.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
@@ -34,14 +35,14 @@
targetNode = targetNode.parent!;
}
if (targetNode is ImportDirective) {
- var importDirective = targetNode;
- var uriSource = importDirective.uriSource;
-
- // Ignore if invalid URI.
- if (uriSource == null) {
+ final elementUri = targetNode.element2?.uri;
+ if (elementUri is! DirectiveUriWithSource) {
return;
}
+ var importDirective = targetNode;
+ var uriSource = elementUri.source;
+
var importUri = uriSource.uri;
if (!importUri.isScheme('package')) {
return;
@@ -49,8 +50,8 @@
// Don't offer to convert a 'package:' URI to itself.
try {
- var uriContent = importDirective.uriContent;
- if (uriContent == null || Uri.parse(uriContent).isScheme('package')) {
+ var uriContent = elementUri.relativeUriString;
+ if (Uri.parse(uriContent).isScheme('package')) {
return;
}
} on FormatException {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart
index c179e68..544f2fa 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart
@@ -6,6 +6,7 @@
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer_plugin/utilities/assist/assist.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
@@ -39,7 +40,8 @@
}
// Ignore if invalid URI.
- if (targetNode.uriSource == null) {
+ final elementUri = targetNode.element2?.uri;
+ if (elementUri is! DirectiveUriWithSource) {
return;
}
@@ -49,16 +51,7 @@
return;
}
- Uri importUri;
- try {
- var uriContent = targetNode.uriContent;
- if (uriContent == null) {
- return;
- }
- importUri = Uri.parse(uriContent);
- } on FormatException {
- return;
- }
+ final importUri = elementUri.relativeUri;
// Ignore if import uri is not a package: uri.
if (!importUri.isScheme('package')) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
index 152e61b..f4fe7e0 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
@@ -4,6 +4,7 @@
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analysis_server/src/utilities/extensions/ast.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
@@ -26,7 +27,7 @@
if (parent is NamespaceDirective) {
// TODO(brianwilkerson) Support the case where the node's parent is a
// Configuration.
- var source = parent.uriSource;
+ var source = parent.referencedSource;
if (source != null) {
var fullName = source.fullName;
var pathContext = resourceProvider.pathContext;
@@ -39,7 +40,7 @@
}
}
} else if (parent is PartDirective) {
- var source = parent.uriSource;
+ var source = parent.referencedSource;
if (source != null) {
var pathContext = resourceProvider.pathContext;
var relativePath = pathContext.relative(
diff --git a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
index f1483f5..6d6ec55 100644
--- a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
+++ b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
@@ -560,6 +560,13 @@
}
@override
+ void visitExportDirective(ExportDirective node) {
+ _handleUriReference(node.uri, node.element2?.exportedLibrary);
+
+ super.visitExportDirective(node);
+ }
+
+ @override
void visitFieldFormalParameter(FieldFormalParameter node) {
// identifier
// Specified as Element, not var, so that the type can be changed in the
@@ -665,8 +672,7 @@
@override
void visitImportDirective(ImportDirective node) {
- // uri
- _handleUriReference(node.uri, node.uriElement);
+ _handleUriReference(node.uri, node.element2?.importedLibrary);
// prefix
var prefixIdentifier = node.prefix;
@@ -908,14 +914,6 @@
}
@override
- void visitUriBasedDirective(UriBasedDirective node) {
- _handleUriReference(node.uri, node.uriElement);
-
- // visit children
- super.visitUriBasedDirective(node);
- }
-
- @override
void visitVariableDeclaration(VariableDeclaration node) {
var isLocal = _enclosingVName != _enclosingClassVName &&
_enclosingVName != _enclosingFileVName;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
index 743e96f..f3f985b 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
@@ -6,9 +6,11 @@
import 'package:analysis_server/src/services/correction/status.dart';
import 'package:analysis_server/src/services/refactoring/refactoring.dart';
import 'package:analysis_server/src/services/refactoring/refactoring_internal.dart';
+import 'package:analysis_server/src/utilities/extensions/ast.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/generated/source.dart';
@@ -153,16 +155,17 @@
if (directive is UriBasedDirective) {
// If the import is relative and the referenced file is also in
// the moved folder, no update is necessary.
- var uriContent = directive.uriContent;
- var uriFullPath = directive.uriSource?.fullName;
- if (uriContent != null &&
- uriFullPath != null &&
- pathContext.isRelative(uriContent) &&
- // `oldFile` is used here and not `oldDir` because we care
- // about whether this is within the folder being renamed, not
- // the folder for this specific resource.
- pathContext.isWithin(oldFile, uriFullPath)) {
- continue;
+ final elementUri = directive.referencedUri;
+ if (elementUri is DirectiveUriWithSource) {
+ final uriContent = elementUri.relativeUriString;
+ final uriFullPath = elementUri.source.fullName;
+ if (pathContext.isRelative(uriContent) &&
+ // `oldFile` is used here and not `oldDir` because we care
+ // about whether this is within the folder being renamed, not
+ // the folder for this specific resource.
+ pathContext.isWithin(oldFile, uriFullPath)) {
+ continue;
+ }
}
_updateUriReference(builder, directive, oldDir, newDir);
}
diff --git a/pkg/analysis_server/lib/src/status/ast_writer.dart b/pkg/analysis_server/lib/src/status/ast_writer.dart
index f571ee9..42460ba 100644
--- a/pkg/analysis_server/lib/src/status/ast_writer.dart
+++ b/pkg/analysis_server/lib/src/status/ast_writer.dart
@@ -59,8 +59,6 @@
properties['keyword'] = node.keyword;
} else if (node is ExportDirective) {
properties['element'] = node.element2;
- properties['selectedSource'] = node.selectedSource;
- properties['uriSource'] = node.uriSource;
} else if (node is FieldDeclaration) {
properties['static keyword'] = node.staticKeyword;
} else if (node is FormalParameter) {
@@ -88,8 +86,6 @@
properties['type'] = node.type;
} else if (node is ImportDirective) {
properties['element'] = node.element2;
- properties['selectedSource'] = node.selectedSource;
- properties['uriSource'] = node.uriSource;
} else if (node is IndexExpression) {
properties['static element'] = node.staticElement;
properties['static type'] = node.staticType;
@@ -108,7 +104,6 @@
properties['static type'] = node.staticType;
} else if (node is PartDirective) {
properties['element'] = node.element2;
- properties['uriSource'] = node.uriSource;
} else if (node is PartOfDirective) {
properties['element'] = node.element2;
} else if (node is PostfixExpression) {
diff --git a/pkg/analysis_server/lib/src/status/element_writer.dart b/pkg/analysis_server/lib/src/status/element_writer.dart
index 37b09b4..1f9328f 100644
--- a/pkg/analysis_server/lib/src/status/element_writer.dart
+++ b/pkg/analysis_server/lib/src/status/element_writer.dart
@@ -39,12 +39,10 @@
properties['nameOffset'] = element.nameOffset;
if (element is ClassElement) {
properties['hasNonFinalField'] = element.hasNonFinalField;
- properties['hasStaticMember'] = element.hasStaticMember;
properties['interfaces'] = element.interfaces;
properties['isAbstract'] = element.isAbstract;
properties['isEnum'] = element.isEnum;
properties['isMixinApplication'] = element.isMixinApplication;
- properties['isValidMixin'] = element.isValidMixin;
properties['mixins'] = element.mixins;
properties['superclassConstraints'] = element.superclassConstraints;
properties['supertype'] = element.supertype;
diff --git a/pkg/analysis_server/lib/src/utilities/extensions/ast.dart b/pkg/analysis_server/lib/src/utilities/extensions/ast.dart
index 84e8908..4392013 100644
--- a/pkg/analysis_server/lib/src/utilities/extensions/ast.dart
+++ b/pkg/analysis_server/lib/src/utilities/extensions/ast.dart
@@ -6,6 +6,7 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/src/generated/source.dart';
extension AnnotatedNodeExtensions on AnnotatedNode {
/// Return the first token in this node that is not a comment.
@@ -107,6 +108,44 @@
declaredElement?.library.isNonNullableByDefault ?? false;
}
+extension DirectiveExtensions on Directive {
+ /// If the target imports or exports a [LibraryElement], returns it.
+ LibraryElement? get referencedLibrary {
+ final element = element2;
+ if (element is LibraryExportElement) {
+ return element.exportedLibrary;
+ } else if (element is LibraryImportElement) {
+ return element.importedLibrary;
+ }
+ return null;
+ }
+
+ /// If [referencedUri] is a [DirectiveUriWithSource], returns the [Source]
+ /// from it.
+ Source? get referencedSource {
+ final uri = referencedUri;
+ if (uri is DirectiveUriWithSource) {
+ return uri.source;
+ }
+ return null;
+ }
+
+ /// Returns the [DirectiveUri] from the element.
+ DirectiveUri? get referencedUri {
+ final self = this;
+ if (self is AugmentationImportDirective) {
+ return self.element2?.uri;
+ } else if (self is ExportDirective) {
+ return self.element2?.uri;
+ } else if (self is ImportDirective) {
+ return self.element2?.uri;
+ } else if (self is PartDirective) {
+ return self.element2?.uri;
+ }
+ return null;
+ }
+}
+
extension ExpressionExtensions on Expression {
/// Return `true` if this expression is an invocation of the method `cast`
/// from either Iterable`, `List`, `Map`, or `Set`.
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index e16c1b4..1588cce 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -5,6 +5,12 @@
* Deprecated `ClassOrMixinDeclaration.getMethod`, filter `members` instead.
* Deprecated `ClassDeclaration.getConstructor`, filter `members` instead.
* Deprecated `Directive.element`, use `element2` instead.
+* Deprecated `ClassElement.isValidMixin`, it is not useful for clients.
+* Deprecated `ClassElement.hasStaticMember`, it is not useful for clients.
+* Deprecated `NamespaceDirective.uriElement`, use `element2.uri` with `DirectiveUriWithLibrary` instead.
+* Deprecated `UriBasedDirective.uriContent`, `UriBasedDirective.uriElement`, `UriBasedDirective.uriSource`.
+ Use `Directive.element2.uri` instead.
+* Deprecated `NamespaceDirective.selectedSource`, use `element2.uri` with `DirectiveUriWithSource` instead.
## 4.3.1
* Fix `identifier` for `LibraryExportElement` and `LibraryImportElement`.
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index fc24d3d..f4f40f7 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -634,6 +634,9 @@
@override
AugmentationImportElement? get element;
+ @override
+ AugmentationImportElement? get element2;
+
/// The token representing the 'import' keyword.
Token get importKeyword;
@@ -1242,6 +1245,7 @@
StringLiteral get uri;
/// Return the source to which the [uri] was resolved.
+ /// TODO(scheglov) Deprecate and remove.
Source? get uriSource;
/// Return the value to which the value of the declared variable will be
@@ -3484,6 +3488,7 @@
/// This will be the source from the first configuration whose condition is
/// true, or the `[uriSource]` if either there are no configurations or if
/// there are no configurations whose condition is true.
+ @Deprecated('Use element2.uri and check for DirectiveUriWithSource instead')
Source? get selectedSource;
/// Return the content of the URI that was selected based on the declared
@@ -3492,11 +3497,14 @@
/// This will be the URI from the first configuration whose condition is
/// true, or the `[uriContent]` if either there are no configurations or if
/// there are no configurations whose condition is true.
+ @Deprecated(
+ 'Use element2.uri and check for DirectiveUriWithRelativeUriString instead')
String? get selectedUriContent;
/// Return the semicolon terminating the directive.
Token get semicolon;
+ @Deprecated('Use element2.uri and check for DirectiveUriWithLibrary instead')
@override
LibraryElement? get uriElement;
}
@@ -4563,7 +4571,8 @@
/// Return the content of the [uri], or `null` if the AST structure has not
/// been resolved, or if the [uri] has a string interpolation.
- /// TODO(scheglov) Deprecate and remove it.
+ @Deprecated(
+ 'Use element2.uri and check for DirectiveUriWithRelativeUriString instead')
String? get uriContent;
/// Return the element associated with the [uri] of this directive, or `null`
@@ -4572,11 +4581,11 @@
///
/// Examples of the latter case include a directive that contains an invalid
/// URL or a URL that does not exist.
- /// TODO(scheglov) Deprecate and remove it.
+ @Deprecated('Use element2.uri and check for DirectiveUriWithLibrary instead')
Element? get uriElement;
/// Return the source to which the [uri] was resolved.
- /// TODO(scheglov) Deprecate and remove it.
+ @Deprecated('Use element2.uri and check for DirectiveUriWithSource instead')
Source? get uriSource;
}
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index d51d9e5..18e03b9 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -2289,6 +2289,7 @@
bool get hasNonFinalField;
/// Return `true` if this class declares a static member.
+ @Deprecated('Not useful for clients')
bool get hasStaticMember;
/// Return `true` if this class is abstract. A class is abstract if it has an
@@ -2327,7 +2328,7 @@
/// declares a constructor. It is a compile-time error if a mixin is derived
/// from a class whose superclass is not Object.
/// </blockquote>
- /// TODO(scheglov) Deprecate and remove it.
+ @Deprecated('Not useful for clients')
bool get isValidMixin;
/// Return a list containing all of the superclass constraints defined for
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index 3818634..b7ec2f5 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -191,27 +191,30 @@
for (var directive in libraryUnit.directives) {
if (directive is PartDirective) {
- var partUnit = elementToUnit[directive.uriElement];
- if (partUnit != null) {
- var shouldReport = false;
- var partOverrideToken = partUnit.languageVersionToken;
- if (libraryOverrideToken != null) {
- if (partOverrideToken != null) {
- if (partOverrideToken.major != libraryOverrideToken.major ||
- partOverrideToken.minor != libraryOverrideToken.minor) {
+ final elementUri = directive.element2?.uri;
+ if (elementUri is DirectiveUriWithUnit) {
+ final partUnit = elementToUnit[elementUri.unit];
+ if (partUnit != null) {
+ var shouldReport = false;
+ var partOverrideToken = partUnit.languageVersionToken;
+ if (libraryOverrideToken != null) {
+ if (partOverrideToken != null) {
+ if (partOverrideToken.major != libraryOverrideToken.major ||
+ partOverrideToken.minor != libraryOverrideToken.minor) {
+ shouldReport = true;
+ }
+ } else {
shouldReport = true;
}
- } else {
+ } else if (partOverrideToken != null) {
shouldReport = true;
}
- } else if (partOverrideToken != null) {
- shouldReport = true;
- }
- if (shouldReport) {
- _getErrorReporter(_library.file).reportErrorForNode(
- CompileTimeErrorCode.INCONSISTENT_LANGUAGE_VERSION_OVERRIDE,
- directive.uri,
- );
+ if (shouldReport) {
+ _getErrorReporter(_library.file).reportErrorForNode(
+ CompileTimeErrorCode.INCONSISTENT_LANGUAGE_VERSION_OVERRIDE,
+ directive.uri,
+ );
+ }
}
}
}
@@ -551,7 +554,9 @@
final uriState = state.uri;
if (uriState is DirectiveUriWithString) {
+ // ignore: deprecated_member_use_from_same_package
directive.uriContent = uriState.relativeUriStr;
+ // ignore: deprecated_member_use_from_same_package
directive.uriSource = uriState.source;
}
@@ -611,6 +616,7 @@
units[augmentationFile] = augmentationUnit;
final importedAugmentation = element.importedAugmentation!;
+ // ignore: deprecated_member_use_from_same_package
directive.uriSource = importedAugmentation.source;
augmentationUnit.element = importedAugmentation.definingCompilationUnit;
@@ -865,11 +871,14 @@
for (var i = 0; i < configurationNodes.length; i++) {
final configurationNode = configurationNodes[i];
configurationNode as ConfigurationImpl;
+ // TODO(scheglov) Use `DirectiveUri` here instead.
configurationNode.uriSource = configurationUris[i].source;
}
if (primaryUriState is DirectiveUriWithString) {
+ // ignore: deprecated_member_use_from_same_package
directive.uriContent = primaryUriState.relativeUriStr;
+ // ignore: deprecated_member_use_from_same_package
directive.uriSource = primaryUriState.source;
}
@@ -890,6 +899,7 @@
}) {
StringLiteral partUri = directive.uri;
+ // ignore: deprecated_member_use_from_same_package
directive.uriSource = partState.includedSource;
directive.element = partElement;
@@ -975,6 +985,7 @@
}
final partSource = includedKind.file.source;
+ // ignore: deprecated_member_use_from_same_package
directive.uriSource = partSource;
for (final directive in partUnit.directives) {
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index 2c88c82..c36c045 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -923,6 +923,7 @@
@override
Token get keyword => importKeyword;
+ @Deprecated('Use element2.uri instead')
@override
LibraryAugmentationElement? get uriElement {
return element2?.importedAugmentation;
@@ -3818,6 +3819,7 @@
@override
Token get keyword => exportKeyword;
+ @Deprecated('Use element2.uri instead')
@override
LibraryElement? get uriElement {
return element2?.exportedLibrary;
@@ -6475,6 +6477,7 @@
_prefix = _becomeParentOf(identifier as SimpleIdentifierImpl?);
}
+ @Deprecated('Use element2.uri instead')
@override
LibraryElement? get uriElement {
return element2?.importedLibrary;
@@ -7330,6 +7333,7 @@
@override
Token get keyword => libraryKeyword;
+ @Deprecated('Use element2.uri instead')
@override
LibraryElement? get uriElement {
// TODO(scheglov) Implement it.
@@ -8272,6 +8276,7 @@
@override
Token get endToken => semicolon;
+ @Deprecated('Use element2.uri instead')
@override
LibraryElement? get uriElement;
}
@@ -8820,6 +8825,7 @@
@override
Token get keyword => partKeyword;
+ @Deprecated('Use element2.uri instead')
@override
CompilationUnitElement? get uriElement {
final partElementUri = element2?.uri;
@@ -11445,9 +11451,11 @@
/// The URI referenced by this directive.
StringLiteralImpl _uri;
+ @Deprecated('Use element2.uri instead')
@override
String? uriContent;
+ @Deprecated('Use element2.uri instead')
@override
Source? uriSource;
@@ -11465,6 +11473,7 @@
_uri = _becomeParentOf(uri as StringLiteralImpl);
}
+ @Deprecated('Use element2.uri instead')
UriValidationCode? validate() {
return validateUri(this is ImportDirective, uri, uriContent);
}
diff --git a/pkg/analyzer/lib/src/dart/ast/element_locator.dart b/pkg/analyzer/lib/src/dart/ast/element_locator.dart
index 279c3fb..4612dc3 100644
--- a/pkg/analyzer/lib/src/dart/ast/element_locator.dart
+++ b/pkg/analyzer/lib/src/dart/ast/element_locator.dart
@@ -161,9 +161,16 @@
@override
Element? visitStringLiteral(StringLiteral node) {
- var parent = node.parent;
- if (parent is UriBasedDirective) {
- return parent.uriElement;
+ final parent = node.parent;
+ if (parent is ExportDirective) {
+ return parent.element2?.exportedLibrary;
+ } else if (parent is ImportDirective) {
+ return parent.element2?.importedLibrary;
+ } else if (parent is PartDirective) {
+ final elementUri = parent.element2?.uri;
+ if (elementUri is DirectiveUriWithUnit) {
+ return elementUri.unit;
+ }
}
return null;
}
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 437d67b..98f9781 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -718,6 +718,7 @@
return definingClass != null && !definingClass.isDartCoreObject;
}
+ @Deprecated('Not useful for clients')
@override
bool get hasStaticMember {
for (MethodElement method in methods) {
@@ -815,6 +816,7 @@
setModifier(Modifier.SIMPLY_BOUNDED, isSimplyBounded);
}
+ @Deprecated('Not useful for clients')
@override
bool get isValidMixin {
final supertype = this.supertype;
@@ -2935,6 +2937,7 @@
@override
bool get hasNonFinalField => false;
+ @Deprecated('Not useful for clients')
@override
bool get hasStaticMember => true;
@@ -2956,6 +2959,7 @@
setModifier(Modifier.SIMPLY_BOUNDED, isSimplyBounded);
}
+ @Deprecated('Not useful for clients')
@override
bool get isValidMixin => false;
diff --git a/pkg/analyzer/lib/src/error/best_practices_verifier.dart b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
index ec868b6..a1b430c 100644
--- a/pkg/analyzer/lib/src/error/best_practices_verifier.dart
+++ b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
@@ -1084,7 +1084,7 @@
void _checkForInternalExport(ExportDirective node) {
if (!_inPublicPackageApi) return;
- var libraryElement = node.uriElement;
+ var libraryElement = node.element2?.exportedLibrary;
if (libraryElement == null) return;
if (libraryElement.hasInternal) {
_errorReporter.reportErrorForNode(
@@ -1914,7 +1914,7 @@
}
void verifyImport(ImportDirective node) {
- var element = node.uriElement;
+ var element = node.element2?.importedLibrary;
if (_hasInternal(element) &&
!_isLibraryInWorkspacePackage(element!.library)) {
// The only way for an import directive's URI to have a `null`
diff --git a/pkg/analyzer/lib/src/error/deprecated_member_use_verifier.dart b/pkg/analyzer/lib/src/error/deprecated_member_use_verifier.dart
index 240e440..954b777 100644
--- a/pkg/analyzer/lib/src/error/deprecated_member_use_verifier.dart
+++ b/pkg/analyzer/lib/src/error/deprecated_member_use_verifier.dart
@@ -35,7 +35,7 @@
}
void exportDirective(ExportDirective node) {
- _checkForDeprecated(node.uriElement, node);
+ _checkForDeprecated(node.element2?.exportedLibrary, node);
}
void functionExpressionInvocation(FunctionExpressionInvocation node) {
@@ -47,7 +47,7 @@
}
void importDirective(ImportDirective node) {
- _checkForDeprecated(node.uriElement, node);
+ _checkForDeprecated(node.element2?.importedLibrary, node);
}
void indexExpression(IndexExpression node) {
diff --git a/pkg/analyzer/lib/src/error/imports_verifier.dart b/pkg/analyzer/lib/src/error/imports_verifier.dart
index 549c43b..81adecd 100644
--- a/pkg/analyzer/lib/src/error/imports_verifier.dart
+++ b/pkg/analyzer/lib/src/error/imports_verifier.dart
@@ -258,7 +258,7 @@
final importsWithLibraries = <_ImportDirective>[];
for (Directive directive in node.directives) {
if (directive is ImportDirective) {
- var libraryElement = directive.uriElement;
+ var libraryElement = directive.element2?.importedLibrary;
if (libraryElement == null) {
continue;
}
diff --git a/pkg/analyzer/test/generated/simple_resolver_test.dart b/pkg/analyzer/test/generated/simple_resolver_test.dart
index e26ff8a..8a4b10d 100644
--- a/pkg/analyzer/test/generated/simple_resolver_test.dart
+++ b/pkg/analyzer/test/generated/simple_resolver_test.dart
@@ -745,6 +745,7 @@
verifyTestResolved();
}
+ @deprecated
test_isValidMixin_badSuperclass() async {
await assertErrorsInCode(r'''
class A extends B {}
@@ -758,6 +759,7 @@
expect(a.isValidMixin, isFalse);
}
+ @deprecated
test_isValidMixin_constructor() async {
await assertErrorsInCode(r'''
class A {
@@ -772,6 +774,7 @@
expect(a.isValidMixin, isFalse);
}
+ @deprecated
test_isValidMixin_factoryConstructor() async {
await assertNoErrorsInCode(r'''
class A {
@@ -784,6 +787,7 @@
expect(a.isValidMixin, isTrue);
}
+ @deprecated
test_isValidMixin_super_toString() async {
await assertNoErrorsInCode(r'''
class A {
@@ -798,6 +802,7 @@
expect(a.isValidMixin, isTrue);
}
+ @deprecated
test_isValidMixin_valid() async {
await assertNoErrorsInCode('''
class A {}
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 0d394cc..0bf2ac3 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -114,12 +114,14 @@
expect(classB.hasNonFinalField, isTrue);
}
+ @deprecated
void test_hasStaticMember_false_empty() {
var classA = class_(name: 'A');
// no members
expect(classA.hasStaticMember, isFalse);
}
+ @deprecated
void test_hasStaticMember_false_instanceMethod() {
var classA = class_(name: 'A');
MethodElement method = ElementFactory.methodElement("foo", intNone);
@@ -127,6 +129,7 @@
expect(classA.hasStaticMember, isFalse);
}
+ @deprecated
void test_hasStaticMember_instanceGetter() {
var classA = class_(name: 'A');
PropertyAccessorElement getter =
@@ -135,6 +138,7 @@
expect(classA.hasStaticMember, isFalse);
}
+ @deprecated
void test_hasStaticMember_true_getter() {
var classA = class_(name: 'A');
PropertyAccessorElementImpl getter =
@@ -145,6 +149,7 @@
expect(classA.hasStaticMember, isTrue);
}
+ @deprecated
void test_hasStaticMember_true_method() {
var classA = class_(name: 'A');
MethodElementImpl method = ElementFactory.methodElement("foo", intNone);
@@ -154,6 +159,7 @@
expect(classA.hasStaticMember, isTrue);
}
+ @deprecated
void test_hasStaticMember_true_setter() {
var classA = class_(name: 'A');
PropertyAccessorElementImpl setter =
diff --git a/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart b/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart
index de92432..5273d88 100644
--- a/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/augmentation_import_test.dart
@@ -44,9 +44,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithAugmentation
uri: package:test/c.dart
- uriContent: c.dart
- uriElement: self::@augmentation::package:test/c.dart
- uriSource: package:test/c.dart
''');
}
@@ -81,9 +78,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithAugmentation
uri: package:test/c.dart
- uriContent: c.dart
- uriElement: self::@augmentation::package:test/c.dart
- uriSource: package:test/c.dart
''');
}
@@ -115,9 +109,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithSource
source: package:test/c.dart
- uriContent: c.dart
- uriElement: <null>
- uriSource: package:test/c.dart
''');
}
@@ -147,9 +138,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithRelativeUriString
relativeUriString: :net
- uriContent: :net
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -189,9 +177,6 @@
semicolon: ;
element: AugmentationImportElement
uri: DirectiveUri
- uriContent: null
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -221,9 +206,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithRelativeUri
relativeUri: foo:bar
- uriContent: foo:bar
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -247,9 +229,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithAugmentation
uri: package:test/a.dart
- uriContent: a.dart
- uriElement: self::@augmentation::package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -276,9 +255,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithAugmentation
uri: package:test/a.dart
- uriContent: a.dart
- uriElement: self::@augmentation::package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -300,9 +276,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
@@ -326,9 +299,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
@@ -350,9 +320,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithRelativeUriString
relativeUriString: :net
- uriContent: :net
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -384,9 +351,6 @@
semicolon: ;
element: AugmentationImportElement
uri: DirectiveUri
- uriContent: null
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -408,9 +372,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithRelativeUri
relativeUri: foo:bar
- uriContent: foo:bar
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -436,9 +397,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
@@ -464,9 +422,6 @@
element: AugmentationImportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/library_export_test.dart b/pkg/analyzer/test/src/dart/resolution/library_export_test.dart
index 9022bf9..b4f6a2f 100644
--- a/pkg/analyzer/test/src/dart/resolution/library_export_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/library_export_test.dart
@@ -41,11 +41,6 @@
element: LibraryExportElement
uri: DirectiveUriWithLibrary
uri: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: package:test/c.dart
- uriSource: package:test/c.dart
''');
}
@@ -74,11 +69,6 @@
element: LibraryExportElement
uri: DirectiveUriWithLibrary
uri: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: package:test/c.dart
- uriSource: package:test/c.dart
''');
}
@@ -107,11 +97,6 @@
element: LibraryExportElement
uri: DirectiveUriWithRelativeUriString
relativeUriString: :net
- selectedSource: <null>
- selectedUriContent: :net
- uriContent: :net
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -150,11 +135,6 @@
semicolon: ;
element: LibraryExportElement
uri: DirectiveUri
- selectedSource: <null>
- selectedUriContent: null
- uriContent: null
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -183,11 +163,6 @@
element: LibraryExportElement
uri: DirectiveUriWithRelativeUri
relativeUri: foo:bar
- selectedSource: <null>
- selectedUriContent: foo:bar
- uriContent: foo:bar
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -220,11 +195,6 @@
element: LibraryExportElement
uri: DirectiveUriWithSource
source: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: <null>
- uriSource: package:test/c.dart
''');
}
@@ -257,11 +227,6 @@
element: LibraryExportElement
uri: DirectiveUriWithSource
source: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: <null>
- uriSource: package:test/c.dart
''');
}
@@ -294,11 +259,6 @@
element: LibraryExportElement
uri: DirectiveUriWithSource
source: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: <null>
- uriSource: package:test/c.dart
''');
}
@@ -369,11 +329,6 @@
element: LibraryExportElement
uri: DirectiveUriWithLibrary
uri: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -444,11 +399,6 @@
element: LibraryExportElement
uri: DirectiveUriWithLibrary
uri: package:test/a_html.dart
- selectedSource: package:test/a_html.dart
- selectedUriContent: a_html.dart
- uriContent: a.dart
- uriElement: package:test/a_html.dart
- uriSource: package:test/a.dart
''');
}
@@ -519,11 +469,6 @@
element: LibraryExportElement
uri: DirectiveUriWithLibrary
uri: package:test/a_io.dart
- selectedSource: package:test/a_io.dart
- selectedUriContent: a_io.dart
- uriContent: a.dart
- uriElement: package:test/a_io.dart
- uriSource: package:test/a.dart
''');
}
@@ -544,11 +489,6 @@
element: LibraryExportElement
uri: DirectiveUriWithLibrary
uri: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -569,11 +509,6 @@
element: LibraryExportElement
uri: DirectiveUriWithLibrary
uri: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -608,11 +543,6 @@
element: LibraryExportElement
uri: DirectiveUriWithRelativeUriString
relativeUriString: :net
- selectedSource: <null>
- selectedUriContent: :net
- uriContent: :net
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -643,11 +573,6 @@
semicolon: ;
element: LibraryExportElement
uri: DirectiveUri
- selectedSource: <null>
- selectedUriContent: null
- uriContent: null
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -668,11 +593,6 @@
element: LibraryExportElement
uri: DirectiveUriWithRelativeUri
relativeUri: foo:bar
- selectedSource: <null>
- selectedUriContent: foo:bar
- uriContent: foo:bar
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -697,11 +617,6 @@
element: LibraryExportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
@@ -726,11 +641,6 @@
element: LibraryExportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
@@ -755,11 +665,6 @@
element: LibraryExportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/library_import_test.dart b/pkg/analyzer/test/src/dart/resolution/library_import_test.dart
index 2549157..1cc0030 100644
--- a/pkg/analyzer/test/src/dart/resolution/library_import_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/library_import_test.dart
@@ -42,11 +42,6 @@
element: LibraryImportElement
uri: DirectiveUriWithLibrary
uri: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: package:test/c.dart
- uriSource: package:test/c.dart
''');
}
@@ -75,11 +70,6 @@
element: LibraryImportElement
uri: DirectiveUriWithLibrary
uri: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: package:test/c.dart
- uriSource: package:test/c.dart
''');
}
@@ -108,11 +98,6 @@
element: LibraryImportElement
uri: DirectiveUriWithRelativeUriString
relativeUriString: :net
- selectedSource: <null>
- selectedUriContent: :net
- uriContent: :net
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -151,11 +136,6 @@
semicolon: ;
element: LibraryImportElement
uri: DirectiveUri
- selectedSource: <null>
- selectedUriContent: null
- uriContent: null
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -184,11 +164,6 @@
element: LibraryImportElement
uri: DirectiveUriWithRelativeUri
relativeUri: foo:bar
- selectedSource: <null>
- selectedUriContent: foo:bar
- uriContent: foo:bar
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -221,11 +196,6 @@
element: LibraryImportElement
uri: DirectiveUriWithSource
source: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: <null>
- uriSource: package:test/c.dart
''');
}
@@ -258,11 +228,6 @@
element: LibraryImportElement
uri: DirectiveUriWithSource
source: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: <null>
- uriSource: package:test/c.dart
''');
}
@@ -295,11 +260,6 @@
element: LibraryImportElement
uri: DirectiveUriWithSource
source: package:test/c.dart
- selectedSource: package:test/c.dart
- selectedUriContent: c.dart
- uriContent: c.dart
- uriElement: <null>
- uriSource: package:test/c.dart
''');
}
@@ -374,11 +334,6 @@
element: LibraryImportElement
uri: DirectiveUriWithLibrary
uri: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: package:test/a.dart
- uriSource: package:test/a.dart
declarations
TopLevelVariableDeclaration
variables: VariableDeclarationList
@@ -480,11 +435,6 @@
element: LibraryImportElement
uri: DirectiveUriWithLibrary
uri: package:test/a_html.dart
- selectedSource: package:test/a_html.dart
- selectedUriContent: a_html.dart
- uriContent: a.dart
- uriElement: package:test/a_html.dart
- uriSource: package:test/a.dart
declarations
TopLevelVariableDeclaration
variables: VariableDeclarationList
@@ -586,11 +536,6 @@
element: LibraryImportElement
uri: DirectiveUriWithLibrary
uri: package:test/a_io.dart
- selectedSource: package:test/a_io.dart
- selectedUriContent: a_io.dart
- uriContent: a.dart
- uriElement: package:test/a_io.dart
- uriSource: package:test/a.dart
declarations
TopLevelVariableDeclaration
variables: VariableDeclarationList
@@ -639,11 +584,6 @@
element: LibraryImportElement
uri: DirectiveUriWithLibrary
uri: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -664,11 +604,6 @@
element: LibraryImportElement
uri: DirectiveUriWithLibrary
uri: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -689,11 +624,6 @@
element: LibraryImportElement
uri: DirectiveUriWithRelativeUriString
relativeUriString: :net
- selectedSource: <null>
- selectedUriContent: :net
- uriContent: :net
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -724,11 +654,6 @@
semicolon: ;
element: LibraryImportElement
uri: DirectiveUri
- selectedSource: <null>
- selectedUriContent: null
- uriContent: null
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -749,11 +674,6 @@
element: LibraryImportElement
uri: DirectiveUriWithRelativeUri
relativeUri: foo:bar
- selectedSource: <null>
- selectedUriContent: foo:bar
- uriContent: foo:bar
- uriElement: <null>
- uriSource: <null>
''');
}
@@ -778,11 +698,6 @@
element: LibraryImportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
@@ -807,11 +722,6 @@
element: LibraryImportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
@@ -836,11 +746,6 @@
element: LibraryImportElement
uri: DirectiveUriWithSource
source: package:test/a.dart
- selectedSource: package:test/a.dart
- selectedUriContent: a.dart
- uriContent: a.dart
- uriElement: <null>
- uriSource: package:test/a.dart
''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/part_test.dart b/pkg/analyzer/test/src/dart/resolution/part_test.dart
index 2f9c069..82d8c26 100644
--- a/pkg/analyzer/test/src/dart/resolution/part_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/part_test.dart
@@ -31,9 +31,6 @@
semicolon: ;
element: DirectiveUriWithSource
source: package:test/a.dart
- uriContent: null
- uriElement: notUnitElement
- uriSource: package:test/a.dart
''');
}
@@ -53,9 +50,6 @@
semicolon: ;
element: DirectiveUriWithRelativeUriString
relativeUriString: :net
- uriContent: null
- uriElement: notUnitElement
- uriSource: <null>
''');
}
@@ -85,9 +79,6 @@
stringValue: null
semicolon: ;
element: DirectiveUri
- uriContent: null
- uriElement: notUnitElement
- uriSource: <null>
''');
}
@@ -107,9 +98,6 @@
semicolon: ;
element: DirectiveUriWithRelativeUri
relativeUri: foo:bar
- uriContent: null
- uriElement: notUnitElement
- uriSource: <null>
''');
}
@@ -131,9 +119,6 @@
semicolon: ;
element: DirectiveUriWithUnit
uri: package:test/a.dart
- uriContent: null
- uriElement: unitElement package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -154,9 +139,6 @@
semicolon: ;
element: DirectiveUriWithUnit
uri: package:test/a.dart
- uriContent: null
- uriElement: unitElement package:test/a.dart
- uriSource: package:test/a.dart
''');
}
@@ -179,9 +161,6 @@
semicolon: ;
element: DirectiveUriWithSource
source: package:test/a.dart
- uriContent: null
- uriElement: notUnitElement
- uriSource: package:test/a.dart
''');
}
@@ -202,9 +181,6 @@
semicolon: ;
element: DirectiveUriWithSource
source: package:test/a.dart
- uriContent: null
- uriElement: notUnitElement
- uriSource: package:test/a.dart
''');
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index e101a50..cf74902 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -404,15 +404,6 @@
}
}
- void assertNamespaceDirectiveSelected(
- NamespaceDirective directive, {
- required String expectedRelativeUri,
- required String expectedUri,
- }) {
- expect(directive.selectedUriContent, expectedRelativeUri);
- expect('${directive.selectedSource!.uri}', expectedUri);
- }
-
Future<void> assertNoErrorsInCode(String code) async {
addTestFile(code);
await resolveTestFile();
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index d1c30e3..521477e 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -130,9 +130,6 @@
_withIndent(() {
_writeNamedChildEntities(node);
_writeElement('element', node.element2);
- _writeRaw('uriContent', node.uriContent);
- _writeElement('uriElement', node.uriElement);
- _writeSource('uriSource', node.uriSource);
});
}
@@ -427,11 +424,6 @@
_withIndent(() {
_writeNamedChildEntities(node);
_writeElement('element', node.element2);
- _writeSource('selectedSource', node.selectedSource);
- _writeRaw('selectedUriContent', node.selectedUriContent);
- _writeRaw('uriContent', node.uriContent);
- _writeElement('uriElement', node.uriElement);
- _writeSource('uriSource', node.uriSource);
});
}
@@ -696,11 +688,6 @@
_withIndent(() {
_writeNamedChildEntities(node);
_writeElement('element', node.element2);
- _writeSource('selectedSource', node.selectedSource);
- _writeRaw('selectedUriContent', node.selectedUriContent);
- _writeRaw('uriContent', node.uriContent);
- _writeElement('uriElement', node.uriElement);
- _writeSource('uriSource', node.uriSource);
});
}
@@ -902,9 +889,6 @@
_withIndent(() {
_writeNamedChildEntities(node);
_writeElement('element', node.element2);
- _writeRaw('uriContent', node.uriContent);
- _writePartUnitElement('uriElement', node.uriElement);
- _writeSource('uriSource', node.uriSource);
});
}
@@ -1604,30 +1588,10 @@
_writeDirectiveUri(element.uri);
}
- void _writePartUnitElement(String name, Element? element) {
- if (_withResolution) {
- _sink.write(_indent);
- _sink.write('$name: ');
- if (element is CompilationUnitElement) {
- _sink.writeln('unitElement ${_stringOfSource(element.source)}');
- } else {
- _sink.writeln('notUnitElement');
- }
- }
- }
-
void _writeRaw(String name, Object? value) {
_writelnWithIndent('$name: $value');
}
- void _writeSource(String name, Source? source) {
- if (source != null) {
- _writelnWithIndent('$name: ${source.uri}');
- } else {
- _writelnWithIndent('$name: <null>');
- }
- }
-
void _writeToken(String name, Token? token) {
if (token != null) {
_sink.write(_indent);
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
index 43e340b..ec84066 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
@@ -1614,7 +1614,7 @@
var isLastExistingDart = false;
var isLastExistingPackage = false;
for (var existingImport in importDirectives) {
- var existingUri = existingImport.uriContent ?? '';
+ var existingUri = existingImport.uri.stringValue ?? '';
var isExistingDart = existingUri.startsWith('dart:');
var isExistingPackage = existingUri.startsWith('package:');
diff --git a/pkg/nnbd_migration/lib/src/fix_aggregator.dart b/pkg/nnbd_migration/lib/src/fix_aggregator.dart
index f307882..14750b4 100644
--- a/pkg/nnbd_migration/lib/src/fix_aggregator.dart
+++ b/pkg/nnbd_migration/lib/src/fix_aggregator.dart
@@ -607,7 +607,7 @@
/// an existing [directive].
bool _shouldImportGoBefore(String newImportUri, Directive directive) {
if (directive is ImportDirective) {
- return newImportUri.compareTo(directive.uriContent!) < 0;
+ return newImportUri.compareTo(directive.uri.stringValue!) < 0;
} else if (directive is LibraryDirective) {
// Library directives must come before imports.
return false;
diff --git a/pkg/nnbd_migration/lib/src/fix_builder.dart b/pkg/nnbd_migration/lib/src/fix_builder.dart
index b4c14e7..05c8ff4 100644
--- a/pkg/nnbd_migration/lib/src/fix_builder.dart
+++ b/pkg/nnbd_migration/lib/src/fix_builder.dart
@@ -1191,7 +1191,7 @@
for (var directive in unit.directives) {
if (directive is ImportDirective &&
directive.prefix == null &&
- directive.uriContent == uri) {
+ directive.uri.stringValue == uri) {
return directive;
}
}
diff --git a/pkg/nnbd_migration/lib/src/front_end/info_builder.dart b/pkg/nnbd_migration/lib/src/front_end/info_builder.dart
index 15b67af..efef185 100644
--- a/pkg/nnbd_migration/lib/src/front_end/info_builder.dart
+++ b/pkg/nnbd_migration/lib/src/front_end/info_builder.dart
@@ -497,7 +497,7 @@
/// it if found, or `null` if not found.
ImportDirective? _findImportDirective(CompilationUnit unit, String uri) {
for (var directive in unit.directives) {
- if (directive is ImportDirective && directive.uriContent == uri) {
+ if (directive is ImportDirective && directive.uri.stringValue == uri) {
return directive;
}
}
diff --git a/tools/VERSION b/tools/VERSION
index d5cd0a9..3ceeb63 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 19
PATCH 0
-PRERELEASE 47
+PRERELEASE 48
PRERELEASE_PATCH 0
\ No newline at end of file