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

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

Issue 689433003: add class type alias suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/local_computer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 assertSuggest(CompletionSuggestionKind.CLASS, name, relevance); 105 assertSuggest(CompletionSuggestionKind.CLASS, name, relevance);
106 protocol.Element element = cs.element; 106 protocol.Element element = cs.element;
107 expect(element, isNotNull); 107 expect(element, isNotNull);
108 expect(element.kind, equals(protocol.ElementKind.CLASS)); 108 expect(element.kind, equals(protocol.ElementKind.CLASS));
109 expect(element.name, equals(name)); 109 expect(element.name, equals(name));
110 expect(element.parameters, isNull); 110 expect(element.parameters, isNull);
111 expect(element.returnType, isNull); 111 expect(element.returnType, isNull);
112 return cs; 112 return cs;
113 } 113 }
114 114
115 CompletionSuggestion assertSuggestClassTypeAlias(String name,
116 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) {
117 CompletionSuggestion cs =
118 assertSuggest(CompletionSuggestionKind.CLASS_ALIAS, name, relevance);
119 protocol.Element element = cs.element;
120 expect(element, isNotNull);
121 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS));
122 expect(element.name, equals(name));
123 expect(element.parameters, isNull);
124 expect(element.returnType, isNull);
125 return cs;
126 }
127
115 CompletionSuggestion assertSuggestFunction(String name, String returnType, 128 CompletionSuggestion assertSuggestFunction(String name, String returnType,
116 bool isDeprecated, [CompletionRelevance relevance = 129 bool isDeprecated, [CompletionRelevance relevance =
117 CompletionRelevance.DEFAULT]) { 130 CompletionRelevance.DEFAULT]) {
118 CompletionSuggestion cs = assertSuggest( 131 CompletionSuggestion cs = assertSuggest(
119 CompletionSuggestionKind.FUNCTION, 132 CompletionSuggestionKind.FUNCTION,
120 name, 133 name,
121 relevance, 134 relevance,
122 isDeprecated); 135 isDeprecated);
123 expect(cs.returnType, equals(returnType)); 136 expect(cs.returnType, equals(returnType));
124 protocol.Element element = cs.element; 137 protocol.Element element = cs.element;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 559
547 CompletionSuggestion assertSuggestLocalClass(String name, 560 CompletionSuggestion assertSuggestLocalClass(String name,
548 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 561 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) {
549 if (computer is LocalComputer) { 562 if (computer is LocalComputer) {
550 return assertSuggestClass(name, relevance); 563 return assertSuggestClass(name, relevance);
551 } else { 564 } else {
552 return assertNotSuggested(name); 565 return assertNotSuggested(name);
553 } 566 }
554 } 567 }
555 568
569 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name,
570 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) {
571 if (computer is LocalComputer) {
572 return assertSuggestClassTypeAlias(name, relevance);
573 } else {
574 return assertNotSuggested(name);
575 }
576 }
577
556 CompletionSuggestion assertSuggestLocalFunction(String name, 578 CompletionSuggestion assertSuggestLocalFunction(String name,
557 String returnType, [bool isDeprecated = false, CompletionRelevance relevan ce = 579 String returnType, [bool isDeprecated = false, CompletionRelevance relevan ce =
558 CompletionRelevance.DEFAULT]) { 580 CompletionRelevance.DEFAULT]) {
559 if (computer is LocalComputer) { 581 if (computer is LocalComputer) {
560 return assertSuggestFunction(name, returnType, isDeprecated, relevance); 582 return assertSuggestFunction(name, returnType, isDeprecated, relevance);
561 } else { 583 } else {
562 return assertNotSuggested(name); 584 return assertNotSuggested(name);
563 } 585 }
564 } 586 }
565 587
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 addSource('/testAB.dart', ''' 997 addSource('/testAB.dart', '''
976 library libAB; 998 library libAB;
977 part '/partAB.dart'; 999 part '/partAB.dart';
978 class A { } 1000 class A { }
979 class B { }'''); 1001 class B { }''');
980 addSource('/partAB.dart', ''' 1002 addSource('/partAB.dart', '''
981 part of libAB; 1003 part of libAB;
982 var T1; 1004 var T1;
983 PB F1() => new PB(); 1005 PB F1() => new PB();
984 typedef PB2 F2(int blat); 1006 typedef PB2 F2(int blat);
1007 class Clz = Object with Object;
985 class PB { }'''); 1008 class PB { }''');
986 addSource('/testCD.dart', ''' 1009 addSource('/testCD.dart', '''
987 class C { } 1010 class C { }
988 class D { }'''); 1011 class D { }''');
989 addTestSource(''' 1012 addTestSource('''
990 import "/testAB.dart" show ^; 1013 import "/testAB.dart" show ^;
991 import "/testCD.dart"; 1014 import "/testCD.dart";
992 class X {}'''); 1015 class X {}''');
993 computeFast(); 1016 computeFast();
994 return computeFull(true).then((_) { 1017 return computeFull(true).then((_) {
995 assertSuggestImportedClass('A'); 1018 assertSuggestImportedClass('A');
996 assertSuggestImportedClass('B'); 1019 assertSuggestImportedClass('B');
997 assertSuggestImportedClass('PB'); 1020 assertSuggestImportedClass('PB');
998 assertSuggestImportedTopLevelVar('T1', null); 1021 assertSuggestImportedTopLevelVar('T1', null);
999 assertSuggestImportedFunction('F1', 'PB'); 1022 assertSuggestImportedFunction('F1', 'PB');
1023 assertSuggestImportedClass('Clz');
1000 assertSuggestImportedFunctionTypeAlias('F2', null); 1024 assertSuggestImportedFunctionTypeAlias('F2', null);
1001 assertNotSuggested('C'); 1025 assertNotSuggested('C');
1002 assertNotSuggested('D'); 1026 assertNotSuggested('D');
1003 assertNotSuggested('X'); 1027 assertNotSuggested('X');
1004 assertNotSuggested('Object'); 1028 assertNotSuggested('Object');
1005 }); 1029 });
1006 } 1030 }
1007 1031
1008 test_ConstructorName_importedClass() { 1032 test_ConstructorName_importedClass() {
1009 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 1033 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 1073
1050 test_ExpressionStatement_identifier() { 1074 test_ExpressionStatement_identifier() {
1051 // SimpleIdentifier ExpressionStatement Block 1075 // SimpleIdentifier ExpressionStatement Block
1052 addSource('/testA.dart', ''' 1076 addSource('/testA.dart', '''
1053 _B F1() { } 1077 _B F1() { }
1054 class A {int x;} 1078 class A {int x;}
1055 class _B { }'''); 1079 class _B { }''');
1056 addTestSource(''' 1080 addTestSource('''
1057 import "/testA.dart"; 1081 import "/testA.dart";
1058 typedef int F2(int blat); 1082 typedef int F2(int blat);
1083 class Clz = Object with Object;
1059 class C {foo(){O^} void bar() {}}'''); 1084 class C {foo(){O^} void bar() {}}''');
1060 computeFast(); 1085 computeFast();
1061 return computeFull(true).then((_) { 1086 return computeFull(true).then((_) {
1062 assertSuggestImportedClass('A'); 1087 assertSuggestImportedClass('A');
1063 assertSuggestImportedFunction('F1', '_B', false); 1088 assertSuggestImportedFunction('F1', '_B', false);
1064 assertSuggestLocalClass('C'); 1089 assertSuggestLocalClass('C');
1065 assertSuggestLocalMethod('foo', 'C', null); 1090 assertSuggestLocalMethod('foo', 'C', null);
1066 assertSuggestLocalMethod('bar', 'C', 'void'); 1091 assertSuggestLocalMethod('bar', 'C', 'void');
1067 assertSuggestLocalFunctionTypeAlias('F2', 'int'); 1092 assertSuggestLocalFunctionTypeAlias('F2', 'int');
1093 assertSuggestLocalClassTypeAlias('Clz');
1068 assertSuggestLocalClass('C'); 1094 assertSuggestLocalClass('C');
1069 assertNotSuggested('x'); 1095 assertNotSuggested('x');
1070 assertNotSuggested('_B'); 1096 assertNotSuggested('_B');
1071 }); 1097 });
1072 } 1098 }
1073 1099
1074 test_ExpressionStatement_name() { 1100 test_ExpressionStatement_name() {
1075 // ExpressionStatement Block BlockFunctionBody MethodDeclaration 1101 // ExpressionStatement Block BlockFunctionBody MethodDeclaration
1076 addSource('/testA.dart', ''' 1102 addSource('/testA.dart', '''
1077 B T1; 1103 B T1;
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 assertNotSuggested('bar2'); 1795 assertNotSuggested('bar2');
1770 assertNotSuggested('_B'); 1796 assertNotSuggested('_B');
1771 assertSuggestLocalClass('Y'); 1797 assertSuggestLocalClass('Y');
1772 assertSuggestLocalClass('C'); 1798 assertSuggestLocalClass('C');
1773 assertSuggestLocalVariable('f', null); 1799 assertSuggestLocalVariable('f', null);
1774 assertNotSuggested('x'); 1800 assertNotSuggested('x');
1775 assertNotSuggested('e'); 1801 assertNotSuggested('e');
1776 }); 1802 });
1777 } 1803 }
1778 } 1804 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/local_computer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698