Skip to content

Commit

Permalink
Version 3.3.0-41.0.dev
Browse files Browse the repository at this point in the history
Merge c31be01 into dev
  • Loading branch information
Dart CI committed Oct 18, 2023
2 parents b423d57 + c31be01 commit d9b1e60
Show file tree
Hide file tree
Showing 65 changed files with 1,133 additions and 336 deletions.
21 changes: 21 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3783,6 +3783,16 @@ const MessageCode messageExpectedOpenParens = const MessageCode(
"ExpectedOpenParens",
problemMessage: r"""Expected '('.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeExpectedRepresentationField =
messageExpectedRepresentationField;

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageExpectedRepresentationField = const MessageCode(
"ExpectedRepresentationField",
analyzerCodes: <String>["EXPECTED_REPRESENTATION_FIELD"],
problemMessage: r"""Expected a representation field.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeExpectedRepresentationType =
messageExpectedRepresentationType;
Expand Down Expand Up @@ -10217,6 +10227,17 @@ const MessageCode messageMultipleOnClauses = const MessageCode(
correctionMessage:
r"""Try combining all of the on clauses into a single clause.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeMultipleRepresentationFields =
messageMultipleRepresentationFields;

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageMultipleRepresentationFields = const MessageCode(
"MultipleRepresentationFields",
analyzerCodes: <String>["MULTIPLE_REPRESENTATION_FIELDS"],
problemMessage:
r"""Each extension type should have exactly one representation field.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeMultipleVarianceModifiers =
messageMultipleVarianceModifiers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/lint/registry.dart';
import 'package:analyzer/src/lint/state.dart';
import 'package:analyzer/src/task/options.dart';

/// A completion generator that can produce completion suggestions for analysis
Expand Down Expand Up @@ -103,7 +104,10 @@ class _LintRuleProducer extends Producer {
Iterable<CompletionSuggestion> suggestions(
YamlCompletionRequest request) sync* {
for (var rule in Registry.ruleRegistry.rules) {
yield identifier(rule.name);
// todo(pq): consider suggesting internal lints if editing an SDK options file
if (!rule.state.isInternal) {
yield identifier(rule.name);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:analyzer/dart/ast/ast.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/range_factory.dart';
import 'package:path/path.dart';

class ConvertPartOfToUri extends ResolvedCorrectionProducer {
@override
Expand All @@ -26,10 +25,12 @@ class ConvertPartOfToUri extends ResolvedCorrectionProducer {
return;
}

var pathContext = resourceProvider.pathContext;
var libraryPath = unitResult.libraryElement.source.fullName;
var partPath = unitResult.path;
var relativePath = relative(libraryPath, from: dirname(partPath));
var uri = Uri.file(relativePath).toString();
var relativePath =
pathContext.relative(libraryPath, from: pathContext.dirname(partPath));
var uri = pathContext.toUri(relativePath).toString();
var replacementRange = range.node(libraryName);
await builder.addDartFileEdit(file, (builder) {
builder.addSimpleReplacement(replacementRange, "'$uri'");
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/test/edit/refactoring_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ import 'new_folder/file.dart';
}

void _setOptions(String newFile) {
options = MoveFileOptions(newFile);
options = MoveFileOptions(convertPath(newFile));
}
}

Expand Down
28 changes: 26 additions & 2 deletions pkg/analysis_server/test/lsp/completion_dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,32 @@ void f() { }
expect(updated, contains('a.abcdefghij'));
}

@FailingTest(reason: 'https://github.com/Dart-Code/Dart-Code/issues/4794')
Future<void> test_prefixed_enumMember() async {
// If the first character of the enum member is typed (`self.MyEnum.o^`)
// this test passes. Without any charactres typed (`self.MyEnum.^`) the
// dotTarget on the completion is `null`. The containingNode is a
// ConstructorName.
final content = '''
import 'main.dart' as self;
enum MyEnum {
one,
two,
}
void main() {
final x = self.MyEnum.^
}
''';

await initialize();
final code = TestCode.parse(content);
await openFile(mainFileUri, code.code);
final res = await getCompletion(mainFileUri, code.position.position);
expect(res.any((c) => c.label == 'one'), isTrue);
}

Future<void> test_prefixFilter_endOfSymbol() async {
final content = '''
class UniqueNamedClassForLspOne {}
Expand Down Expand Up @@ -4148,8 +4174,6 @@ void f() {
}

Future<void> test_snippets_testGroupBlock() async {
// This test fails when running on macOS using Windows style paths. See
// explanation in test_snippets_testBlock.
mainFilePath = join(projectFolderPath, 'test', 'foo_test.dart');
mainFileUri = pathContext.toUri(mainFilePath);
final content = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class LspOverLegacyTest extends PubPackageAnalysisServerTest
path.Context get pathContext => resourceProvider.pathContext;

@override
String get projectFolderPath => testPackageRootPath;
String get projectFolderPath => convertPath(testPackageRootPath);

Uri get testFileUri => toUri(convertPath(testFilePath));

Expand Down
6 changes: 6 additions & 0 deletions pkg/analysis_server/test/search/element_references_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,9 @@ LIBRARY my_lib''');
}

Future<void> test_path_inExtension_named() async {
// This test fails when run on macOS with a Windows pathContext because
// analysis_server/lib/plugin/protocol/protocol_dart.dart
// getElementDisplayName uses path.basename() without any path context.
addTestFile('''
class A {
void foo() {}
Expand All @@ -1027,6 +1030,9 @@ LIBRARY''');
}

Future<void> test_path_inExtension_unnamed() async {
// This test fails when run on macOS with a Windows pathContext because
// analysis_server/lib/plugin/protocol/protocol_dart.dart
// getElementDisplayName uses path.basename() without any path context.
addTestFile('''
class A {
void foo() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:analysis_server/src/services/completion/yaml/analysis_options_generator.dart';
import 'package:analyzer/src/lint/linter.dart';
import 'package:analyzer/src/lint/registry.dart';
import 'package:analyzer/src/task/options.dart';
import 'package:linter/src/rules.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
Expand All @@ -17,13 +19,31 @@ void main() {

@reflectiveTest
class AnalysisOptionsGeneratorTest extends YamlGeneratorTest {
// Keep track of any added rules so they can be unregistered at tearDown
var addedRules = <LintRule>[];

@override
String get fileName => 'analysis_options.yaml';

@override
AnalysisOptionsGenerator get generator =>
AnalysisOptionsGenerator(resourceProvider);

void registerRule(LintRule rule) {
addedRules.add(rule);
Registry.ruleRegistry.register(rule);
}

void setUp() {
registerLintRules();
}

void tearDown() {
for (var rule in addedRules) {
Registry.ruleRegistry.unregister(rule);
}
}

void test_analyzer() {
getCompletions('''
analyzer:
Expand All @@ -33,7 +53,6 @@ analyzer:
}

void test_analyzer_enableExperiment() {
registerLintRules();
getCompletions('''
analyzer:
enable-experiment:
Expand All @@ -44,7 +63,6 @@ analyzer:
}

void test_analyzer_enableExperiment_nonDuplicate() {
registerLintRules();
getCompletions('''
analyzer:
enable-experiment:
Expand Down Expand Up @@ -122,7 +140,6 @@ linter:
}

void test_linter_rules() {
registerLintRules();
getCompletions('''
linter:
rules:
Expand All @@ -131,8 +148,19 @@ linter:
assertSuggestion('annotate_overrides');
}

void test_linter_rules_internal() {
registerRule(InternalLint());

getCompletions('''
linter:
rules:
^
''');

assertNoSuggestion('internal_lint');
}

void test_linter_rules_listItem_first() {
registerLintRules();
getCompletions('''
linter:
rules:
Expand All @@ -144,7 +172,6 @@ linter:
}

void test_linter_rules_listItem_last() {
registerLintRules();
getCompletions('''
linter:
rules:
Expand All @@ -156,7 +183,6 @@ linter:
}

void test_linter_rules_listItem_middle() {
registerLintRules();
getCompletions('''
linter:
rules:
Expand All @@ -170,7 +196,6 @@ linter:
}

void test_linter_rules_listItem_nonDuplicate() {
registerLintRules();
getCompletions('''
linter:
rules:
Expand All @@ -181,7 +206,6 @@ linter:
}

void test_linter_rules_listItem_only() {
registerLintRules();
getCompletions('''
linter:
rules:
Expand All @@ -191,7 +215,6 @@ linter:
}

void test_linter_rules_listItem_partial() {
registerLintRules();
getCompletions('''
linter:
rules:
Expand Down Expand Up @@ -226,3 +249,14 @@ li^
assertSuggestion('linter');
}
}

class InternalLint extends LintRule {
InternalLint()
: super(
name: 'internal_lint',
group: Group.style,
state: State.internal(),
description: '',
details: '',
);
}
23 changes: 10 additions & 13 deletions pkg/analyzer/lib/src/dart/element/least_upper_bound.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class InterfaceLeastUpperBoundHelper {

final representationType = type.representationType;
if (representationType != null) {
// TODO(scheglov) See https://github.com/dart-lang/language/pull/3402
// When it lands, we might need to remove `Object` from the element
// interfaces, and return from the type interfaces.
final first = type.interfaces.singleOrNull;
if (first != null && first.isDartCoreObject) {
final replacement = typeSystem.isNonNullable(representationType)
Expand All @@ -145,31 +148,25 @@ class InterfaceLeastUpperBoundHelper {
}

for (var interface in type.interfaces) {
if (!interface.isDartCoreFunction) {
if (set.add(interface)) {
_addSuperinterfaces(set, interface);
}
if (set.add(interface)) {
_addSuperinterfaces(set, interface);
}
}

for (var mixin in type.mixins) {
if (!mixin.isDartCoreFunction) {
if (set.add(mixin)) {
_addSuperinterfaces(set, mixin);
}
if (set.add(mixin)) {
_addSuperinterfaces(set, mixin);
}
}

for (var constraint in type.superclassConstraints) {
if (!constraint.isDartCoreFunction) {
if (set.add(constraint)) {
_addSuperinterfaces(set, constraint);
}
if (set.add(constraint)) {
_addSuperinterfaces(set, constraint);
}
}

var supertype = type.superclass;
if (supertype != null && !supertype.isDartCoreFunction) {
if (supertype != null) {
if (set.add(supertype)) {
_addSuperinterfaces(set, supertype);
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/analyzer/lib/src/error/codes.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
/// Parameters:
/// 0: the name of the actual argument type
/// 1: the name of the expected type
/// 2: additional information, if any, when problem is associated with records
static const CompileTimeErrorCode ARGUMENT_TYPE_NOT_ASSIGNABLE =
CompileTimeErrorCode(
'ARGUMENT_TYPE_NOT_ASSIGNABLE',
"The argument type '{0}' can't be assigned to the parameter type '{1}'.",
"The argument type '{0}' can't be assigned to the parameter type '{1}'. "
"{2}",
hasPublishedDocs: true,
);

Expand Down
6 changes: 6 additions & 0 deletions pkg/analyzer/lib/src/fasta/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,12 @@ class AstBuilder extends StackListener {
);
break;
}
if (firstFormalParameter.covariantKeyword case final keyword?) {
errorReporter.errorReporter?.reportErrorForToken(
ParserErrorCode.REPRESENTATION_FIELD_MODIFIER,
keyword,
);
}
if (firstFormalParameter.keyword case final keyword?) {
if (keyword.keyword != Keyword.CONST) {
errorReporter.errorReporter?.reportErrorForToken(
Expand Down
Loading

0 comments on commit d9b1e60

Please sign in to comment.