Exemple #1
0
        public override IEnumerable <MemberReference> FindReferences(ProjectDom dom, FilePath fileName, IEnumerable <INode> searchedMembers)
        {
            HashSet <int>        positions = new HashSet <int> ();
            var                  editor    = TextFileProvider.Instance.GetTextEditorData(fileName);
            FindMemberAstVisitor visitor   = new FindMemberAstVisitor(editor.Document);

            visitor.IncludeXmlDocumentation = IncludeDocumentation;
            visitor.Init(searchedMembers);
            if (!visitor.FileContainsMemberName())
            {
                yield break;
            }
            var doc = ProjectDomService.ParseFile(dom, fileName, () => editor.Text);

            if (doc == null || doc.CompilationUnit == null)
            {
                yield break;
            }
            var resolver = new NRefactoryResolver(dom, doc.CompilationUnit, ICSharpCode.NRefactory.SupportedLanguage.CSharp, editor, fileName);

            visitor.ParseFile(resolver);
            visitor.RunVisitor(resolver);
            foreach (var reference in visitor.FoundReferences)
            {
                if (positions.Contains(reference.Position))
                {
                    continue;
                }
                positions.Add(reference.Position);
                yield return(reference);
            }
            visitor.ClearParsers();
        }
Exemple #2
0
        public override void BuildChildNodes(ITreeBuilder treeBuilder,
                                             object dataObject)
        {
            PackageNode          packageNode = dataObject as PackageNode;
            PythonParsedDocument parsed      = ProjectDomService.ParseFile(null, packageNode.ProjectFile.Name) as PythonParsedDocument;

            if (parsed != null && parsed.Module != null)
            {
                foreach (PythonClass pyClass in parsed.Module.Classes)
                {
                    treeBuilder.AddChild(pyClass);
                }
                foreach (PythonAttribute pyAttr in parsed.Module.Attributes)
                {
                    treeBuilder.AddChild(pyAttr);
                }
                foreach (PythonFunction pyFunc in parsed.Module.Functions)
                {
                    treeBuilder.AddChild(pyFunc);
                }
            }
        }