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

Side by Side Diff: pkg/analysis_server/test/services/correction/assist_test.dart

Issue 2140193003: Issue 26249. Quick Assist to convert final fields into getters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.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.correction.assist; 5 library test.services.correction.assist;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
10 import 'package:analysis_server/plugin/protocol/protocol.dart'; 10 import 'package:analysis_server/plugin/protocol/protocol.dart';
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 main(List<String> items) { 1762 main(List<String> items) {
1763 for (int k = 0; k < items.length; k++) { 1763 for (int k = 0; k < items.length; k++) {
1764 String item = items[k]; 1764 String item = items[k];
1765 print(item); 1765 print(item);
1766 int i = 0, j = 1; 1766 int i = 0, j = 1;
1767 } 1767 }
1768 } 1768 }
1769 '''); 1769 ''');
1770 } 1770 }
1771 1771
1772 test_convertToGetter_BAD_noInitializer() async {
1773 resolveTestUnit('''
1774 class A {
1775 final int foo;
1776 }
1777 ''');
1778 await assertNoAssistAt('foo', DartAssistKind.CONVERT_INTO_GETTER);
1779 }
1780
1781 test_convertToGetter_BAD_notFinal() async {
1782 resolveTestUnit('''
1783 class A {
1784 int foo = 1;
1785 }
1786 ''');
1787 await assertNoAssistAt('foo', DartAssistKind.CONVERT_INTO_GETTER);
1788 }
1789
1790 test_convertToGetter_BAD_notSingleField() async {
1791 resolveTestUnit('''
1792 class A {
1793 final int foo = 1, bar = 2;
1794 }
1795 ''');
1796 await assertNoAssistAt('foo', DartAssistKind.CONVERT_INTO_GETTER);
1797 }
1798
1799 test_convertToGetter_OK() async {
1800 resolveTestUnit('''
1801 const myAnnotation = const Object();
1802 class A {
1803 @myAnnotation
1804 final int foo = 1 + 2;
1805 }
1806 ''');
1807 await assertHasAssistAt(
1808 'foo =',
1809 DartAssistKind.CONVERT_INTO_GETTER,
1810 '''
1811 const myAnnotation = const Object();
1812 class A {
1813 @myAnnotation
1814 int get foo => 1 + 2;
1815 }
1816 ''');
1817 }
1818
1819 test_convertToGetter_OK_noType() async {
1820 resolveTestUnit('''
1821 class A {
1822 final foo = 42;
1823 }
1824 ''');
1825 await assertHasAssistAt(
1826 'foo =',
1827 DartAssistKind.CONVERT_INTO_GETTER,
1828 '''
1829 class A {
1830 get foo => 42;
1831 }
1832 ''');
1833 }
1834
1772 test_convertToIsNot_BAD_is_alreadyIsNot() async { 1835 test_convertToIsNot_BAD_is_alreadyIsNot() async {
1773 resolveTestUnit(''' 1836 resolveTestUnit('''
1774 main(p) { 1837 main(p) {
1775 p is! String; 1838 p is! String;
1776 } 1839 }
1777 '''); 1840 ''');
1778 await assertNoAssistAt('is!', DartAssistKind.CONVERT_INTO_IS_NOT); 1841 await assertNoAssistAt('is!', DartAssistKind.CONVERT_INTO_IS_NOT);
1779 } 1842 }
1780 1843
1781 test_convertToIsNot_BAD_is_noEnclosingParenthesis() async { 1844 test_convertToIsNot_BAD_is_noEnclosingParenthesis() async {
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
4120 positions.add(new Position(testFile, offset)); 4183 positions.add(new Position(testFile, offset));
4121 } 4184 }
4122 return positions; 4185 return positions;
4123 } 4186 }
4124 4187
4125 void _setStartEndSelection() { 4188 void _setStartEndSelection() {
4126 offset = findOffset('// start\n') + '// start\n'.length; 4189 offset = findOffset('// start\n') + '// start\n'.length;
4127 length = findOffset('// end') - offset; 4190 length = findOffset('// end') - offset;
4128 } 4191 }
4129 } 4192 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698