当前位置: 首页>>代码示例>>C#>>正文


C# ProjectDomCompletionDataList.Add方法代码示例

本文整理汇总了C#中MonoDevelop.Ide.CodeCompletion.ProjectDomCompletionDataList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectDomCompletionDataList.Add方法的具体用法?C# ProjectDomCompletionDataList.Add怎么用?C# ProjectDomCompletionDataList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MonoDevelop.Ide.CodeCompletion.ProjectDomCompletionDataList的用法示例。


在下文中一共展示了ProjectDomCompletionDataList.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDefineCompletionData

		CompletionDataList GetDefineCompletionData ()
		{
			if (Document.Project == null)
				return null;

			Dictionary<string, string> symbols = new Dictionary<string, string> ();
			CompletionDataList cp = new ProjectDomCompletionDataList ();
			foreach (DotNetProjectConfiguration conf in Document.Project.Configurations) {
				CSharpCompilerParameters cparams = conf.CompilationParameters as CSharpCompilerParameters;
				if (cparams != null) {
					string[] syms = cparams.DefineSymbols.Split (';');
					foreach (string s in syms) {
						string ss = s.Trim ();
						if (ss.Length > 0 && !symbols.ContainsKey (ss)) {
							symbols [ss] = ss;
							cp.Add (ss, "md-literal");
						}
					}
				}
			}
			return cp;
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:22,代码来源:CSharpTextEditorCompletion.cs

示例2: GetPartialCompletionData

		CompletionDataList GetPartialCompletionData (CodeCompletionContext ctx, IType type, string modifiers)
		{
			CompletionDataList result = new ProjectDomCompletionDataList ();

			CompoundType partialType = dom.GetType (type.FullName) as CompoundType;
			if (partialType != null) {
				List<IMethod> methods = new List<IMethod> ();
				// gather all partial methods without implementation
				foreach (IType part in partialType.Parts) {
					if (part.Location == type.Location && part.CompilationUnit.FileName == type.CompilationUnit.FileName)
						continue;
					foreach (IMethod method in part.Methods) {
						if (method.IsPartial && method.BodyRegion.End.Line == 0 && !ContainsDeclaration (type, method)) {
							methods.Add (method);
						}
					}
				}

				// now filter all methods that are implemented in the compound class
				foreach (IType part in partialType.Parts) {
					if (part.Location == type.Location && part.CompilationUnit.FileName == type.CompilationUnit.FileName)
						continue;
					for (int i = 0; i < methods.Count; i++) {
						IMethod curMethod = methods[i];
						IMethod method = GetDeclaration (part, curMethod);
						if (method != null && method.BodyRegion.End.Line != 0) {
							methods.RemoveAt (i);
							i--;
							continue;
						}
					}
				}

				foreach (IMethod method in methods) {
					NewOverrideCompletionData data = new NewOverrideCompletionData (dom, textEditorData, ctx.TriggerOffset, type, method);
					data.GenerateBody = false;
					result.Add (data);
				}
				
			}
			return result;
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:42,代码来源:CSharpTextEditorCompletion.cs

示例3: CreateTypeCompletionData

		CompletionDataList CreateTypeCompletionData (DomLocation location, IType callingType, ExpressionContext context, IReturnType returnType, IReturnType returnTypeUnresolved)
		{
			CompletionDataList result = new ProjectDomCompletionDataList ();
			// "var o = new " needs special treatment.
			if (returnType == null && returnTypeUnresolved != null && returnTypeUnresolved.FullName == "var")
				returnType = returnTypeUnresolved = DomReturnType.Object;

			//	ExpressionContext.TypeExpressionContext tce = context as ExpressionContext.TypeExpressionContext;

			CompletionDataCollector col = new CompletionDataCollector (dom, result, Document.CompilationUnit, callingType, location);
			IType type = null;
			if (returnType != null)
				type = dom.GetType (returnType);
			if (type == null)
				type = dom.SearchType (Document.CompilationUnit, (MonoDevelop.Projects.Dom.INode)Document.CompilationUnit ?? callingType, returnTypeUnresolved);
			
			// special handling for nullable types: Bug 674516 - new completion for nullables should not include "Nullable"
			if (type is InstantiatedType && ((InstantiatedType)type).UninstantiatedType.FullName == "System.Nullable" && ((InstantiatedType)type).GenericParameters.Count == 1) {
				var genericParameter = ((InstantiatedType)type).GenericParameters[0];
				returnType = returnTypeUnresolved = Document.CompilationUnit.ShortenTypeName (genericParameter, location);
				type = dom.SearchType (Document.CompilationUnit, (MonoDevelop.Projects.Dom.INode)Document.CompilationUnit ?? callingType, genericParameter);
			}
			
			if (type == null || !(type.IsAbstract || type.ClassType == ClassType.Interface)) {
				if (type == null || type.ConstructorCount == 0 || type.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, callingType, type, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == type.FullName)))) {
					if (returnTypeUnresolved != null) {
						col.FullyQualify = true;
						CompletionData unresovedCompletionData = col.Add (returnTypeUnresolved);
						col.FullyQualify = false;
						// don't set default completion string for arrays, since it interferes with: 
						// string[] arr = new string[] vs new { "a"}
						if (returnTypeUnresolved.ArrayDimensions == 0)
							result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText);
					} else {
						CompletionData unresovedCompletionData = col.Add (returnType);
						if (returnType.ArrayDimensions == 0)
							result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText);
					}
				}
			}
			
			//				if (tce != null && tce.Type != null) {
			//					result.DefaultCompletionString = StripGenerics (col.AddCompletionData (result, tce.Type).CompletionString);
			//				} 
			//			else {
			//			}
			if (type == null)
				return result;
			HashSet<string> usedNamespaces = new HashSet<string> (GetUsedNamespaces ());
			if (type.FullName == DomReturnType.Object.FullName) 
				AddPrimitiveTypes (col);
			
			foreach (IType curType in dom.GetSubclasses (type)) {
				if (context != null && context.FilterEntry (curType))
					continue;
				if ((curType.TypeModifier & TypeModifier.HasOnlyHiddenConstructors) == TypeModifier.HasOnlyHiddenConstructors)
					continue;
				if (usedNamespaces.Contains (curType.Namespace)) {
					if (curType.ConstructorCount > 0) {
						if (!(curType.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, curType, callingType, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == curType.FullName)))))
							continue;
					}
					col.Add (curType);
				} else {
					string nsName = curType.Namespace;
					int idx = nsName.IndexOf ('.');
					if (idx >= 0)
						nsName = nsName.Substring (0, idx);
					col.Add (new Namespace (nsName));
				}
			}
			
			// add aliases
			if (returnType != null) {
				foreach (IUsing u in Document.CompilationUnit.Usings) {
					foreach (KeyValuePair<string, IReturnType> alias in u.Aliases) {
						if (alias.Value.ToInvariantString () == returnType.ToInvariantString ())
							result.Add (alias.Key, "md-class");
					}
				}
			}
			return result;
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:83,代码来源:CSharpTextEditorCompletion.cs

