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

Unified Diff: pkg/analysis_server/test/edit/fixes_test.dart

Issue 494153003: Return only fixes for the errors on the line of the given offset. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.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/edit/fixes_test.dart
diff --git a/pkg/analysis_server/test/edit/fixes_test.dart b/pkg/analysis_server/test/edit/fixes_test.dart
index 808cd87984b9aa9f1ade5f3cd5ab93f5910beb8c..8b4852514c8f2311c36caeb2836c0f4ad2e360f7 100644
--- a/pkg/analysis_server/test/edit/fixes_test.dart
+++ b/pkg/analysis_server/test/edit/fixes_test.dart
@@ -32,24 +32,47 @@ class FixesTest extends AbstractAnalysisTest {
Future test_hasFixes() {
addTestFile('''
-main() {
- print(42)
+foo() {
+ print(1)
+}
+bar() {
+ print(10) print(20)
}
''');
return waitForTasksFinished().then((_) {
- Request request = new EditGetFixesParams(testFile,
- findOffset('print')).toRequest('0');
- Response response = handleSuccessfulRequest(request);
- var result = new EditGetFixesResult.fromResponse(response);
- List<ErrorFixes> errorFixes = result.fixes;
- expect(errorFixes, hasLength(1));
+ // print(1)
+ {
+ List<ErrorFixes> errorFixes = _getFixesAt('print(1)');
+ expect(errorFixes, hasLength(1));
+ _isSyntacticErrorWithSingleFix(errorFixes[0]);
+ }
+ // print(10)
{
- ErrorFixes fixes = errorFixes[0];
- AnalysisError error = fixes.error;
- expect(error.severity, ErrorSeverity.ERROR);
- expect(error.type, ErrorType.SYNTACTIC_ERROR);
- expect(fixes.fixes, hasLength(1));
+ List<ErrorFixes> errorFixes = _getFixesAt('print(10)');
+ expect(errorFixes, hasLength(2));
+ _isSyntacticErrorWithSingleFix(errorFixes[0]);
+ _isSyntacticErrorWithSingleFix(errorFixes[1]);
}
});
}
+
+ void _isSyntacticErrorWithSingleFix(ErrorFixes fixes) {
+ AnalysisError error = fixes.error;
+ expect(error.severity, ErrorSeverity.ERROR);
+ expect(error.type, ErrorType.SYNTACTIC_ERROR);
+ expect(fixes.fixes, hasLength(1));
+ }
+
+ List<ErrorFixes> _getFixesAt(String search) {
+ int offset = findOffset(search);
+ return _getFixes(offset);
+ }
+
+
+ List<ErrorFixes> _getFixes(int offset) {
+ Request request = new EditGetFixesParams(testFile, offset).toRequest('0');
+ Response response = handleSuccessfulRequest(request);
+ var result = new EditGetFixesResult.fromResponse(response);
+ return result.fixes;
+ }
}
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698