/// <summary> /// Explores given method using C# lookuper /// </summary> protected virtual void Explore(AbstractBatchCommand parentCommand, CodeFunction2 codeFunction, CodeNamespace parentNamespace, CodeElement2 codeClassOrStruct, Predicate <CodeElement> exploreable, bool isLocalizableFalse) { if (codeFunction.MustImplement) { return; // method must not be abstract or declated in an interface } if (!exploreable(codeFunction as CodeElement)) { return; // predicate must eval to true } // there is no way of knowing whether a function is not declared 'extern'. In that case, following will throw an exception. string functionText = null; try { functionText = codeFunction.GetText(); // get method text } catch (Exception) { } if (string.IsNullOrEmpty(functionText)) { return; } TextPoint startPoint = codeFunction.GetStartPoint(vsCMPart.vsCMPartBody); // is method decorated with Localizable(false) bool functionLocalizableFalse = (codeFunction as CodeElement).HasLocalizableFalseAttribute(); var list = parentCommand.LookupInCSharp(functionText, startPoint, parentNamespace, codeClassOrStruct, codeFunction.Name, null, isLocalizableFalse || functionLocalizableFalse); // add context to result items (surounding few lines of code) EditPoint2 editPoint = (EditPoint2)startPoint.CreateEditPoint(); foreach (AbstractResultItem item in list) { item.CodeModelSource = codeFunction; AddContextToItem(item, editPoint); } // read optional arguments initializers (just to show them - they cannot be moved) TextPoint headerStartPoint = null; try { headerStartPoint = codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader); } catch (Exception) { } if (headerStartPoint == null) { return; } string headerText = codeFunction.GetHeaderText(); // search method header var headerList = parentCommand.LookupInCSharp(headerText, headerStartPoint, parentNamespace, codeClassOrStruct, codeFunction.Name, null, isLocalizableFalse || functionLocalizableFalse); // add to list editPoint = (EditPoint2)startPoint.CreateEditPoint(); foreach (AbstractResultItem item in headerList) { item.IsConst = true; item.CodeModelSource = codeFunction; AddContextToItem(item, editPoint); } }