Beispiel #1
0
        public void MakeTextMarker(IVsTextLines buffer)
        {
            Trace.Assert(TextLineMarker == null);
            if (TextLineMarker != null)
            {
                DisposeTextLineMarker();
            }

            var span = Utils.SpanFromLocation(CompilerMessage.Location);
            int markerType;

            switch (CompilerMessage.Kind)
            {
            case MessageKind.Error:   markerType = (int)MARKERTYPE.MARKER_CODESENSE_ERROR;  break;

            case MessageKind.Warning: markerType = (int)MARKERTYPE.MARKER_COMPILE_ERROR;    break;

            default:                  markerType = (int)MARKERTYPE2.MARKER_WARNING;         break;
            }

            // create marker so task item navigation works even after file is edited.
            IVsTextLineMarker[] marker = new IVsTextLineMarker[1];
            // bugbug: the following comment in the method CEnumMarkers::Initialize() of
            // ~\env\msenv\textmgr\markers.cpp means that tool tips on empty spans
            // don't work:
            //      "VS7 #23719/#15312 [CFlaat]: exclude adjacent markers when the target span is non-empty"
            // So I wonder if we should debug assert on that or try and modify the span
            // in some way to make it non-empty...
            ErrorHandler.ThrowOnFailure(buffer.CreateLineMarker(markerType, span.iStartLine, span.iStartIndex,
                                                                span.iEndLine, span.iEndIndex, this, marker));

            _textLineMarker = marker[0];
        }
Beispiel #2
0
        private static void AddMarker(DocumentInfo documentInfo, IVsTextLines textLines, Clone clone)
        {
            // The line marker should span the text range from the first character
            // in the first line to the last character in the last line. So we need
            // to retrieve the length of the last line. If that is not possible
            // we simply ignore the clone.
            int firstLine = clone.StartLine;
            int lastLine  = clone.StartLine + clone.LineCount - 1;
            int lastLineLength;

            if (ErrorHandler.Failed(textLines.GetLengthOfLine(lastLine, out lastLineLength)))
            {
                return;
            }

            // Finally create the clone marker and store it in our dictionary.
            // Ignore any errors.
            IVsTextLineMarker[]       markers         = new IVsTextLineMarker[1];
            TextMarkerClientEventSink clientEventSink = new TextMarkerClientEventSink();
            int hr = textLines.CreateLineMarker(CloneBackgroundMarkerType.Id,
                                                firstLine, 0,
                                                lastLine, lastLineLength - 1,
                                                clientEventSink, markers);

            if (ErrorHandler.Succeeded(hr))
            {
                clientEventSink.Marker = markers[0];
                documentInfo.MarkersToCloneClasses.Add(markers[0], clone.CloneClass);
            }
        }
Beispiel #3
0
        private void AddMarkers()
        {
            int curLine = -1, columnDelta = 0;

            foreach (LocationPreviewItem item in Items)
            {
                if (item.CheckState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked)
                {
                    if (item.Line != curLine)
                    {
                        columnDelta = 0;
                    }
                    curLine = item.Line;

                    IVsTextLineMarker[] marker = new IVsTextLineMarker[1];

                    ErrorHandler.ThrowOnFailure(
                        _buffer.CreateLineMarker(
                            (int)MARKERTYPE2.MARKER_REFACTORING_FIELD,
                            item.Line - 1,
                            item.Column - 1 + columnDelta,
                            item.Line - 1,
                            item.Column - 1 + Engine.Request.Name.Length + columnDelta,
                            null,
                            marker
                            )
                        );

                    columnDelta += Engine.Request.Name.Length - Engine.OriginalName.Length;
                    _markers.Add(marker[0]);
                }
            }
        }
Beispiel #4
0
 public void Release()
 {
     // Called from "OnDelete"
     // task list makes sure it doesn't show up
     //  and we remove it later when an enumeration is asked.
     isDeleted = true;
     if (marker != null)
     {
         marker.Invalidate();
         marker = null;
     }
     if (commands != null)
     {
         commands.Dispose();
         commands = null;
     }
     userContext = null;
     taskManager = null;
     if (location != null)
     {
         location.Dispose();
         location = null;
     }
     if (persistLoc != null)
     {
         persistLoc.Dispose();
         persistLoc = null;
     }
     if (initLoc != null)
     {
         initLoc.Dispose();
         initLoc = null;
     }
 }
        public static Result <TextSpan> GetCurrentSpan(this IVsTextLineMarker marker)
        {
            var array   = new TextSpan[1];
            var hresult = marker.GetCurrentSpan(array);

            return(Result.CreateSuccessOrError(array[0], hresult));
        }
        /// <summary>
        /// Expands the read only region to the end of the current buffer
        /// </summary>
        private void ExtendReadOnlyRegion()
        {
            // Get the position of the last element in the buffer
            int lastLine;
            int lastColumn;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                textLines.GetLastLineIndex(out lastLine, out lastColumn));
            // Check if the text marker for the read-only region was created.
            if (null == lineMarker)
            {
                // No text marker, so we have to create it.
                IVsTextLineMarker[] markers = new IVsTextLineMarker[1];
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    textLines.CreateLineMarker(
                        (int)MARKERTYPE.MARKER_READONLY,      // Type of marker.
                        0, 0,                                 // Position of the beginning of the marker.
                        lastLine, lastColumn,                 // Position of the last char in the marker.
                        null,                                 // Object implementing the text marker client.
                        markers));                            // Output marker.
                lineMarker = markers[0];
                // Get the behavior of the marker
                uint behavior;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    lineMarker.GetBehavior(out behavior));
                // Add the track left behavior.
                behavior |= (uint)MARKERBEHAVIORFLAGS.MB_LEFTEDGE_LEFTTRACK;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    lineMarker.SetBehavior(behavior));
            }
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                lineMarker.ResetSpan(0, 0, lastLine, lastColumn));
        }
        public bool IsExternalEditMarker(IVsTextLineMarker marker)
        {
            var result = marker.GetMarkerType();
            if (result.IsError)
            {
                return false;
            }

            // Predefined markers aren't a concern
            var value = (int)result.Value;
            if (value <= (int)MARKERTYPE.DEF_MARKER_COUNT)
            {
                return false;
            }

            switch ((int)result.Value)
            {
                case 15:
                case 16:
                case 26:
                    // Details
                    //  15: Snippet marker for inactive span
                    //  16: Snippet marker for active span
                    //  26: Tracks comment insertion for a snippet don' for cursor placement
                    return true;
                case 25:
                    // Kind currently unknown.
                    // Used at least for brace matching
                    return false;
                default:
                    return false;
            }
        }
        public static Result <MARKERTYPE> GetMarkerType(this IVsTextLineMarker marker)
        {
            int type;
            var hresult = marker.GetType(out type);

            return(Result.CreateSuccessOrError((MARKERTYPE)type, hresult));
        }
Beispiel #9
0
        /// <summary>
        /// Logic to create the TextLineMarker associated with this task
        /// To prevent dangling markers, we'll defer the creation to when the task is added to the task list
        /// </summary>
        public void CreateTextLineMarker()
        {
            var targetSpan = this.span;

            if (this.textLineMarker != null)
            {
                TextSpan[] tp = new TextSpan[1];
                this.textLineMarker.GetCurrentSpan(tp);
                targetSpan = tp[0];
            }
            if (this.buffer != null)
            {
                if (markerType != MARKERTYPE.MARKER_OTHER_ERROR)
                {
                    // create marker so task item navigation works even after file is edited.
                    IVsTextLineMarker[] marker = new IVsTextLineMarker[1];
                    // bugbug: the following comment in the method CEnumMarkers::Initialize() of
                    // ~\env\msenv\textmgr\markers.cpp means that tool tips on empty spans
                    // don't work:
                    //      "VS7 #23719/#15312 [CFlaat]: exclude adjacent markers when the target span is non-empty"
                    // So I wonder if we should debug assert on that or try and modify the span
                    // in some way to make it non-empty...
                    NativeMethods.ThrowOnFailure(buffer.CreateLineMarker((int)markerType, targetSpan.iStartLine, targetSpan.iStartIndex, targetSpan.iEndLine, targetSpan.iEndIndex, this, marker));
                    this.textLineMarker = marker[0];
                    this.markerValid    = true;
                }
            }
        }
Beispiel #10
0
 public virtual void OnDeleteTask()
 {
     if (textLineMarker != null)
     {
         textLineMarker.Invalidate();
     }
     textLineMarker = null;
 }
Beispiel #11
0
 public void MarkerInvalidated()
 {
     if (marker != null)
     {
         marker.UnadviseClient();
         marker = null;
     }
 }
Beispiel #12
0
 public void DisposeTextLineMarker()
 {
     if (TextLineMarker != null)
     {
         TextLineMarker.UnadviseClient();
         _textLineMarker = null;
     }
 }
