示例#1
0
        public IListDataProvider <string> GetCollections()
        {
            var result = new List <CodeTemplateVariableValue> ();
            var ext    = CurrentContext.Document.GetContent <CompletionTextEditorExtension> ();

            if (ext != null)
            {
                if (list == null)
                {
                    list = ext.CodeCompletionCommand(
                        CurrentContext.Document.GetContent <MonoDevelop.Ide.CodeCompletion.ICompletionWidget> ().CurrentCodeCompletionContext);
                }

                foreach (object o in list)
                {
                    var data = o as IEntityCompletionData;
                    if (data == null)
                    {
                        continue;
                    }

                    if (data.Entity is IMember)
                    {
                        var m = data.Entity as IMember;
                        if (GetElementType(m.ReturnType).Kind != TypeKind.Unknown)
                        {
                            if (m is IMethod)
                            {
                                if (((IMethod)m).Parameters.Count == 0)
                                {
                                    result.Add(new CodeTemplateVariableValue(m.Name + " ()", ((CompletionData)data).Icon));
                                }
                                continue;
                            }

                            result.Add(new CodeTemplateVariableValue(m.Name, ((CompletionData)data).Icon));
                        }
                    }
                }

                foreach (object o in list)
                {
                    var data = o as IEntityCompletionData;
                    if (data == null)
                    {
                        continue;
                    }
                    if (data.Entity is IParameter)
                    {
                        var m = data.Entity as IParameter;
                        if (GetElementType(m.Type).Kind != TypeKind.Unknown)
                        {
                            result.Add(new CodeTemplateVariableValue(m.Name, ((CompletionData)data).Icon));
                        }
                    }
                }

                foreach (object o in list)
                {
                    var data = o as IVariableCompletionData;
                    if (data == null)
                    {
                        continue;
                    }
                    var m = data.Variable;
                    if (GetElementType(m.Type).Kind != TypeKind.Unknown)
                    {
                        result.Add(new CodeTemplateVariableValue(m.Name, ((CompletionData)data).Icon));
                    }
                }
            }
            return(new CodeTemplateListDataProvider(result));
        }
		public IListDataProvider<string> GetCollections ()
		{
			var result = new List<CodeTemplateVariableValue> ();
			var ext = CurrentContext.Document.GetContent <CompletionTextEditorExtension> ();
			if (ext != null) {
				if (list == null)
					list = ext.CodeCompletionCommand (
						CurrentContext.Document.GetContent <MonoDevelop.Ide.CodeCompletion.ICompletionWidget> ().CurrentCodeCompletionContext);
				
				foreach (object o in list) {
					var data = o as IEntityCompletionData;
					if (data == null)
						continue;
					
					if (data.Entity is IMember) {
						var m = data.Entity as IMember;
						if (GetElementType (m.ReturnType).Kind != TypeKind.Unknown) {
							if (m is IMethod) {
								if (((IMethod)m).Parameters.Count == 0)
									result.Add (new CodeTemplateVariableValue (m.Name + " ()", ((CompletionData)data).Icon));
								continue;
							}

							result.Add (new CodeTemplateVariableValue (m.Name, ((CompletionData)data).Icon));
						}
					}
				}
				
				foreach (object o in list) {
					var data = o as IEntityCompletionData;
					if (data == null)
						continue;
					if (data.Entity is IParameter) {
						var m = data.Entity as IParameter;
						if (GetElementType (m.Type).Kind != TypeKind.Unknown)
							result.Add (new CodeTemplateVariableValue (m.Name, ((CompletionData)data).Icon));
					}
				}
				
				foreach (object o in list) {
					var data = o as IVariableCompletionData;
					if (data == null)
						continue;
					var m = data.Variable;
					if (GetElementType (m.Type).Kind != TypeKind.Unknown)
						result.Add (new CodeTemplateVariableValue (m.Name, ((CompletionData)data).Icon));
				}
			}
			return new CodeTemplateListDataProvider (result);
		}