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

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

Issue 899753004: Send notificatinos after no-op changes. (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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return; 582 return;
583 } 583 }
584 } 584 }
585 channel.sendResponse(new Response.unknownRequest(request)); 585 channel.sendResponse(new Response.unknownRequest(request));
586 }, onError: (exception, stackTrace) { 586 }, onError: (exception, stackTrace) {
587 sendServerErrorNotification(exception, stackTrace, fatal: true); 587 sendServerErrorNotification(exception, stackTrace, fatal: true);
588 }); 588 });
589 } 589 }
590 590
591 /** 591 /**
592 * Returns `true` if there is a subscription for the given [server] and [file] . 592 * Returns `true` if there is a subscription for the given [service] and
593 * [file].
593 */ 594 */
594 bool hasAnalysisSubscription(AnalysisService service, String file) { 595 bool hasAnalysisSubscription(AnalysisService service, String file) {
595 Set<String> files = analysisServices[service]; 596 Set<String> files = analysisServices[service];
596 return files != null && files.contains(file); 597 return files != null && files.contains(file);
597 } 598 }
598 599
599 /** 600 /**
600 * Return `true` if analysis is complete. 601 * Return `true` if analysis is complete.
601 */ 602 */
602 bool isAnalysisComplete() { 603 bool isAnalysisComplete() {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // Instruct the contextDirectoryManager to rebuild all contexts from 693 // Instruct the contextDirectoryManager to rebuild all contexts from
693 // scratch. 694 // scratch.
694 contextDirectoryManager.refresh(); 695 contextDirectoryManager.refresh();
695 } 696 }
696 697
697 /** 698 /**
698 * Schedules execution of the given [ServerOperation]. 699 * Schedules execution of the given [ServerOperation].
699 */ 700 */
700 void scheduleOperation(ServerOperation operation) { 701 void scheduleOperation(ServerOperation operation) {
701 addOperation(operation); 702 addOperation(operation);
702 if (!performOperationPending) { 703 _schedulePerformOperation();
703 _schedulePerformOperation();
704 }
705 } 704 }
706 705
707 /** 706 /**
708 * Schedules analysis of the given context. 707 * Schedules analysis of the given context.
709 */ 708 */
710 void schedulePerformAnalysisOperation(AnalysisContext context) { 709 void schedulePerformAnalysisOperation(AnalysisContext context) {
711 _onAnalysisStartedController.add(context); 710 _onAnalysisStartedController.add(context);
712 scheduleOperation(new PerformAnalysisOperation(context, false)); 711 scheduleOperation(new PerformAnalysisOperation(context, false));
713 } 712 }
714 713
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 index.stop(); 921 index.stop();
923 } 922 }
924 // Defer closing the channel and shutting down the instrumentation server so 923 // Defer closing the channel and shutting down the instrumentation server so
925 // that the shutdown response can be sent and logged. 924 // that the shutdown response can be sent and logged.
926 new Future(() { 925 new Future(() {
927 instrumentationService.shutdown(); 926 instrumentationService.shutdown();
928 channel.close(); 927 channel.close();
929 }); 928 });
930 } 929 }
931 930
931 void test_flushResolvedUnit(String file) {
932 if (AnalysisEngine.isDartFileName(file)) {
933 AnalysisContextImpl context = getAnalysisContext(file);
934 Source source = getSource(file);
935 DartEntry dartEntry = context.getReadableSourceEntryOrNull(source);
936 dartEntry.flushAstStructures();
937 }
938 }
939
932 /** 940 /**
933 * Implementation for `analysis.updateContent`. 941 * Implementation for `analysis.updateContent`.
934 */ 942 */
935 void updateContent(String id, Map<String, dynamic> changes) { 943 void updateContent(String id, Map<String, dynamic> changes) {
936 changes.forEach((file, change) { 944 changes.forEach((file, change) {
937 Source source = getSource(file); 945 Source source = getSource(file);
938 String oldContents = _overlayState.getContents(source); 946 String oldContents = _overlayState.getContents(source);
939 String newContents; 947 String newContents;
940 if (change is AddContentOverlay) { 948 if (change is AddContentOverlay) {
941 newContents = change.content; 949 newContents = change.content;
(...skipping 18 matching lines...) Expand all
960 RequestErrorCode.INVALID_OVERLAY_CHANGE, 968 RequestErrorCode.INVALID_OVERLAY_CHANGE,
961 'Invalid overlay change'))); 969 'Invalid overlay change')));
962 } 970 }
963 } else if (change is RemoveContentOverlay) { 971 } else if (change is RemoveContentOverlay) {
964 newContents = null; 972 newContents = null;
965 } else { 973 } else {
966 // Protocol parsing should have ensured that we never get here. 974 // Protocol parsing should have ensured that we never get here.
967 throw new AnalysisException('Illegal change type'); 975 throw new AnalysisException('Illegal change type');
968 } 976 }
969 _overlayState.setContents(source, newContents); 977 _overlayState.setContents(source, newContents);
978 // Update all contexts.
970 for (InternalAnalysisContext context in folderMap.values) { 979 for (InternalAnalysisContext context in folderMap.values) {
971 if (context.handleContentsChanged( 980 if (context.handleContentsChanged(
972 source, 981 source,
973 oldContents, 982 oldContents,
974 newContents, 983 newContents,
975 true)) { 984 true)) {
976 schedulePerformAnalysisOperation(context); 985 schedulePerformAnalysisOperation(context);
986 } else {
987 // When the client sends any change for a source, we should resend
988 // subscribed notifications, even if there were no changes in the
989 // source contents.
990 // TODO(scheglov) consider checking if there are subscriptions.
991 if (AnalysisEngine.isDartFileName(file)) {
992 CompilationUnit dartUnit =
993 context.ensureAnyResolvedDartUnit(source);
994 if (dartUnit != null) {
995 AnalysisErrorInfo errorInfo = context.getErrors(source);
996 scheduleNotificationOperations(
997 this,
998 file,
999 errorInfo.lineInfo,
1000 context,
1001 null,
1002 dartUnit,
1003 errorInfo.errors);
1004 } else {
1005 schedulePerformAnalysisOperation(context);
1006 }
1007 }
977 } 1008 }
978 } 1009 }
979 }); 1010 });
980 } 1011 }
981 1012
982 /** 1013 /**
983 * Use the given updaters to update the values of the options in every 1014 * Use the given updaters to update the values of the options in every
984 * existing analysis context. 1015 * existing analysis context.
985 */ 1016 */
986 void updateOptions(List<OptionUpdater> optionUpdaters) { 1017 void updateOptions(List<OptionUpdater> optionUpdaters) {
(...skipping 14 matching lines...) Expand all
1001 AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions; 1032 AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions;
1002 optionUpdaters.forEach((OptionUpdater optionUpdater) { 1033 optionUpdaters.forEach((OptionUpdater optionUpdater) {
1003 optionUpdater(options); 1034 optionUpdater(options);
1004 }); 1035 });
1005 } 1036 }
1006 1037
1007 /** 1038 /**
1008 * Schedules [performOperation] exection. 1039 * Schedules [performOperation] exection.
1009 */ 1040 */
1010 void _schedulePerformOperation() { 1041 void _schedulePerformOperation() {
1011 assert(!performOperationPending); 1042 if (performOperationPending) {
1043 return;
1044 }
1012 /* 1045 /*
1013 * TODO (danrubel) Rip out this workaround once the underlying problem 1046 * TODO (danrubel) Rip out this workaround once the underlying problem
1014 * is fixed. Currently, the VM and dart:io do not deliver content 1047 * is fixed. Currently, the VM and dart:io do not deliver content
1015 * on stdin in a timely manner if the event loop is busy. 1048 * on stdin in a timely manner if the event loop is busy.
1016 * To work around this problem, we delay for 1 millisecond 1049 * To work around this problem, we delay for 1 millisecond
1017 * every 25 milliseconds. 1050 * every 25 milliseconds.
1018 * 1051 *
1019 * To disable this workaround and see the underlying problem, 1052 * To disable this workaround and see the underlying problem,
1020 * set performOperationDelayFreqency to zero 1053 * set performOperationDelayFreqency to zero
1021 */ 1054 */
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 new DateTime.now().millisecondsSinceEpoch - 1257 new DateTime.now().millisecondsSinceEpoch -
1225 request.clientRequestTime; 1258 request.clientRequestTime;
1226 requestLatency += latency; 1259 requestLatency += latency;
1227 maxLatency = max(maxLatency, latency); 1260 maxLatency = max(maxLatency, latency);
1228 if (latency > 150) { 1261 if (latency > 150) {
1229 ++slowRequestCount; 1262 ++slowRequestCount;
1230 } 1263 }
1231 } 1264 }
1232 } 1265 }
1233 } 1266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698