本文整理汇总了C#中SyntaxTokenList.Select方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTokenList.Select方法的具体用法?C# SyntaxTokenList.Select怎么用?C# SyntaxTokenList.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTokenList
的用法示例。
在下文中一共展示了SyntaxTokenList.Select方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReformatModifiersAsMultipleLines
private static SyntaxTokenList ReformatModifiersAsMultipleLines(SyntaxTokenList modifiers, SyntaxTrivia indentation)
{
if (modifiers.Count == 0)
{
return modifiers;
}
var reformattedModifiers = modifiers.Select(t => t.WithLeadingTrivia(ReformatTriviaListNoLeadingSpace(t.LeadingTrivia)).WithTrailingTrivia(ReformatTriviaList(t.TrailingTrivia))).ToArray();
reformattedModifiers[0] = reformattedModifiers[0].WithLeadingTrivia(reformattedModifiers[0].LeadingTrivia.Insert(0, indentation));
return SyntaxFactory.TokenList(reformattedModifiers);
}
示例2: IsIgnoreMember
private bool IsIgnoreMember(SyntaxTokenList modifiers)
{
if (_ignoreMemberAccessibilities == Accessibilities.None) { return false; }
var tokenKinds = modifiers.Select(x => x.Kind()).ToArray();
if (_ignoreMemberAccessibilities.HasFlag(Accessibilities.ProtectedInternal)
&& tokenKinds.Contains(SyntaxKind.ProtectedKeyword)
&& tokenKinds.Contains(SyntaxKind.InternalKeyword))
{
return true;
}
if (_ignoreMemberAccessibilities.HasFlag(Accessibilities.Public)
&& tokenKinds.Contains(SyntaxKind.PublicKeyword))
{
return true;
}
if (_ignoreMemberAccessibilities.HasFlag(Accessibilities.Protected)
&& tokenKinds.Contains(SyntaxKind.ProtectedKeyword))
{
return true;
}
if (_ignoreMemberAccessibilities.HasFlag(Accessibilities.Internal)
&& tokenKinds.Contains(SyntaxKind.InternalKeyword))
{
return true;
}
if (_ignoreMemberAccessibilities.HasFlag(Accessibilities.Private)
&& tokenKinds.Contains(SyntaxKind.PrivateKeyword))
{
return true;
}
return false;
}
示例3: ReformatModifiersAsSingleLine
private static SyntaxTokenList ReformatModifiersAsSingleLine(SyntaxTokenList modifiers)
{
if (modifiers.Count == 0)
{
return modifiers;
}
var reformattedModifiers = modifiers.Select(t => t.WithLeadingTrivia(ReformatTriviaListNoLeadingSpace(t.LeadingTrivia)).WithTrailingTrivia(ReformatTriviaList(t.TrailingTrivia)));
return SyntaxFactory.TokenList(reformattedModifiers);
}
示例4: GetTypeModifiersText
private string GetTypeModifiersText(SyntaxTokenList modifiers)
{
var tokens = modifiers.Select(token =>
{
switch (token.Kind())
{
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
case SyntaxKind.InternalKeyword:
case SyntaxKind.AbstractKeyword:
return "";
default:
return $"<<{token.ValueText}>>";
}
}).Where(token => token != "");
var result = string.Join(" ", tokens);
if (result != string.Empty)
{
result += " ";
};
return result;
}
示例5: GetMemberModifiersText
private string GetMemberModifiersText(SyntaxTokenList modifiers)
{
var tokens = modifiers.Select(token =>
{
switch (token.Kind())
{
case SyntaxKind.PublicKeyword:
return "+";
case SyntaxKind.PrivateKeyword:
return "-";
case SyntaxKind.ProtectedKeyword:
return "#";
case SyntaxKind.AbstractKeyword:
case SyntaxKind.StaticKeyword:
return $"{{{token.ValueText}}}";
case SyntaxKind.InternalKeyword:
default:
return $"<<{token.ValueText}>>";
}
});
var result = string.Join(" ", tokens);
if (result != string.Empty)
{
result += " ";
};
return result;
}
示例6: ParseModifiers
/// <summary>
/// Converts member declaration modifiers to Swift
/// NOTE that internal will be converted to public, as Swift doesn't have an internal modifier
/// </summary>
/// <example>public readonly</example>
/// <param name="modifiers">The modifiers to convert</param>
/// <returns>The converted Swift modifiers</returns>
private static string ParseModifiers(SyntaxTokenList modifiers)
{
return string.Join(" ", modifiers.Select(modifier =>
modifier.Text == "internal" ? "public" : modifier.Text)) + " ";
}
示例7: ConvertModifiers
static SyntaxTokenList ConvertModifiers(SyntaxTokenList modifiers, TokenContext context = TokenContext.Global)
{
return SyntaxFactory.TokenList(modifiers.Select(m => SyntaxFactory.Token(ConvertToken(CS.CSharpExtensions.Kind(m), context))));
}
示例8: SyntaxTokenListTranslation
public SyntaxTokenListTranslation(SyntaxTokenList syntax, SyntaxTranslation parent) : base(null, parent)
{
tokenListSyntax = syntax;
tokens = syntax.Select(f => f.Get(this)).ToArray();
}