本文整理汇总了C#中IDocument.GetLineEndOffsetNoLineBreak方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.GetLineEndOffsetNoLineBreak方法的具体用法?C# IDocument.GetLineEndOffsetNoLineBreak怎么用?C# IDocument.GetLineEndOffsetNoLineBreak使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocument
的用法示例。
在下文中一共展示了IDocument.GetLineEndOffsetNoLineBreak方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTokensForLine
/// <summary>
/// Gets a HashSet of tokens for the entire line specified.
/// </summary>
/// <param name="solution">
/// The solution.
/// </param>
/// <param name="lineNumber">
/// The line number.
/// </param>
/// <param name="document">
/// The document.
/// </param>
/// <returns>
/// A HashSet of tokens for this line.
/// </returns>
public static IList<ITokenNode> GetTokensForLine(
ISolution solution, JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> lineNumber, IDocument document)
{
List<ITokenNode> tokens = new List<ITokenNode>();
ICSharpFile file = Utils.GetCSharpFile(solution, document);
using (ReadLockCookie.Create())
{
// must call GetLineCount first - it forces the line index to be built
document.GetLineCount();
int start = document.GetLineStartOffset(lineNumber);
int end = document.GetLineEndOffsetNoLineBreak(lineNumber);
for (int i = start; i < end; i++)
{
ITokenNode t = (ITokenNode)file.FindTokenAt(new TreeOffset(i));
tokens.Add(t);
}
}
return tokens;
}
示例2: FormatLines
/// <summary>
/// Executes the standard C Sharp reformatter on the lines passed in.
/// </summary>
/// <param name="solution">
/// The solution.
/// </param>
/// <param name="document">
/// The document.
/// </param>
/// <param name="startLine">
/// The line to start the format of. Zero based.
/// </param>
/// <param name="endLine">
/// The line to end the formatting.
/// </param>
public static void FormatLines(
ISolution solution,
IDocument document,
JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> startLine,
JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> endLine)
{
JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> lineCount = document.GetLineCount();
if (startLine < (JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine>)0)
{
startLine = (JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine>)0;
}
if (endLine > lineCount.Minus1())
{
endLine = lineCount.Minus1();
}
int startOffset = document.GetLineStartOffset(startLine);
int endOffset = document.GetLineEndOffsetNoLineBreak(endLine);
CSharpFormatterHelper.FormatterInstance.Format(
solution,
new DocumentRange(document, new JB::JetBrains.Util.TextRange(startOffset, endOffset)),
SolutionCodeStyleSettings.GetInstance(solution).CodeStyleSettings,
CodeFormatProfile.DEFAULT,
true,
true,
NullProgressIndicator.Instance);
}
示例3: GetTextRangeForLineNumber
/// <summary>
/// Gets a TextRange covering the entire line specified.
/// </summary>
/// <param name="document">
/// The document the line is in.
/// </param>
/// <param name="lineNumber">
/// The line number to use. 0 based.
/// </param>
/// <returns>
/// A TextRange for the line.
/// </returns>
public static JB::JetBrains.Util.TextRange GetTextRangeForLineNumber(
IDocument document, JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> lineNumber)
{
using (ReadLockCookie.Create())
{
// must call GetLineCount first - it forces the line index to be built
document.GetLineCount();
int start = document.GetLineStartOffset(lineNumber);
int end = document.GetLineEndOffsetNoLineBreak(lineNumber);
return new JB::JetBrains.Util.TextRange(start, end);
}
}