Beispiel #13
0
 public void Dispose()
 {
     if (marker != null)
     {
         marker.Invalidate();
         marker = null;
     }
 }
Beispiel #14
0
 public virtual int OnDeleteTask()
 {
     if (textLineMarker != null)
     {
         textLineMarker.Invalidate();
     }
     textLineMarker = null;
     return(0);
 }
Beispiel #15
0
        public static IVsTextLineMarker CreateMarker(IVsTextLines textLines, TextSpan span, MARKERTYPE mt, string tipText)
        {
            IVsTextLineMarker marker           = null;
            TextMarkerClient  textMarkerClient = new TextMarkerClient(tipText);

            textLines.CreateLineMarker((int)mt, span.iStartLine, span.iStartIndex,
                                       span.iEndLine, span.iEndIndex, textMarkerClient, out marker);
            return(marker);
        }
Beispiel #16
0
 public void RemoveTextLineMarker()
 {
     if (_textLineMarker != null)
     {
         ErrorHandler.Ignore(_textLineMarker.UnadviseClient());
         ErrorHandler.Ignore(_textLineMarker.Invalidate());
     }
     _textLineMarker = null;
 }
Beispiel #17
0
 /// <include file='doc\TaskProvider.uex' path='docs/doc[@for="DocumentTask.Dispose1"]/*' />
 protected virtual void Dispose(bool disposing)
 {
     if (this.textLineMarker != null)
     {
         this.textLineMarker.UnadviseClient();
     }
     this.textLineMarker = null;
     this.site           = null;
 }
 public void DisposeTextLineMarker()
 {
     if (TextLineMarker != null)
     {
         TextLineMarker.Invalidate();
         TextLineMarker.UnadviseClient();
         TextLineMarker = null;
     }
 }
Beispiel #19
0
 /// <include file='doc\DocumentTask.uex' path='docs/doc[@for="DocumentTask.DocumentTask"]/*' />
 public DocumentTask(IServiceProvider site, IVsTextLineMarker textLineMarker, TextSpan span, string fileName)
 {
     this.site           = site;
     this.fileName       = fileName;
     this.span           = span;
     this.textLineMarker = textLineMarker;
     this.Document       = this.fileName;
     this.Column         = span.iStartIndex;
     this.Line           = span.iStartLine;
 }
Beispiel #20
0
 /// <include file='doc\DocumentTask.uex' path='docs/doc[@for="DocumentTask.OnRemoved"]/*' />
 protected override void OnRemoved(EventArgs e)
 {
     if (textLineMarker != null)
     {
         NativeMethods.ThrowOnFailure(textLineMarker.Invalidate());
     }
     textLineMarker = null;
     this.site      = null;
     base.OnRemoved(e);
 }
Beispiel #21
0
 public void OnBeforeBufferClose()
 {
     if (persistLoc != null)
     {
         location = persistLoc.Clone(); // back to persistent span
         if (marker != null)
         {
             marker.Invalidate();
             marker = null;
         }
     }
 }
Beispiel #22
0
        protected virtual void Dispose(bool disposing)
        {
            if (this.textLineMarker != null)
            {
                NativeMethods.ThrowOnFailure(textLineMarker.Invalidate());
                this.markerValid = false;
                this.textLineMarker.UnadviseClient();
            }

            this.textLineMarker = null;
            this.site           = null;
        }
Beispiel #23
0
 public TaskItem(ServiceProvider site, IVsTextLineMarker textLineMarker, string fileName, string text, bool readOnly, VSTASKCATEGORY cat, VSTASKPRIORITY pri, _vstaskbitmap bitmap, string helpKeyword)
 {
     this.site           = site;
     this.text           = text;
     this.fileName       = fileName;
     this.textLineMarker = textLineMarker;
     this.helpKeyword    = helpKeyword;
     this.category       = cat;
     this.priority       = pri;
     this.bitmap         = bitmap;
     this.readOnly       = readOnly;
 }
        private static void addMarker(IVsTextLines textLines, int line, int start, int end, int markerType,
                                      AbstractMarkerClientEventSink client)
        {
            IVsTextLineMarker[] markers = new IVsTextLineMarker[1];
            int hr = textLines.CreateLineMarker(markerType, line, start, line, end, client, markers);

            if (!ErrorHandler.Succeeded(hr))
            {
                return;
            }
            client.Marker = markers[0];
        }
