February 06, 2006

IntelliJ IDEA 5.1: What's new in OpenAPI

Now that the version 5.1 has been released, I decided to summarize the changes in OpenAPI for this version. None of them are major, but I hope that some of them enable new integration scenarios. An important point is that almost all of the changes are backward-compatible: if a plugin developed for the version 5.0 does not use any APIs which are not part of our OpenAPI, the plugin will work just as fine with version 5.1. All of the reports of actual plugin breakage that we have received during the 5.1 EAP cycle are related to usages of non-open APIs.

The major areas where new APIs have been added are:

PSI and Repository

  • Package-level annotations support: PsiPackage.getAnnotationList(). Version 5.1 has improved support for processing and validating package-level annotations, and the new method provides access to the annotation list.
  • Hierarchical method signatures: PsiClass.getVisibleSignatures(). The main motivation for this API is performance: it allows to calculate the information about the super methods of a method only once and not repeat any calculations for every superclass.
  • Indexing occurrences of specified regex patterns in comments: IndexPatternProvider and IndexPatternSearch. This is effectively a generalization of the TODO API: TODO has been decoupled from the word index system, and it’s now possible to extend the word indexing. Possible uses for this API are, for example, finding occurrences of bug tracker request IDs in the comments. The query framework on which the IndexPatternSearch API is based (QueryFactory, QueryExecutor and related classes) has been backported from Demetra, and will be used much more extensively in the new version.
  • Possibility to delegate getChildAttributes() processing to a child block of the current block: ChildAttributes.DELEGATE_TO_PREV_CHILD and ChildAttributes.DELEGATE_TO_NEXT_CHILD. In additional to these API additions, there have been a number of fixes in the formatter core (in particular, the fixes are required for correct operation of the Python formatter).

Version Control Integration

  • Checkin handlers: CheckinHandlerFactory, CheckinHandler. This API allows any plugin to add actions which are executed before and/or after files are checked in to VCS. The new feature of version 5.1 “Before check-in / Perform code analysis on affected files” is based on this API, and in fact the entire source code of that feature is supplied in the CodeAnalysisBeforeCheckinHandler class.
  • Code analysis API: AbstractVcsHelper.findCodeSmells(), CodeSmellInfo. These APIs are used by the “Perform code analysis on affected files” feature, but can also be useful for some other cases.
  • Custom actions in the “Commit Project” dialog: Vcs.MessageActionGroup standard action group. There are no new APIs here besides the action group ID: all actions added to this group are shown as buttons in the Commit Project dialog. The standard “History” button is now provided by such an action, and its source code is supplied as ShowMessageHistoryAction class.
  • External access to the “Browse Changes” functionality of VCS plugins: AbstractVcs.getVersionsProvider(). An extrernal plugin can now query that interface from a particular VCS and use it to load the history of changes for a file, directory or an entire project.

IDE and User Interface

  • Querying the complete list of registered actions: ActionManager.getActionIds(), ActionManager.isGroup(). The APIs are used in the “New Action…” dialog of the DevKit plugin.
  • API for creating classes from templates: CreateElementActionBase and PsiDirectory.createClass(name, templateName). Sample usages of this API are CreateClassAction in the OpenAPI and GeneratePluginClassAction in the DevKit plugin. The IdeView interface and DataConstants.IDE_VIEW have been moved to the OpenAPI because they are used by this code.
  • Clickable annotations in the editor gutter: EditorGutterAction. Sample can be found in the implementation of the “Annotate” action of the Perforce plugin (PerforceFileAnnotation.PerforceRevisionAnnotationAspect).
  • Automatic mnemonic registration: MnemonicHelper class. Used everywhere in IDEA, and particularly in the DialogWrapper class.

There are also a number of smaller changes and additions (for example, some new methods in the utility classes).

Posted by Dmitry Jemerov at February 6, 2006 06:47 PM
Post a comment

Remember personal info?