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

Side by Side Diff: pkg/analysis_server/lib/src/services/correction/assist.dart

Issue 618833003: Add 'Introduce new local with cast type' quick assist. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | 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 services.correction.assist; 5 library services.correction.assist;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/correction/assist_internal.dart';
8 import 'package:analysis_server/src/services/search/search_engine.dart'; 9 import 'package:analysis_server/src/services/search/search_engine.dart';
9 import 'package:analysis_server/src/services/correction/assist_internal.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
12 12
13 13
14 /** 14 /**
15 * Computes [Assist]s at the given location. 15 * Computes [Assist]s at the given location.
16 * 16 *
17 * Returns the computed [Assist]s, not `null`. 17 * Returns the computed [Assist]s, not `null`.
18 */ 18 */
19 List<Assist> computeAssists(SearchEngine searchEngine, CompilationUnit unit, 19 List<Assist> computeAssists(SearchEngine searchEngine, CompilationUnit unit,
(...skipping 23 matching lines...) Expand all
43 43
44 44
45 /** 45 /**
46 * An enumeration of possible quick assist kinds. 46 * An enumeration of possible quick assist kinds.
47 */ 47 */
48 class AssistKind { 48 class AssistKind {
49 static const ADD_PART_DIRECTIVE = 49 static const ADD_PART_DIRECTIVE =
50 const AssistKind('ADD_PART_DIRECTIVE', 30, "Add 'part' directive"); 50 const AssistKind('ADD_PART_DIRECTIVE', 30, "Add 'part' directive");
51 static const ADD_TYPE_ANNOTATION = 51 static const ADD_TYPE_ANNOTATION =
52 const AssistKind('ADD_TYPE_ANNOTATION', 30, "Add type annotation"); 52 const AssistKind('ADD_TYPE_ANNOTATION', 30, "Add type annotation");
53 static const ASSIGN_TO_LOCAL_VARIABLE = 53 static const ASSIGN_TO_LOCAL_VARIABLE = const AssistKind(
54 const AssistKind( 54 'ASSIGN_TO_LOCAL_VARIABLE',
55 'ASSIGN_TO_LOCAL_VARIABLE', 55 30,
56 30, 56 "Assign value to new local variable");
57 "Assign value to new local variable");
58 static const CONVERT_INTO_BLOCK_BODY = 57 static const CONVERT_INTO_BLOCK_BODY =
59 const AssistKind('CONVERT_INTO_BLOCK_BODY', 30, "Convert into block body") ; 58 const AssistKind('CONVERT_INTO_BLOCK_BODY', 30, "Convert into block body") ;
60 static const CONVERT_INTO_EXPRESSION_BODY = 59 static const CONVERT_INTO_EXPRESSION_BODY = const AssistKind(
61 const AssistKind( 60 'CONVERT_INTO_EXPRESSION_BODY',
62 'CONVERT_INTO_EXPRESSION_BODY', 61 30,
63 30, 62 "Convert into expression body");
64 "Convert into expression body");
65 static const CONVERT_INTO_IS_NOT = 63 static const CONVERT_INTO_IS_NOT =
66 const AssistKind('CONVERT_INTO_IS_NOT', 30, "Convert into is!"); 64 const AssistKind('CONVERT_INTO_IS_NOT', 30, "Convert into is!");
67 static const CONVERT_INTO_IS_NOT_EMPTY = 65 static const CONVERT_INTO_IS_NOT_EMPTY =
68 const AssistKind('CONVERT_INTO_IS_NOT_EMPTY', 30, "Convert into 'isNotEmpt y'"); 66 const AssistKind('CONVERT_INTO_IS_NOT_EMPTY', 30, "Convert into 'isNotEmpt y'");
69 static const EXCHANGE_OPERANDS = 67 static const EXCHANGE_OPERANDS =
70 const AssistKind('EXCHANGE_OPERANDS', 30, "Exchange operands"); 68 const AssistKind('EXCHANGE_OPERANDS', 30, "Exchange operands");
71 static const EXTRACT_CLASS = 69 static const EXTRACT_CLASS =
72 const AssistKind('EXTRACT_CLASS', 30, "Extract class into file '{0}'"); 70 const AssistKind('EXTRACT_CLASS', 30, "Extract class into file '{0}'");
73 static const IMPORT_ADD_SHOW = 71 static const IMPORT_ADD_SHOW =
74 const AssistKind('IMPORT_ADD_SHOW', 30, "Add explicit 'show' combinator"); 72 const AssistKind('IMPORT_ADD_SHOW', 30, "Add explicit 'show' combinator");
73 static const INTRODUCE_LOCAL_CAST_TYPE = const AssistKind(
74 'INTRODUCE_LOCAL_CAST_TYPE',
75 30,
76 "Introduce new local with cast type");
Paul Berry 2014/09/30 20:34:46 I think this terminology may be confusing to Dart
scheglov 2014/09/30 20:44:06 Done.
75 static const INVERT_IF_STATEMENT = 77 static const INVERT_IF_STATEMENT =
76 const AssistKind('INVERT_IF_STATEMENT', 30, "Invert 'if' statement"); 78 const AssistKind('INVERT_IF_STATEMENT', 30, "Invert 'if' statement");
77 static const JOIN_IF_WITH_INNER = 79 static const JOIN_IF_WITH_INNER = const AssistKind(
78 const AssistKind( 80 'JOIN_IF_WITH_INNER',
79 'JOIN_IF_WITH_INNER', 81 30,
80 30, 82 "Join 'if' statement with inner 'if' statement");
81 "Join 'if' statement with inner 'if' statement"); 83 static const JOIN_IF_WITH_OUTER = const AssistKind(
82 static const JOIN_IF_WITH_OUTER = 84 'JOIN_IF_WITH_OUTER',
83 const AssistKind( 85 30,
84 'JOIN_IF_WITH_OUTER', 86 "Join 'if' statement with outer 'if' statement");
85 30,
86 "Join 'if' statement with outer 'if' statement");
87 static const JOIN_VARIABLE_DECLARATION = 87 static const JOIN_VARIABLE_DECLARATION =
88 const AssistKind('JOIN_VARIABLE_DECLARATION', 30, "Join variable declarati on"); 88 const AssistKind('JOIN_VARIABLE_DECLARATION', 30, "Join variable declarati on");
89 static const REMOVE_TYPE_ANNOTATION = 89 static const REMOVE_TYPE_ANNOTATION =
90 const AssistKind('REMOVE_TYPE_ANNOTATION', 29, "Remove type annotation"); 90 const AssistKind('REMOVE_TYPE_ANNOTATION', 29, "Remove type annotation");
91 static const REPLACE_CONDITIONAL_WITH_IF_ELSE = 91 static const REPLACE_CONDITIONAL_WITH_IF_ELSE = const AssistKind(
92 const AssistKind( 92 'REPLACE_CONDITIONAL_WITH_IF_ELSE',
93 'REPLACE_CONDITIONAL_WITH_IF_ELSE', 93 30,
94 30, 94 "Replace conditional with 'if-else'");
95 "Replace conditional with 'if-else'"); 95 static const REPLACE_IF_ELSE_WITH_CONDITIONAL = const AssistKind(
96 static const REPLACE_IF_ELSE_WITH_CONDITIONAL = 96 'REPLACE_IF_ELSE_WITH_CONDITIONAL',
97 const AssistKind( 97 30,
98 'REPLACE_IF_ELSE_WITH_CONDITIONAL', 98 "Replace 'if-else' with conditional ('c ? x : y')");
99 30,
100 "Replace 'if-else' with conditional ('c ? x : y')");
101 static const SPLIT_AND_CONDITION = 99 static const SPLIT_AND_CONDITION =
102 const AssistKind('SPLIT_AND_CONDITION', 30, "Split && condition"); 100 const AssistKind('SPLIT_AND_CONDITION', 30, "Split && condition");
103 static const SPLIT_VARIABLE_DECLARATION = 101 static const SPLIT_VARIABLE_DECLARATION = const AssistKind(
104 const AssistKind( 102 'SPLIT_VARIABLE_DECLARATION',
105 'SPLIT_VARIABLE_DECLARATION', 103 30,
106 30, 104 "Split variable declaration");
107 "Split variable declaration");
108 static const SURROUND_WITH_BLOCK = 105 static const SURROUND_WITH_BLOCK =
109 const AssistKind('SURROUND_WITH_BLOCK', 30, "Surround with block"); 106 const AssistKind('SURROUND_WITH_BLOCK', 30, "Surround with block");
110 static const SURROUND_WITH_DO_WHILE = 107 static const SURROUND_WITH_DO_WHILE =
111 const AssistKind('SURROUND_WITH_DO_WHILE', 30, "Surround with 'do-while'") ; 108 const AssistKind('SURROUND_WITH_DO_WHILE', 30, "Surround with 'do-while'") ;
112 static const SURROUND_WITH_FOR = 109 static const SURROUND_WITH_FOR =
113 const AssistKind('SURROUND_WITH_FOR', 30, "Surround with 'for'"); 110 const AssistKind('SURROUND_WITH_FOR', 30, "Surround with 'for'");
114 static const SURROUND_WITH_FOR_IN = 111 static const SURROUND_WITH_FOR_IN =
115 const AssistKind('SURROUND_WITH_FOR_IN', 30, "Surround with 'for-in'"); 112 const AssistKind('SURROUND_WITH_FOR_IN', 30, "Surround with 'for-in'");
116 static const SURROUND_WITH_IF = 113 static const SURROUND_WITH_IF =
117 const AssistKind('SURROUND_WITH_IF', 30, "Surround with 'if'"); 114 const AssistKind('SURROUND_WITH_IF', 30, "Surround with 'if'");
118 static const SURROUND_WITH_TRY_CATCH = 115 static const SURROUND_WITH_TRY_CATCH =
119 const AssistKind('SURROUND_WITH_TRY_CATCH', 30, "Surround with 'try-catch' "); 116 const AssistKind('SURROUND_WITH_TRY_CATCH', 30, "Surround with 'try-catch' ");
120 static const SURROUND_WITH_TRY_FINALLY = 117 static const SURROUND_WITH_TRY_FINALLY = const AssistKind(
121 const AssistKind( 118 'SURROUND_WITH_TRY_FINALLY',
122 'SURROUND_WITH_TRY_FINALLY', 119 30,
123 30, 120 "Surround with 'try-finally'");
124 "Surround with 'try-finally'");
125 static const SURROUND_WITH_WHILE = 121 static const SURROUND_WITH_WHILE =
126 const AssistKind('SURROUND_WITH_WHILE', 30, "Surround with 'while'"); 122 const AssistKind('SURROUND_WITH_WHILE', 30, "Surround with 'while'");
127 123
128 final name; 124 final name;
129 final int relevance; 125 final int relevance;
130 final String message; 126 final String message;
131 127
132 const AssistKind(this.name, this.relevance, this.message); 128 const AssistKind(this.name, this.relevance, this.message);
133 129
134 @override 130 @override
135 String toString() => name; 131 String toString() => name;
136 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698