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

Unified Diff: pkg/analysis_server/test/analysis/get_hover_test.dart

Issue 717513003: Issue 21552. Fixes for navigation, hover and rename in instance creation expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
Index: pkg/analysis_server/test/analysis/get_hover_test.dart
diff --git a/pkg/analysis_server/test/analysis/get_hover_test.dart b/pkg/analysis_server/test/analysis/get_hover_test.dart
index 1fe91f1953f3c737ba94b6e2e1b097c4712c0e13..43a931388832c3c9c8011c9cf083e5c132f5a8d8 100644
--- a/pkg/analysis_server/test/analysis/get_hover_test.dart
+++ b/pkg/analysis_server/test/analysis/get_hover_test.dart
@@ -138,7 +138,7 @@ class A {
});
}
- test_expression_method_nvocation() {
+ test_expression_method_invocation() {
addTestFile('''
library my.library;
class A {
@@ -212,6 +212,92 @@ main() {
});
}
+ test_instanceCreation_implicit() {
+ addTestFile('''
+library my.library;
+class A {
+}
+main() {
+ new A();
+}
+''');
+ return prepareHover('new A').then((HoverInformation hover) {
+ // range
+ expect(hover.offset, findOffset('new A'));
+ expect(hover.length, 'new A()'.length);
+ // element
+ expect(hover.containingLibraryName, 'my.library');
+ expect(hover.containingLibraryPath, testFile);
+ expect(hover.dartdoc, isNull);
+ expect(hover.elementDescription, 'A() → A');
+ expect(hover.elementKind, 'constructor');
+ // types
+ expect(hover.staticType, 'A');
+ expect(hover.propagatedType, isNull);
+ // no parameter
+ expect(hover.parameter, isNull);
+ });
+ }
+
+ test_instanceCreation_implicit_withTypeArgument() {
+ addTestFile('''
+library my.library;
+class A<T> {}
+main() {
+ new A<String>();
+}
+''');
+ Function onConstructor = (HoverInformation hover) {
+ // range
+ expect(hover.offset, findOffset('new A<String>'));
+ expect(hover.length, 'new A<String>()'.length);
+ // element
+ expect(hover.containingLibraryName, 'my.library');
+ expect(hover.containingLibraryPath, testFile);
+ expect(hover.dartdoc, isNull);
+ expect(hover.elementDescription, 'A() → A<String>');
+ expect(hover.elementKind, 'constructor');
+ // types
+ expect(hover.staticType, 'A<String>');
+ expect(hover.propagatedType, isNull);
+ // no parameter
+ expect(hover.parameter, isNull);
+ };
+ var futureNewA = prepareHover('new A').then(onConstructor);
+ var futureA = prepareHover('A<String>()').then(onConstructor);
+ var futureString = prepareHover('String>').then((HoverInformation hover) {
+ expect(hover.offset, findOffset('String>'));
+ expect(hover.length, 'String'.length);
+ expect(hover.elementKind, 'class');
+ });
+ return Future.wait([futureNewA, futureA, futureString]);
+ }
+
+ test_instanceCreation_named() {
+ addTestFile('''
+library my.library;
+class A {
+ /// my doc
+ A.named() {}
+}
+main() {
+ new A.named();
+}
+''');
+ var onConstructor = (HoverInformation hover) {
+ // range
+ expect(hover.offset, findOffset('new A'));
+ expect(hover.length, 'new A.named()'.length);
+ // element
+ expect(hover.dartdoc, 'my doc');
+ expect(hover.elementDescription, 'A.named() → A');
+ expect(hover.elementKind, 'constructor');
+ };
+ var futureCreation = prepareHover('new A').then(onConstructor);
+ var futureName = prepareHover('named();').then(onConstructor);
+ return Future.wait([futureCreation, futureName]);
+ }
+
test_noHoverInfo() {
addTestFile('''
library my.library;

Powered by Google App Engine
This is Rietveld 408576698