Esempio n. 1
0
        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());
            }
        }
Esempio n. 2
0
        public void FindMembers()
        {
            try
            {
                var asts = SyntaxTreeMaintainer.GetSyntaxTrees();
                dialog                  = CreateListFindControl();
                dialog.DataSource       = asts.SelectMany(a => a.GetAllMembers()).Cast <object>().ToList();
                dialog.AlwaysShowList   = false;
                dialog.MaxResults       = 15;
                dialog.SearchHintText   = "Search solution...";
                dialog.OnGetIconForItem = FortranIconProvider.GetIconForMember;
                dialog.OnGetHintForItem = o => ((IMember)o).GetScopeDescription();
                dialog.DataMember       = "Name";
                dialog.ItemChosen      += (s, e) =>
                {
                    var chosenMember = (IMember)s;
                    VisualStudio.Goto(chosenMember.Root.CodeFile, chosenMember.Location.Line, chosenMember.Location.Offset);
                };

                dialog.Show();
            }
            catch (Exception e)
            {
                Log.Error("FindMembers failed", e, GetContext());
            }
        }
        private void BrowseToVariable(string elementName)
        {
            //find variables
            var elementsInScope = FortranSyntaxTreeModel.GetElementsAvailableInScope(
                SyntaxTreeMaintainer.GetSyntaxTrees(),
                GetCurrentMember());

            var firstMatch = elementsInScope.OfType <Variable>().FirstOrDefault(el => Equals(elementName, el.Name));

            if (firstMatch == null)
            {
                // second chance: try items in types:
                var typesInScope = elementsInScope.OfType <Fortran.Elements.Type>().ToList();

                foreach (var type in typesInScope)
                {
                    new FortranDeclarationParser().ParseDeclarationsAndUses(type);
                }

                firstMatch = elementsInScope.OfType <Fortran.Elements.Type>()
                             .SelectMany(t => t.LocalVariables)
                             .FirstOrDefault(el => Equals(elementName, el.Name));

                if (firstMatch == null)
                {
                    return;
                }
            }

            VisualStudio.Goto(firstMatch.Member.Root.CodeFile, firstMatch.Location.Line,
                              firstMatch.Location.Offset + 1);
        }
Esempio n. 4
0
 public void FindFiles()
 {
     try
     {
         var asts = SyntaxTreeMaintainer.GetSyntaxTrees();
         dialog                  = CreateListFindControl();
         dialog.DataSource       = asts.Select(a => a.CodeFile).Cast <object>().ToList();
         dialog.AlwaysShowList   = false;
         dialog.MaxResults       = 15;
         dialog.SearchHintText   = "Find files...";
         dialog.OnGetIconForItem = FortranIconProvider.GetIconForFile;
         dialog.OnGetHintForItem = o => ((CodeFile)o).ProjectName;
         dialog.DataMember       = "FileName";
         dialog.ItemChosen      += (s, e) => VisualStudio.Goto(s as CodeFile, 1, 1);
         dialog.Show();
     }
     catch (Exception e)
     {
         Log.Error("FindFiles failed", e, GetContext());
     }
 }
        private void BrowseToCore(IEnumerable <SearchResult> _matches)
        {
            var matches = _matches.ToList();

            if (matches.Count == 1)
            {
                var match = matches.First();

                if (match.Member is Interface)
                {
                    BrowseToCore(FortranSyntaxTreeModel.FindInterfaceReferences(match.Member as Interface, match.SyntaxTree));
                }
                else
                {
                    VisualStudio.Goto(match.SyntaxTree.CodeFile, match.Member.Location.Line,
                                      match.Member.Location.Offset);
                }
            }
            else if (matches.Count > 1)
            {
                //let user make selection & then do recursive call
                dialog                  = CreateListFindControl();
                dialog.DataSource       = matches.Select(m => m.Member).OfType <object>().ToList();
                dialog.AlwaysShowList   = true;
                dialog.HideSearchDialog = true;
                dialog.MaxResults       = 25;
                dialog.OnGetIconForItem = FortranIconProvider.GetIconForMember;
                dialog.OnGetHintForItem = o => ((IMember)o).GetScopeDescription();
                dialog.DataMember       = "Name";
                dialog.ItemChosen      += (s, e) =>
                {
                    var chosenMember = s as IMember;
                    var match        = matches.First(m => m.Member == chosenMember);
                    BrowseToCore(new[] { match });     //recursive: perhaps user chose interface
                };
                dialog.Show();
            }
        }
Esempio n. 6
0
 private void GotoUsage(UsageResult result)
 {
     VisualStudio.Goto(result.SyntaxTree.CodeFile, result.Location.Line, result.Location.Offset + 1);
 }