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


C# Mono.GetTextBetween方法代码示例

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


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

示例1: GetExpression

		public string GetExpression (Mono.TextEditor.TextEditorData data, int offset)
		{
			if (offset < 0)
				return "";
			var doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null)
				return "";
			var loc = RefactoringService.GetCorrectResolveLocation (doc, data.OffsetToLocation (offset));
			var unit       = doc.ParsedDocument.GetAst<CompilationUnit> ();
			var parsedFile = doc.ParsedDocument.ParsedFile as CSharpParsedFile;
			var node       = unit.GetNodeAt<Expression> (loc.Line, loc.Column);
			if (unit == null || parsedFile == null || node == null)
				return "";
			
			return data.GetTextBetween (node.StartLocation, node.EndLocation);
		}
开发者ID:vac0,项目名称:monodevelop,代码行数:16,代码来源:TextEditorResolverProvider.cs

示例2: ExpressionResult


//.........这里部分代码省略.........
						if (ch == '\n' || ch == '\r')
							break;
						if (wasWhitespace && IsNamePart(ch)) {
							start++;
							if (start < chunk.Offset)
								start = Int32.MaxValue;
							break;
						}
						if (ch == '<') {
							bracketCount--;
							if (bracketCount < 0) {
								start++;
								break; 
							}
							start--;
							wasWhitespace = false;
							continue;
						}
						if (ch == '>') {
							if (wasWhitespace && !wasDot)
								break;
							bracketCount++;
							start--;
							wasWhitespace = false;
							continue;
						}
						if (!IsNamePart(ch) && !Char.IsWhiteSpace (ch) && ch != '.') {
							start++;
							break;
						}
						wasWhitespace = Char.IsWhiteSpace (ch);
						wasDot = ch == '.' || wasDot && wasWhitespace;
						start--;
					}
					
					int end = i;
					int genericCount = 0;
					wasWhitespace = false;
					List<Segment> nameSegments = new List<Segment> ();
					while (end < chunk.EndOffset) {
						char ch = doc.GetCharAt (end);
						if (wasWhitespace && IsNamePart(ch))
							break;
						if (ch == '<') {
							genericCount = 1;
							while (end < doc.Length) {
								ch = doc.GetCharAt (end);
								if (ch == ',')
									genericCount++;
								if (ch == '>') {
									nameSegments.Add (new Segment (end, 1));
									break;
								}
								end++;
							}
							break;
						}
						if (!IsNamePart(ch) && !Char.IsWhiteSpace (ch)) 
							break;
						wasWhitespace = Char.IsWhiteSpace (ch);
						end++;
					}
					if (start >= end) 
						continue;
					string typeString = doc.GetTextBetween (start, end);
					IReturnType returnType = NRefactoryResolver.ParseReturnType (new ExpressionResult (typeString));
						
					int nameEndOffset = start;
					for (; nameEndOffset < end; nameEndOffset++) {
						char ch = doc.GetCharAt (nameEndOffset);
						if (nameEndOffset >= i && ch == '<') {
							nameEndOffset++;
							break;
						}
					}
					nameSegments.Add (new Segment (i, nameEndOffset - i));

					int column = i - line.Offset;
					IType callingType = unit.GetTypeAt (lineNumber, column);
					List<IReturnType> genericParams = null;
					if (genericCount > 0) {
						genericParams = new List<IReturnType> ();
						for (int n = 0; n < genericCount; n++) 
							genericParams.Add (new DomReturnType ("A"));
					}
					
					IType type = null;
					if (ctx != null)
						type = ctx.SearchType ((MonoDevelop.Projects.Dom.INode)callingType ?? unit, returnType);
					if (type == null && unit != null && returnType != null)
						type = unit.GetType (returnType.FullName, returnType.GenericArguments.Count);
					if (ctx != null && type == null && returnType != null) {
						returnType.Name += "Attribute";
						type = ctx.SearchType ((MonoDevelop.Projects.Dom.INode)callingType ?? unit, returnType);
					}
					if (type != null)
						nameSegments.ForEach (segment => HighlightSegment (startChunk, segment, "keyword.semantic.type"));
				}
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:101,代码来源:HighlightCSharpSemanticRule.cs


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