| Index: pkg/analyzer/test/generated/all_the_rest_test.dart
|
| diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| index 71fbe5b767032f8daedcbaa2e9a2fb774d10f3b7..324a6277b1928af03b6941ec42f88a58ead99a9a 100644
|
| --- a/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| +++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| @@ -734,6 +734,7 @@ class C {
|
| expect(type.isMixinApplication, isFalse);
|
| expect(type.isSynthetic, isFalse);
|
| expect(type.documentationComment, '/// aaa');
|
| + _assertHasDocRange(type, 50, 7);
|
| _assertHasCodeRange(type, 50, 31);
|
| }
|
|
|
| @@ -1000,6 +1001,7 @@ class C {
|
| expect(constructor, isNotNull);
|
| _assertHasCodeRange(constructor, 50, 31);
|
| expect(constructor.documentationComment, '/// aaa');
|
| + _assertHasDocRange(constructor, 50, 7);
|
| expect(constructor.isExternal, isFalse);
|
| expect(constructor.isFactory, isFalse);
|
| expect(constructor.name, "");
|
| @@ -1202,6 +1204,7 @@ class C {
|
| expect(enumElement, isNotNull);
|
| _assertHasCodeRange(enumElement, 50, 31);
|
| expect(enumElement.documentationComment, '/// aaa');
|
| + _assertHasDocRange(enumElement, 50, 7);
|
| expect(enumElement.name, enumName);
|
| }
|
|
|
| @@ -1227,6 +1230,7 @@ class C {
|
| expect(firstField, isNotNull);
|
| _assertHasCodeRange(firstField, 50, 61);
|
| expect(firstField.documentationComment, '/// aaa');
|
| + _assertHasDocRange(firstField, 50, 7);
|
| expect(firstField.name, firstFieldName);
|
| expect(firstField.initializer, isNull);
|
| expect(firstField.isConst, isFalse);
|
| @@ -1237,6 +1241,7 @@ class C {
|
| expect(secondField, isNotNull);
|
| _assertHasCodeRange(secondField, 50, 61);
|
| expect(secondField.documentationComment, '/// aaa');
|
| + _assertHasDocRange(secondField, 50, 7);
|
| expect(secondField.name, secondFieldName);
|
| expect(secondField.initializer, isNull);
|
| expect(secondField.isConst, isFalse);
|
| @@ -1357,6 +1362,7 @@ class C {
|
| expect(accessor, isNotNull);
|
| _assertHasCodeRange(accessor, 50, 31);
|
| expect(accessor.documentationComment, '/// aaa');
|
| + _assertHasDocRange(accessor, 50, 7);
|
| expect(accessor.name, functionName);
|
| expect(declaration.element, same(accessor));
|
| expect(declaration.functionExpression.element, same(accessor));
|
| @@ -1394,6 +1400,7 @@ class C {
|
| expect(function, isNotNull);
|
| _assertHasCodeRange(function, 50, 31);
|
| expect(function.documentationComment, '/// aaa');
|
| + _assertHasDocRange(function, 50, 7);
|
| expect(function.hasImplicitReturnType, isFalse);
|
| expect(function.name, functionName);
|
| expect(declaration.element, same(function));
|
| @@ -1425,6 +1432,7 @@ class C {
|
| expect(accessor, isNotNull);
|
| _assertHasCodeRange(accessor, 50, 31);
|
| expect(accessor.documentationComment, '/// aaa');
|
| + _assertHasDocRange(accessor, 50, 7);
|
| expect(accessor.hasImplicitReturnType, isTrue);
|
| expect(accessor.name, "$functionName=");
|
| expect(declaration.element, same(accessor));
|
| @@ -1505,6 +1513,7 @@ class C {
|
| expect(alias, isNotNull);
|
| _assertHasCodeRange(alias, 50, 31);
|
| expect(alias.documentationComment, '/// aaa');
|
| + _assertHasDocRange(alias, 50, 7);
|
| expect(alias.name, aliasName);
|
| expect(alias.parameters, hasLength(0));
|
| List<TypeParameterElement> typeParameters = alias.typeParameters;
|
| @@ -1705,6 +1714,7 @@ class A {
|
| expect(getter, isNotNull);
|
| _assertHasCodeRange(getter, 50, 31);
|
| expect(getter.documentationComment, '/// aaa');
|
| + _assertHasDocRange(getter, 50, 7);
|
| expect(getter.hasImplicitReturnType, isTrue);
|
| expect(getter.isAbstract, isFalse);
|
| expect(getter.isExternal, isFalse);
|
| @@ -1817,6 +1827,7 @@ class A {
|
| expect(method, isNotNull);
|
| _assertHasCodeRange(method, 50, 31);
|
| expect(method.documentationComment, '/// aaa');
|
| + _assertHasDocRange(method, 50, 7);
|
| expect(method.hasImplicitReturnType, isFalse);
|
| expect(method.name, methodName);
|
| expect(method.functions, hasLength(0));
|
| @@ -1893,6 +1904,7 @@ class A {
|
| expect(setter, isNotNull);
|
| _assertHasCodeRange(setter, 50, 31);
|
| expect(setter.documentationComment, '/// aaa');
|
| + _assertHasDocRange(setter, 50, 7);
|
| expect(setter.hasImplicitReturnType, isTrue);
|
| expect(setter.isAbstract, isFalse);
|
| expect(setter.isExternal, isFalse);
|
| @@ -2481,7 +2493,33 @@ class A {
|
| expect(variable.setter, isNotNull);
|
| }
|
|
|
| - void test_visitVariableDeclaration_top() {
|
| + void test_visitVariableDeclaration_top_const_hasInitializer() {
|
| + // const v = 42;
|
| + ElementHolder holder = new ElementHolder();
|
| + ElementBuilder builder = _makeBuilder(holder);
|
| + String variableName = "v";
|
| + VariableDeclaration variableDeclaration =
|
| + AstFactory.variableDeclaration2(variableName, AstFactory.integer(42));
|
| + AstFactory.variableDeclarationList2(Keyword.CONST, [variableDeclaration]);
|
| + variableDeclaration.accept(builder);
|
| +
|
| + List<TopLevelVariableElement> variables = holder.topLevelVariables;
|
| + expect(variables, hasLength(1));
|
| + TopLevelVariableElement variable = variables[0];
|
| + expect(variable, new isInstanceOf<ConstTopLevelVariableElementImpl>());
|
| + expect(variable.initializer, isNotNull);
|
| + expect(variable.initializer.type, isNotNull);
|
| + expect(variable.initializer.hasImplicitReturnType, isTrue);
|
| + expect(variable.name, variableName);
|
| + expect(variable.hasImplicitType, isTrue);
|
| + expect(variable.isConst, isTrue);
|
| + expect(variable.isFinal, isFalse);
|
| + expect(variable.isSynthetic, isFalse);
|
| + expect(variable.getter, isNotNull);
|
| + expect(variable.setter, isNull);
|
| + }
|
| +
|
| + void test_visitVariableDeclaration_top_docRange() {
|
| // final a, b;
|
| ElementHolder holder = new ElementHolder();
|
| ElementBuilder builder = _makeBuilder(holder);
|
| @@ -2503,36 +2541,12 @@ class A {
|
| TopLevelVariableElement variable1 = variables[0];
|
| expect(variable1, isNotNull);
|
| expect(variable1.documentationComment, '/// aaa');
|
| + _assertHasDocRange(variable1, 50, 7);
|
|
|
| TopLevelVariableElement variable2 = variables[1];
|
| expect(variable2, isNotNull);
|
| expect(variable2.documentationComment, '/// aaa');
|
| - }
|
| -
|
| - void test_visitVariableDeclaration_top_const_hasInitializer() {
|
| - // const v = 42;
|
| - ElementHolder holder = new ElementHolder();
|
| - ElementBuilder builder = _makeBuilder(holder);
|
| - String variableName = "v";
|
| - VariableDeclaration variableDeclaration =
|
| - AstFactory.variableDeclaration2(variableName, AstFactory.integer(42));
|
| - AstFactory.variableDeclarationList2(Keyword.CONST, [variableDeclaration]);
|
| - variableDeclaration.accept(builder);
|
| -
|
| - List<TopLevelVariableElement> variables = holder.topLevelVariables;
|
| - expect(variables, hasLength(1));
|
| - TopLevelVariableElement variable = variables[0];
|
| - expect(variable, new isInstanceOf<ConstTopLevelVariableElementImpl>());
|
| - expect(variable.initializer, isNotNull);
|
| - expect(variable.initializer.type, isNotNull);
|
| - expect(variable.initializer.hasImplicitReturnType, isTrue);
|
| - expect(variable.name, variableName);
|
| - expect(variable.hasImplicitType, isTrue);
|
| - expect(variable.isConst, isTrue);
|
| - expect(variable.isFinal, isFalse);
|
| - expect(variable.isSynthetic, isFalse);
|
| - expect(variable.getter, isNotNull);
|
| - expect(variable.setter, isNull);
|
| + _assertHasDocRange(variable2, 50, 7);
|
| }
|
|
|
| void test_visitVariableDeclaration_top_final() {
|
| @@ -2564,6 +2578,15 @@ class A {
|
| expect(elementImpl.codeLength, length);
|
| }
|
|
|
| + void _assertHasDocRange(
|
| + Element element, int expectedOffset, int expectedLength) {
|
| + // Cast to dynamic here to avoid a hint about @deprecated docRange.
|
| + SourceRange docRange = (element as dynamic).docRange;
|
| + expect(docRange, isNotNull);
|
| + expect(docRange.offset, expectedOffset);
|
| + expect(docRange.length, expectedLength);
|
| + }
|
| +
|
| void _assertVisibleRange(LocalElement element, int offset, int end) {
|
| SourceRange visibleRange = element.visibleRange;
|
| expect(visibleRange.offset, offset);
|
| @@ -3117,6 +3140,8 @@ class EnumMemberBuilderTest extends EngineTestCase {
|
| expect(constant.isStatic, isTrue);
|
| expect((constant as FieldElementImpl).evaluationResult, isNotNull);
|
| expect(constant.documentationComment, '/// aaa');
|
| + expect(constant.docRange.offset, 50);
|
| + expect(constant.docRange.length, 7);
|
| _assertGetter(constant);
|
| }
|
|
|
| @@ -4125,7 +4150,7 @@ void f() {
|
| _assertNthStatementDoesNotExit(source, 0);
|
| }
|
|
|
| - void test_whileStatement_breakWithLabel_afterExiting() {
|
| + void test_whileStatement_breakWithLabel_afterExting() {
|
| Source source = addSource(r'''
|
| void f() {
|
| x: while (true) {
|
|
|