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

Side by Side Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 339933006: Fix for subscribing for notifications after analysis. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « no previous file | pkg/analysis_server/test/analysis_notification_navigation_test.dart » ('j') | 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 analysis.server; 5 library analysis.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/analysis_logger.dart'; 10 import 'package:analysis_server/src/analysis_logger.dart';
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 subscriptions.forEach((service, Set<String> newFiles) { 391 subscriptions.forEach((service, Set<String> newFiles) {
392 Set<String> oldFiles = analysisServices[service]; 392 Set<String> oldFiles = analysisServices[service];
393 Set<String> todoFiles = oldFiles != null ? newFiles.difference(oldFiles) : newFiles; 393 Set<String> todoFiles = oldFiles != null ? newFiles.difference(oldFiles) : newFiles;
394 for (String file in todoFiles) { 394 for (String file in todoFiles) {
395 if (service == AnalysisService.ERRORS) { 395 if (service == AnalysisService.ERRORS) {
396 Source source = _getSource(file); 396 Source source = _getSource(file);
397 AnalysisContext analysisContext = _getAnalysisContext(file); 397 AnalysisContext analysisContext = _getAnalysisContext(file);
398 List<AnalysisError> errors = analysisContext.getErrors(source).errors; 398 List<AnalysisError> errors = analysisContext.getErrors(source).errors;
399 sendAnalysisNotificationErrors(this, file, errors); 399 sendAnalysisNotificationErrors(this, file, errors);
400 } 400 }
401 // TODO(scheglov) 401 // Dart unit notifications.
402 // 1. implement resolveCompilationUnit() 402 if (AnalysisEngine.isDartFileName(file)) {
403 // 2. Share "if (dartUnit != null)" 403 CompilationUnit dartUnit = resolveCompilationUnit(file);
Brian Wilkerson 2014/06/18 16:25:11 I think we need to only get the compilation unit i
scheglov 2014/06/18 17:38:27 Agree. Done.
404 if (service == AnalysisService.HIGHLIGHTS) {
405 CompilationUnit dartUnit = test_getResolvedCompilationUnit(file);
406 if (dartUnit != null) { 404 if (dartUnit != null) {
407 sendAnalysisNotificationHighlights(this, file, dartUnit); 405 switch (service) {
408 } 406 case AnalysisService.HIGHLIGHTS:
409 } 407 sendAnalysisNotificationHighlights(this, file, dartUnit);
410 if (service == AnalysisService.NAVIGATION) { 408 break;
411 CompilationUnit dartUnit = test_getResolvedCompilationUnit(file); 409 case AnalysisService.NAVIGATION:
412 if (dartUnit != null) { 410 sendAnalysisNotificationNavigation(this, file, dartUnit);
413 sendAnalysisNotificationNavigation(this, file, dartUnit); 411 break;
414 } 412 case AnalysisService.OUTLINE:
415 } 413 sendAnalysisNotificationOutline(this, file, dartUnit);
416 if (service == AnalysisService.OUTLINE) { 414 break;
417 CompilationUnit dartUnit = test_getResolvedCompilationUnit(file); 415 }
418 if (dartUnit != null) {
419 sendAnalysisNotificationOutline(this, file, dartUnit);
420 } 416 }
421 } 417 }
422 } 418 }
423 }); 419 });
424 // remember new subscriptions 420 // remember new subscriptions
425 this.analysisServices = subscriptions; 421 this.analysisServices = subscriptions;
426 } 422 }
427 423
428 /** 424 /**
429 * Return the [AnalysisContext] that is used to analyze the given [path]. 425 * Return the [AnalysisContext] that is used to analyze the given [path].
(...skipping 13 matching lines...) Expand all
443 */ 439 */
444 Source _getSource(String path) { 440 Source _getSource(String path) {
445 File file = contextDirectoryManager.resourceProvider.getResource(path); 441 File file = contextDirectoryManager.resourceProvider.getResource(path);
446 return file.createSource(UriKind.FILE_URI); 442 return file.createSource(UriKind.FILE_URI);
447 } 443 }
448 444
449 /** 445 /**
450 * Return the [CompilationUnit] of the Dart file with the given [path]. 446 * Return the [CompilationUnit] of the Dart file with the given [path].
451 * Return `null` if the file is not a part of any context. 447 * Return `null` if the file is not a part of any context.
452 */ 448 */
449 CompilationUnit resolveCompilationUnit(String path) {
450 // prepare AnalysisContext
451 AnalysisContext context = _getAnalysisContext(path);
452 if (context == null) {
453 return null;
454 }
455 // prepare sources
456 Source unitSource = _getSource(path);
457 List<Source> librarySources = context.getLibrariesContaining(unitSource);
458 if (librarySources.isEmpty) {
459 return null;
460 }
461 // resolve the unit
462 return context.resolveCompilationUnit2(unitSource, librarySources[0]);
Brian Wilkerson 2014/06/18 16:25:11 We need to handle the case where a file is in more
scheglov 2014/06/18 17:38:27 AFAIK multiple libraries matter only for navigatio
463 }
464
465 /**
466 * Return the [CompilationUnit] of the Dart file with the given [path].
467 * Return `null` if the file is not a part of any context.
468 */
453 CompilationUnit test_getResolvedCompilationUnit(String path) { 469 CompilationUnit test_getResolvedCompilationUnit(String path) {
454 // prepare AnalysisContext 470 // prepare AnalysisContext
455 AnalysisContext context = _getAnalysisContext(path); 471 AnalysisContext context = _getAnalysisContext(path);
456 if (context == null) { 472 if (context == null) {
457 return null; 473 return null;
458 } 474 }
459 // prepare sources 475 // prepare sources
460 Source unitSource = _getSource(path); 476 Source unitSource = _getSource(path);
461 List<Source> librarySources = context.getLibrariesContaining(unitSource); 477 List<Source> librarySources = context.getLibrariesContaining(unitSource);
462 if (librarySources.isEmpty) { 478 if (librarySources.isEmpty) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 /** 594 /**
579 * An enumeration of the services provided by the server domain. 595 * An enumeration of the services provided by the server domain.
580 */ 596 */
581 class ServerService extends Enum2<ServerService> { 597 class ServerService extends Enum2<ServerService> {
582 static const ServerService STATUS = const ServerService('STATUS', 0); 598 static const ServerService STATUS = const ServerService('STATUS', 0);
583 599
584 static const List<ServerService> VALUES = const [STATUS]; 600 static const List<ServerService> VALUES = const [STATUS];
585 601
586 const ServerService(String name, int ordinal) : super(name, ordinal); 602 const ServerService(String name, int ordinal) : super(name, ordinal);
587 } 603 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_notification_navigation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698