Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Contextual Editor

The Eclipse Plugin provides a Contextual Editor for Brew MP CIF, CAR and Lua files.

Prerequisites

The following prerequisites are required to use the Contextual Editor:

  • DLTK 2.0 - Instructions for installation are provided on the Brew MP website under https://developer.brewmp.com/tools/sdk. If you are installing DLTK on a Win 7 machine, start Eclipse in Administrator mode prior to installation, and ensure that you have write permission in the Eclipse folder in Administrator mode.
  • Antlr-runtime-3.2.jar - http://www.antlr.org/download and copy the .jar file to the . This is to support the error highlighting feature in the Context Editor.
  • Once the prerequisites have been installed, restart Eclipse if open.

Verifying setup of Contextual Editor

Verify the Contextual Editor is properly setup by doing the following:

  1. In Eclipse, select Help > About Eclipse.

    The About Eclipse dialog opens.

  2. In the About Eclipse dialog, select Installation Details.

    The Installation Details dialog opens.

  3. In the Installation Details dialog, select the Plug-ins tab, and verify that Brew MP Contextual Editor and Brew MP Contextual Editor Core are listed. If not, see the Troubleshooting section for help.

Contextual Editor features

CIF, CAR, and Lua files can be opened and edited with the Contextual Editor within the Eclipse IDE, as shown in the following image:

Text is highlighted in different colors based on its category. Brace highlighting is performed when the cursor is positioned near any brace, where supported brace symbols are '[', ']', '{', '}', '(', ')'.

Selecting Ctrl+space provides a code-completion list, containing keywords as well as templates, as shown in the following image.

Signature help provides details of the parameters associated with all functions defined in CIFC. For example, to see signature help, type Enc, then select Ctrl+space, and select the first entry in the code completion drop-down list. Signature help information is provided as shown in the following image.

Error Highlighting

The error highlighting feature assists in correcting mistakes in code prior to compilation. The Contextual Editor implements a parser to scan the code and report any errors or warnings found. The parser is implemented with the help of the ANTLR parser generator. Any errors in code are underlined with red, with an error marker displaying in the margin, as shown in the image below.

The following are some error messages/warnings raised by the parser:

Message Description
Repeated entry Assignments to a variable inside a Lua table are repeated, e.g. the entry local sampleTable = {x=1, x=2} will prompt a warning for "x=2"
Unexpected token Unexpected token in the file
Mismatched token Token encountered while parsing the code is different from what parser expected in that context
Syntax error at . Generic error when error isn't an unexpected or mismatched token
Attempt to get length of a number value Attempt to get length of an integer incorrectly, e.g. local len = #10

The parser also validates CIF primitive fields. An error displays if a field doesn't match, such as in the following example, where the parser prompts the warning: "Expected integer value for type filed of ModRsc":

ModRsc {type = "test"}

The following are errors/warnings related to CIF primitives:

  • Expected integer value for field of
  • Value of must be in the range
  • Expected table value for field of {primitive name}
  • Expected integer or string value for field of
  • Expected integer or nil value for field of
  • Expected string value for field of
  • Use 'singled_newfunc' instead of 'newfunc'
  • ACLs are deprecated. Use ACL_Grant instead
  • Mandatory field(s) of not found :
  • Singleton requires a classid and a (singled_newfunc or singled_id or (singled_newfunc and singled_id))
  • ExtDeps must be of this format {cls1, cls2..., {id = number or string, type = number} }
  • ACL_Grant must contain at least one permission group
  • ACL_Grant groups must be of type {groups = {class_ids,}, perms=string}

Content Outline

The Eclipse Outline view displays the details of file contents, such as local field declarations, function definitions, CIF primitives, and includes/required files used.

Outline view eases navigation between declarations. When an entry is selected in outline view, focus goes to that entry in the editor, and vice versa. Icons used for each entry assist with identification.

For CIF primitives, the primitive name and any additional info is added to help identify the resource. For example, for an applet, the outline view entry is "Applet [appletid = ]"

The outline view of a sample file opened in the editor is shown in the following image.