Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement compileDDC, additional fields for v3 #2682

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 67 additions & 4 deletions pkgs/dart_pad/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
cli_pkg:
dependency: transitive
description:
name: cli_pkg
sha256: "716254ea9f38179f64ff36d6e26c6193acd59939baeaf5b932ed13f25b28f6ad"
url: "https://pub.dev"
source: hosted
version: "2.7.0"
cli_repl:
dependency: transitive
description:
Expand Down Expand Up @@ -265,6 +273,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.3"
dartpad_shared:
dependency: "direct main"
description:
path: "../dartpad_shared"
relative: true
source: path
version: "0.0.0"
encrypt:
dependency: "direct main"
description:
Expand All @@ -273,6 +288,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.3"
ffi:
dependency: transitive
description:
name: ffi
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
file:
dependency: transitive
description:
Expand Down Expand Up @@ -357,10 +380,10 @@ packages:
dependency: "direct main"
description:
name: http
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
url: "https://pub.dev"
source: hosted
version: "0.13.6"
version: "1.1.0"
http_multi_server:
dependency: transitive
description:
Expand Down Expand Up @@ -465,6 +488,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
native_synchronization:
dependency: transitive
description:
name: native_synchronization
sha256: ff200fe0a64d733ff7d4dde2005271c297db81007604c8cd21037959858133ab
url: "https://pub.dev"
source: hosted
version: "0.2.0"
node_interop:
dependency: transitive
description:
Expand Down Expand Up @@ -497,6 +528,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.8.3"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: eeb2d1428ee7f4170e2bd498827296a18d4e7fc462b71727d111c0ac7707cfa6
url: "https://pub.dev"
source: hosted
version: "6.0.1"
pointycastle:
dependency: transitive
description:
Expand Down Expand Up @@ -537,14 +576,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.3"
retry:
dependency: transitive
description:
name: retry
sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sass:
dependency: "direct overridden"
description:
name: sass
sha256: c3ba6203735361e1c779f0d84b650cf7f1c0c94b0e8223b944447b82fb018832
sha256: "5dd460578023d236404c3131cd7543399a891189aad130f61a16cc91f4842973"
url: "https://pub.dev"
source: hosted
version: "1.65.1"
version: "1.69.3"
sass_builder:
dependency: "direct main"
description:
Expand Down Expand Up @@ -712,6 +759,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.7"
test_process:
dependency: transitive
description:
name: test_process
sha256: "217f19b538926e4922bdb2a01410100ec4e3beb4cc48eae5ae6b20037b07bbd6"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -768,6 +823,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
xml:
dependency: transitive
description:
name: xml
sha256: af5e77e9b83f2f4adc5d3f0a4ece1c7f45a2467b695c2540381bac793e34e556
url: "https://pub.dev"
source: hosted
version: "6.4.2"
yaml:
dependency: "direct main"
description:
Expand Down
6 changes: 4 additions & 2 deletions pkgs/dart_pad/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ dependencies:
checked_yaml: ^2.0.3
codemirror: ^0.7.10+5.65.13
collection: ^1.17.2
dartpad_shared: any
encrypt: ^5.0.1
fluttering_phrases: ^0.5.0
html_unescape: ^2.0.0
http: ^0.13.0
http: ^1.1.0
js: ^0.6.7
json_annotation: ^4.8.1
logging: ^1.2.0
Expand Down Expand Up @@ -42,6 +43,8 @@ dev_dependencies:
webdriver: ^3.0.2

dependency_overrides:
dartpad_shared:
path: ../dartpad_shared
# package:mdc_web needs to upgrade the version of material-components-web 12.0.0
# or above, which includes this fix for the division operator:
# https://github.com/material-components/material-components-web/pull/7158
Expand All @@ -52,6 +55,5 @@ dependency_overrides:
# See this issue for details:
# https://github.com/dart-lang/dart-pad/issues/2388
sass: ^1.62.0

split:
path: third_party/pkg/split/
14 changes: 9 additions & 5 deletions pkgs/dart_services/lib/src/analysis_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ abstract class AnalysisServerWrapper {
relevance: suggestion.relevance,
completion: suggestion.completion,
deprecated: suggestion.isDeprecated,
selectionOffset: suggestion.selectionOffset,
displayText: suggestion.displayText,
returnType: suggestion.returnType,
elementKind: suggestion.element?.kind,
Expand Down Expand Up @@ -685,12 +686,15 @@ extension SourceChangeExtension on SourceChange {
message: message,
edits: edits
.expand((fileEdit) => fileEdit.edits)
.map((edit) => api.SourceEdit(
offset: edit.offset,
length: edit.length,
replacement: edit.replacement,
))
.map(
(edit) => api.SourceEdit(
offset: edit.offset,
length: edit.length,
replacement: edit.replacement,
),
)
.toList(),
selectionOffset: selection?.offset,
);
}
}
36 changes: 28 additions & 8 deletions pkgs/dart_services/lib/src/common_server_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class CommonServerApi {
kind: issue.kind,
message: issue.message,
correction: issue.hasCorrection() ? issue.correction : null,
url: issue.hasUrl() ? issue.url : null,
charStart: issue.charStart,
charLength: issue.charLength,
line: issue.line,
Expand Down Expand Up @@ -99,14 +100,32 @@ class CommonServerApi {
}

@Route.post('$apiPrefix/compileDDC')
Future<Response> compileDDC(Request request, String apiVersion) {
return _processRequest(
request,
decodeFromJSON: (json) =>
proto.CompileDDCRequest.create()..mergeFromProto3Json(json),
decodeFromProto: proto.CompileDDCRequest.fromBuffer,
transform: _impl.compileDDC,
);
Future<Response> compileDDC(Request request, String apiVersion) async {
if (apiVersion == api2) {
return _processRequest(
request,
decodeFromJSON: (json) =>
proto.CompileDDCRequest.create()..mergeFromProto3Json(json),
decodeFromProto: proto.CompileDDCRequest.fromBuffer,
transform: _impl.compileDDC,
);
} else if (apiVersion == api3) {
final sourceRequest =
api.SourceRequest.fromJson(await request.readAsJson());
final results = await serialize(() {
return _impl.compiler.compileDDC(sourceRequest.source);
});
if (results.hasOutput) {
return ok(api.CompileDDCResponse(
result: results.compiledJS!,
modulesBaseUrl: results.modulesBaseUrl!,
).toJson());
} else {
return failure(results.problems.map((p) => p.message).join('\n'));
}
} else {
return unhandledVersion(apiVersion);
}
}

@experimental
Expand Down Expand Up @@ -401,6 +420,7 @@ class CommonServerApi {
return api.VersionResponse(
dartVersion: sdk.versionFull,
flutterVersion: sdk.flutterVersion,
engineVersion: sdk.engineVersion,
experiments: sdk.experiments,
packages: packages,
);
Expand Down
24 changes: 24 additions & 0 deletions pkgs/dart_services/lib/src/shared/model.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading