protected string GetContext() { try { string context = "\n\n\nError context:"; context += "\nSolution: " + VisualStudio.GetSolutionName(); var codeFile = VisualStudio.GetCurrentCodeFile(); if (codeFile != null) { context += "\nCurrent file: " + codeFile.FilePath; context += "\nLineNumber: " + VisualStudio.GetCurrentLine(); context += "\nCursor position: " + VisualStudio.GetCursorPositionInLine(); } else { context += "\nCurrent file: <none>"; } context += "\n\n"; return(context); } catch (Exception) { return("<exception during GetContext()>"); } }
public void ShowFileMembers() { try { var currentFile = VisualStudio.GetCurrentCodeFile(); if (currentFile == null) { return; } var ast = SyntaxTreeMaintainer.GetSyntaxTree(currentFile); dialog = CreateListFindControl(); dialog.DataSource = ast.GetAllMembers().Cast <object>().ToList(); dialog.AlwaysShowList = true; dialog.SearchHintText = "Search current file..."; dialog.MaxResults = 75; // (scrollable) dialog.OnGetIconForItem = FortranIconProvider.GetIconForMember; dialog.DataMember = "Name"; dialog.ItemChosen += (s, e) => { var chosenMember = (IMember)s; VisualStudio.Goto(currentFile, chosenMember.Location.Line, chosenMember.Location.Offset); }; dialog.Show(); } catch (Exception e) { Log.Error("ShowFileMembers failed", e, GetContext()); } }
protected IMember GetCurrent <T>() where T : class, IMember { var current = VisualStudio.GetCurrentCodeFile(); if (current != null) { var ast = SyntaxTreeMaintainer.GetSyntaxTree(current); var allMethods = ast.GetAllMembers().OfType <T>(); var lineNumber = VisualStudio.GetCurrentLineNumber(); return(FortranParseHelper.GetEnclosingMember(allMethods.OfType <IMember>(), lineNumber)); } return(null); }