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

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

Issue 1072623002: refactor optype to better filter invocation/prefixed suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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/prefixed_element_contributor.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/optype_test.dart
diff --git a/pkg/analysis_server/test/services/completion/optype_test.dart b/pkg/analysis_server/test/services/completion/optype_test.dart
index 2fffca80861a77b7378d182c73c7f50d74c4ccf8..ff74539d11a0cb6d1636b313632602254493b98b 100644
--- a/pkg/analysis_server/test/services/completion/optype_test.dart
+++ b/pkg/analysis_server/test/services/completion/optype_test.dart
@@ -42,23 +42,20 @@ class OpTypeTest {
visitor = new OpType.forCompletion(completionTarget, offset);
}
- void assertOpType({bool invocation: false, bool returnValue: false,
+ void assertOpType({bool prefixed: false, bool returnValue: false,
bool typeNames: false, bool voidReturn: false, bool statementLabel: false,
bool caseLabel: false, bool constructors: false}) {
- expect(visitor.includeInvocationSuggestions, equals(invocation),
- reason: 'invocation');
- expect(visitor.includeReturnValueSuggestions, equals(returnValue),
+ expect(visitor.includeReturnValueSuggestions, returnValue,
reason: 'returnValue');
- expect(visitor.includeTypeNameSuggestions, equals(typeNames),
- reason: 'typeNames');
- expect(visitor.includeVoidReturnSuggestions, equals(voidReturn),
+ expect(visitor.includeTypeNameSuggestions, typeNames, reason: 'typeNames');
+ expect(visitor.includeVoidReturnSuggestions, voidReturn,
reason: 'voidReturn');
- expect(visitor.includeStatementLabelSuggestions, equals(statementLabel),
+ expect(visitor.includeStatementLabelSuggestions, statementLabel,
reason: 'statementLabel');
- expect(visitor.includeCaseLabelSuggestions, equals(caseLabel),
- reason: 'caseLabel');
- expect(visitor.includeConstructorSuggestions, equals(constructors),
+ expect(visitor.includeCaseLabelSuggestions, caseLabel, reason: 'caseLabel');
+ expect(visitor.includeConstructorSuggestions, constructors,
reason: 'constructors');
+ expect(visitor.isPrefixed, prefixed, reason: 'prefixed');
}
test_Annotation() {
@@ -80,6 +77,12 @@ class OpTypeTest {
assertOpType(returnValue: true, typeNames: true);
}
+ test_ArgumentList_prefixedIdentifier() {
+ // SimpleIdentifier PrefixedIdentifier ArgumentList
+ addTestSource('void main() {expect(aa.^)}');
+ assertOpType(returnValue: true, typeNames: true, prefixed: true);
+ }
+
test_AsExpression() {
// SimpleIdentifier TypeName AsExpression
addTestSource('class A {var b; X _c; foo() {var a; (a as ^).foo();}');
@@ -230,19 +233,20 @@ class OpTypeTest {
// looks like a cascade to the parser
// but the user is trying to get completions for a non-cascade
main() {A a; a.^.z}''');
- assertOpType(invocation: true);
+ assertOpType(
+ returnValue: true, typeNames: true, voidReturn: true, prefixed: true);
}
test_CascadeExpression_selector2() {
// SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement
addTestSource('main() {A a; a..^z}');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, voidReturn: true, prefixed: true);
}
test_CascadeExpression_selector2_withTrailingReturn() {
// PropertyAccess CascadeExpression ExpressionStatement Block
addTestSource('main() {A a; a..^ return}');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, voidReturn: true, prefixed: true);
}
test_CascadeExpression_target() {
@@ -344,7 +348,7 @@ class OpTypeTest {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('main() {new X.^}');
- assertOpType(invocation: true);
+ assertOpType(constructors: true, prefixed: true);
}
test_ConstructorName_name_resolved() {
@@ -358,14 +362,14 @@ class OpTypeTest {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('main() {new String.fr^omCharCodes([]);}', resolved: true);
- assertOpType(invocation: true);
+ assertOpType(constructors: true, prefixed: true);
}
test_ConstructorName_unresolved() {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('main() {new String.fr^omCharCodes([]);}');
- assertOpType(invocation: true);
+ assertOpType(constructors: true, prefixed: true);
}
test_Continue_after_label() {
@@ -490,19 +494,19 @@ class OpTypeTest {
test_FormalParameter_partialType() {
// FormalParameterList MethodDeclaration
addTestSource('class A {a(b.^ f) { }}');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, typeNames: true, prefixed: true);
}
test_FormalParameter_partialType2() {
// FormalParameterList MethodDeclaration
addTestSource('class A {a(b.z^ f) { }}');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, typeNames: true, prefixed: true);
}
test_FormalParameter_partialType3() {
// FormalParameterList MethodDeclaration
addTestSource('class A {a(b.^) { }}');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, typeNames: true, prefixed: true);
}
test_FormalParameterList() {
@@ -726,7 +730,7 @@ class OpTypeTest {
test_IfStatement_invocation() {
// SimpleIdentifier PrefixIdentifier IfStatement
addTestSource('main() {var a; if (a.^) something}');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, typeNames: true, prefixed: true);
}
test_ImplementsClause() {
@@ -792,7 +796,7 @@ class OpTypeTest {
test_InterpolationExpression_prefix_selector() {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
addTestSource('main() {String name; print("hello \${name.^}");}');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, typeNames: true, prefixed: true);
}
test_InterpolationExpression_prefix_target() {
@@ -1021,7 +1025,8 @@ class C2 {
// no semicolon between completion point and next statement
set _s2(I x) {x.^ m(null);}
}''');
- assertOpType(invocation: true);
+ assertOpType(
+ returnValue: true, typeNames: true, voidReturn: true, prefixed: true);
}
test_PostfixExpression() {
@@ -1033,13 +1038,15 @@ class C2 {
test_PrefixedIdentifier_class_const() {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement Block
addTestSource('main() {A.^}');
- assertOpType(invocation: true);
+ assertOpType(
+ returnValue: true, typeNames: true, voidReturn: true, prefixed: true);
}
test_PrefixedIdentifier_class_imported() {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('main() {A a; a.^}');
- assertOpType(invocation: true);
+ assertOpType(
+ returnValue: true, typeNames: true, voidReturn: true, prefixed: true);
}
test_PrefixedIdentifier_prefix() {
@@ -1051,7 +1058,8 @@ class C2 {
test_PropertyAccess_expression() {
// SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement
addTestSource('class A {a() {"hello".to^String().length}}');
- assertOpType(invocation: true);
+ assertOpType(
+ returnValue: true, typeNames: true, voidReturn: true, prefixed: true);
}
test_PropertyAccess_noTarget() {
@@ -1075,7 +1083,8 @@ class C2 {
test_PropertyAccess_selector() {
// SimpleIdentifier PropertyAccess ExpressionStatement Block
addTestSource('class A {a() {"hello".length.^}}');
- assertOpType(invocation: true);
+ assertOpType(
+ returnValue: true, typeNames: true, voidReturn: true, prefixed: true);
}
test_ReturnStatement() {
@@ -1110,16 +1119,16 @@ class C2 {
// no semicolon between completion point and next statement
set s1(I x) {} set _s2(I x) {this.^ m(null);}
}''');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, voidReturn: true, prefixed: true);
}
test_ThisExpression_constructor() {
- // MethodInvocation ExpressionStatement Block
+ // SimpleIdentifier PropertyAccess ExpressionStatement
addTestSource('''
class A implements I {
A() {this.^}
}''');
- assertOpType(invocation: true);
+ assertOpType(returnValue: true, voidReturn: true, prefixed: true);
}
test_ThrowExpression() {
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698