Skip to content

Commit

Permalink
Version 3.6.0-5.0.dev
Browse files Browse the repository at this point in the history
Merge 5c69448 into dev
  • Loading branch information
Dart CI committed Jul 3, 2024
2 parents 5ce04c2 + 5c69448 commit 5ce3bbe
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 51 deletions.
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vars = {
# Checked-in SDK version. The checked-in SDK is a Dart SDK distribution
# in a cipd package used to run Dart scripts in the build and test
# infrastructure, which is automatically built on the release commits.
"sdk_tag": "version:3.5.0-307.0.dev",
"sdk_tag": "git_revision:7e6469bd51d404916395a47b011d907d2c905121",

# co19 is a cipd package automatically generated for each co19 commit.
# Use tests/co19/update.sh to update this hash.
Expand Down Expand Up @@ -102,7 +102,7 @@ vars = {
"boringssl_rev": "d24a38200fef19150eef00cad35b138936c08767",
"browser-compat-data_tag": "ac8cae697014da1ff7124fba33b0b4245cc6cd1b", # v1.0.22
"cpu_features_rev": "936b9ab5515dead115606559502e3864958f7f6e",
"devtools_rev": "70375f6c6d81faa8f3069aa6dcf2a98c69445455",
"devtools_rev": "e77d6ce142b7bc737af3652f5727e449e84b7b03",
"icu_rev": "81d656878ec611cb0b42d52c82e9dae93920d9ba",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
"libcxx_rev": "44079a4cc04cdeffb9cfe8067bfb3c276fb2bab0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ sealed class CandidateSuggestion {
}

/// The information about a candidate suggestion based on a class.
final class ClassSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class ClassSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final ClassElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand Down Expand Up @@ -81,8 +82,9 @@ final class ClosureSuggestion extends CandidateSuggestion {
}

/// The information about a candidate suggestion based on a constructor.
final class ConstructorSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class ConstructorSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final ConstructorElement element;

/// Whether the class name is already, implicitly or explicitly, at the call
Expand Down Expand Up @@ -118,11 +120,17 @@ final class ConstructorSuggestion extends ImportableSuggestion {
String get completion => '$completionPrefix${element.displayName}';
}

abstract interface class ElementBasedSuggestion {
/// The element on which the suggestion is based.
Element get element;
}

/// The information about a candidate suggestion based on a static field in a
/// location where the name of the field must be qualified by the name of the
/// enclosing element.
final class EnumConstantSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class EnumConstantSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final FieldElement element;

/// Whether the name of the enum should be included in the completion.
Expand All @@ -147,8 +155,9 @@ final class EnumConstantSuggestion extends ImportableSuggestion {
}

/// The information about a candidate suggestion based on an enum.
final class EnumSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class EnumSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final EnumElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand Down Expand Up @@ -180,8 +189,9 @@ sealed class ExecutableSuggestion extends ImportableSuggestion {
}

/// The information about a candidate suggestion based on an extension.
final class ExtensionSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class ExtensionSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final ExtensionElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -195,8 +205,9 @@ final class ExtensionSuggestion extends ImportableSuggestion {
}

/// The information about a candidate suggestion based on an extension type.
final class ExtensionTypeSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class ExtensionTypeSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final ExtensionTypeElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -211,7 +222,6 @@ final class ExtensionTypeSuggestion extends ImportableSuggestion {

/// The information about a candidate suggestion based on a field.
final class FieldSuggestion extends CandidateSuggestion with MemberSuggestion {
/// The element on which the suggestion is based.
@override
final FieldElement element;

Expand All @@ -231,8 +241,9 @@ final class FieldSuggestion extends CandidateSuggestion with MemberSuggestion {
}

/// The information about a candidate suggestion based on a formal parameter.
final class FormalParameterSuggestion extends CandidateSuggestion {
/// The element on which the suggestion is based.
final class FormalParameterSuggestion extends CandidateSuggestion
implements ElementBasedSuggestion {
@override
final ParameterElement element;

/// The number of local variable declarations between the completion location
Expand Down Expand Up @@ -337,8 +348,10 @@ final class ImportData {
}

/// A suggestion based on an import prefix.
final class ImportPrefixSuggestion extends CandidateSuggestion {
final class ImportPrefixSuggestion extends CandidateSuggestion
implements ElementBasedSuggestion {
final LibraryElement libraryElement;

final PrefixElement prefixElement;

ImportPrefixSuggestion({
Expand All @@ -349,6 +362,9 @@ final class ImportPrefixSuggestion extends CandidateSuggestion {

@override
String get completion => prefixElement.name;

@override
Element get element => prefixElement;
}

/// The information about a candidate suggestion based on a keyword.
Expand Down Expand Up @@ -428,7 +444,9 @@ final class LabelSuggestion extends CandidateSuggestion {
}

/// The suggestion for `loadLibrary()`.
final class LoadLibraryFunctionSuggestion extends ExecutableSuggestion {
final class LoadLibraryFunctionSuggestion extends ExecutableSuggestion
implements ElementBasedSuggestion {
@override
final FunctionElement element;

LoadLibraryFunctionSuggestion({
Expand All @@ -442,8 +460,9 @@ final class LoadLibraryFunctionSuggestion extends ExecutableSuggestion {
}

/// The information about a candidate suggestion based on a local function.
final class LocalFunctionSuggestion extends ExecutableSuggestion {
/// The element on which the suggestion is based.
final class LocalFunctionSuggestion extends ExecutableSuggestion
implements ElementBasedSuggestion {
@override
final FunctionElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -456,8 +475,9 @@ final class LocalFunctionSuggestion extends ExecutableSuggestion {
}

/// The information about a candidate suggestion based on a local variable.
final class LocalVariableSuggestion extends CandidateSuggestion {
/// The element on which the suggestion is based.
final class LocalVariableSuggestion extends CandidateSuggestion
implements ElementBasedSuggestion {
@override
final LocalVariableElement element;

/// The number of local variables between the completion location and the
Expand All @@ -476,10 +496,7 @@ final class LocalVariableSuggestion extends CandidateSuggestion {

/// Behavior common to suggestions that are for members of a class, enum, mixin,
/// etc.
mixin MemberSuggestion {
/// The element on which the suggestion is based.
Element get element;

mixin MemberSuggestion implements ElementBasedSuggestion {
/// The element defined by the declaration in which the suggestion is to be
/// applied, or `null` if the completion is in a static context.
InterfaceElement? get referencingInterface;
Expand All @@ -505,7 +522,6 @@ mixin MemberSuggestion {
/// The information about a candidate suggestion based on a method.
final class MethodSuggestion extends ExecutableSuggestion
with MemberSuggestion {
/// The element on which the suggestion is based.
@override
final MethodElement element;

Expand All @@ -527,8 +543,9 @@ final class MethodSuggestion extends ExecutableSuggestion
}

/// The information about a candidate suggestion based on a mixin.
final class MixinSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class MixinSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final MixinElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand Down Expand Up @@ -582,8 +599,9 @@ final class NameSuggestion extends CandidateSuggestion {

/// The information about a candidate suggestion to create an override of an
/// inherited method.
final class OverrideSuggestion extends CandidateSuggestion {
/// The method to be overridden.
final class OverrideSuggestion extends CandidateSuggestion
implements ElementBasedSuggestion {
@override
final ExecutableElement element;

/// Whether `super` should be invoked in the body of the override.
Expand Down Expand Up @@ -615,7 +633,6 @@ final class OverrideSuggestion extends CandidateSuggestion {
/// The information about a candidate suggestion based on a getter or setter.
final class PropertyAccessSuggestion extends ImportableSuggestion
with MemberSuggestion {
/// The element on which the suggestion is based.
@override
final PropertyAccessorElement element;

Expand Down Expand Up @@ -679,8 +696,9 @@ final class RecordLiteralNamedFieldSuggestion extends CandidateSuggestion {
/// The information about a candidate suggestion based on a static field in a
/// location where the name of the field must be qualified by the name of the
/// enclosing element.
final class StaticFieldSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class StaticFieldSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final FieldElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -698,8 +716,9 @@ final class StaticFieldSuggestion extends ImportableSuggestion {

/// The information about a candidate suggestion based on a parameter from a
/// super constructor.
final class SuperParameterSuggestion extends CandidateSuggestion {
/// The element on which the suggestion is based.
final class SuperParameterSuggestion extends CandidateSuggestion
implements ElementBasedSuggestion {
@override
final ParameterElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -712,8 +731,9 @@ final class SuperParameterSuggestion extends CandidateSuggestion {

/// The information about a candidate suggestion based on a top-level getter or
/// setter.
final class TopLevelFunctionSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class TopLevelFunctionSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final FunctionElement element;

/// The kind of suggestion to be made, either
Expand All @@ -736,8 +756,9 @@ final class TopLevelFunctionSuggestion extends ImportableSuggestion {

/// The information about a candidate suggestion based on a top-level getter or
/// setter.
final class TopLevelPropertyAccessSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class TopLevelPropertyAccessSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final PropertyAccessorElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -751,8 +772,9 @@ final class TopLevelPropertyAccessSuggestion extends ImportableSuggestion {
}

/// The information about a candidate suggestion based on a top-level variable.
final class TopLevelVariableSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class TopLevelVariableSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final TopLevelVariableElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -766,8 +788,9 @@ final class TopLevelVariableSuggestion extends ImportableSuggestion {
}

/// The information about a candidate suggestion based on a type alias.
final class TypeAliasSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
final class TypeAliasSuggestion extends ImportableSuggestion
implements ElementBasedSuggestion {
@override
final TypeAliasElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand All @@ -781,8 +804,9 @@ final class TypeAliasSuggestion extends ImportableSuggestion {
}

/// The information about a candidate suggestion based on a type parameter.
final class TypeParameterSuggestion extends CandidateSuggestion {
/// The element on which the suggestion is based.
final class TypeParameterSuggestion extends CandidateSuggestion
implements ElementBasedSuggestion {
@override
final TypeParameterElement element;

/// Initialize a newly created candidate suggestion to suggest the [element].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,17 @@ class BulkFixProcessor {
}

var library = await context.currentSession.getResolvedLibrary(path);

if (isCancelled) {
break;
}
if (library is NotLibraryButPartResult) {
var unit = await context.currentSession.getResolvedUnit(path);
if (unit is ResolvedUnitResult) {
library = await context.currentSession
.getResolvedLibraryByElement(unit.libraryElement);
}
}
if (library is ResolvedLibraryResult) {
await _fixErrorsInLibrary(library, stopAfterFirst: stopAfterFirst);
if (isCancelled || (stopAfterFirst && changeMap.hasFixes)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,59 @@ var a = new A();
expect(await computeHasFixes(), isTrue);
}

Future<void> test_hasFixes_in_part() async {
createAnalysisOptionsFile(experiments: experiments, lints: [
LintNames.unnecessary_new,
]);

newFile('$testPackageLibPath/a.dart', '''
part of 'test.dart';
class A { }
var a = new A();
''');

await resolveTestCode('''
part 'a.dart';
''');

expect(await computeHasFixes(), isTrue);
}

Future<void> test_hasFixes_in_part_and_library() async {
createAnalysisOptionsFile(experiments: experiments, lints: [
LintNames.unnecessary_new,
]);

newFile('$testPackageLibPath/a.dart', '''
part of 'test.dart';
class A { }
var a = new A();
''');

newFile('$testPackageLibPath/b.dart', '''
part of 'test.dart';
class B { }
var b = new B();
''');

await resolveTestCode('''
part 'a.dart';
part 'b.dart';
class C{}
var c = new C();
''');

expect(await computeHasFixes(), isTrue);
expect(processor.changeMap.libraryMap.length, 3);
}

Future<void> test_hasFixes_stoppedAfterFirst() async {
createAnalysisOptionsFile(experiments: experiments, lints: [
LintNames.annotate_overrides,
Expand Down
Loading

0 comments on commit 5ce3bbe

Please sign in to comment.