public TypeCompletionData(IType type) : base(type.Name) { this.type = type; this.Image = ClassBrowserIconService.GetIcon(type); // don't set this.Description -- we use CreateFancyDescription() instead, // and accessing entity.Documentation in the constructor is too slow }
public MemberNode(IMethod method) { InitMemberNode(method); sortOrder = 10; Text = AppendReturnType(GetAmbience().Convert(method), method.ReturnType); SelectedImageIndex = ImageIndex = ClassBrowserIconService.GetIcon(method); }
public MemberNode(IField field) { InitMemberNode(field); sortOrder = 11; Text = AppendReturnType(GetAmbience().Convert(field), field.ReturnType); SelectedImageIndex = ImageIndex = ClassBrowserIconService.GetIcon(field); }
public MemberNode(IEvent e) { InitMemberNode(e); sortOrder = 14; Text = AppendReturnType(GetAmbience().Convert(e), e.ReturnType); SelectedImageIndex = ImageIndex = ClassBrowserIconService.GetIcon(e); }
public EntityCompletionData(IEntity entity) : base(entity.Name) { this.entity = entity; this.Image = ClassBrowserIconService.GetIcon(entity); // don't set this.Description -- we use CreateFancyDescription() instead, // and accessing entity.Documentation in the constructor is too slow }
public MemberNode(IProperty property) { InitMemberNode(property); sortOrder = 12; Text = AppendReturnType(GetAmbience().Convert(property), property.ReturnType); SelectedImageIndex = ImageIndex = ClassBrowserIconService.GetIcon(property); }
void FillMembersComboBox() { IClass c = GetCurrentSelectedClass(); if (c != null && lastClassInMembersComboBox != c) { lastClassInMembersComboBox = c; ArrayList items = new ArrayList(); bool partialMode = false; IClass currentPart = c; if (c.IsPartial) { CompoundClass cc = c.GetCompoundClass() as CompoundClass; if (cc != null) { partialMode = true; c = cc; } } lock (c) { int lastIndex = 0; IComparer comparer = new Comparer(System.Globalization.CultureInfo.InvariantCulture); foreach (IMethod m in c.Methods) { items.Add(new ComboBoxItem(m, m.Name, ClassBrowserIconService.GetIcon(m), partialMode ? currentPart.Methods.Contains(m) : true)); } items.Sort(lastIndex, c.Methods.Count, comparer); lastIndex = items.Count; foreach (IProperty p in c.Properties) { items.Add(new ComboBoxItem(p, p.Name, ClassBrowserIconService.GetIcon(p), partialMode ? currentPart.Properties.Contains(p) : true)); } items.Sort(lastIndex, c.Properties.Count, comparer); lastIndex = items.Count; foreach (IField f in c.Fields) { items.Add(new ComboBoxItem(f, f.Name, ClassBrowserIconService.GetIcon(f), partialMode ? currentPart.Fields.Contains(f) : true)); } items.Sort(lastIndex, c.Fields.Count, comparer); lastIndex = items.Count; foreach (IEvent evt in c.Events) { items.Add(new ComboBoxItem(evt, evt.Name, ClassBrowserIconService.GetIcon(evt), partialMode ? currentPart.Events.Contains(evt) : true)); } items.Sort(lastIndex, c.Events.Count, comparer); lastIndex = items.Count; } membersComboBox.BeginUpdate(); membersComboBox.Items.Clear(); membersComboBox.Items.AddRange(items.ToArray()); membersComboBox.EndUpdate(); UpdateMembersComboBox(); } }
void AddAllMembersMatchingText(IClass c, string text) { foreach (IClass innerClass in c.InnerClasses) { AddAllMembersMatchingText(innerClass, text); } foreach (IMethod m in c.Methods) { if (!m.IsConstructor) { AddItemIfMatchText(text, m, ClassBrowserIconService.GetIcon(m)); } } foreach (IField f in c.Fields) { AddItemIfMatchText(text, f, ClassBrowserIconService.GetIcon(f)); } foreach (IProperty p in c.Properties) { AddItemIfMatchText(text, p, ClassBrowserIconService.GetIcon(p)); } foreach (IEvent evt in c.Events) { AddItemIfMatchText(text, evt, ClassBrowserIconService.GetIcon(evt)); } }
public CodeCompletionItem(IEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } this.entity = entity; IAmbience ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags = entity is IClass ? ConversionFlags.ShowTypeParameterList : ConversionFlags.None; this.Text = ambience.Convert(entity); ambience.ConversionFlags = ConversionFlags.StandardConversionFlags; if (entity is IClass) { // Show fully qualified Type name (called UseFullyQualifiedMemberNames though) ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedMemberNames; } description = ambience.Convert(entity); this.Image = ClassBrowserIconService.GetIcon(entity); this.Overloads = 1; this.InsertGenericArguments = false; this.Priority = CodeCompletionDataUsageCache.GetPriority(entity.DotNetName, true); }
void AddClasses(ArrayList items, ICollection classes) { foreach (IClass c in classes) { items.Add(new ComboBoxItem(c, c.FullyQualifiedName, ClassBrowserIconService.GetIcon(c), true)); AddClasses(items, c.InnerClasses); } }
protected ContextActionViewModel MakeGoToClassAction(IClass @class, ObservableCollection <ContextActionViewModel> childActions) { return(new ContextActionViewModel { Action = new GoToClassAction(@class, this.LabelAmbience), Image = ClassBrowserIconService.GetIcon(@class).ImageSource, Comment = string.Format("(in {0})", @class.Namespace), ChildActions = childActions }); }
public OverrideCompletionData(IMethod method) : base(GetName(method, ConversionFlags.None), "override " + GetName(method, ConversionFlags.ShowReturnType | ConversionFlags.ShowAccessibility) + "\n\n" + method.Documentation, ClassBrowserIconService.GetIcon(method)) { this.member = method; }
IEnumerable <TreeNode> GetMembers(IEnumerable <IMember> members) { foreach (var memberInfo in members.OrderBy(m => m.Name)) { var memberInfoCopy = memberInfo; var icon = ClassBrowserIconService.GetIcon(memberInfo); yield return(new ValueNode(icon, memberInfo.Name, () => GetValue().GetMemberValue(WindowsDebugger.EvalThread, memberInfoCopy))); } }
void AddClasses(ArrayList items, ICollection <IClass> classes) { foreach (IClass c in classes) { IAmbience ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedMemberNames | ConversionFlags.ShowTypeParameterList; items.Add(new ComboBoxItem(c, ambience.Convert(c), ClassBrowserIconService.GetIcon(c), true)); AddClasses(items, c.InnerClasses); } }
public TypeCompletionData(IType type) : base(type.Name) { this.type = type; ITypeDefinition typeDef = type.GetDefinition(); if (typeDef != null) { this.Description = typeDef.Documentation; } this.Image = ClassBrowserIconService.GetIcon(type); }
public OverrideCompletionItem(IMember member) { if (member == null) { throw new ArgumentNullException("member"); } this.member = member; this.text = GetName(member, ConversionFlags.ShowParameterList); this.image = ClassBrowserIconService.GetIcon(member); }
public CodeCompletionData(IEvent e) { member = e; ambience = AmbienceService.CurrentAmbience; ambience.ConversionFlags = ConversionFlags.ShowReturnType | ConversionFlags.ShowParameterNames | ConversionFlags.ShowModifiers; imageIndex = ClassBrowserIconService.GetIcon(e); text = e.Name; description = ambience.Convert(e); documentation = e.Documentation; GetPriority(e.DotNetName); }
void AddAllExtensionMethodsMatchingText(IUnresolvedTypeDefinition c, string text) { foreach (IUnresolvedMember m in c.Members) { var defMethod = m as DefaultUnresolvedMethod; if ((defMethod != null) && defMethod.IsExtensionMethod) { AddItemIfMatchText(text, m, ClassBrowserIconService.GetIcon(m), false); } } }
public CodeCompletionData(IMember member) { this.entity = member; imageIndex = ClassBrowserIconService.GetIcon(member); IAmbience ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags = ConversionFlags.None; text = ambience.Convert(member); ambience.ConversionFlags = ConversionFlags.StandardConversionFlags; description = ambience.Convert(member); InitializePriority(member.DotNetName); }
public CodeCompletionData(IClass c) { IAmbience ambience = AmbienceService.GetCurrentAmbience(); // save class (for the delegate description shortcut) this.entity = c; imageIndex = ClassBrowserIconService.GetIcon(c); ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList; text = ambience.Convert(c); ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.UseFullyQualifiedMemberNames; description = ambience.Convert(c); InitializePriority(c.DotNetName); }
public CodeCompletionData(IClass c) { ambience = AmbienceService.CurrentAmbience; // save class (for the delegate description shortcut) this.c = c; imageIndex = ClassBrowserIconService.GetIcon(c); ambience.ConversionFlags = ConversionFlags.None; text = ambience.Convert(c); ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedNames | ConversionFlags.ShowReturnType | ConversionFlags.ShowModifiers; description = ambience.Convert(c); documentation = c.Documentation; GetPriority(c.DotNetName); }
void AddAllMembersMatchingText(IUnresolvedTypeDefinition c, string text, bool inCurrentFile) { foreach (IUnresolvedTypeDefinition innerClass in c.NestedTypes) { AddAllMembersMatchingText(innerClass, text, inCurrentFile); } foreach (IUnresolvedMember m in c.Members) { if (m.SymbolKind != SymbolKind.Constructor) { AddItemIfMatchText(text, m, ClassBrowserIconService.GetIcon(m), inCurrentFile); } } }
public ClassNode(IProject project, IClass c) { sortOrder = 3; this.ContextmenuAddinTreePath = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu"; this.project = project; this.c = c; Text = c.Name; SelectedImageIndex = ImageIndex = ClassBrowserIconService.GetIcon(c); if (c.ClassType != ClassType.Delegate) { Nodes.Add(new TreeNode()); } }
protected ContextActionViewModel MakeGoToMemberAction(IClass containingClass, ObservableCollection <ContextActionViewModel> childActions) { var overridenMember = MemberLookupHelper.FindSimilarMember(containingClass, this.member); if (overridenMember == null || overridenMember.Region.IsEmpty) { return(null); } return(new ContextActionViewModel { Action = new GoToMemberAction(overridenMember, this.LabelAmbience), Image = ClassBrowserIconService.GetIcon(overridenMember).ImageSource, Comment = string.Format("(in {0})", containingClass.FullyQualifiedName), ChildActions = childActions }); }
public EntityItem(IEntity entity, int typeCode) { this.IsInSamePart = true; this.entity = entity; this.typeCode = typeCode; IAmbience ambience = entity.ProjectContent.Language.GetAmbience(); if (entity is IClass) { ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.UseFullyQualifiedMemberNames; } else { ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames; } text = ambience.Convert(entity); image = ClassBrowserIconService.GetIcon(entity); }
public IEnumerable <object> BuildItems(Codon codon, object parameter) { IMember member = null; if (parameter is IMemberModel) { // Menu is directly created from a member model (e.g. bookmarks etc.) member = ((IMemberModel)parameter).Resolve(); } else if (parameter is ResolveResult) { MemberResolveResult resolveResult = parameter as MemberResolveResult; if (resolveResult != null) { member = resolveResult.Member; } } else if (parameter is ITextEditor) { // Shown in context menu of a text editor MemberResolveResult resolveResult = GetResolveResult((ITextEditor)parameter) as MemberResolveResult; if (resolveResult != null) { member = resolveResult.Member; } } if (member == null) { return(null); } IType declaringType = member.DeclaringTypeDefinition; if (declaringType == null) { return(null); } var items = new List <object>(); var declaringTypeItem = new MenuItem() { Header = SD.ResourceService.GetString("SharpDevelop.Refactoring.DeclaringType") + ": " + declaringType.Name, Icon = new Image() { Source = ClassBrowserIconService.GetIcon(declaringType).ImageSource } }; var subItems = MenuService.CreateMenuItems( null, new TypeResolveResult(declaringType), "/SharpDevelop/EntityContextMenu"); if (subItems != null) { foreach (var item in subItems) { declaringTypeItem.Items.Add(item); } } items.Add(declaringTypeItem); return(items); }
public override void Draw(IconBarMargin margin, Graphics g, Point p) { g.DrawImageUnscaled(ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GetIcon(@class)], p); }
void AddItem(IUnresolvedTypeDefinition c, int matchType, bool inCurrentFile) { AddItem(c, ClassBrowserIconService.GetIcon(c), matchType, inCurrentFile); }
public ToolStripItem[] BuildSubmenu(Codon codon, object owner) { ToolStripMenuItem item; TextEditorControl textEditorControl = (TextEditorControl)owner; if (textEditorControl.FileName == null) { return(new ToolStripItem[0]); } List <ToolStripItem> resultItems = new List <ToolStripItem>(); TextArea textArea = textEditorControl.ActiveTextAreaControl.TextArea; IDocument doc = textArea.Document; int caretLine = textArea.Caret.Line; // list of dotnet names that have definition bookmarks in this line List <string> definitions = new List <string>(); // Include definitions (use the bookmarks which should already be present) foreach (Bookmark mark in doc.BookmarkManager.Marks) { if (mark != null && mark.LineNumber == caretLine) { ClassMemberBookmark cmb = mark as ClassMemberBookmark; ClassBookmark cb = mark as ClassBookmark; IClass type = null; if (cmb != null) { definitions.Add(cmb.Member.DotNetName); item = new ToolStripMenuItem(MemberNode.GetText(cmb.Member), ClassBrowserIconService.ImageList.Images[cmb.IconIndex]); MenuService.AddItemsToMenu(item.DropDown.Items, mark, ClassMemberBookmark.ContextMenuPath); resultItems.Add(item); type = cmb.Member.DeclaringType; } else if (cb != null) { type = cb.Class; } if (type != null) { definitions.Add(type.DotNetName); item = new ToolStripMenuItem(type.Name, ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GetIcon(type)]); MenuService.AddItemsToMenu(item.DropDown.Items, cb ?? new ClassBookmark(textArea.Document, type), ClassBookmark.ContextMenuPath); resultItems.Add(item); } } } // Include menu for member that has been clicked on IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(textEditorControl.FileName); ExpressionResult expressionResult; ResolveResult rr; int insertIndex = resultItems.Count; // Insert items at this position to get the outermost expression first, followed by the inner expressions (if any). expressionResult = FindFullExpressionAtCaret(textArea, expressionFinder); repeatResolve: rr = ResolveExpressionAtCaret(textArea, expressionResult); item = null; if (rr is MethodResolveResult) { item = MakeItem(definitions, ((MethodResolveResult)rr).GetMethodIfSingleOverload()); } else if (rr is MemberResolveResult) { MemberResolveResult mrr = (MemberResolveResult)rr; item = MakeItem(definitions, mrr.ResolvedMember); if (RefactoringService.FixIndexerExpression(expressionFinder, ref expressionResult, mrr)) { if (item != null) { resultItems.Insert(insertIndex, item); } // Include menu for the underlying expression of the // indexer expression as well. goto repeatResolve; } } else if (rr is TypeResolveResult) { item = MakeItem(definitions, ((TypeResolveResult)rr).ResolvedClass); } else if (rr is LocalResolveResult) { item = MakeItem((LocalResolveResult)rr, caretLine + 1 == ((LocalResolveResult)rr).Field.Region.BeginLine); insertIndex = 0; // Insert local variable menu item at the topmost position. } if (item != null) { resultItems.Insert(insertIndex, item); } // Include menu for current class and method IMember callingMember = null; if (rr != null) { callingMember = rr.CallingMember; } else { ParseInformation parseInfo = ParserService.GetParseInformation(textEditorControl.FileName); if (parseInfo != null) { ICompilationUnit cu = parseInfo.MostRecentCompilationUnit; if (cu != null) { IClass callingClass = cu.GetInnermostClass(caretLine + 1, textArea.Caret.Column + 1); callingMember = GetCallingMember(callingClass, caretLine + 1, textArea.Caret.Column + 1); } } } if (callingMember != null) { item = MakeItem(definitions, callingMember); if (item != null) { item.Text = StringParser.Parse("${res:SharpDevelop.Refactoring.CurrentMethod}: ") + callingMember.Name; resultItems.Add(item); } } if (resultItems.Count == 0) { return(new ToolStripItem[0]); } else { resultItems.Add(new MenuSeparator()); return(resultItems.ToArray()); } }
public OverrideCompletionData(IProperty property) : base(property.Name, "override " + property.Name + "\n\n" + CodeCompletionData.ConvertDocumentation(property.Documentation), ClassBrowserIconService.GetIcon(property)) { this.member = property; }