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

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

Issue 914373004: Use package: URIs for files in lib (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 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 import 'dart:math' show max; 9 import 'dart:math' show max;
10 10
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 /** 328 /**
329 * There was an error related to the socket from which requests are being 329 * There was an error related to the socket from which requests are being
330 * read. 330 * read.
331 */ 331 */
332 void error(argument) { 332 void error(argument) {
333 running = false; 333 running = false;
334 } 334 }
335 335
336 /** 336 /**
337 * Performs all scheduled analysis operations.
338 */
339 void test_performAllAnalysisOperations() {
340 while (true) {
341 ServerOperation operation = operationQueue.takeIf((operation) {
342 return operation is PerformAnalysisOperation;
343 });
344 if (operation == null) {
345 break;
346 }
347 operation.perform(this);
348 }
349 }
350
351 /**
352 * If the given notice applies to a file contained within an analysis root, 337 * If the given notice applies to a file contained within an analysis root,
353 * notify interested parties that the file has been (at least partially) 338 * notify interested parties that the file has been (at least partially)
354 * analyzed. 339 * analyzed.
355 */ 340 */
356 void fileAnalyzed(ChangeNotice notice) { 341 void fileAnalyzed(ChangeNotice notice) {
357 if (contextDirectoryManager.isInAnalysisRoot(notice.source.fullName)) { 342 if (contextDirectoryManager.isInAnalysisRoot(notice.source.fullName)) {
358 _onFileAnalyzedController.add(notice); 343 _onFileAnalyzedController.add(notice);
359 } 344 }
360 } 345 }
361 346
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 452 }
468 // prepare Source 453 // prepare Source
469 Source source = getSource(file); 454 Source source = getSource(file);
470 if (context.getKindOf(source) == SourceKind.UNKNOWN) { 455 if (context.getKindOf(source) == SourceKind.UNKNOWN) {
471 return null; 456 return null;
472 } 457 }
473 // get errors for the file 458 // get errors for the file
474 return context.getErrors(source); 459 return context.getErrors(source);
475 } 460 }
476 461
477 // TODO(brianwilkerson) Add the following method after 'prioritySources' has
478 // been added to InternalAnalysisContext.
479 // /**
480 // * Return a list containing the full names of all of the sources that are
481 // * priority sources.
482 // */
483 // List<String> getPriorityFiles() {
484 // List<String> priorityFiles = new List<String>();
485 // folderMap.values.forEach((ContextDirectory directory) {
486 // InternalAnalysisContext context = directory.context;
487 // context.prioritySources.forEach((Source source) {
488 // priorityFiles.add(source.fullName);
489 // });
490 // });
491 // return priorityFiles;
492 // }
493
494 /** 462 /**
495 * Returns resolved [AstNode]s at the given [offset] of the given [file]. 463 * Returns resolved [AstNode]s at the given [offset] of the given [file].
496 * 464 *
497 * May be empty, but not `null`. 465 * May be empty, but not `null`.
498 */ 466 */
499 List<AstNode> getNodesAtOffset(String file, int offset) { 467 List<AstNode> getNodesAtOffset(String file, int offset) {
500 List<CompilationUnit> units = getResolvedCompilationUnits(file); 468 List<CompilationUnit> units = getResolvedCompilationUnits(file);
501 List<AstNode> nodes = <AstNode>[]; 469 List<AstNode> nodes = <AstNode>[];
502 for (CompilationUnit unit in units) { 470 for (CompilationUnit unit in units) {
503 AstNode node = new NodeLocator.con1(offset).searchWithin(unit); 471 AstNode node = new NodeLocator.con1(offset).searchWithin(unit);
504 if (node != null) { 472 if (node != null) {
505 nodes.add(node); 473 nodes.add(node);
506 } 474 }
507 } 475 }
508 return nodes; 476 return nodes;
509 } 477 }
510 478
479 // TODO(brianwilkerson) Add the following method after 'prioritySources' has
480 // been added to InternalAnalysisContext.
481 // /**
482 // * Return a list containing the full names of all of the sources that are
483 // * priority sources.
484 // */
485 // List<String> getPriorityFiles() {
486 // List<String> priorityFiles = new List<String>();
487 // folderMap.values.forEach((ContextDirectory directory) {
488 // InternalAnalysisContext context = directory.context;
489 // context.prioritySources.forEach((Source source) {
490 // priorityFiles.add(source.fullName);
491 // });
492 // });
493 // return priorityFiles;
494 // }
495
511 /** 496 /**
512 * Returns resolved [CompilationUnit]s of the Dart file with the given [path]. 497 * Returns resolved [CompilationUnit]s of the Dart file with the given [path].
513 * 498 *
514 * May be empty, but not `null`. 499 * May be empty, but not `null`.
515 */ 500 */
516 List<CompilationUnit> getResolvedCompilationUnits(String path) { 501 List<CompilationUnit> getResolvedCompilationUnits(String path) {
517 List<CompilationUnit> units = <CompilationUnit>[]; 502 List<CompilationUnit> units = <CompilationUnit>[];
518 // prepare AnalysisContext 503 // prepare AnalysisContext
519 AnalysisContext context = getAnalysisContext(path); 504 AnalysisContext context = getAnalysisContext(path);
520 if (context == null) { 505 if (context == null) {
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 void test_flushResolvedUnit(String file) { 943 void test_flushResolvedUnit(String file) {
959 if (AnalysisEngine.isDartFileName(file)) { 944 if (AnalysisEngine.isDartFileName(file)) {
960 AnalysisContextImpl context = getAnalysisContext(file); 945 AnalysisContextImpl context = getAnalysisContext(file);
961 Source source = getSource(file); 946 Source source = getSource(file);
962 DartEntry dartEntry = context.getReadableSourceEntryOrNull(source); 947 DartEntry dartEntry = context.getReadableSourceEntryOrNull(source);
963 dartEntry.flushAstStructures(); 948 dartEntry.flushAstStructures();
964 } 949 }
965 } 950 }
966 951
967 /** 952 /**
953 * Performs all scheduled analysis operations.
954 */
955 void test_performAllAnalysisOperations() {
956 while (true) {
957 ServerOperation operation = operationQueue.takeIf((operation) {
958 return operation is PerformAnalysisOperation;
959 });
960 if (operation == null) {
961 break;
962 }
963 operation.perform(this);
964 }
965 }
966
967 /**
968 * Implementation for `analysis.updateContent`. 968 * Implementation for `analysis.updateContent`.
969 */ 969 */
970 void updateContent(String id, Map<String, dynamic> changes) { 970 void updateContent(String id, Map<String, dynamic> changes) {
971 changes.forEach((file, change) { 971 changes.forEach((file, change) {
972 Source source = getSource(file); 972 Source source = getSource(file);
973 operationQueue.sourceAboutToChange(source); 973 operationQueue.sourceAboutToChange(source);
974 // Prepare the new contents. 974 // Prepare the new contents.
975 String oldContents = _overlayState.getContents(source); 975 String oldContents = _overlayState.getContents(source);
976 String newContents; 976 String newContents;
977 if (change is AddContentOverlay) { 977 if (change is AddContentOverlay) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 new StreamController<ContextsChangedEvent>.broadcast(); 1158 new StreamController<ContextsChangedEvent>.broadcast();
1159 } 1159 }
1160 1160
1161 /** 1161 /**
1162 * The stream that is notified when contexts are added or removed. 1162 * The stream that is notified when contexts are added or removed.
1163 */ 1163 */
1164 Stream<ContextsChangedEvent> get onContextsChanged => 1164 Stream<ContextsChangedEvent> get onContextsChanged =>
1165 _onContextsChangedController.stream; 1165 _onContextsChangedController.stream;
1166 1166
1167 @override 1167 @override
1168 void addContext(Folder folder, UriResolver packageUriResolver) { 1168 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver) {
1169 InternalAnalysisContext context = 1169 InternalAnalysisContext context =
1170 AnalysisEngine.instance.createAnalysisContext(); 1170 AnalysisEngine.instance.createAnalysisContext();
1171 context.contentCache = analysisServer._overlayState; 1171 context.contentCache = analysisServer._overlayState;
1172 analysisServer.folderMap[folder] = context; 1172 analysisServer.folderMap[folder] = context;
1173 context.sourceFactory = _createSourceFactory(packageUriResolver); 1173 context.sourceFactory = _createSourceFactory(packageUriResolver);
1174 context.analysisOptions = new AnalysisOptionsImpl.con1(defaultOptions); 1174 context.analysisOptions = new AnalysisOptionsImpl.con1(defaultOptions);
1175 _onContextsChangedController.add( 1175 _onContextsChangedController.add(
1176 new ContextsChangedEvent(added: [context])); 1176 new ContextsChangedEvent(added: [context]));
1177 analysisServer.schedulePerformAnalysisOperation(context); 1177 analysisServer.schedulePerformAnalysisOperation(context);
1178 return context;
1178 } 1179 }
1179 1180
1180 @override 1181 @override
1181 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { 1182 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) {
1182 AnalysisContext context = analysisServer.folderMap[contextFolder]; 1183 AnalysisContext context = analysisServer.folderMap[contextFolder];
1183 if (context != null) { 1184 if (context != null) {
1184 context.applyChanges(changeSet); 1185 context.applyChanges(changeSet);
1185 analysisServer.schedulePerformAnalysisOperation(context); 1186 analysisServer.schedulePerformAnalysisOperation(context);
1186 } 1187 }
1187 } 1188 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 new DateTime.now().millisecondsSinceEpoch - 1286 new DateTime.now().millisecondsSinceEpoch -
1286 request.clientRequestTime; 1287 request.clientRequestTime;
1287 requestLatency += latency; 1288 requestLatency += latency;
1288 maxLatency = max(maxLatency, latency); 1289 maxLatency = max(maxLatency, latency);
1289 if (latency > 150) { 1290 if (latency > 150) {
1290 ++slowRequestCount; 1291 ++slowRequestCount;
1291 } 1292 }
1292 } 1293 }
1293 } 1294 }
1294 } 1295 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/context_manager.dart » ('j') | pkg/analysis_server/lib/src/context_manager.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698