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

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

Issue 1396693004: Fix for top level variable documention ranges. (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/resolver.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 6655 matching lines...) Expand 10 before | Expand all | Expand 10 after
6666 expect(variable.initializer, isNotNull); 6666 expect(variable.initializer, isNotNull);
6667 expect(variable.name, variableName); 6667 expect(variable.name, variableName);
6668 expect(variable.hasImplicitType, isTrue); 6668 expect(variable.hasImplicitType, isTrue);
6669 expect(variable.isConst, isTrue); 6669 expect(variable.isConst, isTrue);
6670 expect(variable.isFinal, isFalse); 6670 expect(variable.isFinal, isFalse);
6671 expect(variable.isSynthetic, isFalse); 6671 expect(variable.isSynthetic, isFalse);
6672 expect(variable.getter, isNotNull); 6672 expect(variable.getter, isNotNull);
6673 expect(variable.setter, isNull); 6673 expect(variable.setter, isNull);
6674 } 6674 }
6675 6675
6676 void test_visitVariableDeclaration_top_docRange() {
6677 // final a, b;
6678 ElementHolder holder = new ElementHolder();
6679 ElementBuilder builder = new ElementBuilder(holder);
6680 VariableDeclaration variableDeclaration1 =
6681 AstFactory.variableDeclaration('a');
6682 VariableDeclaration variableDeclaration2 =
6683 AstFactory.variableDeclaration('b');
6684 TopLevelVariableDeclaration topLevelVariableDeclaration = AstFactory
6685 .topLevelVariableDeclaration(
6686 Keyword.FINAL, null, [variableDeclaration1, variableDeclaration2]);
6687 topLevelVariableDeclaration.documentationComment = AstFactory
6688 .documentationComment(
6689 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
6690
6691 topLevelVariableDeclaration.accept(builder);
6692 List<TopLevelVariableElement> variables = holder.topLevelVariables;
6693 expect(variables, hasLength(2));
6694
6695 TopLevelVariableElement variable1 = variables[0];
6696 expect(variable1, isNotNull);
6697 _assertHasDocRange(variable1, 50, 7);
6698
6699 TopLevelVariableElement variable2 = variables[1];
6700 expect(variable2, isNotNull);
6701 _assertHasDocRange(variable2, 50, 7);
6702 }
6703
6676 void test_visitVariableDeclaration_top_final() { 6704 void test_visitVariableDeclaration_top_final() {
6677 // final v; 6705 // final v;
6678 ElementHolder holder = new ElementHolder(); 6706 ElementHolder holder = new ElementHolder();
6679 ElementBuilder builder = new ElementBuilder(holder); 6707 ElementBuilder builder = new ElementBuilder(holder);
6680 String variableName = "v"; 6708 String variableName = "v";
6681 VariableDeclaration variableDeclaration = 6709 VariableDeclaration variableDeclaration =
6682 AstFactory.variableDeclaration2(variableName, null); 6710 AstFactory.variableDeclaration2(variableName, null);
6683 AstFactory.variableDeclarationList2(Keyword.FINAL, [variableDeclaration]); 6711 AstFactory.variableDeclarationList2(Keyword.FINAL, [variableDeclaration]);
6684 variableDeclaration.accept(builder); 6712 variableDeclaration.accept(builder);
6685 List<TopLevelVariableElement> variables = holder.topLevelVariables; 6713 List<TopLevelVariableElement> variables = holder.topLevelVariables;
(...skipping 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after
9363 if (_expectedExternalScriptName == null) { 9391 if (_expectedExternalScriptName == null) {
9364 expect(scriptSource, isNull, reason: "script $scriptIndex"); 9392 expect(scriptSource, isNull, reason: "script $scriptIndex");
9365 } else { 9393 } else {
9366 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 9394 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
9367 String actualExternalScriptName = scriptSource.shortName; 9395 String actualExternalScriptName = scriptSource.shortName;
9368 expect(actualExternalScriptName, _expectedExternalScriptName, 9396 expect(actualExternalScriptName, _expectedExternalScriptName,
9369 reason: "script $scriptIndex"); 9397 reason: "script $scriptIndex");
9370 } 9398 }
9371 } 9399 }
9372 } 9400 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698