Esempio n. 1
0
        /// <summary>
        /// Semantically parses the specified <see cref="TextRange"/> of the <see cref="Document"/>.
        /// </summary>
        /// <param name="document">The <see cref="Document"/> to examine.</param>
        /// <param name="parseTextRange">A <see cref="TextRange"/> indicating the offset range to parse.</param>
        /// <param name="flags">A <see cref="SemanticParseFlags"/> that indicates semantic parse flags.</param>
        public override void PerformSemanticParse(Document document, TextRange parseTextRange, SemanticParseFlags flags)
        {
            if (null == document.Filename)
            {
                throw new Exception("Document Filename must be set");
            }

            string source = document.GetCoreTextBuffer().ToString();
            string filename = System.IO.Path.GetFullPath(document.Filename); // Normalise the path;

            // Remove any pending SemanticParse tasks for this document
            object key = new KeyValuePair<Document, object>(document, m_performSemanticParseKey);
            m_plugin.TaskQueue.RemoveTasks(key);

            // Queue a SemanticParse task for this document
            m_plugin.TaskQueue.AddTask(() =>
            {
                var textBufferReader = new StringTextBufferReader(source, 0, 0);
                var cu = MergableLexicalParserManager.PerformSemanticParse(this, textBufferReader, filename) as CompilationUnit;
                if (null != cu)
                {
                    cu.SourceKey = filename;
                    cu.Source = source;
                    m_plugin.Database.ProcessSynchronous(cu);
                    document.SemanticParseData = cu;
                }
            }, TaskQueue.Thread.Worker, key);

        }