]> granicus.if.org Git - clang/commitdiff
Adds a VSPackage project that builds a VS extension to run clang-format over a select...
authorManuel Klimek <klimek@google.com>
Wed, 4 Sep 2013 16:11:46 +0000 (16:11 +0000)
committerManuel Klimek <klimek@google.com>
Wed, 4 Sep 2013 16:11:46 +0000 (16:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189955 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
tools/clang-format-vs/ClangFormat.sln [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/ClangFormat.csproj [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/ClangFormat.vsct [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/Guids.cs [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/PkgCmdID.cs [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/Resources.Designer.cs [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/Resources.resx [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/Resources/Images.png [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/Resources/Package.ico [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/VSPackage.resx [new file with mode: 0644]
tools/clang-format-vs/ClangFormat/source.extension.vsixmanifest [new file with mode: 0644]
tools/clang-format-vs/README [new file with mode: 0644]

diff --git a/tools/clang-format-vs/ClangFormat.sln b/tools/clang-format-vs/ClangFormat.sln
new file mode 100644 (file)
index 0000000..d6b211f
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 2012\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClangFormat", "ClangFormat\ClangFormat.csproj", "{7FD1783E-2D31-4D05-BF23-6EBE1B42B608}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {7FD1783E-2D31-4D05-BF23-6EBE1B42B608}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {7FD1783E-2D31-4D05-BF23-6EBE1B42B608}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {7FD1783E-2D31-4D05-BF23-6EBE1B42B608}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {7FD1783E-2D31-4D05-BF23-6EBE1B42B608}.Release|Any CPU.Build.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/tools/clang-format-vs/ClangFormat/ClangFormat.csproj b/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
new file mode 100644 (file)
index 0000000..51e1382
--- /dev/null
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">\r
+  <PropertyGroup>\r
+    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>\r
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>\r
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>\r
+  </PropertyGroup>\r
+  <PropertyGroup>\r
+    <DelaySign>false</DelaySign>\r
+  </PropertyGroup>\r
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{7FD1783E-2D31-4D05-BF23-6EBE1B42B608}</ProjectGuid>\r
+    <ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>LLVM.ClangFormat</RootNamespace>\r
+    <AssemblyName>ClangFormat</AssemblyName>\r
+    <SignAssembly>true</SignAssembly>\r
+    <AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>\r
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>\r
+    <RunCodeAnalysis>false</RunCodeAnalysis>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <RunCodeAnalysis>true</RunCodeAnalysis>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="Microsoft.CSharp" />\r
+    <Reference Include="Microsoft.VisualStudio.CoreUtility, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />\r
+    <Reference Include="Microsoft.VisualStudio.Editor, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />\r
+    <Reference Include="Microsoft.VisualStudio.OLE.Interop" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.Interop" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0">\r
+      <EmbedInteropTypes>true</EmbedInteropTypes>\r
+    </Reference>\r
+    <Reference Include="Microsoft.VisualStudio.Text.Data, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />\r
+    <Reference Include="Microsoft.VisualStudio.Text.Logic, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />\r
+    <Reference Include="Microsoft.VisualStudio.Text.UI, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />\r
+    <Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />\r
+    <Reference Include="Microsoft.VisualStudio.TextManager.Interop" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.11.0" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />\r
+    <Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" />\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Core" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Design" />\r
+    <Reference Include="System.Drawing" />\r
+    <Reference Include="System.Windows.Forms" />\r
+    <Reference Include="System.Xml" />\r
+    <Reference Include="System.Xml.Linq" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <COMReference Include="EnvDTE">\r
+      <Guid>{80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}</Guid>\r
+      <VersionMajor>8</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>primary</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+      <EmbedInteropTypes>False</EmbedInteropTypes>\r
+    </COMReference>\r
+    <COMReference Include="EnvDTE100">\r
+      <Guid>{26AD1324-4B7C-44BC-84F8-B86AED45729F}</Guid>\r
+      <VersionMajor>10</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>primary</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+      <EmbedInteropTypes>False</EmbedInteropTypes>\r
+    </COMReference>\r
+    <COMReference Include="EnvDTE80">\r
+      <Guid>{1A31287A-4D7D-413E-8E32-3B374931BD89}</Guid>\r
+      <VersionMajor>8</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>primary</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+      <EmbedInteropTypes>False</EmbedInteropTypes>\r
+    </COMReference>\r
+    <COMReference Include="EnvDTE90">\r
+      <Guid>{2CE2370E-D744-4936-A090-3FFFE667B0E1}</Guid>\r
+      <VersionMajor>9</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>primary</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+      <EmbedInteropTypes>False</EmbedInteropTypes>\r
+    </COMReference>\r
+    <COMReference Include="Microsoft.VisualStudio.CommandBars">\r
+      <Guid>{1CBA492E-7263-47BB-87FE-639000619B15}</Guid>\r
+      <VersionMajor>8</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>primary</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+      <EmbedInteropTypes>False</EmbedInteropTypes>\r
+    </COMReference>\r
+    <COMReference Include="stdole">\r
+      <Guid>{00020430-0000-0000-C000-000000000046}</Guid>\r
+      <VersionMajor>2</VersionMajor>\r
+      <VersionMinor>0</VersionMinor>\r
+      <Lcid>0</Lcid>\r
+      <WrapperTool>primary</WrapperTool>\r
+      <Isolated>False</Isolated>\r
+      <EmbedInteropTypes>False</EmbedInteropTypes>\r
+    </COMReference>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Guids.cs" />\r
+    <Compile Include="Resources.Designer.cs">\r
+      <AutoGen>True</AutoGen>\r
+      <DesignTime>True</DesignTime>\r
+      <DependentUpon>Resources.resx</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="GlobalSuppressions.cs" />\r
+    <Compile Include="ClangFormatPackage.cs">\r
+      <SubType>Component</SubType>\r
+    </Compile>\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <Compile Include="PkgCmdID.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <EmbeddedResource Include="Resources.resx">\r
+      <Generator>ResXFileCodeGenerator</Generator>\r
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>\r
+      <SubType>Designer</SubType>\r
+    </EmbeddedResource>\r
+    <EmbeddedResource Include="VSPackage.resx">\r
+      <MergeWithCTO>true</MergeWithCTO>\r
+      <ManifestResourceName>VSPackage</ManifestResourceName>\r
+    </EmbeddedResource>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="Key.snk" />\r
+    <None Include="source.extension.vsixmanifest">\r
+      <SubType>Designer</SubType>\r
+    </None>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <VSCTCompile Include="ClangFormat.vsct">\r
+      <ResourceName>Menus.ctmenu</ResourceName>\r
+    </VSCTCompile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="Resources\Images.png" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Content Include="Resources\Package.ico" />\r
+  </ItemGroup>\r
+  <PropertyGroup>\r
+    <UseCodebase>true</UseCodebase>\r
+  </PropertyGroup>\r
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />\r
+  <Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />\r
+  <PropertyGroup>\r
+    <PreBuildEvent>if not exist $(ProjectDir)Key.snk (\r
+  "$(FrameworkSDKDir)Bin\NETFX 4.0 Tools\sn.exe" -k $(ProjectDir)Key.snk\r
+)</PreBuildEvent>\r
+  </PropertyGroup>\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file
diff --git a/tools/clang-format-vs/ClangFormat/ClangFormat.vsct b/tools/clang-format-vs/ClangFormat/ClangFormat.vsct
new file mode 100644 (file)
index 0000000..9037ecd
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">\r
+\r
+  <!--  This is the file that defines the actual layout and type of the commands.\r
+        It is divided in different sections (e.g. command definition, command\r
+        placement, ...), with each defining a specific set of properties.\r
+        See the comment before each section for more details about how to\r
+        use it. -->\r
+\r
+  <!--  The VSCT compiler (the tool that translates this file into the binary \r
+        format that VisualStudio will consume) has the ability to run a preprocessor \r
+        on the vsct file; this preprocessor is (usually) the C++ preprocessor, so \r
+        it is possible to define includes and macros with the same syntax used \r
+        in C++ files. Using this ability of the compiler here, we include some files \r
+        defining some of the constants that we will use inside the file. -->\r
+\r
+  <!--This is the file that defines the IDs for all the commands exposed by VisualStudio. -->\r
+  <Extern href="stdidcmd.h"/>\r
+\r
+  <!--This header contains the command ids for the menus provided by the shell. -->\r
+  <Extern href="vsshlids.h"/>\r
+\r
+\r
+\r
+\r
+  <!--The Commands section is where we the commands, menus and menu groups are defined.\r
+      This section uses a Guid to identify the package that provides the command defined inside it. -->\r
+  <Commands package="guidClangFormatPkg">\r
+    <!-- Inside this section we have different sub-sections: one for the menus, another  \r
+    for the menu groups, one for the buttons (the actual commands), one for the combos \r
+    and the last one for the bitmaps used. Each element is identified by a command id that  \r
+    is a unique pair of guid and numeric identifier; the guid part of the identifier is usually  \r
+    called "command set" and is used to group different command inside a logically related  \r
+    group; your package should define its own command set in order to avoid collisions  \r
+    with command ids defined by other packages. -->\r
+\r
+    \r
+    <!-- In this section you can define new menu groups. A menu group is a container for \r
+         other menus or buttons (commands); from a visual point of view you can see the \r
+         group as the part of a menu contained between two lines. The parent of a group \r
+         must be a menu. -->\r
+    <Groups>\r
+\r
+      <Group guid="guidClangFormatCmdSet" id="MyMenuGroup" priority="0x0600">\r
+        <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>\r
+      </Group>\r
+      \r
+\r
+\r
+    </Groups>\r
+    \r
+    <!--Buttons section. -->\r
+    <!--This section defines the elements the user can interact with, like a menu command or a button \r
+        or combo box in a toolbar. -->\r
+    <Buttons>\r
+      <!--To define a menu group you have to specify its ID, the parent menu and its display priority. \r
+          The command is visible and enabled by default. If you need to change the visibility, status, etc, you can use\r
+          the CommandFlag node.\r
+          You can add more than one CommandFlag node e.g.:\r
+              <CommandFlag>DefaultInvisible</CommandFlag>\r
+              <CommandFlag>DynamicVisibility</CommandFlag>\r
+          If you do not want an image next to your command, remove the Icon node /> -->\r
+\r
+      <Button guid="guidClangFormatCmdSet" id="cmdidClangFormat" priority="0x0100" type="Button">\r
+        <Parent guid="guidClangFormatCmdSet" id="MyMenuGroup" />\r
+        <Icon guid="guidImages" id="bmpPic1" />\r
+        <Strings>\r
+          <ButtonText>ClangFormat</ButtonText>\r
+        </Strings>\r
+      </Button>\r
+\r
+\r
+\r
+    </Buttons>\r
+   \r
+    <!--The bitmaps section is used to define the bitmaps that are used for the commands.-->\r
+    <Bitmaps>\r
+      <!--  The bitmap id is defined in a way that is a little bit different from the others: \r
+            the declaration starts with a guid for the bitmap strip, then there is the resource id of the \r
+            bitmap strip containing the bitmaps and then there are the numeric ids of the elements used \r
+            inside a button definition. An important aspect of this declaration is that the element id \r
+            must be the actual index (1-based) of the bitmap inside the bitmap strip. -->\r
+      <Bitmap guid="guidImages" href="Resources\Images.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>\r
+      \r
+    </Bitmaps>\r
\r
+  </Commands>\r
+\r
+\r
+  <KeyBindings>\r
+    <KeyBinding guid="guidClangFormatCmdSet" id="cmdidClangFormat" editor="guidVSStd97" key1="R" mod1="Control" key2="F" mod2="Control"/>\r
+  </KeyBindings>\r
+\r
+\r
+\r
+  <Symbols>\r
+    <!-- This is the package guid. -->\r
+    <GuidSymbol name="guidClangFormatPkg" value="{c5286038-25d3-4f65-83a8-51fa2df4a146}" />\r
+    \r
+    <!-- This is the guid used to group the menu commands together -->\r
+    <GuidSymbol name="guidClangFormatCmdSet" value="{e39cbab1-0f96-4022-a2bc-da5a9db7eb78}">\r
+\r
+      <IDSymbol name="MyMenuGroup" value="0x1020" />\r
+      <IDSymbol name="cmdidClangFormat" value="0x0100" />\r
+    </GuidSymbol>\r
+    \r
+    \r
+    \r
+    <GuidSymbol name="guidImages" value="{6d53937b-9ae1-42e1-8849-d876dcdbad7b}" >\r
+      <IDSymbol name="bmpPic1" value="1" />\r
+      <IDSymbol name="bmpPic2" value="2" />\r
+      <IDSymbol name="bmpPicSearch" value="3" />\r
+      <IDSymbol name="bmpPicX" value="4" />\r
+      <IDSymbol name="bmpPicArrows" value="5" />\r
+      <IDSymbol name="bmpPicStrikethrough" value="6" />\r
+    </GuidSymbol>\r
+  </Symbols>\r
+\r
+</CommandTable>\r
diff --git a/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs b/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
new file mode 100644 (file)
index 0000000..61cc644
--- /dev/null
@@ -0,0 +1,210 @@
+//===-- ClangFormatPackages.cs - VSPackage for clang-format ------*- C# -*-===//\r
+//\r
+//                     The LLVM Compiler Infrastructure\r
+//\r
+// This file is distributed under the University of Illinois Open Source\r
+// License. See LICENSE.TXT for details.\r
+//\r
+//===----------------------------------------------------------------------===//\r
+//\r
+// This class contains a VS extension package that runs clang-format over a\r
+// selection in a VS text editor.\r
+//\r
+//===----------------------------------------------------------------------===//\r
+\r
+using Microsoft.VisualStudio.Editor;\r
+using Microsoft.VisualStudio.Shell;\r
+using Microsoft.VisualStudio.Shell.Interop;\r
+using Microsoft.VisualStudio.Text;\r
+using Microsoft.VisualStudio.Text.Editor;\r
+using Microsoft.VisualStudio.TextManager.Interop;\r
+using System;\r
+using System.ComponentModel;\r
+using System.ComponentModel.Design;\r
+using System.IO;\r
+using System.Runtime.InteropServices;\r
+using System.Xml.Linq;\r
+\r
+namespace LLVM.ClangFormat\r
+{\r
+    [ClassInterface(ClassInterfaceType.AutoDual)]\r
+    [CLSCompliant(false), ComVisible(true)]\r
+    public class OptionPageGrid : DialogPage\r
+    {\r
+        private string style = "File";\r
+\r
+        [Category("LLVM/Clang")]\r
+        [DisplayName("Style")]\r
+        [Description("Coding style, currently supports:\n" +\r
+                     "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla').\n" +\r
+                     "  - 'File' to search for a YAML .clang-format configuration.\n" +\r
+                     "  - A YAML configuration snippet.\n\n" +\r
+                     "'File':\n" +\r
+                     "  Searches for a .clang-format configuration in the source file's\n" +\r
+                     "  directory and its parents.\n\n" +\r
+                     "YAML configuration snippet:\n" +\r
+                     "  The content of a .clang-format configuration file, as string.\n" +\r
+                     "  Example: '{BasedOnStyle: \"LLVM\", IndentWidth: 8}'\n\n" +\r
+                     "See also: http://clang.llvm.org/docs/ClangFormatStyleOptions.html.")]\r
+        public string Style\r
+        {\r
+            get { return style; }\r
+            set { style = value; }\r
+        }\r
+    }\r
+\r
+    [PackageRegistration(UseManagedResourcesOnly = true)]\r
+    [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]\r
+    [ProvideMenuResource("Menus.ctmenu", 1)]\r
+    [Guid(GuidList.guidClangFormatPkgString)]\r
+    [ProvideOptionPage(typeof(OptionPageGrid), "LLVM/Clang", "ClangFormat", 0, 0, true)]\r
+    public sealed class ClangFormatPackage : Package\r
+    {\r
+        #region Package Members\r
+        protected override void Initialize()\r
+        {\r
+            base.Initialize();\r
+\r
+            var commandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;\r
+            if (commandService != null)\r
+            {\r
+                var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormat);\r
+                var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);\r
+                commandService.AddCommand(menuItem);\r
+            }\r
+        }\r
+        #endregion\r
+\r
+        private void MenuItemCallback(object sender, EventArgs args)\r
+        {\r
+            IWpfTextView view = GetCurrentView();\r
+            if (view == null)\r
+                // We're not in a text view.\r
+                return;\r
+            string text = view.TextBuffer.CurrentSnapshot.GetText();\r
+            int start = view.Selection.Start.Position.GetContainingLine().Start.Position;\r
+            int end = view.Selection.End.Position.GetContainingLine().End.Position;\r
+            int length = end - start;\r
+            // clang-format doesn't support formatting a range that starts at the end\r
+            // of the file.\r
+            if (start >= text.Length && text.Length > 0)\r
+                start = text.Length - 1;\r
+            string path = GetDocumentParent(view);\r
+            try\r
+            {\r
+                var root = XElement.Parse(RunClangFormat(text, start, length, path));\r
+                var edit = view.TextBuffer.CreateEdit();\r
+                foreach (XElement replacement in root.Descendants("replacement"))\r
+                {\r
+                    var span = new Span(\r
+                        int.Parse(replacement.Attribute("offset").Value),\r
+                        int.Parse(replacement.Attribute("length").Value));\r
+                    edit.Replace(span, replacement.Value);\r
+                }\r
+                edit.Apply();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));\r
+                var id = Guid.Empty;\r
+                int result;\r
+                uiShell.ShowMessageBox(\r
+                        0, ref id,\r
+                        "Error while running clang-format:",\r
+                        e.Message,\r
+                        string.Empty, 0,\r
+                        OLEMSGBUTTON.OLEMSGBUTTON_OK,\r
+                        OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,\r
+                        OLEMSGICON.OLEMSGICON_INFO,\r
+                        0, out result);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Runs the given text through clang-format and returns the replacements as XML.\r
+        /// \r
+        /// Formats the text range starting at offset of the given length.\r
+        /// </summary>\r
+        private string RunClangFormat(string text, int offset, int length, string path)\r
+        {\r
+            System.Diagnostics.Process process = new System.Diagnostics.Process();\r
+            process.StartInfo.UseShellExecute = false;\r
+            process.StartInfo.FileName = "clang-format.exe";\r
+            // Poor man's escaping - this will not work when quotes are already escaped\r
+            // in the input (but we don't need more).\r
+            string style = GetStyle().Replace("\"", "\\\"");\r
+            process.StartInfo.Arguments = " -offset " + offset +\r
+                                          " -length " + length +\r
+                                          " -output-replacements-xml " +\r
+                                          " -style \"" + style + "\"";\r
+            process.StartInfo.CreateNoWindow = true;\r
+            process.StartInfo.RedirectStandardInput = true;\r
+            process.StartInfo.RedirectStandardOutput = true;\r
+            process.StartInfo.RedirectStandardError = true;\r
+            if (path != null)\r
+                process.StartInfo.WorkingDirectory = path;\r
+            // We have to be careful when communicating via standard input / output,\r
+            // as writes to the buffers will block until they are read from the other side.\r
+            // Thus, we:\r
+            // 1. Start the process - clang-format.exe will start to read the input from the\r
+            //    standard input.\r
+            process.Start();\r
+            // 2. We write everything to the standard output - this cannot block, as clang-format\r
+            //    reads the full standard input before analyzing it without writing anything to the\r
+            //    standard output.\r
+            process.StandardInput.Write(text);\r
+            // 3. We notify clang-format that the input is done - after this point clang-format\r
+            //    will start analyzing the input and eventually write the output.\r
+            process.StandardInput.Close();\r
+            // 4. We must read clang-format's output before waiting for it to exit; clang-format\r
+            //    will close the channel by exiting.\r
+            string output = process.StandardOutput.ReadToEnd();\r
+            // 5. clang-format is done, wait until it is fully shut down.\r
+            process.WaitForExit();\r
+            if (process.ExitCode != 0)\r
+            {\r
+                // FIXME: If clang-format writes enough to the standard error stream to block,\r
+                // we will never reach this point; instead, read the standard error asynchronously.\r
+                throw new Exception(process.StandardError.ReadToEnd());\r
+            }\r
+            return output;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Returns the currently active view if it is a IWpfTextView.\r
+        /// </summary>\r
+        private IWpfTextView GetCurrentView()\r
+        {\r
+            // The SVsTextManager is a service through which we can get the active view.\r
+            var textManager = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));\r
+            IVsTextView textView;\r
+            textManager.GetActiveView(1, null, out textView);\r
+\r
+            // Now we have the active view as IVsTextView, but the text interfaces we need\r
+            // are in the IWpfTextView.\r
+            var userData = (IVsUserData)textView;\r
+            if (userData == null)\r
+                return null;\r
+            Guid guidWpfViewHost = DefGuidList.guidIWpfTextViewHost;\r
+            object host;\r
+            userData.GetData(ref guidWpfViewHost, out host);\r
+            return ((IWpfTextViewHost)host).TextView;\r
+        }\r
+\r
+        private string GetStyle()\r
+        {\r
+            var page = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));\r
+            return page.Style;\r
+        }\r
+\r
+        private string GetDocumentParent(IWpfTextView view)\r
+        {\r
+            ITextDocument document;\r
+            if (view.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document))\r
+            {\r
+                return Directory.GetParent(document.FilePath).ToString();\r
+            }\r
+            return null;\r
+        }\r
+    }\r
+}\r
diff --git a/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs b/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs
new file mode 100644 (file)
index 0000000..175a74e
--- /dev/null
@@ -0,0 +1,11 @@
+// This file is used by Code Analysis to maintain SuppressMessage\r
+// attributes that are applied to this project. Project-level\r
+// suppressions either have no target or are given a specific target\r
+// and scoped to a namespace, type, member, etc.\r
+//\r
+// To add a suppression to this file, right-click the message in the\r
+// Error List, point to "Suppress Message(s)", and click "In Project\r
+// Suppression File". You do not need to add suppressions to this\r
+// file manually.\r
+\r
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")]\r
diff --git a/tools/clang-format-vs/ClangFormat/Guids.cs b/tools/clang-format-vs/ClangFormat/Guids.cs
new file mode 100644 (file)
index 0000000..c045224
--- /dev/null
@@ -0,0 +1,12 @@
+using System;\r
+\r
+namespace LLVM.ClangFormat\r
+{\r
+    static class GuidList\r
+    {\r
+        public const string guidClangFormatPkgString = "c5286038-25d3-4f65-83a8-51fa2df4a146";\r
+        public const string guidClangFormatCmdSetString = "e39cbab1-0f96-4022-a2bc-da5a9db7eb78";\r
+\r
+        public static readonly Guid guidClangFormatCmdSet = new Guid(guidClangFormatCmdSetString);\r
+    };\r
+}
\ No newline at end of file
diff --git a/tools/clang-format-vs/ClangFormat/PkgCmdID.cs b/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
new file mode 100644 (file)
index 0000000..bb6b455
--- /dev/null
@@ -0,0 +1,7 @@
+namespace LLVM.ClangFormat\r
+{\r
+    static class PkgCmdIDList\r
+    {\r
+        public const uint cmdidClangFormat = 0x100;\r
+    };\r
+}
\ No newline at end of file
diff --git a/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs b/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..e6e4de4
--- /dev/null
@@ -0,0 +1,33 @@
+using System;\r
+using System.Reflection;\r
+using System.Resources;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following \r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle("ClangFormat")]\r
+[assembly: AssemblyDescription("")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("LLVM")]\r
+[assembly: AssemblyProduct("ClangFormat")]\r
+[assembly: AssemblyCopyright("")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+[assembly: ComVisible(false)]\r
+[assembly: CLSCompliant(false)]\r
+[assembly: NeutralResourcesLanguage("en-US")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// You can specify all the values or you can default the Revision and Build Numbers \r
+// by using the '*' as shown below:\r
+\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
diff --git a/tools/clang-format-vs/ClangFormat/Resources.Designer.cs b/tools/clang-format-vs/ClangFormat/Resources.Designer.cs
new file mode 100644 (file)
index 0000000..d5d7d3f
--- /dev/null
@@ -0,0 +1,64 @@
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+//     This code was generated by a tool.\r
+//     Runtime Version:2.0.50727.42\r
+//\r
+//     Changes to this file may cause incorrect behavior and will be lost if\r
+//     the code is regenerated.\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace LLVM.ClangFormat {\r
+    using System;\r
+    \r
+    \r
+    /// <summary>\r
+    ///   A strongly-typed resource class, for looking up localized strings, etc.\r
+    /// </summary>\r
+    // This class was auto-generated by the StronglyTypedResourceBuilder\r
+    // class via a tool like ResGen or Visual Studio.\r
+    // To add or remove a member, edit your .ResX file then rerun ResGen\r
+    // with the /str option, or rebuild your VS project.\r
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]\r
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\r
+    internal class Resources {\r
+        \r
+        private static global::System.Resources.ResourceManager resourceMan;\r
+        \r
+        private static global::System.Globalization.CultureInfo resourceCulture;\r
+        \r
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]\r
+        internal Resources() {\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Returns the cached ResourceManager instance used by this class.\r
+        /// </summary>\r
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r
+        internal static global::System.Resources.ResourceManager ResourceManager {\r
+            get {\r
+                if (object.ReferenceEquals(resourceMan, null)) {\r
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LLVM.ClangFormat.Resources", typeof(Resources).Assembly);\r
+                    resourceMan = temp;\r
+                }\r
+                return resourceMan;\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Overrides the current thread's CurrentUICulture property for all\r
+        ///   resource lookups using this strongly typed resource class.\r
+        /// </summary>\r
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r
+        internal static global::System.Globalization.CultureInfo Culture {\r
+            get {\r
+                return resourceCulture;\r
+            }\r
+            set {\r
+                resourceCulture = value;\r
+            }\r
+        }\r
+        \r
+    }\r
+}\r
diff --git a/tools/clang-format-vs/ClangFormat/Resources.resx b/tools/clang-format-vs/ClangFormat/Resources.resx
new file mode 100644 (file)
index 0000000..352987a
--- /dev/null
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<!--\r
+    VS SDK Notes: This resx file contains the resources that will be consumed directly by your package.\r
+    For example, if you chose to create a tool window, there is a resource with ID 'CanNotCreateWindow'. This\r
+    is used in VsPkg.cs to determine the string to show the user if there is an error when attempting to create\r
+    the tool window.\r
+\r
+    Resources that are accessed directly from your package *by Visual Studio* are stored in the VSPackage.resx \r
+    file.\r
+-->\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+</root>
\ No newline at end of file
diff --git a/tools/clang-format-vs/ClangFormat/Resources/Images.png b/tools/clang-format-vs/ClangFormat/Resources/Images.png
new file mode 100644 (file)
index 0000000..51fe0d1
Binary files /dev/null and b/tools/clang-format-vs/ClangFormat/Resources/Images.png differ
diff --git a/tools/clang-format-vs/ClangFormat/Resources/Package.ico b/tools/clang-format-vs/ClangFormat/Resources/Package.ico
new file mode 100644 (file)
index 0000000..449296f
Binary files /dev/null and b/tools/clang-format-vs/ClangFormat/Resources/Package.ico differ
diff --git a/tools/clang-format-vs/ClangFormat/VSPackage.resx b/tools/clang-format-vs/ClangFormat/VSPackage.resx
new file mode 100644 (file)
index 0000000..81102d3
--- /dev/null
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<!--\r
+    VS SDK Notes: This resx file contains the resources that will be consumed from your package by Visual Studio.\r
+    For example, Visual Studio will attempt to load resource '400' from this resource stream when it needs to\r
+    load your package's icon. Because Visual Studio will always look in the VSPackage.resources stream first for\r
+    resources it needs, you should put additional resources that Visual Studio will load directly into this resx \r
+    file. \r
+\r
+    Resources that you would like to access directly from your package in a strong-typed fashion should be stored \r
+    in Resources.resx or another resx file.\r
+-->\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />\r
+  <data name="110" xml:space="preserve">\r
+    <value>ClangFormat</value>\r
+  </data>\r
+  <data name="112" xml:space="preserve">\r
+    <value>Formats code by calling the clang-format executable.</value>\r
+  </data>\r
+  <data name="400" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
+    <value>Resources\Package.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
+  </data>\r
+</root>
\ No newline at end of file
diff --git a/tools/clang-format-vs/ClangFormat/source.extension.vsixmanifest b/tools/clang-format-vs/ClangFormat/source.extension.vsixmanifest
new file mode 100644 (file)
index 0000000..274c028
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">\r
+  <Metadata>\r
+    <Identity Id="c5286038-25d3-4f65-83a8-51fa2df4a146" Version="1.0" Language="en-US" Publisher="LLVM" />\r
+    <DisplayName>ClangFormat</DisplayName>\r
+    <Description>Formats code by calling the clang-format executable.</Description>\r
+  </Metadata>\r
+  <Installation InstalledByMsi="false">\r
+    <InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="11.0" />\r
+  </Installation>\r
+  <Dependencies>\r
+    <Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="4.5" />\r
+    <Dependency Id="Microsoft.VisualStudio.MPF.11.0" DisplayName="Visual Studio MPF 11.0" d:Source="Installed" Version="11.0" />\r
+  </Dependencies>\r
+  <Assets>\r
+    <Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />\r
+  </Assets>\r
+</PackageManifest>\r
diff --git a/tools/clang-format-vs/README b/tools/clang-format-vs/README
new file mode 100644 (file)
index 0000000..240821c
--- /dev/null
@@ -0,0 +1,6 @@
+This directory contains a VSPackage project to generate a visual studio extension\r
+for clang-format.\r
+\r
+Build prerequisites are:\r
+- Visual Studio 2012 Professional\r
+- Visual Studio SDK (http://www.microsoft.com/en-us/download/details.aspx?id=30668)
\ No newline at end of file