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

Add PiE API autocomplete and tooltips #35

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Conversation

Hal-9k1
Copy link
Collaborator

@Hal-9k1 Hal-9k1 commented Nov 28, 2024

  • Add context-sensitive autocomplete
    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.
  • Try to improve autocomplete
  • Reduce boilerplate in completions
  • Try to fix context position stuff
  • Fix position-sensitive context completion
    Cue several hours of fighting with the ace tokenizer.
  • Lint
  • Fix acequire import weirdness
    "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.
  • Fix typescript errors
  • Document addEditorAutocomplete
  • Start adding tooltips
  • Uninstall redux
    Also change devEngines -> engines (electron boilerplate bug) so newer versions of node don't blow
    up when reading our package.json.
  • Add demo tooltip on everything
  • Improve context autocomplete
  • Fail to fix some bad completions
  • Somehow fix autocomplete
  • Fix typescript error in tooltips
  • Remove beforeCaret now that buf is only before caret
  • Extract text grabbing part of getCompletions to readApiCall.ts
    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.
  • Get tooltips working
    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.
  • Fix empty returns in readApiCall
  • Fix problems with ace and jest
  • Fully remove isInterrupted, make readApiCall break on strings
  • Lint

Resolves #31.

Hal-9k1 and others added 27 commits October 30, 2024 07:07
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor tooltips for API stuff
2 participants