Beispiel #1
0
        static void CheckStartPoint(IReadonlyTextDocument doc, InsertionPoint point, bool isEndPoint)
        {
            var line = doc.GetLine(point.Location.Line);

            if (line == null)
            {
                return;
            }
            if (doc.GetLineIndent(line).Length + 1 == point.Location.Column)
            {
                int lineNr = point.Location.Line;
                while (lineNr > 1 && doc.GetLineIndent(lineNr - 1).Length == doc.GetLine(lineNr - 1).Length)
                {
                    lineNr--;
                }
                line           = doc.GetLine(lineNr);
                point.Location = new DocumentLocation(lineNr, doc.GetLineIndent(line).Length + 1);
            }

            if (doc.GetLineIndent(line).Length + 1 < point.Location.Column)
            {
                point.LineBefore = NewLineInsertion.Eol;
            }
            if (point.Location.Column < line.Length + 1)
            {
                point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
            }
        }
Beispiel #2
0
        static string GetIndent(IReadonlyTextDocument data, ISymbol member, out int offset)
        {
            var line = data.GetLineByOffset(member.Locations.First().SourceSpan.Start);

            offset = line.Offset;
            return(data.GetLineIndent(line));
        }
Beispiel #3
0
 public static string GetLineIndent(this IReadonlyTextDocument document, int lineNumber)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     return(document.GetLineIndent(document.GetLine(lineNumber)));
 }
Beispiel #4
0
        static bool NeedsDocumentation(IReadonlyTextDocument data, ISymbol member)
        {
            int           lineNr = data.OffsetToLineNumber(member.Locations.First().SourceSpan.Start) - 1;
            IDocumentLine line;

            do
            {
                line = data.GetLine(lineNr--);
            } while (lineNr > 0 && data.GetLineIndent(line).Length == line.Length);
            return(!data.GetTextAt(line).TrimStart().StartsWith("///", StringComparison.Ordinal));
        }
Beispiel #5
0
        static void CheckEndPoint(IReadonlyTextDocument doc, InsertionPoint point, bool isStartPoint)
        {
            var line = doc.GetLine(point.Location.Line);

            if (line == null)
            {
                return;
            }

            if (doc.GetLineIndent(line).Length + 1 < point.Location.Column)
            {
                point.LineBefore = NewLineInsertion.BlankLine;
            }
            if (point.Location.Column < line.Length + 1)
            {
                point.LineAfter = NewLineInsertion.Eol;
            }
        }
		static void CheckStartPoint (IReadonlyTextDocument doc, InsertionPoint point, bool isEndPoint)
		{
			var line = doc.GetLine (point.Location.Line);
			if (line == null)
				return;
			if (doc.GetLineIndent (line).Length + 1 == point.Location.Column) {
				int lineNr = point.Location.Line;
				while (lineNr > 1 && doc.GetLineIndent (lineNr - 1).Length == doc.GetLine (lineNr - 1).Length) {
					lineNr--;
				}
				line = doc.GetLine (lineNr);
				point.Location = new DocumentLocation (lineNr, doc.GetLineIndent (line).Length + 1);
			}

			if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
				point.LineBefore = NewLineInsertion.Eol;
			if (point.Location.Column < line.Length + 1)
				point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
		}
		static void CheckEndPoint (IReadonlyTextDocument doc, InsertionPoint point, bool isStartPoint)
		{
			var line = doc.GetLine (point.Location.Line);
			if (line == null)
				return;

			if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
				point.LineBefore = NewLineInsertion.BlankLine;
			if (point.Location.Column < line.Length + 1)
				point.LineAfter = NewLineInsertion.Eol;
		}
		static string GetIndent (IReadonlyTextDocument data, ISymbol member, out int offset)
		{
			var line = data.GetLineByOffset (member.Locations.First().SourceSpan.Start);
			offset = line.Offset;
			return data.GetLineIndent (line);
		}
		static bool NeedsDocumentation (IReadonlyTextDocument data, ISymbol member)
		{
			int lineNr = data.OffsetToLineNumber (member.Locations.First().SourceSpan.Start) - 1;
			IDocumentLine line;

			do {
				line = data.GetLine (lineNr--);
			} while (lineNr > 0 && data.GetLineIndent (line).Length == line.Length);
			return !data.GetTextAt (line).TrimStart ().StartsWith ("///", StringComparison.Ordinal);
		}