Coder Social home page Coder Social logo

vscode-rpgle's Introduction

vscode-rpgle README

Adds functionality to assist in writing accurate, readable and consistent RPGLE, including:

  • Content assist
  • Outline view
  • Linter, including indentation checking and reformatting (**FREE only)
  • Column assist for fixed-format RPGLE.

Depends on the Code for IBM i extension due to source code living on the remote system when developing with source members.

Documentation

Check out the official documentation for a usage guide.

Developing

  1. Fork & clone
  2. npm i
  3. Run

Debugging

To run the tests, you have two options:

  1. npm run test from the command line
  2. 'Debug Tests' from the VS Code debugger

To run debug the extension and server, from the VS Code debugger:

  1. Debug 'Launch Client'
  2. Debug 'Attach to Server'

Previous contributors

Thanks so much to everyone who has contributed.

vscode-rpgle's People

Contributors

brandonp42 avatar chrjorgensen avatar marcin-ogon avatar moralescr avatar p-behr avatar richardm90 avatar sebcil avatar sebjulliand avatar sjlennon avatar worksofliam avatar wright4i avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar

vscode-rpgle's Issues

Need to restart VSCODE to make the Linter active.

I did not have an RPGLINT.JSON file.
I started VSCODE.
I opened an RPGLE **FREE member. No errors are reported.
I used F1 and Open RPGLE lint configuration and created a RPGLINT.JSON.
I get the "Duplicate id declaration" in problems. (not sure if this is significant).
I switched back to the tab with the RPGLE code. Line 4 and line 9 should have errors but none show.
image
I close and reopen the member. Still no errors.
I close the member, then close an re-start VSCODE and open the member. And now the errors are shown:
image
If this is working as expected, then perhaps the readme needs to be updated to mention that VSCODE needs to be restarted to make the Linter active, or perhaps add a message to that effect to the dialog.

Lint option: Stick to a consistant way of referencing other source (COPY or INCLUDE)

I would normally say that /COPY is better because it is included by default when compiling SQLRPGLE without having to compile at *LVL2 however I did notice that IBM state this:

https://www.ibm.com/docs/en/i/7.1?topic=directives-copy-include

/COPY members are considered fixed-form by default, even if the /COPY directive is coded within a free-form group. If the /COPY member will contain free-form specifications, these must be delimited with /FREE and /END-FREE directives.

so INCLUDE does have it's advantages!

Could we have an option i.e. COPY or INCLUDE to make the behaviour consistant?

After conversion to **FREE, quick fix of indent deletes position 1-5

We use positions 1-5 currently for mod marks, tied to a mod number in the header. when i convert an RPG to **FREE, these marks are just deleted. Would it be possible via a setting or something to move them to the end of the source line as a // comment or something. we are still trying to determine our rules for mod marking in **FREE code, and this is kind of how we are leaning.

Code completion + linter

Maybe I am doing something wrong. When I do a DO it auto completes, however, the linter is given the wrong indentation on it.

CleanShot 2021-12-06 at 09 04 10
CleanShot 2021-12-06 at 09 05 35

RPGLE cli

Parser and linter should also be a separate CLI tool and not be dependent on VS Code. Of course that means it will only work on local files.

# print lint issues
$ rpglint ./file.rpgle

# prints all known symbols
$ rpglint ./file --defs

RPGLE linter

Linter would be cool. Was thinking the options could be defined in a .json file somewhere, whether a source file or in the IFS.

Some potential settings:

  • QualifiedCheck - When true, will warn about structs defined without the qualified keyword.
  • PrototypeCheck - When true, will warn about prototypes defined without extpgm or extproc.
  • TooMuchHardCoding - When true, will warn about string and numeric constants that have been used in more than one place.
  • UpperCaseSpecials - When true, will warn about all special constants that are not uppercase.
  • BlankStructNamesCheck - When true, will warn about structs that are defined with a name of *N (no name).
  • UseBlankSpecial - When true, will warn when '' is used and will suggest to use *BLANK instead.
  • ForceOptionalParens - When true, will warn when conditional operations are used without parentheses
  • PointOutUseless - When true, will point out variables, structs and prototypes that are not used.
  • NoOCCURS - When true, will warn when the OCCURS keyword is used on definitions
  • NoCTDATA - When true, will warn when the CTDATA keyword is used on definitions
  • UselessOperationCheck - When true, will warn when when EVAL or CALLP is used
  • NoSELECTAll - When true, will warn when SELECT * is used in an embedded SQL statement
  • CanConvertSubroutines - When true, subroutines are used and procedures are not, will check to see if a subroutine could become a procedure

