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


C# CompletionDataWrapper.AddTypeParameter方法代码示例

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


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

示例1: AddContextCompletion

		void AddContextCompletion(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node)
		{
			int i = offset - 1;
			var isInGlobalDelegate = node == null && state.CurrentTypeDefinition == null && GetPreviousToken(ref i, true) == "delegate";

			if (state != null && !(node is AstType)) {
				foreach (var variable in state.LocalVariables) {
					if (variable.Region.IsInside(location.Line, location.Column - 1)) {
						continue;
					}
					wrapper.AddVariable(variable);
				}
			}

			if (state.CurrentMember is IParameterizedMember && !(node is AstType)) {
				var param = (IParameterizedMember)state.CurrentMember;
				foreach (var p in param.Parameters) {
					wrapper.AddVariable(p);
				}
			}

			if (state.CurrentMember is IMethod) {
				var method = (IMethod)state.CurrentMember;
				foreach (var p in method.TypeParameters) {
					wrapper.AddTypeParameter(p);
				}
			}

			Func<IType, IType> typePred = null;
			if (IsAttributeContext(node)) {
				var attribute = Compilation.FindType(KnownTypeCode.Attribute);
				typePred = t => t.GetAllBaseTypeDefinitions().Any(bt => bt.Equals(attribute)) ? t : null;
			}
			if (node != null && node.Role == Roles.BaseType) {
				typePred = t => {
					var def = t.GetDefinition();
					if (def != null && t.Kind != TypeKind.Interface && (def.IsSealed || def.IsStatic))
						return null;
					return t;
				};
			}

			if (node != null && !(node is NamespaceDeclaration) || state.CurrentTypeDefinition != null || isInGlobalDelegate) {
				AddTypesAndNamespaces(wrapper, state, node, typePred);

				wrapper.Result.Add(factory.CreateLiteralCompletionData("global"));
			}

			if (!(node is AstType)) {
				if (currentMember != null || node is Expression) {
					AddKeywords(wrapper, statementStartKeywords);
					if (LanguageVersion.Major >= 5)
						AddKeywords(wrapper, new [] { "await" });
					AddKeywords(wrapper, expressionLevelKeywords);
					if (node == null || node is TypeDeclaration)
						AddKeywords(wrapper, typeLevelKeywords);
				} else if (currentType != null) {
					AddKeywords(wrapper, typeLevelKeywords);
				} else {
					if (!isInGlobalDelegate && !(node is Attribute))
						AddKeywords(wrapper, globalLevelKeywords);
				}
				var prop = currentMember as IUnresolvedProperty;
				if (prop != null && prop.Setter != null && prop.Setter.Region.IsInside(location)) {
					wrapper.AddCustom("value");
				} 
				if (currentMember is IUnresolvedEvent) {
					wrapper.AddCustom("value");
				} 

				if (IsInSwitchContext(node)) {
					if (IncludeKeywordsInCompletionList)
						wrapper.AddCustom("case"); 
				}
			} else {
				if (((AstType)node).Parent is ParameterDeclaration) {
					AddKeywords(wrapper, parameterTypePredecessorKeywords);
				}
			}

			if (node != null || state.CurrentTypeDefinition != null || isInGlobalDelegate)
				AddKeywords(wrapper, primitiveTypesKeywords);
			if (currentMember != null && (node is IdentifierExpression || node is SimpleType) && (node.Parent is ExpressionStatement || node.Parent is ForeachStatement || node.Parent is UsingStatement)) {
				if (IncludeKeywordsInCompletionList) {
					wrapper.AddCustom("var");
					wrapper.AddCustom("dynamic");
				}
			} 
			wrapper.Result.AddRange(factory.CreateCodeTemplateCompletionData());
			if (node != null && node.Role == Roles.Argument) {
				var resolved = ResolveExpression(node.Parent);
				var invokeResult = resolved != null ? resolved.Result as CSharpInvocationResolveResult : null;
				if (invokeResult != null) {
					int argNum = 0;
					foreach (var arg in node.Parent.Children.Where (c => c.Role == Roles.Argument)) {
						if (arg == node) {
							break;
						}
						argNum++;
					}
//.........这里部分代码省略.........
开发者ID:pentp,项目名称:SharpDevelop,代码行数:101,代码来源:CSharpCompletionEngine.cs

示例2: AddTypesAndNamespaces

		void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func<IType, IType> typePred = null, Predicate<IMember> memberPred = null, Action<ICompletionData, IType> callback = null, bool onlyAddConstructors = false)
		{
			var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);

			if (currentType != null) {
				for (var ct = ctx.CurrentTypeDefinition; ct != null; ct = ct.DeclaringTypeDefinition) {
					foreach (var nestedType in ct.GetNestedTypes ()) {
						if (!lookup.IsAccessible(nestedType.GetDefinition(), true))
							continue;
						if (onlyAddConstructors) {
							if (!nestedType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
								continue;
						}

						if (typePred == null) {
							if (onlyAddConstructors)
								wrapper.AddConstructors(nestedType, false, IsAttributeContext(node));
							else
								wrapper.AddType(nestedType, false, IsAttributeContext(node));
							continue;
						}

						var type = typePred(nestedType);
						if (type != null) {
							var a2 = onlyAddConstructors ? wrapper.AddConstructors(type, false, IsAttributeContext(node)) : wrapper.AddType(type, false, IsAttributeContext(node));
							if (a2 != null && callback != null) {
								callback(a2, type);
							}
						}
						continue;
					}
				}

				if (this.currentMember != null && !(node is AstType)) {
					var def = ctx.CurrentTypeDefinition;
					if (def == null && currentType != null)
						def = Compilation.MainAssembly.GetTypeDefinition(currentType.FullTypeName);
					if (def != null) {
						bool isProtectedAllowed = true;

						foreach (var member in def.GetMembers (m => currentMember.IsStatic ? m.IsStatic : true)) {
							if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") {
								continue;
							}
							if (member.SymbolKind == SymbolKind.Operator) {
								continue;
							}
							if (member.IsExplicitInterfaceImplementation) {
								continue;
							}
							if (!lookup.IsAccessible(member, isProtectedAllowed)) {
								continue;
							}
							if (memberPred == null || memberPred(member)) {
								wrapper.AddMember(member);
							}
						}
						var declaring = def.DeclaringTypeDefinition;
						while (declaring != null) {
							foreach (var member in declaring.GetMembers (m => m.IsStatic)) {
								if (memberPred == null || memberPred(member)) {
									wrapper.AddMember(member);
								}
							}
							declaring = declaring.DeclaringTypeDefinition;
						}
					}
				}
				if (ctx.CurrentTypeDefinition != null) {
					foreach (var p in ctx.CurrentTypeDefinition.TypeParameters) {
						wrapper.AddTypeParameter(p);
					}
				}
			}
			var scope = ctx.CurrentUsingScope;

			for (var n = scope; n != null; n = n.Parent) {
				foreach (var pair in n.UsingAliases) {
					wrapper.AddAlias(pair.Key);
				}
				foreach (var alias in n.ExternAliases) {
					wrapper.AddAlias(alias);
				}
				foreach (var u in n.Usings) {
					foreach (var type in u.Types) {
						if (!lookup.IsAccessible(type, false))
							continue;

						IType addType = typePred != null ? typePred(type) : type;

						if (onlyAddConstructors && addType != null) {
							if (!addType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
								continue;
						}

						if (addType != null) {
							var a = onlyAddConstructors ? wrapper.AddConstructors(addType, false, IsAttributeContext(node)) : wrapper.AddType(addType, false, IsAttributeContext(node));
							if (a != null && callback != null) {
								callback(a, type);
							}
//.........这里部分代码省略.........
开发者ID:pentp,项目名称:SharpDevelop,代码行数:101,代码来源:CSharpCompletionEngine.cs

示例3: AddContextCompletion

		void AddContextCompletion(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, CompilationUnit unit)
		{
			if (state != null && !(node is AstType)) {
				foreach (var variable in state.LocalVariables) {
					if (variable.Region.IsInside(location.Line, location.Column - 1)) {
						continue;
					}
					wrapper.AddVariable(variable);
				}
			}
			
			if (currentMember is IUnresolvedParameterizedMember && !(node is AstType)) {
				var param = (IParameterizedMember)currentMember.CreateResolved(ctx);
				foreach (var p in param.Parameters) {
					wrapper.AddVariable(p);
				}
			}
			
			if (currentMember is IUnresolvedMethod) {
				var method = (IUnresolvedMethod)currentMember;
				foreach (var p in method.TypeParameters) {
					wrapper.AddTypeParameter(p);
				}
			}
			
			Func<IType, IType> typePred = null;
			if (IsAttributeContext(node)) {
				var attribute = Compilation.FindType(KnownTypeCode.Attribute);
				typePred = t => {
					return t.GetAllBaseTypeDefinitions().Any(bt => bt.Equals(attribute)) ? t : null;
				};
			}
			AddTypesAndNamespaces(wrapper, state, node, typePred);
			
			wrapper.Result.Add(factory.CreateLiteralCompletionData("global"));
			
			if (!(node is AstType)) {
				if (currentMember != null || node is Expression) {
					AddKeywords(wrapper, statementStartKeywords);
					AddKeywords(wrapper, expressionLevelKeywords);
					if (node is TypeDeclaration)
						AddKeywords(wrapper, typeLevelKeywords);
				} else if (currentType != null) {
					AddKeywords(wrapper, typeLevelKeywords);
				} else {
					AddKeywords(wrapper, globalLevelKeywords);
				}
				var prop = currentMember as IUnresolvedProperty;
				if (prop != null && prop.Setter != null && prop.Setter.Region.IsInside(location)) {
					wrapper.AddCustom("value");
				} 
				if (currentMember is IUnresolvedEvent) {
					wrapper.AddCustom("value");
				} 
				
				if (IsInSwitchContext(node)) {
					wrapper.AddCustom("case"); 
				}
			} else {
				if (((AstType)node).Parent is ParameterDeclaration) {
					AddKeywords(wrapper, parameterTypePredecessorKeywords);
				}
			}

			AddKeywords(wrapper, primitiveTypesKeywords);
			if (currentMember != null) {
				wrapper.AddCustom("var");
			} 
			wrapper.Result.AddRange(factory.CreateCodeTemplateCompletionData());
			
			if (node != null && node.Role == Roles.Argument) {
				var resolved = ResolveExpression(node.Parent, unit);
				var invokeResult = resolved != null ? resolved.Item1 as CSharpInvocationResolveResult : null;
				if (invokeResult != null) {
					int argNum = 0;
					foreach (var arg in node.Parent.Children.Where (c => c.Role == Roles.Argument)) {
						if (arg == node) {
							break;
						}
						argNum++;
					}
					var param = argNum < invokeResult.Member.Parameters.Count ? invokeResult.Member.Parameters [argNum] : null;
					if (param != null && param.Type.Kind == TypeKind.Enum) {
						AddEnumMembers(wrapper, param.Type, state);
					}
				}
			}
			
			if (node is Expression) {
				var astResolver = new CSharpAstResolver(state, unit, CSharpParsedFile);
				foreach (var type in CreateFieldAction.GetValidTypes(astResolver, (Expression)node)) {
					if (type.Kind == TypeKind.Enum) {
						AddEnumMembers(wrapper, type, state);
					} else if (type.Kind == TypeKind.Delegate) {
						AddDelegateHandlers(wrapper, type, true, true);
						AutoSelect = false;
						AutoCompleteEmptyMatch = false;
					}
				}
			}
//.........这里部分代码省略.........
开发者ID:DavidS,项目名称:monodevelop,代码行数:101,代码来源:CSharpCompletionEngine.cs

示例4: AddTypesAndNamespaces

		void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func<IType, IType> typePred = null, Predicate<IMember> memberPred = null, Action<ICompletionData, IType> callback = null)
		{
			var lookup = new MemberLookup(
				ctx.CurrentTypeDefinition,
				Compilation.MainAssembly
			);
			if (currentType != null) {
				for (var ct = currentType; ct != null; ct = ct.DeclaringTypeDefinition) {
					foreach (var nestedType in ct.NestedTypes) {
						string name = nestedType.Name;
						if (IsAttributeContext(node) && name.EndsWith("Attribute") && name.Length > "Attribute".Length) {
							name = name.Substring(0, name.Length - "Attribute".Length);
						}

						if (typePred == null) {
							wrapper.AddType(nestedType, name);
							continue;
						}

						var type = typePred(nestedType.Resolve(ctx));
						if (type != null) {
							var a2 = wrapper.AddType(type, name);
							if (a2 != null && callback != null) {
								callback(a2, type);
							}
						}
						continue;
					}
				}
				if (this.currentMember != null && !(node is AstType)) {
					var def = ctx.CurrentTypeDefinition ?? Compilation.MainAssembly.GetTypeDefinition(currentType);
					if (def != null) {
						bool isProtectedAllowed = true;
						foreach (var member in def.GetMembers ()) {
							if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") {
								continue;
							}
							if (member.EntityType == EntityType.Operator) {
								continue;
							}
							if (member.IsExplicitInterfaceImplementation) {
								continue;
							}
							if (!lookup.IsAccessible(member, isProtectedAllowed)) {
								continue;
							}

							if (memberPred == null || memberPred(member)) {
								wrapper.AddMember(member);
							}
						}
						var declaring = def.DeclaringTypeDefinition;
						while (declaring != null) {
							foreach (var member in declaring.GetMembers (m => m.IsStatic)) {
								if (memberPred == null || memberPred(member)) {
									wrapper.AddMember(member);
								}
							}
							declaring = declaring.DeclaringTypeDefinition;
						}
					}
				}
				foreach (var p in currentType.TypeParameters) {
					wrapper.AddTypeParameter(p);
				}
			}
			var scope = CSharpParsedFile.GetUsingScope(location).Resolve(Compilation);
			
			for (var n = scope; n != null; n = n.Parent) {
				foreach (var pair in n.UsingAliases) {
					wrapper.AddNamespace(pair.Key);
				}
				foreach (var u in n.Usings) {
					foreach (var type in u.Types) {
						if (!lookup.IsAccessible(type, false))
							continue;

						IType addType = typePred != null ? typePred(type) : type;
						if (addType != null) {
							string name = type.Name;
							if (IsAttributeContext(node) && name.EndsWith("Attribute") && name.Length > "Attribute".Length) {
								name = name.Substring(0, name.Length - "Attribute".Length);
							}
							var a = wrapper.AddType(addType, name);
							if (a != null && callback != null) {
								callback(a, type);
							}
						}
					}
				}
				
				foreach (var type in n.Namespace.Types) {
					if (!lookup.IsAccessible(type, false))
						continue;
					IType addType = typePred != null ? typePred(type) : type;
					if (addType != null) {
						var a2 = wrapper.AddType(addType, addType.Name);
						if (a2 != null && callback != null) {
							callback(a2, type);
						}
//.........这里部分代码省略.........
开发者ID:DavidS,项目名称:monodevelop,代码行数:101,代码来源:CSharpCompletionEngine.cs

示例5: AddTypesAndNamespaces

        void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func<IType, IType> typePred = null, Predicate<IMember> memberPred = null, Action<ICompletionData, IType> callback = null, bool onlyAddConstructors = false)
        {
            var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);

            if (currentType != null) {
                for (var ct = ctx.CurrentTypeDefinition; ct != null; ct = ct.DeclaringTypeDefinition) {
                    foreach (var nestedType in ct.GetNestedTypes ()) {
                        if (!lookup.IsAccessible (nestedType.GetDefinition (), true))
                            continue;
                        if (onlyAddConstructors) {
                            if (!nestedType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
                                continue;
                        }

                        if (typePred == null) {
                            if (onlyAddConstructors)
                                wrapper.AddConstructors (nestedType, false, IsAttributeContext(node));
                            else
                                wrapper.AddType(nestedType, false, IsAttributeContext(node));
                            continue;
                        }

                        var type = typePred(nestedType);
                        if (type != null) {
                            var a2 = onlyAddConstructors ? wrapper.AddConstructors(type, false, IsAttributeContext(node)) : wrapper.AddType(type, false, IsAttributeContext(node));
                            if (a2 != null && callback != null) {
                                callback(a2, type);
                            }
                        }
                        continue;
                    }
                }

                if (this.currentMember != null && !(node is AstType)) {
                    var def = ctx.CurrentTypeDefinition;
                    if (def == null && currentType != null)
                        def = Compilation.MainAssembly.GetTypeDefinition(currentType.FullTypeName);
                    if (def != null) {
                        bool isProtectedAllowed = true;

                        foreach (var member in def.GetMembers (m => currentMember.IsStatic ? m.IsStatic : true)) {
                            if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") {
                                continue;
                            }
                            if (member.SymbolKind == SymbolKind.Operator) {
                                continue;
                            }
                            if (member.IsExplicitInterfaceImplementation) {
                                continue;
                            }
                            if (!lookup.IsAccessible(member, isProtectedAllowed)) {
                                continue;
                            }
                            if (memberPred == null || memberPred(member)) {
                                wrapper.AddMember(member);
                            }
                        }
                        var declaring = def.DeclaringTypeDefinition;
                        while (declaring != null) {
                            foreach (var member in declaring.GetMembers (m => m.IsStatic)) {
                                if (memberPred == null || memberPred(member)) {
                                    wrapper.AddMember(member);
                                }
                            }
                            declaring = declaring.DeclaringTypeDefinition;
                        }
                    }
                }
                if (ctx.CurrentTypeDefinition != null) {
                    foreach (var p in ctx.CurrentTypeDefinition.TypeParameters) {
                        wrapper.AddTypeParameter(p);
                    }
                }
            }
            var scope = ctx.CurrentUsingScope;

            for (var n = scope; n != null; n = n.Parent) {
                foreach (var pair in n.UsingAliases) {
                    wrapper.AddAlias(pair.Key);
                }
                foreach (var alias in n.ExternAliases) {
                    wrapper.AddAlias(alias);
                }
                foreach (var u in n.Usings) {
                    foreach (var type in u.Types) {
                        if (!lookup.IsAccessible(type, false))
                            continue;

                        IType addType = typePred != null ? typePred(type) : type;

                        if (onlyAddConstructors && addType != null) {
                            if (!addType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
                                continue;
                        }

                        if (addType != null) {
                            var a = onlyAddConstructors ? wrapper.AddConstructors(addType, false, IsAttributeContext(node)) : wrapper.AddType(addType, false, IsAttributeContext(node));
                            if (a != null && callback != null) {
                                callback(a, type);
                            }
//.........这里部分代码省略.........
开发者ID:JoeSGeorge,项目名称:NRefactory,代码行数:101,代码来源:CSharpCompletionEngine.cs

示例6: AddTypesAndNamespaces

        void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func<IType, IType> typePred = null, Predicate<IMember> memberPred = null, Action<ICompletionData, IType> callback = null)
        {
            var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);

            if (currentType != null) {
                for (var ct = ctx.CurrentTypeDefinition; ct != null; ct = ct.DeclaringTypeDefinition) {
                    foreach (var nestedType in ct.GetNestedTypes ()) {
                        if (!lookup.IsAccessible (nestedType.GetDefinition (), true))
                            continue;

                        if (typePred == null) {
                            wrapper.AddType(nestedType, false, IsAttributeContext(node));
                            continue;
                        }

                        var type = typePred(nestedType);
                        if (type != null) {
                            var a2 = wrapper.AddType(type, false, IsAttributeContext(node));
                            if (a2 != null && callback != null) {
                                callback(a2, type);
                            }
                        }
                        continue;
                    }
                }
                if (this.currentMember != null && !(node is AstType)) {
                    var def = ctx.CurrentTypeDefinition;
                    if (def == null && currentType != null)
                        def = Compilation.MainAssembly.GetTypeDefinition(currentType.FullTypeName);
                    if (def != null) {
                        bool isProtectedAllowed = true;

                        foreach (var member in def.GetMembers (m => currentMember.IsStatic ? m.IsStatic : true)) {
                            if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") {
                                continue;
                            }
                            if (member.EntityType == EntityType.Operator) {
                                continue;
                            }
                            if (member.IsExplicitInterfaceImplementation) {
                                continue;
                            }
                            if (!lookup.IsAccessible(member, isProtectedAllowed)) {
                                continue;
                            }
                            if (memberPred == null || memberPred(member)) {
                                wrapper.AddMember(member);
                            }
                        }
                        var declaring = def.DeclaringTypeDefinition;
                        while (declaring != null) {
                            foreach (var member in declaring.GetMembers (m => m.IsStatic)) {
                                if (memberPred == null || memberPred(member)) {
                                    wrapper.AddMember(member);
                                }
                            }
                            declaring = declaring.DeclaringTypeDefinition;
                        }
                    }
                }
                if (ctx.CurrentTypeDefinition != null) {
                    foreach (var p in ctx.CurrentTypeDefinition.TypeParameters) {
                        wrapper.AddTypeParameter(p);
                    }
                }
            }
            var scope = ctx.CurrentUsingScope;

            for (var n = scope; n != null; n = n.Parent) {
                foreach (var pair in n.UsingAliases) {
                    wrapper.AddAlias(pair.Key);
                }
                foreach (var alias in n.ExternAliases) {
                    wrapper.AddAlias(alias);
                }
                foreach (var u in n.Usings) {
                    foreach (var type in u.Types) {
                        if (!lookup.IsAccessible(type, false))
                            continue;

                        IType addType = typePred != null ? typePred(type) : type;
                        if (addType != null) {
                            var a = wrapper.AddType(addType, false, IsAttributeContext(node));
                            if (a != null && callback != null) {
                                callback(a, type);
                            }
                        }
                    }
                }

                foreach (var type in n.Namespace.Types) {
                    if (!lookup.IsAccessible(type, false))
                        continue;
                    IType addType = typePred != null ? typePred(type) : type;
                    if (addType != null) {
                        var a2 = wrapper.AddType(addType, false);
                        if (a2 != null && callback != null) {
                            callback(a2, type);
                        }
                    }
//.........这里部分代码省略.........
开发者ID:artifexor,项目名称:NRefactory,代码行数:101,代码来源:CSharpCompletionEngine.cs

示例7: AddContextCompletion

        void AddContextCompletion(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node)
        {
            if (state != null) {
                foreach (var variable in state.LocalVariables) {
                    wrapper.AddVariable (variable);
                }
            }

            if (ctx.CurrentMember is IParameterizedMember) {
                var param = (IParameterizedMember)ctx.CurrentMember;
                foreach (var p in param.Parameters) {
                    wrapper.AddVariable (p);
                }
            }

            if (currentMember is IUnresolvedMethod) {
                var method = (IUnresolvedMethod)currentMember;
                foreach (var p in method.TypeParameters) {
                    wrapper.AddTypeParameter (p);
                }
            }

            Predicate<IType> typePred = null;
            if (node is Attribute) {
                var attribute = Compilation.FindType (typeof (System.Attribute));
                typePred = t => {
                    return t.GetAllBaseTypeDefinitions ().Any (bt => bt.Equals (attribute));
                };
            }
            AddTypesAndNamespaces (wrapper, state, node, typePred);

            wrapper.Result.Add (factory.CreateLiteralCompletionData ("global"));
            if (state.CurrentMember != null) {
                AddKeywords (wrapper, statementStartKeywords);
                AddKeywords (wrapper, expressionLevelKeywords);
            } else if (state.CurrentTypeDefinition != null) {
                AddKeywords (wrapper, typeLevelKeywords);
            } else {
                AddKeywords (wrapper, globalLevelKeywords);
            }
            var prop = currentMember as IUnresolvedProperty;
            if (prop != null && prop.Setter.Region.IsInside (location))
                wrapper.AddCustom ("value");
            if (currentMember is IUnresolvedEvent)
                wrapper.AddCustom ("value");

            if (IsInSwitchContext (node)) {
                wrapper.AddCustom ("case");
                wrapper.AddCustom ("default");
            }

            AddKeywords (wrapper, primitiveTypesKeywords);
            wrapper.Result.AddRange (factory.CreateCodeTemplateCompletionData ());
        }
开发者ID:holmak,项目名称:NRefactory,代码行数:54,代码来源:CSharpCompletionEngine.cs


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