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

Vincent Massol, Eduard Moraru

Active Installs80
Rating
1 Votes
LicenseGNU Lesser General Public License 2.1

Installable with the Extension Manager

Description

  • 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
}

Example

POST URL:

http://localhost:8080/xwiki/rest/autocomplete?media=json&offset=35&syntax=xwiki%2F2.1

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

Input (POST body):

{{velocity}}
$services.model.create
{{/velocity}}

Output:

{
 "hints":[
    {
     "name":"createAttachmentReference",
     "description":"createAttachmentReference(DocumentReference, String) AttachmentReference"
    },
    {
     "name":"createDocumentReference",
     "description":"createDocumentReference(String, String, String) DocumentReference"
    },
    {
     "name":"createEntityReference",
     "description":"createEntityReference(String, EntityType, EntityReference) EntityReference"
    },
    {
     "name":"createSpaceReference",
     "description":"createSpaceReference(String, WikiReference) SpaceReference"
    },
    {
     "name":"createWikiReference",
     "description":"createWikiReference(String) WikiReference"
    }
  ],
 "startOffset":29,
 "empty":false
}

Release Notes

All release notes

4.6

4.5.2

4.5.1

4.5

4.4

4.3.1

4.3

4.2

4.1

4.0

3.4

3.3

3.2

3.1.1

3.1

3.0

This version improved the overall stability of the application but unfortunatey also introduced a serious performance issue that can lead to the syntax highlighting being activated 10+ seconds after the page is loaded. An improvement of this problem will come with the new version that will be released once XWiki 7.1M1 is released and an even better solution will hopefully come after that. To stay up to date with the problem, please watch the assigned WIKIEDITOR-21 Jira issue

2.2

2.1

2.0

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).

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

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

Tags:
    

Get Connected