├── CppTripleSlash.csproj ├── CppTripleSlash.sln ├── CppTripleSlashPackage.cs ├── Guids.cs ├── Key.snk ├── LICENSE ├── MS-PL.txt ├── Properties └── AssemblyInfo.cs ├── README.md ├── Release.txt ├── TripleSlashCompletionCommandHandler.cs ├── TripleSlashCompletionHandlerProvider.cs ├── TripleSlashCompletionSource.cs ├── TripleSlashCompletionSourceProvider.cs ├── cppts.png ├── cppts_preview.png └── source.extension.vsixmanifest /CppTripleSlash.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 15.0 5 | 12.0 6 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 7 | 8 | 9 | 10 | 11 | 12.0 12 | 13 | 14 | 15 | Debug 16 | AnyCPU 17 | 2.0 18 | {DD4A3475-97EB-4C5C-AFF7-DE4921AA9B94} 19 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 20 | Library 21 | Properties 22 | CppTripleSlash 23 | CppTripleSlash 24 | True 25 | Key.snk 26 | v4.0 27 | false 28 | 29 | 30 | true 31 | full 32 | false 33 | bin\Debug\ 34 | DEBUG;TRACE 35 | prompt 36 | 4 37 | 38 | 39 | pdbonly 40 | true 41 | bin\Release\ 42 | TRACE 43 | prompt 44 | 4 45 | false 46 | False 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | {80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2} 78 | 8 79 | 0 80 | 0 81 | primary 82 | False 83 | False 84 | 85 | 86 | {1A31287A-4D7D-413E-8E32-3B374931BD89} 87 | 8 88 | 0 89 | 0 90 | primary 91 | False 92 | False 93 | 94 | 95 | {1CBA492E-7263-47BB-87FE-639000619B15} 96 | 8 97 | 0 98 | 0 99 | primary 100 | False 101 | False 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | Designer 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | Always 124 | true 125 | 126 | 127 | Always 128 | true 129 | 130 | 131 | Always 132 | true 133 | 134 | 135 | Always 136 | true 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /CppTripleSlash.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.4 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppTripleSlash", "CppTripleSlash.csproj", "{DD4A3475-97EB-4C5C-AFF7-DE4921AA9B94}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {DD4A3475-97EB-4C5C-AFF7-DE4921AA9B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {DD4A3475-97EB-4C5C-AFF7-DE4921AA9B94}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {DD4A3475-97EB-4C5C-AFF7-DE4921AA9B94}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {DD4A3475-97EB-4C5C-AFF7-DE4921AA9B94}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /CppTripleSlashPackage.cs: -------------------------------------------------------------------------------- 1 | namespace CppTripleSlash 2 | { 3 | using Microsoft.VisualStudio.Shell; 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | [PackageRegistration(UseManagedResourcesOnly = true)] 8 | [Guid(GuidList.guidCppTripleSlashPkgString)] 9 | public sealed class CppTripleSlashPackage : Package 10 | { 11 | protected override void Initialize() 12 | { 13 | base.Initialize(); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Guids.cs: -------------------------------------------------------------------------------- 1 | // Guids.cs 2 | // MUST match guids.h 3 | using System; 4 | 5 | namespace CppTripleSlash 6 | { 7 | static class GuidList 8 | { 9 | public const string guidCppTripleSlashPkgString = "70dbb5d8-42d5-43f8-af7b-37668d5c9b46"; 10 | public const string guidCppTripleSlashCmdSetString = "7dda296b-3ba8-404a-a15b-bc88d13884b9"; 11 | 12 | public static readonly Guid guidCppTripleSlashCmdSet = new Guid(guidCppTripleSlashCmdSetString); 13 | }; 14 | } -------------------------------------------------------------------------------- /Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tcbhat/cpptripleslash/9c00742430acd258766026f1251bacfc410d0922/Key.snk -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 tcbhat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MS-PL.txt: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Public License (MS-PL) 3 | 4 | This license governs use of the accompanying software. If you use the software, you 5 | accept this license. If you do not accept the license, do not use the software. 6 | 7 | 1. Definitions 8 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the 9 | same meaning here as under U.S. copyright law. 10 | A "contribution" is the original software, or any additions or changes to the software. 11 | A "contributor" is any person that distributes its contribution under this license. 12 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 13 | 14 | 2. Grant of Rights 15 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 16 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 17 | 18 | 3. Conditions and Limitations 19 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 20 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 21 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 22 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 23 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. 24 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Resources; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("CppTripleSlash")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("Company")] 14 | [assembly: AssemblyProduct("CppTripleSlash")] 15 | [assembly: AssemblyCopyright("")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | [assembly: ComVisible(false)] 19 | [assembly: CLSCompliant(false)] 20 | [assembly: NeutralResourcesLanguage("en-US")] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cpptripleslash 2 | Generate xml documentaton comment stubs for c++ when three forward slashes are typed 3 | -------------------------------------------------------------------------------- /Release.txt: -------------------------------------------------------------------------------- 1 | Version 1.0.6 2 | Support Vs Community 2017 3 | 4 | Version 1.0.5 5 | Better intellisense 6 | 7 | Version 1.0.4 8 | Inserting the tag if no code element is found 9 | 10 | Version 1.0.3 11 | Added a few more tags to intellisense 12 | 13 | Version 1.0.2 14 | Fixed minor bug when Enter is pressed in the doc section 15 | 16 | Version 1.0.1 17 | Fixed minor bug with commenting in function declarations -------------------------------------------------------------------------------- /TripleSlashCompletionCommandHandler.cs: -------------------------------------------------------------------------------- 1 | namespace CppTripleSlash 2 | { 3 | using EnvDTE; 4 | using Microsoft.VisualStudio; 5 | using Microsoft.VisualStudio.Language.Intellisense; 6 | using Microsoft.VisualStudio.OLE.Interop; 7 | using Microsoft.VisualStudio.Shell; 8 | using Microsoft.VisualStudio.Text; 9 | using Microsoft.VisualStudio.Text.Editor; 10 | using Microsoft.VisualStudio.TextManager.Interop; 11 | using System; 12 | using System.Runtime.InteropServices; 13 | using System.Text; 14 | 15 | public class TripleSlashCompletionCommandHandler : IOleCommandTarget 16 | { 17 | public const string CppTypeName = "C/C++"; 18 | private IOleCommandTarget m_nextCommandHandler; 19 | private IWpfTextView m_textView; 20 | private TripleSlashCompletionHandlerProvider m_provider; 21 | private ICompletionSession m_session; 22 | DTE m_dte; 23 | 24 | public TripleSlashCompletionCommandHandler( 25 | IVsTextView textViewAdapter, 26 | IWpfTextView textView, 27 | TripleSlashCompletionHandlerProvider provider, 28 | DTE dte) 29 | { 30 | this.m_textView = textView; 31 | this.m_provider = provider; 32 | this.m_dte = dte; 33 | 34 | // add the command to the command chain 35 | if (textViewAdapter != null && 36 | textView != null && 37 | textView.TextBuffer != null && 38 | textView.TextBuffer.ContentType.TypeName == CppTypeName) 39 | { 40 | textViewAdapter.AddCommandFilter(this, out m_nextCommandHandler); 41 | } 42 | } 43 | 44 | public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) 45 | { 46 | return m_nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); 47 | } 48 | 49 | public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) 50 | { 51 | try 52 | { 53 | if (VsShellUtilities.IsInAutomationFunction(m_provider.ServiceProvider)) 54 | { 55 | return m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); 56 | } 57 | 58 | // make a copy of this so we can look at it after forwarding some commands 59 | uint commandID = nCmdID; 60 | char typedChar = char.MinValue; 61 | 62 | // make sure the input is a char before getting it 63 | if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR) 64 | { 65 | typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn); 66 | } 67 | 68 | // check for the triple slash 69 | if (typedChar == '/' && m_dte != null) 70 | { 71 | string currentLine = m_textView.TextSnapshot.GetLineFromPosition( 72 | m_textView.Caret.Position.BufferPosition.Position).GetText(); 73 | if ((currentLine + "/").Trim() == "///") 74 | { 75 | // Calculate how many spaces 76 | string spaces = currentLine.Replace(currentLine.TrimStart(), ""); 77 | TextSelection ts = m_dte.ActiveDocument.Selection as TextSelection; 78 | int oldLine = ts.ActivePoint.Line; 79 | int oldOffset = ts.ActivePoint.LineCharOffset; 80 | ts.LineDown(); 81 | ts.EndOfLine(); 82 | 83 | CodeElement codeElement = null; 84 | FileCodeModel fcm = m_dte.ActiveDocument.ProjectItem.FileCodeModel; 85 | if (fcm != null) 86 | { 87 | codeElement = fcm.CodeElementFromPoint(ts.ActivePoint, vsCMElement.vsCMElementFunction); 88 | } 89 | 90 | if (codeElement != null && codeElement is CodeFunction) 91 | { 92 | CodeFunction function = codeElement as CodeFunction; 93 | StringBuilder sb = new StringBuilder("/ \r\n" + spaces + "/// \r\n" + spaces + "/// "); 94 | foreach (CodeElement child in codeElement.Children) 95 | { 96 | CodeParameter parameter = child as CodeParameter; 97 | if (parameter != null) 98 | { 99 | sb.AppendFormat("\r\n" + spaces + "/// ", parameter.Name); 100 | } 101 | } 102 | 103 | if (function.Type.AsString != "void") 104 | { 105 | sb.AppendFormat("\r\n" + spaces + "/// "); 106 | } 107 | 108 | ts.MoveToLineAndOffset(oldLine, oldOffset); 109 | ts.Insert(sb.ToString()); 110 | ts.MoveToLineAndOffset(oldLine, oldOffset); 111 | ts.LineDown(); 112 | ts.EndOfLine(); 113 | return VSConstants.S_OK; 114 | } 115 | else 116 | { 117 | ts.MoveToLineAndOffset(oldLine, oldOffset); 118 | ts.Insert("/ \r\n" + spaces + "/// \r\n" + spaces + "/// "); 119 | ts.MoveToLineAndOffset(oldLine, oldOffset); 120 | ts.LineDown(); 121 | ts.EndOfLine(); 122 | return VSConstants.S_OK; 123 | } 124 | } 125 | } 126 | 127 | if (m_session != null && !m_session.IsDismissed) 128 | { 129 | // check for a commit character 130 | if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN 131 | || nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB 132 | || typedChar == '>') 133 | { 134 | // check for a selection 135 | // if the selection is fully selected, commit the current session 136 | if (m_session.SelectedCompletionSet.SelectionStatus.IsSelected) 137 | { 138 | string selectedCompletion = m_session.SelectedCompletionSet.SelectionStatus.Completion.DisplayText; 139 | m_session.Commit(); 140 | TextSelection ts = m_dte.ActiveDocument.Selection as TextSelection; 141 | switch (selectedCompletion) 142 | { 143 | case "": 144 | ts.CharLeft(false, 3); 145 | break; 146 | case "": 147 | ts.CharLeft(false, 3); 148 | break; 149 | case "": 150 | ts.CharLeft(false, 4); 151 | break; 152 | case "": 153 | ts.CharLeft(false, 7); 154 | break; 155 | case "": 156 | ts.CharLeft(false, 10); 157 | break; 158 | case "": 159 | ts.CharLeft(false, 14); 160 | break; 161 | case "": 162 | ts.CharLeft(false, 21); 163 | break; 164 | case "": 165 | ts.CharLeft(false, 7); 166 | break; 167 | case "": 168 | ts.CharLeft(false, 7); 169 | break; 170 | case "": 171 | ts.CharLeft(false, 10); 172 | break; 173 | case "": 174 | ts.CharLeft(false, 13); 175 | break; 176 | case "": 177 | ts.CharLeft(false, 15); 178 | break; 179 | case "": 180 | ts.CharLeft(false, 10); 181 | break; 182 | case "": 183 | ts.CharLeft(false, 10); 184 | break; 185 | case "": 186 | ts.CharLeft(false, 3); 187 | break; 188 | case "": 189 | ts.CharLeft(false, 3); 190 | break; 191 | case "": 192 | ts.CharLeft(false, 14); 193 | break; 194 | case "": 195 | ts.CharLeft(false, 3); 196 | break; 197 | case "": 198 | ts.CharLeft(false, 8); 199 | break; 200 | default: 201 | break; 202 | } 203 | 204 | // also, don't add the character to the buffer 205 | return VSConstants.S_OK; 206 | } 207 | else 208 | { 209 | // if there is no selection, dismiss the session 210 | m_session.Dismiss(); 211 | } 212 | } 213 | } 214 | else 215 | { 216 | if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN) 217 | { 218 | string currentLine = m_textView.TextSnapshot.GetLineFromPosition( 219 | m_textView.Caret.Position.BufferPosition.Position).GetText(); 220 | if (currentLine.TrimStart().StartsWith("///")) 221 | { 222 | TextSelection ts = m_dte.ActiveDocument.Selection as TextSelection; 223 | string spaces = currentLine.Replace(currentLine.TrimStart(), ""); 224 | ts.Insert("\r\n" + spaces + "/// "); 225 | return VSConstants.S_OK; 226 | } 227 | } 228 | } 229 | 230 | // pass along the command so the char is added to the buffer 231 | int retVal = m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); 232 | if (typedChar == '<') 233 | { 234 | string currentLine = m_textView.TextSnapshot.GetLineFromPosition( 235 | m_textView.Caret.Position.BufferPosition.Position).GetText(); 236 | if (currentLine.TrimStart().StartsWith("///")) 237 | { 238 | if (m_session == null || m_session.IsDismissed) // If there is no active session, bring up completion 239 | { 240 | if (this.TriggerCompletion()) 241 | { 242 | m_session.SelectedCompletionSet.SelectBestMatch(); 243 | m_session.SelectedCompletionSet.Recalculate(); 244 | return VSConstants.S_OK; 245 | } 246 | } 247 | } 248 | } 249 | else if ( 250 | commandID == (uint)VSConstants.VSStd2KCmdID.BACKSPACE || 251 | commandID == (uint)VSConstants.VSStd2KCmdID.DELETE || 252 | char.IsLetter(typedChar)) 253 | { 254 | if (m_session != null && !m_session.IsDismissed) // the completion session is already active, so just filter 255 | { 256 | m_session.SelectedCompletionSet.SelectBestMatch(); 257 | m_session.SelectedCompletionSet.Recalculate(); 258 | return VSConstants.S_OK; 259 | } 260 | } 261 | 262 | return retVal; 263 | } 264 | catch 265 | { 266 | } 267 | 268 | return VSConstants.E_FAIL; 269 | } 270 | 271 | private bool TriggerCompletion() 272 | { 273 | try 274 | { 275 | if (m_session != null) 276 | { 277 | return false; 278 | } 279 | 280 | // the caret must be in a non-projection location 281 | SnapshotPoint? caretPoint = 282 | m_textView.Caret.Position.Point.GetPoint( 283 | textBuffer => (!textBuffer.ContentType.IsOfType("projection")), PositionAffinity.Predecessor); 284 | if (!caretPoint.HasValue) 285 | { 286 | return false; 287 | } 288 | 289 | m_session = m_provider.CompletionBroker.CreateCompletionSession( 290 | m_textView, 291 | caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive), 292 | true); 293 | 294 | // subscribe to the Dismissed event on the session 295 | m_session.Dismissed += this.OnSessionDismissed; 296 | m_session.Start(); 297 | return true; 298 | } 299 | catch 300 | { 301 | } 302 | 303 | return false; 304 | } 305 | 306 | private void OnSessionDismissed(object sender, EventArgs e) 307 | { 308 | if (m_session != null) 309 | { 310 | m_session.Dismissed -= this.OnSessionDismissed; 311 | m_session = null; 312 | } 313 | } 314 | } 315 | } -------------------------------------------------------------------------------- /TripleSlashCompletionHandlerProvider.cs: -------------------------------------------------------------------------------- 1 | namespace CppTripleSlash 2 | { 3 | using EnvDTE; 4 | using Microsoft.VisualStudio.Editor; 5 | using Microsoft.VisualStudio.Language.Intellisense; 6 | using Microsoft.VisualStudio.Shell; 7 | using Microsoft.VisualStudio.Text.Editor; 8 | using Microsoft.VisualStudio.TextManager.Interop; 9 | using Microsoft.VisualStudio.Utilities; 10 | using System; 11 | using System.ComponentModel.Composition; 12 | 13 | [Export(typeof(IVsTextViewCreationListener))] 14 | [Name("C++ Triple Slash Completion Handler")] 15 | [ContentType("code")] 16 | [TextViewRole(PredefinedTextViewRoles.Editable)] 17 | public class TripleSlashCompletionHandlerProvider : IVsTextViewCreationListener 18 | { 19 | [Import] 20 | public IVsEditorAdaptersFactoryService AdapterService = null; 21 | 22 | [Import] 23 | public ICompletionBroker CompletionBroker { get; set; } 24 | 25 | [Import] 26 | public SVsServiceProvider ServiceProvider { get; set; } 27 | 28 | public void VsTextViewCreated(IVsTextView textViewAdapter) 29 | { 30 | try 31 | { 32 | IWpfTextView textView = this.AdapterService.GetWpfTextView(textViewAdapter); 33 | if (textView == null) 34 | { 35 | return; 36 | } 37 | 38 | Func createCommandHandler = delegate() 39 | { 40 | var dte = ServiceProvider.GetService(typeof(DTE)) as DTE; 41 | return new TripleSlashCompletionCommandHandler(textViewAdapter, textView, this, dte); 42 | }; 43 | 44 | textView.Properties.GetOrCreateSingletonProperty(createCommandHandler); 45 | } 46 | catch 47 | { 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /TripleSlashCompletionSource.cs: -------------------------------------------------------------------------------- 1 | namespace CppTripleSlash 2 | { 3 | using Microsoft.VisualStudio.Language.Intellisense; 4 | using Microsoft.VisualStudio.Text; 5 | using Microsoft.VisualStudio.Text.Operations; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Windows.Media; 10 | 11 | public class TripleSlashCompletionSource : ICompletionSource 12 | { 13 | private TripleSlashCompletionSourceProvider m_sourceProvider; 14 | private ITextBuffer m_textBuffer; 15 | private List m_compList = new List(); 16 | private bool m_isDisposed; 17 | 18 | public TripleSlashCompletionSource(TripleSlashCompletionSourceProvider sourceProvider, ITextBuffer textBuffer) 19 | { 20 | m_sourceProvider = sourceProvider; 21 | m_textBuffer = textBuffer; 22 | ImageSource image = null; 23 | 24 | try 25 | { 26 | image = this.m_sourceProvider.GlyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic); 27 | } 28 | catch 29 | { 30 | } 31 | 32 | 33 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 34 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 35 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 36 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 37 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 38 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 39 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 40 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 41 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 42 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 43 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 44 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 45 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 46 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 47 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 48 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 49 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 50 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 51 | m_compList.Add(new Completion("", "", string.Empty, image, string.Empty)); 52 | 53 | } 54 | 55 | void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList completionSets) 56 | { 57 | try 58 | { 59 | if (m_isDisposed) 60 | { 61 | return; 62 | } 63 | 64 | SnapshotPoint? snapshotPoint = session.GetTriggerPoint(m_textBuffer.CurrentSnapshot); 65 | if (!snapshotPoint.HasValue) 66 | { 67 | return; 68 | } 69 | 70 | string text = snapshotPoint.Value.GetContainingLine().GetText(); 71 | if (m_textBuffer.ContentType.TypeName != TripleSlashCompletionCommandHandler.CppTypeName) 72 | { 73 | return; 74 | } 75 | 76 | if (!text.TrimStart().StartsWith("///")) 77 | { 78 | return; 79 | } 80 | 81 | ITrackingSpan trackingSpan = FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), session); 82 | var newCompletionSet = new CompletionSet( 83 | "TripleSlashCompletionSet", 84 | "TripleSlashCompletionSet", 85 | trackingSpan, 86 | m_compList, 87 | Enumerable.Empty()); 88 | completionSets.Add(newCompletionSet); 89 | } 90 | catch 91 | { 92 | } 93 | } 94 | 95 | public void Dispose() 96 | { 97 | if (!m_isDisposed) 98 | { 99 | GC.SuppressFinalize(this); 100 | m_isDisposed = true; 101 | } 102 | } 103 | 104 | private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session) 105 | { 106 | try 107 | { 108 | SnapshotPoint currentPoint = session.TextView.Caret.Position.BufferPosition - 1; 109 | return currentPoint.Snapshot.CreateTrackingSpan(currentPoint, 1, SpanTrackingMode.EdgeInclusive); 110 | } 111 | catch 112 | { 113 | } 114 | 115 | return null; 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /TripleSlashCompletionSourceProvider.cs: -------------------------------------------------------------------------------- 1 | namespace CppTripleSlash 2 | { 3 | using Microsoft.VisualStudio.Language.Intellisense; 4 | using Microsoft.VisualStudio.Text; 5 | using Microsoft.VisualStudio.Text.Operations; 6 | using Microsoft.VisualStudio.Utilities; 7 | using System.ComponentModel.Composition; 8 | 9 | [Export(typeof(ICompletionSourceProvider))] 10 | [ContentType("code")] 11 | [Name("xml doc comment completion")] 12 | public class TripleSlashCompletionSourceProvider : ICompletionSourceProvider 13 | { 14 | [Import] 15 | internal ITextStructureNavigatorSelectorService NavigatorService { get; set; } 16 | 17 | [Import] 18 | internal IGlyphService GlyphService { get; set; } 19 | 20 | public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer) 21 | { 22 | return new TripleSlashCompletionSource(this, textBuffer); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /cppts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tcbhat/cpptripleslash/9c00742430acd258766026f1251bacfc410d0922/cppts.png -------------------------------------------------------------------------------- /cppts_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tcbhat/cpptripleslash/9c00742430acd258766026f1251bacfc410d0922/cppts_preview.png -------------------------------------------------------------------------------- /source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | CppTripleSlash - xml doc comments for c++ 5 | Generate xml documentaton comment stubs for c++ when three forward slashes are typed 6 | https://github.com/tcbhat/cpptripleslash 7 | MS-PL.txt 8 | https://marketplace.visualstudio.com/items?itemName=tcbhat.CppTripleSlash-xmldoccommentsforc 9 | Release.txt 10 | cppts.png 11 | cppts_preview.png 12 | C++, Comments, xml doc comments 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------