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

Unified Diff: pkg/analysis_server/lib/src/services/completion/completion_manager.dart

Issue 867023002: cache completion performance by default (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/domain_completion.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/completion_manager.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
index 308b8bb4aee590a9d92ef277c6d71149dba0f1e0..4861199f154e02b1110acd6e1b2fc7df79d0d7d6 100644
--- a/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/completion_manager.dart
@@ -121,8 +121,7 @@ class CompletionPerformance {
final List<OperationPerformance> operations = <OperationPerformance>[];
Source source;
- int offset;
- String contents;
+ String snippet = '';
int notificationCount = -1;
int suggestionCountFirst = -1;
int suggestionCountLast = -1;
@@ -132,37 +131,16 @@ class CompletionPerformance {
_stopwatch.start();
}
+ void setContentsAndOffset(String contents, int offset) {
+ snippet = _computeSnippet(contents, offset);
+ }
+
int get elapsedInMilliseconds =>
operations.length > 0 ? operations.last.elapsed.inMilliseconds : 0;
int get firstNotificationInMilliseconds =>
_firstNotification != null ? _firstNotification.inMilliseconds : 0;
- String get snippet {
- if (contents == null || offset < 0 || contents.length < offset) {
- return '???';
- }
- int start = offset;
- while (start > 0) {
- String ch = contents[start - 1];
- if (ch == '\r' || ch == '\n') {
- break;
- }
- --start;
- }
- int end = offset;
- while (end < contents.length) {
- String ch = contents[end];
- if (ch == '\r' || ch == '\n') {
- break;
- }
- ++end;
- }
- String prefix = contents.substring(start, offset);
- String suffix = contents.substring(offset, end);
- return '$prefix^$suffix';
- }
-
String get startTimeAndMs => '${start.millisecondsSinceEpoch} - $start';
String get suggestionCount {
@@ -207,6 +185,31 @@ class CompletionPerformance {
void _logDuration(String tag, Duration elapsed) {
operations.add(new OperationPerformance(tag, elapsed));
}
+
+ static String _computeSnippet(String contents, int offset) {
+ if (contents == null || offset == null || offset < 0 || contents.length < offset) {
+ return '???';
+ }
+ int start = offset;
+ while (start > 0) {
+ String ch = contents[start - 1];
+ if (ch == '\r' || ch == '\n') {
+ break;
+ }
+ --start;
+ }
+ int end = offset;
+ while (end < contents.length) {
+ String ch = contents[end];
+ if (ch == '\r' || ch == '\n') {
+ break;
+ }
+ ++end;
+ }
+ String prefix = contents.substring(start, offset);
+ String suffix = contents.substring(offset, end);
+ return '$prefix^$suffix';
+ }
}
/**
« no previous file with comments | « pkg/analysis_server/lib/src/domain_completion.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698