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

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

Issue 956103002: Add instrumentation (issue 22572) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 context.directory.manager; 5 library context.directory.manager;
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_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
11 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/instrumentation/instrumentation.dart';
12 import 'package:analyzer/source/package_map_provider.dart'; 13 import 'package:analyzer/source/package_map_provider.dart';
13 import 'package:analyzer/source/package_map_resolver.dart'; 14 import 'package:analyzer/source/package_map_resolver.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 15 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/java_io.dart'; 16 import 'package:analyzer/src/generated/java_io.dart';
16 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
17 import 'package:analyzer/src/generated/source_io.dart'; 18 import 'package:analyzer/src/generated/source_io.dart';
18 import 'package:path/path.dart' as pathos; 19 import 'package:path/path.dart' as pathos;
19 import 'package:watcher/watcher.dart'; 20 import 'package:watcher/watcher.dart';
20 21
21 22
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 * and non-folders have been removed. 80 * and non-folders have been removed.
80 */ 81 */
81 Map<String, String> normalizedPackageRoots = <String, String>{}; 82 Map<String, String> normalizedPackageRoots = <String, String>{};
82 83
83 /** 84 /**
84 * Provider which is used to determine the mapping from package name to 85 * Provider which is used to determine the mapping from package name to
85 * package folder. 86 * package folder.
86 */ 87 */
87 final PackageMapProvider _packageMapProvider; 88 final PackageMapProvider _packageMapProvider;
88 89
89 ContextManager(this.resourceProvider, this._packageMapProvider) { 90 /**
91 * The instrumentation service used to report instrumentation data.
92 */
93 final InstrumentationService _instrumentationService;
94
95 ContextManager(this.resourceProvider, this._packageMapProvider,
96 this._instrumentationService) {
90 pathContext = resourceProvider.pathContext; 97 pathContext = resourceProvider.pathContext;
91 } 98 }
92 99
93 /** 100 /**
94 * Create and return a new analysis context. 101 * Create and return a new analysis context.
95 */ 102 */
96 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver); 103 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver);
97 104
98 /** 105 /**
99 * Called when the set of files associated with a context have changed (or 106 * Called when the set of files associated with a context have changed (or
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 folder, 360 folder,
354 pubspecFile, 361 pubspecFile,
355 children, 362 children,
356 normalizedPackageRoots[folder.path]); 363 normalizedPackageRoots[folder.path]);
357 _contexts[folder] = info; 364 _contexts[folder] = info;
358 info.changeSubscription = folder.changes.listen((WatchEvent event) { 365 info.changeSubscription = folder.changes.listen((WatchEvent event) {
359 _handleWatchEvent(folder, info, event); 366 _handleWatchEvent(folder, info, event);
360 }); 367 });
361 UriResolver packageUriResolver = _computePackageUriResolver(folder, info); 368 UriResolver packageUriResolver = _computePackageUriResolver(folder, info);
362 info.context = addContext(folder, packageUriResolver); 369 info.context = addContext(folder, packageUriResolver);
370 info.context.name = folder.path;
363 return info; 371 return info;
364 } 372 }
365 373
366 /** 374 /**
367 * Creates a new context associated with [folder]. 375 * Creates a new context associated with [folder].
368 * 376 *
369 * If there are subfolders with 'pubspec.yaml' files, separate contexts 377 * If there are subfolders with 'pubspec.yaml' files, separate contexts
370 * are created for them, and excluded from the context associated with 378 * are created for them, and excluded from the context associated with
371 * [folder]. 379 * [folder].
372 * 380 *
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 ChangeSet changeSet = new ChangeSet(); 461 ChangeSet changeSet = new ChangeSet();
454 extractedSources.forEach((path, source) { 462 extractedSources.forEach((path, source) {
455 oldInfo.sources.remove(path); 463 oldInfo.sources.remove(path);
456 changeSet.removedSource(source); 464 changeSet.removedSource(source);
457 }); 465 });
458 applyChangesToContext(oldInfo.folder, changeSet); 466 applyChangesToContext(oldInfo.folder, changeSet);
459 } 467 }
460 } 468 }
461 469
462 void _handleWatchEvent(Folder folder, _ContextInfo info, WatchEvent event) { 470 void _handleWatchEvent(Folder folder, _ContextInfo info, WatchEvent event) {
471 _instrumentationService.logWatchEvent(
472 folder.path,
473 event.path,
474 event.type.toString());
463 String path = event.path; 475 String path = event.path;
464 // maybe excluded globally 476 // maybe excluded globally
465 if (_isExcluded(path)) { 477 if (_isExcluded(path)) {
466 return; 478 return;
467 } 479 }
468 // maybe excluded from the context, so other context will handle it 480 // maybe excluded from the context, so other context will handle it
469 if (info.excludes(path)) { 481 if (info.excludes(path)) {
470 return; 482 return;
471 } 483 }
472 // handle the change 484 // handle the change
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 return excludes(resource.path); 714 return excludes(resource.path);
703 } 715 }
704 716
705 /** 717 /**
706 * Returns `true` if [path] is the pubspec file of this context. 718 * Returns `true` if [path] is the pubspec file of this context.
707 */ 719 */
708 bool isPubspec(String path) { 720 bool isPubspec(String path) {
709 return path == pubspecPath; 721 return path == pubspecPath;
710 } 722 }
711 } 723 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/test/context_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698