Giter VIP home page Giter VIP logo

vscode-sqflint's Introduction

vscode-sqflint

Integrates sqflint tool into VS code.

Prerequisites

Java ( You no longer need to have sqflint installed as it's bundled with extension. )

Works best with SQF Language extension.

Debugger

Experimental debugger that'll scan RPT file for changes and output new messages and errors to console. Go to Debug tab to create debugger config.

Features

Debugger (just watches RPT files for new output)

Debugger launch choice example

Debugger output example

Syntax error checking

Error example

Hover support for commands and BIS functions

Hover example

Signature help for some commands

Signature example

Autocomplete for commands and BIS functions (including basic description)

Autocomplete example

Credits

vscode-sqflint's People

Contributors

mr-guard avatar skacekamen avatar veteran29 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vscode-sqflint's Issues

if statement on variables

I've noticed the following:
If-Statement-Returns do not work on variables.

private _foo = (if (true) then { false; } else { true; });

It would be nice, if you fix this.

Language server crashed

After updating to version 0.5.5 i got the following error:

[...]
Adding bis_fnc_simpleobjectdata 3
events.js:160
throw er; // Unhandled 'error' event
^

Error: write EPIPE
at exports._errnoException (util.js:1026:11)
at Socket._writeGeneric (net.js:706:26)
at Socket._write (net.js:725:8)
at doWrite (_stream_writable.js:307:12)
at writeOrBuffer (_stream_writable.js:293:5)
at Socket.Writable.write (_stream_writable.js:220:11)
at Socket.write (net.js:651:40)
at SQFLint.process (C:\Users\xxx.vscode\extensions\skacekachna.sqflint-0.5.5\server\sqflint.js:88:21)
at SQFLint.runLint (C:\Users\xxx.vscode\extensions\skacekachna.sqflint-0.5.5\server\sqflint.js:23:14)
at Timeout._onTimeout (C:\Users\xxx.vscode\extensions\skacekachna.sqflint-0.5.5\server\sqflint.js:110:23)
[Error - 22:20:24] Connection to server got closed. Server will not be restarted.

Mathematical operators cause unexpected behaviours

Hello @SkaceKamen,

I've found 2 issues regarding mathematical operators that break your plugin in the current file

  • Using operators on commands (such as "time") breaks any futher debugging (this bug, breaks the debugger out of its current scope)

Example:
This is a perfectly legit script-code. Yet you notice that not only the "else" statement is marked as error but also all follwing "case" statements and closing brackets. This is all caused by the "-3" behind the time command.
sqflint_mo_breack

  • While _varC =_varA - varB is not marked as an error, _varC = -varB is.

I often use mathematical operators like this with parameters which results me in having false errors in the console and debugger. Example:
sqflint_mathematicaloperators

Hope it's not too hard to fix ;) Great project btw. will, try to raise more attention on it.
/ Armitxes

Function macro expansion

#define MACRO(x) _x = x
MACRO(a);

Is incorrectly expanded as:
_a = a;

The correct expansion is:
_x = a;

Context aware variable existence detection fails on inline functions

Context aware detection fails under cenrtain conditions

_array = [];
_something = 1;

// _something is reported undefined
_array select { _x == _something }; 

// _something is reported undefined
_array findIf { _x == _something };

// _something, _array is reported undefined in the inner blocks
(count(_array) == 1 && { count(_array) == 1 && { _someting == 1 && count(_array) == 0 } });

(moved from #36)

Version 0.8 crash

SQFLint extension crashes after updating to Version 0.8

Indexing workspace...
SQFLint: Process crashed { Error: spawn java ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn java',
  path: 'java',
  spawnargs: 
   [ '-jar',
     'C:\\Users\\Dorbedo\\.vscode\\extensions\\skacekachna.sqflint-0.8.0\\bin\\SQFLint.jar',
     '-j',
     '-v',
     '-s' ] }
(node:17708) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: write EPIPE
(node:17708) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
SQFLint: Process crashed with code -4058

Cannot read property 'bis_fnc_mp' of undefined

TypeError: Cannot read property 'bis_fnc_mp' of undefined at result.variables.forEach (c:\Users\Admin\.vscode\extensions\skacekachna.sqflint-0.9.7\server\server.js:396:59) at Array.forEach (<anonymous>) at client.parse.then (c:\Users\Admin\.vscode\extensions\skacekachna.sqflint-0.9.7\server\server.js:379:46)

Sqflint does not recognize Windows style paths

This valid line of code:
_addzone = [] execVM "persistent\persistent_stats_zones_add.sqf";
will produce this warning when using Windows style path separators:
File 'persistent\persistent_stats_zones_add.sqf' doesn't exists.

To my understanding, this is not expected behavior, especially since most (if not all) the examples used on the BI Wiki use this format.

In addition, prepending with a / to persistent\persistent_stats_zones_add.sqf the will remove the warning which, again, isn't the expected outcome.

Not recognizing if..then ARRAY

if (true) then [{true},{false}];
Is the same as
if (true) then {true} else {false};
But sqflint errors on the first with Expected block after then. error on the opening array bracket.

Added possibility to define prefixes for include preprocessor command

Add new config section allowing user to assign path to specific include prefixes. For example to assign

\a3 -> c:\unpacked-a3\

So when you have include in your script like this one:

#include "\a3\ui\some_macros.hpp"

it will actually try to include c:\unpacked-a3\ui\some_macros.hpp making it possible to load contents of packed files (provided you unpack them to specified directory using some pbo unpacker).

includePrefixes seems to work only in sqf and not in hpp files

I configured the includePrefixes in the settings to recognize the unzipped cba code on my P drive:

"sqflint.includePrefixes": {
    "\\x\\cba\\": "P:/x/cba/"
}

This seems to work fine when I include the main script macros in a sqf file:
#include "\x\cba\addons\main\script_macros.hpp"
but doesn't work when included in a Arma header file (.hpp for example)

CfgFunctions parser issue

Reference: #19 (comment)

But there is already parser for cfgFunctions in description.ext.

Hrm, then I guess it don't go some levels further down concerning includes.

In my current project it's structured that the description.ext includes a functions.hpp in the root folder. And that functions.hpp just fetches (via includes) the functions from other functions.hpp files which are inside seperate module folders. Guess some kind of comparable to the structure @TheMysteriousVincent mentioned.

Could it be possible that it just include one level further down from the description.ext but don't include further levels from that point?

with uiNamespace do is incorrect by linter

with uiNamespace do {call compile format ["[""LOADED"", controlNull] call (missionNamespace getVariable ""%1"");", _resource_fnc]};

Is detected wrong by the linter and displays as an error where in truth it is correct.

Autocompletion for own/ACE/CBA variables/functions

Currently the autocompletion only shows BI commands.
It doesn't show/suggest:

  • Global variables defined in the project
  • Local variables defined in same file or scope
  • Functions defined in the project via CfgFunctions (but display tooltip on them when hovering)
  • CBA functions
  • ACE functions

Settings in environment:

"sqf.enableCBA": true, (SQF Language from Armitexes)
"sqf.enableACE3": true, (SQF Language from Armitexes)
"sqflint.ignoredVariables": [
    // Some global variables from our project which are set via preprocessor macros on missionNamespace. Ref: https://github.com/KillahPotatoes/KP-Liberation/blob/v0.97S12/Missionframework/presets/armies/script_component.hpp
],

Every other setting is on its default value.

Add working preprocesor for ext/hpp files

Right now, the description.ext parser gracefully skips preprocesor commands and only includes required files. That works as long as the user doesn't use macros.

This causes issues when loading cfgFunctions in cases, where they're defined using macro.

High CPU usage in VSCode 1.20.0

Hello

After I updated to VSCode 1.20.0, I get high CPU usage when not doing anything. If I only disable this extension and leave all others on (including SQF Language).
The JVM is consuming the CPU usage.
capture
I am on Windows 10 Pro x64 and my Java build is 1.8.0_161-b12.
My CPU is an i5 7600K overclocked to 4.8 GHz, so that you can get a sense of how intensive the bug is.

Translation strings break parser

Translation strings ($STR_name) break parser when used in description.ext or in classes in header files.

When used in description.ext the language server reports incorrect line/file with problem and points to some random part of code. When used in class it shows correct position.

I've attached archive with files that I used for testing.

I've found this problem when I was debugging why function library parsing does not work for us in KP-Liberation#0.97 repository.

Thanks for developing this great tool, it was really useful so far!

Adding SQF commands

Is it possible to add commands e.g. <any> doSomething <code> via configuration files or otherwise, without rebuilding sqflint?

Exclude Folders

Hey there and many thanks for providing this tool to work with SQF. In my opinion really an essential tool if you want to work with SQF.

I'm currently trying to exclude a folder in my workspace from indexing.
Basically it's old code which should not be indexed, show errors etc.

I've added the

"sqflint.exclude": ["oldCode/"]

in my settings.
But there are still errors shown which are linked to scripts inside that folder.
So my question is how the path should be provided.
I've tried

  • "c:\Path\to\workspace\oldCode\"
  • "c:/Path/to/workspace/oldCode/"
  • "\oldCode\"
  • "/oldCode/"
  • "./oldCode/"
  • "oldCode/"

Just keep asking myself what is the right format you need in the exlude path array.

Would really appreciate a hint or explanation :)

Many thanks in advance.

Absolute include paths

Are absolute include paths e.g. #include "my\my_addon\my_file.h" supported?

In my project source the corresponding path is addons/my_addon/my_file.h.
Is it possible to configure include path resolution to take this into account?

problems with # and params

Behind the "_group;" the error Encountered ";". Was expecting one of: "=" ... ">" ..." will be shown.

(disconnectCache # (_find # 0)) params ["_uid", "_group"];
	
[player] joinSilent _group;

VSCode is no longer supporting specifiying a commandId in the "initialConfigurations" contribution

Hi,

We noticed your extension in package.json is using a "initialConfigurations" contribution in a deprecated way by specifiying a command id.
We wanted to let you know that we plan to delete support for this specific use of "initialConfigurations" soon.
More about this deprecation can be found here and in our release notes.
A good example on how to use the DebugConfigurarationProvider which is the new way of doing this can be found here

Also note other deprecations which are specified in our release notes (which can be found on our site).

Kind regards,
Isidor from the VSCode team

Possibility to define SQF workspace functions and documentation

It would be great if the user himself can define global functions and add suitable documentations for it.
For example, I want to create a mod with this package structure:

/
    @Mod/
        addons/
            pkg1/
            pkg2/
            pkgN/
            [...]

If you now want to use a function from pkg1 in pkg2 you can't because the used function is not defined in pkg2 or is not defined in the consuming script. But it is obviously defined in pkg1.

I would appreciate it if you add support for global functions, like how it is done with the CBA functions.

CfgFunctions issue with 0.9.8

Since the update this night all own functions, defined via CfgFunctions.hpp, are marked as possibly undefined variables.

Before the update, same project, it worked fine and also parsed the function header as tooltip.

String definitions gone wrong

It is just a short noticement. Since I scripted with a "false" string definition. I do not get the main error. Simply because there was no Engine-Type-Error.
The following is the problem:

_var = '"'; // not possible
_var = '""' // it have to be quoted

I would recommend that you just add quoting of <"> in a string definition with <'> surrounding.
Thanks.

Config - array in array square brackets not supported.

It seems that in config files inner arrays can also use "[ ... ]" instead of "{ ... }".

This is valid and works in sqflint:

class KPLIB_MapControl {
    stickX[] = {0.2, {"Gamma", 1, 1.5} };
};

This is valid and breaks the sqflint parser:

class KPLIB_MapControl {
    stickX[] = {0.2, ["Gamma", 1, 1.5] };
};

This is not valid:

class KPLIB_MapControl {
    stickX[] = [0.2, ["Gamma", 1, 1.5] ];
};

#define only likes 1 whitespace

I don't know how long this small issue persists, I just recognized it some days ago.
The preprocessor command #define is causing the linter to throw an error, when there is more than one whitespace after the command. Guess it's a small and easy fix. ๐Ÿ™‚

// This shows errors in the linter
#define        bla        1

// this is fine
#define bla            1

// it doesn't accept more then one whitespace after #define

fine

notfine

notfinetooltip

_input0, _input1,... not recognized as defined in BIS_fnc_sortBy

Reference: https://community.bistudio.com/wiki/BIS_fnc_sortBy

_this select 1: input parameters (Array)
    - used in the eval algorithm (object/numbers/strings ..)
    - input params are referenced in the sorting algorithm by _input0, _input1 .. _input9
    - max. number of 10 input params is supported (0-9)

_input0 etc. are shown as possible not defined, which is basically right, but not if it's used in the parameter list of the above function.

Example:
https://github.com/Wyqer/kp_liberation/blob/v0.97/Missionframework/modules/01_core/fnc/fn_core_getNearestSector.sqf#L25

Fails to recognize missing colon (,) in arrays

This does not produce error:

params [
    ["_start", nil, [[]], 3],
    ["_end", nil, [[]], 3],
    ["_focus", nil, [objNull, []], 3]   // <-- missing "," does not result in syntax error
    ["_camera", nil, [objNull]]
];

Additional colon is properly seen as error:

params [
    ["_start", nil, [[]], 3],
    ["_end", nil, [[]], 3],
    ["_focus", nil, [objNull, []], 3],
    ["_camera", nil, [objNull]], // <-- produces error
];
private _arr = ["1" "2", "3"]; // no error
private _arr = ["1", "2" "3"]; // no error
private _arr = ["1", "2" "3",]; // error

Not working on Mac OS?

Hello,

on my Mac the SQFLint extension don't work. Actually nothing. It this 'expected' or not?
My version: macOS Sierra 10.12.3 (no hackintosh, original)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.