本文整理汇总了C#中CSharpTokenNode类的典型用法代码示例。如果您正苦于以下问题:C# CSharpTokenNode类的具体用法?C# CSharpTokenNode怎么用?C# CSharpTokenNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CSharpTokenNode类属于命名空间,在下文中一共展示了CSharpTokenNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: VisitCSharpTokenNode
public override void VisitCSharpTokenNode(CSharpTokenNode token)
{
if (_currentNamespaces.Count != 0 && token == _currentNamespaces.Peek().Item2)
{
_currentNamespaces.Pop();
}
else if (_currentMembers.Count != 0 && token == _currentMembers.Peek().Item3)
{
_currentMembers.Pop();
}
base.VisitCSharpTokenNode(token);
}
示例3: 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);
}
示例4: ConvertNamespaceName
// public override void Visit (UsingsBag.Namespace nspace)
// {
//
//
// VisitNamespaceUsings (nspace);
// VisitNamespaceBody (nspace);
//
// }
//
void ConvertNamespaceName(MemberName memberName, NamespaceDeclaration namespaceDecl)
{
AstNode insertPos = null;
while (memberName != null) {
Identifier newIdent = Identifier.Create (memberName.Name, Convert (memberName.Location));
// HACK for a parser 'bug' - sometimes it generates "<invalid>" identifiers in namespace names (on certain bugs in the input file)
if (newIdent.Name != "<invalid>") {
namespaceDecl.InsertChildBefore (insertPos, newIdent, Roles.Identifier);
insertPos = newIdent;
if (!memberName.DotLocation.IsNull) {
var dotToken = new CSharpTokenNode (Convert (memberName.DotLocation), Roles.Dot);
namespaceDecl.InsertChildBefore (insertPos, dotToken, Roles.Dot);
insertPos = dotToken;
}
}
memberName = memberName.Left;
}
}
示例5: ConvertNamespaceName
void ConvertNamespaceName (MemberName memberName, NamespaceDeclaration namespaceDecl)
{
AstNode insertPos = null;
while (memberName != null) {
Identifier newIdent = Identifier.Create (memberName.Name, Convert (memberName.Location));
namespaceDecl.InsertChildBefore (insertPos, newIdent, NamespaceDeclaration.Roles.Identifier);
insertPos = newIdent;
if (!memberName.DotLocation.IsNull) {
var dotToken = new CSharpTokenNode (Convert (memberName.DotLocation), 1);
namespaceDecl.InsertChildBefore (insertPos, dotToken, NamespaceDeclaration.Roles.Dot);
insertPos = dotToken;
}
memberName = memberName.Left;
}
}
示例6: VisitCSharpTokenNode
public void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode)
{
CSharpModifierToken mod = cSharpTokenNode as CSharpModifierToken;
if (mod != null) {
// ITokenWriter assumes that each node processed between a
// StartNode(parentNode)-EndNode(parentNode)-pair is a child of parentNode.
WriteKeyword(CSharpModifierToken.GetModifierName(mod.Modifier), cSharpTokenNode.Role);
} else {
throw new NotSupportedException ("Should never visit individual tokens");
}
}
示例7: FixEmbeddedStatment
void FixEmbeddedStatment(BraceStyle braceStyle, BraceForcement braceForcement, CSharpTokenNode token, bool allowInLine, AstNode node, bool statementAlreadyIndented = false)
{
if (node == null) {
return;
}
bool isBlock = node is BlockStatement;
TextReplaceAction beginBraceAction = null;
TextReplaceAction endBraceAction = null;
switch (braceForcement) {
case BraceForcement.DoNotChange:
//nothing
break;
case BraceForcement.AddBraces:
if (!isBlock) {
AstNode n = node.Parent.GetCSharpNodeBefore(node);
int start = document.GetOffset(n.EndLocation);
string startBrace = "";
switch (braceStyle) {
case BraceStyle.EndOfLineWithoutSpace:
startBrace = "{";
break;
case BraceStyle.BannerStyle:
case BraceStyle.EndOfLine:
startBrace = " {";
break;
case BraceStyle.NextLine:
startBrace = this.options.EolMarker + curIndent.IndentString + "{";
break;
case BraceStyle.NextLineShifted2:
case BraceStyle.NextLineShifted:
curIndent.Push(IndentType.Block);
startBrace = this.options.EolMarker + curIndent.IndentString + "{";
curIndent.Pop();
break;
}
beginBraceAction = AddChange(start, 0, startBrace);
}
break;
case BraceForcement.RemoveBraces:
if (isBlock) {
BlockStatement block = node as BlockStatement;
if (block.Statements.Count() == 1) {
int offset1 = document.GetOffset(node.StartLocation);
int start = SearchWhitespaceStart(offset1);
int offset2 = document.GetOffset(node.EndLocation);
int end = SearchWhitespaceStart(offset2 - 1);
beginBraceAction = AddChange(start, offset1 - start + 1, null);
endBraceAction = AddChange(end + 1, offset2 - end, null);
node = block.FirstChild;
isBlock = false;
}
}
break;
}
if (isBlock) {
BlockStatement block = node as BlockStatement;
if (allowInLine && block.StartLocation.Line == block.EndLocation.Line && block.Statements.Count() <= 1) {
if (block.Statements.Count() == 1) {
nextStatementIndent = " ";
}
} else {
if (!statementAlreadyIndented) {
EnforceBraceStyle(braceStyle, block.LBraceToken, block.RBraceToken);
}
}
if (braceStyle == BraceStyle.NextLineShifted2) {
curIndent.Push(IndentType.Block);
}
} else {
if (allowInLine && token.StartLocation.Line == node.EndLocation.Line) {
nextStatementIndent = " ";
}
}
if (policy.IndentBlocks && !(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) {
curIndent.Push(IndentType.Block);
}
if (isBlock) {
VisitBlockWithoutFixingBraces((BlockStatement)node, false);
} else {
if (!statementAlreadyIndented) {
FixStatementIndentation(node.StartLocation);
}
node.AcceptVisitor(this);
}
if (policy.IndentBlocks && !(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) {
curIndent.Pop();
}
switch (braceForcement) {
case BraceForcement.DoNotChange:
break;
case BraceForcement.AddBraces:
if (!isBlock) {
int offset = document.GetOffset(node.EndLocation);
if (!char.IsWhiteSpace(document.GetCharAt(offset))) {
offset++;
}
string startBrace = "";
//.........这里部分代码省略.........
示例8: VisitCSharpTokenNode
public override void VisitCSharpTokenNode(CSharpTokenNode token)
{
// Nothing
}
示例9: VisitCSharpTokenNode
public virtual void VisitCSharpTokenNode (CSharpTokenNode token)
{
VisitChildren (token);
}
示例10: VisitCSharpTokenNode
public abstract StringBuilder VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, int data);
示例11: AddIssue
private void AddIssue (CSharpTokenNode operatorToken)
{
AddIssue (operatorToken,
ctx.TranslateString ("Bitwise Operations on enum not marked with Flags attribute"));
}
示例12: VisitCSharpTokenNode
public override StringBuilder VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, int data)
{
throw new NotImplementedException();
}
示例13: VisitCSharpTokenNode
public void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode)
{
tokennodeCounter++;
if (tokennodeCounter == 26)
{
}
CSharpModifierToken mod = cSharpTokenNode as CSharpModifierToken;
if (mod != null)
{
JsonElement element = new JsonElement();
element.SetValue(CSharpModifierToken.GetModifierName(mod.Modifier));
Push(element);
}
else
{
throw new NotSupportedException("Should never visit individual tokens");
}
}
示例14: VisitCSharpTokenNode
public void VisitCSharpTokenNode(CSharpTokenNode node)
{
}
示例15: FixSemicolon
public void FixSemicolon(CSharpTokenNode semicolon)
{
if (semicolon.IsNull) {
return;
}
int endOffset = document.GetOffset(semicolon.StartLocation);
int offset = endOffset;
while (offset - 1 > 0 && char.IsWhiteSpace (document.GetCharAt (offset - 1))) {
offset--;
}
if (offset < endOffset) {
AddChange(offset, endOffset - offset, null);
}
}