Skip to content

Commit

Permalink
Version 3.6.0-220.0.dev
Browse files Browse the repository at this point in the history
Merge b2bdedf into dev
  • Loading branch information
Dart CI committed Sep 5, 2024
2 parents de5d8a2 + b2bdedf commit 62faf3f
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 90 deletions.
2 changes: 1 addition & 1 deletion pkg/_fe_analyzer_shared/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: _fe_analyzer_shared
version: 73.0.0
version: 74.0.0
description: Logic that is shared between the front_end and analyzer packages.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/_fe_analyzer_shared

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class DeclarationHelper {
}
for (var accessor in extension.accessors) {
if (!accessor.isStatic) {
_suggestFieldOrProperty(
_suggestProperty(
accessor: accessor,
referencingInterface: referencingInterface,
importData: importData);
Expand Down Expand Up @@ -931,7 +931,7 @@ class DeclarationHelper {
referencingInterface: referencingInterface,
);
case PropertyAccessorElement():
_suggestFieldOrProperty(
_suggestProperty(
accessor: member, referencingInterface: referencingInterface);
}
}
Expand Down Expand Up @@ -1637,30 +1637,6 @@ class DeclarationHelper {
}
}

/// Adds a suggestion for a [FieldElement] or a [PropertyAccessorElement].
void _suggestFieldOrProperty(
{required PropertyAccessorElement accessor,
required InterfaceElement? referencingInterface,
ImportData? importData}) {
if (accessor.isSynthetic) {
// Avoid visiting a field twice. All fields induce a getter, but only
// non-final fields induce a setter, so we don't add a suggestion for a
// synthetic setter.
if (accessor.isGetter) {
var variable = accessor.variable2;
if (variable is FieldElement) {
_suggestField(
field: variable, referencingInterface: referencingInterface);
}
}
} else {
_suggestProperty(
accessor: accessor,
referencingInterface: referencingInterface,
importData: importData);
}
}

/// Adds a suggestion for the method `call` defined on the class `Function`.
void _suggestFunctionCall() {
var matcherScore = state.matcher.score('call');
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 6.9.0-dev
## 6.9.0
* `NormalFormalParameter` now implements `AnnotatedNode`.
* Deprecated `Element.enclosingElement`, use `enclosingElement3`.

Expand Down
17 changes: 0 additions & 17 deletions pkg/analyzer/lib/src/lint/analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:analyzer/src/analysis_options/analysis_options_provider.dart';
import 'package:analyzer/src/analysis_options/apply_options.dart';
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/lint/io.dart';
import 'package:analyzer/src/lint/linter.dart';

Expand Down Expand Up @@ -66,22 +65,6 @@ class DriverOptions {

/// Whether to use Dart's Strong Mode analyzer.
bool strongMode = true;

/// The mock SDK (to speed up testing) or `null` to use the actual SDK.
@Deprecated('Use createMockSdk() and set dartSdkPath')
DartSdk? mockSdk;

/// Return `true` is the parser is able to parse asserts in the initializer
/// list of a constructor.
@deprecated
bool get enableAssertInitializer => true;

/// Set whether the parser is able to parse asserts in the initializer list of
/// a constructor to match [enable].
@deprecated
set enableAssertInitializer(bool enable) {
// Ignored because the option is now always enabled.
}
}

/// A driver _only used_ by [DartLinter], which is only used by package:linter
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: analyzer
version: 6.9.0-dev
version: 6.9.0
description: >-
This package provides a library that performs static analysis of Dart code.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer
Expand All @@ -8,7 +8,7 @@ environment:
sdk: '>=3.3.0 <4.0.0'

dependencies:
_fe_analyzer_shared: ^73.0.0
_fe_analyzer_shared: ^74.0.0
collection: ^1.19.0
convert: ^3.0.0
crypto: ^3.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,7 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl

if (isReplacement) {
insert(replace: existingImport);
break;
} else if (isDart) {
if (!isExistingDart || isNewBeforeExisting) {
insert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,37 @@ _prefix0.A1 a1; _prefix0.A2 a2; _prefix1.B b;''');
"import 'package:test/test_a.dart' show A, Other;A"));
}

/// The same test as [test_writeType_shownImport] but where the updated
/// import is not the last import. This verifies the code that updates imports
/// correctly breaks after updating the import so it does not also import a
/// duplicate.
Future<void> test_writeType_shownImport_nonLast() async {
var aPath = convertPath('/home/test/lib/test_a.dart');
var aContent = 'class A {} class Other {}';
addSource(aPath, aContent);
var bPath = convertPath('/home/test/lib/test_b.dart');
var bContent = '''
import 'package:test/test_a.dart' show Other;
import 'package:test/test_b.dart';
''';
addSource(bPath, bContent);

var builder = await newBuilder();
var typeA = await _getType(aPath, 'A');
await builder.addDartFileEdit(bPath, (builder) {
builder.addInsertion(bContent.length, (builder) {
builder.writeType(typeA);
});
});
var edits = getEdits(builder);
expect(edits, hasLength(2));
var edited = SourceEdit.applySequence(bContent, edits);
expect(edited, equalsIgnoringWhitespace('''
import 'package:test/test_a.dart' show A, Other;
import 'package:test/test_b.dart';
A'''));
}

Future<void> test_writeType_shownImportUnsorted() async {
var aPath = convertPath('/home/test/lib/test_a.dart');
var aContent = 'class A {} class B {} class C {} class D {}';
Expand Down
2 changes: 1 addition & 1 deletion pkg/linter/lib/src/rules/directives_ordering.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class _Visitor extends SimpleAstVisitor<void> {
}

void _checkSectionInOrder(
Set<AstNode> lintedNodes, Iterable<NamespaceDirective> nodes) {
Set<AstNode> lintedNodes, Iterable<UriBasedDirective> nodes) {
if (nodes.isEmpty) return;

var previousUri = nodes.first.uri.stringValue;
Expand Down
19 changes: 5 additions & 14 deletions pkg/linter/lib/src/rules/non_constant_identifier_names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// 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.

import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';

import '../analyzer.dart';
import '../extensions.dart';
Expand Down Expand Up @@ -50,7 +48,7 @@ class NonConstantIdentifierNames extends LintRule {
@override
void registerNodeProcessors(
NodeLintRegistry registry, LinterContext context) {
var visitor = _Visitor(this, context.libraryElement);
var visitor = _Visitor(this);
registry.addCatchClause(this, visitor);
registry.addConstructorDeclaration(this, visitor);
registry.addDeclaredVariablePattern(this, visitor);
Expand All @@ -68,14 +66,9 @@ class NonConstantIdentifierNames extends LintRule {
}

class _Visitor extends SimpleAstVisitor<void> {
/// Whether the `wildcard_variables` feature is enabled.
final bool _wildCardVariablesEnabled;

final LintRule rule;

_Visitor(this.rule, LibraryElement? library)
: _wildCardVariablesEnabled =
library?.featureSet.isEnabled(Feature.wildcard_variables) ?? false;
_Visitor(this.rule);

void checkIdentifier(Token? id, {bool underscoresOk = false}) {
if (id == null) {
Expand All @@ -93,10 +86,8 @@ class _Visitor extends SimpleAstVisitor<void> {

@override
void visitCatchClause(CatchClause node) {
checkIdentifier(node.exceptionParameter?.name,
underscoresOk: !_wildCardVariablesEnabled);
checkIdentifier(node.stackTraceParameter?.name,
underscoresOk: !_wildCardVariablesEnabled);
checkIdentifier(node.exceptionParameter?.name, underscoresOk: true);
checkIdentifier(node.stackTraceParameter?.name, underscoresOk: true);
}

@override
Expand Down Expand Up @@ -129,7 +120,7 @@ class _Visitor extends SimpleAstVisitor<void> {
for (var p in node.parameters) {
if (inAugmentation && p.isNamed) continue;
if (p is! FieldFormalParameter) {
checkIdentifier(p.name, underscoresOk: !_wildCardVariablesEnabled);
checkIdentifier(p.name, underscoresOk: true);
}
}
}
Expand Down
55 changes: 50 additions & 5 deletions pkg/linter/test/directives_ordering_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@

import 'package:linter/src/rules/directives_ordering.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';

import 'rule_test_support.dart';

// ignore_for_file: non_constant_identifier_names
void main() {
group(compareDirectives, () {
void checkImportGroup(List<String> correctlyOrderedImports) {
defineReflectiveSuite(() {
defineReflectiveTests(DirectivesOrderingTest);
});

group('compareDirectives', () {
void checkSection(List<String> correctlyOrderedImports) {
for (int i = 0; i < correctlyOrderedImports.length; i++) {
var a = correctlyOrderedImports[i];
expect(compareDirectives(a, a), 0,
Expand All @@ -24,14 +32,14 @@ void main() {
}

test('dart: imports', () {
checkImportGroup(const [
checkSection(const [
'dart:aaa',
'dart:bbb',
]);
});

test('package: imports', () {
checkImportGroup(const [
checkSection(const [
'package:aa/bb.dart',
'package:aaa/aaa.dart',
'package:aaa/ccc.dart',
Expand All @@ -40,7 +48,7 @@ void main() {
});

test('relative imports', () {
checkImportGroup(const [
checkSection(const [
'/foo5.dart',
'../../foo4.dart',
'../foo2/a.dart',
Expand All @@ -54,3 +62,40 @@ void main() {
});
});
}

@reflectiveTest
class DirectivesOrderingTest extends LintRuleTest {
@override
String get lintRule => 'directives_ordering';

test_partOrder_sorted() async {
newFile('$testPackageLibPath/a.dart', r'''
part of 'test.dart';
''');
newFile('$testPackageLibPath/b.dart', r'''
part of 'test.dart';
''');

await assertNoDiagnostics(r'''
part 'a.dart';
part 'b.dart';
''');
}

test_partOrder_unsorted() async {
newFile('$testPackageLibPath/a.dart', r'''
part of 'test.dart';
''');
newFile('$testPackageLibPath/b.dart', r'''
part of 'test.dart';
''');

// Because parts can contain augmentations, whose order of
// application matters, we do *not* want to enforce part sorting.
// See: https://github.com/dart-lang/linter/issues/4945
await assertNoDiagnostics(r'''
part 'b.dart';
part 'a.dart';
''');
}
}
8 changes: 3 additions & 5 deletions pkg/linter/test/rules/non_constant_identifier_names_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ augment int Xx = 2;
''');
}

@FailingTest(issue: 'https://github.com/dart-lang/linter/issues/5048')
test_catch_underscores() async {
await assertDiagnostics(r'''
f() {
Expand Down Expand Up @@ -470,12 +471,9 @@ class A {
}

test_formalParams_underscores() async {
await assertDiagnostics(r'''
await assertNoDiagnostics(r'''
f(int _, int __, int ___) {}
''', [
lint(13, 2),
lint(21, 3),
]);
''');
}

test_formalParams_underscores_preWildcards() async {
Expand Down
12 changes: 2 additions & 10 deletions sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/runtime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
library dart._runtime;

import 'dart:async';
import 'dart:collection';

import 'dart:_debugger' show stackTraceMapper, trackCall;
import 'dart:_foreign_helper'
show
Expand All @@ -18,8 +16,7 @@ import 'dart:_foreign_helper'
JS_GET_NAME,
JSExportName,
rest,
TYPE_REF,
spread;
TYPE_REF;
import 'dart:_interceptors'
show
JavaScriptBigInt,
Expand All @@ -44,33 +41,28 @@ import 'dart:_js_helper'
getRtiForRecord,
ImmutableMap,
ImmutableSet,
JsLinkedHashMap,
jsObjectGetPrototypeOf,
jsObjectSetPrototypeOf,
NoReifyGeneric,
notNull,
Primitives,
PrivateSymbol,
ReifyFunctionTypes,
TypeErrorImpl,
undefined;
TypeErrorImpl;
import 'dart:_js_shared_embedded_names';
import 'dart:_rti' as rti
show
bindingRtiFromList,
constructorRtiCachePropertyName,
createRuntimeType,
findType,
getFunctionParametersForDynamicChecks,
getGenericFunctionBounds,
getLegacyErasedRti,
getRecordTypeElementTypes,
getRecordTypeShapeKey,
instanceType,
instantiatedGenericFunctionType,
interfaceTypeRecipePropertyName,
isGenericFunctionType,
isNullable,
isRecordType,
isSubtype,
Rti,
Expand Down
5 changes: 0 additions & 5 deletions sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@ class _Rest {

const _Rest rest = _Rest();

dynamic spread(args) {
throw StateError('The spread function cannot be called, '
'it should be compiled away.');
}

/// Reads an embedded global.
///
/// The [name] should be a constant defined in the `_js_shared_embedded_names`
Expand Down
Loading

0 comments on commit 62faf3f

Please sign in to comment.