-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add PiE API autocomplete and tooltips #35
Open
Hal-9k1
wants to merge
27
commits into
master
Choose a base branch
from
editor-robot-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gamepad and Keyboard get_value autocomplete doesn't work because ace fills in the matching parenthesis -- typing 'Gamepad.get_value(' writes 'Gamepad.get_value()'. So try to add a way for makeContextCompleter to require a caret position, like inside the parens. Very broken right now and I'm not sure why.
Add addEditorTooltips skeleton. Don't use alias for TokenIterator in addEditorAutocomplete.
Uninstall redux because it was causing problems for the clean install on Clorox.
Try to fix bad completions for Gamepad/Keyboard.get_value by slicing away already-typed part. Observations: Completion is multiple tokens (e.g. when quoted): slice is needed to remove already-typed string from completion. Completion is single token: unsliced is needed or else existing text is replaced with sliced completion, effectively deleting the already-typed bit. Revert to using unsliced completions, as Ace can't seem to decide between replacing partially typed completions or appending to them, and I don't know how to programmatically predict which Ace will do.
Completion slicing still doesn't work, so Gamepad/Keyboard.get_value looks silly when quotes are already typed.
Add Robot.get_value doc as proof of concept. Text was pulled from api.md in the runtime repo. Styling still needed. Add HighlightedCode which wraps an AceEditor with appropriate configuration to be a highlighted read-only code block. The doc stuff will eventually have to live in its own directory somewhere if it's going to be reused. The API help window could probably just sort apiHelpComponents by key and concat them.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The last version of Dawn did autocomplete by dumping globals and methods all into the same
completer, which triggered on everything. Ace's default completers do the same thing, which is
functional but also means keywords, local variable names, and PiE globals will be suggested when
they are clearly not appropriate (such as after typing "Robot." when only a method on the Robot
object would be acceptable). Our autocomplete reads a few tokens behind the caret (the "context")
to suggest only relevant completions. It also patches ace's native completers to only trigger when
a global or keyword would make sense to be completed.
Cue several hours of fighting with the ace tokenizer.
"require" is prohibited as an identifier in typescript, but that's the name ace gives its module
loader. Knowing this, ace aliases their require to be called "acequire"... but doesn't include it
in the typescript declaration file. So we just have to alias it ourselves whenever we import
require.
Also change devEngines -> engines (electron boilerplate bug) so newer versions of node don't blow
up when reading our package.json.
Tooltips will also use this context reading bit so it needs to be pulled out to its own file. Also
makes addEditorCompletions a lot easier to read, too. readApiCall isn't a great name but I
couldn't think what else to call it. "getInterestingTextBeforePosition"? The criteria for
"interesting" is kind of narrow.
Uses readApiCall to find help for that API call/field, which is rendered as a React component.
Ideally apiHelpComponents would be broken out into multiple files so it could be reused in the
help modal.
Resolves #31.