Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2016-08-27 Thread Jason Juang via cfe-commits
jasjuang added a comment.

Just in case someone is interested. I figured out a hack with VCMD that 
actually does the job.

  using EnvDTE;
  using EnvDTE80;
  
  public class E : VisualCommanderExt.IExtension
  {
public void SetSite(EnvDTE80.DTE2 DTE_, 
Microsoft.VisualStudio.Shell.Package package)
{
  DTE = DTE_;
  events = DTE.Events;
  documentEvents = events.DocumentEvents;
  documentEvents.DocumentSaved += OnDocumentSaved;  
}
  
public void Close()
{
  documentEvents.DocumentSaved -= OnDocumentSaved;
}
  
private void OnDocumentSaved(EnvDTE.Document doc)
{
  if(doc.Language == "C/C++")
  {   
 DTE.ExecuteCommand("Edit.SelectAll");
 DTE.ExecuteCommand("Tools.ClangFormat");
 DTE.ExecuteCommand("View.NavigateBackward");
  }
}
  
private EnvDTE80.DTE2 DTE;
private EnvDTE.Events events;
private EnvDTE.DocumentEvents documentEvents;
  }

This will invoke clang format whenever a c++ related file is saved


https://reviews.llvm.org/D12407



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2016-08-29 Thread Jason Juang via cfe-commits
jasjuang added a comment.

@jsmouret Bravo for the improved solution!


https://reviews.llvm.org/D12407



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits