Jump to content
K-Town

Arma Intellij Plugin - Smart Editing for Header and SQF Files

Recommended Posts

Arma IntelliJ Plugin
Current version: 2.0.2 (Released June 21, 2018)
 
Index
1. Introduction
2. Features
3. Feature Spotlight
4. Planned Features
5. Download and Installation
6. Source Code
7. Donate
8. Wiki, Bug Reporting, Discord
 
 
1. Introduction
Arma Intellij Plugin is a plugin developed by K-Town (me) for Intellij IDEA. Intellij IDEA is a Java IDE developed by Jetbrains and offers many amazing API's for creating support for custom languages to be used inside the Intellij editor.
Intellij is free, but I recommend reading the license agreement regardless.
 
2. Features
Arma Intellij Plugin has many features with more on the way. The plugin currently has:

  • Syntax checking for Header files (*.h, *.hh, *.sqm, *.ext, *.hpp) and SQF files
  • Description.ext Function lookup (See feature Spotlight a.)
  • Documentation 'tags' which can link to command wiki documentation without opening the browser.
  • Finding usages of variables and commands
  • Syntax highlighting
  • Rename refactoring for functions and variables
  • Auto-completion (ctrl + space)
  • Wiki documentation on commands and BIS functions via ctrl+Q
  • Complete type checking (including arrays)
  • Full preprocessor support for Header/Config files
  • Partial preprocessor support for SQF Files

 
3. Feature Spotlight
a. Auto-completion (more detail here)

 

Quote

Auto-completion is accessible at any time via ctrl + space.
 
When typing "call" or "spawn" followed by a space and then pressing the keybind, it will list all available functions defined in description.ext >> CfgFunctions. Some times, it may take an underscore to activate it.
 
When invoked after "localize", all Stringtable.xml entries will be listed. This also works for Header files when typing "$STR_" and then pressing the keybind.
 
Also, a few shortcuts are:

  • ifthen  - for creating if() then{};
  • ifexit   - for creating if() exitWith{};
  • hintfo - for creating hint format[""];
  • hintarg - for creating hint format["%1", _this select  ];
  • hintln - for hinting the current file name and line number. Example: hint "file.sqf 5"
  • hintvalue - for hinting an arbitrary value. Example: hint format["%1", ];

 
b. Syntax Checking

Quote

Syntax checking is available for both SQF files and Header files. Syntax checking is done with a Lexer and Parser. 
A lexer reads the entire file and splits the text into tokens (like createVehicle or "I'm a string").
The parser then combines the tokens into a syntax. The trivial syntax for adding is: operand PLUS operand
 
A note on syntax checking: syntax checking refers to verifying the correct placement of keywords, operators, and operands. There is no type checking which verifies types are correct in a given syntax. For example, var = 1+true makes no sense in terms of types (integer '+' boolean), but makes sense in terms of syntax (operand '+' operand).

 
c. Documentation Tags - detail here

Quote

Function documentation has always supported HTML support. However, there wasn't functionality to link to a command  or BIS function documentation saved within the plugin. Documentation tags allow just that. When the tags are used in the comment, they will automatically be converted into an internal link in the documentation viewer. Internal links open documentation inside IntelliJ's documentation window and not inside a web browser.
 
Example use cases:
 


/*
See @command createVehicle to learn how to create vehicles
See @bis BIS_fnc_mp to send something to server.
See @fnc myTag_fnc_myDescriptionExtFunction to learn something.
*/

 
4. Planned Features

  • Automatic code formatting for SQF and Header
  • Creating new mission files from scratch
  • More code inspecting functionalities
  • Other secret features ;)

 
5. Download and Installation
Download:

IntelliJ IDEA:

Plugin (Optional download. See Install from JetBrains Plugin Repository below):

NOTE: both GitHub and JetBrains Repo include the same .jar files. You only need one plugin jar from one of the repositories to install.

 

Install: 