Use VS Code cache instead

Instead of using custom cache mechanism, look into using openTextDocument instead.. which looks like it may provide it's own cache..?

RPG Lint configuration error

Describe the bug
Opening the RPGLE Lint configuration produces an error

To Reproduce
F1 - RPGLE Open RPGLE lint configuration

Expected behavior
To see lint config

Screenshots
2022-01-07_09-51-39

Environment (please complete the following information):

  • Extension version
  • IBM i OS version 7.3
  • VSCode insiders 1.64.0
  • Windows 11

Linter not working

Describe the bug
I installed the linter to my VSC and followed the instructions, but is not 'marking' where the errors are happening in a **FREE source and I think it's because the JSON when written into the iSeries is not recognizing the {} like this:

This is when I open the linter on VSC
Screen Shot 2022-01-10 at 5 40 23 PM

This is how it's seen in the pub400 source file
Screen Shot 2022-01-10 at 5 40 44 PM

Environment (please complete the following information):

  • Extension version 0.3.0 of RPLE language tools
  • IBM i OS version V7R4M0

Could it be that I need to map some values for these chars?

thank you
Ramon Sandoval

Lint Qualified data-structure

Hi,

a simple bug, a likerec Datastructure is implicity qualified,
so Could you remove the quick fix bug?

Many thanks.

image

Keeping up with Lint configuration options

(This is not a complaint--I understand this is an evolving extension.)

I have trouble keeping up with new configuration options. Today I saw someone else's RPGLINT.JSON and discovered he had options I didn't know about.

So I renamed my RPGLINT.JSON to RPGLINTOLD.JSON, restarted VS Code and had it create a new RPGLINT.JSON. Now I can run a compare, see the new options and the one's I have changed.

Questions:

  1. Is this the best way to find out about and install new options? If so, it means I have to reset any that I changed. If I had my druthers, I think I'd like to see new options put in automatically when the RPGLINT.JSON is opened by the extension and a message something like "New Lint options have been added."
  2. Short of renaming RPGLINT.JSON, is there a quick way to turn off and on linting? I think it would be convenient just to be able to turn it off temporarily while dealing with coding errors. It can be a bit intrusive, because "Clear Diagnostics" doesn't clear lint errors.

Just for grins, here's my compare. Note that I seem to have one that has disappeared, though that may be something I did.
image

END-PI emitted before DCL-PI

When i Convert an entire program to fully free format, the D spec conversion for my procedure comes out with the END-PI before the DCL-PI.

Add ON-EXIT to indentation rules in linter.js

Requesting the addition of ON-EXIT to indentation rules in linter.js. At the time I'm submitting this request (2022-01-09 @ 12:34pm EST), that would be line 622.

