Ejemplo n.º 1
0
        /// <summary>
        /// Calls the Dafny parser/resolver/type checker on the contents of the buffer, updates the Error List accordingly.
        /// </summary>
        public void ResolveBuffer(object sender, EventArgs args)
        {
            ITextSnapshot snapshot = _buffer.CurrentSnapshot;

            if (snapshot == Snapshot)
            {
                return; // we've already done this snapshot
            }
            string            filename = _document != null ? _document.FilePath : "<program>";
            var               driver   = new DafnyDriver(_buffer, filename);
            List <DafnyError> newErrors;

            Dafny.Program program;
            try
            {
                program            = driver.ProcessResolution(RunResolver);
                MostRecentResolver = driver.MostRecentResolver;
                newErrors          = driver.Errors;
            }
            catch (Exception e)
            {
                newErrors = new List <DafnyError> {
                    new DafnyError(filename, 0, 0, ErrorCategory.InternalError, "internal Dafny error: " + e.Message, snapshot, false)
                };
                program = null;
            }

            lock (this)
            {
                Snapshot = snapshot;
                Program  = program;
            }

            if (program != null && _document != null)
            {
                ResolverTaggers[_document.TextBuffer] = this;
            }
            else if (_document != null)
            {
                ResolverTaggers.Remove(_document.TextBuffer);
            }

            _resolutionErrors      = newErrors;
            FatalVerificationError = null;

            UpdateErrorList(snapshot);
        }