Beispiel #25
0
        private static void RemoveAllMarkers()
        {
            // Invalidate all markers in all text views. Ignore any errors.
            foreach (KeyValuePair <IVsTextLines, DocumentInfo> linesToDocInfo in _textLinesToDocInfos)
            {
                IVsTextLineMarker[] markers = new IVsTextLineMarker[linesToDocInfo.Value.MarkersToCloneClasses.Count];
                linesToDocInfo.Value.MarkersToCloneClasses.Keys.CopyTo(markers, 0);

                foreach (IVsTextLineMarker marker in markers)
                {
                    ErrorHandler.Ignore(marker.Invalidate());
                }
            }
        }
Beispiel #26
0
 public int Next(out IVsTextLineMarker marker)
 {
     if (_index >= _markers.Count)
     {
         marker = null;
         return VSConstants.S_FALSE;
     }
     else
     {
         marker = _markers[_index];
         _index++;
         return VSConstants.S_OK;
     }
 }
 public int Next(out IVsTextLineMarker marker)
 {
     if (_index >= _markers.Count)
     {
         marker = null;
         return(VSConstants.S_FALSE);
     }
     else
     {
         marker = _markers[_index];
         _index++;
         return(VSConstants.S_OK);
     }
 }
Beispiel #28
0
        public static IVsTextLineMarker CreateMarker(IVsTextLines textLines, TextSpan span, MARKERTYPE mt, string tipText)
        {
            IVsTextLineMarker[] marker           = new IVsTextLineMarker[1];
            TextMarkerClient    textMarkerClient = new TextMarkerClient(tipText);

            // bugbug: the following comment in the method CEnumMarkers::Initialize() of
            // ~\env\msenv\textmgr\markers.cpp means that tool tips on empty spans
            // don't work:
            //      "VS7 #23719/#15312 [CFlaat]: exclude adjacent markers when the target span is non-empty"
            // So I wonder if we should debug assert on that or try and modify the span
            // in some way to make it non-empty...
            NativeMethods.ThrowOnFailure(textLines.CreateLineMarker((int)mt, span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex, textMarkerClient, marker));
            return(marker[0]);
        }
        private static void addMarker(IVsTextLines textLines, int line, int start, int end)
        {
            TextMarkerClientEventSink clientEventSinkBackground = new TextMarkerClientEventSink();
            TextMarkerClientEventSink clientEventSinkMargin = new TextMarkerClientEventSink();

            IVsTextLineMarker[] markers = new IVsTextLineMarker[1];

            int hr = textLines.CreateLineMarker(JiraLinkBackgroundMarkerType.Id, line, start, line, end, clientEventSinkBackground, markers);
            if (!ErrorHandler.Succeeded(hr)) return;
            clientEventSinkBackground.BackgroundMarker = markers[0];

            hr = textLines.CreateLineMarker(JiraLinkMarginMarkerType.Id, line, start, line, end, clientEventSinkMargin, markers);

            if (!ErrorHandler.Succeeded(hr)) return;
            clientEventSinkMargin.MarginMarker = markers[0];
        }
Beispiel #30
0
        /// <include file='doc\DocumentTask.uex' path='docs/doc[@for="DocumentTask.DocumentTask"]/*' />
        public DocumentTask(IServiceProvider site, IVsTextLines buffer, MARKERTYPE markerType, TextSpan span, string fileName)
        {
            this.site     = site;
            this.fileName = fileName;
            this.span     = span;
            this.Document = this.fileName;
            this.Column   = span.iStartIndex;
            this.Line     = span.iStartLine;

            if (markerType != MARKERTYPE.MARKER_OTHER_ERROR)
            {
                // create marker so task item navigation works even after file is edited.
                IVsTextLineMarker[] marker = new IVsTextLineMarker[1];
                NativeMethods.ThrowOnFailure(buffer.CreateLineMarker((int)markerType, span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex, this, marker));
                this.textLineMarker = marker[0];
                this.markerValid    = true;
            }
        }
        public ExternalEditMarker?TryCreateExternalEditMarker(IVsTextLineMarker marker, ITextSnapshot snapshot)
        {
            var result = marker.GetMarkerType();

            if (result.IsError)
            {
                return(null);
            }

            // Predefined markers aren't a concern
            var value = (int)result.Value;

            if (value <= (int)MARKERTYPE.DEF_MARKER_COUNT)
            {
                return(null);
            }

            // Get the SnapshotSpan for the marker
            var span = marker.GetCurrentSpan(snapshot);

            if (span.IsError)
            {
                return(null);
            }

            switch ((int)result.Value)
            {
            case 15:
            case 16:
            case 26:
                // Details
                //  15: Snippet marker for inactive span
                //  16: Snippet marker for active span
                //  26: Tracks comment insertion for a snippet don' for cursor placement
                return(new ExternalEditMarker(ExternalEditKind.Snippet, span.Value));

            case 25:
                // Kind currently unknown.
                return(null);

            default:
                return(null);
            }
        }
