Skip to content

Instantly share code, notes, and snippets.

@klazuka
Created March 1, 2019 00:17
Show Gist options
  • Save klazuka/23a9894253fb6878f95ab74ba1b75bd9 to your computer and use it in GitHub Desktop.
Save klazuka/23a9894253fb6878f95ab74ba1b75bd9 to your computer and use it in GitHub Desktop.
Notes on the IntelliJ action system
WARNING: these are raw notes. I do not work for JetBrains. This is just meant to give a rough overview.
DataManager
- convert a Swing component into a DataContext (which can then be queried)
- handles the tree walk to find the focused Swing component
- you can call `registerDataProvider()` to register yourself as a data provider for the action system
DataContext
- Allows an action to retrieve information about the context in which it was invoked.
- implemented by:
DataProvider
- ask for data using a dataId String
- in order to provide context/args to an Action
- the UI hierarchy will be walked up from the currently focused component
- every component implementing `DataProvider` will be queried until one of them returns data
- transparent mapping can also be performed (e.g. NAVIGATABLE for NAVIGATABLE_ARRAY)
GetDataRule
- ask a `DataProvider` for data
- seems to be how they map compatible things into the same query result
- Extension Point exists
CommonDataKeys
- a bunch of constants for things like
- PROJECT
- EDITOR
- CARET
- NAVIGATABLE
- PSI_ELEMENT
- PSI_FILE
- etc.
PlatformDataKeys
- additional constants for things like
- SELECTED_ITEM
- SELECTED_ITEMS
- CONTENT_MANAGER
- TOOL_WINDOW
- etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment