private void GetCppInfo(CodeElement ce, LocatorCodeItem item, ProjectItem projectItem) { item.ProjectItem = null; item.ElementOffset = 1; VCCodeElement vcEl = ce as VCCodeElement; if (vcEl != null) { try { TextPoint def = vcEl.StartPointOf[vsCMPart.vsCMPartName, vsCMWhere.vsCMWhereDefinition]; if (def.Parent.Parent.ProjectItem == projectItem) { item.ProjectItem = def.Parent.Parent.ProjectItem; item.ElementOffset = def.AbsoluteCharOffset; } } catch { } if (item.ProjectItem == null) { try { TextPoint decl = vcEl.StartPointOf[vsCMPart.vsCMPartName, vsCMWhere.vsCMWhereDeclaration]; if (decl.Parent.Parent.ProjectItem == projectItem) { item.ProjectItem = decl.Parent.Parent.ProjectItem; item.ElementOffset = decl.AbsoluteCharOffset; } } catch { } } } }
private void GetCodeElements(List<LocatorCodeItem> results, CodeElements codeElements, ProjectItem projectItem) { if (codeElements == null) return; foreach (CodeElement ce in codeElements) { if (_cancelSearch) return; bool emptySearchStr = _currentSearchString.Length == 0; if (ce.Kind == vsCMElement.vsCMElementNamespace) { CodeNamespace nsp = ce as CodeNamespace; GetCodeElements(results, nsp.Children, projectItem); } else if (ce.Kind == vsCMElement.vsCMElementStruct) { CodeStruct str = ce as CodeStruct; if (str != null) { VCCodeStruct vcStr = str as VCCodeStruct; if (vcStr != null) { // Skip forward declarations if (vcStr.ProjectItem == projectItem) { if (emptySearchStr || str.Name.ToUpper().Contains(_currentSearchString)) { LocatorCodeItem item = new LocatorCodeItem(); item.CodeElement = ce; item.Name = str.Name; item.FQName = str.FullName; item.Comment = str.Comment; item.Image = _codeIconList[CodeIcon_Struct]; results.Add(item); } GetCodeElements(results, vcStr.Children, projectItem); } } else { GetCodeElements(results, str.Children, projectItem); } } } else if (ce.Kind == vsCMElement.vsCMElementClass) { CodeClass cls = ce as CodeClass; if (cls != null) { VCCodeClass vcCls = cls as VCCodeClass; if (vcCls != null) { // Skip forward declarations if (vcCls.ProjectItem == projectItem) { if (emptySearchStr || cls.Name.ToUpper().Contains(_currentSearchString)) { LocatorCodeItem item = new LocatorCodeItem(); item.CodeElement = ce; item.Name = cls.Name; item.FQName = cls.FullName; item.Comment = cls.Comment; item.Image = _codeIconList[CodeIcon_Class]; results.Add(item); } GetCodeElements(results, vcCls.Children, projectItem); } } else { GetCodeElements(results, cls.Children, projectItem); } } } else if (ce.Kind == vsCMElement.vsCMElementFunction) { CodeFunction f = ce as CodeFunction; if (f != null) { if (emptySearchStr || f.Name.ToUpper().Contains(_currentSearchString)) { LocatorCodeItem item = new LocatorCodeItem(); item.CodeElement = ce; item.Name = f.get_Prototype((int)vsCMPrototype.vsCMPrototypeParamTypes); item.FQName = f.FullName; item.Comment = f.Comment; item.Image = _codeIconList[CodeIcon_Function]; GetCppInfo(ce, item, projectItem); results.Add(item); } } } else if (ce.Kind == vsCMElement.vsCMElementEnum) { CodeEnum enm = ce as CodeEnum; if (enm != null) { if (emptySearchStr || enm.Name.ToUpper().Contains(_currentSearchString)) { VCCodeEnum vcEnm = enm as VCCodeEnum; // Skip forward declarations if (vcEnm == null || vcEnm.ProjectItem == projectItem) { LocatorCodeItem item = new LocatorCodeItem(); item.CodeElement = ce; item.Name = enm.Name; item.FQName = enm.FullName; item.Comment = enm.Comment; item.Image = _codeIconList[CodeIcon_Enum]; results.Add(item); } } } } else if (ce.Kind == vsCMElement.vsCMElementUnion) { VCCodeUnion vcUn = ce as VCCodeUnion; if (vcUn != null) { if (emptySearchStr || vcUn.Name.ToUpper().Contains(_currentSearchString)) { // Skip forward declarations if (vcUn.ProjectItem == projectItem) { LocatorCodeItem item = new LocatorCodeItem(); item.CodeElement = ce; item.Name = vcUn.Name; item.FQName = vcUn.FullName; item.Comment = vcUn.Comment; item.Image = _codeIconList[CodeIcon_Union]; results.Add(item); } } } } else if (ce.Kind == vsCMElement.vsCMElementInterface) { CodeInterface intf = ce as CodeInterface; if (intf != null) { if (emptySearchStr || intf.Name.ToUpper().Contains(_currentSearchString)) { LocatorCodeItem item = new LocatorCodeItem(); item.CodeElement = ce; item.Name = intf.Name; item.FQName = intf.FullName; item.Comment = intf.Comment; item.Image = _codeIconList[CodeIcon_Interface]; results.Add(item); } GetCodeElements(results, intf.Children, projectItem); } } if (_resultFlushStopwatch.ElapsedMilliseconds > RESULT_FLUSH_TIMEOUT) { // Taking too long, flush what we got alredy. List<LocatorCodeItem> toSend = new List<LocatorCodeItem>(results); RaiseSearchResultEventInUserThread(SearchResultEventArgs.ResultType.Data, -1, toSend); results.Clear(); _resultFlushStopwatch.Restart(); } } }