本文整理汇总了C#中SyntaxTrivia.IsRegularOrDocComment方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTrivia.IsRegularOrDocComment方法的具体用法?C# SyntaxTrivia.IsRegularOrDocComment怎么用?C# SyntaxTrivia.IsRegularOrDocComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTrivia
的用法示例。
在下文中一共展示了SyntaxTrivia.IsRegularOrDocComment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldSelectEntireTriviaFromStart
protected override bool ShouldSelectEntireTriviaFromStart(SyntaxTrivia trivia)
{
return trivia.IsRegularOrDocComment();
}
示例2: OnComment
private bool OnComment(SyntaxTrivia trivia, int currentIndex)
{
if (!trivia.IsRegularOrDocComment())
{
return false;
}
// check whether indentation are right
if (this.UseIndentation && _indentation != _context.GetBaseIndentation(trivia.SpanStart))
{
// comment has wrong indentation
return true;
}
// go deep down for single line documentation comment
if (trivia.IsSingleLineDocComment() &&
ShouldFormatSingleLineDocumentationComment(_indentation, _optionSet.GetOption(FormattingOptions.TabSize, LanguageNames.CSharp), trivia))
{
return true;
}
return false;
}
示例3: GetLineColumnRuleBetween
protected override LineColumnRule GetLineColumnRuleBetween(SyntaxTrivia trivia1, LineColumnDelta existingWhitespaceBetween, bool implicitLineBreak, SyntaxTrivia trivia2)
{
if (IsStartOrEndOfFile(trivia1, trivia2))
{
return LineColumnRule.PreserveLinesWithAbsoluteIndentation(lines: 0, indentation: 0);
}
// [trivia] [whitespace] [token] case
if (trivia2.IsKind(SyntaxKind.None))
{
var insertNewLine = this.FormattingRules.GetAdjustNewLinesOperation(this.Token1, this.Token2) != null;
if (IsMultilineComment(trivia1))
{
return LineColumnRule.PreserveLinesWithGivenIndentation(lines: insertNewLine ? 1 : 0);
}
if (insertNewLine)
{
return LineColumnRule.PreserveLinesWithDefaultIndentation(lines: 0);
}
if (existingWhitespaceBetween.Lines > 0 && existingWhitespaceBetween.Spaces != this.Spaces)
{
return LineColumnRule.PreserveWithGivenSpaces(spaces: this.Spaces);
}
return LineColumnRule.Preserve();
}
// preprocessor case
if (SyntaxFacts.IsPreprocessorDirective(trivia2.Kind()))
{
// Check for immovable preprocessor directives, which are bad directive trivia
// without a preceding line break
if (trivia2.IsKind(SyntaxKind.BadDirectiveTrivia) && existingWhitespaceBetween.Lines == 0 && !implicitLineBreak)
{
_succeeded = false;
return LineColumnRule.Preserve();
}
// if current line is the first line of the file, don't put extra line 1
var lines = (trivia1.IsKind(SyntaxKind.None) && this.Token1.IsKind(SyntaxKind.None)) ? 0 : 1;
if (trivia2.IsKind(SyntaxKind.RegionDirectiveTrivia) || trivia2.IsKind(SyntaxKind.EndRegionDirectiveTrivia))
{
return LineColumnRule.PreserveLinesWithDefaultIndentation(lines);
}
return LineColumnRule.PreserveLinesWithAbsoluteIndentation(lines, indentation: 0);
}
// comments case
if (trivia2.IsRegularOrDocComment())
{
// start of new comments group
if (!trivia1.IsRegularComment() || existingWhitespaceBetween.Lines > 1)
{
if (this.FormattingRules.GetAdjustNewLinesOperation(this.Token1, this.Token2) != null)
{
return LineColumnRule.PreserveLinesWithDefaultIndentation(lines: 0);
}
return LineColumnRule.PreserveLinesWithGivenIndentation(lines: 0);
}
// comments after existing comment
if (existingWhitespaceBetween.Lines == 0)
{
return LineColumnRule.PreserveLinesWithGivenIndentation(lines: 0);
}
return LineColumnRule.PreserveLinesWithFollowingPrecedingIndentation();
}
if (trivia2.IsKind(SyntaxKind.SkippedTokensTrivia))
{
// if there is any skipped tokens, it is not possible to format this trivia range.
_succeeded = false;
}
return LineColumnRule.Preserve();
}