/// <summary> /// Determines if there is a region under the cursor for the specified text document. /// </summary> /// <param name="textDocument">The text document.</param> /// <returns>True if there is a region under the cursor, otherwise false.</returns> internal bool IsCodeRegionUnderCursor(TextDocument textDocument) { if (textDocument != null && textDocument.Selection != null) { var cursor = textDocument.GetEditPointAtCursor(); var currentLineText = cursor.GetLine(); return(RegexNullSafe.IsMatch(currentLineText, RegionPattern)); } return(false); }
/// <summary> /// Gets a starting point adjusted for leading comments. /// </summary> /// <param name="originalPoint">The original point.</param> /// <returns>The adjusted starting point.</returns> private static EditPoint GetStartPointAdjustedForComments(TextPoint originalPoint) { var point = originalPoint.CreateEditPoint(); while (point.Line > 1) { string text = point.GetLines(point.Line - 1, point.Line); if (RegexNullSafe.IsMatch(text, @"^\s*//")) { point.LineUp(); point.StartOfLine(); } else { break; } } return(point); }
/// <summary> /// Determines if the specified keyword is present in the specified code element declaration. /// </summary> /// <param name="codeElementDeclaration">The code element declaration.</param> /// <param name="keyword">The keyword.</param> /// <returns>True if the keyword is present, otherwise false.</returns> private static bool IsKeywordSpecified(string codeElementDeclaration, string keyword) { string matchString = @"(^|\s)" + keyword + @"\s"; return(RegexNullSafe.IsMatch(codeElementDeclaration, matchString)); }