Skip to content

Commit

Permalink
Version 3.4.0-202.0.dev
Browse files Browse the repository at this point in the history
Merge e786502 into dev
  • Loading branch information
Dart CI committed Mar 5, 2024
2 parents d74a953 + e786502 commit b4d06bc
Show file tree
Hide file tree
Showing 66 changed files with 1,795 additions and 740 deletions.
4 changes: 2 additions & 2 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def HasFormatErrors(filename: str = None,
# them.
def skip_file(path):
if path.endswith('_test.dart'):
with open(path) as f:
with open(path, encoding='utf-8') as f:
contents = f.read()
if '//#' in contents:
return True
Expand Down Expand Up @@ -427,7 +427,7 @@ def _CheckCopyrightYear(input_api, output_api):
path = f.LocalPath()
if (is_dart_file(path) or is_cpp_file(path)
) and f.Action() == 'A' and os.path.isfile(path):
with open(path) as f:
with open(path, encoding='utf-8') as f:
first_line = f.readline()
if 'Copyright' in first_line and year not in first_line:
files.append(path)
Expand Down
127 changes: 46 additions & 81 deletions build/dart/dart_action.gni
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
# BSD-style license that can be found in the LICENSE file.

import("../executable_suffix.gni")
import("prebuilt_dart_sdk.gni")

_is_fuchsia = defined(is_fuchsia_tree) && is_fuchsia_tree

if (_is_fuchsia) {
import("//build/dart/dart.gni")
}

# This file defines templates for running and compiling Dart code during
# Dart's build.
Expand Down Expand Up @@ -99,8 +92,6 @@ template("_compiled_action") {
template("_prebuilt_tool_action") {
assert(defined(invoker.binary),
"The path to where the prebuilt binary lives must be defined")
assert(_is_fuchsia || prebuilt_dart_exe_works,
"A pre built dart executable needs to be present")

vm_args = []
if (defined(invoker.vm_args)) {
Expand Down Expand Up @@ -180,22 +171,8 @@ template("prebuilt_dart_action") {

_prebuilt_tool_action(target_name) {
forward_variables_from(invoker, "*")
if (_is_fuchsia) {
binary = prebuilt_dart
dfe = "$prebuilt_dart_sdk/bin/snapshots/kernel-service.dart.snapshot"
} else {
binary = "$_dart_root/tools/sdks/dart-sdk/bin/dart$executable_suffix"
dfe = "$_dart_root/tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot"
}
}
}

if (_is_fuchsia) {
template("_prebuilt_gen_snapshot_action") {
_prebuilt_tool_action(target_name) {
forward_variables_from(invoker, "*")
binary = prebuilt_gen_snapshot
}
binary = "$_dart_root/tools/sdks/dart-sdk/bin/dart$executable_suffix"
dfe = "$_dart_root/tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot"
}
}

Expand Down Expand Up @@ -298,39 +275,33 @@ template("_built_tool_action") {
# visibility
template("dart_action") {
assert(defined(invoker.script), "script must be defined for $target_name")
if (!_is_fuchsia || !use_prebuilt_dart_sdk) {
_built_tool_action(target_name) {
tool = "$_dart_root/runtime/bin:dart"
forward_variables_from(invoker,
[
"args",
"depfile",
"deps",
"inputs",
"outputs",
"packages",
"pool",
"script",
"testonly",
"tool",
"visibility",
"vm_args",
])
_built_tool_action(target_name) {
tool = "$_dart_root/runtime/bin:dart"
forward_variables_from(invoker,
[
"args",
"depfile",
"deps",
"inputs",
"outputs",
"packages",
"pool",
"script",
"testonly",
"tool",
"visibility",
"vm_args",
])

# Dart has an implicit dependency on the kernel service so unless DFE is
# passed, we need to add this dep.
if (defined(invoker.dfe)) {
vm_args += [ "--dfe=" + rebase_path(invoker.dfe, root_build_dir) ]
} else {
if (!defined(invoker.deps)) {
deps = []
}
deps += [ "$_dart_root/utils/kernel-service:kernel-service" ]
# Dart has an implicit dependency on the kernel service so unless DFE is
# passed, we need to add this dep.
if (defined(invoker.dfe)) {
vm_args += [ "--dfe=" + rebase_path(invoker.dfe, root_build_dir) ]
} else {
if (!defined(invoker.deps)) {
deps = []
}
}
} else {
prebuilt_dart_action(target_name) {
forward_variables_from(invoker, "*")
deps += [ "$_dart_root/utils/kernel-service:kernel-service" ]
}
}
}
Expand Down Expand Up @@ -365,31 +336,25 @@ template("gen_snapshot_action") {
assert(
!defined(invoker.script),
"script must not be defined for $target_name. If there is a script use args instead.")
if (!_is_fuchsia || !use_prebuilt_dart_sdk) {
_built_tool_action(target_name) {
if (product_mode) {
tool = "$_dart_root/runtime/bin:gen_snapshot_product"
} else {
tool = "$_dart_root/runtime/bin:gen_snapshot"
}
forward_variables_from(invoker,
[
"args",
"depfile",
"deps",
"inputs",
"outputs",
"packages",
"pool",
"testonly",
"tool",
"visibility",
"vm_args",
])
}
} else {
_prebuilt_gen_snapshot_action(target_name) {
forward_variables_from(invoker, "*")
_built_tool_action(target_name) {
if (product_mode) {
tool = "$_dart_root/runtime/bin:gen_snapshot_product"
} else {
tool = "$_dart_root/runtime/bin:gen_snapshot"
}
forward_variables_from(invoker,
[
"args",
"depfile",
"deps",
"inputs",
"outputs",
"packages",
"pool",
"testonly",
"tool",
"visibility",
"vm_args",
])
}
}
25 changes: 0 additions & 25 deletions build/dart/prebuilt_dart_sdk.gni

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ mixin FactorTypeTestMixin<Type> {
Type get dynamicType;
Type get intNone;
Type get intQuestion;
Type get intStar;
Type get numNone;
Type get numQuestion;
Type get numStar;
Type get objectNone;
Type get objectQuestion;
Type get objectStar;
Type get stringNone;
Type get stringQuestion;
Type get stringStar;
Type get nullNone;
Type get voidType;

Expand All @@ -34,8 +30,6 @@ mixin FactorTypeTestMixin<Type> {
check(futureOrNone(intQuestion), futureNone(intNone), 'FutureOr<int?>');
check(futureOrNone(intQuestion), intQuestion, 'Future<int?>');
check(futureOrNone(intQuestion), futureNone(intQuestion), 'int?');
check(futureOrNone(intQuestion), intStar, 'Future<int?>');
check(futureOrNone(intQuestion), futureNone(intStar), 'int?');

check(futureOrNone(intNone), numNone, 'Future<int>');
check(futureOrNone(intNone), futureNone(numNone), 'int');
Expand All @@ -44,61 +38,38 @@ mixin FactorTypeTestMixin<Type> {
void test_object() {
check(objectNone, objectNone, 'Never');
check(objectNone, objectQuestion, 'Never');
check(objectNone, objectStar, 'Never');

check(objectNone, intNone, 'Object');
check(objectNone, intQuestion, 'Object');
check(objectNone, intStar, 'Object');

check(objectQuestion, objectNone, 'Never?');
check(objectQuestion, objectQuestion, 'Never');
check(objectQuestion, objectStar, 'Never');

check(objectQuestion, intNone, 'Object?');
check(objectQuestion, intQuestion, 'Object');
check(objectQuestion, intStar, 'Object');
}

test_subtype() {
check(intNone, intNone, 'Never');
check(intNone, intQuestion, 'Never');
check(intNone, intStar, 'Never');

check(intQuestion, intNone, 'Never?');
check(intQuestion, intQuestion, 'Never');
check(intQuestion, intStar, 'Never');

check(intStar, intNone, 'Never');
check(intStar, intQuestion, 'Never');
check(intStar, intStar, 'Never');

check(intNone, numNone, 'Never');
check(intNone, numQuestion, 'Never');
check(intNone, numStar, 'Never');

check(intQuestion, numNone, 'Never?');
check(intQuestion, numQuestion, 'Never');
check(intQuestion, numStar, 'Never');

check(intStar, numNone, 'Never');
check(intStar, numQuestion, 'Never');
check(intStar, numStar, 'Never');

check(intNone, nullNone, 'int');
check(intQuestion, nullNone, 'int');
check(intStar, nullNone, 'int');

check(intNone, stringNone, 'int');
check(intQuestion, stringNone, 'int?');
check(intStar, stringNone, 'int*');

check(intNone, stringQuestion, 'int');
check(intQuestion, stringQuestion, 'int');
check(intStar, stringQuestion, 'int');

check(intNone, stringStar, 'int');
check(intQuestion, stringStar, 'int');
check(intStar, stringStar, 'int');
}

void test_void() {
Expand Down
11 changes: 4 additions & 7 deletions pkg/analysis_server/lib/src/computer/computer_highlights.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1008,9 +1008,8 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {

@override
void visitFunctionDeclaration(FunctionDeclaration node) {
// TODO(brianwilkerson): Update the interface to expose the token.
// computer._addRegion_token(
// node.augmentKeyword, HighlightRegionType.BUILT_IN);
computer._addRegion_token(
node.augmentKeyword, HighlightRegionType.BUILT_IN);
computer._addRegion_token(
node.externalKeyword, HighlightRegionType.BUILT_IN);
computer._addRegion_token(
Expand Down Expand Up @@ -1542,10 +1541,8 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {

@override
void visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
// TODO(brianwilkerson): Uncomment the following lines when the token is
// supported.
// computer._addRegion_token(
// node.augmentKeyword, HighlightRegionType.BUILT_IN);
computer._addRegion_token(
node.augmentKeyword, HighlightRegionType.BUILT_IN);
computer._addRegion_token(
node.externalKeyword, HighlightRegionType.BUILT_IN);

Expand Down
3 changes: 3 additions & 0 deletions pkg/analysis_server/lib/src/lsp/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ abstract class ServerErrorCodes {
/// A file that is expected to be analyzed, but failed.
static const FileAnalysisFailed = ErrorCodes(-32013);

/// Computation of a refactoring change failed.
static const RefactoringComputeStatusFailure = ErrorCodes(-32014);

/// An error raised when the server detects that the server and client are out
/// of sync and cannot recover. For example if a textDocument/didChange notification
/// has invalid offsets, suggesting the client and server have become out of sync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:analysis_server/src/lsp/progress.dart';
import 'package:analysis_server/src/lsp/source_edits.dart';
import 'package:analysis_server/src/services/refactoring/framework/refactoring_context.dart';
import 'package:analysis_server/src/services/refactoring/framework/refactoring_processor.dart';
import 'package:analysis_server/src/services/refactoring/framework/refactoring_producer.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';

Expand Down Expand Up @@ -73,7 +74,17 @@ class RefactorCommandHandler extends SimpleEditCommandHandler {
var producer = generator(context);
var builder = ChangeBuilder(
workspace: context.workspace, eol: context.utils.endOfLine);
await producer.compute(arguments, builder);
var status = await producer.compute(arguments, builder);

if (status is ComputeStatusFailure) {
var reason = status.reason ?? 'Cannot compute the change. No details.';
return ErrorOr.error(
ResponseError(
code: ServerErrorCodes.RefactoringComputeStatusFailure,
message: reason,
),
);
}

var edits = builder.sourceChange.edits;
if (edits.isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ final class ClassSuggestion extends ImportableSuggestion {
String get completion => '$completionPrefix${element.name}';
}

/// The information about a candidate suggestion based on a constructor.
final class ClosureSuggestion extends CandidateSuggestion {
/// The type that the closure must conform to.
final FunctionType functionType;

/// Whether a trailing comma should be included in the suggestion.
final bool includeTrailingComma;

/// Initialize a newly created candidate suggestion to suggest a closure that
/// conforms to the given [functionType].
///
/// If [includeTrailingComma] is `true`, then the replacement will include a
/// trailing comma.
ClosureSuggestion(
{required this.functionType, required this.includeTrailingComma});

@override
// TODO(brianwilkerson): Fix this.
String get completion => '() {}${includeTrailingComma ? ', ' : ''}';
}

/// The information about a candidate suggestion based on a constructor.
final class ConstructorSuggestion extends ImportableSuggestion {
/// The element on which the suggestion is based.
Expand Down Expand Up @@ -560,6 +581,9 @@ extension SuggestionBuilderExtension on SuggestionBuilder {
libraryUriStr = suggestion.libraryUriStr;
suggestInterface(suggestion.element, prefix: suggestion.prefix);
libraryUriStr = null;
case ClosureSuggestion():
suggestClosure(suggestion.functionType,
includeTrailingComma: suggestion.includeTrailingComma);
case ConstructorSuggestion():
libraryUriStr = suggestion.libraryUriStr;
suggestConstructor(suggestion.element,
Expand Down
Loading

0 comments on commit b4d06bc

Please sign in to comment.