You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
INPUTS
bindings
cmake
docs
examples
include
lib
runtime
tools
arcmt-test
c-arcmt-test
c-index-test
clang-check
clang-diff
clang-format
clang-format-vs
ClangFormat
Properties
Resources
ClangFormat.csproj
ClangFormat.vsct
ClangFormatPackage.cs
GlobalSuppressions.cs
Guids.cs
PkgCmdID.cs
Resources.Designer.cs
Resources.resx
RunningDocTableEventsDispatcher.cs
VSPackage.resx
Vsix.cs
license.txt
packages.config
.gitignore
CMakeLists.txt
ClangFormat.sln
README.txt
source.extension.vsixmanifest.in
clang-func-mapping
clang-fuzzer
clang-import-test
clang-offload-bundler
clang-refactor
clang-rename
diag-build
diagtool
driver
libclang
scan-build
scan-build-py
scan-view
CMakeLists.txt
unittests
utils
www
.arcconfig
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
INSTALL.txt
LICENSE.TXT
ModuleInfo.txt
NOTES.txt
README.txt
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
using EnvDTE;
|
|
using Microsoft.VisualStudio;
|
|
using Microsoft.VisualStudio.Shell;
|
|
using Microsoft.VisualStudio.Shell.Interop;
|
|
using System.Linq;
|
|
|
|
namespace LLVM.ClangFormat
|
|
{
|
|
// Exposes event sources for IVsRunningDocTableEvents3 events.
|
|
internal sealed class RunningDocTableEventsDispatcher : IVsRunningDocTableEvents3
|
|
{
|
|
private RunningDocumentTable _runningDocumentTable;
|
|
private DTE _dte;
|
|
|
|
public delegate void OnBeforeSaveHander(object sender, Document document);
|
|
public event OnBeforeSaveHander BeforeSave;
|
|
|
|
public RunningDocTableEventsDispatcher(Package package)
|
|
{
|
|
_runningDocumentTable = new RunningDocumentTable(package);
|
|
_runningDocumentTable.Advise(this);
|
|
_dte = (DTE)Package.GetGlobalService(typeof(DTE));
|
|
}
|
|
|
|
public int OnAfterAttributeChange(uint docCookie, uint grfAttribs)
|
|
{
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
public int OnAfterAttributeChangeEx(uint docCookie, uint grfAttribs, IVsHierarchy pHierOld, uint itemidOld, string pszMkDocumentOld, IVsHierarchy pHierNew, uint itemidNew, string pszMkDocumentNew)
|
|
{
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
public int OnAfterDocumentWindowHide(uint docCookie, IVsWindowFrame pFrame)
|
|
{
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
public int OnAfterFirstDocumentLock(uint docCookie, uint dwRDTLockType, uint dwReadLocksRemaining, uint dwEditLocksRemaining)
|
|
{
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
public int OnAfterSave(uint docCookie)
|
|
{
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
|
|
{
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
public int OnBeforeLastDocumentUnlock(uint docCookie, uint dwRDTLockType, uint dwReadLocksRemaining, uint dwEditLocksRemaining)
|
|
{
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
public int OnBeforeSave(uint docCookie)
|
|
{
|
|
if (BeforeSave != null)
|
|
{
|
|
var document = FindDocumentByCookie(docCookie);
|
|
if (document != null) // Not sure why this happens sometimes
|
|
{
|
|
BeforeSave(this, FindDocumentByCookie(docCookie));
|
|
}
|
|
}
|
|
return VSConstants.S_OK;
|
|
}
|
|
|
|
private Document FindDocumentByCookie(uint docCookie)
|
|
{
|
|
var documentInfo = _runningDocumentTable.GetDocumentInfo(docCookie);
|
|
return _dte.Documents.Cast<Document>().FirstOrDefault(doc => doc.FullName == documentInfo.Moniker);
|
|
}
|
|
}
|
|
}
|