Skip to content

Commit

Permalink
Version 3.6.0-118.0.dev
Browse files Browse the repository at this point in the history
Merge 6161fd8 into dev
  • Loading branch information
Dart CI committed Aug 6, 2024
2 parents dedfa33 + 6161fd8 commit 2e4eac4
Show file tree
Hide file tree
Showing 44 changed files with 12,531 additions and 443 deletions.
49 changes: 49 additions & 0 deletions pkg/analyzer/lib/dart/element/element2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,22 @@ abstract class LibraryElement2 implements Element2, _Annotatable, _Fragmented {
TypeSystem get typeSystem;
}

/// An export directive within a library.
///
/// Clients may not extend, implement or mix-in this class.
abstract class LibraryExport {
/// The combinators that were specified as part of the `export` directive.
///
/// The combinators are in the order in which they were specified.
List<NamespaceCombinator> get combinators;

/// The [LibraryElement], if [uri] is a [DirectiveUriWithLibrary].
LibraryElement2? get exportedLibrary2;

/// The offset of the `export` keyword.
int get exportKeywordOffset;

/// The interpretation of the URI specified in the directive.
DirectiveUri get uri;
}

Expand Down Expand Up @@ -725,6 +734,9 @@ abstract class LibraryFragment implements Fragment, _Annotatable {
/// The fragments of the mixins declared in this fragment.
List<MixinFragment> get mixins2;

@override
LibraryFragment? get nextFragment;

/// The parts included by this unit.
List<PartInclude> get partIncludes;

Expand All @@ -733,6 +745,9 @@ abstract class LibraryFragment implements Fragment, _Annotatable {
/// Each prefix can be used in more than one `import` directive.
List<PrefixElement2> get prefixes;

@override
LibraryFragment? get previousFragment;

/// The scope used to resolve names within the fragment.
///
/// It includes all of the elements that are declared in the library, and all
Expand All @@ -750,17 +765,37 @@ abstract class LibraryFragment implements Fragment, _Annotatable {
List<TypeAliasFragment> get typeAliases2;
}

/// An import directive within a library.
///
/// Clients may not extend, implement or mix-in this class.
abstract class LibraryImport {
/// The combinators that were specified as part of the `import` directive.
///
/// The combinators are in the order in which they were specified.
List<NamespaceCombinator> get combinators;

/// The [LibraryElement], if [uri] is a [DirectiveUriWithLibrary].
LibraryElement2? get importedLibrary2;

/// The offset of the `import` keyword.
int get importKeywordOffset;

/// Whether this import is synthetic.
///
/// A synthetic import is an import that is not represented in the source
/// code explicitly, but is implied by the source code. This only happens for
/// an implicit import of `dart:core`.
bool get isSynthetic;

/// The [Namespace] that this directive contributes to the containing library.
Namespace get namespace;

/// The prefix that was specified as part of the import directive.
///
/// Returns `null` if there was no prefix specified.
ImportElementPrefix? get prefix;

/// The interpretation of the URI specified in the directive.
DirectiveUri get uri;
}

Expand Down Expand Up @@ -807,23 +842,37 @@ abstract class MultiplyInheritedExecutableElement2
List<ExecutableElement2> get inheritedElements2;
}

/// A 'part' directive within a library fragment.
///
/// Clients may not extend, implement or mix-in this class.
abstract class PartInclude {
/// The interpretation of the URI specified in the directive.
DirectiveUri get uri;
}

abstract class PatternVariableElement2 implements LocalVariableElement2 {
JoinPatternVariableElement2? get join2;
}

/// A prefix used to import one or more libraries into another library.
///
/// Clients may not extend, implement or mix-in this class.
abstract class PrefixElement2 implements Element2 {
/// The library that encloses this element.
@override
LibraryElement2 get enclosingElement2;

/// The imports that share this prefix.
List<LibraryImport> get imports2;

@override
LibraryElement2 get library2;

/// The name lookup scope for this import prefix.
///
/// It consists of elements imported into the enclosing library with this
/// prefix. The namespace combinators of the import directives are taken
/// into account.
Scope get scope;
}

Expand Down
43 changes: 35 additions & 8 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
List<ClassFragment> get classes2 => classes.cast<ClassFragment>();

@override
LibraryElement2 get element => enclosingElement as LibraryElement2;
LibraryElement2 get element => library as LibraryElement2;

@override
LibraryOrAugmentationElement get enclosingElement =>
Expand Down Expand Up @@ -1027,7 +1027,11 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
List<MixinFragment> get mixins2 => mixins.cast<MixinFragment>();

@override
Fragment? get nextFragment => throw UnsupportedError('Not yet implemented');
LibraryFragment? get nextFragment {
var units = library.units;
var index = units.indexOf(this);
return units.elementAtOrNull(index + 1);
}

@override
List<PartInclude> get partIncludes =>
Expand Down Expand Up @@ -1055,8 +1059,14 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
libraryImportPrefixes.cast<PrefixElement2>();

@override
Fragment? get previousFragment =>
throw UnsupportedError('Not yet implemented');
LibraryFragment? get previousFragment {
var units = library.units;
var index = units.indexOf(this);
if (index >= 1) {
return units[index - 1];
}
return null;
}

@override
Scope get scope => enclosingElement.scope;
Expand Down Expand Up @@ -5079,7 +5089,7 @@ class LibraryElementImpl extends LibraryOrAugmentationElementImpl
}

class LibraryExportElementImpl extends _ExistingElementImpl
implements LibraryExportElement {
implements LibraryExportElement, LibraryExport {
@override
final List<NamespaceCombinator> combinators;

Expand All @@ -5104,6 +5114,9 @@ class LibraryExportElementImpl extends _ExistingElementImpl
return null;
}

@override
LibraryElement2? get exportedLibrary2 => exportedLibrary;

@override
int get hashCode => identityHashCode(this);

Expand All @@ -5130,7 +5143,7 @@ class LibraryExportElementImpl extends _ExistingElementImpl
}

class LibraryImportElementImpl extends _ExistingElementImpl
implements LibraryImportElement {
implements LibraryImportElement, LibraryImport {
@override
final List<NamespaceCombinator> combinators;

Expand Down Expand Up @@ -5167,6 +5180,9 @@ class LibraryImportElementImpl extends _ExistingElementImpl
return null;
}

@override
LibraryElement2? get importedLibrary2 => importedLibrary;

@override
ElementKind get kind => ElementKind.IMPORT;

Expand Down Expand Up @@ -6647,7 +6663,8 @@ mixin ParameterElementMixin implements ParameterElement {
}
}

class PartElementImpl extends _ExistingElementImpl implements PartElement {
class PartElementImpl extends _ExistingElementImpl
implements PartElement, PartInclude {
@override
final DirectiveUri uri;

Expand Down Expand Up @@ -6694,7 +6711,8 @@ class PatternVariableElementImpl extends LocalVariableElementImpl
}

/// A concrete implementation of a [PrefixElement].
class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
class PrefixElementImpl extends _ExistingElementImpl
implements PrefixElement, PrefixElement2 {
/// The scope of this prefix, `null` if it has not been created yet.
PrefixScope? _scope;

Expand All @@ -6709,16 +6727,25 @@ class PrefixElementImpl extends _ExistingElementImpl implements PrefixElement {
LibraryOrAugmentationElementImpl get enclosingElement =>
super.enclosingElement as LibraryOrAugmentationElementImpl;

@override
LibraryElement2 get enclosingElement2 => enclosingElement as LibraryElement2;

@override
List<LibraryImportElementImpl> get imports {
return enclosingElement.libraryImports
.where((import) => import.prefix?.element == this)
.toList();
}

@override
List<LibraryImport> get imports2 => imports.cast<LibraryImport>();

@override
ElementKind get kind => ElementKind.PREFIX;

@override
LibraryElement2 get library2 => library as LibraryElement2;

@override
String get name {
return super.name!;
Expand Down
Loading

0 comments on commit 2e4eac4

Please sign in to comment.