Exemplo n.º 1
0
            public override void OnYieldStatement(YieldStatement node)
            {
                noReturnStatement = false;

                IProjectContent pc         = context != null ? context.ProjectContent : ParserService.CurrentProjectContent;
                IReturnType     enumerable = new GetClassReturnType(pc, "System.Collections.Generic.IEnumerable", 1);

                // Prevent creating an infinite number of InferredReturnTypes in inferring cycles
                parentReturnType.expression = new NullLiteralExpression();
                IReturnType returnType;

                if (node.Expression == null)
                {
                    returnType = ConvertVisitor.GetDefaultReturnType(pc);
                }
                else
                {
                    returnType = new BooResolver().GetTypeOfExpression(node.Expression, context);
                }
                if (returnType != null)
                {
                    returnType.GetUnderlyingClass();                     // force to infer type
                }
                if (parentReturnType.expression == null)
                {
                    // inferrence cycle with parentReturnType
                    returnType = new GetClassReturnType(pc, "?", 0);
                }
                parentReturnType.expression = null;

                result = new ConstructedReturnType(enumerable, new IReturnType[] { returnType });
            }
        static IReturnType Parse(IProjectContent pc, IEnumerator <string> tokenizer)
        {
            string typeName = tokenizer.Current;

            if (typeName == null)
            {
                throw new ReflectionTypeNameSyntaxError("Unexpected end of type name");
            }
            tokenizer.MoveNext();
            int typeParameterCount;

            typeName = ReflectionClass.SplitTypeParameterCountFromReflectionName(typeName, out typeParameterCount);
            IReturnType rt = new GetClassReturnType(pc, typeName, typeParameterCount);

            if (tokenizer.Current == "[")
            {
                // this is a constructed type
                List <IReturnType> typeArguments = new List <IReturnType>();
                do
                {
                    tokenizer.MoveNext();
                    if (tokenizer.Current != "[")
                    {
                        throw new ReflectionTypeNameSyntaxError("Expected '['");
                    }
                    tokenizer.MoveNext();
                    typeArguments.Add(Parse(pc, tokenizer));
                    if (tokenizer.Current != "]")
                    {
                        throw new ReflectionTypeNameSyntaxError("Expected ']' after generic argument");
                    }
                    tokenizer.MoveNext();
                } while (tokenizer.Current == ",");
                if (tokenizer.Current != "]")
                {
                    throw new ReflectionTypeNameSyntaxError("Expected ']' after generic argument list");
                }
                tokenizer.MoveNext();

                rt = new ConstructedReturnType(rt, typeArguments);
            }
            while (tokenizer.Current == ",")
            {
                tokenizer.MoveNext();
                string token = tokenizer.Current;
                if (token != null && token != "," && token != "[" && token != "]")
                {
                    tokenizer.MoveNext();
                }
            }
            return(rt);
        }
Exemplo n.º 3
0
        public override void OnGeneratorExpression(GeneratorExpression node)
        {
            ClearResult();
            node.Expression.Accept(this);

            if (resolveResult != null)
            {
                IReturnType enumerable = new GetClassReturnType(projectContent, "System.Collections.Generic.IEnumerable", 1);
                MakeResult(new ConstructedReturnType(enumerable, new IReturnType[] { resolveResult.ResolvedType }));
            }
            else
            {
                MakeResult(new GetClassReturnType(projectContent, "System.Collections.IEnumerable", 0));
            }
        }
Exemplo n.º 4
0
		static IReturnType Parse(IProjectContent pc, IEnumerator<string> tokenizer)
		{
			string typeName = tokenizer.Current;
			if (typeName == null)
				throw new ReflectionTypeNameSyntaxError("Unexpected end of type name");
			tokenizer.MoveNext();
			int typeParameterCount;
			typeName = ReflectionClass.SplitTypeParameterCountFromReflectionName(typeName, out typeParameterCount);
			IReturnType rt = new GetClassReturnType(pc, typeName, typeParameterCount);
			if (tokenizer.Current == "[") {
				// this is a constructed type
				List<IReturnType> typeArguments = new List<IReturnType>();
				do {
					tokenizer.MoveNext();
					if (tokenizer.Current != "[")
						throw new ReflectionTypeNameSyntaxError("Expected '['");
					tokenizer.MoveNext();
					typeArguments.Add(Parse(pc, tokenizer));
					if (tokenizer.Current != "]")
						throw new ReflectionTypeNameSyntaxError("Expected ']' after generic argument");
					tokenizer.MoveNext();
				} while (tokenizer.Current == ",");
				if (tokenizer.Current != "]")
					throw new ReflectionTypeNameSyntaxError("Expected ']' after generic argument list");
				tokenizer.MoveNext();
				
				rt = new ConstructedReturnType(rt, typeArguments);
			}
			while (tokenizer.Current == ",") {
				tokenizer.MoveNext();
				string token = tokenizer.Current;
				if (token != null && token != "," && token != "[" && token != "]")
					tokenizer.MoveNext();
			}
			return rt;
		}