示例4: HandleCodeCompletion


//.........这里部分代码省略.........
						if (!String.IsNullOrEmpty (tag) && commentTags.IndexOf (tag) >= 0) {
							textEditorData.Insert (cursor, "</" + tag + ">");
							textEditorData.Caret.Offset = cursor; 
							return null;
						}
					}
				}
				return null;
/* Disabled because it gives problems when declaring arrays - for example string [] should not pop up code completion.
 			case '[':
				if (stateTracker.Engine.IsInsideDocLineComment || stateTracker.Engine.IsInsideOrdinaryCommentOrString)
					return null;
				result = FindExpression (dom, completionContext);
				if (result.ExpressionContext == ExpressionContext.Attribute)
					return CreateCtrlSpaceCompletionData (completionContext, result);
				return null;*/
			case '<':
				if (stateTracker.Engine.IsInsideDocLineComment) 
					return GetXmlDocumentationCompletionData ();
				return null;
			case '(':
				if (stateTracker.Engine.IsInsideDocLineComment || stateTracker.Engine.IsInsideOrdinaryCommentOrString)
					return null;
				result = FindExpression (dom, completionContext, -1);
				if (result == null || result.Expression == null)
					return null;
				resolver = CreateResolver ();
				resolveResult = resolver.Resolve (result, new DomLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset - 2));
				
				if (resolveResult != null && resolver.ResolvedExpression is ICSharpCode.NRefactory.Ast.TypeOfExpression) {
					CompletionDataList completionList = new ProjectDomCompletionDataList ();
					
					CompletionDataCollector col = new CompletionDataCollector (dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
					AddPrimitiveTypes (col);
					foreach (object o in dom.GetNamespaceContents (GetUsedNamespaces (), true, true)) {
						col.Add (o);
					}
					if (resolver.CallingMember is IMethod) {
						foreach (ITypeParameter tp in ((IMethod)resolver.CallingMember).TypeParameters) {
							col.Add (tp.Name, "md-keyword");
						}
					}
					if (resolver.CallingType != null) {
						foreach (ITypeParameter tp in resolver.CallingType.TypeParameters) {
							col.Add (tp.Name, "md-keyword");
						}
					}
					return completionList;
				}
				return null;
			case '/':
				cursor = textEditorData.IsSomethingSelected ? textEditorData.SelectionRange.Offset : textEditorData.Caret.Offset;
				if (cursor < 2)
					break;
					
				if (stateTracker.Engine.IsInsideDocLineComment) {
					string lineText = textEditorData.GetLineText (completionContext.TriggerLine);
					bool startsDocComment = true;
					int slashes = 0;
					for (int i = 0; i < completionContext.TriggerLineOffset && i < lineText.Length; i++) {
						if (lineText[i] == '/') {
							slashes++;
							continue;
						}
						if (!Char.IsWhiteSpace (lineText[i])) {
							startsDocComment = false;
开发者ID:famousthom,项目名称:monodevelop,代码行数:67,代码来源:CSharpTextEditorCompletion.cs

示例5: CreateParameterCompletion

		public CompletionDataList CreateParameterCompletion (NRefactoryResolver resolver, DomLocation location, ExpressionContext context, IEnumerable<IMethod> possibleMethods, int parameter)
		{
			CompletionDataList completionList = new ProjectDomCompletionDataList ();
			var addedEnums = new HashSet<string> ();
			var addedDelegates = new HashSet<string> ();
			IType resolvedType = null;
			foreach (var method in possibleMethods) {
				if (method.Parameters.Count <= parameter)
					continue;
				resolvedType = dom.GetType (method.Parameters [parameter].ReturnType);
				if (resolvedType == null)
					continue;
				switch (resolvedType.ClassType) {
				case MonoDevelop.Projects.Dom.ClassType.Enum:
					if (addedEnums.Contains (resolvedType.DecoratedFullName))
						continue;
					addedEnums.Add (resolvedType.DecoratedFullName);
					AddEnumMembers (completionList, resolvedType);
					break;
				case MonoDevelop.Projects.Dom.ClassType.Delegate:
					if (addedDelegates.Contains (resolvedType.DecoratedFullName))
						continue;
					addedDelegates.Add (resolvedType.DecoratedFullName);
					string parameterDefinition = AddDelegateHandlers (completionList, resolvedType, false, addedDelegates.Count == 1);
					string varName = "Handle" + method.Parameters [parameter].ReturnType.Name + method.Parameters [parameter].Name;
					completionList.Add (new EventCreationCompletionData (textEditorData, varName, resolvedType, null, parameterDefinition, resolver.Unit.GetMemberAt (location), resolvedType) { AddSemicolon = false });
					break;
				}
			}
			if (addedEnums.Count + addedDelegates.Count == 0)
				return null;
			CompletionDataCollector cdc = new CompletionDataCollector (this, dom, completionList, Document.CompilationUnit, resolver.CallingType, location);
			completionList.AutoCompleteEmptyMatch = false;
			completionList.AutoSelect = false;
			resolver.AddAccessibleCodeCompletionData (ExpressionContext.MethodBody, cdc);
			if (addedDelegates.Count > 0) {
				foreach (var data in completionList) {
					if (data is MemberCompletionData) 
						((MemberCompletionData)data).IsDelegateExpected = true;
				}
			}
			return completionList;
		}
开发者ID:rohdef,项目名称:monodevelop,代码行数:43,代码来源:CSharpTextEditorCompletion.cs


注:本文中的MonoDevelop.Ide.CodeCompletion.ProjectDomCompletionDataList.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。