[webkit-changes] [WebKit/WebKit] 5c6736: Web Inspector: Console code completion doesn't sug...
Qianlang Chen
noreply at github.com
Tue Apr 9 12:33:09 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5c6736f3f9ad8508918c6a2c2ece135498603d9c
https://github.com/WebKit/WebKit/commit/5c6736f3f9ad8508918c6a2c2ece135498603d9c
Author: Qianlang Chen <qianlangchen at apple.com>
Date: 2024-04-09 (Tue, 09 Apr 2024)
Changed paths:
A LayoutTests/inspector/console/js-completions-expected.txt
A LayoutTests/inspector/console/js-completions.html
M Source/WebInspectorUI/UserInterface/Controllers/ConsoleManager.js
M Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js
M Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js
M Source/WebInspectorUI/UserInterface/Test.html
Log Message:
-----------
Web Inspector: Console code completion doesn't suggest variables unless inspector is re-opened
rdar://125035133
https://bugs.webkit.org/show_bug.cgi?id=271265
Reviewed by Devin Rousso.
In the current JavaScriptRuntimeCompletionProvider, there's work done
to cache the list of property names present in the runtime. This
property name cache is cleared / forced to be re-fetched either when 30
seconds have passed or when the code typed starts accessing a different
object's properties (the object to the left of a dot operator). However,
when variables are created by executing a command, the cache is not
updated, resulting in those new variables missing from the suggestions.
This commit simply makes it so that executing a command from the console
also forces clearing the cache, so that new variables, in case created,
are immediately collected as suggestions when typing a new command. The
cache is also cleared when the console clears, so when the page is
reloaded with the console opened, the variable completion still gets
properly reset.
* Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:
(WI.JavaScriptRuntimeCompletionProvider):
(WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded):
- Update the comment on the need of loading the list of property
names from cache to reflect now there can be additional
opportunities that the cache should be cleared.
- Remove the `// Protected` section comment as this function is
accessed by others.
(WI.JavaScriptRuntimeCompletionProvider):
(WI.JavaScriptRuntimeCompletionProvider.prototype.clearCachedPropertyNames):
(WI.JavaScriptRuntimeCompletionProvider.prototype._clearLastProperties): Deleted
- Expose the logic of clearing the property name cache so that the
completion provider's users can also force a reload of property
names.
(WI.JavaScriptRuntimeCompletionProvider.prototype.completionControllerCompletionsNeeded.updateLastPropertyNames):
- Adapt to the cache-clearing logic being exposed to public.
* Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js:
(WI.JavaScriptLogViewController.prototype.consolePromptTextCommitted):
- Clear cached property names whenever a new command is executed in
the console, since new commands are what can possibly introduce
changes to existing variables (additions from `x = ...` or `let x`,
and deletions from `delete x`).
* Source/WebInspectorUI/UserInterface/Controllers/ConsoleManager.js:
(WI.ConsoleManager.prototype.messagesCleared):
- Clear cached property names when the console is cleared because the
page might've been reloaded and therefore variables were reset
as a result.
* Source/WebInspectorUI/UserInterface/Test.html:
* LayoutTests/inspector/console/js-completions.html: Added.
* LayoutTests/inspector/console/js-completions-expected.txt: Added.
- Add a simple test to demonstrate how `clearCachedPropertyNames`
is used.
Canonical link: https://commits.webkit.org/277261@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list