本文整理汇总了C#中CompletionListWindow类的典型用法代码示例。如果您正苦于以下问题:C# CompletionListWindow类的具体用法?C# CompletionListWindow怎么用?C# CompletionListWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompletionListWindow类属于命名空间,在下文中一共展示了CompletionListWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
{
var ext = engine.Ext;
var editor = ext.TextEditorData;
var generator = CodeGenerator.CreateGenerator (ext.Document);
if (ext.Project != null)
generator.PolicyParent = ext.Project.Policies;
var builder = engine.MDRefactoringCtx.CreateTypeSystemAstBuilder ();
string sb = BaseExportCodeGenerator.GenerateMemberCode (engine.MDRefactoringCtx, builder, member);
sb = sb.TrimEnd ();
string indent = editor.GetIndentationString (editor.Caret.Location);
sb = sb.Replace (editor.EolMarker, editor.EolMarker + indent);
int targetCaretPosition = sb.LastIndexOf ("throw", StringComparison.Ordinal);
int selectionEndPosition = sb.LastIndexOf (";", StringComparison.Ordinal);
editor.Replace (declarationBegin, editor.Caret.Offset - declarationBegin, sb);
if (selectionEndPosition > 0) {
targetCaretPosition += declarationBegin;
selectionEndPosition += declarationBegin;
editor.Caret.Offset = selectionEndPosition;
editor.SetSelection (targetCaretPosition, selectionEndPosition);
}
}
示例2: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
{
// insert add/remove event handler code after +=/-=
editor.Replace (initialOffset, editor.Caret.Offset - initialOffset, this.DisplayText + (AddSemicolon ? ";" : ""));
// Search opening bracket of member
int pos = callingMember != null ? editor.Document.LocationToOffset (callingMember.BodyRegion.BeginLine, callingMember.BodyRegion.BeginColumn) : initialOffset;
while (pos < editor.Document.TextLength && editor.Document.GetCharAt (pos) != '{') {
pos++;
}
// Search closing bracket of member
pos = editor.Document.GetMatchingBracketOffset (pos) + 1;
pos = Math.Max (0, Math.Min (pos, editor.Document.TextLength - 1));
// Insert new event handler after closing bracket
var line = callingMember != null ? editor.Document.GetLine (callingMember.Region.BeginLine) : editor.Document.GetLineByOffset (initialOffset);
string indent = line.GetIndentation (editor.Document);
StringBuilder sb = new StringBuilder ();
sb.Append (editor.EolMarker);
sb.Append (editor.EolMarker);
sb.Append (indent);
if (callingMember != null && callingMember.IsStatic)
sb.Append ("static ");
sb.Append ("void ");
int pos2 = sb.Length;
sb.Append (this.DisplayText);
sb.Append (' ');
sb.Append (this.parameterList);
sb.Append (editor.EolMarker);
sb.Append (indent);
sb.Append ("{");
sb.Append (editor.EolMarker);
sb.Append (indent);
sb.Append (editor.Options.IndentationString);
int cursorPos = pos + sb.Length;
sb.Append (editor.EolMarker);
sb.Append (indent);
sb.Append ("}");
editor.Insert (pos, sb.ToString ());
editor.Caret.Offset = cursorPos;
// start text link mode after insert
List<TextLink> links = new List<TextLink> ();
TextLink link = new TextLink ("name");
link.AddLink (new TextSegment (0, this.DisplayText.Length));
link.AddLink (new TextSegment (pos - initialOffset + pos2, this.DisplayText.Length));
links.Add (link);
var tle = new TextLinkEditMode (editor.Parent, initialOffset, links);
tle.TextLinkMode = TextLinkMode.EditIdentifier;
tle.SetCaretPosition = true;
tle.SelectPrimaryLink = true;
tle.OldMode = editor.CurrentMode;
tle.StartMode ();
editor.CurrentMode = tle;
}
示例3: GetCurrentWord
public static string GetCurrentWord (CompletionListWindow window)
{
int partialWordLength = window.PartialWord != null ? window.PartialWord.Length : 0;
int replaceLength = window.CodeCompletionContext.TriggerWordLength + partialWordLength - window.InitialWordLength;
int endOffset = Math.Min (window.CodeCompletionContext.TriggerOffset + replaceLength, window.CompletionWidget.TextLength);
var result = window.CompletionWidget.GetText (window.CodeCompletionContext.TriggerOffset, endOffset);
return result;
}
示例4: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Ide.Editor.Extension.KeyDescriptor descriptor)
{
base.InsertCompletionText (window, ref ka, descriptor);
factory.Ext.Editor.GetContent<CSharpTextEditorIndentation> ().DoReSmartIndent ();
if (this.CompletionText.Contains ("\n")) {
factory.Ext.Editor.GetContent<CSharpTextEditorIndentation> ().DoReSmartIndent (factory.Ext.Editor.GetLine (factory.Ext.Editor.CaretLine).NextLine.Offset);
}
}
示例5: InsertCompletionText
public virtual void InsertCompletionText (CompletionListWindow window)
{
int partialWordLength = window.PartialWord != null ? window.PartialWord.Length : 0;
int replaceLength = window.CodeCompletionContext.TriggerWordLength + partialWordLength - window.InitialWordLength;
string currentWord = window.CompletionWidget.GetText (window.CodeCompletionContext.TriggerOffset, window.CodeCompletionContext.TriggerOffset + replaceLength);
window.CompletionWidget.SetCompletionText (window.CodeCompletionContext, currentWord, CompletionText);
}
示例6: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor)
{
var editor = factory.Ext.Editor;
var offset = window.CodeCompletionContext.TriggerOffset;
using (var undo = editor.OpenUndoGroup ()) {
base.InsertCompletionText (window, ref ka, descriptor);
var span = nodeToCast.Span;
var type = SafeMinimalDisplayString (targetType, semanticModel, nodeToCast.SpanStart, Ambience.LabelFormat);
editor.ReplaceText (span.Start, span.Length, "((" + type + ")" + nodeToCast + ")");
}
}
示例7: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window)
{
// insert add/remove event handler code after +=/-=
editor.Replace (initialOffset, editor.Caret.Offset - initialOffset, this.DisplayText + ";");
// Search opening bracket of member
int pos = callingMember != null ? editor.Document.LocationToOffset (callingMember.BodyRegion.Start.Line, callingMember.BodyRegion.Start.Column) : initialOffset;
while (pos < editor.Document.Length && editor.Document.GetCharAt (pos) != '{') {
pos++;
}
// Search closing bracket of member
pos = editor.Document.GetMatchingBracketOffset (pos) + 1;
pos = Math.Max (0, Math.Min (pos, editor.Document.Length - 1));
// Insert new event handler after closing bracket
string indent = editor.Document.GetLine (callingMember.Location.Line).GetIndentation (editor.Document);
StringBuilder sb = new StringBuilder ();
sb.Append (editor.EolMarker);
sb.Append (editor.EolMarker);
sb.Append (indent);
if (callingMember.IsStatic)
sb.Append ("static ");
sb.Append ("void ");
int pos2 = sb.Length;
sb.Append (this.DisplayText);sb.Append (' ');sb.Append (this.parameterList);sb.Append (editor.EolMarker);
sb.Append (indent);sb.Append ("{");sb.Append (editor.EolMarker);
sb.Append (indent);sb.Append (TextEditorProperties.IndentString);
int cursorPos = pos + sb.Length;
sb.Append (editor.EolMarker);
sb.Append (indent);sb.Append ("}");
editor.Insert (pos, sb.ToString ());
editor.Caret.Offset = cursorPos;
// start text link mode after insert
List<TextLink> links = new List<TextLink> ();
TextLink link = new TextLink ("name");
link.AddLink (new Segment (0, this.DisplayText.Length));
link.AddLink (new Segment (pos - initialOffset + pos2, this.DisplayText.Length));
links.Add (link);
CompletionTextLinkMode tle = new CompletionTextLinkMode (editor.Parent, initialOffset, links);
tle.TriggerCodeCompletion = false;
tle.SetCaretPosition = true;
tle.SelectPrimaryLink = true;
tle.OldMode = editor.CurrentMode;
tle.StartMode ();
editor.CurrentMode = tle;
}
示例8: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor)
{
var buf = window.CompletionWidget;
if (buf != null) {
//completion context gets nulled from window as soon as we alter the buffer
var codeCompletionContext = window.CodeCompletionContext;
buf.Replace (buf.CaretOffset, 0, element);
// Move caret into the middle of the tags
buf.CaretOffset = codeCompletionContext.TriggerOffset + cursorOffset;
}
}
示例9: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
{
IEditableTextBuffer buf = window.CompletionWidget as IEditableTextBuffer;
if (buf != null) {
using (var undo = buf.OpenUndoGroup ()) {
buf.InsertText (buf.CursorPosition, element);
// Move caret into the middle of the tags
buf.CursorPosition = window.CodeCompletionContext.TriggerOffset + cursorOffset;
buf.Select (buf.CursorPosition, buf.CursorPosition);
}
}
}
示例10: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window)
{
IEditableTextBuffer buf = window.CompletionWidget as IEditableTextBuffer;
if (buf != null) {
buf.BeginAtomicUndo ();
buf.InsertText (buf.CursorPosition, element);
// Move caret into the middle of the tags
buf.CursorPosition = window.CodeCompletionContext.TriggerOffset + cursorOffset;
buf.Select (buf.CursorPosition, buf.CursorPosition);
buf.EndAtomicUndo ();
}
}
示例11: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
{
var editor = ext.TextEditorData;
var generator = CodeGenerator.CreateGenerator (ext.Document);
bool isExplicit = false;
if (member.DeclaringTypeDefinition.Kind == TypeKind.Interface) {
foreach (var m in type.Members) {
if (m.Name == member.Name && !m.ReturnType.Equals (member.ReturnType)) {
isExplicit = true;
break;
}
}
}
var resolvedType = type.Resolve (ext.ParsedDocument.GetTypeResolveContext (ext.Compilation, editor.Caret.Location)).GetDefinition ();
if (ext.Project != null)
generator.PolicyParent = ext.Project.Policies;
var result = generator.CreateMemberImplementation (resolvedType, type, member, isExplicit);
string sb = result.Code.TrimStart ();
int trimStart = result.Code.Length - sb.Length;
sb = sb.TrimEnd ();
var lastRegion = result.BodyRegions.LastOrDefault ();
var region = lastRegion == null? null
: new CodeGeneratorBodyRegion (lastRegion.StartOffset - trimStart, lastRegion.EndOffset - trimStart);
int targetCaretPosition;
int selectionEndPosition = -1;
if (region != null && region.IsValid) {
targetCaretPosition = declarationBegin + region.StartOffset;
if (region.Length > 0) {
if (GenerateBody) {
selectionEndPosition = declarationBegin + region.EndOffset;
} else {
//FIXME: if there are multiple regions, remove all of them
sb = sb.Substring (0, region.StartOffset) + sb.Substring (region.EndOffset);
}
}
} else {
targetCaretPosition = declarationBegin + sb.Length;
}
editor.Replace (declarationBegin, editor.Caret.Offset - declarationBegin, sb);
if (selectionEndPosition > 0) {
editor.Caret.Offset = selectionEndPosition;
editor.SetSelection (targetCaretPosition, selectionEndPosition);
} else {
editor.Caret.Offset = targetCaretPosition;
}
}
示例12: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor)
{
//insert the method name
var buf = window.CompletionWidget;
if (buf != null) {
buf.Replace (window.CodeCompletionContext.TriggerOffset, buf.CaretOffset - window.CodeCompletionContext.TriggerOffset, methodInfo.Name);
}
//generate the codebehind method
// TODO: Roslyn port.
// if (codeBehindClassLocation != null && project != null)
// BindingService.AddMemberToClass (project, codeBehindClass, codeBehindClassLocation, methodInfo, false);
// else
// BindingService.AddMemberToClass (project, codeBehindClass, codeBehindClass.Locations.First (), methodInfo, false);
}
示例13: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, Gdk.Key closeChar, char keyChar, Gdk.ModifierType modifier)
{
//insert the method name
MonoDevelop.Ide.Gui.Content.IEditableTextBuffer buf = window.CompletionWidget as MonoDevelop.Ide.Gui.Content.IEditableTextBuffer;
if (buf != null) {
using (var undo = buf.OpenUndoGroup ()) {
buf.DeleteText (window.CodeCompletionContext.TriggerOffset, buf.CursorPosition - window.CodeCompletionContext.TriggerOffset);
buf.InsertText (buf.CursorPosition, methodInfo.Name);
}
}
//generate the codebehind method
if (codeBehindClassPart != null && project != null)
BindingService.AddMemberToClass (project, codeBehindClass.GetDefinition (), codeBehindClassPart, methodInfo, false);
else
BindingService.AddMemberToClass (project, codeBehindClass.GetDefinition (), codeBehindClass.GetDefinition ().Parts.First (), methodInfo, false);
}
示例14: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor)
{
var buf = window.CompletionWidget;
if (buf != null) {
int deleteStartOffset = window.CodeCompletionContext.TriggerOffset;
if (text.StartsWith (docTypeStart)) {
int start = window.CodeCompletionContext.TriggerOffset - docTypeStart.Length;
if (start >= 0) {
string readback = buf.GetText (start, window.CodeCompletionContext.TriggerOffset);
if (string.Compare (readback, docTypeStart, StringComparison.OrdinalIgnoreCase) == 0)
deleteStartOffset -= docTypeStart.Length;
}
}
buf.Replace (deleteStartOffset, buf.CaretOffset - deleteStartOffset, text);
}
}
示例15: InsertCompletionText
public override void InsertCompletionText (CompletionListWindow window)
{
//insert the method name
MonoDevelop.Ide.Gui.Content.IEditableTextBuffer buf = window.CompletionWidget as MonoDevelop.Ide.Gui.Content.IEditableTextBuffer;
if (buf != null) {
buf.BeginAtomicUndo ();
buf.DeleteText (window.CodeCompletionContext.TriggerOffset, buf.CursorPosition - window.CodeCompletionContext.TriggerOffset);
buf.InsertText (buf.CursorPosition, methodInfo.Name);
buf.EndAtomicUndo ();
}
//generate the codebehind method
if (codeBehindClassPart != null && project != null)
BindingService.AddMemberToClass (project, codeBehindClass, codeBehindClassPart, methodInfo, false);
else
BindingService.AddMemberToClass (project, codeBehindClass, codeBehindClass, methodInfo, false);
}