Coder Social home page Coder Social logo

al-codeactions's People

Stargazers

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

Watchers

 avatar  avatar

al-codeactions's Issues

Code Actions do not work anymore

I don't know how and when exactly it happened, but all your app code actions are not provided for me anymore.

image

I am using, as required, the latest versions of your app and of the apps you are depending on:
image

Code actions are enabled for AL Language.

VS Code Version: 1.46.1

Any ideas ...?

"Create procedure": Handle return value type and length

    procedure MyFunction()
    var      
        MyCode5Variable: Code[5];
    begin
        MyCode5Variable := MyNewFunction('CCCCC');     // missing
    end;

"Create procedure":
Currently:

 local procedure MyNewFunction(arg: Text): Variant
    begin
        Error('Procedure not implemented.');
    end;

Expected:

 local procedure MyNewFunction(arg: Text): Code[5]
    begin
        Error('Procedure not implemented.');
    end;

That would be great :)

New Feature "Extract to procedure"

There should be a possibility to extract a few selected lines to a new procedure.
The variables and parameters needed should be identified automatically.

[Idea] Check Procedure Event Name for Affix

If I use an affix for event signatures in table extensions (e.g. XXX_OnBeforeDoSomething), I don't receive the quickfix for creating an event.

Maybe it is possible to check for the Affix in the AppSourceCop.json?

At the moment i solved this problem for me by using a suffix. (OnBeforeDoSomething_XXX)

What do you think about that?

Create unknown procedures as event publishers

My suggestions are based on my personal need only; probably they should be controlled by settings instead:

  • If the unknown procedure name starts with keyword "On" + any capital letter, then decorate the new procedure with [IntegrationEvent(false, false)]
  • Put the new method at the very bottom, where usually all event publishers are gathered

The "Unable to get position to insert the procedure" error seems to be back again

The "Unable to get position to insert the procedure" error seems to be back again
(#70)

"AZ AL Dev Tools/AL Code Outline" v2.0.8
"AL CodeActions" v0.2.14
VSCode v1.47.3
AL Language v3.0.106655

I get the error, when I try to run the "Create Procedure OnTestSomething" action in the following example:

codeunit 50000 "Test"
{
    trigger OnRun()
    var
        A: Text;
        B: Integer;
        OK: Boolean;
    begin
        OK := OnTestSomething(A, B);
    end;
    
    var
        myInt: Integer;
}

Thanks.

Possibility to create a procedure in table when you are using the CodeAction from a page

Hi David,
would it be possible to extend the functionality a bit to also create a procedure in the Source Table of a Page?
When I am in a custom page, I would like to have the business logic in my custom table instead of the page.

image

Maybe by adding a second option "Create Procedure 'XYZ' in Table 'CustomTable'"?

Not sure if that is too complicated, but I had two cases where I needed that :-)

Create Procedure: Missing Boolean return value

In a test codeunit, create the following procedure:

    local procedure AssertMyFunction_True(MyText: Text)
    var
        Assert: Codeunit Assert;
    begin
        Assert.IsTrue(MyFunction(MyText), '');
    end;

Run the quick fix on MyFunction. Actual result:

	local procedure MyFunction(MyText: Text)
	begin
		Error('Procedure MyFunction not implemented.');
	end;

Expected result:

	local procedure MyFunction(MyText: Text) : Boolean
	begin
		Error('Procedure MyFunction not implemented.');
	end;

Create procedure: Missing return value when called in exit statement

I am having the following issue. When i have a procedure call which return value is written to a variable everything is working as expected:

procedure GetReceivedFlag(var rData: Text): Boolean
    var
        lOk: Boolean;
    begin
        lOk := GetReceivedFlagRemote(rData);
        exit(lOk);
    end;

Creates

     local procedure GetReceivedFlagRemote(var rData: Text): Boolean
    begin
        Error('Procedure GetReceivedFlagRemote not implemented.');
    end;

But when writing it into an one liner the return value is missing:

    procedure GetReceivedFlag(var rData: Text): Boolean
    begin
        exit(GetReceivedFlagRemote(rData));
    end;

