Beispiel #1
0
        /// <summary>
        /// Sends a message via the <seealso cref="Messages"/> event.
        /// </summary>
        /// <param name="e">Event arguments for compiler message.</param>
        public void OnMessage(CompilerMessageEventArgs e)
        {
            if (e.Message.Type == CompilerMessage.CompilerMessageType.LexerError ||
                e.Message.Type == CompilerMessage.CompilerMessageType.Error)
            {
                this.EncounteredError = true;
            }

            if (this.Messages != null)
            {
                this.Messages(this, e);
            }
        }
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;

            // Map the trigger point down to our buffer.
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(this.textBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }

            // Find the source file we're looking at.
            SourceFileData sourceFileData = SourceFileCompiler.Instance.FindSourceFileData(this.textBuffer);

            if (sourceFileData == null)
            {
                return;
            }

            // Find the line/position of the trigger...
            ITextSnapshotLine line = subjectTriggerPoint.Value.GetContainingLine();
            int column             = subjectTriggerPoint.Value.Position - line.Start;

            // See if there's an error/message that intersects the trigger...
            CompilerMessageEventArgs message = sourceFileData.Messages.FirstOrDefault(m =>
                                                                                      m.LineNumber - 1 == line.LineNumber &&
                                                                                      m.LinePosition - 1 <= column &&
                                                                                      m.LinePositionEnd > column);

            if (message == null)
            {
                return;
            }

            // If we found it, create the span and content!
            applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpanFromSwix(message);

            // For some reason, we sometimes get doubled (and more!) messages... we specifically check for this, just in case.
            if (quickInfoContent.Count > 0 || session.QuickInfoContent.Count > 0)
            {
                System.Diagnostics.Debug.Assert(false, "multiple quick info?");
                System.Diagnostics.Debugger.Break();
            }

            quickInfoContent.Add(message.Message.Message);
        }
Beispiel #3
0
        internal static ITrackingSpan CreateTrackingSpanFromSwix(this ITextSnapshot snapshot, CompilerMessageEventArgs message, SpanTrackingMode trackingMode = SpanTrackingMode.EdgeExclusive)
        {
            SnapshotSpan span = snapshot.CreateSpanFromSwix(message);

            return(snapshot.CreateTrackingSpan(span, trackingMode));
        }
Beispiel #4
0
 internal static SnapshotSpan CreateSpanFromSwix(this ITextSnapshot snapshot, CompilerMessageEventArgs message)
 {
     return(snapshot.CreateSpanFromSwix(message.LineNumber, message.LinePosition, message.LinePositionEnd));
 }