void okButtonClick(object sender, RoutedEventArgs e)
		{
			try {
				if (listBox.SelectedItem == null)
					return;
				object tag = ((GotoEntry)listBox.SelectedItem).Tag;
				if (tag is int) {
					ITextEditor editor = GetEditor();
					if (editor != null) {
						int i = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, (int)tag));
						editor.JumpTo(i, int.MaxValue);
					}
				} else if (tag is IClass) {
					IClass c = tag as IClass;
					CodeCompletionDataUsageCache.IncrementUsage(c.DotNetName);
					GotoRegion(c.Region, c.CompilationUnit.FileName);
				} else if (tag is IMember) {
					IMember m = tag as IMember;
					CodeCompletionDataUsageCache.IncrementUsage(m.DotNetName);
					GotoRegion(m.Region, m.DeclaringType.CompilationUnit.FileName);
				} else if (tag is FileLineReference) {
					FileLineReference flref = (FileLineReference)tag;
					if (flref.Line <= 0) {
						FileService.OpenFile(flref.FileName);
					} else {
						FileService.JumpToFilePosition(flref.FileName, flref.Line, flref.Column);
					}
				} else {
					throw new NotImplementedException("Unknown tag: " + tag);
				}
			} finally {
				Close();
			}
		}
Ejemplo n.º 2
0
 void okButtonClick(object sender, RoutedEventArgs e)
 {
     try {
         if (listBox.SelectedItem == null)
         {
             return;
         }
         object tag = ((GotoEntry)listBox.SelectedItem).Tag;
         if (tag is int)
         {
             ITextEditor editor = GetEditor();
             if (editor != null)
             {
                 int i = Math.Min(editor.Document.LineCount, Math.Max(1, (int)tag));
                 editor.JumpTo(i, int.MaxValue);
             }
         }
         else if (tag is IUnresolvedEntity)
         {
             IUnresolvedEntity c = tag as IUnresolvedEntity;
             CodeCompletionDataUsageCache.IncrementUsage(c.ReflectionName);
             GotoRegion(c.Region);
         }
         else if (tag is IEntity)
         {
             IEntity m = tag as IEntity;
             CodeCompletionDataUsageCache.IncrementUsage(m.ReflectionName);
             GotoRegion(m.Region);
         }
         else if (tag is FileLineReference)
         {
             FileLineReference flref = (FileLineReference)tag;
             if (flref.Line <= 0)
             {
                 FileService.OpenFile(flref.FileName);
             }
             else
             {
                 FileService.JumpToFilePosition(flref.FileName, flref.Line, flref.Column);
             }
         }
         else
         {
             throw new NotImplementedException("Unknown tag: " + tag);
         }
     } finally {
         Close();
     }
 }
        public void Complete(CompletionContext context)
        {
            if (context.Editor != this.textEditor)
            {
                throw new ArgumentException("wrong editor");
            }

            CodeCompletionDataUsageCache.IncrementUsage("snippet" + codeSnippet.Name);

            using (context.Editor.Document.OpenUndoGroup()) {
                if (context.CompletionChar == '\t' || AlwaysInsertSnippet)
                {
                    codeSnippet.TrackUsage("SnippetCompletionItem");

                    context.Editor.Document.Remove(context.StartOffset, context.Length);
                    CreateSnippet().Insert(textArea);
                }
                else
                {
                    context.Editor.Document.Replace(context.StartOffset, context.Length, this.Text);
                }
            }
        }
Ejemplo n.º 4
0
 public virtual void Complete(CompletionContext context)
 {
     context.Editor.Document.Replace(context.StartOffset, context.Length, this.CompletionText);
     context.EndOffset = context.StartOffset + this.CompletionText.Length;
     CodeCompletionDataUsageCache.IncrementUsage(DisplayText);
 }
 public override void Complete(CompletionContext context)
 {
     CodeCompletionDataUsageCache.IncrementUsage("keyword." + Text);
     base.Complete(context);
 }
Ejemplo n.º 6
0
 protected void MarkAsUsed()
 {
     CodeCompletionDataUsageCache.IncrementUsage(_entity.DotNetName);
 }