Exemplo n.º 5
0
        public static IReturnType CreateReturnType(TypeReference reference, IClass callingClass,
                                                   IMember callingMember, int caretLine, int caretColumn,
                                                   IProjectContent projectContent,
                                                   bool useLazyReturnType)
        {
            if (reference == null)
            {
                return(null);
            }
            if (reference.IsNull)
            {
                return(null);
            }
            if (reference is InnerClassTypeReference)
            {
                reference = ((InnerClassTypeReference)reference).CombineToNormalTypeReference();
            }
            LanguageProperties languageProperties = projectContent.Language;
            IReturnType        t = null;

            if (callingClass != null && !reference.IsGlobal)
            {
                foreach (ITypeParameter tp in callingClass.TypeParameters)
                {
                    if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType))
                    {
                        t = new GenericReturnType(tp);
                        break;
                    }
                }
                if (t == null && callingMember is IMethod && (callingMember as IMethod).TypeParameters != null)
                {
                    foreach (ITypeParameter tp in (callingMember as IMethod).TypeParameters)
                    {
                        if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType))
                        {
                            t = new GenericReturnType(tp);
                            break;
                        }
                    }
                }
            }
            if (t == null)
            {
                if (reference.Type != reference.SystemType)
                {
                    // keyword-type like void, int, string etc.
                    IClass c = projectContent.GetClass(reference.SystemType);
                    if (c != null)
                    {
                        t = c.DefaultReturnType;
                    }
                    else
                    {
                        t = new GetClassReturnType(projectContent, reference.SystemType, 0);
                    }
                }
                else
                {
                    int typeParameterCount = reference.GenericTypes.Count;
                    if (useLazyReturnType)
                    {
                        if (reference.IsGlobal)
                        {
                            t = new GetClassReturnType(projectContent, reference.SystemType, typeParameterCount);
                        }
                        else if (callingClass != null)
                        {
                            t = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.SystemType, typeParameterCount);
                        }
                    }
                    else
                    {
                        IClass c;
                        if (reference.IsGlobal)
                        {
                            c = projectContent.GetClass(reference.SystemType, typeParameterCount);
                            t = (c != null) ? c.DefaultReturnType : null;
                        }
                        else if (callingClass != null)
                        {
                            t = projectContent.SearchType(new SearchTypeRequest(reference.SystemType, typeParameterCount, callingClass, caretLine, caretColumn)).Result;
                        }
                        if (t == null)
                        {
                            if (reference.GenericTypes.Count == 0 && !reference.IsArrayType)
                            {
                                // reference to namespace is possible
                                if (reference.IsGlobal)
                                {
                                    if (projectContent.NamespaceExists(reference.Type))
                                    {
                                        return(new NamespaceReturnType(reference.Type));
                                    }
                                }
                                else
                                {
                                    string name = projectContent.SearchNamespace(reference.Type, callingClass, (callingClass == null) ? null : callingClass.CompilationUnit, caretLine, caretColumn);
                                    if (name != null)
                                    {
                                        return(new NamespaceReturnType(name));
                                    }
                                }
                            }
                            return(null);
                        }
                    }
                }
            }
            if (reference.GenericTypes.Count > 0)
            {
                List <IReturnType> para = new List <IReturnType>(reference.GenericTypes.Count);
                for (int i = 0; i < reference.GenericTypes.Count; ++i)
                {
                    para.Add(CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, useLazyReturnType));
                }
                t = new ConstructedReturnType(t, para);
            }
            return(WrapArray(projectContent, t, reference));
        }
