script_codeAutocompletion back-end, providing a REST end-point
Developed by

Vincent Massol, Eduard Moraru

Active Installs45
1 Votes
LicenseGNU Lesser General Public License 2.1
Installable with the Extension Manager


  • REST-based which means other clients can use it
    • POST the document content to /xwiki/rest/autocomplete?offset=<contentOffset>&syntax=<documentSyntax>
  • Clean code with automated tests which is ready to be proposed to the XWiki Platform
  • Pluggable: new method finder can be plugged in for a specific variable name
  • Generic code which can be used not only for Velocity but for other scripting languages (groovy, etc) and wiki syntax autocompletion

Features Implemented for the Velocity completions and XWiki API

  • $
  • $!
  • ${
  • $!{
  • $a
  • $!a
  • ${a
  • $!{a
  • $a.
  • $a.b
  • $services. (list SS)
  • $xwiki. (find plugins too)
  • $context. (find context keys too)
  • $xcontext. (find context keys too)
  • $a.bbb with cursor inside the method
  • Special support for Velocity shorthands for getters
  • List parameters and return type
  • Sorted
  • Supports lowercase matching (user enters in lowercase and it matches uppercase)
  • PR support!

Response format

 "hints" : [
     "name" : String, // Value to be used as completion when the user selects it
     "description" : String, // Value to display in the UI for the current completion
 "startOffset" : integer, // The offset in the content where to insert a selected completion.
                          // Note: It should actually be used to replace anything between startOffset and offset in the content.
 "empty" : boolean // True if there are no results, false otherwise




Note: if not specified, the default media type is XML.

Input (POST body):



     "description":"createAttachmentReference(DocumentReference, String) AttachmentReference"
     "description":"createDocumentReference(String, String, String) DocumentReference"
     "description":"createEntityReference(String, EntityType, EntityReference) EntityReference"
     "description":"createSpaceReference(String, WikiReference) SpaceReference"
     "description":"createWikiReference(String) WikiReference"


  • Auto complete variables created in Velocity:
    #set ($mydoc = $xwiki.getDocument("whatever"))
  • Velocity Macro autocompletion
  • Javadoc display
  • Wiki syntax autocompletion on links
  • Velocity VTL elements for autocompletion
  • Parameter autocompletion; i.e. show param types when inside method params
  • Bug: $something.class is a String and not a Class, shows as "class class"
  • Return PR requirement not as text but as color of autocompletion hint for example

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

This extensions adds a REST resource and since we don't support adding REST resources dynamically yet, you'll need to restart your wiki for it to be active.


Dependencies for this extension (org.xwiki.contrib.editortool:editor-tool-autocomplete-api 4.3.1):

Created by Eduard Moraru on 2013/07/22 22:57

Get Connected