IEnumerable <ICompletionData> ICompletionDataFactory.CreateCodeTemplateCompletionData() { var result = new CompletionDataList(); CodeTemplateService.AddCompletionDataForMime("text/x-csharp", result); return(result); }
public CSharpTextEditorCompletion.CompletionDataCollector AddAccessibleCodeCompletionData(ExpressionContext context, CSharpTextEditorCompletion.CompletionDataCollector col) { if (context != ExpressionContext.Global && context != ExpressionContext.TypeName) { AddContentsFromClassAndMembers(context, col); if (lookupTableVisitor != null && lookupTableVisitor.Variables != null) { // int callingMemberline = CallingMember != null ? CallingMember.Location.Line : 0; // local variables could be outside members (LINQ initializers) foreach (KeyValuePair <string, List <LocalLookupVariable> > pair in lookupTableVisitor.Variables) { if (pair.Value != null && pair.Value.Count > 0) { foreach (LocalLookupVariable v in pair.Value) { DomLocation varStartPos = new DomLocation(lookupVariableLine + v.StartPos.Line, v.StartPos.Column - 1); DomLocation varEndPos = new DomLocation(lookupVariableLine + v.EndPos.Line, v.EndPos.Column - 1); if (varStartPos > this.resolvePosition || (!v.EndPos.IsEmpty && varEndPos < this.resolvePosition)) { continue; } col.Add(new LocalVariable(CallingMember, pair.Key, ConvertTypeReference(v.TypeRef), DomRegion.Empty)); } } } } if (CallingMember is IProperty) { IProperty property = (IProperty)callingMember; if (property.HasSet && editor != null && property.SetRegion.Contains(resolvePosition.Line, editor.CursorColumn)) { col.Add("value"); } } if (CallingMember is IEvent) { col.Add("value"); } } List <string> namespaceList = new List <string> (); namespaceList.Add(""); List <string> namespaceDeclList = new List <string> (); namespaceDeclList.Add(""); if (unit != null) { foreach (IUsing u in unit.Usings) { foreach (string alias in u.Aliases.Keys) { col.Add(alias); } if (u.Namespaces == null) { continue; } bool isNamespaceDecl = u.IsFromNamespace && u.Region.Contains(this.resolvePosition); if (u.IsFromNamespace && !isNamespaceDecl) { continue; } foreach (string ns in u.Namespaces) { namespaceList.Add(ns); if (isNamespaceDecl) { namespaceDeclList.Add(ns); } } } foreach (object o in dom.GetNamespaceContents(namespaceList, true, true)) { if (context.FilterEntry(o)) { continue; } if (o is Namespace) { Namespace ns = o as Namespace; bool skip = true; foreach (string str in namespaceDeclList) { if (dom.NamespaceExists(str.Length > 0 ? str + "." + ns.Name : ns.Name)) { skip = false; break; } } if (skip) { continue; } } //IMember member = o as IMember; //if (member != null && completionList.Find (member.Name) != null) // continue; if (context == ExpressionContext.Attribute) { IType t = o as IType; if (t != null && !t.IsBaseType(attributeType)) { continue; } } CompletionData data = col.Add(o); if (data != null && context == ExpressionContext.Attribute && data.CompletionText != null && data.CompletionText.EndsWith("Attribute")) { string newText = data.CompletionText.Substring(0, data.CompletionText.Length - "Attribute".Length); data.SetText(newText); } } CodeTemplateService.AddCompletionDataForMime("text/x-csharp", col.CompletionList); } return(col); }