Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CppHelper.SourcePattern is very constraining for non-"all in one folder" source layouts #45

Open
RoyAwesome opened this issue Oct 20, 2021 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@RoyAwesome
Copy link

I'm not a fan of the traditional 'all files in one folder' approach to C++ development, and I often create folders in my source tree for different logical components, ie:

src
 - public/
 -  - example/
 -  - - example.hpp
 - - - example2.hpp
 - - core.hpp
 - private/
 - - example/
 - - - example.cpp
 - - - example2.cpp
 - - core.cpp

As far as I can tell, I can't pass regex paths or any other mechanism to have this plugin search for the proper source files when creating an implementation. I can work around this by adding the folder structure to the plugin, but I often create new folders for different logical parts of my codebase and modifying the search paths every time I decide to add or rename a folder is very tedious.

It would be nice to specify a path like "private/**/{file}.cpp", and have the plugin search through my paths to find the source file. It may also be helpful to be able to walk up the directory tree any number of folders to a given folder name, since I sometimes go 2 or 3 deep in folders.

@high-cloud
Copy link

I have same problem when work with unreal engine project

@amir9480 amir9480 added enhancement New feature or request help wanted Extra attention is needed labels Feb 14, 2022
@knetworx
Copy link
Contributor

knetworx commented Aug 22, 2023

I'm not a typescript expert, nor have I ever created a VS Code extension, so I'm not familiar with the process of compiling this repository into a usable extension. That being said, I've looked into the source code a bit, and it looks like in Helpers.ts, there's an openSourceFile() function which grabs the current file and attempts to find the match with a simple replacement. I believe if you swap the fs.existsSync() with some sort of globbing, that would give you the wildcard functionality, and make this extension 1000x more useful for Unreal projects. With enough poking around, I think I could figure out how to handle this, but if someone with a bit more expertise in this area could help, I would be forever grateful.

@knetworx
Copy link
Contributor

Another possibility: What if, in the settings, we could specify replacement pairs, e.g.
{ replace: "Public", with: "Private" }
And each of the requested replacements would be applied when searching for the cpp file.
The above could replace "/somedir/Public/someotherdir/myfile.h" with "somefir/Private/someotherdir/myfile.cpp", allowing the directory structure to be whatever the user wants it to be.

@knetworx
Copy link
Contributor

Alright, I toyed around with it a bit last night and this morning, and have submitted a pull request:
#70

@amir9480
Copy link
Owner

amir9480 commented Oct 9, 2023

@RoyAwesome
@knetworx contribution is now available in v0.3.3.
You can now use CppHelper.FindReplaceStrings configuration.

Maybe something like this can fix your issue:

"CppHelper.FindReplaceStrings": [
        {
            "find": "/public",
            "replace": "/private"
        }
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants