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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/abstract_refactoring.dart

Issue 485083004: Make RefactoringStatus a collection of generated RefactoringProblems. (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.refactoring; 5 library test.services.refactoring;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol2.dart'; 9 import 'package:analysis_server/src/protocol2.dart';
10 import 'package:analysis_server/src/services/correction/change.dart'; 10 import 'package:analysis_server/src/services/correction/change.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return refactoring.checkFinalConditions().then((status) { 54 return refactoring.checkFinalConditions().then((status) {
55 assertRefactoringStatusOK(status); 55 assertRefactoringStatusOK(status);
56 }); 56 });
57 }); 57 });
58 } 58 }
59 59
60 /** 60 /**
61 * Asserts that [status] has expected severity and message. 61 * Asserts that [status] has expected severity and message.
62 */ 62 */
63 void assertRefactoringStatus(RefactoringStatus status, 63 void assertRefactoringStatus(RefactoringStatus status,
64 RefactoringStatusSeverity expectedSeverity, {String expectedMessage, 64 RefactoringProblemSeverity expectedSeverity, {String expectedMessage,
65 SourceRange expectedContextRange, String expectedContextSearch}) { 65 SourceRange expectedContextRange, String expectedContextSearch}) {
66 expect(status.severity, expectedSeverity, reason: status.message); 66 expect(status.severity, expectedSeverity, reason: status.toString());
67 if (expectedSeverity != RefactoringStatusSeverity.OK) { 67 if (expectedSeverity != null) {
68 RefactoringStatusEntry entry = status.entryWithHighestSeverity; 68 RefactoringProblem problem = status.problem;
69 expect(entry.severity, expectedSeverity); 69 expect(problem.severity, expectedSeverity);
70 if (expectedMessage != null) { 70 if (expectedMessage != null) {
71 expect(entry.message, expectedMessage); 71 expect(problem.message, expectedMessage);
72 } 72 }
73 if (expectedContextRange != null) { 73 if (expectedContextRange != null) {
74 expect(entry.context.range, expectedContextRange); 74 expect(problem.location.offset, expectedContextRange.offset);
75 expect(problem.location.length, expectedContextRange.length);
75 } 76 }
76 if (expectedContextSearch != null) { 77 if (expectedContextSearch != null) {
77 SourceRange contextRange = entry.context.range;
78 int expectedOffset = findOffset(expectedContextSearch); 78 int expectedOffset = findOffset(expectedContextSearch);
79 int expectedLength = findIdentifierLength(expectedContextSearch); 79 int expectedLength = findIdentifierLength(expectedContextSearch);
80 expect(contextRange.offset, expectedOffset); 80 expect(problem.location.offset, expectedOffset);
81 expect(contextRange.length, expectedLength); 81 expect(problem.location.length, expectedLength);
82 } 82 }
83 } 83 }
84 } 84 }
85 85
86 /** 86 /**
87 * Asserts that [refactoring] status is OK. 87 * Asserts that [refactoring] status is OK.
88 */ 88 */
89 void assertRefactoringStatusOK(RefactoringStatus status) { 89 void assertRefactoringStatusOK(RefactoringStatus status) {
90 assertRefactoringStatus(status, RefactoringStatusSeverity.OK); 90 assertRefactoringStatus(status, null);
91 } 91 }
92 92
93 /** 93 /**
94 * Asserts that [refactoringChange] contains a [FileEdit] for [testFile], and 94 * Asserts that [refactoringChange] contains a [FileEdit] for [testFile], and
95 * it results the [expectedCode]. 95 * it results the [expectedCode].
96 */ 96 */
97 void assertTestChangeResult(String expectedCode) { 97 void assertTestChangeResult(String expectedCode) {
98 // prepare FileEdit 98 // prepare FileEdit
99 SourceFileEdit fileEdit = refactoringChange.getFileEdit(testFile); 99 SourceFileEdit fileEdit = refactoringChange.getFileEdit(testFile);
100 expect(fileEdit, isNotNull); 100 expect(fileEdit, isNotNull);
(...skipping 12 matching lines...) Expand all
113 CompilationUnit unit = resolveLibraryUnit(source); 113 CompilationUnit unit = resolveLibraryUnit(source);
114 index.indexUnit(context, unit); 114 index.indexUnit(context, unit);
115 } 115 }
116 116
117 void setUp() { 117 void setUp() {
118 super.setUp(); 118 super.setUp();
119 index = createLocalMemoryIndex(); 119 index = createLocalMemoryIndex();
120 searchEngine = new SearchEngineImpl(index); 120 searchEngine = new SearchEngineImpl(index);
121 } 121 }
122 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698