protected override void OnNewFile(LibraryTask task)
        {
            if (IsNonMemberItem(task.ModuleID.Hierarchy, task.ModuleID.ItemID))
            {
                return;
            }

            var analyzer = task.ModuleID.Hierarchy
                           .GetProject()
                           .GetPythonProject()
                           .GetAnalyzer();

            AnalysisEntry item;

            if (analyzer.GetAnalysisEntryFromPath(task.FileName) == null)
            {
                analyzer.AnalyzeFileAsync(task.FileName).ContinueWith(x => {
                    item = x.Result;

                    if (item != null)
                    {
                        // We subscribe to OnNewAnalysis here instead of OnNewParseTree so that
                        // in the future we can use the analysis to include type information in the
                        // object browser (for example we could include base type information with
                        // links elsewhere in the object browser).
                        item.AnalysisComplete += (sender, args) => {
                            _package.GetUIThread().InvokeAsync(() => FileParsed(task))
                            .HandleAllExceptions(_package, GetType())
                            .DoNotWait();
                        };
                    }
                });
            }
        }
Beispiel #2
0
        protected override void OnNewFile(LibraryTask task)
        {
            if (IsNonMemberItem(task.ModuleID.Hierarchy, task.ModuleID.ItemID))
            {
                return;
            }
            IPythonProjectEntry item;

            if (task.TextBuffer == null || !task.TextBuffer.TryGetPythonProjectEntry(out item))
            {
                item = task.ModuleID.Hierarchy
                       .GetProject()
                       .GetPythonProject()
                       .GetAnalyzer()
                       .AnalyzeFile(task.FileName) as IPythonProjectEntry;
            }

            if (item != null)
            {
                // We subscribe to OnNewAnalysis here instead of OnNewParseTree so that
                // in the future we can use the analysis to include type information in the
                // object browser (for example we could include base type information with
                // links elsewhere in the object browser).
                item.OnNewAnalysis += (sender, args) => {
                    _package.GetUIThread().InvokeAsync(() => FileParsed(task, new AstScopeNode(item.Tree, item)))
                    .HandleAllExceptions(_package, GetType())
                    .DoNotWait();
                };
            }
        }