Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c7a093c

Browse files
author
Dart CI
committed
Version 2.14.0-363.0.dev
Merge commit '32038798c6a719d54c198c57bc82e2773b0fccf5' into 'dev'
2 parents f942c48 + 3203879 commit c7a093c

File tree

73 files changed

+635
-2063
lines changed

Some content is hidden

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

73 files changed

+635
-2063
lines changed

.dart_tool/package_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
"name": "dds",
245245
"rootUri": "../pkg/dds",
246246
"packageUri": "lib/",
247-
"languageVersion": "2.14"
247+
"languageVersion": "2.12"
248248
},
249249
{
250250
"name": "dev_compiler",

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ vars = {
139139
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
140140
"pool_rev": "7abe634002a1ba8a0928eded086062f1307ccfae",
141141
"process_rev": "56ece43b53b64c63ae51ec184b76bd5360c28d0b",
142-
"protobuf_rev": "0d03fd588df69e9863e2a2efc0059dee8f18d5b2",
142+
"protobuf_rev": "c1eb6cb51af39ccbaa1a8e19349546586a5c8e31",
143143
"pub_rev": "70b1a4f9229a36bac6340ec7eae2b2068baac96c",
144144
"pub_semver_rev": "f50d80ef10c4b2fa5f4c8878036a4d9342c0cc82",
145145
"resource_rev": "6b79867d0becf5395e5819a75720963b8298e9a7",

pkg/_fe_analyzer_shared/lib/src/messages/codes.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class DiagnosticMessageFromJson implements DiagnosticMessage {
279279
this.severity, this.uri, this.involvedFiles, this.codeName);
280280

281281
factory DiagnosticMessageFromJson.fromJson(String jsonString) {
282-
Map<String, Object> decoded = json.decode(jsonString);
282+
Map<String, Object?> decoded = json.decode(jsonString);
283283
List<String> ansiFormatted =
284284
new List<String>.from(_asListOfString(decoded["ansiFormatted"]));
285285
List<String> plainTextFormatted =

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element;
5555
import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart';
5656
import 'package:analyzer_plugin/utilities/navigation/navigation_dart.dart';
5757
import 'package:http/http.dart' as http;
58-
import 'package:process/process.dart';
5958
import 'package:telemetry/crash_reporting.dart';
6059
import 'package:telemetry/telemetry.dart' as telemetry;
6160
import 'package:watcher/watcher.dart';
@@ -131,7 +130,6 @@ class AnalysisServer extends AbstractAnalysisServer {
131130
CrashReportingAttachmentsBuilder crashReportingAttachmentsBuilder,
132131
InstrumentationService instrumentationService, {
133132
http.Client? httpClient,
134-
ProcessManager? processManager,
135133
RequestStatisticsHelper? requestStatistics,
136134
DiagnosticServer? diagnosticServer,
137135
this.detachableFileSystemManager,
@@ -145,7 +143,6 @@ class AnalysisServer extends AbstractAnalysisServer {
145143
baseResourceProvider,
146144
instrumentationService,
147145
httpClient,
148-
processManager,
149146
NotificationManager(channel, baseResourceProvider.pathContext),
150147
requestStatistics: requestStatistics,
151148
enableBazelWatcher: enableBazelWatcher,
@@ -432,11 +429,9 @@ class AnalysisServer extends AbstractAnalysisServer {
432429
bool isPubspec(String filePath) =>
433430
file_paths.isPubspecYaml(resourceProvider.pathContext, filePath);
434431

435-
// When pubspecs are opened, trigger pre-loading of pub package names and
436-
// versions.
437-
final pubspecs = files.where(isPubspec).toList();
438-
if (pubspecs.isNotEmpty) {
439-
pubPackageService.beginCachePreloads(pubspecs);
432+
// When a pubspec is opened, trigger package name caching for completion.
433+
if (!pubPackageService.isRunning && files.any(isPubspec)) {
434+
pubPackageService.beginPackageNamePreload();
440435
}
441436

442437
priorityFiles.clear();
@@ -692,18 +687,6 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
692687
analysisDriver.priorityFiles = analysisServer.priorityFiles.toList();
693688
}
694689

695-
@override
696-
void pubspecChanged(String pubspecPath) {
697-
analysisServer.pubPackageService.fetchPackageVersionsViaPubOutdated(
698-
pubspecPath,
699-
pubspecWasModified: true);
700-
}
701-
702-
@override
703-
void pubspecRemoved(String pubspecPath) {
704-
analysisServer.pubPackageService.flushPackageCaches(pubspecPath);
705-
}
706-
707690
@override
708691
void recordAnalysisErrors(String path, List<AnalysisError> errors) {
709692
filesToFlush.add(path);

pkg/analysis_server/lib/src/analysis_server_abstract.dart

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import 'package:analysis_server/src/services/completion/dart/documentation_cache
1919
import 'package:analysis_server/src/services/completion/dart/extension_cache.dart';
2020
import 'package:analysis_server/src/services/correction/namespace.dart';
2121
import 'package:analysis_server/src/services/pub/pub_api.dart';
22-
import 'package:analysis_server/src/services/pub/pub_command.dart';
2322
import 'package:analysis_server/src/services/pub/pub_package_service.dart';
2423
import 'package:analysis_server/src/services/search/element_visitors.dart';
2524
import 'package:analysis_server/src/services/search/search_engine.dart';
@@ -53,7 +52,6 @@ import 'package:analyzer/src/util/file_paths.dart' as file_paths;
5352
import 'package:collection/collection.dart';
5453
import 'package:http/http.dart' as http;
5554
import 'package:meta/meta.dart';
56-
import 'package:process/process.dart';
5755

5856
/// Implementations of [AbstractAnalysisServer] implement a server that listens
5957
/// on a [CommunicationChannel] for analysis messages and process them.
@@ -154,26 +152,14 @@ abstract class AbstractAnalysisServer {
154152
ResourceProvider baseResourceProvider,
155153
this.instrumentationService,
156154
http.Client? httpClient,
157-
ProcessManager? processManager,
158155
this.notificationManager, {
159156
this.requestStatistics,
160157
bool enableBazelWatcher = false,
161158
}) : resourceProvider = OverlayResourceProvider(baseResourceProvider),
162159
pubApi = PubApi(instrumentationService, httpClient,
163160
Platform.environment['PUB_HOSTED_URL']) {
164-
// We can only use a LocalProcessManager to run pub commands when backed by
165-
// a real file system, otherwise we may try to run commands in folders that
166-
// don't really exist. If processManager was supplied, it's likely a mock
167-
// from a test in which case the pub command should still be created.
168-
if (baseResourceProvider is PhysicalResourceProvider) {
169-
processManager ??= LocalProcessManager();
170-
}
171-
final pubCommand = processManager != null
172-
? PubCommand(instrumentationService, processManager)
173-
: null;
174-
175-
pubPackageService = PubPackageService(
176-
instrumentationService, baseResourceProvider, pubApi, pubCommand);
161+
pubPackageService =
162+
PubPackageService(instrumentationService, baseResourceProvider, pubApi);
177163
performance = performanceDuringStartup;
178164

179165
pluginManager = PluginManager(

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ abstract class ContextManagerCallbacks {
122122
/// TODO(scheglov) Just pass results in here?
123123
void listenAnalysisDriver(AnalysisDriver driver);
124124

125-
/// The `pubspec.yaml` at [path] was added/modified.
126-
void pubspecChanged(String path);
127-
128-
/// The `pubspec.yaml` at [path] was removed.
129-
void pubspecRemoved(String path);
130-
131125
/// Record error information for the file with the given [path].
132126
void recordAnalysisErrors(String path, List<protocol.AnalysisError> errors);
133127
}
@@ -572,21 +566,12 @@ class ContextManagerImpl implements ContextManager {
572566

573567
_instrumentationService.logWatchEvent('<unknown>', path, type.toString());
574568

575-
final isPubpsec = file_paths.isPubspecYaml(pathContext, path);
576569
if (file_paths.isAnalysisOptionsYaml(pathContext, path) ||
577570
file_paths.isDotPackages(pathContext, path) ||
578571
file_paths.isPackageConfigJson(pathContext, path) ||
579-
isPubpsec ||
572+
file_paths.isPubspecYaml(pathContext, path) ||
580573
false) {
581574
_createAnalysisContexts();
582-
583-
if (isPubpsec) {
584-
if (type == ChangeType.REMOVE) {
585-
callbacks.pubspecRemoved(path);
586-
} else {
587-
callbacks.pubspecChanged(path);
588-
}
589-
}
590575
return;
591576
}
592577

@@ -741,12 +726,6 @@ class NoopContextManagerCallbacks implements ContextManagerCallbacks {
741726
@override
742727
void listenAnalysisDriver(AnalysisDriver driver) {}
743728

744-
@override
745-
void pubspecChanged(String pubspecPath) {}
746-
747-
@override
748-
void pubspecRemoved(String pubspecPath) {}
749-
750729
@override
751730
void recordAnalysisErrors(String path, List<protocol.AnalysisError> errors) {}
752731
}

pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin;
5252
import 'package:collection/collection.dart';
5353
import 'package:http/http.dart' as http;
5454
import 'package:meta/meta.dart';
55-
import 'package:process/process.dart';
5655
import 'package:watcher/watcher.dart';
5756

5857
/// Instances of the class [LspAnalysisServer] implement an LSP-based server
@@ -127,7 +126,6 @@ class LspAnalysisServer extends AbstractAnalysisServer {
127126
CrashReportingAttachmentsBuilder crashReportingAttachmentsBuilder,
128127
InstrumentationService instrumentationService, {
129128
http.Client? httpClient,
130-
ProcessManager? processManager,
131129
DiagnosticServer? diagnosticServer,
132130
// Disable to avoid using this in unit tests.
133131
bool enableBazelWatcher = false,
@@ -139,7 +137,6 @@ class LspAnalysisServer extends AbstractAnalysisServer {
139137
baseResourceProvider,
140138
instrumentationService,
141139
httpClient,
142-
processManager,
143140
LspNotificationManager(channel, baseResourceProvider.pathContext),
144141
enableBazelWatcher: enableBazelWatcher,
145142
) {
@@ -187,10 +184,10 @@ class LspAnalysisServer extends AbstractAnalysisServer {
187184
RefactoringWorkspace(driverMap.values, searchEngine);
188185

189186
void addPriorityFile(String filePath) {
190-
// When pubspecs are opened, trigger pre-loading of pub package names and
191-
// versions.
192-
if (file_paths.isPubspecYaml(resourceProvider.pathContext, filePath)) {
193-
pubPackageService.beginCachePreloads([filePath]);
187+
// When a pubspec is opened, trigger package name caching for completion.
188+
if (!pubPackageService.isRunning &&
189+
file_paths.isPubspecYaml(resourceProvider.pathContext, filePath)) {
190+
pubPackageService.beginPackageNamePreload();
194191
}
195192

196193
final didAdd = priorityFiles.add(filePath);
@@ -854,18 +851,6 @@ class LspServerContextManagerCallbacks extends ContextManagerCallbacks {
854851
analysisDriver.priorityFiles = analysisServer.priorityFiles.toList();
855852
}
856853

857-
@override
858-
void pubspecChanged(String pubspecPath) {
859-
analysisServer.pubPackageService.fetchPackageVersionsViaPubOutdated(
860-
pubspecPath,
861-
pubspecWasModified: true);
862-
}
863-
864-
@override
865-
void pubspecRemoved(String pubspecPath) {
866-
analysisServer.pubPackageService.flushPackageCaches(pubspecPath);
867-
}
868-
869854
@override
870855
void recordAnalysisErrors(String path, List<protocol.AnalysisError> errors) {
871856
final errorsToSend = errors.where(_shouldSendError).toList();

pkg/analysis_server/lib/src/lsp/mapping.dart

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ final diagnosticTagsForErrorCode = <String, List<lsp.DiagnosticTag>>{
4949
],
5050
};
5151

52-
/// Pattern for docComplete text on completion items that can be upgraded to
53-
/// the "detail" field so that it can be shown more prominently by clients.
54-
///
55-
/// This is typically used for labels like _latest compatible_ and _latest_ in
56-
/// the pubspec version items. These go into docComplete so that they appear
57-
/// reasonably for non-LSP clients where there is no equivalent of the detail
58-
/// field.
59-
final _upgradableDocCompletePattern = RegExp(r'^_([\w ]{0,20})_$');
60-
6152
lsp.Either2<String, lsp.MarkupContent> asStringOrMarkupContent(
6253
Set<lsp.MarkupKind>? preferredFormats, String content) {
6354
return preferredFormats == null
@@ -965,21 +956,7 @@ lsp.CompletionItem toCompletionItem(
965956
final insertText = insertTextInfo.first;
966957
final insertTextFormat = insertTextInfo.last;
967958
final isMultilineCompletion = insertText.contains('\n');
968-
969-
var cleanedDoc = cleanDartdoc(suggestion.docComplete);
970-
var detail = getCompletionDetail(suggestion, completionKind,
971-
supportsCompletionDeprecatedFlag || supportsDeprecatedTag);
972-
973-
// To improve the display of some items (like pubspec version numbers),
974-
// short labels in the format `_foo_` in docComplete are "upgraded" to the
975-
// detail field.
976-
final labelMatch = cleanedDoc != null
977-
? _upgradableDocCompletePattern.firstMatch(cleanedDoc)
978-
: null;
979-
if (labelMatch != null) {
980-
cleanedDoc = null;
981-
detail = labelMatch.group(1);
982-
}
959+
final cleanedDoc = cleanDartdoc(suggestion.docComplete);
983960

984961
// Because we potentially send thousands of these items, we should minimise
985962
// the generated JSON as much as possible - for example using nulls in place
@@ -994,7 +971,8 @@ lsp.CompletionItem toCompletionItem(
994971
commitCharacters:
995972
includeCommitCharacters ? dartCompletionCommitCharacters : null,
996973
data: resolutionData,
997-
detail: detail,
974+
detail: getCompletionDetail(suggestion, completionKind,
975+
supportsCompletionDeprecatedFlag || supportsDeprecatedTag),
998976
documentation: cleanedDoc != null
999977
? asStringOrMarkupContent(formats, cleanedDoc)
1000978
: null,

pkg/analysis_server/lib/src/services/completion/yaml/producer.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,9 @@ abstract class Producer {
176176
const Producer();
177177

178178
/// A utility method used to create a suggestion for the [identifier].
179-
CompletionSuggestion identifier(String identifier,
180-
{int relevance = 1000, String? docComplete}) =>
179+
CompletionSuggestion identifier(String identifier, {int relevance = 1000}) =>
181180
CompletionSuggestion(CompletionSuggestionKind.IDENTIFIER, relevance,
182-
identifier, identifier.length, 0, false, false,
183-
docComplete: docComplete);
181+
identifier, identifier.length, 0, false, false);
184182

185183
/// A utility method used to create a suggestion for the package [packageName].
186184
CompletionSuggestion packageName(String packageName,

pkg/analysis_server/lib/src/services/completion/yaml/pubspec_generator.dart

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,18 @@ class PubPackageVersionProducer extends Producer {
3737
@override
3838
Iterable<CompletionSuggestion> suggestions(
3939
YamlCompletionRequest request) sync* {
40-
final versions = request.pubPackageService
41-
?.cachedPubOutdatedVersions(request.filePath, package);
42-
final resolvable = versions?.resolvableVersion;
43-
var latest = versions?.latestVersion;
44-
45-
// If we didn't get a latest version from the "pub outdated" results, we can
46-
// use the result from the Pub API if we've called it (this will usually
47-
// only be the case for LSP where a resolve() call was sent).
40+
// TOOD(dantup): Consider supporting async completion requests so this
41+
// could call packageDetails() (with a short timeout, and pub retries
42+
// disabled). A user that explicitly invokes completion in the location
43+
// of a version may be prepared to wait a short period for a web request
44+
// to get completion versions (this is also the only way for non-LSP
45+
// clients to get them, since there are no resolve calls).
4846
//
49-
// This allows us (in some cases) to still show version numbers even if the
50-
// package was newly added to pubspec and not saved, so not yet in the
51-
// "pub outdated" results.
52-
latest ??= request.pubPackageService?.cachedPubApiLatestVersion(package);
53-
54-
if (resolvable != null && resolvable != latest) {
55-
yield identifier('^$resolvable', docComplete: '_latest compatible_');
56-
}
57-
if (latest != null) {
58-
yield identifier('^$latest', docComplete: '_latest_');
47+
// Supporting this will require making the completion async further up.
48+
final details = request.pubPackageService?.cachedPackageDetails(package);
49+
final version = details?.latestVersion;
50+
if (version != null) {
51+
yield identifier('^$version');
5952
}
6053
}
6154
}

0 commit comments

Comments
 (0)