Skip to content

Commit d918ac1

Browse files
scheglovCommit Queue
authored andcommitted
Completion. Cache 'inConstantContext' value.
For package:collection, computing measures. Before: 0:01:00.236000 After: 0:00:55.977000 So, about 7% faster. I think this translates into actual completion speed up. Change-Id: I45f0c0186d5988e6e1b043d465030668cd61335b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357982 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 1473c30 commit d918ac1

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ class DartCompletionRequest {
290290

291291
bool _aborted = false;
292292

293+
/// Return `true` if the completion is occurring in a constant context.
294+
late final bool inConstantContext = () {
295+
var entity = target.entity;
296+
return entity is Expression && entity.inConstantContext;
297+
}();
298+
293299
factory DartCompletionRequest({
294300
required AnalysisSession analysisSession,
295301
required String filePath,
@@ -387,12 +393,6 @@ class DartCompletionRequest {
387393
return opType.includeIdentifiers;
388394
}
389395

390-
/// Return `true` if the completion is occurring in a constant context.
391-
bool get inConstantContext {
392-
var entity = target.entity;
393-
return entity is Expression && entity.inConstantContext;
394-
}
395-
396396
InheritanceManager3 get inheritanceManager {
397397
return analysisSession.inheritanceManager;
398398
}

pkg/analysis_server/tool/code_completion/completion_metrics_base.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ abstract class CompletionMetricsComputer {
120120
final results = <ResolvedUnitResult>[];
121121
final pathContext = context.contextRoot.resourceProvider.pathContext;
122122
for (final filePath in context.contextRoot.analyzedFiles()) {
123+
if (file_paths.isGenerated(filePath) ||
124+
filePath.endsWith('animated_icons.dart') ||
125+
filePath.endsWith('animated_icons_data.dart')) {
126+
continue;
127+
}
123128
if (file_paths.isDart(pathContext, filePath)) {
124129
try {
125130
final result = await context.currentSession.getResolvedUnit(filePath)

0 commit comments

Comments
 (0)