本文整理汇总了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;
}
}
示例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;
}
}
示例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))
//.........这里部分代码省略.........