Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 1376473007: Add the 'docRange' property and use it to compute documentation comment. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/ast_factory.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.all_the_rest_test; 5 library engine.all_the_rest_test;
6 6
7 import 'package:analyzer/file_system/physical_file_system.dart'; 7 import 'package:analyzer/file_system/physical_file_system.dart';
8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 5034 matching lines...) Expand 10 before | Expand all | Expand 10 after
5045 expect(type.isMixinApplication, isFalse); 5045 expect(type.isMixinApplication, isFalse);
5046 expect(type.isSynthetic, isFalse); 5046 expect(type.isSynthetic, isFalse);
5047 } 5047 }
5048 5048
5049 void test_visitClassDeclaration_minimal() { 5049 void test_visitClassDeclaration_minimal() {
5050 ElementHolder holder = new ElementHolder(); 5050 ElementHolder holder = new ElementHolder();
5051 ElementBuilder builder = new ElementBuilder(holder); 5051 ElementBuilder builder = new ElementBuilder(holder);
5052 String className = "C"; 5052 String className = "C";
5053 ClassDeclaration classDeclaration = 5053 ClassDeclaration classDeclaration =
5054 AstFactory.classDeclaration(null, className, null, null, null, null); 5054 AstFactory.classDeclaration(null, className, null, null, null, null);
5055 classDeclaration.documentationComment = AstFactory.documentationComment(
5056 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5055 classDeclaration.accept(builder); 5057 classDeclaration.accept(builder);
5056 List<ClassElement> types = holder.types; 5058 List<ClassElement> types = holder.types;
5057 expect(types, hasLength(1)); 5059 expect(types, hasLength(1));
5058 ClassElement type = types[0]; 5060 ClassElement type = types[0];
5059 expect(type, isNotNull); 5061 expect(type, isNotNull);
5060 expect(type.name, className); 5062 expect(type.name, className);
5061 List<TypeParameterElement> typeParameters = type.typeParameters; 5063 List<TypeParameterElement> typeParameters = type.typeParameters;
5062 expect(typeParameters, hasLength(0)); 5064 expect(typeParameters, hasLength(0));
5063 expect(type.isAbstract, isFalse); 5065 expect(type.isAbstract, isFalse);
5064 expect(type.isMixinApplication, isFalse); 5066 expect(type.isMixinApplication, isFalse);
5065 expect(type.isSynthetic, isFalse); 5067 expect(type.isSynthetic, isFalse);
5068 _assertHasDocRange(type, 50, 7);
5066 } 5069 }
5067 5070
5068 void test_visitClassDeclaration_parameterized() { 5071 void test_visitClassDeclaration_parameterized() {
5069 ElementHolder holder = new ElementHolder(); 5072 ElementHolder holder = new ElementHolder();
5070 ElementBuilder builder = new ElementBuilder(holder); 5073 ElementBuilder builder = new ElementBuilder(holder);
5071 String className = "C"; 5074 String className = "C";
5072 String firstVariableName = "E"; 5075 String firstVariableName = "E";
5073 String secondVariableName = "F"; 5076 String secondVariableName = "F";
5074 ClassDeclaration classDeclaration = AstFactory.classDeclaration( 5077 ClassDeclaration classDeclaration = AstFactory.classDeclaration(
5075 null, 5078 null,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 String className = "A"; 5292 String className = "A";
5290 ConstructorDeclaration constructorDeclaration = AstFactory 5293 ConstructorDeclaration constructorDeclaration = AstFactory
5291 .constructorDeclaration2( 5294 .constructorDeclaration2(
5292 null, 5295 null,
5293 null, 5296 null,
5294 AstFactory.identifier3(className), 5297 AstFactory.identifier3(className),
5295 null, 5298 null,
5296 AstFactory.formalParameterList(), 5299 AstFactory.formalParameterList(),
5297 null, 5300 null,
5298 AstFactory.blockFunctionBody2()); 5301 AstFactory.blockFunctionBody2());
5302 constructorDeclaration.documentationComment = AstFactory
5303 .documentationComment(
5304 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5299 constructorDeclaration.accept(builder); 5305 constructorDeclaration.accept(builder);
5306
5300 List<ConstructorElement> constructors = holder.constructors; 5307 List<ConstructorElement> constructors = holder.constructors;
5301 expect(constructors, hasLength(1)); 5308 expect(constructors, hasLength(1));
5302 ConstructorElement constructor = constructors[0]; 5309 ConstructorElement constructor = constructors[0];
5303 expect(constructor, isNotNull); 5310 expect(constructor, isNotNull);
5311 _assertHasDocRange(constructor, 50, 7);
5304 expect(constructor.isExternal, isFalse); 5312 expect(constructor.isExternal, isFalse);
5305 expect(constructor.isFactory, isFalse); 5313 expect(constructor.isFactory, isFalse);
5306 expect(constructor.name, ""); 5314 expect(constructor.name, "");
5307 expect(constructor.functions, hasLength(0)); 5315 expect(constructor.functions, hasLength(0));
5308 expect(constructor.labels, hasLength(0)); 5316 expect(constructor.labels, hasLength(0));
5309 expect(constructor.localVariables, hasLength(0)); 5317 expect(constructor.localVariables, hasLength(0));
5310 expect(constructor.parameters, hasLength(0)); 5318 expect(constructor.parameters, hasLength(0));
5311 } 5319 }
5312 5320
5313 void test_visitConstructorDeclaration_named() { 5321 void test_visitConstructorDeclaration_named() {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
5471 expect(parameter.isSynthetic, isFalse); 5479 expect(parameter.isSynthetic, isFalse);
5472 expect(parameter.name, parameterName); 5480 expect(parameter.name, parameterName);
5473 } 5481 }
5474 5482
5475 void test_visitEnumDeclaration() { 5483 void test_visitEnumDeclaration() {
5476 ElementHolder holder = new ElementHolder(); 5484 ElementHolder holder = new ElementHolder();
5477 ElementBuilder builder = new ElementBuilder(holder); 5485 ElementBuilder builder = new ElementBuilder(holder);
5478 String enumName = "E"; 5486 String enumName = "E";
5479 EnumDeclaration enumDeclaration = 5487 EnumDeclaration enumDeclaration =
5480 AstFactory.enumDeclaration2(enumName, ["ONE"]); 5488 AstFactory.enumDeclaration2(enumName, ["ONE"]);
5489 enumDeclaration.documentationComment = AstFactory.documentationComment(
5490 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5481 enumDeclaration.accept(builder); 5491 enumDeclaration.accept(builder);
5482 List<ClassElement> enums = holder.enums; 5492 List<ClassElement> enums = holder.enums;
5483 expect(enums, hasLength(1)); 5493 expect(enums, hasLength(1));
5484 ClassElement enumElement = enums[0]; 5494 ClassElement enumElement = enums[0];
5485 expect(enumElement, isNotNull); 5495 expect(enumElement, isNotNull);
5496 _assertHasDocRange(enumElement, 50, 7);
5486 expect(enumElement.name, enumName); 5497 expect(enumElement.name, enumName);
5487 } 5498 }
5488 5499
5489 void test_visitFieldDeclaration() { 5500 void test_visitFieldDeclaration() {
5490 ElementHolder holder = new ElementHolder(); 5501 ElementHolder holder = new ElementHolder();
5491 ElementBuilder builder = new ElementBuilder(holder); 5502 ElementBuilder builder = new ElementBuilder(holder);
5492 String firstFieldName = "x"; 5503 String firstFieldName = "x";
5493 String secondFieldName = "y"; 5504 String secondFieldName = "y";
5494 FieldDeclaration fieldDeclaration = 5505 FieldDeclaration fieldDeclaration =
5495 AstFactory.fieldDeclaration2(false, null, [ 5506 AstFactory.fieldDeclaration2(false, null, [
5496 AstFactory.variableDeclaration(firstFieldName), 5507 AstFactory.variableDeclaration(firstFieldName),
5497 AstFactory.variableDeclaration(secondFieldName) 5508 AstFactory.variableDeclaration(secondFieldName)
5498 ]); 5509 ]);
5510 fieldDeclaration.documentationComment = AstFactory.documentationComment(
5511 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5499 fieldDeclaration.accept(builder); 5512 fieldDeclaration.accept(builder);
5513
5500 List<FieldElement> fields = holder.fields; 5514 List<FieldElement> fields = holder.fields;
5501 expect(fields, hasLength(2)); 5515 expect(fields, hasLength(2));
5516
5502 FieldElement firstField = fields[0]; 5517 FieldElement firstField = fields[0];
5503 expect(firstField, isNotNull); 5518 expect(firstField, isNotNull);
5519 _assertHasDocRange(firstField, 50, 7);
5504 expect(firstField.name, firstFieldName); 5520 expect(firstField.name, firstFieldName);
5505 expect(firstField.initializer, isNull); 5521 expect(firstField.initializer, isNull);
5506 expect(firstField.isConst, isFalse); 5522 expect(firstField.isConst, isFalse);
5507 expect(firstField.isFinal, isFalse); 5523 expect(firstField.isFinal, isFalse);
5508 expect(firstField.isSynthetic, isFalse); 5524 expect(firstField.isSynthetic, isFalse);
5525
5509 FieldElement secondField = fields[1]; 5526 FieldElement secondField = fields[1];
5510 expect(secondField, isNotNull); 5527 expect(secondField, isNotNull);
5528 _assertHasDocRange(secondField, 50, 7);
5511 expect(secondField.name, secondFieldName); 5529 expect(secondField.name, secondFieldName);
5512 expect(secondField.initializer, isNull); 5530 expect(secondField.initializer, isNull);
5513 expect(secondField.isConst, isFalse); 5531 expect(secondField.isConst, isFalse);
5514 expect(secondField.isFinal, isFalse); 5532 expect(secondField.isFinal, isFalse);
5515 expect(secondField.isSynthetic, isFalse); 5533 expect(secondField.isSynthetic, isFalse);
5516 } 5534 }
5517 5535
5518 void test_visitFieldFormalParameter() { 5536 void test_visitFieldFormalParameter() {
5519 ElementHolder holder = new ElementHolder(); 5537 ElementHolder holder = new ElementHolder();
5520 ElementBuilder builder = new ElementBuilder(holder); 5538 ElementBuilder builder = new ElementBuilder(holder);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
5607 // get f() {} 5625 // get f() {}
5608 ElementHolder holder = new ElementHolder(); 5626 ElementHolder holder = new ElementHolder();
5609 ElementBuilder builder = new ElementBuilder(holder); 5627 ElementBuilder builder = new ElementBuilder(holder);
5610 String functionName = "f"; 5628 String functionName = "f";
5611 FunctionDeclaration declaration = AstFactory.functionDeclaration( 5629 FunctionDeclaration declaration = AstFactory.functionDeclaration(
5612 null, 5630 null,
5613 Keyword.GET, 5631 Keyword.GET,
5614 functionName, 5632 functionName,
5615 AstFactory.functionExpression2( 5633 AstFactory.functionExpression2(
5616 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 5634 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
5635 declaration.documentationComment = AstFactory.documentationComment(
5636 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5617 declaration.accept(builder); 5637 declaration.accept(builder);
5618 5638
5619 List<PropertyAccessorElement> accessors = holder.accessors; 5639 List<PropertyAccessorElement> accessors = holder.accessors;
5620 expect(accessors, hasLength(1)); 5640 expect(accessors, hasLength(1));
5621 PropertyAccessorElement accessor = accessors[0]; 5641 PropertyAccessorElement accessor = accessors[0];
5622 expect(accessor, isNotNull); 5642 expect(accessor, isNotNull);
5643 _assertHasDocRange(accessor, 50, 7);
5623 expect(accessor.name, functionName); 5644 expect(accessor.name, functionName);
5624 expect(declaration.element, same(accessor)); 5645 expect(declaration.element, same(accessor));
5625 expect(declaration.functionExpression.element, same(accessor)); 5646 expect(declaration.functionExpression.element, same(accessor));
5626 expect(accessor.hasImplicitReturnType, isTrue); 5647 expect(accessor.hasImplicitReturnType, isTrue);
5627 expect(accessor.isGetter, isTrue); 5648 expect(accessor.isGetter, isTrue);
5628 expect(accessor.isExternal, isFalse); 5649 expect(accessor.isExternal, isFalse);
5629 expect(accessor.isSetter, isFalse); 5650 expect(accessor.isSetter, isFalse);
5630 expect(accessor.isSynthetic, isFalse); 5651 expect(accessor.isSynthetic, isFalse);
5631 expect(accessor.typeParameters, hasLength(0)); 5652 expect(accessor.typeParameters, hasLength(0));
5632 PropertyInducingElement variable = accessor.variable; 5653 PropertyInducingElement variable = accessor.variable;
5633 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement, 5654 EngineTestCase.assertInstanceOf((obj) => obj is TopLevelVariableElement,
5634 TopLevelVariableElement, variable); 5655 TopLevelVariableElement, variable);
5635 expect(variable.isSynthetic, isTrue); 5656 expect(variable.isSynthetic, isTrue);
5636 } 5657 }
5637 5658
5638 void test_visitFunctionDeclaration_plain() { 5659 void test_visitFunctionDeclaration_plain() {
5639 // T f() {} 5660 // T f() {}
5640 ElementHolder holder = new ElementHolder(); 5661 ElementHolder holder = new ElementHolder();
5641 ElementBuilder builder = new ElementBuilder(holder); 5662 ElementBuilder builder = new ElementBuilder(holder);
5642 String functionName = "f"; 5663 String functionName = "f";
5643 FunctionDeclaration declaration = AstFactory.functionDeclaration( 5664 FunctionDeclaration declaration = AstFactory.functionDeclaration(
5644 AstFactory.typeName4('T'), 5665 AstFactory.typeName4('T'),
5645 null, 5666 null,
5646 functionName, 5667 functionName,
5647 AstFactory.functionExpression2( 5668 AstFactory.functionExpression2(
5648 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 5669 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
5670 declaration.documentationComment = AstFactory.documentationComment(
5671 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5649 declaration.accept(builder); 5672 declaration.accept(builder);
5650 5673
5651 List<FunctionElement> functions = holder.functions; 5674 List<FunctionElement> functions = holder.functions;
5652 expect(functions, hasLength(1)); 5675 expect(functions, hasLength(1));
5653 FunctionElement function = functions[0]; 5676 FunctionElement function = functions[0];
5654 expect(function, isNotNull); 5677 expect(function, isNotNull);
5678 _assertHasDocRange(function, 50, 7);
5655 expect(function.hasImplicitReturnType, isFalse); 5679 expect(function.hasImplicitReturnType, isFalse);
5656 expect(function.name, functionName); 5680 expect(function.name, functionName);
5657 expect(declaration.element, same(function)); 5681 expect(declaration.element, same(function));
5658 expect(declaration.functionExpression.element, same(function)); 5682 expect(declaration.functionExpression.element, same(function));
5659 expect(function.isExternal, isFalse); 5683 expect(function.isExternal, isFalse);
5660 expect(function.isSynthetic, isFalse); 5684 expect(function.isSynthetic, isFalse);
5661 expect(function.typeParameters, hasLength(0)); 5685 expect(function.typeParameters, hasLength(0));
5662 } 5686 }
5663 5687
5664 void test_visitFunctionDeclaration_setter() { 5688 void test_visitFunctionDeclaration_setter() {
5665 // set f() {} 5689 // set f() {}
5666 ElementHolder holder = new ElementHolder(); 5690 ElementHolder holder = new ElementHolder();
5667 ElementBuilder builder = new ElementBuilder(holder); 5691 ElementBuilder builder = new ElementBuilder(holder);
5668 String functionName = "f"; 5692 String functionName = "f";
5669 FunctionDeclaration declaration = AstFactory.functionDeclaration( 5693 FunctionDeclaration declaration = AstFactory.functionDeclaration(
5670 null, 5694 null,
5671 Keyword.SET, 5695 Keyword.SET,
5672 functionName, 5696 functionName,
5673 AstFactory.functionExpression2( 5697 AstFactory.functionExpression2(
5674 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 5698 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
5699 declaration.documentationComment = AstFactory.documentationComment(
5700 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5675 declaration.accept(builder); 5701 declaration.accept(builder);
5676 5702
5677 List<PropertyAccessorElement> accessors = holder.accessors; 5703 List<PropertyAccessorElement> accessors = holder.accessors;
5678 expect(accessors, hasLength(1)); 5704 expect(accessors, hasLength(1));
5679 PropertyAccessorElement accessor = accessors[0]; 5705 PropertyAccessorElement accessor = accessors[0];
5680 expect(accessor, isNotNull); 5706 expect(accessor, isNotNull);
5707 _assertHasDocRange(accessor, 50, 7);
5681 expect(accessor.hasImplicitReturnType, isFalse); 5708 expect(accessor.hasImplicitReturnType, isFalse);
5682 expect(accessor.name, "$functionName="); 5709 expect(accessor.name, "$functionName=");
5683 expect(declaration.element, same(accessor)); 5710 expect(declaration.element, same(accessor));
5684 expect(declaration.functionExpression.element, same(accessor)); 5711 expect(declaration.functionExpression.element, same(accessor));
5685 expect(accessor.isGetter, isFalse); 5712 expect(accessor.isGetter, isFalse);
5686 expect(accessor.isExternal, isFalse); 5713 expect(accessor.isExternal, isFalse);
5687 expect(accessor.isSetter, isTrue); 5714 expect(accessor.isSetter, isTrue);
5688 expect(accessor.isSynthetic, isFalse); 5715 expect(accessor.isSynthetic, isFalse);
5689 expect(accessor.typeParameters, hasLength(0)); 5716 expect(accessor.typeParameters, hasLength(0));
5690 PropertyInducingElement variable = accessor.variable; 5717 PropertyInducingElement variable = accessor.variable;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5740 expect(function.typeParameters, hasLength(0)); 5767 expect(function.typeParameters, hasLength(0));
5741 } 5768 }
5742 5769
5743 void test_visitFunctionTypeAlias() { 5770 void test_visitFunctionTypeAlias() {
5744 ElementHolder holder = new ElementHolder(); 5771 ElementHolder holder = new ElementHolder();
5745 ElementBuilder builder = new ElementBuilder(holder); 5772 ElementBuilder builder = new ElementBuilder(holder);
5746 String aliasName = "F"; 5773 String aliasName = "F";
5747 String parameterName = "E"; 5774 String parameterName = "E";
5748 FunctionTypeAlias aliasNode = AstFactory.typeAlias( 5775 FunctionTypeAlias aliasNode = AstFactory.typeAlias(
5749 null, aliasName, AstFactory.typeParameterList([parameterName]), null); 5776 null, aliasName, AstFactory.typeParameterList([parameterName]), null);
5777 aliasNode.documentationComment = AstFactory.documentationComment(
5778 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5750 aliasNode.accept(builder); 5779 aliasNode.accept(builder);
5780
5751 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 5781 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
5752 expect(aliases, hasLength(1)); 5782 expect(aliases, hasLength(1));
5753 FunctionTypeAliasElement alias = aliases[0]; 5783 FunctionTypeAliasElement alias = aliases[0];
5754 expect(alias, isNotNull); 5784 expect(alias, isNotNull);
5785 _assertHasDocRange(alias, 50, 7);
5755 expect(alias.name, aliasName); 5786 expect(alias.name, aliasName);
5756 expect(alias.parameters, hasLength(0)); 5787 expect(alias.parameters, hasLength(0));
5757 List<TypeParameterElement> typeParameters = alias.typeParameters; 5788 List<TypeParameterElement> typeParameters = alias.typeParameters;
5758 expect(typeParameters, hasLength(1)); 5789 expect(typeParameters, hasLength(1));
5759 TypeParameterElement typeParameter = typeParameters[0]; 5790 TypeParameterElement typeParameter = typeParameters[0];
5760 expect(typeParameter, isNotNull); 5791 expect(typeParameter, isNotNull);
5761 expect(typeParameter.name, parameterName); 5792 expect(typeParameter.name, parameterName);
5762 } 5793 }
5763 5794
5764 void test_visitFunctionTypedFormalParameter() { 5795 void test_visitFunctionTypedFormalParameter() {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
5896 ElementBuilder builder = new ElementBuilder(holder); 5927 ElementBuilder builder = new ElementBuilder(holder);
5897 String methodName = "m"; 5928 String methodName = "m";
5898 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 5929 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
5899 null, 5930 null,
5900 null, 5931 null,
5901 Keyword.GET, 5932 Keyword.GET,
5902 null, 5933 null,
5903 AstFactory.identifier3(methodName), 5934 AstFactory.identifier3(methodName),
5904 AstFactory.formalParameterList(), 5935 AstFactory.formalParameterList(),
5905 AstFactory.blockFunctionBody2()); 5936 AstFactory.blockFunctionBody2());
5937 methodDeclaration.documentationComment = AstFactory.documentationComment(
5938 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
5906 methodDeclaration.accept(builder); 5939 methodDeclaration.accept(builder);
5907 5940
5908 List<FieldElement> fields = holder.fields; 5941 List<FieldElement> fields = holder.fields;
5909 expect(fields, hasLength(1)); 5942 expect(fields, hasLength(1));
5910 FieldElement field = fields[0]; 5943 FieldElement field = fields[0];
5911 expect(field, isNotNull); 5944 expect(field, isNotNull);
5912 expect(field.name, methodName); 5945 expect(field.name, methodName);
5913 expect(field.isSynthetic, isTrue); 5946 expect(field.isSynthetic, isTrue);
5914 expect(field.setter, isNull); 5947 expect(field.setter, isNull);
5915 PropertyAccessorElement getter = field.getter; 5948 PropertyAccessorElement getter = field.getter;
5916 expect(getter, isNotNull); 5949 expect(getter, isNotNull);
5950 _assertHasDocRange(getter, 50, 7);
5917 expect(getter.hasImplicitReturnType, isTrue); 5951 expect(getter.hasImplicitReturnType, isTrue);
5918 expect(getter.isAbstract, isFalse); 5952 expect(getter.isAbstract, isFalse);
5919 expect(getter.isExternal, isFalse); 5953 expect(getter.isExternal, isFalse);
5920 expect(getter.isGetter, isTrue); 5954 expect(getter.isGetter, isTrue);
5921 expect(getter.isSynthetic, isFalse); 5955 expect(getter.isSynthetic, isFalse);
5922 expect(getter.name, methodName); 5956 expect(getter.name, methodName);
5923 expect(getter.variable, field); 5957 expect(getter.variable, field);
5924 expect(getter.functions, hasLength(0)); 5958 expect(getter.functions, hasLength(0));
5925 expect(getter.labels, hasLength(0)); 5959 expect(getter.labels, hasLength(0));
5926 expect(getter.localVariables, hasLength(0)); 5960 expect(getter.localVariables, hasLength(0));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
6008 ElementBuilder builder = new ElementBuilder(holder); 6042 ElementBuilder builder = new ElementBuilder(holder);
6009 String methodName = "m"; 6043 String methodName = "m";
6010 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 6044 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
6011 null, 6045 null,
6012 AstFactory.typeName4('T'), 6046 AstFactory.typeName4('T'),
6013 null, 6047 null,
6014 null, 6048 null,
6015 AstFactory.identifier3(methodName), 6049 AstFactory.identifier3(methodName),
6016 AstFactory.formalParameterList(), 6050 AstFactory.formalParameterList(),
6017 AstFactory.blockFunctionBody2()); 6051 AstFactory.blockFunctionBody2());
6052 methodDeclaration.documentationComment = AstFactory.documentationComment(
6053 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
6018 methodDeclaration.accept(builder); 6054 methodDeclaration.accept(builder);
6055
6019 List<MethodElement> methods = holder.methods; 6056 List<MethodElement> methods = holder.methods;
6020 expect(methods, hasLength(1)); 6057 expect(methods, hasLength(1));
6021 MethodElement method = methods[0]; 6058 MethodElement method = methods[0];
6022 expect(method, isNotNull); 6059 expect(method, isNotNull);
6060 _assertHasDocRange(method, 50, 7);
6023 expect(method.hasImplicitReturnType, isFalse); 6061 expect(method.hasImplicitReturnType, isFalse);
6024 expect(method.name, methodName); 6062 expect(method.name, methodName);
6025 expect(method.functions, hasLength(0)); 6063 expect(method.functions, hasLength(0));
6026 expect(method.labels, hasLength(0)); 6064 expect(method.labels, hasLength(0));
6027 expect(method.localVariables, hasLength(0)); 6065 expect(method.localVariables, hasLength(0));
6028 expect(method.parameters, hasLength(0)); 6066 expect(method.parameters, hasLength(0));
6029 expect(method.typeParameters, hasLength(0)); 6067 expect(method.typeParameters, hasLength(0));
6030 expect(method.isAbstract, isFalse); 6068 expect(method.isAbstract, isFalse);
6031 expect(method.isExternal, isFalse); 6069 expect(method.isExternal, isFalse);
6032 expect(method.isStatic, isFalse); 6070 expect(method.isStatic, isFalse);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6072 ElementBuilder builder = new ElementBuilder(holder); 6110 ElementBuilder builder = new ElementBuilder(holder);
6073 String methodName = "m"; 6111 String methodName = "m";
6074 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2( 6112 MethodDeclaration methodDeclaration = AstFactory.methodDeclaration2(
6075 null, 6113 null,
6076 null, 6114 null,
6077 Keyword.SET, 6115 Keyword.SET,
6078 null, 6116 null,
6079 AstFactory.identifier3(methodName), 6117 AstFactory.identifier3(methodName),
6080 AstFactory.formalParameterList(), 6118 AstFactory.formalParameterList(),
6081 AstFactory.blockFunctionBody2()); 6119 AstFactory.blockFunctionBody2());
6120 methodDeclaration.documentationComment = AstFactory.documentationComment(
6121 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
6082 methodDeclaration.accept(builder); 6122 methodDeclaration.accept(builder);
6083 6123
6084 List<FieldElement> fields = holder.fields; 6124 List<FieldElement> fields = holder.fields;
6085 expect(fields, hasLength(1)); 6125 expect(fields, hasLength(1));
6086 FieldElement field = fields[0]; 6126 FieldElement field = fields[0];
6087 expect(field, isNotNull); 6127 expect(field, isNotNull);
6088 expect(field.name, methodName); 6128 expect(field.name, methodName);
6089 expect(field.isSynthetic, isTrue); 6129 expect(field.isSynthetic, isTrue);
6090 expect(field.getter, isNull); 6130 expect(field.getter, isNull);
6131
6091 PropertyAccessorElement setter = field.setter; 6132 PropertyAccessorElement setter = field.setter;
6092 expect(setter, isNotNull); 6133 expect(setter, isNotNull);
6134 _assertHasDocRange(setter, 50, 7);
6093 expect(setter.hasImplicitReturnType, isFalse); 6135 expect(setter.hasImplicitReturnType, isFalse);
6094 expect(setter.isAbstract, isFalse); 6136 expect(setter.isAbstract, isFalse);
6095 expect(setter.isExternal, isFalse); 6137 expect(setter.isExternal, isFalse);
6096 expect(setter.isSetter, isTrue); 6138 expect(setter.isSetter, isTrue);
6097 expect(setter.isSynthetic, isFalse); 6139 expect(setter.isSynthetic, isFalse);
6098 expect(setter.name, "$methodName="); 6140 expect(setter.name, "$methodName=");
6099 expect(setter.displayName, methodName); 6141 expect(setter.displayName, methodName);
6100 expect(setter.variable, field); 6142 expect(setter.variable, field);
6101 expect(setter.functions, hasLength(0)); 6143 expect(setter.functions, hasLength(0));
6102 expect(setter.labels, hasLength(0)); 6144 expect(setter.labels, hasLength(0));
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
6647 expect(variable.hasImplicitType, isTrue); 6689 expect(variable.hasImplicitType, isTrue);
6648 expect(variable.initializer, isNull); 6690 expect(variable.initializer, isNull);
6649 expect(variable.name, variableName); 6691 expect(variable.name, variableName);
6650 expect(variable.isConst, isFalse); 6692 expect(variable.isConst, isFalse);
6651 expect(variable.isFinal, isTrue); 6693 expect(variable.isFinal, isTrue);
6652 expect(variable.isSynthetic, isFalse); 6694 expect(variable.isSynthetic, isFalse);
6653 expect(variable.getter, isNotNull); 6695 expect(variable.getter, isNotNull);
6654 expect(variable.setter, isNull); 6696 expect(variable.setter, isNull);
6655 } 6697 }
6656 6698
6699 void _assertHasDocRange(
6700 Element element, int expectedOffset, int expectedLength) {
6701 SourceRange docRange = element.docRange;
6702 expect(docRange, isNotNull);
6703 expect(docRange.offset, expectedOffset);
6704 expect(docRange.length, expectedLength);
6705 }
6706
6657 void _useParameterInMethod( 6707 void _useParameterInMethod(
6658 FormalParameter formalParameter, int blockOffset, int blockEnd) { 6708 FormalParameter formalParameter, int blockOffset, int blockEnd) {
6659 Block block = AstFactory.block(); 6709 Block block = AstFactory.block();
6660 block.leftBracket.offset = blockOffset; 6710 block.leftBracket.offset = blockOffset;
6661 block.rightBracket.offset = blockEnd - 1; 6711 block.rightBracket.offset = blockEnd - 1;
6662 BlockFunctionBody body = AstFactory.blockFunctionBody(block); 6712 BlockFunctionBody body = AstFactory.blockFunctionBody(block);
6663 AstFactory.methodDeclaration2( 6713 AstFactory.methodDeclaration2(
6664 null, 6714 null,
6665 null, 6715 null,
6666 null, 6716 null,
(...skipping 2646 matching lines...) Expand 10 before | Expand all | Expand 10 after
9313 if (_expectedExternalScriptName == null) { 9363 if (_expectedExternalScriptName == null) {
9314 expect(scriptSource, isNull, reason: "script $scriptIndex"); 9364 expect(scriptSource, isNull, reason: "script $scriptIndex");
9315 } else { 9365 } else {
9316 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 9366 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
9317 String actualExternalScriptName = scriptSource.shortName; 9367 String actualExternalScriptName = scriptSource.shortName;
9318 expect(actualExternalScriptName, _expectedExternalScriptName, 9368 expect(actualExternalScriptName, _expectedExternalScriptName,
9319 reason: "script $scriptIndex"); 9369 reason: "script $scriptIndex");
9320 } 9370 }
9321 } 9371 }
9322 } 9372 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/ast_factory.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698