Пример #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);
        }
Пример #2
0
        public AnalysisItem AnalyzeTextView(ITextView textView)
        {
            // Get an AnalysisItem for this file, creating one if necessary
            var res = textView.TextBuffer.Properties.GetOrCreateSingletonProperty <AnalysisItem>(() => {
                string path = textView.GetFilePath();
                AnalysisItem item;
                if (path != null && _projectFiles.TryGetValue(path, out item))
                {
                    return(item);
                }

                var initialSnapshot = textView.TextBuffer.CurrentSnapshot;
                var entry           = new ProjectEntry(
                    SnapshotTextContentProvider.Make(_engine, initialSnapshot, path),
                    textView.GetFilePath(),
                    new SnapshotCookie(initialSnapshot)
                    );

                item = new AnalysisItem(entry);
                if (path != null)
                {
                    _projectFiles[path] = item;

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

                return(item);
            });

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

            return(res);
        }