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

Unified Diff: pkg/analysis_server/test/services/completion/completion_target_test.dart

Issue 985183003: fix completion target handling of comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/completion_target.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/completion/completion_target_test.dart
diff --git a/pkg/analysis_server/test/services/completion/completion_target_test.dart b/pkg/analysis_server/test/services/completion/completion_target_test.dart
index bb258c4345fd1866cea2d408b5829bb4165e822c..aad78864ead1ffe6a301b61501d4df681b3e56c6 100644
--- a/pkg/analysis_server/test/services/completion/completion_target_test.dart
+++ b/pkg/analysis_server/test/services/completion/completion_target_test.dart
@@ -59,6 +59,12 @@ class CompletionTargetTest extends AbstractContextTest {
assertTarget(')', '()', argIndex: 0);
}
+ test_ArgumentList_InstanceCreationExpression_functionArg2() {
+ // ArgumentList InstanceCreationExpression Block
+ addTestSource('main() {new B(^)} class B{B(f()){}}');
+ assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true);
+ }
+
test_ArgumentList_MethodInvocation() {
// ArgumentList MethodInvocation Block
addTestSource('main() {foo(^)}');
@@ -95,12 +101,6 @@ class CompletionTargetTest extends AbstractContextTest {
assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true);
}
- test_ArgumentList_InstanceCreationExpression_functionArg2() {
- // ArgumentList InstanceCreationExpression Block
- addTestSource('main() {new B(^)} class B{B(f()){}}');
- assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true);
- }
-
test_AsExpression_identifier() {
// SimpleIdentifier TypeName AsExpression
addTestSource('class A {var b; X _c; foo() {var a; (a^ as String).foo();}');
@@ -155,6 +155,116 @@ class CompletionTargetTest extends AbstractContextTest {
assertTarget('new C();', '{var f; {var x;} new C();}');
}
+ test_MethodDeclaration_inComment() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* ^ */ zoo(z) {} String name;}');
+ assertTarget('/* */', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inComment2() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment ^
+ zoo(z) { } String name; }''');
+ assertTarget('// normal comment ', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inComment3() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal ^comment
+ zoo(z) { } String name; }''');
+ assertTarget('// normal comment', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inComment4() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment ^
+ // normal comment 2
+ zoo(z) { } String name; }''');
+ assertTarget('// normal comment ', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inComment5() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment
+ // normal comment 2^
+ zoo(z) { } String name; }''');
+ assertTarget('// normal comment 2', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inDocComment() {
+ // Comment MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** ^ */ zoo(z) { } String name; }');
+ assertTarget('/** */', '');
+ expect(target.containingNode is Comment, isTrue);
+ expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
+ }
+
+ test_MethodDeclaration_inDocComment2() {
+ // Comment MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ /// some dartdoc ^
+ zoo(z) { } String name; }''');
+ assertTarget('/// some dartdoc ', '');
+ expect(target.containingNode is Comment, isTrue);
+ expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
+ }
+
+ test_MethodDeclaration_inDocComment3() {
+ // Comment MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ /// some ^dartdoc
+ zoo(z) { } String name; }''');
+ assertTarget('/// some dartdoc', '');
+ expect(target.containingNode is Comment, isTrue);
+ expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
+ }
+
+ test_MethodDeclaration_returnType() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {^ zoo(z) { } String name; }');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterComment() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* */ ^ zoo(z) { } String name; }');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterComment2() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment
+ ^ zoo(z) {} String name;}''');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterDocComment() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** */ ^ zoo(z) { } String name; }');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
+ test_MethodDeclaration_returnType_afterDocComment2() {
+ // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ /// some dartdoc
+ ^ zoo(z) { } String name; }''');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
Paul Berry 2015/03/09 22:32:51 I'd suggest adding some corner cases to test that
danrubel 2015/03/11 15:01:56 Great suggestion. Done.
test_VariableDeclaration_lhs_identifier_after() {
// VariableDeclaration VariableDeclarationList
addTestSource('main() {int b^ = 1;}');
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/completion_target.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698