vscode-cfml icon indicating copy to clipboard operation
vscode-cfml copied to clipboard

Allow to specify Component directories

Open isapir opened this issue 4 years ago • 7 comments

The extension works great with Components that are on the root of a project, e.g. if the project is at /my-project and the component's path is /my-project/org/myorganization/Security.cfc then referencing it with org.myorganization.Security() works well.

But many projects have the Components in other directories, or a subdirectory. It would be great if we could set the Component directory, for example, if the project's root is /my-project and the Components are mapped from /my-project/components/ then we could specify that path and a call for org.myorganization.Security() will resolve the component correctly at /my-project/components/org/myorganization/Security.cfc.

isapir avatar Jun 15 '20 22:06 isapir

Can you please point to documentation on how this path is resolved on the server? If I am going to introduce something for this, I would like to model it with this knowledge.

The extension does already have a cfml.mappings setting that is modeled after the mappings setting of the server but with the additional ability to use relative paths since it's a static setting without the ability to call something like expandPath. Right now, the paths are resolved like they are on the server as far as I understand, which is (in the order) Current directory, Web root, Mappings. Unfortunately, one of the limitations for this right now is that Application mappings are not supported.

KamasamaK avatar Jun 16 '20 10:06 KamasamaK

Oh, right. In this case I am using an Application mapping, e.g. in Application.cfc (Lucee):

this.componentPaths="/components";

So would it be possible to add a config setting where we can manually add such paths for the extension?

isapir avatar Jun 16 '20 17:06 isapir

I see. So this looks like a Lucee-only setting. Can you confirm that componentpaths is checked after the mappings setting?

KamasamaK avatar Jun 16 '20 18:06 KamasamaK

Yes. Application.cfc settings overwrite the previous settings, i.e. settings are applied in the following order (last one wins):

ENVIRONMENT Variables
  Lucee Server settings
    Lucee Web Context settings
      Application.cfc settings

isapir avatar Jun 16 '20 19:06 isapir

But the idea here is to allow project-specific settings for the extension, so a user will be able to set whatever path he/she wants.

isapir avatar Jun 16 '20 19:06 isapir

Thanks for clarifying how Lucee resolves its settings. I was specifically interested in the order in which path resolution is performed. In other words, how does the setting componentpaths affect those checks? For example, in the ordered list "Current directory, Web root, Mappings", is that componentpaths setting used instead of the web root in that check or after regular mappings? I was not able to find this information in the Lucee documentation.

KamasamaK avatar Jun 16 '20 19:06 KamasamaK

@KamasamaK I am actually not sure without testing. This could be tested easily enough so I'll try to test it in the coming days.

Perhaps @michaeloffner can chime in in the meantime.

isapir avatar Jun 16 '20 20:06 isapir