Version 1.9.0-dev.10.6
svn merge -c 44379 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44380 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44385 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44405 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44408 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44409 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44411 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44415 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 44416 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
git-svn-id: http://dart.googlecode.com/svn/trunk@44421 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkg/analysis_server/lib/src/services/completion/completion_target.dart b/pkg/analysis_server/lib/src/services/completion/completion_target.dart
index 47b8863..7c7badc 100644
--- a/pkg/analysis_server/lib/src/services/completion/completion_target.dart
+++ b/pkg/analysis_server/lib/src/services/completion/completion_target.dart
@@ -156,6 +156,18 @@
// If the node is a candidate target, then we are done.
if (_isCandidateNode(entity, offset)) {
+ // Check to see if the offset is in a preceeding comment
+ Token commentToken = _getContainingCommentToken(entity, offset);
+ if (commentToken != null) {
+ entity = commentToken;
+ // If the preceeding comment is dartdoc token then update
+ // the containing node to be the dartdoc comment
+ Comment docComment =
+ _getContainingDocComment(containingNode, commentToken);
+ if (docComment != null) {
+ containingNode = docComment;
+ }
+ }
return new CompletionTarget._(containingNode, entity);
}
@@ -234,6 +246,46 @@
}
/**
+ * Determine if the offset is contained in a preceeding comment token
+ * and return that token, otherwise return `null`.
+ */
+ static Token _getContainingCommentToken(AstNode node, int offset) {
+ if (offset >= node.offset) {
+ return null;
+ }
+ Token token = node.beginToken;
+ if (token == null) {
+ return null;
+ }
+ token = token.precedingComments;
+ while (token != null) {
+ if (offset <= token.offset) {
+ return null;
+ }
+ if (offset <= token.end) {
+ if (token.type == TokenType.SINGLE_LINE_COMMENT || offset < token.end) {
+ return token;
+ }
+ }
+ token = token.next;
+ }
+ return null;
+ }
+
+ /**
+ * Determine if the given token is part of the given node's dart doc.
+ */
+ static Comment _getContainingDocComment(AstNode node, Token token) {
+ if (node is AnnotatedNode) {
+ Comment docComment = node.documentationComment;
+ if (docComment != null && docComment.tokens.contains(token)) {
+ return docComment;
+ }
+ }
+ return null;
+ }
+
+ /**
* Determine whether [node] could possibly be the [entity] for a
* [CompletionTarget] associated with the given [offset].
*/
diff --git a/pkg/analysis_server/lib/src/services/completion/optype.dart b/pkg/analysis_server/lib/src/services/completion/optype.dart
index a7c7053..cba5695 100644
--- a/pkg/analysis_server/lib/src/services/completion/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/optype.dart
@@ -184,7 +184,9 @@
}
void visitCompilationUnit(CompilationUnit node) {
- optype.includeTypeNameSuggestions = true;
+ if (entity is! CommentToken) {
+ optype.includeTypeNameSuggestions = true;
+ }
}
@override
@@ -310,6 +312,14 @@
}
@override
+ void visitFunctionDeclaration(FunctionDeclaration node) {
+ if (identical(entity, node.returnType) ||
+ identical(entity, node.name) && node.returnType == null) {
+ optype.includeTypeNameSuggestions = true;
+ }
+ }
+
+ @override
void visitFunctionTypeAlias(FunctionTypeAlias node) {
if (identical(entity, node.returnType) ||
identical(entity, node.name) && node.returnType == null) {
@@ -380,7 +390,9 @@
}
@override
- void visitMethodDeclaration(MethodDeclaration node) {}
+ void visitMethodDeclaration(MethodDeclaration node) {
+ optype.includeTypeNameSuggestions = true;
+ }
@override
void visitMethodInvocation(MethodInvocation node) {
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 bb258c4..e416cb4 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 @@
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 @@
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();}');
@@ -137,6 +137,151 @@
assertTarget('}', '{}');
}
+ test_FunctionDeclaration_inLineComment() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal comment ^
+ zoo(z) { } String name;''');
+ assertTarget('// normal comment ', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_inLineComment2() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal ^comment
+ zoo(z) { } String name;''');
+ assertTarget('// normal comment', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_inLineComment3() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal comment ^
+ // normal comment 2
+ zoo(z) { } String name;''');
+ assertTarget('// normal comment ', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_inLineComment4() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal comment
+ // normal comment 2^
+ zoo(z) { } String name;''');
+ assertTarget('// normal comment 2', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_inLineDocComment() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('''
+ /// some dartdoc ^
+ zoo(z) { } String name;''');
+ assertTarget('/// some dartdoc ', '');
+ expect(target.containingNode is Comment, isTrue);
+ expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
+ }
+
+ test_FunctionDeclaration_inLineDocComment2() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('''
+ /// some ^dartdoc
+ zoo(z) { } String name;''');
+ assertTarget('/// some dartdoc', '');
+ expect(target.containingNode is Comment, isTrue);
+ expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
+ }
+
+ test_FunctionDeclaration_inStarComment() {
+ // Comment CompilationUnit
+ addTestSource('/* ^ */ zoo(z) {} String name;');
+ assertTarget('/* */', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_inStarComment2() {
+ // Comment CompilationUnit
+ addTestSource('/* *^/ zoo(z) {} String name;');
+ assertTarget('/* */', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_inStarDocComment() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('/** ^ */ zoo(z) { } String name;');
+ assertTarget('/** */', '');
+ expect(target.containingNode is Comment, isTrue);
+ expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
+ }
+
+ test_FunctionDeclaration_inStarDocComment2() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('/** *^/ zoo(z) { } String name;');
+ assertTarget('/** */', '');
+ expect(target.containingNode is Comment, isTrue);
+ expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
+ }
+
+ test_FunctionDeclaration_returnType() {
+ // CompilationUnit
+ addTestSource('^ zoo(z) { } String name;');
+ assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_returnType_afterLineComment() {
+ // FunctionDeclaration CompilationUnit
+ addTestSource('''
+ // normal comment
+ ^ zoo(z) {} String name;''');
+ assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_returnType_afterLineComment2() {
+ // FunctionDeclaration CompilationUnit
+ // TOD(danrubel) left align all test source
+ addTestSource('''
+// normal comment
+^ zoo(z) {} String name;''');
+ assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_returnType_afterLineDocComment() {
+ // SimpleIdentifier FunctionDeclaration CompilationUnit
+ addTestSource('''
+ /// some dartdoc
+ ^ zoo(z) { } String name; ''');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
+ test_FunctionDeclaration_returnType_afterLineDocComment2() {
+ // SimpleIdentifier FunctionDeclaration CompilationUnit
+ addTestSource('''
+/// some dartdoc
+^ zoo(z) { } String name;''');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
+ test_FunctionDeclaration_returnType_afterStarComment() {
+ // CompilationUnit
+ addTestSource('/* */ ^ zoo(z) { } String name;');
+ assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_returnType_afterStarComment2() {
+ // CompilationUnit
+ addTestSource('/* */^ zoo(z) { } String name;');
+ assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
+ }
+
+ test_FunctionDeclaration_returnType_afterStarDocComment() {
+ // FunctionDeclaration CompilationUnit
+ addTestSource('/** */ ^ zoo(z) { } String name;');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
+ test_FunctionDeclaration_returnType_afterStarDocComment2() {
+ // FunctionDeclaration CompilationUnit
+ addTestSource('/** */^ zoo(z) { } String name;');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
test_InstanceCreationExpression_identifier() {
// InstanceCreationExpression ExpressionStatement Block
addTestSource('class C {foo(){var f; {var x;} new ^C();}}');
@@ -155,6 +300,161 @@
assertTarget('new C();', '{var f; {var x;} new C();}');
}
+ test_MethodDeclaration_inLineComment() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment ^
+ zoo(z) { } String name; }''');
+ assertTarget('// normal comment ', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inLineComment2() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal ^comment
+ zoo(z) { } String name; }''');
+ assertTarget('// normal comment', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inLineComment3() {
+ // 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_inLineComment4() {
+ // 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_inLineDocComment() {
+ // 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_inLineDocComment2() {
+ // 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_inStarComment() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* ^ */ zoo(z) {} String name;}');
+ assertTarget('/* */', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inStarComment2() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* *^/ zoo(z) {} String name;}');
+ assertTarget('/* */', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_inStarDocComment() {
+ // 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_inStarDocComment2() {
+ // 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_returnType() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {^ zoo(z) { } String name; }');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterLineComment() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment
+ ^ zoo(z) {} String name;}''');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterLineComment2() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ // TOD(danrubel) left align all test source
+ addTestSource('''
+class C2 {
+ // normal comment
+^ zoo(z) {} String name;}''');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterLineDocComment() {
+ // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ /// some dartdoc
+ ^ zoo(z) { } String name; }''');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
+ test_MethodDeclaration_returnType_afterLineDocComment2() {
+ // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+class C2 {
+ /// some dartdoc
+^ zoo(z) { } String name; }''');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
+ test_MethodDeclaration_returnType_afterStarComment() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* */ ^ zoo(z) { } String name; }');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterStarComment2() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* */^ zoo(z) { } String name; }');
+ assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}');
+ }
+
+ test_MethodDeclaration_returnType_afterStarDocComment() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** */ ^ zoo(z) { } String name; }');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
+ test_MethodDeclaration_returnType_afterStarDocComment2() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** */^ zoo(z) { } String name; }');
+ assertTarget('zoo', 'zoo(z) {}');
+ }
+
test_VariableDeclaration_lhs_identifier_after() {
// VariableDeclaration VariableDeclarationList
addTestSource('main() {int b^ = 1;}');
diff --git a/pkg/analysis_server/test/services/completion/completion_test_util.dart b/pkg/analysis_server/test/services/completion/completion_test_util.dart
index d4504b6..edafc5f 100644
--- a/pkg/analysis_server/test/services/completion/completion_test_util.dart
+++ b/pkg/analysis_server/test/services/completion/completion_test_util.dart
@@ -2111,6 +2111,100 @@
});
}
+ test_FunctionDeclaration_returnType_afterComment() {
+ // ClassDeclaration CompilationUnit
+ addSource('/testA.dart', '''
+ int T1;
+ F1() { }
+ typedef D1();
+ class C1 {C1(this.x) { } int x;}''');
+ addTestSource('''
+ import "/testA.dart";
+ int T2;
+ F2() { }
+ typedef D2();
+ class C2 { }
+ /* */ ^ zoo(z) { } String name;''');
+ computeFast();
+ return computeFull((bool result) {
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertSuggestImportedClass('Object');
+ assertNotSuggested('T1');
+ assertNotSuggested('F1');
+ assertSuggestImportedFunctionTypeAlias('D1', null);
+ assertSuggestImportedClass('C1');
+ assertNotSuggested('T2');
+ assertNotSuggested('F2');
+ assertSuggestLocalFunctionTypeAlias('D2', null);
+ assertSuggestLocalClass('C2');
+ assertNotSuggested('name');
+ });
+ }
+
+ test_FunctionDeclaration_returnType_afterComment2() {
+ // FunctionDeclaration ClassDeclaration CompilationUnit
+ addSource('/testA.dart', '''
+ int T1;
+ F1() { }
+ typedef D1();
+ class C1 {C1(this.x) { } int x;}''');
+ addTestSource('''
+ import "/testA.dart";
+ int T2;
+ F2() { }
+ typedef D2();
+ class C2 { }
+ /** */ ^ zoo(z) { } String name;''');
+ computeFast();
+ return computeFull((bool result) {
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertSuggestImportedClass('Object');
+ assertNotSuggested('T1');
+ assertNotSuggested('F1');
+ assertSuggestImportedFunctionTypeAlias('D1', null);
+ assertSuggestImportedClass('C1');
+ assertNotSuggested('T2');
+ assertNotSuggested('F2');
+ assertSuggestLocalFunctionTypeAlias('D2', null);
+ assertSuggestLocalClass('C2');
+ assertNotSuggested('name');
+ });
+ }
+
+ test_FunctionDeclaration_returnType_afterComment3() {
+ // FunctionDeclaration ClassDeclaration CompilationUnit
+ addSource('/testA.dart', '''
+ int T1;
+ F1() { }
+ typedef D1();
+ class C1 {C1(this.x) { } int x;}''');
+ addTestSource('''
+ import "/testA.dart";
+ int T2;
+ F2() { }
+ typedef D2();
+ /// some dartdoc
+ class C2 { }
+ ^ zoo(z) { } String name;''');
+ computeFast();
+ return computeFull((bool result) {
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertSuggestImportedClass('Object');
+ assertNotSuggested('T1');
+ assertNotSuggested('F1');
+ assertSuggestImportedFunctionTypeAlias('D1', null);
+ assertSuggestImportedClass('C1');
+ assertNotSuggested('T2');
+ assertNotSuggested('F2');
+ assertSuggestLocalFunctionTypeAlias('D2', null);
+ assertSuggestLocalClass('C2');
+ assertNotSuggested('name');
+ });
+ }
+
test_FunctionExpression_body_function() {
// Block BlockFunctionBody FunctionExpression
addTestSource('''
@@ -2626,6 +2720,128 @@
});
}
+ test_MethodDeclaration_returnType() {
+ // ClassDeclaration CompilationUnit
+ addSource('/testA.dart', '''
+ int T1;
+ F1() { }
+ typedef D1();
+ class C1 {C1(this.x) { } int x;}''');
+ addTestSource('''
+ import "/testA.dart";
+ int T2;
+ F2() { }
+ typedef D2();
+ class C2 {^ zoo(z) { } String name; }''');
+ computeFast();
+ return computeFull((bool result) {
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertSuggestImportedClass('Object');
+ assertNotSuggested('T1');
+ assertNotSuggested('F1');
+ assertSuggestImportedFunctionTypeAlias('D1', null);
+ assertSuggestImportedClass('C1');
+ assertNotSuggested('T2');
+ assertNotSuggested('F2');
+ assertSuggestLocalFunctionTypeAlias('D2', null);
+ assertSuggestLocalClass('C2');
+ assertNotSuggested('name');
+ });
+ }
+
+ test_MethodDeclaration_returnType_afterComment() {
+ // ClassDeclaration CompilationUnit
+ addSource('/testA.dart', '''
+ int T1;
+ F1() { }
+ typedef D1();
+ class C1 {C1(this.x) { } int x;}''');
+ addTestSource('''
+ import "/testA.dart";
+ int T2;
+ F2() { }
+ typedef D2();
+ class C2 {/* */ ^ zoo(z) { } String name; }''');
+ computeFast();
+ return computeFull((bool result) {
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertSuggestImportedClass('Object');
+ assertNotSuggested('T1');
+ assertNotSuggested('F1');
+ assertSuggestImportedFunctionTypeAlias('D1', null);
+ assertSuggestImportedClass('C1');
+ assertNotSuggested('T2');
+ assertNotSuggested('F2');
+ assertSuggestLocalFunctionTypeAlias('D2', null);
+ assertSuggestLocalClass('C2');
+ assertNotSuggested('name');
+ });
+ }
+
+ test_MethodDeclaration_returnType_afterComment2() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addSource('/testA.dart', '''
+ int T1;
+ F1() { }
+ typedef D1();
+ class C1 {C1(this.x) { } int x;}''');
+ addTestSource('''
+ import "/testA.dart";
+ int T2;
+ F2() { }
+ typedef D2();
+ class C2 {/** */ ^ zoo(z) { } String name; }''');
+ computeFast();
+ return computeFull((bool result) {
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertSuggestImportedClass('Object');
+ assertNotSuggested('T1');
+ assertNotSuggested('F1');
+ assertSuggestImportedFunctionTypeAlias('D1', null);
+ assertSuggestImportedClass('C1');
+ assertNotSuggested('T2');
+ assertNotSuggested('F2');
+ assertSuggestLocalFunctionTypeAlias('D2', null);
+ assertSuggestLocalClass('C2');
+ assertNotSuggested('name');
+ });
+ }
+
+ test_MethodDeclaration_returnType_afterComment3() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addSource('/testA.dart', '''
+ int T1;
+ F1() { }
+ typedef D1();
+ class C1 {C1(this.x) { } int x;}''');
+ addTestSource('''
+ import "/testA.dart";
+ int T2;
+ F2() { }
+ typedef D2();
+ class C2 {
+ /// some dartdoc
+ ^ zoo(z) { } String name; }''');
+ computeFast();
+ return computeFull((bool result) {
+ expect(request.replacementOffset, completionOffset);
+ expect(request.replacementLength, 0);
+ assertSuggestImportedClass('Object');
+ assertNotSuggested('T1');
+ assertNotSuggested('F1');
+ assertSuggestImportedFunctionTypeAlias('D1', null);
+ assertSuggestImportedClass('C1');
+ assertNotSuggested('T2');
+ assertNotSuggested('F2');
+ assertSuggestLocalFunctionTypeAlias('D2', null);
+ assertSuggestLocalClass('C2');
+ assertNotSuggested('name');
+ });
+ }
+
test_MethodInvocation_no_semicolon() {
// MethodInvocation ExpressionStatement Block
addTestSource('''
diff --git a/pkg/analysis_server/test/services/completion/optype_test.dart b/pkg/analysis_server/test/services/completion/optype_test.dart
index 067c14e..9ff44e5 100644
--- a/pkg/analysis_server/test/services/completion/optype_test.dart
+++ b/pkg/analysis_server/test/services/completion/optype_test.dart
@@ -502,6 +502,155 @@
assertOpType(returnValue: true, typeNames: true);
}
+ test_FunctionDeclaration1() {
+ // SimpleIdentifier FunctionDeclaration CompilationUnit
+ addTestSource('const ^Fara();');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration2() {
+ // SimpleIdentifier FunctionDeclaration CompilationUnit
+ addTestSource('const F^ara();');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_inLineComment() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal comment ^
+ zoo(z) { } String name;''');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inLineComment2() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal ^comment
+ zoo(z) { } String name;''');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inLineComment3() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal comment ^
+ // normal comment 2
+ zoo(z) { } String name;''');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inLineComment4() {
+ // Comment CompilationUnit
+ addTestSource('''
+ // normal comment
+ // normal comment 2^
+ zoo(z) { } String name;''');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inLineDocComment() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('''
+ /// some dartdoc ^
+ zoo(z) { } String name;''');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inLineDocComment2() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('''
+ /// some ^dartdoc
+ zoo(z) { } String name;''');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inStarComment() {
+ // Comment CompilationUnit
+ addTestSource('/* ^ */ zoo(z) {} String name;');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inStarComment2() {
+ // Comment CompilationUnit
+ addTestSource('/* *^/ zoo(z) {} String name;');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inStarDocComment() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('/** ^ */ zoo(z) { } String name; ');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_inStarDocComment2() {
+ // Comment FunctionDeclaration CompilationUnit
+ addTestSource('/** *^/ zoo(z) { } String name;');
+ assertOpType();
+ }
+
+ test_FunctionDeclaration_returnType() {
+ // CompilationUnit
+ addTestSource('^ zoo(z) { } String name;');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterLineComment() {
+ // FunctionDeclaration CompilationUnit
+ addTestSource('''
+ // normal comment
+ ^ zoo(z) {} String name;''');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterLineComment2() {
+ // FunctionDeclaration CompilationUnit
+ // TOD(danrubel) left align all test source
+ addTestSource('''
+// normal comment
+^ zoo(z) {} String name;''');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterLineDocComment() {
+ // SimpleIdentifier FunctionDeclaration CompilationUnit
+ addTestSource('''
+ /// some dartdoc
+ ^ zoo(z) { } String name;''');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterLineDocComment2() {
+ // SimpleIdentifier FunctionDeclaration CompilationUnit
+ addTestSource('''
+/// some dartdoc
+^ zoo(z) { } String name;''');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterStarComment() {
+ // CompilationUnit
+ addTestSource('/* */ ^ zoo(z) { } String name;');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterStarComment2() {
+ // CompilationUnit
+ addTestSource('/* */^ zoo(z) { } String name;');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterStarDocComment() {
+ // FunctionDeclaration CompilationUnit
+ addTestSource('/** */ ^ zoo(z) { } String name;');
+ assertOpType(typeNames: true);
+ }
+
+ test_FunctionDeclaration_returnType_afterStarDocComment2() {
+ // FunctionDeclaration CompilationUnit
+ addTestSource('/** */^ zoo(z) { } String name;');
+ assertOpType(typeNames: true);
+ }
+
test_FunctionTypeAlias() {
// SimpleIdentifier FunctionTypeAlias CompilationUnit
addTestSource('typedef n^ ;');
@@ -562,12 +711,6 @@
assertOpType(constructors: true);
}
- test_InstanceCreationExpression_trailingStmt() {
- // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
- addTestSource('class C {foo(){var f; {var x;} new ^ int x = 7;}}');
- assertOpType(constructors: true);
- }
-
test_InstanceCreationExpression_keyword() {
// InstanceCreationExpression ExpressionStatement Block
addTestSource('class C {foo(){var f; {var x;} new^ }}');
@@ -580,6 +723,12 @@
assertOpType(returnValue: true, typeNames: true, voidReturn: true);
}
+ test_InstanceCreationExpression_trailingStmt() {
+ // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
+ addTestSource('class C {foo(){var f; {var x;} new ^ int x = 7;}}');
+ assertOpType(constructors: true);
+ }
+
test_InterpolationExpression() {
// SimpleIdentifier InterpolationExpression StringInterpolation
addTestSource('main() {String name; print("hello \$^");}');
@@ -652,6 +801,153 @@
assertOpType(typeNames: true);
}
+ test_MethodDeclaration_inLineComment() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment ^
+ zoo(z) { } String name; }''');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inLineComment2() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal ^comment
+ zoo(z) { } String name; }''');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inLineComment3() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment ^
+ // normal comment 2
+ zoo(z) { } String name; }''');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inLineComment4() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment
+ // normal comment 2^
+ zoo(z) { } String name; }''');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inLineDocComment() {
+ // Comment MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ /// some dartdoc ^
+ zoo(z) { } String name; }''');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inLineDocComment2() {
+ // Comment MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ /// some ^dartdoc
+ zoo(z) { } String name; }''');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inStarComment() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* ^ */ zoo(z) {} String name;}');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inStarComment2() {
+ // Comment ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* *^/ zoo(z) {} String name;}');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inStarDocComment() {
+ // Comment MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** ^ */ zoo(z) { } String name; }');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_inStarDocComment2() {
+ // Comment MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** *^/ zoo(z) { } String name; }');
+ assertOpType();
+ }
+
+ test_MethodDeclaration_returnType() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {^ zoo(z) { } String name; }');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterLineComment() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ // normal comment
+ ^ zoo(z) {} String name;}''');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterLineComment2() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ // TOD(danrubel) left align all test source
+ addTestSource('''
+class C2 {
+ // normal comment
+^ zoo(z) {} String name;}''');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterLineDocComment() {
+ // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+ class C2 {
+ /// some dartdoc
+ ^ zoo(z) { } String name; }''');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterLineDocComment2() {
+ // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('''
+class C2 {
+ /// some dartdoc
+^ zoo(z) { } String name; }''');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterStarComment() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* */ ^ zoo(z) { } String name; }');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterStarComment2() {
+ // ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/* */^ zoo(z) { } String name; }');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterStarDocComment() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** */ ^ zoo(z) { } String name; }');
+ assertOpType(typeNames: true);
+ }
+
+ test_MethodDeclaration_returnType_afterStarDocComment2() {
+ // MethodDeclaration ClassDeclaration CompilationUnit
+ addTestSource('class C2 {/** */^ zoo(z) { } String name; }');
+ assertOpType(typeNames: true);
+ }
+
test_MethodInvocation_no_semicolon() {
// MethodInvocation ExpressionStatement Block
addTestSource('''
diff --git a/pkg/analyzer/lib/src/analyzer_impl.dart b/pkg/analyzer/lib/src/analyzer_impl.dart
index a9f72a3..2897e8b 100644
--- a/pkg/analyzer/lib/src/analyzer_impl.dart
+++ b/pkg/analyzer/lib/src/analyzer_impl.dart
@@ -61,6 +61,15 @@
final HashMap<Source, AnalysisErrorInfo> sourceErrorsMap =
new HashMap<Source, AnalysisErrorInfo>();
+ /**
+ * If the file specified on the command line is part of a package, the name
+ * of that package. Otherwise `null`. This allows us to analyze the file
+ * specified on the command line as though it is reached via a "package:"
+ * URI, but avoid suppressing its output in the event that the user has not
+ * specified the "--package-warnings" option.
+ */
+ String _selfPackageName;
+
AnalyzerImpl(String sourcePath, this.options, this.startTime, this.isBatch)
: sourcePath = _normalizeSourcePath(sourcePath) {
if (sdk == null) {
@@ -101,7 +110,7 @@
{
UriKind uriKind = library.source.uriKind;
// Optionally skip package: libraries.
- if (!options.showPackageWarnings && uriKind == UriKind.PACKAGE_URI) {
+ if (!options.showPackageWarnings && _isOtherPackage(library.source.uri)) {
return;
}
// Optionally skip SDK libraries.
@@ -210,6 +219,11 @@
librarySource = computeLibrarySource();
+ Uri libraryUri = librarySource.uri;
+ if (libraryUri.scheme == 'package' && libraryUri.pathSegments.length > 0) {
+ _selfPackageName = libraryUri.pathSegments[0];
+ }
+
// Create and add a ChangeSet
ChangeSet changeSet = new ChangeSet();
changeSet.addedSource(librarySource);
@@ -295,7 +309,7 @@
}
return options.showSdkWarnings;
}
- if (source.uri.scheme == 'package') {
+ if (_isOtherPackage(source.uri)) {
return options.showPackageWarnings;
}
return true;
@@ -342,6 +356,22 @@
return true;
}
+ /**
+ * Determine whether the given URI refers to a package other than the package
+ * being analyzed.
+ */
+ bool _isOtherPackage(Uri uri) {
+ if (uri.scheme != 'package') {
+ return false;
+ }
+ if (_selfPackageName != null &&
+ uri.pathSegments.length > 0 &&
+ uri.pathSegments[0] == _selfPackageName) {
+ return false;
+ }
+ return true;
+ }
+
_printColdPerf() {
// print cold VM performance numbers
int totalTime = JavaSystem.currentTimeMillis() - startTime;
diff --git a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
index 020b81b..f5460e3 100644
--- a/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart
@@ -558,8 +558,15 @@
&& !seenSuperConstructorCall
&& !cls.isObject) {
FunctionElement target = cls.superclass.lookupDefaultConstructor();
- analyzeSuperConstructorCall(target, new ArgumentsTypes([], {}));
- synthesizeForwardingCall(analyzedElement, target);
+ ArgumentsTypes arguments = new ArgumentsTypes([], {});
+ analyzeSuperConstructorCall(target, arguments);
+ inferrer.registerCalledElement(node,
+ null,
+ outermostElement,
+ target.implementation,
+ arguments,
+ sideEffects,
+ inLoop);
}
visit(node.body);
inferrer.recordExposesThis(analyzedElement, isThisExposed);
@@ -1291,6 +1298,7 @@
sideEffects,
inLoop);
}
+
T visitRedirectingFactoryBody(ast.RedirectingFactoryBody node) {
Element element = elements.getRedirectingTargetConstructor(node);
if (Elements.isErroneous(element)) {
diff --git a/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart b/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
index e95c25e..8c7ff14 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/dart2js_transformer.dart
@@ -12,10 +12,10 @@
import 'package:path/path.dart' as path;
import 'package:pool/pool.dart';
-import '../../../../../../../pkg/compiler/lib/compiler.dart' as compiler;
-import '../../../../../../../pkg/compiler/lib/src/dart2js.dart'
+import 'package:compiler/compiler.dart' as compiler;
+import 'package:compiler/src/dart2js.dart'
show AbortLeg;
-import '../../../../../../../pkg/compiler/lib/src/io/source_file.dart';
+import 'package:compiler/src/io/source_file.dart';
import '../barback.dart';
import '../dart.dart' as dart;
import '../utils.dart';
diff --git a/sdk/lib/_internal/pub/lib/src/dart.dart b/sdk/lib/_internal/pub/lib/src/dart.dart
index 46d71dd..f5210f1 100644
--- a/sdk/lib/_internal/pub/lib/src/dart.dart
+++ b/sdk/lib/_internal/pub/lib/src/dart.dart
@@ -12,8 +12,8 @@
import 'package:analyzer/analyzer.dart';
import 'package:path/path.dart' as path;
-import '../../../../../../pkg/compiler/lib/compiler.dart' as compiler;
-import '../../../../../../pkg/compiler/lib/src/filenames.dart'
+import 'package:compiler/compiler.dart' as compiler;
+import 'package:compiler/src/filenames.dart'
show appendSlash;
import '../../asset/dart/serialize.dart';
diff --git a/tests/language/implicit_super_constructor_call_test.dart b/tests/language/implicit_super_constructor_call_test.dart
new file mode 100644
index 0000000..16e41b2
--- /dev/null
+++ b/tests/language/implicit_super_constructor_call_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// This is a regression test for http://dartbug.com/22723.
+
+import "package:expect/expect.dart";
+
+class A {
+ final x;
+
+ @NoInline()
+ A({this.x: "foo"}) {
+ Expect.equals("foo", x.toString());
+ try {} catch (_) {}; // Make sure it really does not get inlined.
+ }
+}
+
+class C extends A {
+ C(foobar) { }
+}
+
+main() {
+ var c = new C(499);
+ Expect.equals("foo", c.x.toString());
+}
+
diff --git a/tests/language/language_analyzer2.status b/tests/language/language_analyzer2.status
index 9694935..eb9d175 100644
--- a/tests/language/language_analyzer2.status
+++ b/tests/language/language_analyzer2.status
@@ -25,7 +25,6 @@
external_test/25: Fail
constructor_duplicate_final_test/03: Fail
reify_typevar_static_test/00: MissingCompileTimeError # Issue 21565
-regress_22700_test: Crash # Issue 22700
# Please add new failing tests before this line.
# Section below is for invalid tests.
diff --git a/tools/VERSION b/tools/VERSION
index fa3745a..c00da2d 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
MINOR 9
PATCH 0
PRERELEASE 10
-PRERELEASE_PATCH 5
+PRERELEASE_PATCH 6