Beispiel #32
0
        public static CloneClass GetCloneClass(IVsTextLineMarker marker)
        {
            IVsTextLines textLines;

            ErrorHandler.ThrowOnFailure(marker.GetLineBuffer(out textLines));

            DocumentInfo documentInfo;

            if (_textLinesToDocInfos.TryGetValue(textLines, out documentInfo))
            {
                CloneClass cloneClass;
                if (documentInfo.MarkersToCloneClasses.TryGetValue(marker, out cloneClass))
                {
                    return(cloneClass);
                }
            }

            return(null);
        }
Beispiel #33
0
        internal static void OnMarkerInvalidated(IVsTextLineMarker marker)
        {
            // Remove the invalidated marker reference from our dictionary of
            // markers. Since this dictionary is held in another one we have
            // to get the text buffer of the marker first.
            IVsTextLines textLines;

            ErrorHandler.ThrowOnFailure(marker.GetLineBuffer(out textLines));

            DocumentInfo documentInfo;

            if (_textLinesToDocInfos.TryGetValue(textLines, out documentInfo))
            {
                if (documentInfo.MarkersToCloneClasses.ContainsKey(marker))
                {
                    documentInfo.MarkersToCloneClasses.Remove(marker);
                }
            }
        }
Beispiel #34
0
        private void OnOpenFile(IVsTextLines textLines, bool refresh)
        {
            if (!isDeleted && marker == null && textLines != null)
            {
                Common.Trace("Task.OnOpenFile: " + location);
                const MARKERTYPE MARKER_COMPILE_WARNING = (MARKERTYPE)11;
                MARKERTYPE       mtype;
                switch (markerType)
                {
                case TaskMarker.CodeSense: mtype = MARKERTYPE.MARKER_CODESENSE_ERROR; break;

                case TaskMarker.Error: mtype = MARKERTYPE.MARKER_COMPILE_ERROR; break;

                case TaskMarker.Warning: mtype = MARKER_COMPILE_WARNING; break;

                case TaskMarker.Other: mtype = MARKERTYPE.MARKER_OTHER_ERROR; break;

                case TaskMarker.Invisible: mtype = MARKERTYPE.MARKER_INVISIBLE; break;

                default:
                    if ((int)markerType < (int)MARKERTYPE.DEF_MARKER_COUNT)
                    {
                        mtype = (MARKERTYPE)markerType;
                    }
                    else
                    {
                        mtype = MARKERTYPE.MARKER_INVISIBLE;
                    } break;                                            // still create a marker to track position changes
                }
                IVsTextLineMarker[] markers = new IVsTextLineMarker[1];
                TextSpan            ts      = location.TextSpan;
                IVsTextMarkerClient client  = (taskManager.TrackMarkerEvents ? this : null);

                textLines.CreateLineMarker((int)mtype
                                           , ts.iStartLine, ts.iStartIndex, ts.iEndLine, ts.iEndIndex
                                           , client, markers);
                marker = markers[0];
                if (marker == null)
                {
                    Common.Trace("Task: failed to create marker at " + location);
                }
            }
        }
        public NemerleTextMarkerClient(IVsTextLines buffer, Location loc)
        {
            Location = loc;

            var markerRef = new IVsTextLineMarker[1];

            var hr = buffer.CreateLineMarker((int)MARKERTYPE2.MARKER_SMARTTAG_FACTOID,
                loc.Line - 1, loc.Column - 1, loc.EndLine - 1, loc.EndColumn - 1, this, markerRef);

            Debug.Assert(hr == 0);

            if (hr == 0) // S_OK
            {
                TextLineMarker = markerRef[0];
                string[] ss = new string[1];
                uint i;
                TextLineMarker.GetVisualStyle(out i);
                //TextLineMarker.SetVisualStyle((uint)MARKERVISUAL.MV_SEL_MARGIN_GLYPH);
                Debug.Assert(true);
            }
        }
        public ExternalEditMarker? TryCreateExternalEditMarker(IVsTextLineMarker marker, ITextSnapshot snapshot)
        {
            var result = marker.GetMarkerType();
            if (result.IsError)
            {
                return null;
            }

            // Predefined markers aren't a concern
            var value = (int)result.Value;
            if (value <= (int)MARKERTYPE.DEF_MARKER_COUNT)
            {
                return null;
            }

            // Get the SnapshotSpan for the marker
            var span = marker.GetCurrentSpan(snapshot);
            if (span.IsError)
            {
                return null;
            }

            switch ((int)result.Value)
            {
                case 15:
                case 16:
                case 26:
                    // Details
                    //  15: Snippet marker for inactive span
                    //  16: Snippet marker for active span
                    //  26: Tracks comment insertion for a snippet don' for cursor placement
                    return new ExternalEditMarker(ExternalEditKind.Snippet, span.Value);
                case 25:
                    // Kind currently unknown.
                    return null;
                default:
                    return null;
            }
        }
Beispiel #37
0
 int IVsTextLines.CreateLineMarker(int iMarkerType,
             int iStartLine,
             int iStartIndex,
             int iEndLine,
             int iEndIndex,
             IVsTextMarkerClient pClient,
             IVsTextLineMarker[] ppMarker
     )
 {
     return VSConstants.E_NOTIMPL;
 }
Beispiel #38
0
        public void MakeTextMarker(IVsTextLines buffer)
        {
            Trace.Assert(TextLineMarker == null);
            if (TextLineMarker != null)
                DisposeTextLineMarker();

            var span = Utils.SpanFromLocation(CompilerMessage.Location);
            int markerType;
            switch (CompilerMessage.Kind)
            {
                case MessageKind.Error:   markerType = (int)MARKERTYPE.MARKER_CODESENSE_ERROR;  break;
                case MessageKind.Warning: markerType = (int)MARKERTYPE.MARKER_COMPILE_ERROR;    break;
                default:                  markerType = (int)MARKERTYPE2.MARKER_WARNING;         break;
            }

            // create marker so task item navigation works even after file is edited.
            IVsTextLineMarker[] marker = new IVsTextLineMarker[1];
            // bugbug: the following comment in the method CEnumMarkers::Initialize() of
            // ~\env\msenv\textmgr\markers.cpp means that tool tips on empty spans
            // don't work:
            //      "VS7 #23719/#15312 [CFlaat]: exclude adjacent markers when the target span is non-empty"
            // So I wonder if we should debug assert on that or try and modify the span
            // in some way to make it non-empty...
            ErrorHandler.ThrowOnFailure(buffer.CreateLineMarker(markerType, span.iStartLine, span.iStartIndex,
                span.iEndLine, span.iEndIndex, this, marker));

            _textLineMarker = marker[0];
        }
 public int CreateLineMarker(int iMarkerType, int iStartLine, int iStartIndex, int iEndLine, int iEndIndex, IVsTextMarkerClient pClient, IVsTextLineMarker[] ppMarker)
 {
     return VSConstants.S_OK;
 }
 public int CreateLineMarker(
     int iMarkerType, int iStartLine, int iStartIndex, int iEndLine, int iEndIndex, IVsTextMarkerClient pClient,
     IVsTextLineMarker[] ppMarker)
 {
     return _textBuffer.CreateLineMarker(iMarkerType, iStartLine, iStartIndex, iEndLine, iEndIndex, pClient, ppMarker);
 }
Beispiel #41
0
    public static IVsTextLineMarker CreateMarker( IVsTextLines textLines, TextSpan span, MARKERTYPE mt, string tipText){

      IVsTextLineMarker[] marker = new IVsTextLineMarker[1];    
      TextMarkerClient textMarkerClient = new TextMarkerClient( tipText );
      textLines.CreateLineMarker((int)mt, span.iStartLine, span.iStartIndex, 
        span.iEndLine, span.iEndIndex, textMarkerClient, marker);
      return marker[0];
    }
 bool IExternalEditAdapter.IsExternalEditMarker(IVsTextLineMarker marker)
 {
     return IsExternalEditMarker(marker);
 }
Beispiel #43
0
        private void XPathQueryButton_Click(object sender, EventArgs e)
        {
            try
            {
                //ErrorListBox.Items.Clear();
                this.errors.Clear(); ;
                this.resultsGridView.DataSource = null;
                ClearResults();

                GetCurrentSource();

                if (!this.currentDocument.IsValidXmlDocument())
                {
                    ReportError(new ErrorInfoLine("Invalid XML Document – see Error List Window for details", errors.Count + 1, ErrorInfoLine.ErrorType.Warning));
                    return;
                }

                try
                {
                    foreach (DataGridViewRow CurrentRow in namespaceGridView.Rows)
                    {
                        if (CurrentRow.Cells[0].Value == null && CurrentRow.Cells[1].Value == null)
                        {
                            //skip empty rows
                            continue;
                        }
                        else
                        {
                            if (CurrentRow.Cells[0].Value == null)
                            {
                                ReportError(new ErrorInfoLine("Invalid Namespace Table - a prefix is required for all namespaces", errors.Count + 1, ErrorInfoLine.ErrorType.Warning));
                                return;
                            }
                            else
                            {
                                if (CurrentRow.Cells[1].Value == null)
                                {
                                    this.currentDocument.XmlNamespaceManager.AddNamespace((string)CurrentRow.Cells[0].Value, string.Empty);
                                }
                                else
                                {
                                    this.currentDocument.XmlNamespaceManager.AddNamespace((string)CurrentRow.Cells[0].Value, (string)CurrentRow.Cells[1].Value);
                                }
                            }
                        }


                    }
                }
                catch (Exception ex)
                {
                    //We should never get here
                    //ReportError(ex);
                    return;
                }

                XmlNodeList XPathResultNodeList = null;
                try
                {
                    XPathResultNodeList = this.currentDocument.Query(xpathTextBox.Text);
                }
                catch (XPathException ex)
                {
                    ReportError(ex);
                    return;
                }

                results = new BindingList<XmlNodeInfo>();

                if (XPathResultNodeList != null)
                {
                    foreach (XmlNode Node in XPathResultNodeList)
                    {
                        LineInfo CurrentLineInfo = this.currentDocument.GetLineInfo(Node);
                        if (CurrentLineInfo != null)
                        {
                            XmlNodeInfo info = new XmlNodeInfo(Node, CurrentLineInfo.LineNumber, CurrentLineInfo.LinePosition);
                            results.Add(info);
                            TextSpan span = GetNodeSpan(info);
                            IVsTextLineMarker[] amark = new IVsTextLineMarker[1];
                            int hr = this.currentDocument.TextEditorBuffer.CreateLineMarker((int)MARKERTYPE2.MARKER_EXSTENCIL,
                                span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex,
                                info, amark);
                            info.Marker = amark[0];
                            info.MarkerChanged += new EventHandler(OnMarkerChanged);
                            info.MarkerDeleted += new EventHandler(OnMarkerDeleted);
                        }
                    }
                }

                this.resultsGridView.AutoGenerateColumns = false;
                this.resultsGridView.DataSource = results;

                if (this.results.Count > 0)
                {
                    this.resultsGridView.Focus();
                    this.queryTabControl.SelectedTab = this.resultsTabPage;
                }
                else
                {
                    // If no results and XmlDoc has a default namespace, display a warning
                    if (!String.IsNullOrEmpty(this.currentDocument.DocumentElementDefaultNamespace) && !(this.currentDocument.DocumentElementDefaultNamespace == ""))
                    {
                        this.ReportError(new ErrorInfoLine("Document has a default namespace.  Did you make sure to add it to the Namespace Table and use its prefix in your XPath query?",errors.Count + 1,ErrorInfoLine.ErrorType.Warning));
                        return;
                    }
                }
            }
            catch { }
        }
Beispiel #44
0
 public int CreateLineMarker(int iMarkerType, int iStartLine, int iStartIndex, int iEndLine, int iEndIndex, IVsTextMarkerClient pClient, IVsTextLineMarker[] ppMarker)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Beispiel #45
0
 public int FindMarkerByLineIndex(int iMarkerType, int iStartingLine, int iStartingIndex, uint dwFlags, out IVsTextLineMarker ppMarker)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Beispiel #46
0
 public int CreateLineMarker(int iMarkerType, int iStartLine, int iStartIndex, int iEndLine, int iEndIndex, IVsTextMarkerClient pClient, IVsTextLineMarker[] ppMarker) {
     throw new NotImplementedException();
 }
Beispiel #47
0
 public int FindMarkerByLineIndex(int iMarkerType, int iStartingLine, int iStartingIndex, uint dwFlags, out IVsTextLineMarker ppMarker) {
     throw new NotImplementedException();
 }
Beispiel #48
0
 public void Dispose()
 {
     if (marker != null)
     {
         marker.Invalidate();
         marker = null;
     }
 }
Beispiel #49
0
 int IVsTextLines.FindMarkerByLineIndex(int iMarkerType,
             int iStartingLine,
             int iStartingIndex,
             uint dwFlags,
             out IVsTextLineMarker ppMarker
     )
 {
     ppMarker = null;
     return VSConstants.E_NOTIMPL;
 }
Beispiel #50
0
 public virtual void OnDeleteTask(){
   if (textLineMarker != null) 
     textLineMarker.Invalidate();
   textLineMarker = null;
 }   
Beispiel #51
0
 public void DisposeTextLineMarker()
 {
     if (TextLineMarker != null)
     {
         TextLineMarker.UnadviseClient();
         _textLineMarker = null;
     }
 }
 public ExternalEditMarker? TryCreateExternalEditMarker(IVsTextLineMarker marker, ITextSnapshot snapshot)
 {
     return null;
 }
Beispiel #53
0
        private void AddMarkers() {
            int curLine = -1, columnDelta = 0;
            foreach (LocationPreviewItem item in Items) {

                if (item.CheckState == __PREVIEWCHANGESITEMCHECKSTATE.PCCS_Checked) {
                    if (item.Line != curLine) {
                        columnDelta = 0;
                    }
                    curLine = item.Line;

                    IVsTextLineMarker[] marker = new IVsTextLineMarker[1];

                    ErrorHandler.ThrowOnFailure(
                        _buffer.CreateLineMarker(
                            (int)MARKERTYPE2.MARKER_REFACTORING_FIELD,
                            item.Line - 1,
                            item.Column - 1 + columnDelta,
                            item.Line - 1,
                            item.Column - 1 + Engine.Request.Name.Length + columnDelta,
                            null,
                            marker
                        )
                    );

                    columnDelta += Engine.Request.Name.Length - Engine.OriginalName.Length;
                    _markers.Add(marker[0]);
                }
            }
        }
 public bool IsExternalEditMarker(IVsTextLineMarker marker)
 {
     return false;
 }
 public static void OnMarkerInvalidated(IVsTextLineMarker marker)
 {
 }
 public int FindMarkerByLineIndex(int iMarkerType, int iStartingLine, int iStartingIndex, uint dwFlags, out IVsTextLineMarker ppMarker)
 {
     ppMarker = null;
     return VSConstants.S_OK;
 }
 public int FindMarkerByLineIndex(
     int iMarkerType, int iStartingLine, int iStartingIndex, uint dwFlags, out IVsTextLineMarker ppMarker)
 {
     return _textBuffer.FindMarkerByLineIndex(iMarkerType, iStartingLine, iStartingIndex, dwFlags, out ppMarker);
 }
Beispiel #58
0
 public void MarkerInvalidated()
 {
     MarkerDeleted(this, new EventArgs());
     marker = null;
 }
 /// <summary>
 /// Expands the read only region to the end of the current buffer
 /// </summary>
 private void ExtendReadOnlyRegion()
 {
     // Get the position of the last element in the buffer
     int lastLine;
     int lastColumn;
     Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
         textLines.GetLastLineIndex(out lastLine, out lastColumn));
     // Check if the text marker for the read-only region was created.
     if (null == lineMarker)
     {
         // No text marker, so we have to create it.
         IVsTextLineMarker[] markers = new IVsTextLineMarker[1];
         Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
             textLines.CreateLineMarker(
                     (int)MARKERTYPE.MARKER_READONLY,  // Type of marker.
                     0, 0,                             // Position of the beginning of the marker.
                     lastLine, lastColumn,             // Position of the last char in the marker.
                     null,                             // Object implementing the text marker client.
                     markers));                        // Output marker.
         lineMarker = markers[0];
         // Get the behavior of the marker
         uint behavior;
         Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
             lineMarker.GetBehavior(out behavior));
         // Add the track left behavior.
         behavior |= (uint)MARKERBEHAVIORFLAGS.MB_LEFTEDGE_LEFTTRACK;
         Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
             lineMarker.SetBehavior(behavior));
     }
     Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
         lineMarker.ResetSpan(0, 0, lastLine, lastColumn));
 }
Beispiel #60
0
 public TaskItem(ServiceProvider site, IVsTextLineMarker textLineMarker, string fileName, string text, bool readOnly, VSTASKCATEGORY cat, VSTASKPRIORITY pri, _vstaskbitmap bitmap, string helpKeyword) {
   this.site = site;
   this.text = text;
   this.fileName = fileName;
   this.textLineMarker = textLineMarker;
   this.helpKeyword = helpKeyword;
   this.category = cat;
   this.priority = pri;
   this.bitmap = bitmap;
   this.readOnly = readOnly;
 }