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

Side by Side Diff: pkg/analysis_server/test/domain_analysis_test.dart

Issue 398513002: Fix for NPE if subscribing for errors in a not analyzed file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.domain.analysis; 5 library test.domain.analysis;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/computer/element.dart'; 10 import 'package:analysis_server/src/computer/element.dart';
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 expect(highlights, isEmpty); 318 expect(highlights, isEmpty);
319 // subscribe 319 // subscribe
320 helper.addAnalysisSubscriptionHighlights(helper.testFile); 320 helper.addAnalysisSubscriptionHighlights(helper.testFile);
321 // wait, has regions 321 // wait, has regions
322 return helper.waitForOperationsFinished().then((_) { 322 return helper.waitForOperationsFinished().then((_) {
323 var highlights = helper.getHighlights(helper.testFile); 323 var highlights = helper.getHighlights(helper.testFile);
324 expect(highlights, isNot(isEmpty)); 324 expect(highlights, isNot(isEmpty));
325 }); 325 });
326 }); 326 });
327 }); 327 });
328
329 test('after analysis, no such file', () {
330 AnalysisTestHelper helper = new AnalysisTestHelper();
331 helper.createSingleFileProject('int V = 42;');
332 return helper.waitForOperationsFinished().then((_) {
333 String noFile = '/no-such.file.dart';
334 helper.addAnalysisSubscriptionErrors(noFile);
335 return helper.waitForOperationsFinished().then((_) {
336 var errors = helper.getErrors(noFile);
337 expect(errors, isEmpty);
338 });
339 });
340 });
328 } 341 }
329 342
330 343
331 int _getSafeInt(Map<String, Object> json, String key, int defaultValue) { 344 int _getSafeInt(Map<String, Object> json, String key, int defaultValue) {
332 Object value = json[key]; 345 Object value = json[key];
333 if (value is int) { 346 if (value is int) {
334 return value; 347 return value;
335 } 348 }
336 return defaultValue; 349 return defaultValue;
337 } 350 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 files = <String>[]; 490 files = <String>[];
478 analysisSubscriptions[service.name] = files; 491 analysisSubscriptions[service.name] = files;
479 } 492 }
480 files.add(file); 493 files.add(file);
481 // set subscriptions 494 // set subscriptions
482 Request request = new Request('0', ANALYSIS_SET_SUBSCRIPTIONS); 495 Request request = new Request('0', ANALYSIS_SET_SUBSCRIPTIONS);
483 request.setParameter(SUBSCRIPTIONS, analysisSubscriptions); 496 request.setParameter(SUBSCRIPTIONS, analysisSubscriptions);
484 handleSuccessfulRequest(request); 497 handleSuccessfulRequest(request);
485 } 498 }
486 499
500 void addAnalysisSubscriptionErrors(String file) {
501 addAnalysisSubscription(AnalysisService.ERRORS, file);
502 }
503
487 void addAnalysisSubscriptionHighlights(String file) { 504 void addAnalysisSubscriptionHighlights(String file) {
488 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, file); 505 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, file);
489 } 506 }
490 507
491 void addAnalysisSubscriptionNavigation(String file) { 508 void addAnalysisSubscriptionNavigation(String file) {
492 addAnalysisSubscription(AnalysisService.NAVIGATION, file); 509 addAnalysisSubscription(AnalysisService.NAVIGATION, file);
493 } 510 }
494 511
495 /** 512 /**
496 * Creates an empty project `/project`. 513 * Creates an empty project `/project`.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 return waitForServerOperationsPerformed(server); 643 return waitForServerOperationsPerformed(server);
627 } 644 }
628 645
629 static String _getCodeString(code) { 646 static String _getCodeString(code) {
630 if (code is List<String>) { 647 if (code is List<String>) {
631 code = code.join('\n'); 648 code = code.join('\n');
632 } 649 }
633 return code as String; 650 return code as String;
634 } 651 }
635 } 652 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698