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

Side by Side Diff: pkg/analysis_server/test/services/completion/dart/reference_contributor_test.dart

Issue 1407273004: next step toward completion plugin API (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.services.completion.contributor.dart.reference;
6
7 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol
8 show Element, ElementKind;
9 import 'package:analysis_server/plugin/protocol/protocol.dart'
10 hide Element, ElementKind;
11 import 'package:analysis_server/src/provisional/completion/completion_dart.dart' ;
12 import 'package:analysis_server/src/services/completion/dart/reference_contribut or.dart';
13 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'
14 hide DartCompletionContributor;
15 import 'package:test_reflective_loader/test_reflective_loader.dart';
16 import 'package:unittest/unittest.dart';
17
18 import '../../../utils.dart';
19 import 'dart_completion_contributor_test.dart';
20
21 main() {
22 initializeTestEnvironment();
23 defineReflectiveTests(ReferenceContributorTest);
24 }
25
26 @reflectiveTest
27 class ReferenceContributorTest extends DartCompletionContributorTest {
28 CompletionSuggestion assertSuggestFunction(String name, String returnType,
29 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
30 bool deprecated: false,
31 int relevance: DART_RELEVANCE_DEFAULT,
32 String importUri}) {
33 CompletionSuggestion cs = assertSuggest(name,
34 csKind: kind,
35 relevance: relevance,
36 importUri: importUri,
37 isDeprecated: deprecated);
38 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
39 protocol.Element element = cs.element;
40 expect(element, isNotNull);
41 expect(element.kind, equals(protocol.ElementKind.FUNCTION));
42 expect(element.name, equals(name));
43 expect(element.isDeprecated, equals(deprecated));
44 String param = element.parameters;
45 expect(param, isNotNull);
46 expect(param[0], equals('('));
47 expect(param[param.length - 1], equals(')'));
48 expect(element.returnType,
49 equals(returnType != null ? returnType : 'dynamic'));
50 assertHasParameterInfo(cs);
51 return cs;
52 }
53
54 CompletionSuggestion assertSuggestLocalFunction(
55 String name, String returnType,
56 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
57 bool deprecated: false,
58 int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) {
59 return assertSuggestFunction(name, returnType,
60 kind: kind, deprecated: deprecated, relevance: relevance);
61 }
62
63 @override
64 DartCompletionContributor createContributor() {
65 return new ReferenceContributor();
66 }
67
68 test_ArgumentList_InstanceCreationExpression_functionalArg() async {
69 // ArgumentList InstanceCreationExpression ExpressionStatement Block
70 addSource(
71 '/libA.dart',
72 '''
73 library A;
74 class A { A(f()) { } }
75 bool hasLength(int expected) { }
76 void baz() { }''');
77 addTestSource('''
78 import 'dart:async';
79 import '/libA.dart';
80 class B { }
81 String bar() => true;
82 void main() {new A(^)}''');
83 await computeSuggestions();
84 assertSuggestLocalFunction('bar', 'String',
85 kind: CompletionSuggestionKind.IDENTIFIER);
86 // assertSuggestImportedFunction('hasLength', 'bool',
87 // kind: CompletionSuggestionKind.IDENTIFIER);
88 // assertSuggestImportedFunction('identical', 'bool',
89 // kind: CompletionSuggestionKind.IDENTIFIER);
90 // assertSuggestLocalClass('B', kind: CompletionSuggestionKind.IDENTIFIER);
91 // assertSuggestImportedClass('A',
92 // kind: CompletionSuggestionKind.IDENTIFIER);
93 // assertSuggestImportedClass('Object',
94 // kind: CompletionSuggestionKind.IDENTIFIER);
95 // assertNotSuggested('main');
96 // assertNotSuggested('baz');
97 // assertNotSuggested('print');
98 }
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698