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

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

Issue 862803008: fix completion in for statement (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 10 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 | Annotate | Revision Log
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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 }); 1846 });
1847 } 1847 }
1848 1848
1849 test_ForEachStatement_body_typed() { 1849 test_ForEachStatement_body_typed() {
1850 // Block ForEachStatement 1850 // Block ForEachStatement
1851 addTestSource('main(args) {for (int foo in bar) {^}}'); 1851 addTestSource('main(args) {for (int foo in bar) {^}}');
1852 computeFast(); 1852 computeFast();
1853 return computeFull((bool result) { 1853 return computeFull((bool result) {
1854 expect(request.replacementOffset, completionOffset); 1854 expect(request.replacementOffset, completionOffset);
1855 expect(request.replacementLength, 0); 1855 expect(request.replacementLength, 0);
1856 assertSuggestParameter('args', null);
1856 assertSuggestLocalVariable('foo', 'int'); 1857 assertSuggestLocalVariable('foo', 'int');
1857 assertSuggestImportedClass('Object'); 1858 assertSuggestImportedClass('Object');
1858 }); 1859 });
1859 } 1860 }
1860 1861
1861 test_ForEachStatement_body_untyped() { 1862 test_ForEachStatement_body_untyped() {
1862 // Block ForEachStatement 1863 // Block ForEachStatement
1863 addTestSource('main(args) {for (foo in bar) {^}}'); 1864 addTestSource('main(args) {for (foo in bar) {^}}');
1864 computeFast(); 1865 computeFast();
1865 return computeFull((bool result) { 1866 return computeFull((bool result) {
1866 expect(request.replacementOffset, completionOffset); 1867 expect(request.replacementOffset, completionOffset);
1867 expect(request.replacementLength, 0); 1868 expect(request.replacementLength, 0);
1869 assertSuggestParameter('args', null);
1868 assertSuggestLocalVariable('foo', null); 1870 assertSuggestLocalVariable('foo', null);
1869 assertSuggestImportedClass('Object'); 1871 assertSuggestImportedClass('Object');
1870 }); 1872 });
1871 } 1873 }
1872 1874
1875 test_ForEachStatement_iterable() {
1876 // SimpleIdentifier ForEachStatement Block
1877 addTestSource('main(args) {for (int foo in ^) {}}');
1878 computeFast();
1879 return computeFull((bool result) {
1880 expect(request.replacementOffset, completionOffset);
1881 expect(request.replacementLength, 0);
1882 assertSuggestParameter('args', null);
1883 assertSuggestImportedClass('Object');
1884 });
1885 }
1886
1887 test_ForEachStatement_loopVariable() {
1888 // SimpleIdentifier ForEachStatement Block
1889 addTestSource('main(args) {for (^ in args) {}}');
1890 computeFast();
1891 return computeFull((bool result) {
1892 expect(request.replacementOffset, completionOffset);
1893 expect(request.replacementLength, 0);
1894 assertNotSuggested('args');
1895 assertSuggestImportedClass('String');
1896 });
1897 }
1898
1899 test_ForEachStatement_loopVariable_type() {
1900 // SimpleIdentifier ForEachStatement Block
1901 addTestSource('main(args) {for (^ foo in args) {}}');
1902 computeFast();
1903 return computeFull((bool result) {
1904 expect(request.replacementOffset, completionOffset);
1905 expect(request.replacementLength, 0);
1906 assertNotSuggested('args');
1907 assertNotSuggested('foo');
1908 assertSuggestImportedClass('String');
1909 });
1910 }
1911
1912 test_ForEachStatement_loopVariable_type2() {
1913 // DeclaredIdentifier ForEachStatement Block
1914 addTestSource('main(args) {for (S^ foo in args) {}}');
1915 computeFast();
1916 return computeFull((bool result) {
1917 expect(request.replacementOffset, completionOffset - 1);
1918 expect(request.replacementLength, 1);
1919 assertNotSuggested('args');
1920 assertNotSuggested('foo');
1921 assertSuggestImportedClass('String');
1922 });
1923 }
1924
1873 test_FormalParameterList() { 1925 test_FormalParameterList() {
1874 // FormalParameterList MethodDeclaration 1926 // FormalParameterList MethodDeclaration
1875 addTestSource(''' 1927 addTestSource('''
1876 foo() { } 1928 foo() { }
1877 void bar() { } 1929 void bar() { }
1878 class A {a(^) { }}'''); 1930 class A {a(^) { }}''');
1879 computeFast(); 1931 computeFast();
1880 return computeFull((bool result) { 1932 return computeFull((bool result) {
1881 expect(request.replacementOffset, completionOffset); 1933 expect(request.replacementOffset, completionOffset);
1882 expect(request.replacementLength, 0); 1934 expect(request.replacementLength, 0);
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 assertNotSuggested('bar2'); 2947 assertNotSuggested('bar2');
2896 assertNotSuggested('_B'); 2948 assertNotSuggested('_B');
2897 assertSuggestLocalClass('Y'); 2949 assertSuggestLocalClass('Y');
2898 assertSuggestLocalClass('C'); 2950 assertSuggestLocalClass('C');
2899 assertSuggestLocalVariable('f', null); 2951 assertSuggestLocalVariable('f', null);
2900 assertNotSuggested('x'); 2952 assertNotSuggested('x');
2901 assertNotSuggested('e'); 2953 assertNotSuggested('e');
2902 }); 2954 });
2903 } 2955 }
2904 } 2956 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698