public static void JumpToDeclaration(MonoDevelop.Ide.Gui.Document doc, RefactoringSymbolInfo info) { if (info.Symbol != null) { RefactoringService.RoslynJumpToDeclaration(info.Symbol, doc.Project); } if (info.CandidateSymbols.Length > 0) { RefactoringService.RoslynJumpToDeclaration(info.CandidateSymbols[0], doc.Project); } }
public override void JumpToSignalHandler(Stetic.Signal signal) { var cls = codeBinder.GetClass(); var met = cls.GetMembers(signal.Handler).OfType <IMethodSymbol> ().FirstOrDefault(); if (met != null) { ShowPage(1); RefactoringService.RoslynJumpToDeclaration(met).Ignore(); } }
public static void GotoBase(MonoDevelop.Ide.Gui.Document doc, ISymbol symbol) { if (doc == null) { throw new ArgumentNullException("doc"); } if (symbol == null) { throw new ArgumentNullException("symbol"); } switch (symbol.Kind) { case SymbolKind.NamedType: RefactoringService.RoslynJumpToDeclaration(((ITypeSymbol)symbol).BaseType, doc.Project); break; case SymbolKind.Property: var property = (IPropertySymbol)symbol; if (property.OverriddenProperty != null) { RefactoringService.RoslynJumpToDeclaration(property.OverriddenProperty, doc.Project); } else { RefactoringService.RoslynJumpToDeclaration(property.ExplicitInterfaceImplementations.First(), doc.Project); } break; case SymbolKind.Event: var evt = (IEventSymbol)symbol; if (evt.OverriddenEvent != null) { RefactoringService.RoslynJumpToDeclaration(evt.OverriddenEvent, doc.Project); } else { RefactoringService.RoslynJumpToDeclaration(evt.ExplicitInterfaceImplementations.First(), doc.Project); } break; case SymbolKind.Method: var method = (IMethodSymbol)symbol; if (method.OverriddenMethod != null) { RefactoringService.RoslynJumpToDeclaration(method.OverriddenMethod, doc.Project); } else { RefactoringService.RoslynJumpToDeclaration(method.ExplicitInterfaceImplementations.First(), doc.Project); } break; } }
public override async void Activate() { var token = default(CancellationToken); var doc = GetDocument(token); if (doc != null) { var symbol = await type.GetSymbolAsync(doc, token); var project = TypeSystemService.GetMonoProject(doc.Id); await RefactoringService.RoslynJumpToDeclaration(symbol, project); } }
public override void VisitIdentifierName(IdentifierNameSyntax node) { var info = model.GetSymbolInfo(node); if (IsNavigatable(info)) { result.Add(new NavigationSegment(node.Span.Start, node.Span.Length, delegate { GLib.Timeout.Add(50, delegate { RefactoringService.RoslynJumpToDeclaration(info.Symbol, documentContext.Project); return(false); }); })); } }
protected override async void Run() { var doc = IdeApp.Workbench.ActiveDocument; var name = doc.FileName.ParentDirectory.FileName; var controller = await FindController(doc.Project, name); if (controller != null) { await RefactoringService.RoslynJumpToDeclaration(controller, doc.Project); } else { MessageService.ShowError("Matching controller cannot be found."); } }
static Task GotoBaseInternal(MonoDevelop.Ide.Gui.Document doc, ISymbol symbol) { switch (symbol.Kind) { case SymbolKind.NamedType: return(RefactoringService.RoslynJumpToDeclaration(((ITypeSymbol)symbol).BaseType, doc.Owner)); case SymbolKind.Property: var property = (IPropertySymbol)symbol; if (property.OverriddenProperty != null) { return(RefactoringService.RoslynJumpToDeclaration(property.OverriddenProperty, doc.Owner)); } else { return(RefactoringService.RoslynJumpToDeclaration(property.ExplicitInterfaceImplementations.First(), doc.Owner)); } case SymbolKind.Event: var evt = (IEventSymbol)symbol; if (evt.OverriddenEvent != null) { return(RefactoringService.RoslynJumpToDeclaration(evt.OverriddenEvent, doc.Owner)); } else { return(RefactoringService.RoslynJumpToDeclaration(evt.ExplicitInterfaceImplementations.First(), doc.Owner)); } case SymbolKind.Method: var method = (IMethodSymbol)symbol; if (method.OverriddenMethod != null) { return(RefactoringService.RoslynJumpToDeclaration(method.OverriddenMethod, doc.Owner)); } else { return(RefactoringService.RoslynJumpToDeclaration(method.ExplicitInterfaceImplementations.First(), doc.Owner)); } default: // CanGotoBase should prevent this from happening. throw new ArgumentException(string.Format("Invalid symbol.Kind {0}", symbol.Kind)); } }
static CSharpFeaturesTextEditorExtension() { GoToDefinitionService.TryNavigateToSymbol = delegate(ISymbol symbol, Microsoft.CodeAnalysis.Project project, bool usePreviewTab) { RefactoringService.RoslynJumpToDeclaration(symbol, TypeSystemService.GetMonoProject(project)); return(true); }; GoToDefinitionService.TryNavigateToSpan = delegate(Workspace workspace, DocumentId documentId, Microsoft.CodeAnalysis.Text.TextSpan textSpan, bool usePreviewTab) { var project = workspace.CurrentSolution.GetProject(documentId.ProjectId); if (project == null) { return(false); } var fileName = project.GetDocument(documentId).FilePath; var offset = textSpan.Start; string projectedName; int projectedOffset; if (TypeSystemService.GetWorkspace(TypeSystemService.GetMonoProject(project).ParentSolution).TryGetOriginalFileFromProjection(fileName, offset, out projectedName, out projectedOffset)) { fileName = projectedName; offset = projectedOffset; } IdeApp.Workbench.OpenDocument(new FileOpenInformation(fileName, TypeSystemService.GetMonoProject(project)) { Offset = offset }); return(true); }; GoToDefinitionService.DisplayMultiple = delegate(IEnumerable <Tuple <Solution, ISymbol, Location> > list) { using (var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true, true)) { foreach (var part in list) { if (monitor.CancellationToken.IsCancellationRequested) { return; } monitor.ReportResult(GotoDeclarationHandler.GetJumpTypePartSearchResult(part.Item2, part.Item3)); } } }; }