/// <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)); }
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); } }
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]; }
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]; }
/// <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; } } }
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 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); }
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]; }
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]; }
private static void CreateMarker(IVsTextLines textLines, TextSpan resultSpan, bool highlight) { ArgumentValidation.CheckForNullReference(textLines, "textLines"); ArgumentValidation.CheckForNullReference(resultSpan, "resultSpan"); IVsTextLineMarker[] textMarker = null; var result = textLines.CreateLineMarker( highlight ? (int)MARKERTYPE2.MARKER_REFACTORING_FIELD : (int)MARKERTYPE2.MARKER_REFACTORING_DEPFIELD, resultSpan.iStartLine, resultSpan.iStartIndex, resultSpan.iEndLine, resultSpan.iEndIndex, null, textMarker); Debug.Assert(result == VSConstants.S_OK, "Failed to create line marker for text span."); }
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]); }
/// <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; } }
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 void CreateTextLineMarker(IVsTextLines buffer) { RemoveTextLineMarker(); var tasks = this.Tasks; if (!tasks.Any()) { return; } int markerType = (int)MARKERTYPE.MARKER_INVISIBLE; var errorCategory = tasks.Min(x => x.ErrorCategory); switch (errorCategory) { case TaskErrorCategory.Message: markerType = (int)MARKERTYPE.MARKER_COMPILE_ERROR; break; case TaskErrorCategory.Warning: markerType = (int)MARKERTYPE2.MARKER_WARNING; break; case TaskErrorCategory.Error: markerType = (int)MARKERTYPE.MARKER_CODESENSE_ERROR; break; } int iStartLine = this.PackageReference.StartLine - 1; int iStartIndex = this.PackageReference.StartPos; int iEndLine = this.PackageReference.EndLine - 1; int iEndIndex = this.PackageReference.EndPos; // create marker IVsTextLineMarker[] marker = new IVsTextLineMarker[1]; ErrorHandler.ThrowOnFailure(buffer.CreateLineMarker(markerType, iStartLine, iStartIndex, iEndLine, iEndIndex, this, marker)); _textLineMarker = marker[0]; }
private void MarkTests(ConfiguredProject configuredCPPProject, IVsTextLines lines) { int lineNumber; lines.GetLineCount(out lineNumber); for (int i = 0; i < lineNumber; i++) { int linelength; lines.GetLengthOfLine(i, out linelength); if (linelength <= 0) { continue; } string codeLine; lines.GetLineText(i, 0, i, linelength, out codeLine); //TODO improve this so it deals with if the class declaration isn't the first thing on the line if (!codeLine.StartsWith("TEST") && !codeLine.StartsWith("GTEST")) { continue; } //extract the test group name and test name and combine them for the gtest filter string. int endOfBrackets = codeLine.IndexOf(')'); //TODO validate the next characters after the ) are a newline, curly bracket or a comment. int startOfBrackets = codeLine.IndexOf('(') + 1; //inside of brackets string name = codeLine.Substring(startOfBrackets, endOfBrackets - startOfBrackets); name = name.Replace(',', '.').Replace(" ", ""); IVsTextLineMarker[] marker = new IVsTextLineMarker[1]; int err = lines.CreateLineMarker(TestMarkerType.ID, i, 0, i, linelength, new GTestMarker(configuredCPPProject, name), marker); if (err != VSConstants.S_OK) { throw new Exception("Could not create marker"); } _markers.Add(marker); } }
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); } }
private void OnOpenFile(IVsTextLines textLines) { 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; textLines.CreateLineMarker((int)mtype , ts.iStartLine, ts.iStartIndex, ts.iEndLine, ts.iEndIndex , this, markers); marker = markers[0]; } }
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)); }
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; }
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]; }