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


C# AstNode.GetText方法代码示例

本文整理汇总了C#中AstNode.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetText方法的具体用法?C# AstNode.GetText怎么用?C# AstNode.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AstNode的用法示例。


在下文中一共展示了AstNode.GetText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindPhrase

        private static Phrase FindPhrase(AstNode node)
        {
            var text = node.GetText();

            if (node.Role == Roles.Comment)
                return Phrase.Comment;

            if (node.Role == Roles.Type)
            {
                var type = (node as PrimitiveType);
                if (type != null)
                    return (type.Keyword != null) ? Phrase.Keyword : Phrase.Type;

                // some keywords can be type like "var" which our parser does not recognise
                return text.IsKeyword() ? Phrase.Keyword : Phrase.Type;
            }

            if (node is PrimitiveExpression)
            {
                if (text.IsString())
                    return Phrase.String;
            }

            if (node is CSharpTokenNode)
            {
                if (text.IsKeyword())
                    return Phrase.Keyword;
            }

            return Phrase.Unknwon;
        }
开发者ID:shayanelhami,项目名称:syntaxtame,代码行数:31,代码来源:Code.cs

示例2: GetName

			string GetName (AstNode node)
			{
				if (tag is SyntaxTree) {
					var type = node as TypeDeclaration;
					if (type != null) {
						var sb = new StringBuilder ();
						sb.Append (type.Name);
						while (type.Parent is TypeDeclaration) {
							type = type.Parent as TypeDeclaration;
							sb.Insert (0, type.Name + ".");
						}
						return sb.ToString ();
					}
				}
				
				if (node is Accessor) {
					if (node.Role == PropertyDeclaration.GetterRole)
						return "get";
					if (node.Role == PropertyDeclaration.SetterRole)
						return "set";
					if (node.Role == CustomEventDeclaration.AddAccessorRole) 
						return "add";
					if (node.Role == CustomEventDeclaration.RemoveAccessorRole)
						return "remove";
					return node.GetText ();
				}
				if (node is EntityDeclaration)
					return ((EntityDeclaration)node).Name;
				return ((VariableInitializer)node).Name;
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:30,代码来源:PathedDocumentTextEditorExtension.cs

示例3: Resolve

		/// <summary>
		/// Resolves the specified node.
		/// </summary>
		public ResolveResult Resolve(AstNode node, CancellationToken cancellationToken = default(CancellationToken))
		{
			if (node == null || node.IsNull || IsUnresolvableNode(node))
				return ErrorResolveResult.UnknownError;
			lock (resolveVisitor) {
				InitResolver();
				resolveVisitor.cancellationToken = cancellationToken;
				try {
					ResolveResult rr = resolveVisitor.GetResolveResult(node);
					if (rr == null)
						Debug.Fail (node.GetType () + " resolved to null.", node.StartLocation + ":'" + node.GetText () + "'");
					return rr;
				} finally {
					resolveVisitor.cancellationToken = CancellationToken.None;
				}
			}
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:20,代码来源:CSharpAstResolver.cs

示例4: CreateNewType

		public override void CreateNewType (AstNode newType, NewTypeContext ntctx)
		{
			if (newType == null)
				throw new System.ArgumentNullException ("newType");
			var correctFileName = MoveTypeToFile.GetCorrectFileName (context, (EntityDeclaration)newType);
			
			var content = context.Document.Editor.Text;
			
			var types = new List<TypeDeclaration> (context.Unit.GetTypes ());
			types.Sort ((x, y) => y.StartLocation.CompareTo (x.StartLocation));

			foreach (var removeType in types) {
				var start = context.GetOffset (removeType.StartLocation);
				var end = context.GetOffset (removeType.EndLocation);
				content = content.Remove (start, end - start);
			}
			
			var insertLocation = types.Count > 0 ? context.GetOffset (types.Last ().StartLocation) : -1;
			var formattingPolicy = this.document.GetFormattingPolicy ();
			if (insertLocation < 0 || insertLocation > content.Length)
				insertLocation = content.Length;
			content = content.Substring (0, insertLocation) + newType.GetText (formattingPolicy.CreateOptions ()) + content.Substring (insertLocation);

			var formatter = new CSharpFormatter ();
			content = formatter.FormatText (formattingPolicy, null, CSharpFormatter.MimeType, content, 0, content.Length);

			File.WriteAllText (correctFileName, content);
			document.Project.AddFile (correctFileName);
			MonoDevelop.Ide.IdeApp.ProjectOperations.Save (document.Project);
			MonoDevelop.Ide.IdeApp.Workbench.OpenDocument (correctFileName);
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:31,代码来源:MDRefactoringScript.cs

示例5: GetKeywordTooltip

		public TooltipInformation GetKeywordTooltip (AstNode node)
		{
			return GetKeywordTooltip (node.GetText (), node);
		}
开发者ID:kekekeks,项目名称:monodevelop,代码行数:4,代码来源:SignatureMarkupCreator.cs

示例6: Resolve

        /// <summary>
        /// Resolves the specified node.
        /// </summary>
        public ResolveResult Resolve(AstNode node, CancellationToken cancellationToken = default(CancellationToken))
        {
            if(node == null)
                return ErrorResolveResult.UnknownError;

            lock(resolve_visitor){
                InitResolver();
                resolve_visitor.cancellation_token = cancellationToken;
                try{
                    ResolveResult rr = resolve_visitor.GetResolveResult(node);
                    if(rr == null){
                        Debug.Fail(string.Format("{0} resolved to null.{1}:'{2}'", node.GetType(), node.StartLocation,
                                                 node.GetText()));
                    }

                    return rr;
                }finally{
                    resolve_visitor.cancellation_token = CancellationToken.None;
                }
            }
        }
开发者ID:hazama-yuinyan,项目名称:monodevelop-bvebinding,代码行数:24,代码来源:BVE5AstResolver.cs


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