Пример #1
0
        public IProjectEntry AnalyzeTextView(ITextView textView)
        {
            // Get an AnalysisItem for this file, creating one if necessary
            var res = textView.TextBuffer.Properties.GetOrCreateSingletonProperty <IProjectEntry>(() => {
                string path = textView.GetFilePath();
                if (path == null)
                {
                    return(null);
                }

                IProjectEntry entry;
                if (!_projectFiles.TryGetValue(path, out entry))
                {
                    var modName = PathToModuleName(path);

                    var initialSnapshot = textView.TextBuffer.CurrentSnapshot;

                    if (textView.TextBuffer.ContentType.IsOfType(PythonCoreConstants.ContentType))
                    {
                        entry = _analysisState.AddModule(
                            modName,
                            textView.GetFilePath(),
                            new SnapshotCookie(initialSnapshot)
                            );
                    }
                    else if (textView.TextBuffer.ContentType.IsOfType("xaml"))
                    {
                        entry = _analysisState.AddXamlFile(path);
                    }
                    else
                    {
                        return(null);
                    }

                    _projectFiles[path] = entry;

                    if (ImplicitProject)
                    {
                        AddImplicitFiles(Path.GetDirectoryName(Path.GetFullPath(path)));
                    }
                }

                return(entry);
            });

            // kick off initial processing on the ITextWindow
            _queue.EnqueueBuffer(textView);

            return(res);
        }