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

Side by Side Diff: pkg/analysis_services/lib/src/correction/statement_analyzer.dart

Issue 458063002: Initial work on refactorings. (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
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library services.src.correction.statement_analyzer; 8 library services.src.correction.statement_analyzer;
9 9
10 import 'package:analysis_services/correction/status.dart';
10 import 'package:analysis_services/src/correction/selection_analyzer.dart'; 11 import 'package:analysis_services/src/correction/selection_analyzer.dart';
11 import 'package:analysis_services/src/correction/source_range.dart'; 12 import 'package:analysis_services/src/correction/source_range.dart';
12 import 'package:analysis_services/src/correction/util.dart'; 13 import 'package:analysis_services/src/correction/util.dart';
13 import 'package:analyzer/src/generated/ast.dart'; 14 import 'package:analyzer/src/generated/ast.dart';
14 import 'package:analyzer/src/generated/element.dart'; 15 import 'package:analyzer/src/generated/element.dart';
15 import 'package:analyzer/src/generated/scanner.dart'; 16 import 'package:analyzer/src/generated/scanner.dart';
16 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
17 18
18 19
19 /** 20 /**
20 * Returns [Token]s of the given Dart source, not `null`, may be empty if no 21 * Returns [Token]s of the given Dart source, not `null`, may be empty if no
21 * tokens or some exception happens. 22 * tokens or some exception happens.
22 */ 23 */
23 List<Token> _getTokens(String text) { 24 List<Token> _getTokens(String text) {
24 try { 25 try {
25 List<Token> tokens = <Token>[]; 26 List<Token> tokens = <Token>[];
26 Scanner scanner = new Scanner(null, new CharSequenceReader(text), null); 27 Scanner scanner = new Scanner(null, new CharSequenceReader(text), null);
27 Token token = scanner.tokenize(); 28 Token token = scanner.tokenize();
28 while (token.type != TokenType.EOF) { 29 while (token.type != TokenType.EOF) {
29 tokens.add(token); 30 tokens.add(token);
30 token = token.next; 31 token = token.next;
31 } 32 }
32 return tokens; 33 return tokens;
33 } catch (e) { 34 } catch (e) {
34 return new List<Token>(0); 35 return new List<Token>(0);
35 } 36 }
36 } 37 }
37 38
38 /**
39 * TODO(scheglov) port the real class
40 */
41 class RefactoringStatus {
42 bool get hasFatalError => false;
43
44 void addFatalError(String message, RefactoringStatusContext context) {
45 }
46 }
47
48 /**
49 * TODO(scheglov) port the real class
50 */
51 class RefactoringStatusContext {
52 RefactoringStatusContext.forUnit(CompilationUnit unit, SourceRange range);
53 }
54
55 39
56 /** 40 /**
57 * Analyzer to check if a selection covers a valid set of statements of AST. 41 * Analyzer to check if a selection covers a valid set of statements of AST.
58 */ 42 */
59 class StatementAnalyzer extends SelectionAnalyzer { 43 class StatementAnalyzer extends SelectionAnalyzer {
60 final CompilationUnit unit; 44 final CompilationUnit unit;
61 45
62 RefactoringStatus _status = new RefactoringStatus(); 46 RefactoringStatus _status = new RefactoringStatus();
63 47
64 StatementAnalyzer(this.unit, SourceRange selection) : super(selection); 48 StatementAnalyzer(this.unit, SourceRange selection) : super(selection);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 */ 227 */
244 static bool _containsAny(List<AstNode> nodes, List<AstNode> otherNodes) { 228 static bool _containsAny(List<AstNode> nodes, List<AstNode> otherNodes) {
245 for (AstNode otherNode in otherNodes) { 229 for (AstNode otherNode in otherNodes) {
246 if (nodes.contains(otherNode)) { 230 if (nodes.contains(otherNode)) {
247 return true; 231 return true;
248 } 232 }
249 } 233 }
250 return false; 234 return false;
251 } 235 }
252 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698