Exemplo n.º 6
0
 public static IReturnType CreateReturnType(AST.TypeReference reference, IClass callingClass,
                                            IMethodOrProperty callingMember, int caretLine, int caretColumn,
                                            IProjectContent projectContent)
 {
     System.Diagnostics.Debug.Assert(projectContent != null);
     if (reference == null)
     {
         return(GetDefaultReturnType(projectContent));
     }
     if (reference is AST.ArrayTypeReference)
     {
         AST.ArrayTypeReference arr = (AST.ArrayTypeReference)reference;
         return(new ArrayReturnType(projectContent,
                                    CreateReturnType(arr.ElementType, callingClass, callingMember,
                                                     caretLine, caretColumn, projectContent),
                                    (arr.Rank != null) ? (int)arr.Rank.Value : 1));
     }
     else if (reference is AST.SimpleTypeReference)
     {
         string      name = ((AST.SimpleTypeReference)reference).Name;
         IReturnType rt;
         int         typeParameterCount = (reference is AST.GenericTypeReference) ? ((AST.GenericTypeReference)reference).GenericArguments.Count : 0;
         if (name == "duck")
         {
             rt = new BooResolver.DuckClass(new DefaultCompilationUnit(projectContent)).DefaultReturnType;
         }
         else if (BooAmbience.ReverseTypeConversionTable.ContainsKey(name))
         {
             rt = new GetClassReturnType(projectContent, BooAmbience.ReverseTypeConversionTable[name], typeParameterCount);
         }
         else if (callingClass == null)
         {
             rt = new GetClassReturnType(projectContent, name, typeParameterCount);
         }
         else
         {
             rt = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn,
                                            name, typeParameterCount);
         }
         if (typeParameterCount > 0)
         {
             AST.TypeReferenceCollection arguments = ((AST.GenericTypeReference)reference).GenericArguments;
             // GenericTypeReference derives from SimpleTypeReference
             IReturnType[] typeArguments = new IReturnType[arguments.Count];
             for (int i = 0; i < typeArguments.Length; i++)
             {
                 typeArguments[i] = CreateReturnType(arguments[i], callingClass, callingMember, caretLine, caretColumn,
                                                     projectContent);
             }
             rt = new ConstructedReturnType(rt, typeArguments);
         }
         return(rt);
     }
     else if (reference is AST.CallableTypeReference)
     {
         AST.CallableTypeReference ctr  = (AST.CallableTypeReference)reference;
         AnonymousMethodReturnType amrt = new AnonymousMethodReturnType(new DefaultCompilationUnit(projectContent));
         if (ctr.ReturnType != null)
         {
             amrt.MethodReturnType = CreateReturnType(ctr.ReturnType, callingClass, callingMember, caretLine, caretColumn, projectContent);
         }
         amrt.MethodParameters = new List <IParameter>();
         AddParameters(ctr.Parameters, amrt.MethodParameters, callingMember, callingClass ?? new DefaultClass(new DefaultCompilationUnit(projectContent), "__Dummy"));
         return(amrt);
     }
     else
     {
         throw new NotSupportedException("unknown reference type: " + reference.ToString());
     }
 }
