Skip to content

Commit

Permalink
Version 3.5.0-82.0.dev
Browse files Browse the repository at this point in the history
Merge 0a1cad1 into dev
  • Loading branch information
Dart CI committed Apr 20, 2024
2 parents d882ce0 + 0a1cad1 commit 95e0894
Show file tree
Hide file tree
Showing 23 changed files with 575 additions and 299 deletions.
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ vars = {
"jsc_tag": "version:274355",

# https://chrome-infra-packages.appspot.com/p/fuchsia/third_party/clang
"clang_version": "git_revision:b1d2e8510b58893e58558ffdf3f8ba29c1e25e5a",
"clang_version": "git_revision:0f61051f541a5b8cfce25c84262dfdbadb9ca688",

# https://chrome-infra-packages.appspot.com/p/gn/gn
"gn_version": "git_revision:155c53952ec2dc324b0438ce5b9bd4a286577d25",
Expand Down Expand Up @@ -192,7 +192,7 @@ vars = {
"vector_math_rev": "43f2a77bb0be812b027a68a11792d563713b42a1",
"watcher_rev": "1bd2f20d0d924c8422aa2b9afdb165bff4f053c0",
"web_rev": "9d8c802d13b785b1a5b201c4a43605d640841c98",
"web_socket_channel_rev": "ced3a37193f89d5ee95792f342eeb15d3d55d8c1",
"web_socket_channel_rev": "b612fc2caa9f4c3c8947b4ffbb274bce33c54a04",
"webdev_rev": "3a10b76f3937fb9b50e7971fb15f82b65dfe05ef",
"webdriver_rev": "c80e01e6ce121e55c31e33a31e5d3950023e6bc9",
"webkit_inspection_protocol_rev": "153fea4fe5ac45bebf0c2e76bb3d76b0f1fcdaae",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ final class FieldSuggestion extends CandidateSuggestion {
/// The element on which the suggestion is based.
final FieldElement element;

/// The class from which the field is being referenced, or `null` if the class
/// is not being referenced from within a class.
final ClassElement? referencingClass;
/// The element defined by the declaration in which the suggestion is to be
/// applied, or `null` if the completion is in a static context.
final InterfaceElement? referencingInterface;

/// Initialize a newly created candidate suggestion to suggest the [element].
FieldSuggestion(
{required this.element,
required this.referencingClass,
required this.referencingInterface,
required super.score});

@override
Expand Down Expand Up @@ -430,13 +430,15 @@ final class MethodSuggestion extends ExecutableSuggestion {
/// The element on which the suggestion is based.
final MethodElement element;

final ClassElement? referencingClass;
/// The element defined by the declaration in which the suggestion is to be
/// applied, or `null` if the completion is in a static context.
final InterfaceElement? referencingInterface;

/// Initialize a newly created candidate suggestion to suggest the [element].
MethodSuggestion(
{required super.kind,
required this.element,
required this.referencingClass,
required this.referencingInterface,
required super.score});

@override
Expand Down Expand Up @@ -532,12 +534,14 @@ final class PropertyAccessSuggestion extends CandidateSuggestion {
/// The element on which the suggestion is based.
final PropertyAccessorElement element;

final ClassElement? referencingClass;
/// The element defined by the declaration in which the suggestion is to be
/// applied, or `null` if the completion is in a static context.
final InterfaceElement? referencingInterface;

/// Initialize a newly created candidate suggestion to suggest the [element].
PropertyAccessSuggestion(
{required this.element,
required this.referencingClass,
required this.referencingInterface,
required super.score});

@override
Expand Down Expand Up @@ -770,7 +774,7 @@ extension SuggestionBuilderExtension on SuggestionBuilder {
} else {
suggestField(fieldElement,
inheritanceDistance: _inheritanceDistance(
suggestion.referencingClass,
suggestion.referencingInterface,
suggestion.element.enclosingElement));
}
case FormalParameterSuggestion():
Expand Down Expand Up @@ -814,7 +818,8 @@ extension SuggestionBuilderExtension on SuggestionBuilder {
suggestion.element,
kind: kind,
inheritanceDistance: _inheritanceDistance(
suggestion.referencingClass, suggestion.element.enclosingElement),
suggestion.referencingInterface,
suggestion.element.enclosingElement),
);
case MixinSuggestion():
libraryUriStr = suggestion.libraryUriStr;
Expand All @@ -836,7 +841,7 @@ extension SuggestionBuilderExtension on SuggestionBuilder {
);
case PropertyAccessSuggestion():
var inheritanceDistance = 0.0;
var referencingClass = suggestion.referencingClass;
var referencingClass = suggestion.referencingInterface;
var declaringClass = suggestion.element.enclosingElement;
if (referencingClass != null && declaringClass is InterfaceElement) {
inheritanceDistance = request.featureComputer
Expand Down Expand Up @@ -895,7 +900,7 @@ extension SuggestionBuilderExtension on SuggestionBuilder {
/// Returns the inheritance distance from the [referencingClass] to the
/// [declaringClass].
double _inheritanceDistance(
ClassElement? referencingClass, Element? declaringClass) {
InterfaceElement? referencingClass, Element? declaringClass) {
var distance = 0.0;
if (referencingClass != null && declaringClass is InterfaceElement) {
distance = request.featureComputer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:analysis_server/src/services/completion/dart/candidate_suggestio
import 'package:analysis_server/src/services/completion/dart/completion_state.dart';
import 'package:analysis_server/src/services/completion/dart/feature_computer.dart';
import 'package:analysis_server/src/services/completion/dart/in_scope_completion_pass.dart';
import 'package:analysis_server/src/services/completion/dart/not_imported_completion_pass.dart';
import 'package:analysis_server/src/services/completion/dart/not_imported_contributor.dart';
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
import 'package:analysis_server/src/services/completion/dart/suggestion_collector.dart';
Expand Down Expand Up @@ -119,18 +120,32 @@ class DartCompletionManager {

var collector = SuggestionCollector();
try {
performance.run(
var selection = request.unit.select(offset: request.offset, length: 0);
if (selection == null) {
throw AbortCompletion();
}
var matcher = request.targetPrefix.isEmpty
? NoPrefixMatcher()
: FuzzyMatcher(request.targetPrefix);
var state = CompletionState(request, selection, budget, matcher);
/*var operations =*/ performance.run(
'InScopeCompletionPass',
(performance) {
_runFirstPass(
request: request,
return _runFirstPass(
state: state,
collector: collector,
builder: builder,
suggestOverrides: enableOverrideContributor,
suggestUris: enableUriContributor,
);
},
);
// if (operations.isNotEmpty && notImportedSuggestions != null) {
// performance.run('NotImportedCompletionPass', (performance) {
// NotImportedCompletionPass(state, collector, operations)
// .computeSuggestions(performance: performance);
// });
// }
for (var contributor in contributors) {
await performance.runAsync(
'${contributor.runtimeType}',
Expand All @@ -155,22 +170,16 @@ class DartCompletionManager {
return builder.suggestions.toList();
}

// Run the first pass of the code completion algorithm.
void _runFirstPass({
required DartCompletionRequest request,
/// Run the first pass of the code completion algorithm.
///
/// Returns the operations that need to be performed in the second pass.
List<NotImportedOperation> _runFirstPass({
required CompletionState state,
required SuggestionCollector collector,
required SuggestionBuilder builder,
required bool suggestOverrides,
required bool suggestUris,
}) {
var selection = request.unit.select(offset: request.offset, length: 0);
if (selection == null) {
throw AbortCompletion();
}
var matcher = request.targetPrefix.isEmpty
? NoPrefixMatcher()
: FuzzyMatcher(request.targetPrefix);
var state = CompletionState(request, selection, budget, matcher);
var pass = InScopeCompletionPass(
state: state,
collector: collector,
Expand All @@ -179,8 +188,9 @@ class DartCompletionManager {
suggestUris: suggestUris,
);
pass.computeSuggestions();
request.collectorLocationName = collector.completionLocation;
state.request.collectorLocationName = collector.completionLocation;
builder.suggestFromCandidates(collector.suggestions);
return pass.notImportedOperations;
}
}

Expand Down
Loading

0 comments on commit 95e0894

Please sign in to comment.