Mon Oct 25, 2021 1:48 am
Login Register Lost Password? Contact Us


ECL Alias in VS Code

Topics around the use of the VS Code & Eclipse plugins

Tue Feb 23, 2021 11:12 pm Change Time Zone

I recently noticed that F12 does not seem to work on aliases (e.g. import statements) as shown in the example below:

Code: Select all
IMPORT MainFolder.SubFolder.AllLayouts AS Layouts;

inData := DATASET([], Layouts.outputLayout);


It appears that by F12'ing on outputLayout doesn't take us to the MainFolder.SubFolder1.AllLayouts (outputlayout) object. Is this an available feature? If not, would it be possible to add it?

Thanks in advance.
flyer
 
Posts: 8
Joined: Fri Dec 11, 2020 1:58 pm

Tue Feb 23, 2021 11:37 pm Change Time Zone

Hello flyer,

I have just tried a similar alias on VSCode with v2.10.0 of the ECL extension and it seemed to work. Can you please confirm if this is the same version you are using so I can try to reproduce the issue?

Thanks
HugoW
hwatanuki
 
Posts: 28
Joined: Mon Apr 15, 2019 1:22 am

Wed Feb 24, 2021 3:09 am Change Time Zone

Hi,

Yes. I am currently using version 2.10.0 of the ECL extension. I just notice that aliases do work for some things such as the first example that I provided - apologies for not providing an example that would actually fail (grins). However, it doesn't seem to work with more deeply nested folder structures when referencing an export definition from a module? (MODULE)

Not very creative but I have attached something I just tried (see attachments).

Rundown of what I did:
TESTPROJECT - test workspace
MyProject - main project folder
common - common functions and other usable pieces of software
services - folder where services and service related functions would go
layouts - folder where several different layouts would go
myLayout - sample layout (alias worked on this)
myService - dummy service returns a message
modConstants - MODULE that contains several constant definitions

When I tried to F12 on the constant defined in modConstants, VSCode says: no definition found for CONSTANT1. So it seems that the issue can be observed when trying to F12 on export definitions contained in MODULEs.

Let me know if you can reproduce the issue on your side. I am not sure if this behavior is expected, a bug, or a potential improvement that could be worked through.

Thanks!
Attachments
noDefinitionFound.jpg
(53.11 KiB) Not downloaded yet
projectSample.jpg
(87.56 KiB) Not downloaded yet
flyer
 
Posts: 8
Joined: Fri Dec 11, 2020 1:58 pm

Wed Feb 24, 2021 2:25 pm Change Time Zone

Hello Flyer,

In my previous test above I was already using an exported definition inside a MODULE. Just to make sure we are on the same page, could you please share the content of your modConstants.ecl file?

Thanks,
HugoW
hwatanuki
 
Posts: 28
Joined: Mon Apr 15, 2019 1:22 am

Wed Feb 24, 2021 4:24 pm Change Time Zone

I included two test constants to showcase what I am experiencing.

Code: Select all
EXPORT modConstants :=  MODULE
    EXPORT CONSTANT1 := 'TEST CONSTANT1';
    EXPORT CONSTANT2 := 'TEST CONSTANT2';
END;


Let me know if this helps!
flyer
 
Posts: 8
Joined: Fri Dec 11, 2020 1:58 pm

Thu Feb 25, 2021 4:24 am Change Time Zone

Thanks for the additional information, flyer.

I think I was now able to reproduce the behavior and it looks like it is just related to how IMPORT statements work with workspaces in VSCode.

When you add the myProject folder to the workspace in VSCode it seems to be equivalent of actually making it the root folder of your ECL repository, thus the IMPORT statements for the ecl code contained inside the myProject folder should start with the direct reference to the modules/subfolders within myProject (such as: "IMPORT services"). So in your case, the myService.ecl could look like this with an alias:

Code: Select all
IMPORT services AS X;

EXPORT myService := FUNCTION
  inMessage := X.modConstants.CONSTANT1;
  RETURN inMessage;
END;


Instead, if you really want to use IMPORT statements that start with references to the myProject folder (such as: "IMPORT myProject.services"), then you would need to select the myProject´s parent folder (if there is one) when you create your workspace in VSCode. I have simulated this alternative option here and the "Go to Definition" feature (F12) worked fine for the CONSTANTS1 definition.

HTH,
HugoW
hwatanuki
 
Posts: 28
Joined: Mon Apr 15, 2019 1:22 am

Fri Feb 26, 2021 2:03 pm Change Time Zone

This makes sense to me. Thank you so much!
flyer
 
Posts: 8
Joined: Fri Dec 11, 2020 1:58 pm


Return to VS Code and Eclipse IDE

Who is online

Users browsing this forum: No registered users and 1 guest

cron