To install the plugin, you do one of the following:

  • Install it from disk with the .jar plugin download (see Plugin download above).
    • Step 1: In Settings Dialog, click on "Plugins", click Install plugin from Disk.
    • Step 2: Locate the "Arma Intellij Plugin.jar" (file name may have version info like v1.0.7)
    • Step 3: Click OK button when you located the plugin jar and then Restart IntelliJ IDEA
    • Step 4: You're good to go!
  • Install it from JetBrains Plugin Repository.
    • Step 1: In Settings Dialog, click on "Plugins", click Browse Repositories.
    • Step 2: Search for "Arma Intellij Plugin"
    • Step 3: Click Install and then Restart IntelliJ IDEA
    • Step 4: You're good to go!


6. Source Code
This project is open source. The plugin and it's creator (K-Town) aren't affiliated with Jetbrains or Bohemia Interactive. This project (the plugin code) is licensed under the MIT License. You don't need to contact me if you want to create derivatives or publish the project elsewhere. You can download and view the source here: https://github.com/kayler-renslow/arma-intellij-plugin
 
7. Donate
I am accepting donations, but please only donate if you can afford it because I will not give refunds.
Donate here.

8. Wiki, Bug Reporting, Discord
The Wiki for the plugin is available. If you have been using the plugin already, you may still find something you don't yet know.
 
Also, please report bugs at the Github repo. It's easier to manage than the forums and is specialized towards reporting bugs.
You can report bugs here: https://github.com/kayler-renslow/arma-intellij-plugin/issues

 

I have created a Discord server for Arma Dialog Creator and Arma IntelliJ Plugin. Here is the invite: https://discord.gg/SPBbYPa

  • Like 7

Share this post


Link to post
Share on other sites

Hello,

 

I tried your plugin and it's awesome!!!

 

But there is a thing I can't use ^^.

 

I tried "call" and ctrl + space, but nothing append. If i use ctrl + space alone I can show all commands, but not my functions. (and I tried with CfgFunctions directly in description.ext)

 

I saw an other problem, if CfgFunction is in another file than description.ext I can't use rename command ("function '....' is not defined in CfgFunctions config").

 

But ctrl+G and F2 macro are very useful ;), thanks a lot for your plugin :D

Share this post


Link to post
Share on other sites

Hello,

 

I tried your plugin and it's awesome!!!

 

But there is a thing I can't use ^^.

 

I tried "call" and ctrl + space, but nothing append. If i use ctrl + space alone I can show all commands, but not my functions. (and I tried with CfgFunctions directly in description.ext)

 

I saw an other problem, if CfgFunction is in another file than description.ext I can't use rename command ("function '....' is not defined in CfgFunctions config").

 

But ctrl+G and F2 macro are very useful ;), thanks a lot for your plugin :D

 

To get the list of functions, you have to type call then have at least one space and then press ctrl+space.

 

It appears that you aren't the first to not have renaming capabilities with functions, which is strange. If you check out https://community.bistudio.com/wiki/Functions_Library_(Arma_3),it will show how to define functions inside CfgFunctions.

Here is a portion of my CfgFunctions:

class CfgFunctions {
	class Client_Functions
	{
		tag="capwar";
		class Util
		{
			file="core\util";
			class fetchVehInfo {};
		};
	};
};

In this example, the only available function is capwar_fnc_fetchVehInfo and it is located inside core\util.

 

Are you able to call your function in Arma 3 editor's debug console? 

Share this post


Link to post
Share on other sites

Nice! I really needed this. While Syntax highlighting is good in Notepad++, Intelij really takes everything to the next level.  I do have several bugs though. 

 

- While{[anything here not ending with a semi-colon ]} do {}; are marked as a syntax error. 

- Variables declared under params ["_whatever"]; are marked as uninitialized and non-private.

- It does not recognize the semicolon as valid in a switch do:

switch (_part) do {
    case "head";
    case "body": { };
};

Regardless of these errors, I still love what you have done. Thank you.

Share this post


Link to post
Share on other sites

I tried "call" and ctrl + space, but nothing append. If i use ctrl + space alone I can show all commands, but not my functions. (and I tried with CfgFunctions directly in description.ext)

I saw an other problem, if CfgFunction is in another file than description.ext I can't use rename command ("function '....' is not defined in CfgFunctions config").

