Julien-R44 / adonis-vscode-extension

💻 VSCode Extension for AdonisJS
https://marketplace.visualstudio.com/items?itemName=jripouteau.adonis-vscode-extension
MIT License
64 stars 5 forks source link

Controllers not detected if in namespaced group #27

Closed theRealPadster closed 10 months ago

theRealPadster commented 1 year ago

I've got a namespaced group for some user-related controllers but when I switch to the pre-release version of the AdonisJS extension, it underlines the ones in the group with a "Missing controller" message:

image

Package version

v1.1.9

Node.js and npm version

Using NVM with default node v20.0.0 and npm v9.6.4

Sample Code (to reproduce the issue)

// Namespace the controllers so they're not all in the same folder
Route.group(() => {
  // Authentication (login/logout/register) routes
  Route.group(() => {
    // Log in page and post route
    Route.get('/login', 'AuthController.loginShow').as('login.show');
    Route.post('/login', 'AuthController.loginSubmit').as('login.submit');
    // Register in page and post route
    Route.get('/register', 'AuthController.registerShow').as('register.show');
    Route.post('/register', 'AuthController.registerSubmit').as('register.submit');
    // log out route
    Route.get('/logout', 'AuthController.logout').as('logout');
  }).as('auth');
}).namespace('App/Controllers/Http/Users');
Julien-R44 commented 10 months ago

Yeah, dealing with that would require a lot of work: basically using an AST to statically analyze the file and extract the different namespaces. And knowing that with Adonis 6 we will have better ways of doing routing (we're going to use real javascript imports. No more magic strings), I don't intend to add or improve this part of the extension

On the other hand, having these little red "Missing controller" lines is annoying. I'm thinking of removing the warning or at least adding an option to disable these warnings. Gonna work on that asap. We can track this in another issue if needed