Exemplo n.º 1
0
        private void InitBuffer(ITextBuffer buffer, int id = 0)
        {
            var bi = _services.GetBufferInfo(buffer);

            if (!bi.SetAnalysisEntryId(id))
            {
                Debug.Fail("Buffer is already initialized");
                return;
            }

            bi.OnChangedLowPriority += BufferChangedLowPriority;
            VsProjectAnalyzer.ConnectErrorList(bi);

            lock (this) {
                _bufferIdMapping[id] = bi;
            }

            ITextDocument doc;

            if (buffer.Properties.TryGetProperty(typeof(ITextDocument), out doc) && doc != _document)
            {
                if (_document != null)
                {
                    _document.EncodingChanged -= EncodingChanged;
                }
                _document = doc;
                if (_document != null)
                {
                    _document.EncodingChanged += EncodingChanged;
                }
            }
        }
Exemplo n.º 2
0
        internal void AddBuffer(ITextBuffer textBuffer)
        {
            lock (this) {
                EnsureMutableBuffers();

                _buffers.Add(textBuffer);

                InitBuffer(textBuffer, _buffers.Count - 1);

                _parser.ConnectErrorList(AnalysisEntry, textBuffer);
            }
        }
        internal void AddBuffer(ITextBuffer textBuffer)
        {
            lock (this) {
                EnsureMutableBuffers();

                _buffers.Add(textBuffer);

                InitBuffer(textBuffer);

                _parser.ConnectErrorList(_currentProjEntry, textBuffer);
            }
        }
Exemplo n.º 4
0
        internal void AddBuffer(ITextBuffer textBuffer)
        {
            int newId;
            var bi = _services.GetBufferInfo(textBuffer);

            var entry = bi.AnalysisEntry;

            if (entry == null)
            {
                throw new InvalidOperationException("buffer must have a project entry before parsing");
            }

            lock (this) {
                var existing = _buffers.FirstOrDefault(b => b.Buffer == bi);
                if (existing != null)
                {
                    existing.AddRef();
                    return;
                }

                _buffers = _buffers.Concat(Enumerable.Repeat(new PythonTextBufferInfoWithRefCount(bi), 1)).ToArray();
                newId    = _buffers.Length - 1;

                if (!bi.SetAnalysisBufferId(newId))
                {
                    // Raced, and now the buffer belongs somewhere else.
                    Debug.Fail("Race condition adding the buffer to a parser");
                    _buffers[newId] = null;
                    return;
                }
                _bufferIdMapping[newId] = bi;
            }

            if (bi.ParseImmediately)
            {
                // Any buffer requesting immediate parsing enables it for
                // the whole file.
                _parseImmediately = true;
            }

            bi.AddSink(this, this);
            VsProjectAnalyzer.ConnectErrorList(bi);
        }
Exemplo n.º 5
0
        internal void AddBuffer(ITextBuffer textBuffer)
        {
            int newId;
            var bi = _services.GetBufferInfo(textBuffer);

            var entry = bi.AnalysisEntry;

            if (entry == null)
            {
                throw new InvalidOperationException("buffer must have a project entry before parsing");
            }

            lock (this) {
                if (DefaultBufferInfo == null)
                {
                    DefaultBufferInfo = bi;
                }

                var existing = _buffers.FirstOrDefault(b => b.Buffer == bi);
                if (existing != null)
                {
                    existing.AddRef();
                    return;
                }

                _buffers = _buffers.Concat(Enumerable.Repeat(new PythonTextBufferInfoWithRefCount(bi), 1)).ToArray();
                newId    = _buffers.Length - 1;
            }

            if (bi.ParseImmediately)
            {
                // Any buffer requesting immediate parsing enables it for
                // the whole file.
                _parseImmediately = true;
            }

            bi.AddSink(this, this);
            VsProjectAnalyzer.ConnectErrorList(bi);
        }