39
39
public abstract class ProjectDom
41
protected List<ProjectDom> references;
41
protected List<ProjectDom> references;
42
42
Dictionary<string, IType> instantiatedTypeCache = new Dictionary<string, IType> ();
44
44
public Project Project;
464
464
// Create a fake class which sublcasses System.Array and implements IList<T>
465
465
DomType t = new DomType (ambience.GetString (elementType, MonoDevelop.Projects.Dom.Output.OutputFlags.UseFullName) + "[]");
467
// set the compilation unit of the array type to that of the element type - it's required for jumping to the declaration of the type.
468
IType eType = GetType (elementType);
470
t.CompilationUnit = eType.CompilationUnit;
466
472
t.Resolved = true;
467
473
t.BaseType = new DomReturnType ("System.Array");
468
474
t.ClassType = ClassType.Class;
495
502
return GetArrayType (newType);
498
if (returnType.Type != null) {
499
if (returnType.GenericArguments == null || returnType.GenericArguments.Count == 0)
500
return returnType.Type;
501
return CreateInstantiatedGenericType (returnType.Type, returnType.GenericArguments);
503
return GetType (((DomReturnType)returnType).DecoratedFullName, returnType.GenericArguments, true, true);
505
IType type = returnType.Type ?? GetType (((DomReturnType)returnType).DecoratedFullName, returnType.GenericArguments, true, true);
507
if (type.Kind == TypeKind.GenericInstantiation || type.Kind == TypeKind.GenericParameter)
509
if (!returnType.Parts.Any (part => part.GenericArguments.Count != 0))
511
List<IReturnType> aggregatedGenerics = new List<IReturnType> ();
512
foreach (IReturnTypePart part in returnType.Parts) {
513
aggregatedGenerics.AddRange (part.GenericArguments);
516
return CreateInstantiatedGenericType (type, aggregatedGenerics);
520
IReturnTypePart part = returnType.Parts [0];
521
string name = !string.IsNullOrEmpty (returnType.Namespace) ? returnType.Namespace + "." + part.Name : part.Name;
522
IType ptype = GetType (name, part.GenericArguments, true, true);
525
for (int n=1; n < returnType.Parts.Count; n++) {
526
part = returnType.Parts [n];
527
ptype = SearchInnerType (ptype, part.Name, part.GenericArguments.Count, true);
532
if (part.GenericArguments.Count > 0)
533
ptype = CreateInstantiatedGenericType (ptype, part.GenericArguments);
506
541
public IType GetType (IReturnType returnType, bool searchDeep)
508
543
if (returnType == null)
766
801
int i = typeName.IndexOf ('`');
768
803
typeName = typeName.Substring (0, i);
804
List<IType> result = new List<IType> ();
769
805
Stack<IType> typeStack = new Stack<IType> ();
770
806
foreach (IType curType in Types) {
771
807
typeStack.Push (curType);
772
808
while (typeStack.Count > 0) {
773
809
IType type = typeStack.Pop ();
774
if (type.FullName == typeName)
810
if (type.FullName == typeName)
776
812
foreach (IType inner in type.InnerTypes) {
777
813
typeStack.Push (inner);
817
if (result.Count == 1)
819
if (result.Count > 1)
820
return new CompoundType (result);