public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded) { string project_path = GetProjectPath(pHierarchy); if (project_path == null) { return(0); } if (m_server != null) { m_server.AddTask(() => m_server.AddProjectInfo(project_path)); } m_projects[pHierarchy] = new UIProjectInfo(this, pHierarchy, project_path, m_dot_ext, m_file_icon); return(0); }
internal void InitProjectInfos(SVsServiceProvider provider, ABnfFactory factory) { if (factory == null) { return; } if (m_server != null) { return; } m_server = new ALanguageServer(); m_server.Start(factory); if (m_cookie != 0) { return; } if (m_solution != null) { return; } m_solution = provider.GetService(typeof(SVsSolution)) as IVsSolution; if (m_solution == null) { return; } m_dot_ext = factory.GetDotExt(); m_file_icon = factory.GetFileIcon(); // 读取所有工程 m_projects.Clear(); Guid rguidEnumOnlyThisType = new Guid(); IEnumHierarchies ppenum = null; m_solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum); IVsHierarchy[] rgelt = new IVsHierarchy[1]; uint pceltFetched = 0; while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1) { IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2; if (sccProject2 != null) { string project_path = GetProjectPath(rgelt[0]); if (project_path != null) { if (m_server != null) { m_server.AddTask(() => m_server.AddProjectInfo(project_path)); } m_projects[rgelt[0]] = new UIProjectInfo(this, rgelt[0], project_path, m_dot_ext, m_file_icon); } } } // 监听工程变化 m_solution.AdviseSolutionEvents(this, out m_cookie); }
private void ProtoToEMsgTypes(ALanguageServer server, IWpfTextView text_view, UIViewItem view_item) { int offset = text_view.Caret.Position.BufferPosition.Position; string project_path = view_item.GetProjectPath(); string full_path = view_item.GetFullPath(); server.AddTask(() => AProtobufFactoryClass.inst.GotoEMsgTypes(server, project_path, full_path, offset)); }
private void OtherToProto(ALanguageServer server, IWpfTextView text_view) { int offset = text_view.Caret.Position.BufferPosition.Position; int length = text_view.TextBuffer.CurrentSnapshot.Length; // 往前找 int start = offset; for (int i = offset - 1; i >= 0; --i) { var value = text_view.TextBuffer.CurrentSnapshot[i]; if (char.IsDigit(value)) { continue; } if (char.IsLetter(value)) { continue; } if (value == '_') { continue; } if (value == ':') { continue; } if (value == '.') { continue; } start = i + 1; break; } // 往后找 int end = offset; for (int i = offset; i < length; ++i) { var value = text_view.TextBuffer.CurrentSnapshot[i]; if (char.IsDigit(value)) { continue; } if (char.IsLetter(value)) { continue; } if (value == '_') { continue; } if (value == ':') { continue; } if (value == '.') { continue; } end = i; break; } // 获取文本 var text = text_view.TextBuffer.CurrentSnapshot.GetText(start, end - start); server.AddTask(() => server.FastGoto(text)); }