Version 1.9.0-dev.7.1
svn merge -c 43568 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 43567 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
svn merge -c 43580 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
git-svn-id: http://dart.googlecode.com/svn/trunk@43584 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkg/analysis_server/lib/src/services/completion/invocation_computer.dart b/pkg/analysis_server/lib/src/services/completion/invocation_computer.dart
index 9913a63..0dc7319 100644
--- a/pkg/analysis_server/lib/src/services/completion/invocation_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/invocation_computer.dart
@@ -63,6 +63,11 @@
} else if (node is PropertyAccess) {
node = (node as PropertyAccess).realTarget;
}
+ if (node is Identifier && node.bestElement is ClassElement) {
+ node.bestElement.accept(
+ new _PrefixedIdentifierSuggestionBuilder(request));
+ return new Future.value(true);
+ }
if (node is Expression) {
InterfaceTypeSuggestionBuilder.suggestionsFor(request, node.bestType);
return new Future.value(true);
diff --git a/pkg/analysis_server/lib/src/services/completion/optype.dart b/pkg/analysis_server/lib/src/services/completion/optype.dart
index 3a6d6ef..efaa8fd 100644
--- a/pkg/analysis_server/lib/src/services/completion/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/optype.dart
@@ -378,6 +378,12 @@
}
@override
+ void visitListLiteral(ListLiteral node) {
+ optype.includeReturnValueSuggestions = true;
+ optype.includeTypeNameSuggestions = true;
+ }
+
+ @override
void visitMethodDeclaration(MethodDeclaration node) {
}
diff --git a/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
index ba6c396..f951371 100644
--- a/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
@@ -321,16 +321,21 @@
// exceptions to handle getter/setter pairs).
for (InterfaceType targetType in _getTypeOrdering(type)) {
for (MethodElement method in targetType.methods) {
- addSuggestion(method);
+ // Exclude static methods when completion on an instance
+ if (!method.isStatic) {
+ addSuggestion(method);
+ }
}
for (PropertyAccessorElement propertyAccessor in targetType.accessors) {
- if (propertyAccessor.isSynthetic) {
- // Avoid visiting a field twice
- if (propertyAccessor.isGetter) {
- addSuggestion(propertyAccessor.variable);
+ if (!propertyAccessor.isStatic) {
+ if (propertyAccessor.isSynthetic) {
+ // Avoid visiting a field twice
+ if (propertyAccessor.isGetter) {
+ addSuggestion(propertyAccessor.variable);
+ }
+ } else {
+ addSuggestion(propertyAccessor);
}
- } else {
- addSuggestion(propertyAccessor);
}
}
}
diff --git a/pkg/analysis_server/test/completion_test.dart b/pkg/analysis_server/test/completion_test.dart
index aef1641..aa47d3e 100644
--- a/pkg/analysis_server/test/completion_test.dart
+++ b/pkg/analysis_server/test/completion_test.dart
@@ -229,8 +229,7 @@
buildTests('testCommentSnippets042', '''
class DateTime{static const int WED=3;int get day;}fd(){DateTime d=new DateTime.now();d.!1WED!2;}''',
- <String>["1+day", "2-WED"],
- failingTests: '2');
+ <String>["1+day", "2-WED"]);
buildTests('testCommentSnippets043', '''
class L{var k;void.!1}''', <String>["1-k"]);
@@ -642,8 +641,7 @@
buildTests('testCommentSnippets079', '''
class Map{static from()=>null;clear(){}}void main() { Map s; s.!1 }''',
- <String>["1-from", "1+clear"],
- failingTests: '1'); // static method, instance method
+ <String>["1-from", "1+clear"]); // static method, instance method
buildTests('testCommentSnippets080', '''
class RuntimeError{var message;}void main() { RuntimeError.!1 }''',
@@ -1427,8 +1425,7 @@
b.a.!1;
c.!2;
}''',
- <String>["1-FIELD", "1+fieldA", "2+fieldC", "2+fieldA"],
- failingTests: '1');
+ <String>["1-FIELD", "1+fieldA", "2+fieldC", "2+fieldA"]);
buildTests('testCompletion_return_withIdentifierPrefix', '''
f() { var vvv = 42; return v!1 }''', <String>["1+vvv"]);
@@ -2160,8 +2157,7 @@
"C+g",
"D+_m",
"E+m",
- "F+g"],
- failingTests: '789');
+ "F+g"]);
buildTests('test026', '''var aBcD; var x=ab!1''', <String>["1+aBcD"]);
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 2764b587..67a7a06 100644
--- a/pkg/analysis_server/test/services/completion/completion_test_util.dart
+++ b/pkg/analysis_server/test/services/completion/completion_test_util.dart
@@ -2328,6 +2328,26 @@
});
}
+ test_Literal_list() {
+ // ']' ListLiteral ArgumentList MethodInvocation
+ addTestSource('main() {var Some; print([^]);}');
+ computeFast();
+ return computeFull((bool result) {
+ assertSuggestLocalVariable('Some', null);
+ assertSuggestImportedClass('String');
+ });
+ }
+
+ test_Literal_list2() {
+ // SimpleIdentifier ListLiteral ArgumentList MethodInvocation
+ addTestSource('main() {var Some; print([S^]);}');
+ computeFast();
+ return computeFull((bool result) {
+ assertSuggestLocalVariable('Some', null);
+ assertSuggestImportedClass('String');
+ });
+ }
+
test_Literal_string() {
// SimpleStringLiteral ExpressionStatement Block
addTestSource('class A {a() {"hel^lo"}}');
@@ -2608,7 +2628,7 @@
return computeFull((bool result) {
expect(request.replacementOffset, completionOffset);
expect(request.replacementLength, 0);
- assertSuggestInvocationField('sc', 'int');
+ assertNotSuggested('sc');
assertSuggestInvocationField('b', null, isDeprecated: true);
assertNotSuggested('_c');
assertSuggestInvocationGetter('d', 'X');
@@ -2643,7 +2663,7 @@
return computeFull((bool result) {
expect(request.replacementOffset, completionOffset);
expect(request.replacementLength, 0);
- assertSuggestInvocationField('sc', 'int');
+ assertNotSuggested('sc');
assertSuggestInvocationField('b', null);
assertSuggestInvocationField('_c', 'X');
assertSuggestInvocationGetter('d', 'X');
diff --git a/pkg/analysis_server/test/services/completion/invocation_computer_test.dart b/pkg/analysis_server/test/services/completion/invocation_computer_test.dart
index 6b9886b..4025bdb 100644
--- a/pkg/analysis_server/test/services/completion/invocation_computer_test.dart
+++ b/pkg/analysis_server/test/services/completion/invocation_computer_test.dart
@@ -153,20 +153,6 @@
});
}
- test_param() {
- addTestSource('foo(String x) {x.^}');
- return computeFull((bool result) {
- assertSuggestGetter('length', 'int');
- });
- }
-
- test_param_is() {
- addTestSource('foo(x) {if (x is String) x.^}');
- return computeFull((bool result) {
- assertSuggestGetter('length', 'int');
- });
- }
-
test_method_parameters_mixed_required_and_named() {
addTestSource('''
class C {
@@ -309,6 +295,92 @@
});
}
+ test_only_instance() {
+ // SimpleIdentifier PropertyAccess ExpressionStatement
+ addTestSource('''
+class C {
+ int f1;
+ static int f2;
+ m1() {}
+ static m2() {}
+}
+void main() {new C().^}''');
+ return computeFull((bool result) {
+ assertSuggestInvocationField('f1', 'int');
+ assertNotSuggested('f2');
+ assertSuggestMethod('m1', 'C', null);
+ assertNotSuggested('m2');
+ });
+ }
+
+ test_only_instance2() {
+ // SimpleIdentifier MethodInvocation ExpressionStatement
+ addTestSource('''
+class C {
+ int f1;
+ static int f2;
+ m1() {}
+ static m2() {}
+}
+void main() {new C().^ print("something");}''');
+ return computeFull((bool result) {
+ assertSuggestInvocationField('f1', 'int');
+ assertNotSuggested('f2');
+ assertSuggestMethod('m1', 'C', null);
+ assertNotSuggested('m2');
+ });
+ }
+
+ test_only_static() {
+ // SimpleIdentifier PrefixedIdentifier ExpressionStatement
+ addTestSource('''
+class C {
+ int f1;
+ static int f2;
+ m1() {}
+ static m2() {}
+}
+void main() {C.^}''');
+ return computeFull((bool result) {
+ assertNotSuggested('f1');
+ assertSuggestInvocationField('f2', 'int');
+ assertNotSuggested('m1');
+ assertSuggestMethod('m2', 'C', null);
+ });
+ }
+
+ test_only_static2() {
+ // SimpleIdentifier MethodInvocation ExpressionStatement
+ addTestSource('''
+class C {
+ int f1;
+ static int f2;
+ m1() {}
+ static m2() {}
+}
+void main() {C.^ print("something");}''');
+ return computeFull((bool result) {
+ assertNotSuggested('f1');
+ assertSuggestInvocationField('f2', 'int');
+ assertNotSuggested('m1');
+ assertSuggestMethod('m2', 'C', null);
+ });
+ }
+
+ test_param() {
+ addTestSource('foo(String x) {x.^}');
+ return computeFull((bool result) {
+ assertSuggestGetter('length', 'int');
+ });
+ }
+
+ test_param_is() {
+ addTestSource('foo(x) {if (x is String) x.^}');
+ return computeFull((bool result) {
+ assertSuggestGetter('length', 'int');
+ });
+ }
+
test_shadowing_field_over_field() =>
check_shadowing('int x;', 'int x;', true);
diff --git a/pkg/analysis_server/test/services/completion/optype_test.dart b/pkg/analysis_server/test/services/completion/optype_test.dart
index ce7a5ba..a5367a7 100644
--- a/pkg/analysis_server/test/services/completion/optype_test.dart
+++ b/pkg/analysis_server/test/services/completion/optype_test.dart
@@ -627,6 +627,18 @@
assertOpType(typeNames: true);
}
+ test_Literal_list() {
+ // ']' ListLiteral ArgumentList MethodInvocation
+ addTestSource('main() {var Some; print([^]);}');
+ assertOpType(returnValue: true, typeNames: true);
+ }
+
+ test_Literal_list2() {
+ // SimpleIdentifier ListLiteral ArgumentList MethodInvocation
+ addTestSource('main() {var Some; print([S^]);}');
+ assertOpType(returnValue: true, typeNames: true);
+ }
+
test_Literal_string() {
// SimpleStringLiteral ExpressionStatement Block
addTestSource('class A {a() {"hel^lo"}}');
diff --git a/tools/VERSION b/tools/VERSION
index dacd602..501caa3 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
MINOR 9
PATCH 0
PRERELEASE 7
-PRERELEASE_PATCH 0
+PRERELEASE_PATCH 1