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

Unified Diff: pkg/analysis_server/test/services/refactoring/inline_local_test.dart

Issue 533273003: Use unit + offset as 'Inline Local' arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/refactoring.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/refactoring/inline_local_test.dart
diff --git a/pkg/analysis_server/test/services/refactoring/inline_local_test.dart b/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
index bd167524cb9cd97cafc616c84839d36ac764a52f..6c7d37ee8b62b10a36b7f4e67f1118ee5a726416 100644
--- a/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
@@ -5,13 +5,12 @@
library test.services.refactoring.inline_local;
import 'package:analysis_server/src/protocol.dart' hide Element;
+import 'package:analysis_server/src/services/correction/status.dart';
import 'package:analysis_server/src/services/refactoring/inline_local.dart';
import 'package:analysis_server/src/services/refactoring/refactoring.dart';
-import '../../reflective_tests.dart';
-import 'package:analyzer/src/generated/ast.dart';
-import 'package:analyzer/src/generated/element.dart';
import 'package:unittest/unittest.dart';
+import '../../reflective_tests.dart';
import 'abstract_refactoring.dart';
@@ -199,6 +198,28 @@ main() {
});
}
+ test_bad_selectionMethod() {
+ indexTestUnit(r'''
+main() {
+}
+''');
+ _createRefactoring('main() {');
+ return refactoring.checkInitialConditions().then((status) {
+ _assert_fatalError_selection(status);
+ });
+ }
+
+ test_bad_selectionParameter() {
+ indexTestUnit(r'''
+main(int test) {
+}
+''');
+ _createRefactoring('test) {');
+ return refactoring.checkInitialConditions().then((status) {
+ _assert_fatalError_selection(status);
+ });
+ }
+
test_bad_selectionVariable_hasAssignments_1() {
indexTestUnit(r'''
main() {
@@ -256,9 +277,16 @@ main() {
});
}
+ void _assert_fatalError_selection(RefactoringStatus status) {
+ assertRefactoringStatus(
+ status,
+ RefactoringProblemSeverity.FATAL,
+ expectedMessage: 'Local variable declaration or reference must be '
+ 'selected to activate this refactoring.');
+ }
+
void _createRefactoring(String search) {
- SimpleIdentifier identifier = findIdentifier(search);
- LocalVariableElement element = identifier.bestElement;
- refactoring = new InlineLocalRefactoring(searchEngine, testUnit, element);
+ int offset = findOffset(search);
+ refactoring = new InlineLocalRefactoring(searchEngine, testUnit, offset);
}
}
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/refactoring.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698