Revert "analyzer: Support doc-imports with prefixes"
This reverts commit 292987fb1dad24c3203fbb5187513dcb95d6c8e7.
The commit appears to poorly regress:
* analysis-server-cold-analysis RunTimeRaw by 16%
* analysis-server-cold-memory Memoryuse by 24%
Change-Id: I82363a7efca0ccaabd3dc0f58ab0bbd699f4cdae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403502
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 38b40fe..578f72b 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -99,7 +99,7 @@
// TODO(scheglov): Clean up the list of implicitly analyzed files.
class AnalysisDriver {
/// The version of data format, should be incremented on every format change.
- static const int DATA_VERSION = 425;
+ static const int DATA_VERSION = 426;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
@@ -1374,6 +1374,17 @@
},
);
+ for (var import in library.docImports) {
+ if (import is LibraryImportWithFile) {
+ if (import.importedLibrary case var libraryFileKind?) {
+ await libraryContext.load(
+ targetLibrary: libraryFileKind,
+ performance: OperationPerformanceImpl('<root>'),
+ );
+ }
+ }
+ }
+
var analysisOptions = file.analysisOptions;
var libraryElement =
libraryContext.elementFactory.libraryOfUri2(library.file.uri);
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 7bf9c52..c3e0b7f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -204,7 +204,7 @@
List<LibraryExportState>? _libraryExports;
List<LibraryImportState>? _libraryImports;
List<PartIncludeState>? _partIncludes;
- List<LibraryImportState>? _docLibraryImports;
+ List<LibraryImportState>? _docImports;
FileKind({
required this.file,
@@ -223,12 +223,12 @@
}
/// The import states of each `@docImport` on the library directive.
- List<LibraryImportState> get docLibraryImports {
- if (_docLibraryImports case var existing?) {
+ List<LibraryImportState> get docImports {
+ if (_docImports case var existing?) {
return existing;
}
- return _docLibraryImports =
+ return _docImports =
_unlinkedDocImports.map(_buildLibraryImportState).toFixedList();
}
@@ -382,7 +382,7 @@
libraryExports;
libraryImports;
partIncludes;
- docLibraryImports;
+ docImports;
}
@mustCallSuper
@@ -392,7 +392,7 @@
_libraryExports?.disposeAll();
_libraryImports?.disposeAll();
_partIncludes?.disposeAll();
- _docLibraryImports?.disposeAll();
+ _docImports?.disposeAll();
}
/// Dispose the containing [LibraryFileKind] cycle.
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index 2bde88f..f987a76 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -185,7 +185,6 @@
ScopeResolverVisitor(
fileAnalysis.errorReporter,
nameScope: unitElement.scope,
- unitElement: unitElement,
),
);
@@ -821,7 +820,7 @@
for (var i = 0; i < docImports.length; i++) {
_resolveLibraryDocImportDirective(
directive: docImports[i].import as ImportDirectiveImpl,
- state: fileKind.docLibraryImports[i],
+ state: fileKind.docImports[i],
errorReporter: containerErrorReporter,
);
}
@@ -855,10 +854,16 @@
_testingData?.recordTypeConstraintGenerationDataForTesting(
fileAnalysis.file.uri, inferenceDataForTesting!);
+ var docImportLibraries = [
+ for (var import in _library.docImports)
+ if (import is LibraryImportWithFile)
+ _libraryElement.session.elementFactory
+ .libraryOfUri2(import.importedFile.uri)
+ ];
unit.accept(ScopeResolverVisitor(
fileAnalysis.errorReporter,
nameScope: unitElement.scope,
- unitElement: unitElement,
+ docImportLibraries: docImportLibraries,
));
// Nothing for RESOLVED_UNIT8?
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_graph.dart b/pkg/analyzer/lib/src/dart/analysis/library_graph.dart
index 50b3be2..a4de133 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_graph.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_graph.dart
@@ -195,9 +195,6 @@
...fileKind.libraryExports
.whereType<LibraryExportWithFile>()
.map((export) => export.exportedLibrary),
- ...fileKind.docLibraryImports
- .whereType<LibraryImportWithFile>()
- .map((import) => import.importedLibrary),
];
})
.flattenedToList
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index acf5f3b..52fde6f 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -781,19 +781,12 @@
List<LibraryImportElementImpl> _libraryImports =
_Sentinel.libraryImportElement;
- /// The libraries imported by this unit with a `@docImport`.
- List<LibraryImportElementImpl> _docLibraryImports =
- _Sentinel.libraryImportElement;
-
/// The cached list of prefixes from [libraryImports].
List<PrefixElementImpl>? _libraryImportPrefixes;
/// The cached list of prefixes from [prefixes].
List<PrefixElementImpl2>? _libraryImportPrefixes2;
- /// The cached list of prefixes from [docLibraryImports].
- List<PrefixElementImpl2>? _docLibraryImportPrefixes;
-
/// The parts included by this unit.
List<PartElementImpl> _parts = const <PartElementImpl>[];
@@ -906,23 +899,6 @@
@override
List<ClassFragment> get classes2 => classes.cast<ClassFragment>();
- List<PrefixElementImpl2> get docLibraryImportPrefixes {
- return _docLibraryImportPrefixes ??= _buildDocLibraryImportPrefixes();
- }
-
- List<LibraryImportElementImpl> get docLibraryImports {
- linkedData?.read(this);
- return _docLibraryImports;
- }
-
- set docLibraryImports(List<LibraryImportElementImpl> imports) {
- _docLibraryImports = imports;
- }
-
- List<LibraryImportElementImpl> get docLibraryImports_unresolved {
- return _docLibraryImports;
- }
-
@override
LibraryElementImpl get element => library;
@@ -1323,17 +1299,6 @@
);
}
- List<PrefixElementImpl2> _buildDocLibraryImportPrefixes() {
- var prefixes = <PrefixElementImpl2>{};
- for (var import in docLibraryImports) {
- var prefix = import.prefix2?.element;
- if (prefix is PrefixElementImpl2) {
- prefixes.add(prefix);
- }
- }
- return prefixes.toFixedList();
- }
-
List<PrefixElementImpl> _buildLibraryImportPrefixes() {
var prefixes = <PrefixElementImpl>{};
for (var import in libraryImports) {
@@ -9414,13 +9379,9 @@
/// The scope of this prefix, `null` if not set yet.
PrefixScope? _scope;
- final bool _isDocLibraryImport;
-
/// Initialize a newly created method element to have the given [name] and
/// [nameOffset].
- PrefixElementImpl(String super.name, super.nameOffset,
- {super.reference, required bool isDocLibraryImport})
- : _isDocLibraryImport = isDocLibraryImport;
+ PrefixElementImpl(String super.name, super.nameOffset, {super.reference});
@override
List<Element2> get children2 => const [];
@@ -9429,15 +9390,9 @@
String get displayName => name;
PrefixElementImpl2 get element2 {
- if (_isDocLibraryImport) {
- return enclosingElement3.docLibraryImportPrefixes.firstWhere((element) {
- return (element.name3 ?? '') == name;
- });
- } else {
- return enclosingElement3.prefixes.firstWhere((element) {
- return (element.name3 ?? '') == name;
- });
- }
+ return enclosingElement3.prefixes.firstWhere((element) {
+ return (element.name3 ?? '') == name;
+ });
}
@override
@@ -9495,14 +9450,10 @@
PrefixFragmentImpl lastFragment;
- final bool _isDocLibraryImport;
-
PrefixElementImpl2({
required this.reference,
required this.firstFragment,
- required bool isDocLibraryImport,
- }) : lastFragment = firstFragment,
- _isDocLibraryImport = isDocLibraryImport {
+ }) : lastFragment = firstFragment {
reference.element2 = this;
}
@@ -9524,15 +9475,9 @@
@override
List<LibraryImportElementImpl> get imports {
- if (_isDocLibraryImport) {
- return firstFragment.enclosingFragment.docLibraryImports
- .where((import) => import.prefix2?.element == this)
- .toList();
- } else {
- return firstFragment.enclosingFragment.libraryImports
- .where((import) => import.prefix2?.element == this)
- .toList();
- }
+ return firstFragment.enclosingFragment.libraryImports
+ .where((import) => import.prefix2?.element == this)
+ .toList();
}
@override
diff --git a/pkg/analyzer/lib/src/dart/element/scope.dart b/pkg/analyzer/lib/src/dart/element/scope.dart
index db17e38..b807e30 100644
--- a/pkg/analyzer/lib/src/dart/element/scope.dart
+++ b/pkg/analyzer/lib/src/dart/element/scope.dart
@@ -2,9 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-/// @docImport 'package:analyzer/src/generated/resolver.dart';
-library;
-
import 'package:_fe_analyzer_shared/src/scanner/string_canonicalizer.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -30,58 +27,32 @@
}
}
-/// The scope that looks up elements in documentation comments.
+/// The scope that looks up elements in doc imports.
///
/// Attempts to look up elements in its [innerScope] before searching
-/// through any doc imports.
-class DocumentationCommentScope implements Scope {
+/// through the doc imports.
+class DocImportScope with _GettersAndSetters implements Scope {
/// The scope that will be prioritized in look ups before searching in doc
/// imports.
///
- /// Will be set for each specific comment scope in the [ScopeResolverVisitor].
+ /// Will be set for each specific comment scope in the `ScopeResolverVisitor`.
Scope innerScope;
- final LibraryFragmentScope? _parent;
-
- final CompilationUnitElementImpl _fragment;
-
- final PrefixScope _noPrefixScope;
-
- final Map<String, PrefixElementImpl2> _prefixElements = {};
-
- factory DocumentationCommentScope(
- Scope innerScope, CompilationUnitElementImpl fragment) {
- var parent = fragment.enclosingElement3?.scope;
- return DocumentationCommentScope._(
- innerScope: innerScope,
- parent: parent,
- fragment: fragment,
- noPrefixScope: PrefixScope(
- libraryFragment: fragment,
- parent: parent?._noPrefixScope,
- libraryImports: fragment.docLibraryImports,
- prefix: null,
- ),
- );
- }
-
- DocumentationCommentScope._({
- required this.innerScope,
- required LibraryFragmentScope? parent,
- required CompilationUnitElementImpl fragment,
- required PrefixScope noPrefixScope,
- }) : _parent = parent,
- _fragment = fragment,
- _noPrefixScope = noPrefixScope {
- for (var prefix in fragment.docLibraryImportPrefixes) {
- var prefix1 = prefix.asElement;
- _prefixElements[prefix1.name] = prefix;
- prefix1.scope = PrefixScope(
- libraryFragment: fragment,
- parent: _getParentPrefixScope(prefix1),
- libraryImports: fragment.docLibraryImports,
- prefix: prefix1,
- );
+ DocImportScope(this.innerScope, List<LibraryElement> docImportLibraries) {
+ for (var importedLibrary in docImportLibraries) {
+ if (importedLibrary is LibraryElementImpl) {
+ // TODO(kallentu): Handle combinators.
+ for (var exportedReference in importedLibrary.exportedReferences) {
+ var reference = exportedReference.reference;
+ var element = importedLibrary.session.elementFactory
+ .elementOfReference(reference)!;
+ if (element is PropertyAccessorElement && element.isSetter) {
+ _addSetter(element);
+ } else {
+ _addGetter(element);
+ }
+ }
+ }
}
}
@@ -89,50 +60,10 @@
ScopeLookupResult lookup(String id) {
var result = innerScope.lookup(id);
if (result.getter != null || result.setter != null) return result;
-
- // Try the combined import scope.
- var importResult = _lookupCombined(id);
- if (importResult != null) {
- return importResult;
- }
-
- // No result.
- return ScopeLookupResultImpl(getter: null, setter: null);
- }
-
- PrefixScope? _getParentPrefixScope(PrefixElementImpl prefix) {
- var isDeferred = prefix.imports
- .any((import) => import.prefix is DeferredImportElementPrefix);
- if (isDeferred) {
- return null;
- }
-
- for (var scope = _parent; scope != null; scope = scope._parent) {
- var parentPrefix = scope._prefixElements[prefix.name];
- if (parentPrefix != null) {
- return parentPrefix.scope;
- }
- }
- return null;
- }
-
- ScopeLookupResult? _lookupCombined(String id) {
- // Try prefix elements.
- if (_fragment.isAllowedAsPrefixElement(id)) {
- if (_prefixElements[id] case var prefixElement?) {
- var prefix1 = prefixElement.asElement;
- return ScopeLookupResultImpl(getter: prefix1, setter: null);
- }
- }
-
- // Try imports of the library fragment.
- var noPrefixResult = _noPrefixScope.lookup(id);
- if (noPrefixResult.getter != null || noPrefixResult.setter != null) {
- return noPrefixResult;
- }
-
- // Try the parent's combined import scope.
- return _parent?._lookupCombined(id);
+ return ScopeLookupResultImpl(
+ getter: _getters[id],
+ setter: _setters[id],
+ );
}
}
@@ -404,9 +335,9 @@
}
class LibraryFragmentScope implements Scope {
- final LibraryFragmentScope? _parent;
- final CompilationUnitElementImpl _fragment;
- final PrefixScope _noPrefixScope;
+ final LibraryFragmentScope? parent;
+ final CompilationUnitElementImpl fragment;
+ final PrefixScope noPrefixScope;
final Map<String, PrefixElementImpl> _prefixElements = {};
@@ -428,7 +359,7 @@
fragment: fragment,
noPrefixScope: PrefixScope(
libraryFragment: fragment,
- parent: parent?._noPrefixScope,
+ parent: parent?.noPrefixScope,
libraryImports: fragment.libraryImports,
prefix: null,
),
@@ -436,31 +367,29 @@
}
LibraryFragmentScope._({
- required LibraryFragmentScope? parent,
- required CompilationUnitElementImpl fragment,
- required PrefixScope noPrefixScope,
- }) : _parent = parent,
- _fragment = fragment,
- _noPrefixScope = noPrefixScope {
- for (var prefix in _fragment.libraryImportPrefixes) {
+ required this.parent,
+ required this.fragment,
+ required this.noPrefixScope,
+ }) {
+ for (var prefix in fragment.libraryImportPrefixes) {
_prefixElements[prefix.name] = prefix;
prefix.scope = PrefixScope(
libraryFragment: fragment,
parent: _getParentPrefixScope(prefix),
- libraryImports: _fragment.libraryImports,
+ libraryImports: fragment.libraryImports,
prefix: prefix,
);
}
}
- /// The extensions accessible within [_fragment].
+ /// The extensions accessible within [fragment].
List<ExtensionElement> get accessibleExtensions {
- var libraryDeclarations = _fragment.library.libraryDeclarations;
+ var libraryDeclarations = fragment.library.libraryDeclarations;
return _extensions ??= {
...libraryDeclarations.extensions,
- ..._noPrefixScope._extensions,
+ ...noPrefixScope._extensions,
for (var prefix in _prefixElements.values) ...prefix.scope._extensions,
- ...?_parent?.accessibleExtensions,
+ ...?parent?.accessibleExtensions,
}.toFixedList();
}
@@ -476,7 +405,7 @@
}
void importsTrackingDestroy() {
- _noPrefixScope.importsTrackingDestroy();
+ noPrefixScope.importsTrackingDestroy();
for (var prefixElement in _prefixElements.values) {
prefixElement.scope.importsTrackingDestroy();
}
@@ -486,7 +415,7 @@
ImportsTracking importsTrackingInit() {
return _importsTracking = ImportsTracking(
map: {
- null: _noPrefixScope.importsTrackingInit(),
+ null: noPrefixScope.importsTrackingInit(),
for (var prefixElement in _prefixElements.values)
prefixElement: prefixElement.scope.importsTrackingInit(),
},
@@ -525,7 +454,7 @@
return null;
}
- for (var scope = _parent; scope != null; scope = scope._parent) {
+ for (var scope = parent; scope != null; scope = scope.parent) {
var parentPrefix = scope._prefixElements[prefix.name];
if (parentPrefix != null) {
return parentPrefix.scope;
@@ -536,7 +465,7 @@
ScopeLookupResult? _lookupCombined(String id) {
// Try prefix elements.
- if (_fragment.isAllowedAsPrefixElement(id)) {
+ if (_shouldTryPrefixElement(id)) {
if (_prefixElements[id] case var prefixElement?) {
return ScopeLookupResultImpl(
getter: prefixElement,
@@ -546,17 +475,17 @@
}
// Try imports of the library fragment.
- var noPrefixResult = _noPrefixScope.lookup(id);
+ var noPrefixResult = noPrefixScope.lookup(id);
if (noPrefixResult.getter != null || noPrefixResult.setter != null) {
return noPrefixResult;
}
// Try the parent's combined import scope.
- return _parent?._lookupCombined(id);
+ return parent?._lookupCombined(id);
}
ScopeLookupResult? _lookupLibrary(String id) {
- var libraryDeclarations = _fragment.library.libraryDeclarations;
+ var libraryDeclarations = fragment.library.libraryDeclarations;
var libraryGetter = libraryDeclarations._getters[id];
var librarySetter = libraryDeclarations._setters[id];
if (libraryGetter != null || librarySetter != null) {
@@ -567,6 +496,14 @@
}
return null;
}
+
+ bool _shouldTryPrefixElement(String id) {
+ if (id == '_') {
+ var featureSet = fragment.library.featureSet;
+ return !featureSet.isEnabled(Feature.wildcard_variables);
+ }
+ return true;
+ }
}
class LocalScope extends EnclosedScope {
@@ -886,15 +823,3 @@
}
}
}
-
-extension on CompilationUnitElementImpl {
- /// Whether we should try to resolve an element via a prefix named '_' (which
- /// depends on whether the 'wildcard-variables' feature is enabled).
- bool isAllowedAsPrefixElement(String id) {
- if (id == '_') {
- var featureSet = library.featureSet;
- return !featureSet.isEnabled(Feature.wildcard_variables);
- }
- return true;
- }
-}
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 5149e92..c020b96 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -4522,7 +4522,7 @@
Scope nameScope;
/// The scope of libraries imported by `@docImport`s.
- final DocumentationCommentScope _docImportScope;
+ final DocImportScope _docImportScope;
/// The scope used to resolve unlabeled `break` and `continue` statements.
ImplicitLabelScope _implicitLabelScope = ImplicitLabelScope.ROOT;
@@ -4548,8 +4548,8 @@
ScopeResolverVisitor(
this.errorReporter, {
required this.nameScope,
- required CompilationUnitElementImpl unitElement,
- }) : _docImportScope = DocumentationCommentScope(nameScope, unitElement);
+ List<LibraryElement> docImportLibraries = const [],
+ }) : _docImportScope = DocImportScope(nameScope, docImportLibraries);
/// Return the implicit label scope in which the current node is being
/// resolved.
@@ -5407,7 +5407,7 @@
}
}
- /// Visits a documentation comment with a [DocumentationCommentScope] that encloses the
+ /// Visits a documentation comment with a [DocImportScope] that encloses the
/// current [nameScope].
void _visitDocumentationComment(CommentImpl? node) {
if (node == null) return;
diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
index e265bbe..61e0852 100644
--- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
@@ -302,8 +302,7 @@
return parameter;
}
- static PrefixElementImpl prefix(String name) =>
- PrefixElementImpl(name, 0, isDocLibraryImport: false);
+ static PrefixElementImpl prefix(String name) => PrefixElementImpl(name, 0);
static ParameterElementImpl requiredParameter(String name) {
return ParameterElementImpl(
diff --git a/pkg/analyzer/lib/src/summary2/ast_resolver.dart b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
index b8eef05..dcdf5fe 100644
--- a/pkg/analyzer/lib/src/summary2/ast_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
@@ -40,7 +40,6 @@
late final _scopeResolverVisitor = ScopeResolverVisitor(
ErrorReporter(_errorListener, _unitElement.source),
nameScope: _nameScope,
- unitElement: _unitElement,
);
late final _flowAnalysis = FlowAnalysisHelper(false, _featureSet,
typeSystemOperations: TypeSystemOperations(
diff --git a/pkg/analyzer/lib/src/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
index 7b77438..e778690 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
@@ -198,13 +198,6 @@
);
}
- for (var import in element.docLibraryImports) {
- var uri = import.uri;
- if (uri is DirectiveUriWithLibraryImpl) {
- uri.library = reader.libraryOfUri(uri.source.uri);
- }
- }
-
applyConstantOffsets?.perform();
}
}
@@ -1226,20 +1219,19 @@
LibraryImportElementImpl _readImportElement({
required CompilationUnitElementImpl containerUnit,
- required bool isDocLibraryImport,
}) {
var element = LibraryImportElementImpl(
combinators: _reader.readTypedList(_readNamespaceCombinator),
importKeywordOffset: -1,
prefix: _readImportElementPrefix(
containerUnit: containerUnit,
- isDocLibraryImport: isDocLibraryImport,
),
prefix2: _readLibraryImportPrefixFragment(
libraryFragment: containerUnit,
- isDocLibraryImport: isDocLibraryImport,
),
- uri: _readDirectiveUri(containerUnit: containerUnit),
+ uri: _readDirectiveUri(
+ containerUnit: containerUnit,
+ ),
);
LibraryImportElementFlags.read(_reader, element);
return element;
@@ -1247,7 +1239,6 @@
ImportElementPrefixImpl? _readImportElementPrefix({
required CompilationUnitElementImpl containerUnit,
- required bool isDocLibraryImport,
}) {
PrefixElementImpl buildElement(String name, Reference reference) {
// TODO(scheglov): Make reference required.
@@ -1255,12 +1246,7 @@
if (existing is PrefixElementImpl) {
return existing;
} else {
- var result = PrefixElementImpl(
- name,
- -1,
- reference: reference,
- isDocLibraryImport: isDocLibraryImport,
- );
+ var result = PrefixElementImpl(name, -1, reference: reference);
result.enclosingElement3 = containerUnit;
return result;
}
@@ -1303,7 +1289,6 @@
PrefixFragmentImpl? _readLibraryImportPrefixFragment({
required CompilationUnitElementImpl libraryFragment,
- required bool isDocLibraryImport,
}) {
return _reader.readOptionalObject((reader) {
var fragmentName = _readFragmentName();
@@ -1321,7 +1306,6 @@
element = PrefixElementImpl2(
reference: reference,
firstFragment: fragment,
- isDocLibraryImport: isDocLibraryImport,
);
} else {
element.addFragment(fragment);
@@ -1839,7 +1823,6 @@
unitElement.libraryImports = _reader.readTypedList(() {
return _readImportElement(
containerUnit: unitElement,
- isDocLibraryImport: false,
);
});
@@ -1849,13 +1832,6 @@
);
});
- unitElement.docLibraryImports = _reader.readTypedList(() {
- return _readImportElement(
- containerUnit: unitElement,
- isDocLibraryImport: true,
- );
- });
-
_readClasses(unitElement, unitReference);
_readEnums(unitElement, unitReference);
_readExtensions(unitElement, unitReference);
diff --git a/pkg/analyzer/lib/src/summary2/bundle_writer.dart b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
index 1dc01dc..c2d7a61 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
@@ -725,7 +725,6 @@
// Write the metadata for parts here, even though we write parts below.
// The reason is that resolution data must be in a single chunk.
_writePartElementsMetadata(unitElement);
- _writeList(unitElement.docLibraryImports, _writeImportElement);
_writeList(unitElement.classes, _writeClassElement);
_writeList(unitElement.enums, _writeEnumElement);
diff --git a/pkg/analyzer/lib/src/summary2/informative_data.dart b/pkg/analyzer/lib/src/summary2/informative_data.dart
index 2caf51a..19a4513 100644
--- a/pkg/analyzer/lib/src/summary2/informative_data.dart
+++ b/pkg/analyzer/lib/src/summary2/informative_data.dart
@@ -100,7 +100,6 @@
unitElement.setCodeRange(unitInfo.codeOffset, unitInfo.codeLength);
unitElement.lineInfo = LineInfo(unitInfo.lineStarts);
- _applyToDocImports(unitElement.docLibraryImports_unresolved, unitInfo);
_applyToImports(unitElement.libraryImports_unresolved, unitInfo);
_applyToExports(unitElement.libraryExports_unresolved, unitInfo);
@@ -108,7 +107,6 @@
unitInfo.libraryConstantOffsets,
(applier) {
applier.applyToMetadata(unitElement);
- applier.applyToImports(unitElement.docLibraryImports);
applier.applyToImports(unitElement.libraryImports);
applier.applyToExports(unitElement.libraryExports);
applier.applyToParts(unitElement.parts);
@@ -339,32 +337,6 @@
);
}
- void _applyToDocImports(
- List<LibraryImportElementImpl> imports,
- _InfoUnit info,
- ) {
- forCorrespondingPairs<LibraryImportElement, _InfoImport>(
- imports,
- info.docImports,
- (element, info) {
- element as LibraryImportElementImpl;
- element.nameOffset = info.nameOffset;
-
- var prefixElement = element.prefix?.element;
- if (prefixElement is PrefixElementImpl) {
- if (prefixElement.nameOffset == -1) {
- prefixElement.nameOffset = info.prefixOffset;
- }
- }
-
- if (element.prefix2 case var prefixFragment?) {
- prefixFragment.nameOffset2 = info.prefixOffset2;
- }
- _applyToCombinators(element.combinators, info.combinators);
- },
- );
- }
-
void _applyToEnumDeclaration(
EnumElement element,
_InfoClassDeclaration info,
@@ -1464,19 +1436,6 @@
var firstDirective = unit.directives.firstOrNull;
_writeDocumentationCommentNode(firstDirective?.documentationComment);
- var libraryDirective =
- unit.directives.whereType<LibraryDirective>().firstOrNull;
- var docImports = libraryDirective?.documentationComment?.docImports;
- var docImportDirectives =
- docImports?.map((e) => e.import).toList() ?? <ImportDirective>[];
-
- sink.writeList2<ImportDirective>(docImportDirectives, (directive) {
- sink.writeUInt30(directive.importKeyword.offset);
- sink.writeUInt30(1 + (directive.prefix?.offset ?? -1));
- sink.writeOptionalUInt30(directive.prefix?.token.offsetIfNotEmpty);
- _writeCombinators(directive.combinators);
- });
-
sink.writeList2<ImportDirective>(unit.directives, (directive) {
sink.writeUInt30(directive.importKeyword.offset);
sink.writeUInt30(1 + (directive.prefix?.offset ?? -1));
@@ -2068,7 +2027,6 @@
final _InfoLibraryName libraryName;
final Uint32List libraryConstantOffsets;
final String docComment;
- final List<_InfoImport> docImports;
final List<_InfoImport> imports;
final List<_InfoExport> exports;
final List<_InfoPart> parts;
@@ -2093,9 +2051,6 @@
libraryName: _InfoLibraryName(reader),
libraryConstantOffsets: reader.readUInt30List(),
docComment: reader.readStringUtf8(),
- docImports: reader.readTypedList(
- () => _InfoImport(reader),
- ),
imports: reader.readTypedList(
() => _InfoImport(reader),
),
@@ -2148,7 +2103,6 @@
required this.libraryName,
required this.libraryConstantOffsets,
required this.docComment,
- required this.docImports,
required this.imports,
required this.exports,
required this.parts,
diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart
index 1415922..1bb119f 100644
--- a/pkg/analyzer/lib/src/summary2/library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/library_builder.dart
@@ -942,7 +942,6 @@
return _buildLibraryImport(
containerUnit: containerUnit,
state: state,
- isDocLibraryImport: false,
);
}).toFixedList();
@@ -953,14 +952,6 @@
state: partState,
);
}).toFixedList();
-
- containerUnit.docLibraryImports = kind.docLibraryImports.map((state) {
- return _buildLibraryImport(
- containerUnit: containerUnit,
- state: state,
- isDocLibraryImport: true,
- );
- }).toFixedList();
}
LibraryExportElementImpl _buildLibraryExport(LibraryExportState state) {
@@ -1036,14 +1027,12 @@
LibraryImportElementImpl _buildLibraryImport({
required CompilationUnitElementImpl containerUnit,
required LibraryImportState state,
- required bool isDocLibraryImport,
}) {
var importPrefix = state.unlinked.prefix.mapOrNull((unlinked) {
var prefix = _buildLibraryImportPrefix(
nameOffset: unlinked.nameOffset,
name: unlinked.name,
containerUnit: containerUnit,
- isDocLibraryImport: isDocLibraryImport,
);
if (unlinked.deferredOffset != null) {
return DeferredImportElementPrefixImpl(
@@ -1061,7 +1050,6 @@
libraryFragment: containerUnit,
unlinkedName: unlinked.name,
isDeferred: unlinked.deferredOffset != null,
- isDocLibraryImport: isDocLibraryImport,
);
});
@@ -1140,7 +1128,6 @@
required int nameOffset,
required UnlinkedLibraryImportPrefixName? name,
required CompilationUnitElementImpl containerUnit,
- required bool isDocLibraryImport,
}) {
// TODO(scheglov): Make reference required.
var containerRef = containerUnit.reference!;
@@ -1154,7 +1141,6 @@
name?.name ?? '',
nameOffset,
reference: reference,
- isDocLibraryImport: isDocLibraryImport,
);
result.enclosingElement3 = containerUnit;
return result;
@@ -1165,7 +1151,6 @@
required CompilationUnitElementImpl libraryFragment,
required UnlinkedLibraryImportPrefixName? unlinkedName,
required bool isDeferred,
- required bool isDocLibraryImport,
}) {
var fragment = PrefixFragmentImpl(
enclosingFragment: libraryFragment,
@@ -1183,7 +1168,6 @@
element = PrefixElementImpl2(
reference: reference,
firstFragment: fragment,
- isDocLibraryImport: isDocLibraryImport,
);
} else {
element.addFragment(fragment);
diff --git a/pkg/analyzer/test/src/dart/analysis/analyzer_state_printer.dart b/pkg/analyzer/test/src/dart/analysis/analyzer_state_printer.dart
index 6088465..1860679 100644
--- a/pkg/analyzer/test/src/dart/analysis/analyzer_state_printer.dart
+++ b/pkg/analyzer/test/src/dart/analysis/analyzer_state_printer.dart
@@ -118,8 +118,8 @@
void _writeDocImports(FileKind container) {
_writeElements<LibraryImportState>(
- 'docLibraryImports',
- container.docLibraryImports,
+ 'docImports',
+ container.docImports,
(import) {
expect(import.isDocImport, isTrue);
_writeLibraryImport(container, import);
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index 16be3a9..89a0c12 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -394,7 +394,7 @@
@reflectiveTest
class FileSystemState_BlazeWorkspaceTest extends BlazeWorkspaceResolutionTest {
- void test_getFileForUri_hasGenerated_askGeneratedFirst() {
+ void test_getFileForUri_hasGenerated_askGeneratedFirst() {
var relPath = 'dart/my/test/a.dart';
var writablePath = convertPath('$workspaceRootPath/$relPath');
var generatedPath = convertPath('$workspaceRootPath/blaze-bin/$relPath');
@@ -1127,7 +1127,7 @@
kind: library_0
libraryImports
library_1 dart:core synthetic
- docLibraryImports
+ docImports
library_3 dart:async
library_5 dart:math
fileKinds: library_0
@@ -4256,7 +4256,7 @@
kind: partOfUriKnown_1
uriFile: file_0
library: library_0
- docLibraryImports
+ docImports
library_4 dart:async
library_6 dart:math
referencingFiles: file_0
@@ -4272,7 +4272,7 @@
''');
fileStateFor(b).refresh();
- // The API signature of the cycle has changed.
+ // The API signature of the cycle is the same.
assertDriverStateString(testFile, r'''
files
/home/test/lib/a.dart
@@ -4288,7 +4288,7 @@
cycle_2
dependencies: dart:core
libraries: library_0
- apiSignature_1
+ apiSignature_0
unlinkedKey: k00
/home/test/lib/b.dart
uri: package:test/b.dart
@@ -4297,7 +4297,7 @@
kind: partOfUriKnown_7
uriFile: file_0
library: library_0
- docLibraryImports
+ docImports
library_4 dart:async
referencingFiles: file_0
unlinkedKey: k02
@@ -4306,175 +4306,6 @@
''');
}
- test_part_docImports_nestedPart() async {
- newFile('$testPackageLibPath/a.dart', r'''
-import 'dart:collection';
-part 'b.dart';
-''');
-
- newFile('$testPackageLibPath/b.dart', r'''
-part of 'a.dart';
-part 'c.dart';
-''');
-
- var c = newFile('$testPackageLibPath/c.dart', r'''
-/// @docImport 'dart:async';
-part of 'b.dart';
-''');
-
- fileStateFor(c);
-
- assertDriverStateString(testFile, r'''
-files
- /home/test/lib/a.dart
- uri: package:test/a.dart
- current
- id: file_0
- kind: library_0
- libraryImports
- library_7 dart:collection
- library_3 dart:core synthetic
- partIncludes
- partOfUriKnown_1
- fileKinds: library_0 partOfUriKnown_1 partOfUriKnown_2
- cycle_0
- dependencies: dart:collection dart:core
- libraries: library_0
- apiSignature_0
- unlinkedKey: k00
- /home/test/lib/b.dart
- uri: package:test/b.dart
- current
- id: file_1
- kind: partOfUriKnown_1
- uriFile: file_0
- library: library_0
- partIncludes
- partOfUriKnown_2
- referencingFiles: file_0
- unlinkedKey: k01
- /home/test/lib/c.dart
- uri: package:test/c.dart
- current
- id: file_2
- kind: partOfUriKnown_2
- uriFile: file_1
- library: library_0
- docLibraryImports
- library_5 dart:async
- referencingFiles: file_1
- unlinkedKey: k02
-libraryCycles
-elementFactory
-''');
-
- // Add import 'dart:math'.
- modifyFile2(c, r'''
-/// @docImport 'dart:async';
-/// @docImport 'dart:math';
-part of 'b.dart';
-''');
- fileStateFor(c).refresh();
-
- // New library cycle, with new 'apiSignature'.
- assertDriverStateString(testFile, r'''
-files
- /home/test/lib/a.dart
- uri: package:test/a.dart
- current
- id: file_0
- kind: library_0
- libraryImports
- library_7 dart:collection
- library_3 dart:core synthetic
- partIncludes
- partOfUriKnown_1
- fileKinds: library_0 partOfUriKnown_1 partOfUriKnown_9
- cycle_3
- dependencies: dart:collection dart:core
- libraries: library_0
- apiSignature_1
- unlinkedKey: k00
- /home/test/lib/b.dart
- uri: package:test/b.dart
- current
- id: file_1
- kind: partOfUriKnown_1
- uriFile: file_0
- library: library_0
- partIncludes
- partOfUriKnown_9
- referencingFiles: file_0
- unlinkedKey: k01
- /home/test/lib/c.dart
- uri: package:test/c.dart
- current
- id: file_2
- kind: partOfUriKnown_9
- uriFile: file_1
- library: library_0
- docLibraryImports
- library_5 dart:async
- library_8 dart:math
- referencingFiles: file_1
- unlinkedKey: k03
-libraryCycles
-elementFactory
-''');
-
- // Remove import 'dart:math'.
- modifyFile2(c, r'''
-/// @docImport 'dart:async';
-part of 'b.dart';
-''');
- fileStateFor(c).refresh();
-
- // New library cycle, with the initial 'apiSignature'.
- assertDriverStateString(testFile, r'''
-files
- /home/test/lib/a.dart
- uri: package:test/a.dart
- current
- id: file_0
- kind: library_0
- libraryImports
- library_7 dart:collection
- library_3 dart:core synthetic
- partIncludes
- partOfUriKnown_1
- fileKinds: library_0 partOfUriKnown_1 partOfUriKnown_10
- cycle_4
- dependencies: dart:collection dart:core
- libraries: library_0
- apiSignature_0
- unlinkedKey: k00
- /home/test/lib/b.dart
- uri: package:test/b.dart
- current
- id: file_1
- kind: partOfUriKnown_1
- uriFile: file_0
- library: library_0
- partIncludes
- partOfUriKnown_10
- referencingFiles: file_0
- unlinkedKey: k01
- /home/test/lib/c.dart
- uri: package:test/c.dart
- current
- id: file_2
- kind: partOfUriKnown_10
- uriFile: file_1
- library: library_0
- docLibraryImports
- library_5 dart:async
- referencingFiles: file_1
- unlinkedKey: k02
-libraryCycles
-elementFactory
-''');
- }
-
test_part_libraryExports() async {
newFile('$testPackageLibPath/a.dart', r'''
export 'dart:collection';
@@ -5264,125 +5095,6 @@
''');
}
- test_refresh_library_docImportedBy_part() {
- var a = newFile('$testPackageLibPath/a.dart', r'''
-part 'b.dart';
-''');
-
- newFile('$testPackageLibPath/b.dart', r'''
-/// @docImport 'c.dart';
-part of 'a.dart';
-''');
-
- var c = newFile('$testPackageLibPath/c.dart', r'''
-class C {}
-''');
-
- fileStateFor(a);
-
- // `c.dart` is doc-imported by `b.dart`, so it is a dependency of `a.dart`.
- assertDriverStateString(testFile, r'''
-files
- /home/test/lib/a.dart
- uri: package:test/a.dart
- current
- id: file_0
- kind: library_0
- libraryImports
- library_3 dart:core synthetic
- partIncludes
- partOfUriKnown_1
- fileKinds: library_0 partOfUriKnown_1
- cycle_0
- dependencies: cycle_1 dart:core
- libraries: library_0
- apiSignature_0
- unlinkedKey: k00
- /home/test/lib/b.dart
- uri: package:test/b.dart
- current
- id: file_1
- kind: partOfUriKnown_1
- uriFile: file_0
- library: library_0
- docLibraryImports
- library_2
- referencingFiles: file_0
- unlinkedKey: k01
- /home/test/lib/c.dart
- uri: package:test/c.dart
- current
- id: file_2
- kind: library_2
- libraryImports
- library_3 dart:core synthetic
- fileKinds: library_2
- cycle_1
- dependencies: dart:core
- libraries: library_2
- apiSignature_1
- users: cycle_0
- referencingFiles: file_1
- unlinkedKey: k02
-libraryCycles
-elementFactory
-''');
-
- newFile(c.path, r'''
-class C2 {}
-''');
- fileStateFor(c).refresh();
-
- // Updated `c.dart` invalidates the library cycle for `a.dart`, both
- // have now different signatures.
- assertDriverStateString(testFile, r'''
-files
- /home/test/lib/a.dart
- uri: package:test/a.dart
- current
- id: file_0
- kind: library_0
- libraryImports
- library_3 dart:core synthetic
- partIncludes
- partOfUriKnown_1
- fileKinds: library_0 partOfUriKnown_1
- cycle_3
- dependencies: cycle_4 dart:core
- libraries: library_0
- apiSignature_2
- unlinkedKey: k00
- /home/test/lib/b.dart
- uri: package:test/b.dart
- current
- id: file_1
- kind: partOfUriKnown_1
- uriFile: file_0
- library: library_0
- docLibraryImports
- library_8
- referencingFiles: file_0
- unlinkedKey: k01
- /home/test/lib/c.dart
- uri: package:test/c.dart
- current
- id: file_2
- kind: library_8
- libraryImports
- library_3 dart:core synthetic
- fileKinds: library_8
- cycle_4
- dependencies: dart:core
- libraries: library_8
- apiSignature_3
- users: cycle_3
- referencingFiles: file_1
- unlinkedKey: k03
-libraryCycles
-elementFactory
-''');
- }
-
test_refresh_library_importedBy_part() {
var a = newFile('$testPackageLibPath/a.dart', r'''
part 'b.dart';
@@ -5399,7 +5111,7 @@
fileStateFor(a);
- // `c.dart` is imported by `b.dart`, so it is a dependency of `a.dart`.
+ // `c.dart` is imported by `b.dart`, so it is a dependency of `c.dart`.
assertDriverStateString(testFile, r'''
files
/home/test/lib/a.dart
diff --git a/pkg/analyzer/test/src/dart/resolution/comment_test.dart b/pkg/analyzer/test/src/dart/resolution/comment_test.dart
index 8205094..2094ebe 100644
--- a/pkg/analyzer/test/src/dart/resolution/comment_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/comment_test.dart
@@ -743,207 +743,6 @@
''');
}
- test_docImport_prefix() async {
- newFile('$testPackageLibPath/foo.dart', r'''
-class A {}
-''');
- await assertNoErrorsInCode(r'''
-/// @docImport 'foo.dart' as foo;
-library;
-
-/// [foo]
-void f() {}
-''');
-
- assertResolvedNodeText(findNode.commentReference('foo]'), r'''
-CommentReference
- expression: SimpleIdentifier
- token: foo
- staticElement: <testLibraryFragment>::@prefix::foo
- element: <testLibraryFragment>::@prefix2::foo
- staticType: null
-''');
- }
-
- test_docImport_prefix_extension() async {
- newFile('$testPackageLibPath/foo.dart', r'''
-extension E on int {}
-''');
- await assertNoErrorsInCode(r'''
-/// @docImport 'foo.dart' as foo;
-library;
-
-/// [foo.E]
-void f() {}
-''');
-
- assertResolvedNodeText(findNode.commentReference('foo.E]'), r'''
-CommentReference
- expression: PrefixedIdentifier
- prefix: SimpleIdentifier
- token: foo
- staticElement: <testLibraryFragment>::@prefix::foo
- element: <testLibraryFragment>::@prefix2::foo
- staticType: null
- period: .
- identifier: SimpleIdentifier
- token: E
- staticElement: package:test/foo.dart::<fragment>::@extension::E
- element: package:test/foo.dart::@extension::E
- staticType: null
- staticElement: package:test/foo.dart::<fragment>::@extension::E
- element: package:test/foo.dart::@extension::E
- staticType: null
-''');
- }
-
- @FailingTest(reason: 'TODO(srawlins): Add support for parts')
- test_docImport_prefix_inPart() async {
- newFile('$testPackageLibPath/foo.dart', r'''
-class A {}
-''');
- newFile('$testPackageLibPath/bar.dart', r'''
-/// @docImport 'foo.dart' as foo;
-library;
-part 'test.dart';
-''');
- await assertNoErrorsInCode(r'''
-part of 'bar.dart';
-
-/// [foo.A]
-void f() {}
-''');
-
- assertResolvedNodeText(findNode.commentReference('foo.A]'), r'''
-CommentReference
- expression: PrefixedIdentifier
- prefix: SimpleIdentifier
- token: foo
- staticElement: package:test/bar.dart::<fragment>::@prefix::foo
- element: package:test/bar.dart::<fragment>::@prefix2::foo
- staticType: null
- period: .
- identifier: SimpleIdentifier
- token: A
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
-''');
- }
-
- test_docImport_prefix_prefixedIdentifier() async {
- newFile('$testPackageLibPath/foo.dart', r'''
-class A {}
-''');
- await assertNoErrorsInCode(r'''
-/// @docImport 'foo.dart' as foo;
-library;
-
-/// [foo.A]
-void f() {}
-''');
-
- assertResolvedNodeText(findNode.commentReference('foo.A]'), r'''
-CommentReference
- expression: PrefixedIdentifier
- prefix: SimpleIdentifier
- token: foo
- staticElement: <testLibraryFragment>::@prefix::foo
- element: <testLibraryFragment>::@prefix2::foo
- staticType: null
- period: .
- identifier: SimpleIdentifier
- token: A
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
-''');
- }
-
- test_docImport_prefix_propertyAccess() async {
- newFile('$testPackageLibPath/foo.dart', r'''
-class A {
- int x = 1;
-}
-''');
- await assertNoErrorsInCode(r'''
-/// @docImport 'foo.dart' as foo;
-library;
-
-/// [foo.A.x]
-void f() {}
-''');
-
- assertResolvedNodeText(findNode.commentReference('foo.A.x]'), r'''
-CommentReference
- expression: PropertyAccess
- target: PrefixedIdentifier
- prefix: SimpleIdentifier
- token: foo
- staticElement: <testLibraryFragment>::@prefix::foo
- element: <testLibraryFragment>::@prefix2::foo
- staticType: null
- period: .
- identifier: SimpleIdentifier
- token: A
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
- operator: .
- propertyName: SimpleIdentifier
- token: x
- staticElement: package:test/foo.dart::<fragment>::@class::A::@getter::x
- element: package:test/foo.dart::<fragment>::@class::A::@getter::x#element
- staticType: null
- staticType: null
-''');
- }
-
- test_docImport_prefix_shared() async {
- newFile('$testPackageLibPath/foo.dart', r'''
-class A {}
-''');
- newFile('$testPackageLibPath/bar.dart', r'''
-class B {}
-''');
- await assertNoErrorsInCode(r'''
-/// @docImport 'foo.dart' as foo;
-/// @docImport 'bar.dart' as foo;
-library;
-
-/// [foo.A]
-void f() {}
-''');
-
- assertResolvedNodeText(findNode.commentReference('foo.A]'), r'''
-CommentReference
- expression: PrefixedIdentifier
- prefix: SimpleIdentifier
- token: foo
- staticElement: <testLibraryFragment>::@prefix::foo
- element: <testLibraryFragment>::@prefix2::foo
- staticType: null
- period: .
- identifier: SimpleIdentifier
- token: A
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
-''');
- }
-
test_extension_instanceGetter() async {
await assertNoErrorsInCode('''
extension E on int {
@@ -2284,32 +2083,6 @@
''');
}
- @FailingTest(reason: 'TODO(srawlins): Add support for parts')
- test_docImport_referencedInPart() async {
- newFile('$testPackageLibPath/foo.dart', r'''
-class A {}
-''');
- newFile('$testPackageLibPath/bar.dart', r'''
-/// @docImport 'foo.dart';
-library;
-part 'test.dart';
-''');
- await assertNoErrorsInCode(r'''
-part of 'bar.dart';
-/// Text [A].
-int x = 1;
-''');
-
- assertResolvedNodeText(findNode.commentReference('A]'), r'''
-CommentReference
- expression: SimpleIdentifier
- token: A
- staticElement: package:test/foo.dart::<fragment>::@class::A
- element: package:test/foo.dart::@class::A
- staticType: null
-''');
- }
-
test_newKeyword() async {
await assertErrorsInCode('''
class A {
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 8dcfe70..932b9aa 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -436,13 +436,6 @@
}
}
- void _writeDocLibraryImport(LibraryImport e) {
- _sink.writeIndentedLine(() {
- _writeDirectiveUri(e.uri);
- _writeImportElementPrefix((e as LibraryImportElementImpl).prefix2);
- });
- }
-
void _writeDocumentation(String? documentation) {
if (documentation != null) {
var str = documentation;
@@ -1198,20 +1191,9 @@
imports,
_writeLibraryImport,
);
- _writeList(
- 'docLibraryImports',
- f.docLibraryImports,
- _writeDocLibraryImport,
- );
}
_writeElementList(
'prefixes', f.library2!, f.prefixes, _writePrefixElement);
- _writeElementList(
- 'docLibraryImportPrefixes',
- f.library2!,
- f.docLibraryImportPrefixes,
- _writePrefixElement,
- );
// _writeList(
// 'libraryExports', f.libraryExports, _writeLibraryExportElement);
// _writeList('parts', f.parts, _writePartElement);
@@ -2434,17 +2416,6 @@
}
}
- void _writeDocLibraryImportElement(LibraryImportElementImpl e) {
- _sink.writeIndentedLine(() {
- _writeDirectiveUri(e.uri);
- _writeImportElementPrefix(e.prefix);
- });
-
- _sink.withIndent(() {
- _writeReference(e);
- });
- }
-
void _writeDocumentation(Element element) {
var documentation = element.documentationComment;
if (documentation != null) {
@@ -3161,17 +3132,6 @@
});
}
- /*void _writePrefixElement2(PrefixElementImpl2 e) {
- _sink.writeIndentedLine(() {
- _writeName2(e);
- });
-
- _sink.withIndent(() {
- _writeReference(e);
- _writeEnclosingElement(e);
- });
- }*/
-
void _writePropertyAccessorElement(PropertyAccessorElement e) {
e as PropertyAccessorElementImpl;
@@ -3483,11 +3443,6 @@
return configuration.withSyntheticDartCoreImport || !import.isSynthetic;
}).toList();
_writeElements('libraryImports', imports, _writeLibraryImportElement);
- _writeElements(
- 'docLibraryImports',
- e.docLibraryImports,
- _writeDocLibraryImportElement,
- );
}
_writeElements(
'libraryImportPrefixes',
@@ -3495,11 +3450,6 @@
_writePrefixElement,
);
_writeElements(
- 'docLibraryImportPrefixes',
- e.docLibraryImportPrefixes.map((e) => e.asElement).toList(),
- _writePrefixElement,
- );
- _writeElements(
'libraryExports', e.libraryExports, _writeLibraryExportElement);
_writeElements('parts', e.parts, _writePartElement);
diff --git a/pkg/analyzer/test/src/summary/elements/library_fragment_test.dart b/pkg/analyzer/test/src/summary/elements/library_fragment_test.dart
index c9d7b00..4318ef5 100644
--- a/pkg/analyzer/test/src/summary/elements/library_fragment_test.dart
+++ b/pkg/analyzer/test/src/summary/elements/library_fragment_test.dart
@@ -23,57 +23,6 @@
}
abstract class LibraryFragmentElementTest extends ElementsBaseTest {
- test_docImports() async {
- newFile('$testPackageLibPath/a.dart', r'''
-/// @docImport 'dart:math';
-part of 'test.dart';
-''');
-
- var library = await buildLibrary(r'''
-/// @docImport 'dart:io';
-library;
-
-part 'a.dart';
-''');
-
- checkElementText(library, r'''
-library
- reference: <testLibrary>
- documentationComment: /// @docImport 'dart:io';
- definingUnit: <testLibraryFragment>
- units
- <testLibraryFragment>
- enclosingElement3: <null>
- docLibraryImports
- dart:io
- parts
- part_0
- uri: package:test/a.dart
- enclosingElement3: <testLibraryFragment>
- unit: <testLibrary>::@fragment::package:test/a.dart
- <testLibrary>::@fragment::package:test/a.dart
- enclosingElement3: <testLibraryFragment>
- docLibraryImports
- dart:math
-----------------------------------------
-library
- reference: <testLibrary>
- documentationComment: /// @docImport 'dart:io';
- fragments
- <testLibraryFragment>
- element: <testLibrary>
- nextFragment: <testLibrary>::@fragment::package:test/a.dart
- docLibraryImports
- dart:io
- <testLibrary>::@fragment::package:test/a.dart
- element: <testLibrary>
- enclosingFragment: <testLibraryFragment>
- previousFragment: <testLibraryFragment>
- docLibraryImports
- dart:math
-''');
- }
-
test_libraryExports() async {
newFile('$testPackageLibPath/a.dart', r'''
part of 'test.dart';
diff --git a/pkg/analyzer/test/src/summary/elements/library_import_test.dart b/pkg/analyzer/test/src/summary/elements/library_import_test.dart
index ab274e2..6f4dc9c 100644
--- a/pkg/analyzer/test/src/summary/elements/library_import_test.dart
+++ b/pkg/analyzer/test/src/summary/elements/library_import_test.dart
@@ -18,42 +18,6 @@
}
abstract class LibraryImportElementTest extends ElementsBaseTest {
- test_docImport_prefixed() async {
- newFile('$testPackageLibPath/a.dart', 'library a; class C {}');
- var library = await buildLibrary('''
-/// @docImport "a.dart" as a;
-library;
-''');
-
- checkElementText(library, r'''
-library
- reference: <testLibrary>
- documentationComment: /// @docImport "a.dart" as a;
- definingUnit: <testLibraryFragment>
- units
- <testLibraryFragment>
- enclosingElement3: <null>
- docLibraryImports
- package:test/a.dart as a @27
- docLibraryImportPrefixes
- a @27
- reference: <testLibraryFragment>::@prefix::a
- enclosingElement3: <testLibraryFragment>
-----------------------------------------
-library
- reference: <testLibrary>
- documentationComment: /// @docImport "a.dart" as a;
- fragments
- <testLibraryFragment>
- element: <testLibrary>
- docLibraryImports
- package:test/a.dart as a @27
- docLibraryImportPrefixes
- <testLibraryFragment>::@prefix2::a
- fragments: @27
-''');
- }
-
test_import_configurations_useDefault() async {
declaredVariables = {
'dart.library.io': 'false',
@@ -786,6 +750,10 @@
newFile('$testPackageLibPath/a.dart', 'library a; class C {}');
var library = await buildLibrary('import "a.dart" as a; a.C c;');
+ var prefixElement =
+ library.definingCompilationUnit.libraryImports[0].prefix!.element;
+ expect(prefixElement.nameOffset, 19);
+
checkElementText(library, r'''
library
reference: <testLibrary>