public TypeUpdateInformation UpdateTypeInformation(IList <IType> newClasses, string fileName) { TypeUpdateInformation res = new TypeUpdateInformation(); //Console.WriteLine ("UPDATE TYPE INFO: " + newClasses.Count); for (int n = 0; n < newClasses.Count; n++) { IType c = newClasses[n]; c.SourceProjectDom = this; // Remove file from compound types. NamespaceEntry entry = rootNamespace.FindNamespace(c.Namespace, true); IType t; if (entry.ContainingTypes.TryGetValue(NamespaceEntry.GetDecoratedName(c), out t)) { CompoundType.RemoveFile(t, c.CompilationUnit.FileName); } } for (int n = 0; n < newClasses.Count; n++) { IType c = newClasses[n]; NamespaceEntry entry = rootNamespace.FindNamespace(c.Namespace, true); entry.Add(c); ResetInstantiatedTypes(c); } //Console.WriteLine ("root:" + rootNamespace); return(res); }
public override IType GetType(string typeName, IList <IReturnType> genericArguments, bool deepSearchReferences, bool caseSensitive) { int genericArgumentCount = ExtractGenericArgCount(ref typeName); if (genericArguments != null) { genericArgumentCount = genericArguments.Count; } string decoratedTypeName = NamespaceEntry.GetDecoratedName(typeName, genericArgumentCount); //Console.WriteLine ("Get Type: >" + typeName+"< " + genericArgumentCount + " in " + this.Uri + " deep refs:" + deepSearchReferences + " type count:" + Types.Count ()); NamespaceEntry entry = rootNamespace.FindNamespace(decoratedTypeName, false); //Console.WriteLine ("found entry:" + entry); IType searchType; if (entry.ContainingTypes.TryGetValue(decoratedTypeName, out searchType)) { IType result = CreateInstantiatedGenericType(searchType, genericArguments); //Console.WriteLine ("found type:" + result); return(result); } // may be inner type foreach (IType type in entry.ContainingTypes.Values) { string name = NamespaceEntry.GetDecoratedName(type); if (decoratedTypeName.StartsWith(name)) { string innerClassName = decoratedTypeName.Substring(name.Length + 1); //Console.WriteLine ("icn:" + innerClassName); IType inner = SearchInnerType(type, innerClassName, genericArgumentCount, caseSensitive); if (inner != null) { //Console.WriteLine ("found inner:" + inner); return(CreateInstantiatedGenericType(inner, genericArguments)); } } } /* * if (deepSearchReferences) { * foreach (string uri in this.OnGetReferences ()) { * ProjectDom dom = ProjectDomService.GetDomForUri (uri); * if (dom != null) { * IType result = dom.GetType (typeName, genericArguments, false, caseSensitive); * if (result != null) { * //Console.WriteLine ("found in :" + uri + " : " + result); * return result; * } * } * } * }*/ return(null); }
internal List <IType> ResolveTypeParameters(IEnumerable <IType> types) { List <IType> result = new List <IType> (); foreach (IType type in types) { if (type.TypeParameters.Count == 0) { result.Add(type); continue; } GenericTypeInstanceResolver resolver = new GenericTypeInstanceResolver(); string typeName = NamespaceEntry.GetDecoratedName(type); foreach (TypeParameter par in type.TypeParameters) { resolver.Add(par.Name, new DomReturnType(NamespaceEntry.ConcatNamespaces(typeName, par.Name))); } resolver.Visit(type, type); result.Add((IType)type.AcceptVisitor(resolver, type)); } return(result); }
public override IType GetType(string typeName, int genericArgumentsCount, bool deepSearchReferences, bool caseSensitive) { return(GetType(NamespaceEntry.GetDecoratedName(typeName, genericArgumentsCount), null, deepSearchReferences, caseSensitive)); }