Version 2.12.0-269.0.dev
Merge commit '75a5e771be83ef40969ba741e95b4e462ca32d12' into 'dev'
diff --git a/DEPS b/DEPS
index 8ddc6b3..6ba4e67 100644
--- a/DEPS
+++ b/DEPS
@@ -142,7 +142,7 @@
"shelf_packages_handler_tag": "2.0.0",
"shelf_proxy_tag": "0.1.0+7",
"shelf_rev": "fa5afaa38bd51dedeeaa25b7bfd8822cabbcc57f",
- "shelf_web_socket_rev": "abae6956e2f7d863a416c99aa031d7fa1a7160a7",
+ "shelf_web_socket_rev": "bf8554ff80089bf88de262503f85dc3610d79ecf",
"source_map_stack_trace_rev": "1c3026f69d9771acf2f8c176a1ab750463309cce",
"source_maps-0.9.4_rev": "38524",
"source_maps_rev": "53eb92ccfe6e64924054f83038a534b959b12b3e",
diff --git a/pkg/analysis_server/doc/api.html b/pkg/analysis_server/doc/api.html
index 42a0c71..e5f6988 100644
--- a/pkg/analysis_server/doc/api.html
+++ b/pkg/analysis_server/doc/api.html
@@ -3764,6 +3764,12 @@
The type parameter list for the element. If the element doesn't have
type parameters, this field will not be defined.
</p>
+ </dd><dt class="field"><b>aliasedType: String<span style="color:#999999"> (optional)</span></b></dt><dd>
+
+ <p>
+ If the element is a type alias, this field is the aliased type.
+ Otherwise this field will not be defined.
+ </p>
</dd></dl></dd><dt class="typeDefinition"><a name="type_ElementDeclaration">ElementDeclaration: object</a></dt><dd>
<p>
A declaration - top-level (class, field, etc) or a class member (method,
diff --git a/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart b/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart
index d2793e8..915d8b3 100644
--- a/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart
+++ b/pkg/analysis_server/lib/plugin/protocol/protocol_dart.dart
@@ -10,25 +10,29 @@
/// Return a protocol [Element] corresponding to the given [engine.Element].
Element convertElement(engine.Element element) {
+ var kind = convertElementToElementKind(element);
var name = getElementDisplayName(element);
var elementTypeParameters = _getTypeParametersString(element);
+ var aliasedType = getAliasedTypeString(element);
var elementParameters = _getParametersString(element);
var elementReturnType = getReturnTypeString(element);
- var kind = convertElementToElementKind(element);
return Element(
- kind,
- name,
- Element.makeFlags(
- isPrivate: element.isPrivate,
- isDeprecated: element.hasDeprecated,
- isAbstract: _isAbstract(element),
- isConst: _isConst(element),
- isFinal: _isFinal(element),
- isStatic: _isStatic(element)),
- location: newLocation_fromElement(element),
- typeParameters: elementTypeParameters,
- parameters: elementParameters,
- returnType: elementReturnType);
+ kind,
+ name,
+ Element.makeFlags(
+ isPrivate: element.isPrivate,
+ isDeprecated: element.hasDeprecated,
+ isAbstract: _isAbstract(element),
+ isConst: _isConst(element),
+ isFinal: _isFinal(element),
+ isStatic: _isStatic(element),
+ ),
+ location: newLocation_fromElement(element),
+ typeParameters: elementTypeParameters,
+ aliasedType: aliasedType,
+ parameters: elementParameters,
+ returnType: elementReturnType,
+ );
}
/// Return a protocol [ElementKind] corresponding to the given
@@ -229,7 +233,15 @@
/// Sort required named parameters before optional ones.
int _preferRequiredParams(
engine.ParameterElement e1, engine.ParameterElement e2) {
- var rank1 = (e1.isRequiredNamed || e1.hasRequired) ? 0 : !e1.isNamed ? -1 : 1;
- var rank2 = (e2.isRequiredNamed || e2.hasRequired) ? 0 : !e2.isNamed ? -1 : 1;
+ var rank1 = (e1.isRequiredNamed || e1.hasRequired)
+ ? 0
+ : !e1.isNamed
+ ? -1
+ : 1;
+ var rank2 = (e2.isRequiredNamed || e2.hasRequired)
+ ? 0
+ : !e2.isNamed
+ ? -1
+ : 1;
return rank1 - rank2;
}
diff --git a/pkg/analysis_server/lib/src/protocol_server.dart b/pkg/analysis_server/lib/src/protocol_server.dart
index 61b522c..598e99d 100644
--- a/pkg/analysis_server/lib/src/protocol_server.dart
+++ b/pkg/analysis_server/lib/src/protocol_server.dart
@@ -46,6 +46,14 @@
change.addEdit(file, isNewFile ? -1 : 0, edit);
}
+String getAliasedTypeString(engine.Element element) {
+ if (element is engine.TypeAliasElement) {
+ var aliasedType = element.aliasedType;
+ return aliasedType.getDisplayString(withNullability: false);
+ }
+ return null;
+}
+
String getReturnTypeString(engine.Element element) {
if (element is engine.ExecutableElement) {
if (element.kind == engine.ElementKind.SETTER) {
@@ -63,12 +71,9 @@
if (aliasedType is FunctionType) {
var returnType = aliasedType.returnType;
return returnType.getDisplayString(withNullability: false);
- } else {
- return aliasedType.getDisplayString(withNullability: false);
}
- } else {
- return null;
}
+ return null;
}
/// Translates engine errors through the ErrorProcessor.
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart b/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
index 943669e..cb79f01 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
@@ -649,7 +649,7 @@
ProbabilityRange(lower: 0.017, upper: 0.070),
ElementKind.CLASS: ProbabilityRange(lower: 0.354, upper: 1.000),
},
- 'GenericTypeAlias_functionType': {
+ 'GenericTypeAlias_type': {
ElementKind.FUNCTION_TYPE_ALIAS:
ProbabilityRange(lower: 0.000, upper: 0.020),
ElementKind.PREFIX: ProbabilityRange(lower: 0.020, upper: 0.040),
@@ -1362,7 +1362,7 @@
'FunctionDeclaration_returnType': {
'void': ProbabilityRange(lower: 0.070, upper: 0.354),
},
- 'GenericTypeAlias_functionType': {
+ 'GenericTypeAlias_type': {
'Function': ProbabilityRange(lower: 0.090, upper: 0.140),
'void': ProbabilityRange(lower: 0.480, upper: 1.000),
},
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart
index abe003d..5c33b59 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart
@@ -27,6 +27,10 @@
var targetId = request.dotTarget;
if (targetId is Identifier && !request.target.isCascade) {
var element = targetId.staticElement;
+ if (element is TypeAliasElement) {
+ var aliasedType = (element as TypeAliasElement).aliasedType;
+ element = aliasedType.element;
+ }
if (element is ClassElement) {
for (var accessor in element.accessors) {
if (accessor.isStatic &&
diff --git a/pkg/analysis_server/test/integration/support/protocol_matchers.dart b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
index 354583b..c323422 100644
--- a/pkg/analysis_server/test/integration/support/protocol_matchers.dart
+++ b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
@@ -379,6 +379,7 @@
/// "parameters": optional String
/// "returnType": optional String
/// "typeParameters": optional String
+/// "aliasedType": optional String
/// }
final Matcher isElement = LazyMatcher(() => MatchesJsonObject('Element', {
'kind': isElementKind,
@@ -388,7 +389,8 @@
'location': isLocation,
'parameters': isString,
'returnType': isString,
- 'typeParameters': isString
+ 'typeParameters': isString,
+ 'aliasedType': isString
}));
/// ElementDeclaration
diff --git a/pkg/analysis_server/test/plugin/protocol_dart_test.dart b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
index ccc74d0..91ab49f 100644
--- a/pkg/analysis_server/test/plugin/protocol_dart_test.dart
+++ b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
@@ -381,8 +381,9 @@
expect(location.startLine, 1);
expect(location.startColumn, 9);
}
+ expect(element.aliasedType, 'Map<int, T>');
expect(element.parameters, isNull);
- expect(element.returnType, 'Map<int, T>');
+ expect(element.returnType, isNull);
expect(element.flags, 0);
}
diff --git a/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart
index ae98d85..ea96470 100644
--- a/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/combinator_contributor_test.dart
@@ -107,8 +107,10 @@
assertSuggestFunction('F1', 'PB',
kind: CompletionSuggestionKind.IDENTIFIER);
assertSuggestClass('Clz', kind: CompletionSuggestionKind.IDENTIFIER);
- assertSuggestTypeAlias('F2', null,
- kind: CompletionSuggestionKind.IDENTIFIER);
+ assertSuggestTypeAlias('F2',
+ kind: CompletionSuggestionKind.IDENTIFIER,
+ aliasedType: 'dynamic Function(int)',
+ returnType: 'dynamic');
assertNotSuggested('C');
assertNotSuggested('D');
assertNotSuggested('X');
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
index 781fb5e..bd86522 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
@@ -501,14 +501,17 @@
}
CompletionSuggestion assertSuggestTypeAlias(
- String name,
- String returnType, {
+ String name, {
+ String aliasedType,
+ String returnType,
bool isDeprecated = false,
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
}) {
var cs = assertSuggest(name, csKind: kind, isDeprecated: isDeprecated);
if (returnType != null) {
expect(cs.returnType, returnType);
+ } else if (aliasedType != null) {
+ // Just to don't fall into the next 'if'.
} else if (isNullExpectedReturnTypeConsideredDynamic) {
expect(cs.returnType, 'dynamic');
} else {
@@ -524,7 +527,8 @@
// expect(param, isNotNull);
// expect(param[0], equals('('));
// expect(param[param.length - 1], equals(')'));
- expect(element.returnType, equals(returnType ?? 'dynamic'));
+ expect(element.aliasedType, aliasedType);
+ expect(element.returnType, returnType);
// TODO (danrubel) Determine why param info is missing
// assertHasParameterInfo(cs);
return cs;
diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
index f85b873..ecb0f00 100644
--- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
@@ -2400,7 +2400,8 @@
assertSuggestClass('Object');
assertNotSuggested('T1');
assertNotSuggested('F1');
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -2430,7 +2431,8 @@
assertSuggestClass('Object');
assertNotSuggested('T1');
assertNotSuggested('F1');
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -2461,7 +2463,8 @@
assertSuggestClass('Object');
assertNotSuggested('T1');
assertNotSuggested('F1');
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -2498,7 +2501,8 @@
}
''');
await computeSuggestions();
- assertSuggestTypeAlias('F', 'void');
+ assertSuggestTypeAlias('F',
+ aliasedType: 'void Function()', returnType: 'void');
}
Future<void> test_functionTypeAlias_old() async {
@@ -2513,7 +2517,8 @@
}
''');
await computeSuggestions();
- assertSuggestTypeAlias('F', 'void');
+ assertSuggestTypeAlias('F',
+ aliasedType: 'void Function()', returnType: 'void');
}
Future<void> test_IfStatement() async {
@@ -2914,7 +2919,8 @@
// in which case suggestions will have null (unresolved) returnType
assertSuggestTopLevelVar('T1', null);
assertSuggestFunction('F1', null);
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -3178,7 +3184,8 @@
// to be resolved.
assertSuggestTopLevelVar('T1', /* null */ 'int');
assertSuggestFunction('F1', /* null */ 'dynamic');
- assertSuggestTypeAlias('D1', /* null */ 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -3477,7 +3484,8 @@
assertSuggestClass('Object');
assertNotSuggested('T1');
assertNotSuggested('F1');
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -3506,7 +3514,8 @@
assertSuggestClass('Object');
assertNotSuggested('T1');
assertNotSuggested('F1');
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -3535,7 +3544,8 @@
assertSuggestClass('Object');
assertNotSuggested('T1');
assertNotSuggested('F1');
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -3566,7 +3576,8 @@
assertSuggestClass('Object');
assertNotSuggested('T1');
assertNotSuggested('F1');
- assertSuggestTypeAlias('D1', 'dynamic');
+ assertSuggestTypeAlias('D1',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
@@ -4611,7 +4622,8 @@
expect(replacementLength, 0);
assertSuggestClass('Object');
assertSuggestClass('C1');
- assertSuggestTypeAlias('T1', 'String');
+ assertSuggestTypeAlias('T1',
+ aliasedType: 'String Function(int)', returnType: 'String');
assertNotSuggested('C2');
assertNotSuggested('T2');
assertNotSuggested('F1');
diff --git a/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
index f73cdd7..023cef5 100644
--- a/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
@@ -238,9 +238,11 @@
expect(replacementLength, 0);
assertSuggestClass('X');
assertSuggestClass('Y');
- assertSuggestTypeAlias('TypeAliasLegacy', 'void');
- assertSuggestTypeAlias('TypeAliasFunctionType', 'void');
- assertSuggestTypeAlias('TypeAliasInterfaceType', 'List<int>');
+ assertSuggestTypeAlias('TypeAliasLegacy',
+ aliasedType: 'void Function()', returnType: 'void');
+ assertSuggestTypeAlias('TypeAliasFunctionType',
+ aliasedType: 'void Function()', returnType: 'void');
+ assertSuggestTypeAlias('TypeAliasInterfaceType', aliasedType: 'List<int>');
assertNotSuggested('T1');
assertNotSuggested('T2');
assertNotSuggested('Object');
diff --git a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
index ebf0fdf..6417557 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
@@ -229,9 +229,11 @@
}
assertSuggestFunction('af', 'int');
assertSuggestTopLevelVar('m', null);
- assertSuggestTypeAlias('t1', null);
- assertSuggestTypeAlias('t2', 'void');
- assertSuggestTypeAlias('t3', 'List<int>');
+ assertSuggestTypeAlias('t1',
+ aliasedType: 'dynamic Function(int)', returnType: 'dynamic');
+ assertSuggestTypeAlias('t2',
+ aliasedType: 'void Function(int)', returnType: 'void');
+ assertSuggestTypeAlias('t3', aliasedType: 'List<int>');
assertNotSuggested('a1');
assertNotSuggested('a2');
// Suggested by LocalConstructorContributor
@@ -274,7 +276,8 @@
}
assertSuggestFunction('bf', 'int');
assertSuggestTopLevelVar('n', null);
- assertSuggestTypeAlias('t1', null);
+ assertSuggestTypeAlias('t1',
+ aliasedType: 'dynamic Function(int)', returnType: 'dynamic');
assertNotSuggested('b1');
assertNotSuggested('b2');
// Suggested by ConstructorContributor
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index 5475a78..814f7c8 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -2588,7 +2588,8 @@
assertSuggestClass('C');
assertSuggestMethod('foo', 'C', null);
assertSuggestMethod('bar', 'C', 'void');
- assertSuggestTypeAlias('F2', 'int');
+ assertSuggestTypeAlias('F2',
+ aliasedType: 'int Function(int)', returnType: 'int');
assertSuggestClass('Clz');
assertSuggestClass('C');
assertNotSuggested('x');
@@ -3242,7 +3243,8 @@
assertNotSuggested('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertNotSuggested('name');
}
@@ -3272,7 +3274,8 @@
assertNotSuggested('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertNotSuggested('name');
}
@@ -3303,7 +3306,8 @@
assertNotSuggested('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertNotSuggested('name');
}
@@ -3870,7 +3874,8 @@
assertNotSuggested('C1');
assertSuggestTopLevelVar('T2', 'int');
assertSuggestFunction('F2', null);
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertSuggestLocalVariable('name', 'String');
}
@@ -4218,7 +4223,8 @@
assertNotSuggested('C1');
assertSuggestTopLevelVar('T2', 'int');
assertSuggestFunction('F2', null);
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
}
@@ -4767,7 +4773,8 @@
assertNotSuggested('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertNotSuggested('name');
}
@@ -4796,7 +4803,8 @@
assertNotSuggested('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertNotSuggested('name');
}
@@ -4825,7 +4833,8 @@
assertNotSuggested('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertNotSuggested('name');
}
@@ -4856,7 +4865,8 @@
assertNotSuggested('C1');
assertNotSuggested('T2');
assertNotSuggested('F2');
- assertSuggestTypeAlias('D2', 'dynamic');
+ assertSuggestTypeAlias('D2',
+ aliasedType: 'dynamic Function()', returnType: 'dynamic');
assertSuggestClass('C2');
assertNotSuggested('name');
}
@@ -6035,7 +6045,8 @@
}
''');
await computeSuggestions();
- assertSuggestTypeAlias('F', 'void');
+ assertSuggestTypeAlias('F',
+ aliasedType: 'void Function()', returnType: 'void');
}
Future<void> test_typeAlias_interfaceType() async {
@@ -6046,7 +6057,7 @@
}
''');
await computeSuggestions();
- assertSuggestTypeAlias('F', 'List<int>');
+ assertSuggestTypeAlias('F', aliasedType: 'List<int>');
}
Future<void> test_typeAlias_legacy() async {
@@ -6057,7 +6068,8 @@
}
''');
await computeSuggestions();
- assertSuggestTypeAlias('F', 'void');
+ assertSuggestTypeAlias('F',
+ aliasedType: 'void Function()', returnType: 'void');
}
Future<void> test_TypeArgumentList() async {
@@ -6081,7 +6093,8 @@
assertNotSuggested('C1');
assertNotSuggested('T1');
assertSuggestClass('C2');
- assertSuggestTypeAlias('T2', 'int');
+ assertSuggestTypeAlias('T2',
+ aliasedType: 'int Function(int)', returnType: 'int');
assertNotSuggested('F1');
assertNotSuggested('F2');
}
diff --git a/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart
index 8698dd5..7253f49 100644
--- a/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart
@@ -360,4 +360,72 @@
assertNotSuggested('Object');
assertNotSuggested('==');
}
+
+ Future<void> test_simpleIdentifier_typeAlias_interfaceType_class() async {
+ addSource('/home/test/lib/a.dart', '''
+class A {
+ static int _privateField = 0;
+ static int get _privateGetter => 0;
+ static void _privateMethod() {}
+ static set _privateSetter(int _) {}
+ A._privateConstructor();
+
+ static int publicField = 0;
+ static int get publicGetter => 0;
+ static void publicMethod() {}
+ static set publicSetter(int _) {}
+ A.publicConstructor();
+}
+''');
+ addTestSource('''
+import 'a.dart';
+
+typedef B = A;
+
+void f() {
+ B.^;
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('_privateField');
+ assertNotSuggested('_privateGetter');
+ assertNotSuggested('_privateMethod');
+ assertNotSuggested('_privateSetter');
+ assertNotSuggested('A._privateConstructor');
+
+ assertSuggestField('publicField', 'int');
+ assertSuggestGetter('publicGetter', 'int');
+ assertSuggestMethod('publicMethod', 'A', 'void');
+ assertSuggestSetter('publicSetter');
+ assertSuggestConstructor(
+ 'publicConstructor',
+ elementName: 'publicConstructor',
+ );
+ }
+
+ Future<void> test_simpleIdentifier_typeAlias_interfaceType_enum() async {
+ addSource('/home/test/lib/a.dart', '''
+enum E {
+ aaa,
+ _bbb,
+ ccc
+}
+''');
+ addTestSource('''
+import 'a.dart';
+
+typedef A = E;
+
+void f() {
+ A.^;
+}
+''');
+ await computeSuggestions();
+ assertNotSuggested('E');
+ assertSuggestEnumConst('aaa');
+ assertNotSuggested('_bbb');
+ assertSuggestEnumConst('ccc');
+ assertNotSuggested('index');
+ assertSuggestField('values', 'List<E>');
+ }
}
diff --git a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
index 21230de..601c1de 100644
--- a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
+++ b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
@@ -707,7 +707,7 @@
@override
void visitGenericTypeAlias(GenericTypeAlias node) {
- _recordDataForNode('GenericTypeAlias_functionType', node.functionType,
+ _recordDataForNode('GenericTypeAlias_type', node.functionType,
allowedKeywords: [Keyword.FUNCTION]);
super.visitGenericTypeAlias(node);
}
diff --git a/pkg/analysis_server/tool/spec/generated/java/types/Element.java b/pkg/analysis_server/tool/spec/generated/java/types/Element.java
index 80f51fb..690f101 100644
--- a/pkg/analysis_server/tool/spec/generated/java/types/Element.java
+++ b/pkg/analysis_server/tool/spec/generated/java/types/Element.java
@@ -95,9 +95,15 @@
private final String typeParameters;
/**
+ * If the element is a type alias, this field is the aliased type. Otherwise this field will not be
+ * defined.
+ */
+ private final String aliasedType;
+
+ /**
* Constructor for {@link Element}.
*/
- public Element(String kind, String name, Location location, int flags, String parameters, String returnType, String typeParameters) {
+ public Element(String kind, String name, Location location, int flags, String parameters, String returnType, String typeParameters, String aliasedType) {
this.kind = kind;
this.name = name;
this.location = location;
@@ -105,6 +111,7 @@
this.parameters = parameters;
this.returnType = returnType;
this.typeParameters = typeParameters;
+ this.aliasedType = aliasedType;
}
@Override
@@ -118,7 +125,8 @@
other.flags == flags &&
ObjectUtilities.equals(other.parameters, parameters) &&
ObjectUtilities.equals(other.returnType, returnType) &&
- ObjectUtilities.equals(other.typeParameters, typeParameters);
+ ObjectUtilities.equals(other.typeParameters, typeParameters) &&
+ ObjectUtilities.equals(other.aliasedType, aliasedType);
}
return false;
}
@@ -131,7 +139,8 @@
String parameters = jsonObject.get("parameters") == null ? null : jsonObject.get("parameters").getAsString();
String returnType = jsonObject.get("returnType") == null ? null : jsonObject.get("returnType").getAsString();
String typeParameters = jsonObject.get("typeParameters") == null ? null : jsonObject.get("typeParameters").getAsString();
- return new Element(kind, name, location, flags, parameters, returnType, typeParameters);
+ String aliasedType = jsonObject.get("aliasedType") == null ? null : jsonObject.get("aliasedType").getAsString();
+ return new Element(kind, name, location, flags, parameters, returnType, typeParameters, aliasedType);
}
public static List<Element> fromJsonArray(JsonArray jsonArray) {
@@ -147,6 +156,14 @@
}
/**
+ * If the element is a type alias, this field is the aliased type. Otherwise this field will not be
+ * defined.
+ */
+ public String getAliasedType() {
+ return aliasedType;
+ }
+
+ /**
* A bit-map containing the following flags:
*
* - 0x01 - set if the element is explicitly or implicitly abstract
@@ -217,6 +234,7 @@
builder.append(parameters);
builder.append(returnType);
builder.append(typeParameters);
+ builder.append(aliasedType);
return builder.toHashCode();
}
@@ -261,6 +279,9 @@
if (typeParameters != null) {
jsonObject.addProperty("typeParameters", typeParameters);
}
+ if (aliasedType != null) {
+ jsonObject.addProperty("aliasedType", aliasedType);
+ }
return jsonObject;
}
@@ -281,7 +302,9 @@
builder.append("returnType=");
builder.append(returnType + ", ");
builder.append("typeParameters=");
- builder.append(typeParameters);
+ builder.append(typeParameters + ", ");
+ builder.append("aliasedType=");
+ builder.append(aliasedType);
builder.append("]");
return builder.toString();
}
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart
index cb6ab86..a2a48cd 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_common.dart
@@ -1435,6 +1435,7 @@
/// "parameters": optional String
/// "returnType": optional String
/// "typeParameters": optional String
+/// "aliasedType": optional String
/// }
///
/// Clients may not extend, implement or mix-in this class.
@@ -1477,6 +1478,8 @@
String _typeParameters;
+ String _aliasedType;
+
/// The kind of the element.
ElementKind get kind => _kind;
@@ -1566,11 +1569,22 @@
_typeParameters = value;
}
+ /// If the element is a type alias, this field is the aliased type. Otherwise
+ /// this field will not be defined.
+ String get aliasedType => _aliasedType;
+
+ /// If the element is a type alias, this field is the aliased type. Otherwise
+ /// this field will not be defined.
+ set aliasedType(String value) {
+ _aliasedType = value;
+ }
+
Element(ElementKind kind, String name, int flags,
{Location location,
String parameters,
String returnType,
- String typeParameters}) {
+ String typeParameters,
+ String aliasedType}) {
this.kind = kind;
this.name = name;
this.location = location;
@@ -1578,6 +1592,7 @@
this.parameters = parameters;
this.returnType = returnType;
this.typeParameters = typeParameters;
+ this.aliasedType = aliasedType;
}
factory Element.fromJson(
@@ -1623,11 +1638,17 @@
typeParameters = jsonDecoder.decodeString(
jsonPath + '.typeParameters', json['typeParameters']);
}
+ String aliasedType;
+ if (json.containsKey('aliasedType')) {
+ aliasedType = jsonDecoder.decodeString(
+ jsonPath + '.aliasedType', json['aliasedType']);
+ }
return Element(kind, name, flags,
location: location,
parameters: parameters,
returnType: returnType,
- typeParameters: typeParameters);
+ typeParameters: typeParameters,
+ aliasedType: aliasedType);
} else {
throw jsonDecoder.mismatch(jsonPath, 'Element', json);
}
@@ -1658,6 +1679,9 @@
if (typeParameters != null) {
result['typeParameters'] = typeParameters;
}
+ if (aliasedType != null) {
+ result['aliasedType'] = aliasedType;
+ }
return result;
}
@@ -1673,7 +1697,8 @@
flags == other.flags &&
parameters == other.parameters &&
returnType == other.returnType &&
- typeParameters == other.typeParameters;
+ typeParameters == other.typeParameters &&
+ aliasedType == other.aliasedType;
}
return false;
}
@@ -1688,6 +1713,7 @@
hash = JenkinsSmiHash.combine(hash, parameters.hashCode);
hash = JenkinsSmiHash.combine(hash, returnType.hashCode);
hash = JenkinsSmiHash.combine(hash, typeParameters.hashCode);
+ hash = JenkinsSmiHash.combine(hash, aliasedType.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
diff --git a/pkg/analyzer_plugin/doc/api.html b/pkg/analyzer_plugin/doc/api.html
index 664cdce..fa5c8e0 100644
--- a/pkg/analyzer_plugin/doc/api.html
+++ b/pkg/analyzer_plugin/doc/api.html
@@ -1289,6 +1289,12 @@
The type parameter list for the element. If the element doesn't have
type parameters, this field will not be defined.
</p>
+ </dd><dt class="field"><b>aliasedType: String<span style="color:#999999"> (optional)</span></b></dt><dd>
+
+ <p>
+ If the element is a type alias, this field is the aliased type.
+ Otherwise this field will not be defined.
+ </p>
</dd></dl></dd><dt class="typeDefinition"><a name="type_ElementKind">ElementKind: String</a></dt><dd>
<p>
An enumeration of the kinds of elements.
diff --git a/pkg/analyzer_plugin/lib/protocol/protocol_common.dart b/pkg/analyzer_plugin/lib/protocol/protocol_common.dart
index 5bdb9aa..163a7416 100644
--- a/pkg/analyzer_plugin/lib/protocol/protocol_common.dart
+++ b/pkg/analyzer_plugin/lib/protocol/protocol_common.dart
@@ -1435,6 +1435,7 @@
/// "parameters": optional String
/// "returnType": optional String
/// "typeParameters": optional String
+/// "aliasedType": optional String
/// }
///
/// Clients may not extend, implement or mix-in this class.
@@ -1477,6 +1478,8 @@
String _typeParameters;
+ String _aliasedType;
+
/// The kind of the element.
ElementKind get kind => _kind;
@@ -1566,11 +1569,22 @@
_typeParameters = value;
}
+ /// If the element is a type alias, this field is the aliased type. Otherwise
+ /// this field will not be defined.
+ String get aliasedType => _aliasedType;
+
+ /// If the element is a type alias, this field is the aliased type. Otherwise
+ /// this field will not be defined.
+ set aliasedType(String value) {
+ _aliasedType = value;
+ }
+
Element(ElementKind kind, String name, int flags,
{Location location,
String parameters,
String returnType,
- String typeParameters}) {
+ String typeParameters,
+ String aliasedType}) {
this.kind = kind;
this.name = name;
this.location = location;
@@ -1578,6 +1592,7 @@
this.parameters = parameters;
this.returnType = returnType;
this.typeParameters = typeParameters;
+ this.aliasedType = aliasedType;
}
factory Element.fromJson(
@@ -1623,11 +1638,17 @@
typeParameters = jsonDecoder.decodeString(
jsonPath + '.typeParameters', json['typeParameters']);
}
+ String aliasedType;
+ if (json.containsKey('aliasedType')) {
+ aliasedType = jsonDecoder.decodeString(
+ jsonPath + '.aliasedType', json['aliasedType']);
+ }
return Element(kind, name, flags,
location: location,
parameters: parameters,
returnType: returnType,
- typeParameters: typeParameters);
+ typeParameters: typeParameters,
+ aliasedType: aliasedType);
} else {
throw jsonDecoder.mismatch(jsonPath, 'Element', json);
}
@@ -1658,6 +1679,9 @@
if (typeParameters != null) {
result['typeParameters'] = typeParameters;
}
+ if (aliasedType != null) {
+ result['aliasedType'] = aliasedType;
+ }
return result;
}
@@ -1673,7 +1697,8 @@
flags == other.flags &&
parameters == other.parameters &&
returnType == other.returnType &&
- typeParameters == other.typeParameters;
+ typeParameters == other.typeParameters &&
+ aliasedType == other.aliasedType;
}
return false;
}
@@ -1688,6 +1713,7 @@
hash = JenkinsSmiHash.combine(hash, parameters.hashCode);
hash = JenkinsSmiHash.combine(hash, returnType.hashCode);
hash = JenkinsSmiHash.combine(hash, typeParameters.hashCode);
+ hash = JenkinsSmiHash.combine(hash, aliasedType.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
index 7a6aec5..ae49588 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
@@ -815,10 +815,7 @@
void visitGenericTypeAlias(GenericTypeAlias node) {
if (entity == node.type) {
optype.includeTypeNameSuggestions = true;
- }
- // TODO(scheglov) Use `node.type`, rename the location.
- if (entity == node.functionType) {
- optype.completionLocation = 'GenericTypeAlias_functionType';
+ optype.completionLocation = 'GenericTypeAlias_type';
}
}
diff --git a/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart b/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
index 92ab8c1..cc0e5b8 100644
--- a/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
+++ b/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
@@ -111,19 +111,22 @@
plugin.Element convertElement(analyzer.Element element) {
var kind = _convertElementToElementKind(element);
return plugin.Element(
- kind,
- element.displayName,
- plugin.Element.makeFlags(
- isPrivate: element.isPrivate,
- isDeprecated: element.hasDeprecated,
- isAbstract: _isAbstract(element),
- isConst: _isConst(element),
- isFinal: _isFinal(element),
- isStatic: _isStatic(element)),
- location: locationFromElement(element),
- typeParameters: _getTypeParametersString(element),
- parameters: _getParametersString(element),
- returnType: _getReturnTypeString(element));
+ kind,
+ element.displayName,
+ plugin.Element.makeFlags(
+ isPrivate: element.isPrivate,
+ isDeprecated: element.hasDeprecated,
+ isAbstract: _isAbstract(element),
+ isConst: _isConst(element),
+ isFinal: _isFinal(element),
+ isStatic: _isStatic(element),
+ ),
+ location: locationFromElement(element),
+ typeParameters: _getTypeParametersString(element),
+ aliasedType: _getAliasedTypeString(element),
+ parameters: _getParametersString(element),
+ returnType: _getReturnTypeString(element),
+ );
}
/// Convert the element [kind] from the 'analyzer' package to an element kind
@@ -224,6 +227,14 @@
return convertElementKind(element.kind);
}
+ String _getAliasedTypeString(analyzer.Element element) {
+ if (element is analyzer.TypeAliasElement) {
+ var aliasedType = element.aliasedType;
+ return aliasedType.getDisplayString(withNullability: false);
+ }
+ return null;
+ }
+
/// Return a textual representation of the parameters of the given [element],
/// or `null` if the element does not have any parameters.
String _getParametersString(analyzer.Element element) {
@@ -288,8 +299,6 @@
if (aliasedType is FunctionType) {
var returnType = aliasedType.returnType;
return returnType.getDisplayString(withNullability: false);
- } else {
- return aliasedType.getDisplayString(withNullability: false);
}
}
return null;
diff --git a/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart b/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
index e93caa5..7f36610 100644
--- a/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
+++ b/pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
@@ -221,6 +221,7 @@
/// "parameters": optional String
/// "returnType": optional String
/// "typeParameters": optional String
+/// "aliasedType": optional String
/// }
final Matcher isElement = LazyMatcher(() => MatchesJsonObject('Element', {
'kind': isElementKind,
@@ -230,7 +231,8 @@
'location': isLocation,
'parameters': isString,
'returnType': isString,
- 'typeParameters': isString
+ 'typeParameters': isString,
+ 'aliasedType': isString
}));
/// ElementKind
diff --git a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
index ed2c434..7acc4203 100644
--- a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
@@ -604,8 +604,9 @@
expect(location.startLine, 1);
expect(location.startColumn, 9);
}
+ expect(element.aliasedType, 'Map<int, T>');
expect(element.parameters, isNull);
- expect(element.returnType, 'Map<int, T>');
+ expect(element.returnType, isNull);
expect(element.flags, 0);
}
diff --git a/pkg/analyzer_plugin/tool/spec/common_types_spec.html b/pkg/analyzer_plugin/tool/spec/common_types_spec.html
index c2562cf..8608963 100644
--- a/pkg/analyzer_plugin/tool/spec/common_types_spec.html
+++ b/pkg/analyzer_plugin/tool/spec/common_types_spec.html
@@ -520,6 +520,13 @@
type parameters, this field will not be defined.
</p>
</field>
+ <field name="aliasedType" optional="true">
+ <ref>String</ref>
+ <p>
+ If the element is a type alias, this field is the aliased type.
+ Otherwise this field will not be defined.
+ </p>
+ </field>
</object>
</type>
<type name="ElementKind">
diff --git a/pkg/analyzer_utilities/lib/html.dart b/pkg/analyzer_utilities/lib/html.dart
index 06d19807..c5dc4bf 100644
--- a/pkg/analyzer_utilities/lib/html.dart
+++ b/pkg/analyzer_utilities/lib/html.dart
@@ -24,7 +24,7 @@
String innerText(dom.Element parent) {
var buffer = StringBuffer();
void recurse(dom.Element parent) {
- for (dom.Node child in parent.nodes) {
+ for (var child in parent.nodes) {
if (child is dom.Text) {
buffer.write(child.text);
} else if (child is dom.Element) {
diff --git a/runtime/bin/process.cc b/runtime/bin/process.cc
index 914a5f8..8b5c402 100644
--- a/runtime/bin/process.cc
+++ b/runtime/bin/process.cc
@@ -374,8 +374,11 @@
void Process::GetRSSInformation(int64_t* max_rss, int64_t* current_rss) {
ASSERT(max_rss != NULL);
ASSERT(current_rss != NULL);
- *max_rss = Process::MaxRSS();
+ // Max RSS should be queried after current RSS to produce
+ // consistent values as current RSS can grow beyond max RSS which
+ // was queried before.
*current_rss = Process::CurrentRSS();
+ *max_rss = Process::MaxRSS();
}
} // namespace bin
diff --git a/tools/VERSION b/tools/VERSION
index e795f63..6d46558 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 268
+PRERELEASE 269
PRERELEASE_PATCH 0
\ No newline at end of file