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


C# NewCSharpExpressionFinder.FindExpression方法代码示例

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


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

示例1: FindExpression

		ExpressionResult FindExpression (ProjectDom dom, CodeCompletionContext ctx, int offset)
		{
			NewCSharpExpressionFinder expressionFinder = new NewCSharpExpressionFinder (dom);
			try {
				return expressionFinder.FindExpression (Editor.Text, Math.Max (ctx.TriggerOffset + offset, 0));
			} catch (Exception ex) {
				LoggingService.LogWarning (ex.Message, ex);
				return null;
			}
		}
开发者ID:natosha,项目名称:monodevelop,代码行数:10,代码来源:CSharpTextEditorCompletion.cs

示例2: FindExpression

		ExpressionResult FindExpression (ProjectDom dom, CodeCompletionContext ctx)
		{
			NewCSharpExpressionFinder expressionFinder = new NewCSharpExpressionFinder (dom);
			try {
				return expressionFinder.FindExpression (textEditorData, ctx.TriggerOffset);
			} catch (Exception ex) {
				LoggingService.LogWarning (ex.Message, ex);
				return null;
			}
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:10,代码来源:CSharpTextEditorCompletion.cs

示例3: GetLanguageItem

		public MonoDevelop.Projects.Dom.ResolveResult GetLanguageItem (ProjectDom dom, Mono.TextEditor.TextEditorData data, int offset)
		{
			if (offset < 0)
				return null;
			string fileName = data.Document.FileName;
			IParser parser = ProjectDomService.GetParser (fileName);
			if (parser == null)
				return null;
			
			MonoDevelop.Ide.Gui.Document doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null)
				return null;
			
			IResolver         resolver = parser.CreateResolver (dom, doc, fileName);
			if (resolver == null) 
				return null;
			var expressionFinder = new NewCSharpExpressionFinder (dom);
			
			int wordEnd = Math.Min (offset, data.Length - 1);
			if (data.GetCharAt (wordEnd) == '@')
				wordEnd++;
			while (wordEnd < data.Length && (Char.IsLetterOrDigit (data.GetCharAt (wordEnd)) || data.GetCharAt (wordEnd) == '_'))
				wordEnd++;
			
			while (wordEnd < data.Length - 1 && Char.IsWhiteSpace (data.GetCharAt (wordEnd)))
				wordEnd++;
			/* is checked at the end.
			int saveEnd = wordEnd;
			if (wordEnd < data.Length && data.GetCharAt (wordEnd) == '<') {
				int matchingBracket = data.Document.GetMatchingBracketOffset (wordEnd);
				if (matchingBracket > 0)
					wordEnd = matchingBracket;
				while (wordEnd < data.Length - 1 && Char.IsWhiteSpace (data.GetCharAt (wordEnd)))
					wordEnd++;
			}
			
			bool wasMethodCall = false;
			if (data.GetCharAt (wordEnd) == '(') {
				int matchingBracket = data.Document.GetMatchingBracketOffset (wordEnd);
				if (matchingBracket > 0) {
					wordEnd = matchingBracket;
					wasMethodCall = true;
				}
			}
			if (!wasMethodCall)
				wordEnd = saveEnd;*/

			ExpressionResult expressionResult = expressionFinder.FindExpression (data, wordEnd);
			if (expressionResult == null)
				return null;
			
			ResolveResult resolveResult;
			DocumentLocation loc = data.Document.OffsetToLocation (offset);
			string savedExpression = null;
			
			// special handling for 'var' "keyword"
			if (expressionResult.ExpressionContext == ExpressionContext.IdentifierExpected && expressionResult.Expression != null && expressionResult.Expression.Trim () == "var") {
				int endOffset = data.Document.LocationToOffset (expressionResult.Region.End.Line, expressionResult.Region.End.Column);
				StringBuilder identifer = new StringBuilder ();
				for (int i = endOffset; i >= 0 && i < data.Document.Length; i++) {
					char ch = data.Document.GetCharAt (i);
					if (Char.IsWhiteSpace (ch))
						continue;
					if (ch == '=')
						break;
					if (Char.IsLetterOrDigit (ch) || ch =='_') {
						identifer.Append (ch);
						continue;
					}
					identifer.Length = 0;
					break;
				}
				if (identifer.Length > 0) {
					expressionResult.Expression = identifer.ToString ();
					resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
					if (resolveResult != null) {
						resolveResult = new MemberResolveResult (dom.GetType (resolveResult.ResolvedType));
						resolveResult.ResolvedExpression = expressionResult;
						return resolveResult;
					}
				}
			}
			if (expressionResult.ExpressionContext == ExpressionContext.Attribute) {
				savedExpression = expressionResult.Expression;
				expressionResult.Expression = expressionResult.Expression.Trim () + "Attribute";
				expressionResult.ExpressionContext = ExpressionContext.ObjectCreation;
			} 
			resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
			if (savedExpression != null && resolveResult == null) {
				expressionResult.Expression = savedExpression;
				resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
			}
			// Search for possible generic parameters.
//			if (this.resolveResult == null || this.resolveResult.ResolvedType == null || String.IsNullOrEmpty (this.resolveResult.ResolvedType.Name)) {
			if (!expressionResult.Region.IsEmpty) {
				int j = data.Document.LocationToOffset (expressionResult.Region.End.Line, expressionResult.Region.End.Column);
				int bracket = 0;
				for (int i = j; i >= 0 && i < data.Document.Length; i++) {
					char ch = data.Document.GetCharAt (i);
					if (Char.IsWhiteSpace (ch))
//.........这里部分代码省略.........
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:101,代码来源:TextEditorResolverProvider.cs


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