Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Exclude files from C++ projects?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jschroedl
Tomato Guru

USA
110 Posts

Posted - Apr 07 2025 :  12:33:38 PM  Show Profile  Reply with Quote
I read about the new ability to exclude symbols from select files using a .vscode\settings.json file. This is intriguing and I am wondering if VA offers something similar for C++ projects.

In particular, we include some header files with many symbols. For example a generated typelibrary header like excel.tlh has thousands of symbols. Those includes are needed in just a couple of targeted source files in my project but the "Find Symbol in Solution" list suffers from a lot of SPAM which I'll never need.

So, is there a way I could tell VA to not include symbols from a certain set of files?

Note that I don't use VS Code to work on my C++ code but suppose I could make a config file if someone could guide me through the format it would need (if that's the solution here).

John

feline
Whole Tomato Software

United Kingdom
19164 Posts

Posted - Apr 08 2025 :  07:48:49 AM  Show Profile  Reply with Quote
Yes, you can. You do need to decide what you want VA to ignore. If its an entire directory tree, then that is simple, otherwise it can get a little more complex, but I am here to help.

You start by turning On:

VA Options -> Performance -> Do not parse files excluded by .vscode\settings.json (requires restart)

then, using a text editor, create and edit this file. You place the file relative to your SLN file, so in the folder holding your SLN file make the ".vscode" directory, then inside of it create and edit the file. For testing purposes, I use the following file:

{
    "files.exclude": {
        "*/cpp_dll_cpp17": true,
        "cpp_dll_cpp20" : true,
        "**/bugs" : true,
        "**/code_formatting_tests/clangFormatBase" : true,
        "**/test_plain_text.txt" : true,
        "**/*.xaml" : true
    }
}


the first 4 lines are excluding directories, and all of the files and directories inside of these directories.

The "**/test_plain_text.txt" rule is excluding all files with this exact name, regardless of the directory they sit in.

The "**/*.xaml" rule is excluding all files with this extension.

In my testing, the main problem I ran into is missing a comma at line end, or adding an extra one, since I am editing the file manually. So keep an eye on that.

Hopefully this helps to make sense of things. If you only need to exclude the single tlh file, then the following should be ample:

{
    "files.exclude": {
        "**/excel.tlh" : true
    }
}


but please note this will tell VA to ignore this file completely, rather than just ignoring 90% of it.

I have the vague memory these files come in pairs though... so you might need to exclude the directory, or a second file.

zen is the art of being at one with the two'ness
Go to Top of Page

jschroedl
Tomato Guru

USA
110 Posts

Posted - Apr 08 2025 :  1:45:05 PM  Show Profile  Reply with Quote
Thanks for the great explanation. You are correct, I need to exclude *.tlh and *.tli.

I am attempting it now and seem to have something off.

My .sln file is in a directory named build and this file is in ...\build\.vscode\settings.json


{
    "files.exclude": {
        "**/*.tlh" : true,
        "**/*.tli" : true
    }
}


I set that option in Performance, closed the solution, and restarted VS.

After reload, I opened the Find Symbol dialog but symbols from the .tli files are still shown.



I also tried Open File in Solution and those files are no longer shown in that list.

Do you think I need different json to get the symbols excluded too? maybe a "symbols.exclude" in settings.json?

Edited by - jschroedl on Apr 08 2025 1:45:40 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19164 Posts

Posted - Apr 09 2025 :  08:51:02 AM  Show Profile  Reply with Quote
Oops, my mistake. Adding the settings.json file tells VA to skip these files when parsing, but it doesn't do anything to an existing VA symbol database. So any symbols already parsed and added to the database are still there. To fix this, press the button:

VA Options -> Performance -> Rebuild symbol databases

and restart your IDE. Since the files are being excluded from the OFIS dialog correctly we know the file is being picked up and applied correctly. So we just need to remove the old symbol database. I should have thought of that, but most of the time we are using these exclusion rules to cut down on parsing time, so we don't want to encourage extra parsing by rebuilding the symbol database more than required.

zen is the art of being at one with the two'ness
Go to Top of Page

jschroedl
Tomato Guru

USA
110 Posts

Posted - Apr 09 2025 :  1:54:59 PM  Show Profile  Reply with Quote
That was it! It's working well now. Thank you so much for your help.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19164 Posts

Posted - Apr 10 2025 :  06:25:49 AM  Show Profile  Reply with Quote
Thank you for the update, I am glad this works well for you You can see how to extend the exclusion rules, if you need to. They are also quite helpful if you ever end up working with a CMake project, and need to exclude entire directory trees.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000