Ejemplo n.º 1
0
        public static Position ToLinePosition(this IEditorBufferSnapshot snapshot, int position)
        {
            var line = snapshot.GetLineFromPosition(position);

            return(new Position {
                Line = line.LineNumber, Character = position - line.Start
            });
        }
Ejemplo n.º 2
0
 public static bool IsPositionInNamespace(this IEditorBufferSnapshot snapshot, int position)
 {
     if (position > 0)
     {
         var line = snapshot.GetLineFromPosition(position);
         if (line.Length > 2 && position - line.Start > 2)
         {
             return(snapshot[position - 1] == ':');
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        private static ITextRange GetRoxygenBlockPosition(IEditorBufferSnapshot snapshot, int definitionStart)
        {
            var line = snapshot.GetLineFromPosition(definitionStart);

            for (var i = line.LineNumber - 1; i >= 0; i--)
            {
                var currentLine = snapshot.GetLineFromLineNumber(i);
                var lineText    = currentLine.GetText().TrimStart();
                if (lineText.Length > 0)
                {
                    if (lineText.EqualsOrdinal("##"))
                    {
                        return(currentLine);
                    }
                    if (lineText.EqualsOrdinal("#'"))
                    {
                        return(null);
                    }
                    break;
                }
            }
            return(new TextRange(line.Start, 0));
        }