Skip to content

Commit ecdb943

Browse files
author
Dart CI
committed
Version 2.14.0-47.0.dev
Merge commit '11c2c4aaccb5b09c4b4f954cd82f1fce30bcb98a' into 'dev'
2 parents d688c83 + 11c2c4a commit ecdb943

File tree

5,569 files changed

+12411
-5072
lines changed

Some content is hidden

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

5,569 files changed

+12411
-5072
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,15 @@ class CompletionHandler
357357
final key = _createImportedSymbolKey(nameKey, declaringUri);
358358
final importingUris = alreadyImportedSymbols[key];
359359

360-
// Keep it only if there are either:
361-
// - no URIs importing it
362-
// - the URIs importing it include this one
360+
// Keep it only if:
361+
// - no existing imports include it
362+
// (in which case all libraries will be offered as
363+
// auto-imports)
364+
// - this is the first imported URI that includes it
365+
// (we don't want to repeat it for each imported library that
366+
// includes it)
363367
return importingUris == null ||
364-
importingUris.contains('${library.uri}');
368+
importingUris.first == '${library.uri}';
365369
}).map((item) => declarationToCompletionItem(
366370
capabilities,
367371
unit.path!,

pkg/analysis_server/test/lsp/completion_dart_test.dart

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,95 @@ main() {
11921192
'''));
11931193
}
11941194

1195+
Future<void>
1196+
test_suggestionSets_doesNotDuplicate_importedViaMultipleLibraries() async {
1197+
// An item that's already imported through multiple libraries that
1198+
// export it should not result in multiple entries.
1199+
newFile(
1200+
join(projectFolderPath, 'lib/source_file.dart'),
1201+
content: '''
1202+
class MyExportedClass {}
1203+
''',
1204+
);
1205+
newFile(
1206+
join(projectFolderPath, 'lib/reexport1.dart'),
1207+
content: '''
1208+
export 'source_file.dart';
1209+
''',
1210+
);
1211+
newFile(
1212+
join(projectFolderPath, 'lib/reexport2.dart'),
1213+
content: '''
1214+
export 'source_file.dart';
1215+
''',
1216+
);
1217+
1218+
final content = '''
1219+
import 'reexport1.dart';
1220+
import 'reexport2.dart';
1221+
1222+
main() {
1223+
MyExported^
1224+
}
1225+
''';
1226+
1227+
final initialAnalysis = waitForAnalysisComplete();
1228+
await initialize(
1229+
workspaceCapabilities:
1230+
withApplyEditSupport(emptyWorkspaceClientCapabilities));
1231+
await openFile(mainFileUri, withoutMarkers(content));
1232+
await initialAnalysis;
1233+
1234+
final res = await getCompletion(mainFileUri, positionFromMarker(content));
1235+
1236+
final completions = res.where((c) => c.label == 'MyExportedClass').toList();
1237+
expect(completions, hasLength(1));
1238+
}
1239+
1240+
Future<void>
1241+
test_suggestionSets_doesNotDuplicate_importedViaSingleLibrary() async {
1242+
// An item that's already imported through a library that exports it
1243+
// should not result in multiple entries.
1244+
newFile(
1245+
join(projectFolderPath, 'lib/source_file.dart'),
1246+
content: '''
1247+
class MyExportedClass {}
1248+
''',
1249+
);
1250+
newFile(
1251+
join(projectFolderPath, 'lib/reexport1.dart'),
1252+
content: '''
1253+
export 'source_file.dart';
1254+
''',
1255+
);
1256+
newFile(
1257+
join(projectFolderPath, 'lib/reexport2.dart'),
1258+
content: '''
1259+
export 'source_file.dart';
1260+
''',
1261+
);
1262+
1263+
final content = '''
1264+
import 'reexport1.dart';
1265+
1266+
main() {
1267+
MyExported^
1268+
}
1269+
''';
1270+
1271+
final initialAnalysis = waitForAnalysisComplete();
1272+
await initialize(
1273+
workspaceCapabilities:
1274+
withApplyEditSupport(emptyWorkspaceClientCapabilities));
1275+
await openFile(mainFileUri, withoutMarkers(content));
1276+
await initialAnalysis;
1277+
1278+
final res = await getCompletion(mainFileUri, positionFromMarker(content));
1279+
1280+
final completions = res.where((c) => c.label == 'MyExportedClass').toList();
1281+
expect(completions, hasLength(1));
1282+
}
1283+
11951284
Future<void> test_suggestionSets_doesNotFilterSymbolsWithSameName() async {
11961285
// Classes here are not re-exports, so should not be filtered out.
11971286
newFile(

pkg/compiler/lib/src/commandline_options.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class Flags {
2727
static const String enableDiagnosticColors = '--enable-diagnostic-colors';
2828
static const String experimentalTrackAllocations =
2929
'--experimental-track-allocations';
30-
static const String experimentalAllocationsPath =
31-
'--experimental-allocations-path';
3230

3331
static const String experimentalWrapped = '--experimental-wrapped';
3432
static const String experimentalPowersets = '--experimental-powersets';

pkg/compiler/lib/src/dart2js.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ Future<api.CompilationResult> compile(List<String> argv,
592592
// TODO(29574): provide a warning/hint/error, when profile-based data is
593593
// used without `--fast-startup`.
594594
new OptionHandler(Flags.experimentalTrackAllocations, passThrough),
595-
new OptionHandler("${Flags.experimentalAllocationsPath}=.+", passThrough),
596595

597596
new OptionHandler(Flags.experimentLocalNames, ignoreOption),
598597
new OptionHandler(Flags.experimentStartupFunctions, passThrough),

pkg/compiler/lib/src/js_emitter/code_emitter_task.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ class CodeEmitterTask extends CompilerTask {
125125
});
126126
ProgramBuilder programBuilder = ProgramBuilder(
127127
_compiler.options,
128-
_compiler.reporter,
129128
closedWorld.elementEnvironment,
130129
closedWorld.commonElements,
131130
closedWorld.outputUnitData,

pkg/compiler/lib/src/js_emitter/model.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Program {
1919
final List<Holder> holders;
2020
final bool outputContainsConstantList;
2121
final bool needsNativeSupport;
22-
final bool hasSoftDeferredClasses;
2322

2423
// If this field is not `null` then its value must be emitted in the embedded
2524
// global `TYPE_TO_INTERCEPTOR_MAP`. The map references constants and classes.
@@ -32,9 +31,7 @@ class Program {
3231

3332
Program(this.fragments, this.holders, this.typeToInterceptorMap,
3433
this._metadataCollector, this.finalizers,
35-
{this.needsNativeSupport,
36-
this.outputContainsConstantList,
37-
this.hasSoftDeferredClasses}) {
34+
{this.needsNativeSupport, this.outputContainsConstantList}) {
3835
assert(needsNativeSupport != null);
3936
assert(outputContainsConstantList != null);
4037
}
@@ -289,11 +286,6 @@ class Class implements FieldContainer {
289286
final bool isNative;
290287
final bool isClosureBaseClass; // Common base class for closures.
291288

292-
/// Whether this class should be soft deferred.
293-
///
294-
/// A soft-deferred class is only fully initialized at first instantiation.
295-
final bool isSoftDeferred;
296-
297289
final bool isMixinApplicationWithMembers;
298290

299291
// If the class implements a function type, and the type is encoded in the
@@ -331,7 +323,6 @@ class Class implements FieldContainer {
331323
this.isDirectlyInstantiated,
332324
this.isNative,
333325
this.isClosureBaseClass,
334-
this.isSoftDeferred = false,
335326
this.isMixinApplicationWithMembers}) {
336327
assert(onlyForRti != null);
337328
assert(onlyForConstructor != null);

pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
library dart2js.js_emitter.program_builder;
66

7-
import 'dart:io';
8-
import 'dart:convert' show jsonDecode;
9-
107
import '../../common.dart';
118
import '../../common/names.dart' show Names, Selectors;
129
import '../../constants/values.dart'
@@ -64,7 +61,6 @@ part 'registry.dart';
6461
/// emitted more easily by the individual emitters.
6562
class ProgramBuilder {
6663
final CompilerOptions _options;
67-
final DiagnosticReporter _reporter;
6864
final JElementEnvironment _elementEnvironment;
6965
final JCommonElements _commonElements;
7066
final OutputUnitData _outputUnitData;
@@ -111,7 +107,6 @@ class ProgramBuilder {
111107

112108
ProgramBuilder(
113109
this._options,
114-
this._reporter,
115110
this._elementEnvironment,
116111
this._commonElements,
117112
this._outputUnitData,
@@ -173,17 +168,8 @@ class ProgramBuilder {
173168
List<StubMethod> _jsInteropIsChecks = [];
174169
final Set<TypeCheck> _jsInteropTypeChecks = {};
175170

176-
/// Classes that have been allocated during a profile run.
177-
///
178-
/// These classes should not be soft-deferred.
179-
///
180-
/// Also contains classes that are not tracked by the profile run (like
181-
/// interceptors, ...).
182-
Set<ClassEntity> _notSoftDeferred;
183-
184171
Program buildProgram({bool storeFunctionTypesInMetadata: false}) {
185172
collector.collect();
186-
_initializeSoftDeferredMap();
187173

188174
this._storeFunctionTypesInMetadata = storeFunctionTypesInMetadata;
189175
// Note: In rare cases (mostly tests) output units can be empty. This
@@ -279,78 +265,13 @@ class ProgramBuilder {
279265
return new Program(fragments, holders, _buildTypeToInterceptorMap(),
280266
_task.metadataCollector, finalizers,
281267
needsNativeSupport: needsNativeSupport,
282-
outputContainsConstantList: collector.outputContainsConstantList,
283-
hasSoftDeferredClasses: _notSoftDeferred != null);
268+
outputContainsConstantList: collector.outputContainsConstantList);
284269
}
285270

286271
void _markEagerClasses() {
287272
_markEagerInterceptorClasses();
288273
}
289274

290-
void _initializeSoftDeferredMap() {
291-
var allocatedClassesPath = _options.experimentalAllocationsPath;
292-
if (allocatedClassesPath != null) {
293-
// TODO(29574): the following denylist is ad-hoc and potentially
294-
// incomplete. We need to mark all classes as black listed, that are
295-
// used without code going through the class' constructor.
296-
var denylist = [
297-
'dart:_interceptors',
298-
'dart:html',
299-
'dart:typed_data_implementation',
300-
'dart:_native_typed_data'
301-
].toSet();
302-
303-
// TODO(29574): the compiler should not just use dart:io to get the
304-
// contents of a file.
305-
File file = new File(allocatedClassesPath);
306-
307-
// TODO(29574): are the following checks necessary?
308-
// To make compilation in build-systems easier, we ignore non-existing
309-
// or empty profiles.
310-
if (!file.existsSync()) {
311-
_reporter.log("Profile file does not exist: $allocatedClassesPath");
312-
return;
313-
}
314-
if (file.lengthSync() == 0) {
315-
_reporter.log("Profile information (allocated classes) is empty.");
316-
return;
317-
}
318-
319-
String data = new File(allocatedClassesPath).readAsStringSync();
320-
Set<String> allocatedClassesKeys = jsonDecode(data).keys.toSet();
321-
Set<ClassEntity> allocatedClasses = new Set<ClassEntity>();
322-
323-
// Collects all super and mixin classes of a class.
324-
void collect(ClassEntity element) {
325-
allocatedClasses.add(element);
326-
if (_elementEnvironment.isMixinApplication(element)) {
327-
collect(_elementEnvironment.getEffectiveMixinClass(element));
328-
}
329-
ClassEntity superclass = _elementEnvironment.getSuperClass(element);
330-
if (superclass != null) {
331-
collect(superclass);
332-
}
333-
}
334-
335-
// For every known class, see if it was allocated in the profile. If yes,
336-
// collect its dependencies (supers and mixins) and mark them as
337-
// not-soft-deferrable.
338-
collector.outputClassLists.forEach((_, List<ClassEntity> elements) {
339-
for (ClassEntity element in elements) {
340-
// TODO(29574): share the encoding of the element with the code
341-
// that emits the profile-run.
342-
var key = "${element.library.canonicalUri}:${element.name}";
343-
if (allocatedClassesKeys.contains(key) ||
344-
_nativeData.isJsInteropClass(element) ||
345-
denylist.contains(element.library.canonicalUri.toString())) {
346-
collect(element);
347-
}
348-
}
349-
});
350-
_notSoftDeferred = allocatedClasses;
351-
}
352-
}
353-
354275
js.Expression _buildTypeToInterceptorMap() {
355276
InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator(
356277
_commonElements,
@@ -641,10 +562,6 @@ class ProgramBuilder {
641562
staticFieldsForReflection);
642563
}
643564

644-
bool _isSoftDeferred(ClassEntity element) {
645-
return _notSoftDeferred != null && !_notSoftDeferred.contains(element);
646-
}
647-
648565
Class _buildClass(ClassEntity cls) {
649566
ClassTypeData typeData = _buildClassTypeData(cls);
650567

@@ -850,7 +767,6 @@ class ProgramBuilder {
850767
onlyForConstructor: onlyForConstructor,
851768
isNative: _nativeData.isNativeClass(cls),
852769
isClosureBaseClass: isClosureBaseClass,
853-
isSoftDeferred: _isSoftDeferred(cls),
854770
isMixinApplicationWithMembers: isMixinApplicationWithMembers);
855771
}
856772
_classes[cls] = result;

0 commit comments

Comments
 (0)