本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.Role类的典型用法代码示例。如果您正苦于以下问题:C# Role类的具体用法?C# Role怎么用?C# Role使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Role类属于ICSharpCode.NRefactory.CSharp命名空间,在下文中一共展示了Role类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteKeyword
public override void WriteKeyword(Role role, string keyword)
{
WriteIndentation();
column += keyword.Length;
textWriter.Write(keyword);
isAtStartOfLine = false;
}
示例2: WriteKeyword
public override void WriteKeyword(Role role, string keyword)
{
if (role != null) {
WriteSpecialsUpToRole(role);
}
base.WriteKeyword(role, keyword);
}
示例3: WriteToken
public override void WriteToken(Role role, string token)
{
WriteIndentation();
column += token.Length;
textWriter.Write(token);
isAtStartOfLine = false;
}
示例4: WriteToken
public override void WriteToken(Role role, string token, TextTokenType tokenType)
{
// Avoid that two +, - or ? tokens are combined into a ++, -- or ?? token.
// Note that we don't need to handle tokens like = because there's no valid
// C# program that contains the single token twice in a row.
// (for +, - and &, this can happen with unary operators;
// for ?, this can happen in "a is int? ? b : c" or "a as int? ?? 0";
// and for /, this can happen with "1/ *ptr" or "1/ //comment".)
if (lastWritten == LastWritten.Plus && token[0] == '+' ||
lastWritten == LastWritten.Minus && token[0] == '-' ||
lastWritten == LastWritten.Ampersand && token[0] == '&' ||
lastWritten == LastWritten.QuestionMark && token[0] == '?' ||
lastWritten == LastWritten.Division && token[0] == '*') {
base.Space();
}
base.WriteToken(role, token, tokenType);
if (token == "+") {
lastWritten = LastWritten.Plus;
} else if (token == "-") {
lastWritten = LastWritten.Minus;
} else if (token == "&") {
lastWritten = LastWritten.Ampersand;
} else if (token == "?") {
lastWritten = LastWritten.QuestionMark;
} else if (token == "/") {
lastWritten = LastWritten.Division;
} else {
lastWritten = LastWritten.Other;
}
}
示例5: WriteKeyword
public override void WriteKeyword(Role role, string keyword)
{
if (lastWritten == LastWritten.KeywordOrIdentifier) {
Space();
}
base.WriteKeyword(role, keyword);
lastWritten = LastWritten.KeywordOrIdentifier;
}
示例6: WriteToken
public override void WriteToken(Role role, string token)
{
CSharpTokenNode t = new CSharpTokenNode(locationProvider.Location, (TokenRole)role);
EmptyStatement node = nodes.Peek().LastOrDefault() as EmptyStatement;
if (node == null)
currentList.Add(t);
else {
node.Location = locationProvider.Location;
}
base.WriteToken(role, token);
}
示例7: WriteKeyword
public override void WriteKeyword(Role role, string keyword)
{
TextLocation start = locationProvider.Location;
CSharpTokenNode t = null;
if (role is TokenRole)
t = new CSharpTokenNode(start, (TokenRole)role);
else if (role == EntityDeclaration.ModifierRole)
t = new CSharpModifierToken(start, CSharpModifierToken.GetModifierValue(keyword));
else if (keyword == "this") {
ThisReferenceExpression node = nodes.Peek().LastOrDefault() as ThisReferenceExpression;
if (node != null)
node.Location = start;
} else if (keyword == "base") {
BaseReferenceExpression node = nodes.Peek().LastOrDefault() as BaseReferenceExpression;
if (node != null)
node.Location = start;
}
if (t != null) currentList.Add(t);
base.WriteKeyword(role, keyword);
}
示例8: AddAttributeSection
public void AddAttributeSection(AstNode parent, Attributes attrs, Role role)
{
if (attrs == null)
return;
foreach (var attr in attrs.Sections) {
parent.AddChild (ConvertAttributeSection (attr), EntityDeclaration.AttributeRole);
}
}
示例9: WriteTokenNumber
public void WriteTokenNumber(Role tokenRole, string token)
{
WriteToken(tokenRole, token, BoxedTextColor.Number);
}
示例10: WriteToken
public override void WriteToken(Role role, string token, object data)
{
decoratedWriter.WriteToken(role, token, data);
}
示例11: WriteToken
void WriteToken(string token, Role tokenRole)
{
writer.WriteToken(tokenRole, token);
isAtStartOfLine = false;
}
示例12: WriteKeyword
void WriteKeyword(string token, Role tokenRole = null)
{
writer.WriteKeyword(tokenRole, token);
isAtStartOfLine = false;
}
示例13: WriteKeyword
/// <summary>
/// Writes a keyword to the output.
/// </summary>
public abstract void WriteKeyword(Role role, string keyword);
示例14: WriteSpecialsUpToRole
void WriteSpecialsUpToRole(Role role, AstNode nextNode)
{
if (positionStack.Count == 0) {
return;
}
// Look for the role between the current position and the nextNode.
for (AstNode pos = positionStack.Peek(); pos != null && pos != nextNode; pos = pos.NextSibling) {
if (pos.Role == role) {
WriteSpecials(positionStack.Pop(), pos);
// Push the next sibling because the node matching the role is not a special,
// and should be considered to be already handled.
positionStack.Push(pos.NextSibling);
// This is necessary for OptionalComma() to work correctly.
break;
}
}
}
示例15: AddAttributeSection
public void AddAttributeSection(AstNode parent, Attributes attrs, Role<AttributeSection> role)
{
if (attrs == null)
return;
foreach (var attr in attrs.Sections) {
var section = ConvertAttributeSection(attr);
if (section == null)
continue;
parent.AddChild(section, role);
}
}