drupal-smart-snippets
drupal-smart-snippets copied to clipboard
FR: insert namespace
I would like to request a new feature that can automate namespace insertions.
Given I'm in web/module/custom/example/src/Controller/ExampleController.php
-> generates namespace Drupal\example\Controller;
Given I'm in web/module/custom/theme/src/Plugin/Block/ExampleBlock.php
-> generates namespace Drupal\example\Plugin\Block;
The logic seems consistent enough, although Test
namespaces are a little different.
Thank you for your consideration.
Thanks for this request! Do you have a link to documentation around how namespaces should be created? While i can definitely see value in this, I'm not sure the snippet-based nature of this project currently supports the right functionality to be able to parse all that out.
The best I could find was https://www.drupal.org/docs/develop/standards/php/psr-4-namespaces-and-autoloading-in-drupal-8#s-namespace-resolution .
VSCode does support some file-based variables in snippets such as:
TM_FILENAME The filename of the current document TM_DIRECTORY The directory of the current document TM_FILEPATH The full file path of the current document RELATIVE_FILEPATH The relative (to the opened workspace or folder) file path of the current document
I'm not sure how well these can be parsed/manipulated.