damian-bal / php-class-generator

VSC Extension for generating PHP classes out of compser PSR-4
4 stars 3 forks source link

Generate Class produces "Wrong folder!" error #1

Closed still-dreaming-1 closed 4 years ago

still-dreaming-1 commented 4 years ago

When I select the folder, it always says "Wrong folder!" and no class is created. I'm on Windows 10. I am using Composer with PSR-4. I selected src/Hunti as the folder.

damian-bal commented 4 years ago

Hey, have you opened the projects folder as a workspace? It will only work that way.

still-dreaming-1 commented 4 years ago

I do just so happen to be using a workspace, and yes it is being opened as a workspace. I only created a workspace because saving my workspace just sounded like a good idea. I am pretty new to VS Code, but it is now my understanding that I probably shouldn't even be using a workspace, based on the fact that my workspace file is more or less empty, and based on this: https://stackoverflow.com/questions/44629890/what-is-a-workspace-in-visual-studio-code

Anyway, I don't mind using one. In case it helps, here is the contents of my workspace file. I think it is just the default contents added when you don't really have anything special saved for your workspace (in a file called hunti.code-workspace):

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {}
}
damian-bal commented 4 years ago

I just tested extension on Windows 10 and it worked fine, in visual studio code any opened folder is a workspace just not saved one unless saved as workspace. Can I see the PSR-4 part of your composer.json file? to confirm if that's not the problem. Thanks

still-dreaming-1 commented 4 years ago

My composer.json (autoload section):

{
    "autoload": {
        "psr-4": { "Dreamy\\": "src/" }
    }
}

Just in case I am doing something wrong/strange, here are my exact steps.

  1. Launch VS Code, which automatically loads my workspace.
  2. Press Ctrl+Shift+P
  3. Select "PHP Class Generator: Generate class/interface/trait (Wizard)"
  4. A windows pops up wanting me to "Select folder where new class should be placed". It is already showing my project root. From there I navigate it to src/Hunti, and while "Hunti" is highlighted, I click that "Select folder..." button.
  5. A popup on the bottom right comes up saying "Wrong folder!", and it says the Source is this extension.
still-dreaming-1 commented 4 years ago

I don't mind trying to debug this myself and possibly submit a PR if there ends up being a bug in the code. I have never worked on a plugin for VS Code, but I would like to learn how. Do you have any tips for getting started with debugging this plugin? It looks like the code is written in TypeScript, which is not a difficult language to use even though I rarely write code in it. I guess I just need to get either a debugger working, or else print out debug statements to see what is happening here.

damian-bal commented 4 years ago

I had a look and I found out what is wrong, it works okay when workspace is not saved, when just folder is opened, but when workspace is saved then that issue happens. I will work on fix for that soon. Thanks for reporting that 👍

damian-bal commented 4 years ago

That should get you started with developing extensions for VS code: https://code.visualstudio.com/api/get-started/your-first-extension

damian-bal commented 4 years ago

I have released update to VS Code Extensions Marketplace, it should work as expected now. I have tested it on Windows 10 and macOS 10.15.4.

still-dreaming-1 commented 4 years ago

Cool, it works now, thanks!