• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CSharpTokenNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CSharpTokenNode的典型用法代码示例。如果您正苦于以下问题:C# CSharpTokenNode类的具体用法?C# CSharpTokenNode怎么用?C# CSharpTokenNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CSharpTokenNode类属于命名空间,在下文中一共展示了CSharpTokenNode类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
		}
开发者ID:dyxu,项目名称:vimrc,代码行数:11,代码来源:InsertMissingTokensDecorator.cs


示例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);
 }
开发者ID:KvanTTT,项目名称:CSharp-Minifier,代码行数:12,代码来源:MinifyMembersAstVisitor.cs


示例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);
		}
开发者ID:JackWangCUMT,项目名称:NRefactory,代码行数:20,代码来源:InsertMissingTokensDecorator.cs


示例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;
                }
            }
开发者ID:kaagati,项目名称:NRefactory,代码行数:28,代码来源:CSharpParser.cs


示例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;
				}
			}
开发者ID:N3X15,项目名称:ILSpy,代码行数:17,代码来源:CSharpParser.cs


示例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");
			}
		}
开发者ID:jeremiahyan,项目名称:ILSpy,代码行数:11,代码来源:CSharpOutputVisitor.cs


示例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 = "";
//.........这里部分代码省略.........
开发者ID:txdv,项目名称:monodevelop,代码行数:101,代码来源:AstFormattingVisitor.cs


示例8: VisitCSharpTokenNode

			public override void VisitCSharpTokenNode(CSharpTokenNode token)
			{
				// Nothing
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:4,代码来源:LocalReferenceFinder.cs


示例9: VisitCSharpTokenNode

		public virtual void VisitCSharpTokenNode (CSharpTokenNode token)
		{
			VisitChildren (token);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs


示例10: VisitCSharpTokenNode

 public abstract StringBuilder VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, int data);
开发者ID:hach-que,项目名称:SLSharp,代码行数:1,代码来源:VisitorBase.Abstract.cs


示例11: AddIssue

			private void AddIssue (CSharpTokenNode operatorToken)
			{
				AddIssue (operatorToken, 
					ctx.TranslateString ("Bitwise Operations on enum not marked with Flags attribute"));
			}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:5,代码来源:BitwiseOperationOnNonFlagsEnumIssue.cs


示例12: VisitCSharpTokenNode

 public override StringBuilder VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, int data)
 {
     throw new NotImplementedException();
 }
开发者ID:mono-soc-2011,项目名称:SLSharp,代码行数:4,代码来源:GlslVisitor.Unimplemented.cs


示例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");
            }
        }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:19,代码来源:AstCsToJson.cs


示例14: VisitCSharpTokenNode

 public void VisitCSharpTokenNode(CSharpTokenNode node)
 {
 }
开发者ID:evanw,项目名称:minisharp,代码行数:3,代码来源:Lower.cs


示例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);
     }
 }
开发者ID:segaman,项目名称:NRefactory,代码行数:14,代码来源:FormattingVisitor.cs


示例16: ShouldBreakLine

 static bool ShouldBreakLine(NewLinePlacement placement, CSharpTokenNode token)
 {
     if (placement == NewLinePlacement.NewLine)
         return true;
     if (placement == NewLinePlacement.SameLine)
         return false;
     var prevMeaningfulNode = token.GetPrevNode (n =>n.Role !=Roles.NewLine && n.Role != Roles.Whitespace && n.Role !=Roles.Comment);
     return prevMeaningfulNode.EndLocation.Line != token.StartLocation.Line;
 }
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:FormattingVisitor.cs


示例17: FixEmbeddedStatment

        void FixEmbeddedStatment(BraceStyle braceStyle, CSharpTokenNode token, bool allowInLine, AstNode node, bool statementAlreadyIndented = false)
        {
            if (node == null)
                return;
            bool isBlock = node is BlockStatement;
            FormattingChanges.TextReplaceAction beginBraceAction = null;
            FormattingChanges.TextReplaceAction endBraceAction = null;
            BlockStatement closeBlockToBeFixed = null;
            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)
                        FixOpenBrace(braceStyle, block.LBraceToken);
                    closeBlockToBeFixed = block;
                }

                if (braceStyle == BraceStyle.NextLineShifted2)
                    curIndent.Push(IndentType.Block);
            } else {
                if (allowInLine && token.StartLocation.Line == node.EndLocation.Line) {
                    nextStatementIndent = " ";
                }
            }
            bool pushed = false;
            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);
                pushed = true;
            }
            if (isBlock) {
                VisitBlockWithoutFixingBraces((BlockStatement)node, false);
            } else {
                if (!statementAlreadyIndented)
                    FixStatementIndentation(node.StartLocation);
                node.AcceptVisitor(this);
            }
            if (pushed)
                curIndent.Pop();
            if (beginBraceAction != null && endBraceAction != null) {
                beginBraceAction.DependsOn = endBraceAction;
                endBraceAction.DependsOn = beginBraceAction;
            }

            if (isBlock && braceStyle == BraceStyle.NextLineShifted2)
                curIndent.Pop();
            if (closeBlockToBeFixed != null) {
                FixClosingBrace(braceStyle, closeBlockToBeFixed.RBraceToken);
            }
        }
开发者ID:segaman,项目名称:NRefactory,代码行数:51,代码来源:FormattingVisitor_Statements.cs


示例18: VisitCSharpTokenNode

		public void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode)
		{
			CSharpModifierToken mod = cSharpTokenNode as CSharpModifierToken;
			if (mod != null) {
				StartNode(mod);
				WriteKeyword(CSharpModifierToken.GetModifierName(mod.Modifier));
				EndNode(mod);
			} else {
				throw new NotSupportedException ("Should never visit individual tokens");
			}
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:11,代码来源:CSharpOutputVisitor.cs


示例19: VisitCSharpTokenNode

 public virtual void VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode)
 {
     //throw this.CreateException(cSharpTokenNode);
 }
开发者ID:txdv,项目名称:Builder,代码行数:4,代码来源:Visitor.Empty.cs



注:本文中的CSharpTokenNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharpUnresolvedFile类代码示例发布时间:2022-05-24
下一篇:
C# CSharpSyntaxNode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap