kayler-renslow / arma-intellij-plugin

A plugin for Intellij IDEA that allows for syntactical analysis, code inspections, and other nifty features for the SQF scripting language in Arma 3.
MIT License
41 stars 9 forks source link

NullPointerException in file with warning, not error #21

Closed sygsky closed 8 years ago

sygsky commented 8 years ago

in file:

// x_deleteunits by Xeno. Removes all enemy units (men+vecs) in the range around town/airbase
private ["_index", "_dummy", "_current_target_pos", "_current_target_rad", "_old_units_trigger", "_i", "_list"];

if (!isServer) exitWith{};

_index = _this;
_old_units_trigger = "";

if ( _index >= 0) then
{
    _dummy = target_names select _index;
    _current_target_pos = _dummy select 0;
    _old_units_trigger = createTrigger["EmptyDetector",_current_target_pos];
    _current_target_rad = ((_dummy select 2) max 300) + 50;
    _old_units_trigger setTriggerArea [_current_target_rad, _current_target_rad, 0, false]; // round shape trigger
}
else // take of airfield completed (new action, before any town!!!)
{
    hint localize "x_scripts/x_deleteunits.sqf: called on airbase taken event";
    _old_units_trigger = createTrigger["EmptyDetector",d_base_array select 0];
    _old_units_trigger setTriggerArea [(d_base_array select 1) + 50, (d_base_array select 2) + 50, d_base_array select 3, true]; // rect shape trigger
};
_old_units_trigger setTriggerActivation [d_enemy_side, "PRESENT", false];
_old_units_trigger setTriggerStatements["this", "", ""];

sleep 240;

for "_i" from 0 to 6 do {
    _list = [];
    {
        if (((position _x) select 2) < 20) then {if (!(_x in _list)) then {_list = _list + [_x]}};
        sleep 0.01;
    } forEach (list _old_units_trigger);
    sleep 0.12;
    {
        if (!(_x isKindOf "Man")) then {
            {deleteVehicle _x} foreach [_x] + crew _x;      
        } else {
            if (!(isPlayer _x)) then {deleteVehicle _x};
        };
        sleep 0.05;
    } foreach _list;
    sleep 1.021;
};

sleep 0.321;

deleteVehicle _old_units_trigger;

if (true) exitWith {};

In line if (((position _x) select 2) < 20) then {if (!(_x in _list)) then {_list = _list + [_x]}};

the NullPointerException occure in plugin (accoding ot JIdea repetitive mesasages) if file is in focused editor window:

java.lang.NullPointerException at com.kaylerrenslow.a3plugin.lang.sqf.psi.mixin.SQFStringMixin.getReferences(SQFStringMixin.java:42) at org.intellij.plugins.intelliLang.references.InjectedReferencesContributor.getInjectedReferences(InjectedReferencesContributor.java:56) at org.intellij.plugins.intelliLang.references.InjectedReferencesInspection$1.visitElement(InjectedReferencesInspection.java:38) at com.intellij.psi.impl.PsiElementBase.accept(PsiElementBase.java:274) at com.kaylerrenslow.a3plugin.lang.sqf.psi.impl.SQFStringImpl.accept(SQFStringImpl.java:27) at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:81) at com.intellij.codeInspection.InspectionEngine.createVisitorAndAcceptElements(InspectionEngine.java:69) at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.runToolOnElements(LocalInspectionsPass.java:294) at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.access$200(LocalInspectionsPass.java:73) at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$2.process(LocalInspectionsPass.java:261) at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$2.process(LocalInspectionsPass.java:256) at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:128) at com.intellij.concurrency.ApplierCompleter.access$000(ApplierCompleter.java:44) at com.intellij.concurrency.ApplierCompleter$1.run(ApplierCompleter.java:91) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1178) at com.intellij.concurrency.ApplierCompleter$2.run(ApplierCompleter.java:100) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:443) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54) at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:112) at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:88) at jsr166e.CountedCompleter.exec(CountedCompleter.java:684) at jsr166e.ForkJoinTask.doExec(ForkJoinTask.java:260) at jsr166e.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:858) at jsr166e.ForkJoinPool.scan(ForkJoinPool.java:1687) at jsr166e.ForkJoinPool.runWorker(ForkJoinPool.java:1642) at jsr166e.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:108)

Typical error message log is as follow:

23:15:05 NullPointerException: null 23:15:13 NullPointerException: null 23:15:22 NullPointerException: null 23:15:25 NullPointerException: null 23:15:39 NullPointerException: null 23:15:43 NullPointerException: null 23:15:45 NullPointerException: null 23:19:16 NullPointerException: null

If file is not in focused window, exception stops reproducing.

As only you insert ';' symbol near end of this line as follow:

if (((position _x) select 2) < 20) then {if (!(_x in _list)) then {_list = _list + [_x];}};

the error message immediately stop to reproduce forever. Between stop/start JIdea the error is alive if ';'after '[_x]'and before '}' is absent.

It seems to be not error in sqf syntax, but error in your very usefull plugin. With or without ';' script is working good.

kayler-renslow commented 8 years ago

What version of the plugin are you using? You can find out the plugin version by going to the header menu (File, Edit, etc), Arma Plugin->About. Thanks for the error report.

sygsky commented 8 years ago

Arma Plugin Version 1.0.5

IntelliJ IDEA 2016.1.3 Build #IC-145.1617, built on June 3, 2016 JRE: 1.8.0_77-b03 x86 JVM: Java HotSpot(TM) Server VM by Oracle Corporation

kayler-renslow commented 8 years ago

I have resolved this issue and will be in next version. I'm currently trying to fix a massive bug and when I fix that one, both bugs will be fixed in next version and then released.

kayler-renslow commented 8 years ago

Fix is in release 1.0.5_1, which is now available.