Giter VIP home page Giter VIP logo

includetoolbox's Introduction

Project inactive, looking for maintainer!

IncludeToolbox

Visual Studio extension for managing C/C++ includes:

  • Format & Sort: Format include commands to cleanup large lists of includes according to your preferences
  • Purge: Integrates Include-What-You-Use and comes with simpler but more reliable Trial and Error Removal tool
  • Explore: Include Graph tool window shows the tree of includes for a given file

More information and download on the Visual Studio Extension Gallery page

includetoolbox's People

Contributors

agrael1 avatar charlietangora avatar dakotahawkins avatar wumpf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

includetoolbox's Issues

taken into account forcedincludes and propertysheets

Hi, i am making my own tool and came across the issue that people can also put forcedincludes in a project which are included in every file (precompiled headers for example). Your tool does not take those into account, but it gets even trickier when people start using propertysheets. You will get a value "$(INHERIT)" in the forced includes field, which is not resolved and you have to parse it yourself. To make your tool full-proof you have to parse the visual studio log files to get the exact compiler invocations. That is the only way i know how to do it.

Unable to build the vsix plugin in VS2017

I've created a fork https://github.com/pjwhams/IncludeToolbox/ in order to try building a version of the addin that will load in VS2019. I'm building in VS2017. I've fixed up some of the project references and it's building the .dll but for some reason it's not generating the .vsix file. I really have no idea why - there are no warnings and all the project settings look ok. Any idea why this is happening? PR: #68

Solution doesn't compile out of the box

Hi,

would like to compile the vsix myself and try out a few changes.
I cloned and tried to build Debug/Any CPU with the latest VS 2017
Can you add docs listing whatever pre-requisites are for building?

Thanks.

Dunno if this is useful but here are the errors I get.