Exemplo n.º 7
0
        public static IReturnType CreateReturnType(TypeReference reference, IClass callingClass,
		                                           IMember callingMember, int caretLine, int caretColumn,
		                                           IProjectContent projectContent,
		                                           ReturnTypeOptions options)
        {
            if (reference == null) return null;
            if (reference.IsNull) return null;
            if (reference is InnerClassTypeReference) {
                reference = ((InnerClassTypeReference)reference).CombineToNormalTypeReference();
            }

            bool useLazyReturnType = (options & ReturnTypeOptions.Lazy) == ReturnTypeOptions.Lazy;
            bool isBaseTypeReference = (options & ReturnTypeOptions.BaseTypeReference) == ReturnTypeOptions.BaseTypeReference;

            LanguageProperties languageProperties = projectContent.Language;
            IReturnType t = null;
            if (callingClass != null && !reference.IsGlobal) {
                foreach (ITypeParameter tp in callingClass.TypeParameters) {
                    if (languageProperties.NameComparer.Equals(tp.Name, reference.Type)) {
                        t = new GenericReturnType(tp);
                        break;
                    }
                }
                IMethod callingMethod = callingMember as IMethod;
                if (t == null && callingMethod != null) {
                    foreach (ITypeParameter tp in callingMethod.TypeParameters) {
                        if (languageProperties.NameComparer.Equals(tp.Name, reference.Type)) {
                            t = new GenericReturnType(tp);
                            break;
                        }
                    }
                }
            }
            if (t == null) {
                int typeParameterCount = reference.GenericTypes.Count;
                if (reference.IsKeyword) {
                    // keyword-type like void, int, string etc.
                    IClass c = projectContent.GetClass(reference.Type, typeParameterCount);
                    if (c != null)
                        t = c.DefaultReturnType;
                    else
                        t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
                } else {
                    if (useLazyReturnType || isBaseTypeReference) {
                        if (reference.IsGlobal) {
                            t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
                        } else if (callingClass != null) {
                            SearchClassReturnType scrt = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.Type, typeParameterCount);
                            if (isBaseTypeReference)
                                scrt.LookForInnerClassesInDeclaringClass = false;
                            t = scrt;
                        }
                    } else {
                        IClass c;
                        if (reference.IsGlobal) {
                            c = projectContent.GetClass(reference.Type, typeParameterCount);
                            t = (c != null) ? c.DefaultReturnType : null;
                        } else if (callingClass != null) {
                            t = projectContent.SearchType(new SearchTypeRequest(reference.Type, typeParameterCount, callingClass, caretLine, caretColumn)).Result;
                        }
                        if (t == null) {
                            return null;
                        }
                    }
                }
            }
            if (reference.GenericTypes.Count > 0) {
                IReturnType[] para = new IReturnType[reference.GenericTypes.Count];
                for (int i = 0; i < reference.GenericTypes.Count; ++i) {
                    para[i] = CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, options);
                }
                t = new ConstructedReturnType(t, para);
            }
            for (int i = 0; i < reference.PointerNestingLevel; i++) {
                t = new PointerReturnType(t);
            }
            return WrapArray(projectContent, t, reference);
        }
        protected override string GenerateCode(LanguageProperties language, IClass currentClass)
        {
            StringBuilder builder              = new StringBuilder();
            IDocumentLine line                 = editor.Document.GetLineForOffset(anchor.Offset);
            string        indent               = DocumentUtilitites.GetWhitespaceAfter(editor.Document, line.Offset);
            bool          implementInterface   = this.implementInterface.IsChecked == true;
            bool          hasOnPropertyChanged = HasOnPropertyChanged(currentClass);
            bool          useEventArgs         = false;

            if (implementInterface && !currentClass.IsStatic)
            {
                if (!hasOnPropertyChanged)
                {
                    var nodes = new List <AbstractNode>();
                    var rt    = new GetClassReturnType(currentClass.ProjectContent, "System.ComponentModel.INotifyPropertyChanged", 0);
                    if (!currentClass.ClassInheritanceTree.Any(bt => bt.FullyQualifiedName == "System.ComponentModel.INotifyPropertyChanged"))
                    {
                        int insertion = editor.Document.PositionToOffset(currentClass.BodyRegion.BeginLine, currentClass.BodyRegion.BeginColumn);
                        if (currentClass.BaseTypes.Count > 0)
                        {
                            editor.Document.Insert(insertion, ", INotifyPropertyChanged");
                        }
                        else
                        {
                            editor.Document.Insert(insertion, " : INotifyPropertyChanged");
                        }
                    }
                    language.CodeGenerator.ImplementInterface(nodes, rt, false, currentClass);
                    var ev = rt.GetEvents().First(e => e.Name == "PropertyChanged");
                    MethodDeclaration onEvent = language.CodeGenerator.CreateOnEventMethod(new DefaultEvent(ev.Name, ev.ReturnType, ev.Modifiers, ev.Region, ev.BodyRegion, currentClass));
                    nodes.Add(onEvent);
                    onEvent.Parameters[0].TypeReference = new TypeReference("string", true);
                    onEvent.Parameters[0].ParameterName = "propertyName";
                    ((RaiseEventStatement)onEvent.Body.Children[0]).Arguments[1] = new ObjectCreateExpression(new TypeReference("PropertyChangedEventArgs"), new List <Expression> {
                        new IdentifierExpression("propertyName")
                    });
                    foreach (var node in nodes)
                    {
                        builder.AppendLine(language.CodeGenerator.GenerateCode(node, indent));
                    }
                    useEventArgs = false;
                }
                else
                {
                    useEventArgs = currentClass.DefaultReturnType.GetMethods().First(m => m.Name == "OnPropertyChanged").Parameters[0].ReturnType.FullyQualifiedName != "System.String";
                }
            }

            foreach (FieldWrapper field in listBox.SelectedItems)
            {
                var prop = language.CodeGenerator.CreateProperty(field.Field, true, field.AddSetter);
                if (!field.Field.IsStatic && !currentClass.IsStatic && field.AddSetter && implementInterface)
                {
                    var invocation = new ExpressionStatement(CreateInvocation(field.PropertyName, useEventArgs));
                    var assignment = prop.SetRegion.Block.Children[0];
                    prop.SetRegion.Block.Children.Clear();
                    prop.SetRegion.Block.AddChild(
                        new IfElseStatement(
                            new BinaryOperatorExpression(new IdentifierExpression(field.MemberName), BinaryOperatorType.InEquality, new IdentifierExpression("value")),
                            new BlockStatement {
                        Children = { assignment, invocation }
                    }
                            )
                        );
                }
                builder.AppendLine(language.CodeGenerator.GenerateCode(prop, indent));
            }

            return(builder.ToString().Trim());
        }
