Arma Reforger Script API
|
A Basic Code Formatter - use Ctrl+Shift+K to trigger. More...
Public Member Functions | |
void | RunForced () |
Run the code formatter forced (formats all lines of the currently-opened file) | |
Static Public Member Functions | |
static void | GetIndentAndLineContent (string fullLine, out string indentation, out string content) |
Split line between indentation and content (trailing spaces included if any) | |
Protected Member Functions | |
override void | Run () |
Running method. | |
void | Initialise () |
Required initialisation (prefixes filter) | |
void | RunCurrentFile () |
Run the current file. | |
void | RunAddonFilesBatchProcess () |
Show dialogs to treat all addon script files. | |
array< ref SCR_BasicCodeFormatterPluginFileReport > | ProcessFiles (array< string > relativeFilePaths, bool useFileIO) |
Process multiple files (using ProcessFile) | |
SCR_BasicCodeFormatterPluginFileReport | ProcessFile (string relativeFilePath, bool useFileIO) |
Process a single file. | |
array< string > | ReadFileContent (string relativeFilePath, bool useFileIO) |
Get relative file's content lines as array of strings. | |
void | PrintReport (notnull SCR_BasicCodeFormatterPluginFileReport report, bool printFixes, bool printFindings) |
Output fixes and findings in the log console. | |
int | GeneralFormatting (string indentation, inout notnull array< string > pieces) |
General formatting like spacing, "NULL" → "null", ";;" → ";", etc. | |
bool | AddFinalLineReturnToCurrentFile () |
Add the final line return to a file (to end with a line return instead of the usual closing bracket) | |
bool | HasBadVariableNaming (string indentation, string findingsString) |
Checks for bad prefixes and non-uppercased consts. | |
void | PrintFinding (string description, notnull array< int > lineNumbers, string tip=string.Empty) |
Print the finding with line numbers examples: "int(s)", {}, "" = "No int(s) found" "int(s)", {}, "a tip" = "No int(s) found" "int(s)", { 1, 2, 3 }, "" = "3 int(s) found at line(s) 1, 2 & 3" "int(s)", { 1, 2, 3 }, "use longs instead" = "3 int(s) found at line(s) 1, 2 & 3 - use longs instead". | |
array< int > | GetFileModifiedLineNumbers (string absoluteFilePath, out bool isInRepository) |
Get the 1-based line numbers of lines that were modified since the last edit (according to the local VCS' diff) This method creates a temporary txt file next to the analysed one containing the diff result The temporary txt file is deleted (if everything goes well) after its parsing. | |
override void | Configure () |
bool | ButtonOK () |
bool | ButtonCancel () |
void | SCR_BasicCodeFormatterPlugin () |
Static Protected Member Functions | |
static void | GetIndentAndLineContentAsPieces (string fullLine, out string indentation, out array< string > pieces) |
Get line content as array of strings. | |
static string | JoinLineNumbers (notnull array< int > lineNumbers, int maxNumbers=LINE_NUMBER_LIMIT) |
Joins the provided line numbers together with commas and ampersand for the last element; also groups them by range (e.g 1,2,3,4,6,7,9 = 1-5, 6-7, 9). | |
Static Protected Attributes | |
static const int | LINE_NUMBER_LIMIT = 12 |
used by JoinLineNumbers to limit the amount of shown line number groups | |
static const string | LINE_NUMBER_RANGE = "%1-%2" |
used by JoinLineNumbers to give a line range (e.g 5-17, 2001-2013, etc) | |
static const string | LOG_SEPARATOR = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" |
static const string | BRACKET_OPEN = "{" |
static const string | BRACKET_CLOSE = "}" |
static const string | MEMBER_PREFIX = "m_" |
static const string | STATIC_PREFIX = "s_" |
static const ref array< string > | NATIVE_TYPES |
static const ref array< string > | VARIABLE_NAME_ENDING = { SCR_StringHelper.SPACE, ",", "=", ";", SCR_StringHelper.SLASH } |
static const string | METHOD_SEPARATOR = SCR_StringHelper.DOUBLE_SLASH + "------------------------------------------------------------------------------------------------" |
static const string | DIFF_FILENAME = "tempDiffFile.txt" |
static const string | DEFAULT_DIFF_CMD = "cmd /c svn diff \"%1\" > \"%2\"" |
static const ref array< string > | FORMAT_IGNORE = { SCR_StringHelper.DOUBLE_SLASH, SCR_StringHelper.SLASH + "*", SCR_StringHelper.DOUBLE_QUOTE } |
static const ref array< string > | FORCED_PREFIXES = { "SCR_" } |
static const ref array< string > | EXCLUDED_DIRECTORIES |
static const string | GENERATED_SCRIPT_WARNING = "Do not modify, this script is generated" |
static const ResourceName | SPELLCHECK_CONFIG = "{53D7DE332A43449F}Configs/Workbench/ScriptEditor/BasicCodeFormatterPlugin/BasicCodeFormatterSpellCheckConfig.conf" |
A Basic Code Formatter - use Ctrl+Shift+K to trigger.
Ctrl+Alt+Shift+K can be used to force processing all the lines of the currently opened file.
|
protected |
|
protected |
Add the final line return to a file (to end with a line return instead of the usual closing bracket)
|
protected |
|
protected |
|
protected |
|
protected |
General formatting like spacing, "NULL" → "null", ";;" → ";", etc.
[in] | indentation | used to determine the scope level |
[in,out] | pieces | text pieces input/output |
|
protected |
Get the 1-based line numbers of lines that were modified since the last edit (according to the local VCS' diff) This method creates a temporary txt file next to the analysed one containing the diff result The temporary txt file is deleted (if everything goes well) after its parsing.
[in] | absoluteFilePath | the ABSOLUTE file path (e.g C:/ArmaReforger/Data/scripts/myFile.c) |
[in] | isInRepository |
|
static |
Split line between indentation and content (trailing spaces included if any)
[in] | fullLine | the line's content |
[out] | indentation | gets the left spacing (tabs and spaces) |
[out] | content | gets the text |
|
staticprotected |
Get line content as array of strings.
Cannot return an empty array
[in] | fullLine | the line to analyse |
[out] | indentation | gets the left spacing (tabs and spaces) |
[out] | pieces | the line as split in code, string, comment parts - first element being indentation (empty when none). can be provided null, result is never null or empty |
|
protected |
Checks for bad prefixes and non-uppercased consts.
[in] | fullLine | the line to check - indentation is used to determine the variable's level (1 tab = member variable) |
|
protected |
Required initialisation (prefixes filter)
|
staticprotected |
Joins the provided line numbers together with commas and ampersand for the last element; also groups them by range (e.g 1,2,3,4,6,7,9 = 1-5, 6-7, 9).
examples:
{} = ""
{ 1 } = "1"
{ 1, 2, 3 } = "1-3"
{ 1, 2, ... , 10, 11 } = "1-11"
{ 1, 2, 3, 7, 8, 9 } = "1-3 & 7-9"
{ 1, 2, 3, 5, 7, 8, 9 } = "1-3, 5 & 7-9"
{ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23 } = "1, 3, 5, 7, 9, 11, 13, 15, 17, 19, ..."
[in] | lineNumbers | said line numbers in ascending order |
[in] | maxNumbers | maximum number of lines before ellipsis |
|
protected |
Print the finding with line numbers examples: "int(s)", {}, "" = "No int(s) found" "int(s)", {}, "a tip" = "No int(s) found" "int(s)", { 1, 2, 3 }, "" = "3 int(s) found at line(s) 1, 2 & 3" "int(s)", { 1, 2, 3 }, "use longs instead" = "3 int(s) found at line(s) 1, 2 & 3 - use longs instead".
[in] | description | the finding(s)' description, starting with a lowercase as it is meant to be used in the middle of a sentence |
[in] | lineNumbers | the lines where the findings have been found |
[in] | tip | a suggestion to fix the finding |
|
protected |
Output fixes and findings in the log console.
[in] | report | the generated report |
[in] | printFixes | print applied fixes (edited lines, trimmings, formatting etc) |
[in] | printFindings | print findings that may require user attention (one-liners, bad variable naming, etc) |
|
protected |
Process a single file.
[in] | relativeFilePath | the file's relative path |
[in] | useFileIO | true = use FileIO's API (no Ctrl+Z available, but does not open a Script Editor tab), false = use ScriptEditor API method (opens a tab, allows for Ctrl+Z) |
|
protected |
Process multiple files (using ProcessFile)
[in] | relativeFilePaths | multiple relative file paths |
[in] | useFileIO | true = use FileIO's API (no Ctrl+Z available, but does not open a Script Editor tab), false = use ScriptEditor API method (opens a tab, allows for Ctrl+Z) |
|
protected |
Get relative file's content lines as array of strings.
[in] | relativeFilePath | the file's relative path |
[in] | useFileIO | use FileIO API, otherwise use Script Editor API (opening the file in a tab) |
|
protected |
Running method.
|
protected |
Show dialogs to treat all addon script files.
|
protected |
Run the current file.
void SCR_BasicCodeFormatterPlugin.RunForced | ( | ) |
Run the code formatter forced (formats all lines of the currently-opened file)
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
used by JoinLineNumbers to limit the amount of shown line number groups
|
staticprotected |
used by JoinLineNumbers to give a line range (e.g 5-17, 2001-2013, etc)
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
what should be followed by a TAG_ prefix
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
mistake-correction map; mistake can contain star(s)
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |