本文整理汇总了C#中ICompletionWidget.CreateCodeCompletionContext方法的典型用法代码示例。如果您正苦于以下问题:C# ICompletionWidget.CreateCodeCompletionContext方法的具体用法?C# ICompletionWidget.CreateCodeCompletionContext怎么用?C# ICompletionWidget.CreateCodeCompletionContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICompletionWidget
的用法示例。
在下文中一共展示了ICompletionWidget.CreateCodeCompletionContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentParameterIndex
// Returns the index of the parameter where the cursor is currently positioned.
// -1 means the cursor is outside the method parameter list
// 0 means no parameter entered
// > 0 is the index of the parameter (1-based)
public int GetCurrentParameterIndex(ICompletionWidget widget, CodeCompletionContext ctx)
{
int cursor = widget.CreateCodeCompletionContext().TriggerOffset;
int i = ctx.TriggerOffset;
//if (i < 0 || i >= editor.Length || editor.GetCharAt (i) == ')')
// return -1;
if (i > cursor)
return -1;
else if (i == cursor)
return 0;
int parameterIndex = 1;
while (i++ < cursor) {
if (i >= widget.TextLength)
break;
char ch = widget.GetChar (i);
if (ch == ',')
parameterIndex++;
else if (ch == ')')
return -1;
}
return parameterIndex;
}
示例2: ShowCompletion
public void ShowCompletion (ICompletionDataList completionList)
{
completionWidget = Document.GetContent <ICompletionWidget> ();
currentCompletionContext = completionWidget.CreateCodeCompletionContext (Document.TextEditorData.Caret.Offset);
int cpos, wlen;
if (!GetCompletionCommandOffset (out cpos, out wlen)) {
cpos = Document.TextEditorData.Caret.Offset;
wlen = 0;
}
currentCompletionContext.TriggerOffset = cpos;
currentCompletionContext.TriggerWordLength = wlen;
CompletionWindowManager.ShowWindow ('\0', completionList, completionWidget, currentCompletionContext, OnCompletionWindowClosed);
}
示例3: UpdateWindow
internal static void UpdateWindow(ICompletionWidget widget)
{
// Updates the parameter information window from the information
// of the current method overload
if (window == null && methods.Count > 0) {
window = new ParameterInformationWindow ();
wasAbove = false;
}
if (methods.Count == 0) {
if (window != null) {
window.Hide ();
wasAbove = false;
}
return;
}
var ctx = widget.CreateCodeCompletionContext();
MethodData md = methods[methods.Count - 1];
int cparam = md.MethodProvider.GetCurrentParameterIndex (widget, md.CompletionContext);
Gtk.Requisition reqSize = window.ShowParameterInfo (md.MethodProvider, md.CurrentOverload, cparam - 1);
X = md.CompletionContext.TriggerXCoord;
if (CompletionWindowManager.IsVisible) {
// place above
Y = ctx.TriggerYCoord - ctx.TriggerTextHeight - reqSize.Height - 10;
} else {
// place below
Y = ctx.TriggerYCoord;
}
Gdk.Rectangle geometry = window.Screen.GetMonitorGeometry (window.Screen.GetMonitorAtPoint (X, Y));
if (X + reqSize.Width > geometry.Right)
X = geometry.Right - reqSize.Width;
if (Y < geometry.Top)
Y = ctx.TriggerYCoord;
if (wasAbove || Y + reqSize.Height > geometry.Bottom) {
Y = Y - ctx.TriggerTextHeight - reqSize.Height - 4;
wasAbove = true;
}
if (CompletionWindowManager.IsVisible) {
Rectangle completionWindow = new Rectangle (CompletionWindowManager.X, CompletionWindowManager.Y,
CompletionWindowManager.Wnd.Allocation.Width, CompletionWindowManager.Wnd.Allocation.Height);
if (completionWindow.IntersectsWith (new Rectangle (X, Y, reqSize.Width, reqSize.Height))) {
X = completionWindow.X;
Y = completionWindow.Y - reqSize.Height - 6;
if (Y < 0)
Y = completionWindow.Bottom + 6;
}
}
window.Move (X, Y);
window.Show ();
}
示例4: ShowWindow
//, CodeCompletionContext ctx, IParameterDataProvider provider)
public static void ShowWindow(ICompletionWidget widget, IParameterDataProvider provider)
{
if (provider.OverloadCount == 0)
return;
// There can be several method parameter lists open at the same time, so
// they have to be queued. The last one of queue is the one being shown
// in the information window.
MethodData md = new MethodData ();
md.MethodProvider = provider;
md.CurrentOverload = 0;
md.CompletionContext = widget.CreateCodeCompletionContext(); //ctx;
methods.Add (md);
UpdateWindow (widget);
}