Current:
if ([
IF, ELSE, ELSEIF, FOR, FOR-EACH, DOW, DOU, MONITOR, ON-ERROR, BEGSR, SELECT, WHEN, OTHER, DCL-PROC, DCL-PI, DCL-PR, DCL-DS
].includes(opcode)) {

Proposed:
if ([
IF, ELSE, ELSEIF, FOR, FOR-EACH, DOW, DOU, MONITOR, ON-ERROR, ON-EXIT, BEGSR, SELECT, WHEN, OTHER, DCL-PROC, DCL-PI, DCL-PR, DCL-DS
].includes(opcode)) {

Lint Option: Use SQLSTT instead of SQLCOD

SQL-92 YES 1992!!!

section 22.2

Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated feature that is supported for compatibility with earlier versions of this International Standard. See Annex D, "Deprecated features".

Name on end-proc/end-pi

A name is optional, but the linter thinks it is a procedure call. As in lines 6 and 12 below:

image

Also the indentation warning on line 10 seems wrong.

Is there are way to turn off "Expressions must be surrounded by brackets.", as on line 8? What's the rational of requiring this on a single condition?

Support for code in local workspace

What should I include in the settings for the outline view to work?
I work with a file not on a local computer. Extension - .rpgle
File starts with ** free

Quick fix for indentation causes lint issue with DCL inside PRocedures

I used the auto-convert to convert an entire program that was mixed format. the D specs were in column format. After conversion, i used quick fix to fix the LINT indent errors, and the DCL statements inside the procedure all were indented at 0 and cause a LINT error. I moved them to position 4 and the LINT message went away

Enhancement: Procedures should not access Globals

Subtle error can be introduced if a sub procedure accidentally refers to a global definition when it should be referring to a passed parameter or a local variable.
In the (contrived) code below, there is a typo bug 4 lines from the bottom at << Error here <<. StdDsc should really be StdDisc. The program still compiles and runs, but gives incorrect results in some cases.

It would be neat if Lint could flag use of global value in sub-procedures.

This may be tricky to do. I also note that there is an RFE for the RPG compiler from back in 2016 to address this issue. It has 74 votes but remains an "Uncommitted Candidate".
https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=97164

**free
ctl-opt debug  option(*nodebugio: *srcstmt) dftactgrp(*no) actgrp(*caller)
main(Main);
dcl-s STDDSC  packed(5:2) inz(9.0); //from Item Master External  DS
dcl-proc Main;
    dsply %char(CalcDiscount(10000));
    dsply %char(CalcDiscount(1000));
    return;
end-proc;
// New routine replaces field STDDSC in Item Master
dcl-proc CalcDiscount ;
    dcl-pi CalcDiscount packed(7:2);
        iCost packed(7:2) value;
    end-pi;
    dcl-s StdDisc packed(5:2) inz(10);
    dcl-s BigDisc packed(5:2) inz(5);
    dcl-s wkDisc packed(7:2);
    if (iCost >= 10000);
        wkDisc = (iCost*BigDisc)/100;
    else;
        wkDisc = (iCost*StdDsc)/100;  // << Error here <<
    endif;
    return wkDisc;
end-proc;

Hover assist should display definition details for variables, constants, data structures, files, etc.

When browsing and attempting to follow existing code, it would be nice to be able to hover over a variable name, for example, to display definition details about that field and where it is defined (i.e. external definition location, data type, length, etc.). It would also be helpful to offer the external location for file declarations as well. RDi offers this feature and is quite handy, especially for following programs you are not the author of.

Example:
If I hover over this variable, it should give me the definition details in a tool-tip type of hover box.
image

RDi example:
image

rpgleIndentationEnabled Gone?

Where did "code-for-ibmi.rpgleIndentationEnabled": true go? I know it was experimental, but I liked the feature ! And it worked fairly recently, now it is "unknown Configuration setting". In fact, per #387, it looked like it would be handy to totally fix indention.

I don't can't see any references here. Only this:

Enable these options in VS Code settings.

vscode-rpgle.rpgleColumnAssistEnabled - column assist for RPGLE fixed-format.
vscode-rpgle.rpgleColumnAssistant / Shift+F4 to launch it when on fixed-format line
vscode-rpgle.rpgleContentAssistEnabled - shows content assist and enables the following commands
vscode-rpgle.rpgleOpenInclude / Shift+F12 when on copy or include statement
vscode-rpgle.rpgleLinterSupportEnabled - enables linter
vscode-rpgle.openLintConfig to open or create linter file. Creates / opens relative to source that is currently open. Read more below on linting.

I have 0.0.4 of the extension installed, but get some (inconsistent) messages and squiggly line on indentation. Couple of examples:
image
image

outline and lint not working

Hello, i am on MAC.
I have the extension vscode rpgle. I have enabled content assist, lint in the setting,
I have an RPGLE program (**Free), the lint and outline view is not working.
even the snippets %scan is not working

rpgleIndentation: Add "Quick Fix"

Can we add Quick Fix capability when an indentation error is reported? Also with the option to fix all indentation errors in the member.

Logo

I'd like a logo for this extension. Is there an RPG mascot we could make use of or something?

Question: Expressions surrounded by brackets

Why does an expression with a single condition need to be surrounded by brackets?
For example:

    if a ='/';
        a=' ';
    endif;

It makes sense if there is more than one condition, especially if there is and/or logic, for example:
if a ='/' or a = '&' and b = ' ';

It would make sense in expressions like this but it doesn't complain about them:

wkDisc = iCost*stdDisc/100;

Finally, is there an option in RPGLINT.JSON to turn off expression brackets checking.?

{
  "BlankStructNamesCheck": true,
  "QualifiedCheck": true,
  "PrototypeCheck": true,
  "ForceOptionalParens": true,
  "NoOCCURS": true,
  "NoSELECTAll": true,
  "UppercaseConstants": true,
  "IncorrectVariableCase": true,
  "RequiresParameter": true,
  "StringLiteralDupe": true,
  "NoSQLJoins": true
}

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.