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

Side by Side Diff: pkg/analysis_testing/lib/abstract_single_unit.dart

Issue 498763003: Initial 'Extract Method' refactoring implementation. (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 library test.services.src.index.abstract_single_file; 5 library test.services.src.index.abstract_single_file;
6 6
7 import 'package:analysis_testing/abstract_context.dart'; 7 import 'package:analysis_testing/abstract_context.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 Element findNodeElementAtString(String search, 55 Element findNodeElementAtString(String search,
56 [Predicate<AstNode> predicate]) { 56 [Predicate<AstNode> predicate]) {
57 AstNode node = findNodeAtString(search, predicate); 57 AstNode node = findNodeAtString(search, predicate);
58 if (node == null) { 58 if (node == null) {
59 return null; 59 return null;
60 } 60 }
61 return ElementLocator.locate(node); 61 return ElementLocator.locate(node);
62 } 62 }
63 63
64 int findEnd(String search) {
65 return findOffset(search) + search.length;
66 }
67
64 int findOffset(String search) { 68 int findOffset(String search) {
65 int offset = testCode.indexOf(search); 69 int offset = testCode.indexOf(search);
66 expect(offset, isNonNegative, reason: "Not found '$search' in\n$testCode"); 70 expect(offset, isNonNegative, reason: "Not found '$search' in\n$testCode");
67 return offset; 71 return offset;
68 } 72 }
69 73
70 int getLeadingIdentifierLength(String search) { 74 int getLeadingIdentifierLength(String search) {
71 int length = 0; 75 int length = 0;
72 while (length < search.length) { 76 while (length < search.length) {
73 int c = search.codeUnitAt(length); 77 int c = search.codeUnitAt(length);
(...skipping 18 matching lines...) Expand all
92 testCode = code; 96 testCode = code;
93 testSource = addSource(testFile, code); 97 testSource = addSource(testFile, code);
94 testUnit = resolveLibraryUnit(testSource); 98 testUnit = resolveLibraryUnit(testSource);
95 if (verifyNoTestUnitErrors) { 99 if (verifyNoTestUnitErrors) {
96 assertNoErrorsInSource(testSource); 100 assertNoErrorsInSource(testSource);
97 } 101 }
98 testUnitElement = testUnit.element; 102 testUnitElement = testUnit.element;
99 testLibraryElement = testUnitElement.library; 103 testLibraryElement = testUnitElement.library;
100 } 104 }
101 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698