本文整理汇总了C#中MonoDevelop.CSharp.Resolver.NewCSharpExpressionFinder.FindFullExpression方法的典型用法代码示例。如果您正苦于以下问题:C# NewCSharpExpressionFinder.FindFullExpression方法的具体用法?C# NewCSharpExpressionFinder.FindFullExpression怎么用?C# NewCSharpExpressionFinder.FindFullExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.CSharp.Resolver.NewCSharpExpressionFinder
的用法示例。
在下文中一共展示了NewCSharpExpressionFinder.FindFullExpression方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLanguageItem
//.........这里部分代码省略.........
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))
continue;
if (ch == '<') {
bracket++;
} else if (ch == '>') {
bracket--;
if (bracket == 0) {
expressionResult.Expression += data.Document.GetTextBetween (j, i + 1);
expressionResult.ExpressionContext = ExpressionContext.ObjectCreation;
resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
break;
}
} else {
if (bracket == 0)
break;
}
}
}
// To resolve method overloads the full expression must be parsed.
// ex.: Overload (1)/ Overload("one") - parsing "Overload" gives just a MethodResolveResult
// and for constructor initializers it's tried too to to resolve constructor overloads.
if (resolveResult is ThisResolveResult ||
resolveResult is BaseResolveResult ||
resolveResult is MethodResolveResult && ((MethodResolveResult)resolveResult).Methods.Count > 1) {
// put the search offset at the end of the invocation to be able to find the full expression
// the resolver finds it itself if spaces are between the method name and the argument opening parentheses.
while (wordEnd < data.Length - 1 && Char.IsWhiteSpace (data.GetCharAt (wordEnd)))
wordEnd++;
if (data.GetCharAt (wordEnd) == '(') {
int matchingBracket = data.Document.GetMatchingBracketOffset (wordEnd);
if (matchingBracket > 0)
wordEnd = matchingBracket;
}
//Console.WriteLine (expressionFinder.FindFullExpression (txt, wordEnd));
ResolveResult possibleResult = resolver.Resolve (expressionFinder.FindFullExpression (data, wordEnd), new DomLocation (loc.Line, loc.Column)) ?? resolveResult;
//Console.WriteLine ("possi:" + resolver.Resolve (expressionFinder.FindFullExpression (txt, wordEnd), new DomLocation (loc.Line, loc.Column)));
if (possibleResult is MethodResolveResult)
resolveResult = possibleResult;
}
return resolveResult;
}