Creates:

    local procedure GetReceivedFlagRemote(var rData: Text)
    begin
        Error('Procedure GetReceivedFlagRemote not implemented.');
    end;

Create Procedure: Objects by name not recognized as integer

Hi David,

Creating a new procedure for
MyFunction(Database::"Sales Header");
or
MyFunction(Page::"Sales Order");
etc.

returns

	local procedure MyFunction(arg: Variant)
	begin
		Error('Procedure MyFunction not implemented.');
	end;

instead of

	local procedure MyFunction(i: Integer)
	begin
		Error('Procedure MyFunction not implemented.');
	end;

Use long variable name instead of Rec as parameter name when creating procedures

Hi David,

when I create a procedure from a page or table where I have an implicit "Rec", I sometimes want to pass this variable into a new procedure. For example in this PageAction I would like to create the new procedure "CreateOrderFromWebshopOrder".

image

The new procedure will have a parameter "Rec: Record "Webshop Sales Header WEB11 CCO".

image

Would it be possible to automatically rename this parameter Rec by using the object name?
Instead of "Rec: Record "Webshop Sales Header WEB11 CCO"----
...this? WebshopSalesHeader: Record "Webshop Sales Header WEB11 CCO"

image

Basically by using the same functionality that is already implemented in the AL Variable Helper when you create a new record:

image

But maybe I am the only one who would like to have that :-D

Create Procedure: Cannot handle Enum value passed as parameter

Sorry if I've overlooked it somehwere:

Create the following code line:
MyNewProcedure(Enum::"Sales Document Type"::Order);

and run code action "Create Procedure".

Result:

	local procedure MyNewProcedure(Enum: Enum)
	begin
		Error('Procedure MyNewProcedure not implemented.');
	end;

Expected:

	local procedure MyNewProcedure(SalesDocumentType: Enum "Sales Document Type")
	begin
		Error('Procedure MyNewProcedure not implemented.');
	end;

Extract to Procedure: not provided if leading space missing in selection

For a quick test, please use this very stupid code:

if not (1 in [2, 3]) then begin 
end;

Imagine, you would like to extract the "complicated" expression into a procedure.

If you mark everything from ( to ), then the code action won't be not provided:
image

It will be provided only if you mark the leading space:
image

Bug or feature?

[Suggestion] Refactor Assignment to Validate

Not sure if feasible, but would it be possible to select a large chunk of code, then have a Code Action that replaces any

Rec.Field := [something];

With

Rec.Validate(Field,[something]);

German Special Characters in 'Create procedure'

When using the 'Create procedure' functionality with variables that for example contain german special characters, then the character is removed from the created parameter.

How to reproduce:

Create a new Codeunit

codeunit 99952 Test
{
    procedure MyProcedure()
    var
        Länge: Integer;
    begin
        MySecondProcedure(Länge);
    end;
}

Now use 'Create Procedure' on the reference to MySecondProcedure.
That creates this:

codeunit 99952 Test
{
	procedure MyProcedure()
	var
		Länge: Integer;
	begin
		MySecondProcedure(Länge);
	end;

	local procedure MySecondProcedure(Lnge: Integer)
	begin
		Error('Procedure MySecondProcedure not implemented.');
	end;
}

expected:

codeunit 99952 Test
{
	procedure MyProcedure()
	var
		Länge: Integer;
	begin
		MySecondProcedure(Länge);
	end;

	local procedure MySecondProcedure(Länge: Integer)
	begin
		Error('Procedure MySecondProcedure not implemented.');
	end;
}

Add Result parameter as var to Event

I think it could be usefult to add Result parameters as var to automatically created events:

procedure TestSomething(Input: Integer) Result: Boolean
var
    IsHandled: Boolean;
begin
    IsHandled := false;
    OnCheckSomething(Input, Result, IsHandled)
end;

This would result in the following Event:

[IntegrationEvent(false, false)]
local procedure OnCheckSomething(Input: Integer; var Result: Boolean;  IsHandled: Boolean)
begin
end;

At the moment Result is added without var.
Then I only have to change the IsHandled parameter manually to var.

Illegal argument: character must be non-negative

Hi David,

today I encountered a puzzling error message when trying to create the procedure "RunReportModal":

