amir9480 / vscode-cpp-helper

vscode extension to create implementation for c++ function prototypes.
https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.cpp-helper
MIT License
355 stars 31 forks source link

How to set the SourcePattern dynamically for an Unreal Engine 4 Project #33

Closed Ares9323 closed 1 year ago

Ares9323 commented 3 years ago

Hi, I discovered today your extension and I think it's great, It saves me a lot of time even if I have to copy and paste the implementation manually!

I tried to configure the Source Pattern in several ways but only one worked and the path is hardcoded.

For example

This is the typical hierarchy in UE4

The .h file can be in two different folders, the cpp file is always in the private folder:

ProjectName/Source/ProjectName/Public/File.h
ProjectName/Source/ProjectName/Private/File.h
ProjectName/Source/ProjectName/Private/File.cpp

If they are both in the private folder it's easy, the default "{file}.cpp" is enough to detect the correct file.

If the .h file is in public I have to hardcode the "/Source/ProjectName/Private/{file}.cpp" string, so I have to do this for every project with a different path.

Do you think is there a way to get the {ProjectName} in the same way as you get the {file}?

Thank you in advance <3

amir9480 commented 3 years ago

@Ares9323 Hi

I'm not sure but I think you should use a relative path like this

"../Private/{FILE}.cpp"
Ares9323 commented 3 years ago

Thank you for the fast answer, that's literally the first thing I tried.. I tried it again now and it works, I think I could have made a typo yesterday 😅

I'll leave you a 5 stars review!

Ares9323 commented 3 years ago

Hi, It's me again, today I encountered another problem trying to implement files in subfolders of the path I mentioned when I opened this issue and I really can't figure how to include those directories too...

For example:

ProjectName/Source/ProjectName/Public/Folder/File.h
ProjectName/Source/ProjectName/Private/Folder/File.h

I am able to include these manually by adding in the settings.json the pattern "../../Private/Folder/{FILE}.cpp" but it works only if hardcoded (so if I don't insert every subfolder of public/private it doesn't work).

Is {FILE} the only variable available?

I've used in regex variables contained in the VScode documentation and I was wondering if I could use something like the default ${file} and replace "public" with "private" or something like that.

Thank you in advance!