private void StartTargetPicker(TextDocument textDocument) { TextView activeView = textDocument.ActiveView; if (activeView == null) { if (textDocument.FirstView != null) { textDocument.Activate(); activeView = textDocument.FirstView; activeView.Activate(); } } // IElement -- Lightweight elements for representing source code, including referenced assemblies. // LanguageElement -- Heavier, bigger elements // We can convert from lightweight to heavy using LanguageElementRestorer.ConvertToLanguageElement(); Class typeElement = _TypeElement.GetLanguageElement() as Class; if (typeElement == null) { // We just opened the file -- we need to get a new resolve on the _TypeElement. _TypeElement = _ObjectCreationExpression.ObjectType.GetTypeDeclaration(); typeElement = _TypeElement.GetLanguageElement() as Class; if (typeElement == null) return; } targetPicker1.Start(activeView, typeElement.FirstChild, InsertCode.UsePicker, null); }