IEnumerable <MemberReference> FindInnerReferences(IProgressMonitor monitor, string nspace, FilePath filePath) { var document = IdeApp.Workbench.GetDocument(filePath.CanonicalPath); if (document != null) { ITextBuffer editor = document.GetContent <ITextBuffer> (); if (editor.Text.Contains(nspace + ".")) { var position = -1; while ((position = editor.Text.IndexOf(nspace + ".", position + 1)) > -1) { if (monitor != null && monitor.IsCancelRequested) { break; } int line, column; editor.GetLineColumnFromPosition(position + nspace.Length + 1, out line, out column); editor.CursorPosition = position + nspace.Length + 1; ResolveResult typeResult; INode item; CurrentRefactoryOperationsHandler.GetItem(document.Dom, document, editor, out typeResult, out item); if (typeResult != null && !(typeResult is MethodResolveResult) && typeResult.ResolvedType != null) { yield return(new MemberReference(null, filePath, position, line, column, nspace, nspace)); } } } } }
void HandleButtonReleaseEvent(object o, ButtonReleaseEventArgs args) { var doc = IdeApp.Workbench.ActiveDocument; if (args.Event.Button != 1 || !IsCtrlPush(args.Event.State) || doc == null) { return; } ResolveResult resolveResult; var item = CurrentRefactoryOperationsHandler.GetItem(doc, out resolveResult); if (item == null) { return; } if (item is INamedElement) { IdeApp.ProjectOperations.JumpToDeclaration((INamedElement)item); } else if (item is IVariable) { IdeApp.ProjectOperations.JumpToDeclaration((IVariable)item); } }
protected ResolveResult GetResolvedResult() { Document doc = GetActiveDocument(); if (doc == null || doc.FileName == FilePath.Null || IdeApp.ProjectOperations.CurrentSelectedSolution == null) { return(null); } ITextBuffer data = GetData(doc); if (data == null) { return(null); } int line, column; data.GetLineColumnFromPosition(data.CursorPosition, out line, out column); ProjectDom ctx = doc.Dom; ResolveResult resolveResult; INode item; CurrentRefactoryOperationsHandler.GetItem(ctx, doc, data, out resolveResult, out item); return(resolveResult); }
protected override void Run() { //1. identify if the member belongs to an interface var entity = MemberExtensionsHelper.Instance.GetEntityAtCaret(); //2. find classes that implement the interface //3. go to member in that class Document activeDocument = IdeApp.Workbench.ActiveDocument; if (activeDocument != null && !(activeDocument.FileName == FilePath.Null)) { ResolveResult resolveResult; object item = CurrentRefactoryOperationsHandler.GetItem(activeDocument, out resolveResult); var resolvedEntity = item as AbstractResolvedEntity; if (resolvedEntity != null && resolvedEntity.DeclaringType.Kind == TypeKind.Interface) { NavigateToAbstractMember(resolvedEntity); } else if (IsRequestingCycleMostRecentMemberNavigation()) { CycleResults(); } else if (ViewModelHelper.Instance.IsActiveFileXamlFile) { _mostRecentEntity = null; NavigateToXamlValue(resolvedEntity); } else { _mostRecentEntity = null; NavigateToNonAbstractMember(item); } } }
//FIXME: why is this invalid on the parseddocuments loaded when the doc is first loaded? //maybe the item's type's SourceProject is null? public IEnumerable <IAnalysisFixAction> GetFixes(MonoDevelop.Ide.Gui.Document doc, object fix) { var renameFix = (RenameMemberFix)fix; var refactoring = new RenameRefactoring(); var options = new RefactoringOptions(doc) { SelectedItem = renameFix.Item, }; if (renameFix.Item == null) { ResolveResult resolveResult; options.SelectedItem = CurrentRefactoryOperationsHandler.GetItem(options.Document, out resolveResult); } if (!refactoring.IsValid(options)) { yield break; } var prop = new RenameRefactoring.RenameProperties() { NewName = renameFix.NewName, }; if (string.IsNullOrEmpty(renameFix.NewName)) { yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}'...", renameFix.OldName), Refactoring = refactoring, Options = options, Properties = prop, Preview = false, }); yield break; } yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}' to '{1}'", renameFix.OldName, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = false, }); yield return(new RenameFixAction() { Label = GettextCatalog.GetString("Rename '{0}' to '{1}' with preview", renameFix.OldName, renameFix.NewName), Refactoring = refactoring, Options = options, Properties = prop, Preview = true, }); }
protected override void Run(object data) { Document doc = IdeApp.Workbench.ActiveDocument; if (doc == null || doc.FileName == FilePath.Null || IdeApp.ProjectOperations.CurrentSelectedSolution == null) { return; } ITextBuffer editor = doc.GetContent <ITextBuffer> (); if (editor == null) { return; } int line, column; editor.GetLineColumnFromPosition(editor.CursorPosition, out line, out column); ProjectDom ctx = doc.Dom; ResolveResult resolveResult; INode item; CurrentRefactoryOperationsHandler.GetItem(ctx, doc, editor, out resolveResult, out item); item = item ?? (resolveResult != null ? (resolveResult.CallingMember != null ? resolveResult.CallingMember.DeclaringType : resolveResult.CallingType) : null); if (resolveResult == null) { return; } if (item == null) { item = (INode)resolveResult.ResolvedType.Type; } //NOTE: for generate class- if resolveResult.ResolvedType.Type == null && resolveResult.ResolvedExpression != null // continue with Dodo... IType cls = item as IType; if (cls != null && cls.BaseTypes != null) { foreach (IReturnType bc in cls.BaseTypes) { IType bcls = ctx.GetType(bc); if (bcls != null && bcls.ClassType != ClassType.Interface && !bcls.Location.IsEmpty) { IdeApp.Workbench.OpenDocument(bcls.CompilationUnit.FileName, bcls.Location.Line, bcls.Location.Column, OpenDocumentOptions.Default); return; } } return; } IMethod method = item as IMethod; if (method != null) { foreach (IReturnType bc in method.DeclaringType.BaseTypes) { IType bcls = ctx.GetType(bc); if (bcls != null && bcls.ClassType != ClassType.Interface && !bcls.Location.IsEmpty) { IMethod baseMethod = null; foreach (IMethod m in bcls.Methods) { if (m.Name == method.Name && m.Parameters.Count == m.Parameters.Count) { baseMethod = m; break; } } if (baseMethod != null) { IdeApp.Workbench.OpenDocument(bcls.CompilationUnit.FileName, baseMethod.Location.Line, baseMethod.Location.Column, OpenDocumentOptions.Default); } return; } } return; } }