Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eval Console Autocomplete #3013

Merged
merged 6 commits into from
May 13, 2021
Merged

Eval Console Autocomplete #3013

merged 6 commits into from
May 13, 2021

Conversation

grouma
Copy link
Member

@grouma grouma commented May 13, 2021

Bug fixes to the autocomplete logic:

  • The optional decorator was never actually applied
  • Keyboard events would not propagate if they weren't applicable to the autocomplete infrastructure
  • Rebuilds could cause issue with focus and text state

New features:

  • The evaluation input now uses the autocomplete infrastructure

Follow up work:

  • The autocomplete overlay should be pinned to the . in tracking mode
  • The mixin approach complicates composition. Long term we should model the autocomplete strictly as a stateful widget with the right hooks.

Although not blocking, this feature requires dart-lang/webdev#1319 to be fully functional for Dart web applications.

Screen.Recording.2021-05-12.at.10.36.57.PM.mov

funcRef.name == clazz.name || funcRef.name.startsWith('${clazz.name}.');

bool _isAccessible(String member, Class clazz) {
final frame = widget.controller.selectedStackFrame.value?.frame ??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the ?? needed. Can we just always have the first frame be selected? Seems like that is the UI state in the debugger anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of copied code from the evaluation logic. I'm not exactly sure why it's required but the added defensiveness seemed important.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add it to the controller. Maybe "currentStackFrame".

@grouma grouma changed the title [WIP] Eval Autocomplete Eval Console Autocomplete May 13, 2021
Comment on lines 29 to 30
class _AutoCompleteController extends DisposableController
with SearchControllerMixin, AutoCompleteSearchControllerMixin {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be public and in the search.dart file?


Future<List<String>> _autoCompleteMembersFor(
ClassRef classRef, DebuggerController controller) async {
final result = <String>[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make this return a Set as well as you are currently adding dupes.

bool _validFunction(FuncRef funcRef, Class clazz) {
return !funcRef.isStatic &&
!_isContructor(funcRef, clazz) &&
funcRef.name != '==';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to detect other operators or you will suggest them as invalid autocompletes because the syntax is
foo+bar not foo.+bar

final frame = controller.selectedStackFrame.value?.frame ??
controller.stackFramesWithLocation.value.first.frame;
final currentScript = frame.location.script;
return !(member.startsWith('_') &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think
!member.startsWith('_') || currentScript.id == clazz.location?.script?.id
is a little easier to read.

id: ''),
],
functions: [
FuncRef(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a couple constructors to make sure they are filtered out.

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

}

Future<List<String>> _autoCompleteMembersFor(
ClassRef classRef, DebuggerController controller) async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: trailing comma

final _searchNotifier = ValueNotifier<String>('');

/// Notify that the search has changed.
ValueListenable get searchNotifier => _searchNotifier;

bool isField = false;
bool get isField => search.endsWith('.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems specific to the debugger and not something that should be in a general Search mixin. Can we move this to the debugger?

value: null,
declarationTokenPos: 0,
scopeStartTokenPos: 0,
scopeEndTokenPos: 0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing comma for all these BoundVariable, FieldRef, Class, FuncRef, etc. instances

@@ -0,0 +1,205 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we rename this file to debugger_evalution_test.dart so it is clear that this test is testing functionality in the debugger

@grouma
Copy link
Member Author

grouma commented May 13, 2021

Merging knowing that we'll need to update the goldens one more time. Currently failing with a 0.02% diff detected.

@grouma grouma merged commit 8b0cacb into master May 13, 2021
@grouma grouma deleted the eval-auto-complete branch May 13, 2021 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants