Script Editor: Autocomplete Plugin – Arma Reforger
|
Autocomplete |
|---|
|
Script Editor plugin |
| Ctrl + Return ↵ |
|
A plugin to autocomplete/autofix the current line |
|
File: SCR_AutocompletePlugin.c |
The Autocomplete Script Editor plugin helps script authors by providing autocompletion and smart insertions for e.g common code structures, code snippets, boilerplate code etc. It also assists with attribute decorators, log level consistency, null and validity checks, and more.
Features
- Script snippets on keyword (see Default Keywords below for a full list of default keywords)
- Instantiation help (see Autocomplete below)
- Safety checks: adds a null check after a cast (if not present), adds a validity check after Resource.Load (if not present)
- Attribute decorators: automatically suggests/adds appropriate [Attribute(/* ... */)] decorators for variables
- Log level consistency: ensures Print and PrintFormat method calls have explicit log levels
- User customisation: supports user-defined keywords/snippets and attribute decorators; defaults can be edited or reset.
How to Use
In Script Editor, type a supported keyword or code pattern then press Ctrl + Return ↵ to execute the plugin. The keyword gets replaced with the corresponding snippet, or the line will be auto-fixed/augmented as needed. Many behaviours are configurable in the plugin settings via Workbench and custom keywords can be added.
Default Keywords
| Keyword | Description | Result |
|---|---|---|
| if | if structure | if (condition)
{
}
|
| ife | if-else structure | if (condition)
{
}
else
{
}
|
| for | for loop temporarily storing the iteratedclength | |
| forr | Reversed for loop (from end to start) | |
| foreach | foreach loop (item type to be replaced) | foreach (SCR_Class item : items)
{
}
|
| foreachi | Indexed foreach loop | |
| switch | switch-case structure | switch (value)
{
case 0:
break;
default:
break;
}
|
| while | while structure | while (condition)
{
}
|
| class | class basic structure | class SCR_MyClass
{
protected string m_sValue = "Generated class";
//------------------------------------------------------------------------------------------------
//! constructor
void SCR_MyClass()
{
}
}
|
| method/func | Method/Function structure (indentation depending on keyword's indentation) | //------------------------------------------------------------------------------------------------
//! \param[in] parameter
protected void Method(int parameter)
{
}
|
| ctor/dtor | Current class's constructor/destructor IEntity constructor if class name ends with Entity |
//------------------------------------------------------------------------------------------------
// constructor
void SCR_CurrentClassName()
{
}
//------------------------------------------------------------------------------------------------
// constructor
void SCR_CurrentClassNameEntity(IEntitySource src, IEntity parent)
{
}
//------------------------------------------------------------------------------------------------
// destructor
void ~SCR_CurrentClassName()
{
}
|
| findcomp | Script component-finding structure with null check | SCR_ComponentClass component = SCR_ComponentClass.Cast(entity.FindComponent(SCR_ComponentClass));
if (!comp)
return;
|
| A simple Print line with log level |
Autocompletion
| Type | Examples |
|---|---|
| Instantiation | SCR_Class instance =
// or
SCR_Class instance = new
// or
SCR_Class instance = new SCR_Class;
// becomes
SCR_Class instance = new SCR_Class(); |
| Attribute decorator creation | protected SCR_EBoxSide m_eBoxSide;
// becomes
[Attribute(defvalue: "0", desc: "Side To Show", uiwidget: UIWidgets.ComboBox, enumType: SCR_EBoxSide)]
protected SCR_EBoxSide m_eSideToShow;
|
| Log level check | |
| Cast null check | SCR_Class casted = SCR_Class.Cast(instance);
Print(casted.m_Value);
// becomes
SCR_Class casted = SCR_Class.Cast(instance);
if (!casted)
return;
Print(casted.m_Value); |
| Resource validity check | Resource resource = Resource.Load(resourceName);
BaseContainer baseContainer = resource.GetResource().ToBaseContainer();
// becomes
Resource resource = Resource.Load(resourceName);
if (!resource.IsValid())
return;
BaseContainer baseContainer = resource.GetResource().ToBaseContainer(); |
Settings Overview
- Enable/Disable constructor/destructor/autoinstantiate/fix features
- Choose when instantiation assistance triggers (on "= new", "=" only or both)
- Configure default Print/PrintFormat log level
- Edit tool/user keyword pairs and attribute decorator presets
- All settings available via plugin configuration dialog.
Customisation
- Custom keywords/snippets and attribute templates are supported via settings.
- Tool-provided (default) and user-defined lists are kept separate.