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

Side by Side Diff: pkg/analysis_services/lib/correction/assist.dart

Issue 484733003: Import analysis_services.dart into analysis_server.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
(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 services.correction.assist;
6
7 import 'package:analysis_services/correction/change.dart';
8 import 'package:analysis_services/search/search_engine.dart';
9 import 'package:analysis_services/src/correction/assist.dart';
10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/source.dart';
12
13
14 /**
15 * Computes [Assist]s at the given location.
16 *
17 * Returns the computed [Assist]s, not `null`.
18 */
19 List<Assist> computeAssists(SearchEngine searchEngine, CompilationUnit unit,
20 int offset, int length) {
21 Source source = unit.element.source;
22 String file = source.fullName;
23 AssistProcessor processor =
24 new AssistProcessor(searchEngine, source, file, unit, offset, length);
25 return processor.compute();
26 }
27
28
29 /**
30 * A description of a single proposed assist.
31 */
32 class Assist {
33 final AssistKind kind;
34 final Change change;
35
36 Assist(this.kind, this.change);
37
38 @override
39 String toString() {
40 return 'Assist(kind=$kind, change=$change)';
41 }
42 }
43
44
45 /**
46 * An enumeration of possible quick assist kinds.
47 */
48 class AssistKind {
49 static const ADD_PART_DIRECTIVE =
50 const AssistKind('ADD_PART_DIRECTIVE', 30, "Add 'part' directive");
51 static const ADD_TYPE_ANNOTATION =
52 const AssistKind('ADD_TYPE_ANNOTATION', 30, "Add type annotation");
53 static const ASSIGN_TO_LOCAL_VARIABLE =
54 const AssistKind(
55 'ASSIGN_TO_LOCAL_VARIABLE',
56 30,
57 "Assign value to new local variable");
58 static const CONVERT_INTO_BLOCK_BODY =
59 const AssistKind('CONVERT_INTO_BLOCK_BODY', 30, "Convert into block body") ;
60 static const CONVERT_INTO_EXPRESSION_BODY =
61 const AssistKind(
62 'CONVERT_INTO_EXPRESSION_BODY',
63 30,
64 "Convert into expression body");
65 static const CONVERT_INTO_IS_NOT =
66 const AssistKind('CONVERT_INTO_IS_NOT', 30, "Convert into is!");
67 static const CONVERT_INTO_IS_NOT_EMPTY =
68 const AssistKind('CONVERT_INTO_IS_NOT_EMPTY', 30, "Convert into 'isNotEmpt y'");
69 static const EXCHANGE_OPERANDS =
70 const AssistKind('EXCHANGE_OPERANDS', 30, "Exchange operands");
71 static const EXTRACT_CLASS =
72 const AssistKind('EXTRACT_CLASS', 30, "Extract class into file '{0}'");
73 static const IMPORT_ADD_SHOW =
74 const AssistKind('IMPORT_ADD_SHOW', 30, "Add explicit 'show' combinator");
75 static const INVERT_IF_STATEMENT =
76 const AssistKind('INVERT_IF_STATEMENT', 30, "Invert 'if' statement");
77 static const JOIN_IF_WITH_INNER =
78 const AssistKind(
79 'JOIN_IF_WITH_INNER',
80 30,
81 "Join 'if' statement with inner 'if' statement");
82 static const JOIN_IF_WITH_OUTER =
83 const AssistKind(
84 'JOIN_IF_WITH_OUTER',
85 30,
86 "Join 'if' statement with outer 'if' statement");
87 static const JOIN_VARIABLE_DECLARATION =
88 const AssistKind('JOIN_VARIABLE_DECLARATION', 30, "Join variable declarati on");
89 static const REMOVE_TYPE_ANNOTATION =
90 const AssistKind('REMOVE_TYPE_ANNOTATION', 29, "Remove type annotation");
91 static const REPLACE_CONDITIONAL_WITH_IF_ELSE =
92 const AssistKind(
93 'REPLACE_CONDITIONAL_WITH_IF_ELSE',
94 30,
95 "Replace conditional with 'if-else'");
96 static const REPLACE_IF_ELSE_WITH_CONDITIONAL =
97 const AssistKind(
98 'REPLACE_IF_ELSE_WITH_CONDITIONAL',
99 30,
100 "Replace 'if-else' with conditional ('c ? x : y')");
101 static const SPLIT_AND_CONDITION =
102 const AssistKind('SPLIT_AND_CONDITION', 30, "Split && condition");
103 static const SPLIT_VARIABLE_DECLARATION =
104 const AssistKind(
105 'SPLIT_VARIABLE_DECLARATION',
106 30,
107 "Split variable declaration");
108 static const SURROUND_WITH_BLOCK =
109 const AssistKind('SURROUND_WITH_BLOCK', 30, "Surround with block");
110 static const SURROUND_WITH_DO_WHILE =
111 const AssistKind('SURROUND_WITH_DO_WHILE', 30, "Surround with 'do-while'") ;
112 static const SURROUND_WITH_FOR =
113 const AssistKind('SURROUND_WITH_FOR', 30, "Surround with 'for'");
114 static const SURROUND_WITH_FOR_IN =
115 const AssistKind('SURROUND_WITH_FOR_IN', 30, "Surround with 'for-in'");
116 static const SURROUND_WITH_IF =
117 const AssistKind('SURROUND_WITH_IF', 30, "Surround with 'if'");
118 static const SURROUND_WITH_TRY_CATCH =
119 const AssistKind('SURROUND_WITH_TRY_CATCH', 30, "Surround with 'try-catch' ");
120 static const SURROUND_WITH_TRY_FINALLY =
121 const AssistKind(
122 'SURROUND_WITH_TRY_FINALLY',
123 30,
124 "Surround with 'try-finally'");
125 static const SURROUND_WITH_WHILE =
126 const AssistKind('SURROUND_WITH_WHILE', 30, "Surround with 'while'");
127
128 final name;
129 final int relevance;
130 final String message;
131
132 const AssistKind(this.name, this.relevance, this.message);
133
134 @override
135 String toString() => name;
136 }
OLDNEW
« no previous file with comments | « pkg/analysis_services/lib/constants.dart ('k') | pkg/analysis_services/lib/correction/change.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698