I'm having the same issue, functions work perfectly in Arma, but are loaded into description.ext with the #include macro:

#include "ext\cfgFunctions.ext"
Also, nice work, love the idea of being able to find where variables are used! :)

Share this post


Link to post
Share on other sites

To get the list of functions, you have to type call then have at least one space and then press ctrl+space.

 

It appears that you aren't the first to not have renaming capabilities with functions, which is strange. If you check out https://community.bistudio.com/wiki/Functions_Library_(Arma_3),it will show how to define functions inside CfgFunctions.

Here is a portion of my CfgFunctions:

 

It's work to get list of function with what you say, thanks ;).

 

And my CfgFunctions work perfectly, the plugin don't detect if it's in another file.

 

Is it possible to add my custom macro in IntelliJ? I would like to add ifelse, for, forEach, while, switch ...

Share this post


Link to post
Share on other sites

Is it possible to add my custom macro in IntelliJ? I would like to add ifelse, for, forEach, while, switch ...

There is no functionality to add custom macro's yet. I would like to have that functionality though.

 

 

Nice! I really needed this. While Syntax highlighting is good in Notepad++, Intelij really takes everything to the next level.  I do have several bugs though. 

 

- While{[anything here not ending with a semi-colon ]} do {}; are marked as a syntax error. 

- Variables declared under params ["_whatever"]; are marked as uninitialized and non-private.

- It does not recognize the semicolon as valid in a switch do:

switch (_part) do {
    case "head";
    case "body": { };
};

Regardless of these errors, I still love what you have done. Thank you.

 

I will resolve those errors. Thanks for the feedback.

 

I'm having the same issue, functions work perfectly in Arma, but are loaded into description.ext with the #include macro:

#include "ext\cfgFunctions.ext"
Also, nice work, love the idea of being able to find where variables are used! :)

 

 

Interesting. I have an include in my CfgFunctions as well but works perfectly. I'll look into this and I suspect I know the problem.

Share this post


Link to post
Share on other sites

Switching to Intellij now! Very useful plugin, thanks! :)

  • Like 1

Share this post


Link to post
Share on other sites

Noticed another bug. for "_i" from 5 to 0 step -1 do {}; throws a sytax error at step. If you prefer for me to PM you any bugs I come across, I can do that as well.

 

This plugin has already saved me a significant amount of time I would have spent debugging. Rated Topic 5/5. Thank you again. 

  • Like 1

Share this post


Link to post
Share on other sites

Noticed another bug. for "_i" from 5 to 0 step -1 do {}; throws a sytax error at step. If you prefer for me to PM you any bugs I come across, I can do that as well.

 

This plugin has already saved me a significant amount of time I would have spent debugging. Rated Topic 5/5. Thank you again. 

That took 1 second to fix. Thanks for pointing that out! I plan on releasing a new version tomorrow (May 2) that fixes all bugs that have been pointed out thus far. It also has a few new features already :)

 

Glad to hear you find it useful!

  • Like 1

Share this post


Link to post
Share on other sites

Looks nice man.

 

I'm trying to get this to work in PhpStorm. Since it's the editor i use all day at work to and which i have an official license to. It should be a lightweight of the IDEA version if i read it correctly.

 

Now it does install but the icon is shown in grey as you can see on the following screenshot. Do you have any idea or should i just accept it isn't compatible. 

 

 

LehDH2T.png

Share this post


Link to post
Share on other sites

@zupa

 

PHP-Storm should say everything.

 

Even though the base code of all JetBrains producs is often the same, they differ in how plugins are written and some special modifactions for their main purpose. Also they differ in versions.

 

If you installed the plugin from disk and it does not become active, the plugin is most likely incompatible.

 

You need to use Itellij !

 

---

 

@K-Town

Thank you for that plugin. I am using JetBrain tools for quite a while now, and the plugin is very useful. It The editor + you plugin outmatches my notepad++ finally. All the other language supports for other editors have got a lack of feautres or were build for mod setups I do not use.

 

Once you fixed the mentioned error, I can use this as my active working tool. 