Exemplo n.º 9
0
        public static IReturnType CreateReturnType(TypeReference reference, IClass callingClass,
                                                   IMember callingMember, int caretLine, int caretColumn,
                                                   IProjectContent projectContent,
                                                   ReturnTypeOptions options)
        {
            if (reference == null)
            {
                return(null);
            }
            if (reference.IsNull)
            {
                return(null);
            }
            if (reference is InnerClassTypeReference)
            {
                reference = ((InnerClassTypeReference)reference).CombineToNormalTypeReference();
            }

            bool useLazyReturnType   = (options & ReturnTypeOptions.Lazy) == ReturnTypeOptions.Lazy;
            bool isBaseTypeReference = (options & ReturnTypeOptions.BaseTypeReference) == ReturnTypeOptions.BaseTypeReference;

            LanguageProperties languageProperties = projectContent.Language;
            IReturnType        t = null;

            if (callingClass != null && !reference.IsGlobal)
            {
                foreach (ITypeParameter tp in callingClass.TypeParameters)
                {
                    if (languageProperties.NameComparer.Equals(tp.Name, reference.Type))
                    {
                        t = new GenericReturnType(tp);
                        break;
                    }
                }
                IMethod callingMethod = callingMember as IMethod;
                if (t == null && callingMethod != null)
                {
                    foreach (ITypeParameter tp in callingMethod.TypeParameters)
                    {
                        if (languageProperties.NameComparer.Equals(tp.Name, reference.Type))
                        {
                            t = new GenericReturnType(tp);
                            break;
                        }
                    }
                }
            }
            if (t == null && reference.Type == "dynamic")
            {
                t = new DynamicReturnType(projectContent);
            }
            if (t == null)
            {
                int typeParameterCount = reference.GenericTypes.Count;
                if (reference.IsKeyword)
                {
                    // keyword-type like void, int, string etc.
                    IClass c = projectContent.GetClass(reference.Type, typeParameterCount);
                    if (c != null)
                    {
                        t = c.DefaultReturnType;
                    }
                    else
                    {
                        t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
                    }
                }
                else
                {
                    if (useLazyReturnType || isBaseTypeReference)
                    {
                        if (reference.IsGlobal)
                        {
                            t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
                        }
                        else if (callingClass != null)
                        {
                            SearchClassReturnType scrt = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.Type, typeParameterCount);
                            if (isBaseTypeReference)
                            {
                                scrt.LookForInnerClassesInDeclaringClass = false;
                            }
                            t = scrt;
                        }
                    }
                    else
                    {
                        IClass c;
                        if (reference.IsGlobal)
                        {
                            c = projectContent.GetClass(reference.Type, typeParameterCount);
                            t = (c != null) ? c.DefaultReturnType : null;
                        }
                        else if (callingClass != null)
                        {
                            t = projectContent.SearchType(new SearchTypeRequest(reference.Type, typeParameterCount, callingClass, caretLine, caretColumn)).Result;
                        }
                        if (t == null)
                        {
                            return(null);
                        }
                    }
                }
            }
            if (reference.GenericTypes.Count > 0)
            {
                IReturnType[] para = new IReturnType[reference.GenericTypes.Count];
                for (int i = 0; i < reference.GenericTypes.Count; ++i)
                {
                    para[i] = CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, options);
                }
                t = new ConstructedReturnType(t, para);
            }
            for (int i = 0; i < reference.PointerNestingLevel; i++)
            {
                t = new PointerReturnType(t);
            }
            return(WrapArray(projectContent, t, reference));
        }