1>------ Build started: Project: VCProjectUtils.VS14, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.VCProject, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.VCProjectEngine, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\b\tests\IncludeToolbox\VCProject.Base\VCHelper.cs(2,17,2,29): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
1>C:\b\tests\IncludeToolbox\VCProject.Base\VCHelper.cs(18,24,18,43): error CS0246: The type or namespace name 'VCFileConfiguration' could not be found (are you missing a using directive or an assembly reference?)
1>C:\b\tests\IncludeToolbox\VCProject.Base\VCHelper.cs(85,23,85,35): error CS0246: The type or namespace name 'VCLinkerTool' could not be found (are you missing a using directive or an assembly reference?)
2>------ Build started: Project: IncludeToolbox, Configuration: Debug Any CPU ------
2>C:\b\tests\IncludeToolbox\IncludeToolBox\IncludeToolbox.csproj(294,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.VisualStudio.Threading.Analyzers.15.6.46\build\Microsoft.VisualStudio.Threading.Analyzers.targets.
3>------ Build started: Project: Tests, Configuration: Debug Any CPU ------
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
3>CSC : error CS0006: Metadata file 'C:\b\tests\IncludeToolbox\IncludeToolBox\bin\Debug\IncludeToolbox.dll' could not be found
========== Build: 0 succeeded, 3 failed, 2 up-to-date, 0 skipped ==========

Try and Error: Builds fail when __LINE__ has been used in macros

In certain situations, such as WPP log tracing with wpptrace, an include file will be generated which defines

WPP_FOO_Filename_LineNo

where LineNo is the original line number from the source file.

Try and Error mode appears to delete the entire line, including the line break. Because of this, the macros defined by WPP no longer match the source lines -- they're all off by 1.

If Try and Error mode instead cleared the include line (but left the newline intact), or commented out the line, then the build would succeed.

Typo

This feels like a petty complaint for a great extension, but could the menus be changed to "Trial and error"? (Trial and error)

Include Graphs for Projects

Have include graphs for entire projects!
Grouping, meta information and the like are very important to make this feature useful though.

See also #22

File name not printed if `#include` starts with "../"

Under some circumstances, the file name is not printed (as far as I can tell, this is when it starts with "../"):

relbug

As you can see, in this simple example, both "args.hpp" and "macros.hpp" are resolved and can be expanded, but the filename is not printed in the latter case.

IWYU "Apply Proposal" is slightly broken

Unfortunately I can not share the case, but I can describe it.

The IWYU output is correct (for it) in terms of the "The full include-list for ..." ouptut, however IncludeToolbox winds up removing some of the includes in that output.

I suspect it is just a bug in the editing logic. I'll look in to it if I have some time, however my suggestion is:

IWYU tells you which lines to delete, but not where to add new ones, so I would instead take it's output from "The full include list for..." and assume they go at the top of the file. Delete all includes and insert the list where the first one was.

Another related issue is that suggestions for forward declarations aren't parsed or handled. It could perhaps be easier on this extension to take the suggested end-state as canonical and replace anything that looks like an include OR forward declaration.

IWYU runs always with -march=x86-64

Unfortunately size_t is still 4 bytes on my machine.

Adding -m64 to the commandline as mentioned here solves the problem for me.

There seems to be no way of adding anything to the iwyu commandline. Maybe it's possible to have an optional file in the iwyu directory which can be read by IncludeToolBox and passed verbatim on the commandline when invoking iwyu?

Includes with angled brackets are not being trialed for removal

Looks like you are not even trying to remove it. the <windows.h> has been included (and not needed) however according to the tool it is not on the trial list

Could not remove #include: 'tinyxml2.h'
Could not remove #include: 'P...r.h'
Removed 0 #include directives from 'E...r.cpp'

Include Viewer/Graph parsing via simple custom parsing

Finding out which includes are included via compile + /showIncludes is accurate but super slow. Should be able to do the same thing with a simplistic parsing similar to what the formatter does.

Keeping the /showIncludes stuff around is worthwhile though.

Commands are hard to find in the keyboard shortcut settings

In the keyboard short cut menu the actions show up as:

  • EditorContextMenus.CodeWindow.FormatSelectedINcludes
  • EditorContextMenus.CodeWindow.RunIncludeWhatYouUse
  • EditorContextMenus.CodeWindow.TryandErrorIncludeRemoval
  • View.IncludeViewerToolWindow

At least the one in the context menu should have a shared categorie!

Possibility to use fix-includes

Thanks for this great extension!

Two suggestions:

It would be nice if we would be able to use https://github.com/include-what-you-use/include-what-you-use/blob/master/fix_includes.py, this script quite accurately modifies includes and takes care of placement given the include-what-you-use output.

Besides that it would be nice to use my own version of fix-includes. I am running a custom version of both in order to get the desired behavior. I am probably going to modify my local version of your plugin a bit to get it working, if i have time i try to create a pull request for those improvements

Try to use /showIncludes compile option for IncludeViewer

The IncludeViewer is currently very unstable and slow, so I might try to compile it with /showIncludes and parse the output. This will be even slower, but more stable and also kills off the dependency to ezEngine. Obviously, the tool should not update itself automatically then since I don't think that I can compile in the background (would be nice though!)

Includes inside #ifdef/#endif might get moved outside their #ifdef when formatting with sorting

If I run the formatter on this example with the option to sort the includes, the includes inside the #ifdef will be sorted and moved outside the #ifdef.

Before

#include "myproject/stuff1.h"
#include "myproject/stuff2.h"
#include "myproject/stuff3.h"

#ifdef SOME_DEFINE
#include "myproject/a_stuff4.h"
#include "myproject/a_stuff5.h"
#endif 

After formatting

#include <myproject/a_stuff4.h>
#include <myproject/a_stuff5.h>
#include <myproject/stuff1.h>

#ifdef SOME_DEFINE
#include <myproject/stuff2.h>
#include <myproject/stuff3.h>
#endif 

cheers

Error when trying to format includes with empty lines (new issue with 2.0)

I get an error if I try to format the following:

#include "myproject/precomp.h"
#include "myproject/currentfile.h"

#include "myproject/stuff1.h"
#include "myproject/stuff2.h"
#include "myproject/stuff3.h"

I have the following options:
image

If I put the option to remove the empty lines to true, it will work.
If I remove the empty line before running the formatter, it will also work.

Here is the error.

Unexpected Error: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.Text.StringBuilder.set_Chars(Int32 index, Char value)
   at IncludeToolbox.Formatter.IncludeLineInfo.SetLineType(Type newLineType) in F:\Development\current_development\IncludeToolbox\IncludeToolBox\Formatter\IncludeLineInfo.cs:line 192
   at IncludeToolbox.Formatter.IncludeFormatter.FormatDelimiters(IEnumerable`1 lines, DelimiterMode delimiterMode) in F:\Development\current_development\IncludeToolbox\IncludeToolBox\Formatter\IncludeFormatter.cs:line 68
   at IncludeToolbox.Formatter.IncludeFormatter.FormatIncludes(String text, String documentPath, IEnumerable`1 includeDirectories, FormatterOptionsPage settings) in F:\Development\current_development\IncludeToolbox\IncludeToolBox\Formatter\IncludeFormatter.cs:line 200
   at IncludeToolbox.Commands.FormatIncludes.MenuItemCallback(Object sender, EventArgs e) in F:\Development\current_development\IncludeToolbox\IncludeToolBox\Commands\FormatIncludes.cs:line 80
   at IncludeToolbox.Commands.CommandBase`1.<SetupMenuCommand>b__1_0(Object sender, EventArgs e) in F:\Development\current_development\IncludeToolbox\IncludeToolBox\Commands\CommandBase.cs:line 39

Thanks!

Directory issues with include-what-you-use integration

I have issue with using with include-what-you-need

Running command 'D:\work\include-what-you-use\bin\include-what-you-use.exe' with following arguments:
-I "D:\work\HiddenLands\src\trunk\external\SDL" -I "D:\work\HiddenLands\src\trunk\project\external\SDL" -I "D:\work\HiddenLands\src\trunk\project\h" -I "D:\work\HiddenLands\src\trunk\project\external\SDL_image" -I "D:\work\HiddenLands\src\trunk\project\external\SDL_mixer" -I "D:\work\HiddenLands\src\trunk\project\external\SDL_ttf" -I "D:\work\HiddenLands\src\trunk\project\e" -I "D:\work\HiddenLands\src\trunk\project\external\libcurl\include" -I "D:\work\HiddenLands\src\trunk\project\h\h\framework" -I "D:\work\HiddenLands\src\trunk\project\h\h\framework\Core" -I "D:\work\HiddenLands\src\trunk\project\h\h\framework\Utils" -I "D:\work\HiddenLands\src\trunk\project\h\h\framework\Geom" -I "D:\work\HiddenLands\src\trunk\project\h\h\framework\Gfx" -I "D:\Work\Atlantis_mobile\MemoryManager" -I "D:\Work\Atlantis_mobile\MemoryManager" -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt" -I "C:\Program Files (x86)\Windows Kits\8.1\Include\um" -I "C:\Program Files (x86)\Windows Kits\8.1\Include\shared" -I "C:\Program Files (x86)\Windows Kits\8.1\Include\winrt" -I "D:\Work\Atlantis_mobile\MemoryManager" -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include" -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt" -I "C:\Program Files (x86)\Windows Kits\8.1\Include\um" -I "C:\Program Files (x86)\Windows Kits\8.1\Include\shared" -I "C:\Program Files (x86)\Windows Kits\8.1\Include\winrt" -DWIN32 -DHIDDEN_LAND -DM3_GAME -D_DEBUG -D_CONSOLE -DCHEATS_ON -DFILTER_DEBUG_PRINTF -DPRINTF_TO_DEBUG_OUTPUT_WINDOW -DNEED_TRACE_FUNCTIONAL_WINDOW -DNEED_TRACE_EVENTS_DISPATCHER -DNEED_TRACE_ORIGINAL_TUTORIAL -DNEED_TRACE_ALPHA -DNEED_TRACE_LOBBY_WINDOW -DNEED_TRACE_BOT_MESSAGES -w -Wno-invalid-token-paste -std=c++14 -fms-compatibility -fms-extensions -fdelayed-template-parsing -fmsc-version=1900 -Xiwyu --verbose=2 -Xiwyu --mapping_file="D:\work\include-what-you-use\bin\msvc.imp" -Xiwyu --mapping_file="D:\work\include-what-you-use\bin\stl.c.headers.imp" -Xiwyu --pch_in_code -Xiwyu --prefix_header_includes=add -Xiwyu --max_line_length=1024 "D:\work\HiddenLands\src\trunk\project\e\e\GUI.h"

error: no such file or directory: 'Files'

error: no such file or directory: '(x86)\Microsoft'
error: no such file or directory: 'Visual'
error: no such file or directory: 'Studio'
error: no such file or directory: '14.0\VC\include -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Microsoft'
error: no such file or directory: 'Visual'
error: no such file or directory: 'Studio'
error: no such file or directory: '14.0\VC\atlmfc\include -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\10\Include\10.0.10240.0\ucrt -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\8.1\Include\um -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\8.1\Include\shared -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\8.1\Include\winrt -I D:\Work\Atlantis_mobile\MemoryManager -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Microsoft'
error: no such file or directory: 'Visual'
error: no such file or directory: 'Studio'
error: no such file or directory: '14.0\VC\include -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Microsoft'
error: no such file or directory: 'Visual'
error: no such file or directory: 'Studio'
error: no such file or directory: '14.0\VC\atlmfc\include -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\10\Include\10.0.10240.0\ucrt -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\8.1\Include\um -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\8.1\Include\shared -I C:\Program'
error: no such file or directory: 'Files'
error: no such file or directory: '(x86)\Windows'
error: no such file or directory: 'Kits\8.1\Include\winrt -DWIN32 -DHIDDEN_LAND -DM3_GAME -D_DEBUG -D_CONSOLE -DCHEATS_ON -DFILTER_DEBUG_PRINTF -DPRINTF_TO_DEBUG_OUTPUT_WINDOW -DNEED_TRACE_FUNCTIONAL_WINDOW -DNEED_TRACE_EVENTS_DISPATCHER -DNEED_TRACE_ORIGINAL_TUTORIAL -DNEED_TRACE_ALPHA -DNEED_TRACE_LOBBY_WINDOW -DNEED_TRACE_BOT_MESSAGES -w -Wno-invalid-token-paste -std=c++14 -fms-compatibility -fms-extensions -fdelayed-template-parsing -fmsc-version=1900 -Xiwyu --verbose=2 -Xiwyu --mapping_file=D:\work\include-what-you-use\bin\msvc.imp -Xiwyu --mapping_file=D:\work\include-what-you-use\bin\stl.c.headers.imp -Xiwyu --pch_in_code -Xiwyu --prefix_header_includes=add -Xiwyu --max_line_length=1024 D:\work\HiddenLands\src\trunk\project\e\e\GUI.h'
error: no input files
error: unable to handle compilation, expected exactly one compiler job in ''

Trial & Error Include Removal ignores linker error.

I have the declaration of a function in the global namespace in a header file "aName". The file with definition include the #include "aName.h" header and builds. Another project call the function and builds OK.

// aName.h
__declspec(dllexport) func(*void,**void,int,int);
// differentName.cpp
#include "aName.h"
func(*void,**void,int,int){
  //some implementation.
}

//differentProject.cpp
//calling the function func.
func(arg,arg2,arg3,arg4);

When I run Trial & Error Include Removal on differentName.cpp it removed the #include "aName.h" and give me the message
Successfully removed #include: 'aName.h'
Removed 1 #include directives from 'differentName.cpp'

When I try to build the solution I get a linker error.
error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl func

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.