当前位置: 首页>>代码示例>>C#>>正文


C# CSharpTokenNode类代码示例

本文整理汇总了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);
		}
开发者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


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