Esempio n. 1
0
		public void UnboundTypeOfExpressionTest()
		{
			var type = new SimpleType("MyType");
			type.AddChild (new SimpleType (), Roles.TypeArgument);
			type.AddChild (new SimpleType (), Roles.TypeArgument);
			ParseUtilCSharp.AssertExpression(
				"typeof(MyType<,>)",
				new TypeOfExpression {
					Type = type
				});
		}
Esempio n. 2
0
        public static AstType ConvertToTypeReference(this MonoDevelop.Projects.Dom.IReturnType returnType)
        {
            string primitiveType;

            if (TypeTable.TryGetValue(returnType.DecoratedFullName, out primitiveType))
            {
                return(new PrimitiveType(primitiveType));
            }

            AstType result = null;

            if (!string.IsNullOrEmpty(returnType.Namespace))
            {
                result = new SimpleType(returnType.Namespace);
            }
            foreach (var part in returnType.Parts)
            {
                if (result == null)
                {
                    var st = new SimpleType(part.Name);
                    foreach (var type in part.GenericArguments.Select(ga => ConvertToTypeReference(ga)))
                    {
                        st.AddChild(type, SimpleType.Roles.TypeArgument);
                    }
                    result = st;
                }
                else
                {
                    var mt = new ICSharpCode.NRefactory.CSharp.MemberType()
                    {
                        Target     = result,
                        MemberName = part.Name
                    };
                    foreach (var type in part.GenericArguments.Select(ga => ConvertToTypeReference(ga)))
                    {
                        mt.AddChild(type, SimpleType.Roles.TypeArgument);
                    }
                    result = mt;
                }
            }

            /*
             * List<TypeReference> genericTypes = new List<TypeReference> ();
             * foreach (MonoDevelop.Projects.Dom.IReturnType genericType in returnType.GenericArguments) {
             *      genericTypes.Add (ConvertToTypeReference (genericType));
             * }
             * TypeReference result = new AstType (returnType.FullName, genericTypes);
             * result.IsKeyword = true;
             * result.PointerNestingLevel = returnType.PointerNestingLevel;
             * if (returnType.ArrayDimensions > 0) {
             *      int[] rankSpecfier = new int[returnType.ArrayDimensions];
             *      for (int i = 0; i < returnType.ArrayDimensions; i++) {
             *              rankSpecfier[i] = returnType.GetDimension (i);
             *      }
             *      result.RankSpecifier = rankSpecfier;
             * }*/
            return(result);
        }
Esempio n. 3
0
		public static AstType ConvertToTypeReference (this MonoDevelop.Projects.Dom.IReturnType returnType)
		{
			string primitiveType;
			if (TypeTable.TryGetValue (returnType.DecoratedFullName, out primitiveType))
				return new PrimitiveType (primitiveType);
			
			AstType result = null;
			if (!string.IsNullOrEmpty (returnType.Namespace))
				result = new SimpleType (returnType.Namespace);
			foreach (var part in returnType.Parts) {
				if (result == null) {
					var st = new SimpleType (part.Name);
					foreach (var type in part.GenericArguments.Select (ga => ConvertToTypeReference (ga)))
						st.AddChild (type, SimpleType.Roles.TypeArgument);
					result = st;
				} else {
					var mt = new ICSharpCode.NRefactory.CSharp.MemberType () {
						Target = result,
						MemberName = part.Name
					};
					foreach (var type in part.GenericArguments.Select (ga => ConvertToTypeReference (ga)))
						mt.AddChild (type, SimpleType.Roles.TypeArgument);
					result = mt;
				}
			}
			
			/*
			List<TypeReference> genericTypes = new List<TypeReference> ();
			foreach (MonoDevelop.Projects.Dom.IReturnType genericType in returnType.GenericArguments) {
				genericTypes.Add (ConvertToTypeReference (genericType));
			}
			TypeReference result = new AstType (returnType.FullName, genericTypes);
			result.IsKeyword = true;
			result.PointerNestingLevel = returnType.PointerNestingLevel;
			if (returnType.ArrayDimensions > 0) {
				int[] rankSpecfier = new int[returnType.ArrayDimensions];
				for (int i = 0; i < returnType.ArrayDimensions; i++) {
					rankSpecfier[i] = returnType.GetDimension (i);
				}
				result.RankSpecifier = rankSpecfier;
			}*/
			return result;
		}
Esempio n. 4
0
			AstType ConvertImport(MemberName memberName)
			{
				if (memberName.Left != null) {
					// left.name
					var t = new MemberType();
//					t.IsDoubleColon = memberName.IsDoubleColon;
					t.AddChild(ConvertImport(memberName.Left), MemberType.TargetRole);
					var loc = LocationsBag.GetLocations(memberName);
					if (loc != null)
						t.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Dot), Roles.Dot);
					
					t.AddChild(Identifier.Create(memberName.Name, Convert(memberName.Location)), Roles.Identifier);
					AddTypeArguments(t, memberName);
					return t;
				} else {
					var t = new SimpleType();
					t.AddChild(Identifier.Create(memberName.Name, Convert(memberName.Location)), Roles.Identifier);
					AddTypeArguments(t, memberName);
					return t;
				}
			}
Esempio n. 5
0
			AstType ConvertImport (MemberName memberName)
			{
				if (memberName.Left != null) {
					// left.name
					var t = new MemberType();
					t.IsDoubleColon = memberName.IsDoubleColon;
					t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole);
					
					if (!memberName.DotLocation.IsNull)
						t.AddChild (new CSharpTokenNode (Convert (memberName.DotLocation), 1), MemberType.Roles.Dot);
					
					t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier);
					AddTypeArguments (t, memberName.TypeArguments);
					return t;
				} else {
					SimpleType t = new SimpleType();
					t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier);
					AddTypeArguments (t, memberName.TypeArguments);
					return t;
				}
			}
			AstType ConvertImport (MemberName memberName)
			{
				if (memberName.Left != null) {
					// left.name
					var t = new MemberType();
					t.IsDoubleColon = memberName.IsDoubleColon;
					t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole);
					t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier);
					AddTypeArguments (t, (List<Location>)null, memberName.TypeArguments);
					return t;
				} else {
					SimpleType t = new SimpleType();
					t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier);
					AddTypeArguments (t, (List<Location>)null, memberName.TypeArguments);
					return t;
				}
			}
Esempio n. 7
0
			AstType ConvertImport (MemberName memberName)
			{
				if (memberName.Left != null) {
					// left.name
					MemberType t = new MemberType();
					t.IsDoubleColon = memberName.IsDoubleColon;
					t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole);
					t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier);
					return t;
				} else {
					SimpleType t = new SimpleType();
					t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier);
					// TODO type arguments
					return t;
				}
			}