本文整理汇总了C#中NRefactoryResolver.ExtractCurrentMethod方法的典型用法代码示例。如果您正苦于以下问题:C# NRefactoryResolver.ExtractCurrentMethod方法的具体用法?C# NRefactoryResolver.ExtractCurrentMethod怎么用?C# NRefactoryResolver.ExtractCurrentMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NRefactoryResolver
的用法示例。
在下文中一共展示了NRefactoryResolver.ExtractCurrentMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsightRefreshOnComma
public bool InsightRefreshOnComma(ITextEditor editor, char ch, out IInsightWindow insightWindow)
{
// Show MethodInsightWindow or IndexerInsightWindow
NRefactoryResolver r = new NRefactoryResolver(languageProperties);
Location cursorLocation = editor.Caret.Position;
if (r.Initialize(ParserService.GetParseInformation(editor.FileName), cursorLocation.Y, cursorLocation.X)) {
TextReader currentMethod = r.ExtractCurrentMethod(editor.Document.Text);
if (currentMethod != null) {
ILexer lexer = ParserFactory.CreateLexer(language, currentMethod);
Token token;
InspectedCall call = new InspectedCall(Location.Empty, null);
call.parent = call;
// HACK MINI PARSER
// The following code tries to find the current nested call until the caret position (= cursorLocation) is
// reached. call.commas contains all commas up to the caret position.
// DOES NOT HANDLE GENERICS CORRECTLY! This is sufficient for overload "search", because if we miss one
// overload it does not matter. But if we highlight the wrong parameter (see below) it DOES MATTER!
while ((token = lexer.NextToken()) != null && token.Kind != eofToken && token.Location < cursorLocation) {
if (token.Kind == commaToken) {
call.commas.Add(token.Location);
} else if (token.Kind == openParensToken || token.Kind == openBracketToken || token.Kind == openBracesToken) {
call = new InspectedCall(token.Location, call);
} else if (token.Kind == closeParensToken || token.Kind == closeBracketToken || token.Kind == closeBracesToken) {
call = call.parent;
}
}
int offset = LocationToOffset(editor, call.start);
if (offset >= 0 && offset < editor.Document.TextLength) {
char c = editor.Document.GetCharAt(offset);
if (c == '(' || c == '[') {
var insightProvider = new MethodInsightProvider { LookupOffset = offset };
var insightItems = insightProvider.ProvideInsight(editor);
// find highlighted parameter
// see mini parser description above; the number of recognized parameters is the index
// of the current parameter!
var parameters = ResolveCallParameters(editor, call);
highlightedParameter = parameters.Count;
insightWindow = ShowInsight(editor, insightItems, parameters, ch);
return insightWindow != null;
} else {
Core.LoggingService.Warn("Expected '(' or '[' at start position");
}
}
}
}
insightWindow = null;
return false;
}
示例2: InsightRefreshOnComma
protected bool InsightRefreshOnComma(SharpDevelopTextAreaControl editor, char ch)
{
// Show MethodInsightWindow or IndexerInsightWindow
NRefactoryResolver r = new NRefactoryResolver(languageProperties);
Location cursorLocation = new Location(editor.ActiveTextAreaControl.Caret.Column + 1, editor.ActiveTextAreaControl.Caret.Line + 1);
if (r.Initialize(ParserService.GetParseInformation(editor.FileName), cursorLocation.Y, cursorLocation.X)) {
TextReader currentMethod = r.ExtractCurrentMethod(editor.Text);
if (currentMethod != null) {
ILexer lexer = ParserFactory.CreateLexer(language, currentMethod);
Token token;
InspectedCall call = new InspectedCall(Location.Empty, null);
call.parent = call;
while ((token = lexer.NextToken()) != null
&& token.Kind != eofToken
&& token.Location < cursorLocation)
{
if (token.Kind == commaToken) {
call.commas.Add(token.Location);
} else if (token.Kind == openParensToken || token.Kind == openBracketToken || token.Kind == openBracesToken) {
call = new InspectedCall(token.Location, call);
} else if (token.Kind == closeParensToken || token.Kind == closeBracketToken || token.Kind == closeBracesToken) {
call = call.parent;
}
}
int offset = LocationToOffset(editor, call.start);
if (offset >= 0 && offset < editor.Document.TextLength) {
char c = editor.Document.GetCharAt(offset);
if (c == '(') {
ShowInsight(editor,
new MethodInsightDataProvider(offset, true),
ResolveCallParameters(editor, call),
ch);
return true;
} else if (c == '[') {
ShowInsight(editor,
new IndexerInsightDataProvider(offset, true),
ResolveCallParameters(editor, call),
ch);
return true;
} else {
LoggingService.Warn("Expected '(' or '[' at start position");
}
}
}
}
return false;
}
示例3: InsightRefreshOnComma
public bool InsightRefreshOnComma(ITextEditor editor, char ch, out IInsightWindow insightWindow)
{
// Show MethodInsightWindow or IndexerInsightWindow
NRefactoryResolver r = new NRefactoryResolver(languageProperties);
Location cursorLocation = editor.Caret.Position;
if (r.Initialize(ParserService.GetParseInformation(editor.FileName), cursorLocation.Y, cursorLocation.X)) {
TextReader currentMethod = r.ExtractCurrentMethod(editor.Document.Text);
if (currentMethod != null) {
ILexer lexer = ParserFactory.CreateLexer(language, currentMethod);
Token token;
InspectedCall call = new InspectedCall(Location.Empty, null);
call.parent = call;
while ((token = lexer.NextToken()) != null && token.Kind != eofToken && token.Location < cursorLocation) {
if (token.Kind == commaToken) {
call.commas.Add(token.Location);
} else if (token.Kind == openParensToken || token.Kind == openBracketToken || token.Kind == openBracesToken) {
call = new InspectedCall(token.Location, call);
} else if (token.Kind == closeParensToken || token.Kind == closeBracketToken || token.Kind == closeBracesToken) {
call = call.parent;
}
}
int offset = LocationToOffset(editor, call.start);
if (offset >= 0 && offset < editor.Document.TextLength) {
char c = editor.Document.GetCharAt(offset);
if (c == '(' || c == '[') {
var insightProvider = new MethodInsightProvider { LookupOffset = offset };
var insightItems = insightProvider.ProvideInsight(editor);
insightWindow = ShowInsight(editor, insightItems, ResolveCallParameters(editor, call), ch);
return insightWindow != null;
} else {
Core.LoggingService.Warn("Expected '(' or '[' at start position");
}
}
}
}
insightWindow = null;
return false;
}