Skip to content

Commit

Permalink
Version 3.7.0-138.0.dev
Browse files Browse the repository at this point in the history
Merge 2fbb33e into dev
  • Loading branch information
Dart CI committed Nov 13, 2024
2 parents cdc17e2 + 2fbb33e commit c7d140d
Show file tree
Hide file tree
Showing 56 changed files with 4,187 additions and 4,141 deletions.
12 changes: 6 additions & 6 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ config("compiler") {
cc_std = [
# This option fixes the value of the __cplusplus macro when using MSVC.
"/Zc:__cplusplus",
"/std:c++17",
"/std:c++20",
]
} else {
cc_std = [ "-std=c++17" ]
cc_std = [ "-std=c++20" ]
}
cflags_cc += cc_std
cflags_objcc += cc_std
Expand Down Expand Up @@ -433,10 +433,10 @@ config("compiler") {
config("cxx_version_default") {
if (is_win) {
cflags_c = [ "/std:c17" ]
cc_std = [ "/std:c++17" ]
cc_std = [ "/std:c++20" ]
} else {
cflags_c = [ "-std=c17" ]
cc_std = [ "-std=c++17" ]
cc_std = [ "-std=c++20" ]
}
cflags_cc = cc_std
cflags_objcc = cc_std
Expand Down Expand Up @@ -480,10 +480,10 @@ config("cxx_version_17") {

config("cxx_version_20") {
if (is_win) {
cflags_c = [ "/std:c20" ]
cflags_c = [ "/std:c17" ]
cc_std = [ "/std:c++20" ]
} else {
cflags_c = [ "-std=c20" ]
cflags_c = [ "-std=c17" ]
cc_std = [ "-std=c++20" ]
}
cflags_cc = cc_std
Expand Down
4 changes: 2 additions & 2 deletions pkg/_macros/lib/src/executor/augmentation_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ mixin AugmentationLibraryBuilder on MacroExecutor {
Iterable<MacroExecutionResult> macroResults,
TypeDeclaration Function(Identifier) resolveDeclaration,
ResolvedIdentifier Function(Identifier) resolveIdentifier,
TypeAnnotation? Function(OmittedTypeAnnotation) typeInferrer,
TypeAnnotation? Function(OmittedTypeAnnotation) inferOmittedType,
{Map<OmittedTypeAnnotation, String>? omittedTypes,
List<Span>? spans}) {
return _Builder(augmentedLibraryUri, resolveDeclaration, resolveIdentifier,
typeInferrer, omittedTypes)
inferOmittedType, omittedTypes)
.build(macroResults, spans: spans);
}
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/analysis_server/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ lib/src/services/search/element_visitors.dart
lib/src/services/search/hierarchy.dart
lib/src/services/search/search_engine.dart
lib/src/services/search/search_engine_internal.dart
lib/src/status/ast_writer.dart
lib/src/status/diagnostics.dart
lib/src/status/element_writer.dart
lib/src/status/tree_writer.dart
lib/src/utilities/extensions/ast.dart
lib/src/utilities/extensions/completion_request.dart
lib/src/utilities/extensions/element.dart
Expand Down
76 changes: 63 additions & 13 deletions pkg/analysis_server/lib/src/cider/local_library_contributor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import 'package:analysis_server/src/services/completion/dart/suggestion_builder.
show SuggestionBuilder;
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/visitor.dart';
import 'package:analyzer/src/utilities/extensions/element.dart';
import 'package:analyzer_plugin/src/utilities/completion/optype.dart';

/// A visitor for building suggestions based upon the elements defined by
Expand Down Expand Up @@ -92,7 +94,11 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor<void> {
void visitExtensionElement(ExtensionElement element) {
if (opType.includeReturnValueSuggestions) {
if (element.name != null) {
builder.suggestExtension(element, kind: kind, prefix: prefix);
builder.suggestExtension(
element.asElement2 as ExtensionElement2,
kind: kind,
prefix: prefix,
);
}
}
}
Expand All @@ -114,11 +120,19 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor<void> {
var returnType = element.returnType;
if (returnType is VoidType) {
if (opType.includeVoidReturnSuggestions) {
builder.suggestTopLevelFunction(element, kind: kind, prefix: prefix);
builder.suggestTopLevelFunction(
element.asElement2 as TopLevelFunctionElement,
kind: kind,
prefix: prefix,
);
}
} else {
if (opType.includeReturnValueSuggestions) {
builder.suggestTopLevelFunction(element, kind: kind, prefix: prefix);
builder.suggestTopLevelFunction(
element.asElement2 as TopLevelFunctionElement,
kind: kind,
prefix: prefix,
);
}
}
}
Expand Down Expand Up @@ -152,29 +166,58 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor<void> {
if (element.isSynthetic) {
if (element.isGetter) {
if (variable is FieldElement) {
builder.suggestField(variable, inheritanceDistance: 0.0);
builder.suggestField(
variable.asElement2 as FieldElement2,
inheritanceDistance: 0.0,
);
}
}
} else {
builder.suggestAccessor(element, inheritanceDistance: 0.0);
if (element.isGetter) {
builder.suggestGetter(
element.asElement2 as GetterElement,
inheritanceDistance: 0.0,
);
} else {
builder.suggestSetter(
element.asElement2 as SetterElement,
inheritanceDistance: 0.0,
);
}
}
} else {
builder.suggestTopLevelPropertyAccessor(element, prefix: prefix);
if (element.isGetter) {
builder.suggestTopLevelGetter(
element.asElement2 as GetterElement,
prefix: prefix,
);
} else {
builder.suggestTopLevelSetter(
element.asElement2 as SetterElement,
prefix: prefix,
);
}
}
}
}

@override
void visitTopLevelVariableElement(TopLevelVariableElement element) {
if (opType.includeReturnValueSuggestions && !element.isSynthetic) {
builder.suggestTopLevelVariable(element, prefix: prefix);
builder.suggestTopLevelVariable(
element.asElement2 as TopLevelVariableElement2,
prefix: prefix,
);
}
}

@override
void visitTypeAliasElement(TypeAliasElement element) {
if (opType.includeTypeNameSuggestions) {
builder.suggestTypeAlias(element, prefix: prefix);
builder.suggestTypeAlias(
element.asElement2 as TypeAliasElement2,
prefix: prefix,
);
}
}

Expand All @@ -199,13 +242,17 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor<void> {
if (onlyConst && !constructor.isConst) {
continue;
}
builder.suggestConstructor(constructor, kind: kind, prefix: prefix);
builder.suggestConstructor(
constructor.asElement2 as ConstructorElement2,
kind: kind,
prefix: prefix,
);
}
}

void _visitInterfaceElement(InterfaceElement element) {
if (opType.includeTypeNameSuggestions) {
builder.suggestInterface(element, prefix: prefix);
builder.suggestInterface(element.asElement2, prefix: prefix);
}
if (element is ClassElement) {
if (opType.includeConstructorSuggestions) {
Expand All @@ -226,14 +273,17 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor<void> {
if (field.isSynthetic) {
var getter = field.getter;
if (getter != null) {
builder.suggestAccessor(
getter,
builder.suggestGetter(
getter.asElement2 as GetterElement,
inheritanceDistance: 0.0,
withEnclosingName: true,
);
}
} else {
builder.suggestStaticField(field, prefix: prefix);
builder.suggestStaticField(
field.asElement2 as FieldElement2,
prefix: prefix,
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/lint/linter.dart';
Expand Down Expand Up @@ -170,6 +171,13 @@ class EditableArgumentsHandler
);
}

/// Returns the name of an enum constant prefixed with the enum name.
String? _qualifiedEnumConstant(FieldElement2 enumConstant) {
var enumName = enumConstant.enclosingElement2?.name3;
var name = enumConstant.name3;
return enumName != null && name != null ? '$enumName.$name' : null;
}

/// Converts a [parameter]/[argument] pair into an [EditableArgument] if it
/// is an argument that can be edited.
EditableArgument? _toEditableArgument(
Expand Down Expand Up @@ -200,20 +208,43 @@ class EditableArgumentsHandler
} else if (parameter.type.isDartCoreString) {
type = 'string';
value = (values.argumentValue ?? values.parameterValue)?.toStringValue();
} else if (parameter.type case InterfaceType(:EnumElement2 element3)) {
type = 'enum';
options =
element3.constants2.map(_qualifiedEnumConstant).nonNulls.toList();

// Try to match the argument value up with the enum.
var valueObject = values.argumentValue ?? values.parameterValue;
if (valueObject?.type case InterfaceType(
element3: EnumElement2 valueElement,
) when element3 == valueElement) {
var index = valueObject?.getField('index')?.toIntValue();
if (index != null) {
var enumConstant = element3.constants2.elementAtOrNull(index);
if (enumConstant != null) {
value = _qualifiedEnumConstant(enumConstant);
}
}
}
} else {
// TODO(dantup): Enums.

// TODO(dantup): Determine which parameters we don't include (such as
// Widgets) and which we include just without values.
return null;
}

// If the value is not a literal, include the source as displayValue.
var displayValue =
valueExpression is! Literal ? valueExpression?.toSource() : null;
// Unless it turns out to match the value (converted to string).
if (displayValue != null && displayValue == value?.toString()) {
displayValue = null;
}

return EditableArgument(
name: parameter.displayName,
type: type,
value: value,
displayValue:
valueExpression is! Literal ? valueExpression?.toSource() : null,
displayValue: displayValue,
options: options,
isDefault: values.isDefault,
hasArgument: valueExpression != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ class ExperimentalEchoHandler extends SharedMessageHandler<Object?, Object?> {
MessageInfo message,
CancellationToken token,
) async {
// The DTD client automatically converts `null` params to an empty map, but
// (because of a previous bug) we want to test null results. So if the
// params are an empty map, return null. This is tested by
// `test_service_success_echo_nullResponse` in `SharedDtdTests`.
if (params is Map && params.isEmpty) {
return success(null);
}

return success(params);
}
}
14 changes: 9 additions & 5 deletions pkg/analysis_server/lib/src/protocol_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,15 @@ Location? newLocation_fromElement2(engine.Element2? element) {
if (element == null) {
return null;
}
var fragment = element.firstFragment;
var offset = fragment.nameOffset2 ?? 0;
var length = fragment.name2?.length ?? 0;
var range = engine.SourceRange(offset, length);
return _locationForArgs2(fragment, range);
if (element is engine.FormalParameterElement &&
element.enclosingElement2 == null) {
return null;
}
var fragment = element.firstFragment;
var offset = fragment.nameOffset2 ?? 0;
var length = fragment.name2?.length ?? 0;
var range = engine.SourceRange(offset, length);
return _locationForArgs2(fragment, range);
}

/// Create a Location based on an [engine.SearchMatch].
Expand Down
Loading

0 comments on commit c7d140d

Please sign in to comment.