Ejemplo n.º 1
0
 /// <summary>
 /// Adds type arguments to the result type.
 /// </summary>
 /// <param name="result">The result AST node (a SimpleType or MemberType)</param>
 /// <param name="typeDef">The type definition that owns the type parameters</param>
 /// <param name="typeArguments">The list of type arguments</param>
 /// <param name="startIndex">Index of first type argument to add</param>
 /// <param name="endIndex">Index after last type argument to add</param>
 void AddTypeArguments(AstType result, ITypeDefinition typeDef, IList<IType> typeArguments, int startIndex, int endIndex)
 {
     Debug.Assert(endIndex <= typeDef.TypeParameterCount);
     for (int i = startIndex; i < endIndex; i++) {
         if (ConvertUnboundTypeArguments && typeArguments[i].Kind == TypeKind.UnboundTypeArgument) {
             result.AddChild(new SimpleType(typeDef.TypeParameters[i].Name), Roles.TypeArgument);
         } else {
             result.AddChild(ConvertType(typeArguments[i]), Roles.TypeArgument);
         }
     }
 }
Ejemplo n.º 2
0
			void AddTypeArguments (ATypeNameExpression texpr, AstType result)
			{
				if (texpr.TypeArguments == null || texpr.TypeArguments.Args == null)
					return;
				var loc = LocationsBag.GetLocations (texpr.TypeArguments);
				if (loc != null && loc.Count >= 2)
					result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 2]), 1), AstType.Roles.LChevron);
				int i = 0;
				foreach (var arg in texpr.TypeArguments.Args) {
					result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
					if (loc != null && i < loc.Count - 2)
						result.AddChild (new CSharpTokenNode (Convert (loc [i++]), 1), AstType.Roles.Comma);
				}
				if (loc != null && loc.Count >= 2)
					result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 1]), 1), AstType.Roles.RChevron);
			}
Ejemplo n.º 3
0
 /// <summary>
 /// Adds type arguments to the result type.
 /// </summary>
 /// <param name="result">The result AST node (a SimpleType or MemberType)</param>
 /// <param name="typeArguments">The list of type arguments</param>
 /// <param name="startIndex">Index of first type argument to add</param>
 /// <param name="endIndex">Index after last type argument to add</param>
 void AddTypeArguments(AstType result, IList <IType> typeArguments, int startIndex, int endIndex)
 {
     for (int i = startIndex; i < endIndex; i++)
     {
         result.AddChild(ConvertType(typeArguments[i]), AstType.Roles.TypeArgument);
     }
 }
Ejemplo n.º 4
0
			void AddTypeArguments (ATypeNameExpression texpr, AstType result)
			{
				if (!texpr.HasTypeArguments)
					return;
				foreach (var arg in texpr.TypeArguments.Args) {
					result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
				}
			}
Ejemplo n.º 5
0
        CodeAction ReplaceWithFullTypeNameAction(RefactoringContext context, AstNode node, ITypeDefinition typeDefinition)
        {
            AstType astType             = context.CreateShortType(typeDefinition);
            string  textWithoutGenerics = astType.ToString();

            foreach (var typeArg in node.GetChildrenByRole(Roles.TypeArgument))
            {
                astType.AddChild(typeArg.Clone(), Roles.TypeArgument);
            }
            return(new CodeAction(textWithoutGenerics, s => s.Replace(node, astType), node));
        }
Ejemplo n.º 6
0
			void AddTypeArguments(ATypeNameExpression texpr, AstType result)
			{
				var unbound = texpr.TypeArguments as UnboundTypeArguments;
				if (unbound != null) { 
					var loc2 = LocationsBag.GetLocations(texpr.TypeArguments);
					if (loc2 == null)
						return;
					int j = 0;
					if (j < loc2.Count)
						result.AddChild(new CSharpTokenNode(Convert(loc2 [j++]), Roles.LChevron), Roles.LChevron);
					while (j < loc2.Count - 1) {
						result.AddChild (new SimpleType (), Roles.TypeArgument);
						result.AddChild(new CSharpTokenNode(Convert(loc2 [j++]), Roles.LChevron), Roles.Comma);
					}
					if (j < loc2.Count) {
						result.AddChild (new SimpleType (), Roles.TypeArgument);
						result.AddChild(new CSharpTokenNode(Convert(loc2 [j++]), Roles.RChevron), Roles.RChevron);
					}
					return;
				}
				if (texpr.TypeArguments == null || texpr.TypeArguments.Args == null)
					return;
				var loc = LocationsBag.GetLocations(texpr.TypeArguments);
				if (loc != null && loc.Count >= 2)
					result.AddChild(new CSharpTokenNode(Convert(loc [loc.Count - 2]), Roles.LChevron), Roles.LChevron);
				int i = 0;
				foreach (var arg in texpr.TypeArguments.Args) {
					result.AddChild(ConvertToType(arg), Roles.TypeArgument);
					if (loc != null && i < loc.Count - 2)
						result.AddChild(new CSharpTokenNode(Convert(loc [i++]), Roles.Comma), Roles.Comma);
				}
				if (loc != null && loc.Count >= 2)
					result.AddChild(new CSharpTokenNode(Convert(loc [loc.Count - 1]), Roles.RChevron), Roles.RChevron);
			}
Ejemplo n.º 7
0
 /// <summary>
 /// Adds type arguments to the result type.
 /// </summary>
 /// <param name="result">The result AST node (a SimpleType or MemberType)</param>
 /// <param name="typeDef">The type definition that owns the type parameters</param>
 /// <param name="typeArguments">The list of type arguments</param>
 /// <param name="startIndex">Index of first type argument to add</param>
 /// <param name="endIndex">Index after last type argument to add</param>
 void AddTypeArguments(AstType result, ITypeDefinition typeDef, IList<IType> typeArguments, int startIndex, int endIndex)
 {
     Debug.Assert(endIndex <= typeDef.TypeParameterCount);
     for (int i = startIndex; i < endIndex; i++) {
         if (ConvertUnboundTypeArguments && typeArguments[i].Kind == TypeKind.UnboundTypeArgument) {
             result.AddChild(new SimpleType(typeDef.TypeParameters[i].Name), Roles.TypeArgument);
         } else {
             result.AddChild(ConvertType(typeArguments[i]), Roles.TypeArgument);
         }
     }
 }
		/// <summary>
		/// Adds type arguments to the result type.
		/// </summary>
		/// <param name="result">The result AST node (a SimpleType or MemberType)</param>
		/// <param name="typeArguments">The list of type arguments</param>
		/// <param name="startIndex">Index of first type argument to add</param>
		/// <param name="endIndex">Index after last type argument to add</param>
		void AddTypeArguments(AstType result, IList<IType> typeArguments, int startIndex, int endIndex)
		{
			for (int i = startIndex; i < endIndex; i++) {
				result.AddChild(ConvertType(typeArguments[i]), AstType.Roles.TypeArgument);
			}
		}