"Illegal argument: character must be non-negative"

image

Do you know what is going on there? This message even stayed there when I changed the procedure name.

image

Extract to Procedure: Not all variables needed are handed over as parameter

If the selection which should be extracted is inside a begin..end Block, then variables which are assigned before this block aren't passed to the extracted procedure as parameter. Instead they are just normal variables.
Example:

	local procedure MyProcedure()
	var
		MyInt: Integer;
		SalesLine: Record "Sales Line";
	begin
		MyInt := 5;
		if true then begin
			SalesLine.SetRange("Document Type", "Sales Document Type"::Order);
			if SalesLine.FindSet(true) then begin
				SalesLine.Quantity := MyInt;
				SalesLine.Modify();
			end;
		end;
	end;

results in

	local procedure MyProcedure()
	var
		MyInt: Integer;
		SalesLine: Record "Sales Line";
	begin
		MyInt := 5;
		if true then begin
			ExtractedProcedure();
		end;
	end;

	local procedure ExtractedProcedure()
	var
		MyInt: Integer;
		SalesLine: Record "Sales Line";
	begin
		SalesLine.SetRange("Document Type", "Sales Document Type"::Order);
		if SalesLine.FindSet(true) then begin
			SalesLine.Quantity := MyInt;
			SalesLine.Modify();
		end;
	end;

Create Procedure: return value missing for page fields

I've just added a field to a page. The value is returned by a (still missing) function/method CalcValue:

                    field("My Page Field Name"; CalcValue())
                    {                        
                    }

When I run "Create Procedure" on CalcValue, it has no return value:

	local procedure CalcValue()
	begin
		Error('Procedure CalcValue not implemented.');
	end;

I am aware that you cannot know which return data type to expect.
Nevertheless, could a dummy data type, e.g. text, be added?
Example:

	local procedure CalcValue() ReturnVariable : Text
	begin
                // Please update the ReturnVariable data type and name
		Error('Procedure CalcValue not implemented.');
	end;

Error: Unable to get the position to insert the procedure

I recieve the error:

Unable to get the position to insert the procedure

image

ERR Invalid arguments: Error: Invalid arguments
	at new e (c:\Users\asdf\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:438:373)
	at new e (c:\Users\asdf\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:434:44)
	at asRange (c:\Users\asdf\.vscode\extensions\microsoft.al-3.0.268718\node_modules\vscode-languageclient\lib\protocolConverter.js:59:16)
	at asCodeLens (c:\Users\asdf\.vscode\extensions\microsoft.al-3.0.268718\node_modules\vscode-languageclient\lib\protocolConverter.js:472:53)

I don't what causes this error. Mabe runtime 3.2?
I recieved this error while for every inseriton method (procedure, integration/business event)

I suggest an error handling that I get the action on this notification to copy the event to clipboard. Then I could insert the event manually, als long as this error might occur.

Idea: Add var to Eventpublisher Variables

We love your functionality to automatically create missing Eventpublishers. Having the var keyword on all variables would make it even more useful. If this is not suitable for everyone we would suggest to at least add them to variables called "IsHandled" and "ReturnValue".

Idea: CodeCop/QuickFix for missing permissions

I don't know if your extensions is the right point to share my idea.
So please do what you want with it.

Have you thought about an QuickFix for adding missing Permissions to Codeunits or Reports?
After the annoying CodeCop AL0214 there might be the information about which Records/Table are used (Read, Insert, Modify, Delete) inside this object.
I would really love a QuickFix that would add the minimum required (indirect) permissions.

Create procedure: enum parameter resolved to Variant

Imagine a function like this:

local procedure JustATest()
    var
        SalesLine: Record "Sales Line";
    begin
        MyNewFunction(SalesLine."Document Type"::Order); // <--- new procedure
    end;

SalesLine."Document Type" is an enum since BC 16.
When a use function "Create procedure", you will get:

 local procedure MyNewFunction(arg: Variant)
    begin
        Error('Procedure not implemented.');
    end;

I expect:

 local procedure MyNewFunction(SalesDocumentType: Enum "Sales Document Type")
    begin
        Error('Procedure not implemented.');
    end;

Is that possible?

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.