private void OnNewFile(object sender, HierarchyEventArgs args) { IVsHierarchy hierarchy = sender as IVsHierarchy; if (null == hierarchy) { return; } string fileText = null; if (null != args.TextBuffer) { int lastLine; int lastIndex; int hr = args.TextBuffer.GetLastLineIndex(out lastLine, out lastIndex); if (Microsoft.VisualStudio.ErrorHandler.Failed(hr)) { return; } hr = args.TextBuffer.GetLineText(0, 0, lastLine, lastIndex, out fileText); if (Microsoft.VisualStudio.ErrorHandler.Failed(hr)) { return; } } CreateParseRequest(args.CanonicalName, fileText, new ModuleId(hierarchy, args.ItemID)); }
public void OnIdle() { if (!_isDirty) { return; } var onFileChanged = OnFileChanged; if (null != onFileChanged) { HierarchyEventArgs args = new HierarchyEventArgs(_fileId.ItemID, _fileName); args.TextBuffer = _buffer; onFileChanged(_fileId.Hierarchy, args); } _isDirty = false; }
public int OnBeforeLastDocumentUnlock(uint docCookie, uint dwRDTLockType, uint dwReadLocksRemaining, uint dwEditLocksRemaining) { if ((0 != dwEditLocksRemaining) || (0 != dwReadLocksRemaining)) { return(VSConstants.S_OK); } TextLineEventListener listener; if (!documents.TryGetValue(docCookie, out listener) || (null == listener)) { return(VSConstants.S_OK); } using (listener) { documents.Remove(docCookie); // Now make sure that the information about this file are up to date (e.g. it is // possible that Class View shows something strange if the file was closed without // saving the changes). HierarchyEventArgs args = new HierarchyEventArgs(listener.FileID.ItemID, listener.FileName); OnNewFile(listener.FileID.Hierarchy, args); } return(VSConstants.S_OK); }
private void OnDeleteFile(object sender, HierarchyEventArgs args) { IVsHierarchy hierarchy = sender as IVsHierarchy; if (null == hierarchy) { return; } ModuleId id = new ModuleId(hierarchy, args.ItemID); LibraryNode node = null; lock (files) { if (files.TryGetValue(id, out node)) { files.Remove(id); } } if (null != node) { library.RemoveNode(node); } }
private void SolutionEvents_OnBeforeOpeningChildren(object sender, HierarchyEventArgs e) { Debug.WriteLine($"tr: BeforeOpeningChildren(Hierarchy='{e.Hierarchy}')"); }
private void SolutionEvents_OnAfterRenameProject(object sender, HierarchyEventArgs e) { var hierarchy = e.Hierarchy; var project = hierarchy.GetProp<EnvDTE.Project>(VSConstants.VSITEMID_ROOT, __VSHPROPID.VSHPROPID_ExtObject); Debug.WriteLine($"tr: AfterRenameProject(Hierarchy='{hierarchy}', FullName='{project.FullName}')"); }