If I find any other errors and suggestions I will let you know.

 

 

Regards Arkensor

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for the update! I have some more requests.

 

I just learned about Macros and tried to use them, but it looks like the plugin does not recognize them. It is hard to find anything on them, even when larger mods use them :P .

I also have some minor things: 

Some params sometimes show up as uninitialized, even when you initialize them like this : params["_a", ["_b", true], ["_c", 0]]; 

If you put some code inside brackets for use as a variable (   { private ["_veh] }   ), it thinks the new variable is inside the same scope. This will cause it to say "Variable already declared private" if it is declared elsewhere.

Share this post


Link to post
Share on other sites

Thank you for the update! I have some more requests.

 

I just learned about Macros and tried to use them, but it looks like the plugin does not recognize them. It is hard to find anything on them, even when larger mods use them :P .

I also have some minor things: 

Some params sometimes show up as uninitialized, even when you initialize them like this : params["_a", ["_b", true], ["_c", 0]]; 

If you put some code inside brackets for use as a variable (   { private ["_veh] }   ), it thinks the new variable is inside the same scope. This will cause it to say "Variable already declared private" if it is declared elsewhere.

 

All macros work inside header files, but the only macro that works inside SQF currently is #include. If you want to learn more about them, this is the place to start.

 

As for variables not being initialized inside params, that is a feature I overlooked and will fix that in the next version. As for the {private["_veh"]} example, could you give me a bit more context on that example? Finding scope of variables is the most complex part of the plugin and is hard to debug without code.

Share this post


Link to post
Share on other sites

Hello there,

 

thank you for the update, now everything works for me very well.

Keep it up, and extend the plugin, it is a really good idea!

 

 

Regards Arkensor

Share this post


Link to post
Share on other sites

Hello.
I have problem with syntax error.

In this block of code firs line is considered as an error:

for [{_i = 0}, {_i <  count _candidates}, {_i =_i + 1}] do   // here is some error
{
	// check if this guy is a player
	_processed = _candidates select _i;
	
	for [{_j = 0}, {_j < count allPlayers}, {_j = _j + 1}] do
	{	
		if(_processed == allPlayers select _j) then
		{
			_present = true;
		};
	};
	if(!_present) then
	{
		deleteVehicle _processed;
	};
	_present = false;
};

Also this code is considered as an error:

/**
 * bla bla
**/
//or
/***** PLAYERS *****/

I suppose there is no difference between /* and /**

 

Both are 100% reproducible.

 

Regards.

Share this post


Link to post
Share on other sites

Hello.

I have problem with syntax error.

I suppose there is no difference between /* and /**

 

Both are 100% reproducible.

 

Regards.

 

The comment issue has already been fixed for the next version.

 

There are a number of things that will work with Arma 3's scripting interpreter that won't work for the plugin. This is intentional because if the plugin had as little of syntax checking as the interpreter, the plugin's code would be a mess and harder to maintain.

The general rule I put in place is assignments that are anywhere need to end with a semicolon.

 

With that said, here is the corrected version (notice the semicolons):

for [{_i = 0;}, {_i <  count _candidates}, {_i =_i + 1;}] do   // here is some error
{
	// check if this guy is a player
	_processed = _candidates select _i;
	
	for [{_j = 0;}, {_j < count allPlayers}, {_j = _j + 1;}] do
	{	
		if(_processed == allPlayers select _j) then
		{
			_present = true;
		};
	};
	if(!_present) then
	{
		deleteVehicle _processed;
	};
	_present = false;
};

Share this post


Link to post
Share on other sites

Hello K-Town.

Glad to hear comment fix is on the way.

 

However I am suprised with intentional way of handling of "for".

Mainly because official manual specifically says how "for" should looks like:

https://community.bistudio.com/wiki/for

What you've said about some exclusions in checking of rules questioning point of usage error correction at all.

Of course I understand compexity of plugin maintenance, but as you see I had to ask you on this forum "is everything OK", lost some time to check if code is compatible with reference and finally I've lost all the time I've gain using your plugin.

In this situation maybe justified would be option of "turn off error correction"?

Regads.

Share this post


Link to post
Share on other sites

Hello K-Town.

Glad to hear comment fix is on the way.

 

However I am suprised with intentional way of handling of "for".

Mainly because official manual specifically says how "for" should looks like:

https://community.bistudio.com/wiki/for

What you've said about some exclusions in checking of rules questioning point of usage error correction at all.

Of course I understand compexity of plugin maintenance, but as you see I had to ask you on this forum "is everything OK", lost some time to check if code is compatible with reference and finally I've lost all the time I've gain using your plugin.

In this situation maybe justified would be option of "turn off error correction"?

Regads.

 

The issue lies with the sheer lack of any strictness with SQF. It's a complete nightmare to work on in the plugin and I've constantly tried to persuade myself to quit the plugin entirely and have actually quit in the past. The only reason why I'm still working on it now is because I've had to disregard a specification from time to time. I've always gone with the most strict specification. For example, the for loop's first part can have many assignments:

for [{_a = 2; _b = 1;},{_a < 100},{_a = _a + 1}] do {};

Here you can see that the first semicolon (_a=2; _b=1;) is required here otherwise there would be an error. You can also remove the semicolon from b=1; and it would still be valid. Instead of spending hours in front of a debug console in Arma 3 trying to figure the smallest quirks like that one, I laid down ground rules I know work so I can focus on the features like function auto-completion for call and spawn. I check to make sure that the plugin reports errors when there are actually errors. The false-positives on the other hand just make your code more standard.

 

As for disabling error correction, you might as well use Notepad++. Disabling the syntax checking grammar disables all other features inside the plugin. Everything is built upon the grammar which is why the grammar needs to be concise. The grammar can't be concise with quirks everywhere.

 

The plugin is only in its second version and I released them when I was in school. I can understand that you don't want to use something buggy, but nothing great comes from the first few iterations of anything.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for the update, I have another syntax error bug to report. 

   _isValidWork = {
        if (side _x == west || side _x == east) exitWith {true};
        false
    } forEach (player nearEntities ["Man", 100]);

This code produces the error at forEach. I keep finding the most obscure things in the wiki and finding a use for them.

Share this post


Link to post
Share on other sites

Thanks for the update, I have another syntax error bug to report. 

   _isValidWork = {
        if (side _x == west || side _x == east) exitWith {true};
        false
    } forEach (player nearEntities ["Man", 100]);

This code produces the error at forEach. I keep finding the most obscure things in the wiki and finding a use for them.

I'm not going to fix that because it is messy. Just assign _isValidWork inside the loop.

_isValidWork = false;
{
    if (side _x == west || side _x == east) exitWith {_isValidWork = true;};
} forEach (player nearEntities ["Man", 100]);

I'm beginning to question the point of this plugin again. I don't really see the point in spending time on providing features for a language that has so little of a syntax that you can't even tell if the code was intended to work or not. I mean, seriously. Assigning a variable to a loop? That makes no sense at all....

  • Like 1

Share this post


Link to post
Share on other sites

I'm not going to fix that because it is messy. Just assign _isValidWork inside the loop.

I had actually tried that and it did not work for some reason. Thinking about it again, I think I would have to set the var before the exitWith. If you added a feature to ignore a syntax error, (either by error, line or code block and then have it grey-ed out so people know it is not being checked, a reset would be good as well if someone does something odd) I think that could put less pressure on you so people don't ask for constant implementations of whatever feature they want to use. Personally, this plug in has saved me tons of time debugging so I really like what you made. I understand if you question having to update this plugin, It works most of the time, and only has a bug during obscure things and ones that require time to write or odd checks to work.

 

I would suggest working on it whenever you feel like it and only making packaged releases when a new version of Arma Stable is released so the functions list is updated. This way you are not overworked and updates are on a schedule that makes sense to you.

Regardless, I really appreciate your work. Thank you.

  • Like 1

Share this post


Link to post
Share on other sites

The newest version has been released.

I'm going to be postponing updates to the plugin for a while. However, I'm working extensively on a dialog creator that will be available as an executable as well as inside the plugin itself.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×