Skip to content

Commit 4fad612

Browse files
author
Dart CI
committed
Version 3.9.0-238.0.dev
Merge 8020e36 into dev
2 parents 68d7e34 + 8020e36 commit 4fad612

File tree

154 files changed

+1941
-1591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+1941
-1591
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ vars = {
8484
"download_reclient": True,
8585

8686
# Update from https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core
87-
"fuchsia_sdk_version": "version:28.20250612.3.1",
87+
"fuchsia_sdk_version": "version:28.20250613.3.1",
8888
"download_fuchsia_deps": False,
8989

9090
# Ninja, runs the build based on files generated by GN.

PRESUBMIT.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ def _CheckClangFormat(input_api, output_api):
340340
f.ChangedContents())):
341341
is_deps = True
342342
break
343-
if is_cpp_file(path) and os.path.isfile(path):
343+
if is_cpp_file(path) and os.path.isfile(
344+
path) and not path.startswith('third_party/'):
344345
files.append(path)
345346

346347
if is_deps:

pkg/analysis_server/lib/src/lsp/handlers/handler_inline_value.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,28 @@ class _InlineValueVisitor extends GeneralizingAstVisitor<void> {
290290
super.visitBlock(node);
291291
}
292292

293+
@override
294+
void visitDeclaredIdentifier(DeclaredIdentifier node) {
295+
var name = node.name;
296+
collector.recordVariableLookup(
297+
node.declaredElement2,
298+
name.offset,
299+
name.length,
300+
);
301+
super.visitDeclaredIdentifier(node);
302+
}
303+
304+
@override
305+
void visitDeclaredVariablePattern(DeclaredVariablePattern node) {
306+
var name = node.name;
307+
collector.recordVariableLookup(
308+
node.declaredElement2,
309+
name.offset,
310+
name.length,
311+
);
312+
super.visitDeclaredVariablePattern(node);
313+
}
314+
293315
@override
294316
void visitFormalParameter(FormalParameter node) {
295317
var name = node.name;

pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ class DeclarationHelper {
568568
/// containing the [node] that can be referenced as a super parameter.
569569
void addParametersFromSuperConstructor(SuperFormalParameter node) {
570570
var element = node.declaredFragment?.element;
571-
if (element is! SuperFormalParameterElementImpl2) {
571+
if (element is! SuperFormalParameterElementImpl) {
572572
return;
573573
}
574574

@@ -578,7 +578,7 @@ class DeclarationHelper {
578578
}
579579

580580
var constructorElement = constructor.declaredFragment?.element;
581-
if (constructorElement is! ConstructorElementImpl2) {
581+
if (constructorElement is! ConstructorElementImpl) {
582582
return;
583583
}
584584

pkg/analysis_server/test/lsp/inline_value_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,30 @@ void f() {
405405
await verify_values(code, ofType: InlineValueVariableLookup);
406406
}
407407

408+
Future<void> test_variable_forIn() async {
409+
code = TestCode.parse(r'''
410+
void f(List<int> ints) {
411+
for (var /*[0*/i/*0]*/ in /*[1*/ints/*1]*/) {
412+
^
413+
}
414+
}
415+
''');
416+
417+
await verify_values(code, ofType: InlineValueVariableLookup);
418+
}
419+
420+
Future<void> test_variable_forIn_destructure() async {
421+
code = TestCode.parse(r'''
422+
void f(List<(int, int)> records) {
423+
for (var (/*[0*/x/*0]*/, /*[1*/y/*1]*/) in /*[2*/records/*2]*/) {
424+
^
425+
}
426+
}
427+
''');
428+
429+
await verify_values(code, ofType: InlineValueVariableLookup);
430+
}
431+
408432
/// Lists are included, iterables are not.
409433
Future<void> test_variable_iterables() async {
410434
experimentalInlineValuesProperties = true;

pkg/analysis_server/test/plugin/protocol_dart_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class A {
131131
}
132132

133133
void test_dynamic() {
134-
var engineElement = engine.DynamicElementImpl2.instance;
134+
var engineElement = engine.DynamicElementImpl.instance;
135135
// create notification Element
136136
var element = convertElement(engineElement);
137137
expect(element.kind, ElementKind.UNKNOWN);

pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class AbstractChangeMethodSignatureTest extends AbstractContextTest {
117117
String _elementToReferenceString(Element element) {
118118
var enclosingElement = element.enclosingElement;
119119
var reference = switch (element) {
120-
ElementImpl2() =>
120+
ElementImpl() =>
121121
element.reference ?? (element.firstFragment as FragmentImpl).reference,
122122
_ => null,
123123
};

pkg/analysis_server/test/support/sdk_paths.dart

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import 'dart:isolate';
77

88
import 'package:path/path.dart' as path;
99

10-
/// A temporary file that the server was compiled to from source by
11-
/// [getAnalysisServerPath] because `TEST_SERVER_SNAPSHOT` was set to disable
12-
/// running from the SDK snapshot.
13-
String? _temporaryCompiledServerPath;
10+
/// The compiled version of the analysis server snapshot that should be used
11+
/// for integration tests. Set by [getAnalysisServerPath].
12+
String? _compiledServerPath;
1413

1514
/// The path of the `pkg/analysis_server` folder, resolved using the active
1615
/// `package_config.json`.
@@ -41,43 +40,58 @@ String get sdkRootPath {
4140
/// Gets the path of the analysis server entry point which may be the snapshot
4241
/// from the current SDK (default) or a compiled version of the source script
4342
/// depending on the `TEST_SERVER_SNAPSHOT` environment variable.
44-
///
45-
/// When running from source, the server will be compiled to disk for the first
46-
/// request to speed up subsequent tests in the same process.
4743
Future<String> getAnalysisServerPath(String dartSdkPath) async {
48-
// Always use the "real" SDK binary for compilation, not the path provided,
49-
// which might be an incomplete SDK that is the target of the test.
50-
var dartBinary = Platform.resolvedExecutable;
51-
var snapshotPath = path.join(
52-
dartSdkPath,
53-
'bin',
54-
'snapshots',
55-
'analysis_server.dart.snapshot',
56-
);
57-
var sourcePath = path.join(analysisServerPackagePath, 'bin', 'server.dart');
58-
59-
// Use the SDK snapshot unless this env var is set.
60-
var useSnapshot = Platform.environment['TEST_SERVER_SNAPSHOT'] != 'false';
61-
if (useSnapshot) {
62-
return path.normalize(snapshotPath);
44+
// If we have already computed the path once, use that.
45+
if (_compiledServerPath case var compiledServerPath?) {
46+
return compiledServerPath;
6347
}
6448

65-
// If we've already compiled a copy in this process, use that.
66-
if (_temporaryCompiledServerPath case var temporaryCompiledServerPath?) {
67-
return temporaryCompiledServerPath;
49+
// The 'TEST_SERVER_SNAPSHOT' env variable can either be:
50+
//
51+
// - Unset, in which case the tests run from the SDK compiled snapshot
52+
// - The string 'false' which will cause the server to compiled from source.
53+
// This is a simple way to run from source using the test_all file that
54+
// runs all tests in a single isolate and will trigger a single
55+
// compilation for all integration tests.
56+
// - An path to a pre-compiled snapshot.
57+
// This allows configuring VS Code to pre-compile the snapshot once and
58+
// then use 'dart test' which will run each sweet in a separate isolate
59+
// without each test/isolate having to compile.
60+
var snapshotPath = switch (Platform.environment['TEST_SERVER_SNAPSHOT']) {
61+
// Compile on the fly
62+
'false' => await _compileTemporaryServerSnapshot(),
63+
// Default, use the SDK-bundled snapshot
64+
'true' || '' || null => path.join(
65+
dartSdkPath,
66+
'bin',
67+
'snapshots',
68+
'analysis_server.dart.snapshot',
69+
),
70+
// Custom path in the env variable
71+
String snapshotPath => snapshotPath,
72+
};
73+
74+
return _compiledServerPath = path.normalize(snapshotPath);
75+
}
76+
77+
/// Compiles a temporary snapshot for the analysis server into a temporary file
78+
/// and returns the full path.
79+
///
80+
/// This function can only be called once in a single process/isolate.
81+
Future<String> _compileTemporaryServerSnapshot() async {
82+
if (_compiledServerPath != null) {
83+
throw 'Snapshot is already compiled or being compiled';
6884
}
6985

70-
// Otherwise, we're running from source. But to avoid having to compile the
71-
// server for every test as it spawns the process, pre-compile it once here
72-
// into a temp file and then use that for future invocations in this run.
86+
var dartBinary = Platform.resolvedExecutable;
7387
var tempSnapshotDirectory = Directory.systemTemp.createTempSync(
7488
'dart_analysis_server_tests',
7589
);
76-
var tempSnapshotFilePath =
77-
_temporaryCompiledServerPath = path.join(
78-
tempSnapshotDirectory.path,
79-
'analysis_server.dart.snapshot',
80-
);
90+
var tempSnapshotFilePath = path.join(
91+
tempSnapshotDirectory.path,
92+
'analysis_server.dart.snapshot',
93+
);
94+
var sourcePath = path.join(analysisServerPackagePath, 'bin', 'server.dart');
8195
var result = await Process.run(dartBinary, [
8296
'compile',
8397
'kernel',

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import 'package:meta/meta.dart';
6767

6868
/// This function is used to test recording requirements during analysis.
6969
///
70-
/// Some [ElementImpl2] APIs are not trivial, or maybe even impossible, to
70+
/// Some [ElementImpl] APIs are not trivial, or maybe even impossible, to
7171
/// trigger. For example because this API is not used during normal resolution
7272
/// of Dart code, but can be used by a linter rule.
7373
@visibleForTesting
@@ -110,7 +110,7 @@ testFineAfterLibraryAnalyzerHook;
110110
// TODO(scheglov): Clean up the list of implicitly analyzed files.
111111
class AnalysisDriver {
112112
/// The version of data format, should be incremented on every format change.
113-
static const int DATA_VERSION = 472;
113+
static const int DATA_VERSION = 475;
114114

115115
/// The number of exception contexts allowed to write. Once this field is
116116
/// zero, we stop writing any new exception contexts in this process.

pkg/analyzer/lib/src/dart/analysis/index.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,15 @@ class _IndexAssembler {
374374

375375
/// Adds a prefix (or empty string for unprefixed) for an element.
376376
void addPrefixForElement(Element element, {PrefixElement? prefix}) {
377-
if (element is MultiplyDefinedElementImpl2 ||
377+
if (element is MultiplyDefinedElementImpl ||
378378
// TODO(brianwilkerson): The last two conditions are here because the
379379
// elements for `dynamic` and `Never` are singletons and hence don't have
380380
// a parent element for which we can find an `_ElementInfo`. This means
381381
// that any reference to either type via a prefix can't be stored in the
382382
// index. The solution is to make those elements be normal (not unique)
383383
// elements.
384-
element is DynamicElementImpl2 ||
385-
element is NeverElementImpl2) {
384+
element is DynamicElementImpl ||
385+
element is NeverElementImpl) {
386386
return;
387387
}
388388

@@ -734,7 +734,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
734734
// implicitly invokes the default super constructor. Associate the
735735
// invocation with the name of the class.
736736
var defaultConstructor = declaredElement.constructors.singleOrNull;
737-
if (defaultConstructor is ConstructorElementImpl2 &&
737+
if (defaultConstructor is ConstructorElementImpl &&
738738
defaultConstructor.isSynthetic) {
739739
defaultConstructor.isDefaultConstructor;
740740
var superConstructor = defaultConstructor.superConstructor2;
@@ -1260,7 +1260,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
12601260
@override
12611261
visitSuperFormalParameter(SuperFormalParameter node) {
12621262
var element = node.declaredFragment!.element;
1263-
if (element is SuperFormalParameterElementImpl2) {
1263+
if (element is SuperFormalParameterElementImpl) {
12641264
var superParameter = element.superConstructorParameter2;
12651265
if (superParameter != null) {
12661266
recordRelation(
@@ -1377,9 +1377,9 @@ class _IndexContributor extends GeneralizingAstVisitor {
13771377
ConstructorElement? constructor,
13781378
) {
13791379
var seenConstructors = <ConstructorElement?>{};
1380-
while (constructor is ConstructorElementImpl2 && constructor.isSynthetic) {
1380+
while (constructor is ConstructorElementImpl && constructor.isSynthetic) {
13811381
var enclosing = constructor.enclosingElement;
1382-
if (enclosing is ClassElementImpl2 && enclosing.isMixinApplication) {
1382+
if (enclosing is ClassElementImpl && enclosing.isMixinApplication) {
13831383
var superInvocation =
13841384
constructor.firstFragment.constantInitializers
13851385
.whereType<SuperConstructorInvocation>()

0 commit comments

Comments
 (0)