Exemplo n.º 10
0
        CodeExpression CreateMemberExpression(CodeExpression target, string parentName, string name, bool isStatic)
        {
            _fieldReferenceType = null;

            string combinedName = parentName + "." + name;

            if (pc.GetClass(combinedName, 0) != null)
            {
                return(new CodeTypeReferenceExpression(combinedName));
            }
            else if (pc.NamespaceExists(combinedName))
            {
                return(new CodeTypeReferenceExpression(combinedName));
            }

            GetClassReturnType rt = new GetClassReturnType(pc, parentName, 0);

            foreach (IProperty prop in rt.GetProperties())
            {
                if (prop.IsStatic == isStatic && prop.Name == name)
                {
                    _fieldReferenceType = prop.ReturnType;
                    return(new CodePropertyReferenceExpression(target, name));
                }
            }
            foreach (IEvent ev in rt.GetEvents())
            {
                if (ev.IsStatic == isStatic && ev.Name == name)
                {
                    _fieldReferenceType = ev.ReturnType;
                    return(new CodeEventReferenceExpression(target, name));
                }
            }
            foreach (IMethod me in rt.GetMethods())
            {
                if (me.IsStatic == isStatic && me.Name == name)
                {
                    _fieldReferenceType = me.ReturnType;
                    CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression(target, name);
                    cmre.UserData["methodUserData"] = me;
                    return(cmre);
                }
            }
            foreach (IField field in rt.GetFields())
            {
                if (field.IsStatic == isStatic && field.Name == name)
                {
                    _fieldReferenceType = field.ReturnType;
                    return(new CodeFieldReferenceExpression(target, name));
                }
            }
            // unknown member, guess:
            if (char.IsUpper(name, 0))
            {
                return(new CodePropertyReferenceExpression(target, name));
            }
            else
            {
                return(new CodeFieldReferenceExpression(target, name));
            }
        }
Exemplo n.º 11
0
		public static IReturnType CreateReturnType(TypeReference reference, IClass callingClass,
		                                           IMember callingMember, int caretLine, int caretColumn,
		                                           IProjectContent projectContent,
		                                           bool useLazyReturnType)
		{
			if (reference == null) return null;
			if (reference.IsNull) return null;
			if (reference is InnerClassTypeReference) {
				reference = ((InnerClassTypeReference)reference).CombineToNormalTypeReference();
			}
			LanguageProperties languageProperties = projectContent.Language;
			IReturnType t = null;
			if (callingClass != null && !reference.IsGlobal) {
				foreach (ITypeParameter tp in callingClass.TypeParameters) {
					if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType)) {
						t = new GenericReturnType(tp);
						break;
					}
				}
				if (t == null && callingMember is IMethod && (callingMember as IMethod).TypeParameters != null) {
					foreach (ITypeParameter tp in (callingMember as IMethod).TypeParameters) {
						if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType)) {
							t = new GenericReturnType(tp);
							break;
						}
					}
				}
			}
			if (t == null) {
				if (reference.Type != reference.SystemType) {
					// keyword-type like void, int, string etc.
					IClass c = projectContent.GetClass(reference.SystemType);
					if (c != null)
						t = c.DefaultReturnType;
					else
						t = new GetClassReturnType(projectContent, reference.SystemType, 0);
				} else {
					int typeParameterCount = reference.GenericTypes.Count;
					if (useLazyReturnType) {
						if (reference.IsGlobal)
							t = new GetClassReturnType(projectContent, reference.SystemType, typeParameterCount);
						else if (callingClass != null)
							t = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.SystemType, typeParameterCount);
					} else {
						IClass c;
						if (reference.IsGlobal) {
							c = projectContent.GetClass(reference.SystemType, typeParameterCount);
							t = (c != null) ? c.DefaultReturnType : null;
						} else if (callingClass != null) {
							t = projectContent.SearchType(new SearchTypeRequest(reference.SystemType, typeParameterCount, callingClass, caretLine, caretColumn)).Result;
						}
						if (t == null) {
							if (reference.GenericTypes.Count == 0 && !reference.IsArrayType) {
								// reference to namespace is possible
								if (reference.IsGlobal) {
									if (projectContent.NamespaceExists(reference.Type))
										return new NamespaceReturnType(reference.Type);
								} else {
									string name = projectContent.SearchNamespace(reference.Type, callingClass, (callingClass == null) ? null : callingClass.CompilationUnit, caretLine, caretColumn);
									if (name != null)
										return new NamespaceReturnType(name);
								}
							}
							return null;
						}
					}
				}
			}
			if (reference.GenericTypes.Count > 0) {
				List<IReturnType> para = new List<IReturnType>(reference.GenericTypes.Count);
				for (int i = 0; i < reference.GenericTypes.Count; ++i) {
					para.Add(CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, useLazyReturnType));
				}
				t = new ConstructedReturnType(t, para);
			}
			return WrapArray(projectContent, t, reference);
		}