~ubuntu-branches/ubuntu/lucid/monodevelop/lucid

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Projects/MonoDevelop.Projects.Dom.Parser/ProjectDom.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-01-10 14:25:59 UTC
  • mfrom: (1.2.5 upstream) (1.3.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100110142559-sorji5exvk9tyknr
Tags: 2.2+dfsg-2
* debian/rules/remove_support_for_non_debian_functionality.patch:
  + Also fix monodevelop-core-addins.pc to remove links to the
    addins we remove in Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
{
39
39
        public abstract class ProjectDom
40
40
        {       
41
 
                protected List<ProjectDom> references;
 
41
                protected List<ProjectDom> references; 
42
42
                Dictionary<string, IType> instantiatedTypeCache = new Dictionary<string, IType> ();
43
43
                
44
44
                public Project Project;
463
463
                {
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) + "[]");
 
466
                        
 
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);
 
469
                        if (eType != null)
 
470
                                t.CompilationUnit = eType.CompilationUnit;
 
471
                        
466
472
                        t.Resolved = true;
467
473
                        t.BaseType = new DomReturnType ("System.Array");
468
474
                        t.ClassType = ClassType.Class;
485
491
                {
486
492
                        if (returnType == null)
487
493
                                return null;
 
494
                        
488
495
                        if (returnType.ArrayDimensions > 0) {
489
496
                                DomReturnType newType = new DomReturnType (returnType.FullName);
490
497
                                newType.ArrayDimensions = returnType.ArrayDimensions - 1;
495
502
                                return GetArrayType (newType);
496
503
                        }
497
504
                        
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);
502
 
                        }
503
 
                        return GetType (((DomReturnType)returnType).DecoratedFullName, returnType.GenericArguments, true, true);
 
505
                        IType type = returnType.Type ?? GetType (((DomReturnType)returnType).DecoratedFullName, returnType.GenericArguments, true, true);
 
506
                        if (type != null)  {
 
507
                                if (type.Kind == TypeKind.GenericInstantiation || type.Kind == TypeKind.GenericParameter)
 
508
                                        return type;
 
509
                                if (!returnType.Parts.Any (part => part.GenericArguments.Count != 0))
 
510
                                        return type;
 
511
                                List<IReturnType> aggregatedGenerics = new List<IReturnType> ();
 
512
                                foreach (IReturnTypePart part in returnType.Parts) {
 
513
                                        aggregatedGenerics.AddRange (part.GenericArguments);
 
514
                                }
 
515
                                
 
516
                                return CreateInstantiatedGenericType (type, aggregatedGenerics);
 
517
                        }
 
518
                        return type;
 
519
/*                      
 
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);
 
523
                        if (ptype == null)
 
524
                                return null;
 
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);
 
528
                                if (ptype != null)
 
529
                                        break;
 
530
                                if (ptype == null)
 
531
                                        return null;
 
532
                                if (part.GenericArguments.Count > 0)
 
533
                                        ptype = CreateInstantiatedGenericType (ptype, part.GenericArguments);
 
534
                        }
 
535
                        return ptype;
 
536
                        */
 
537
                        
 
538
                        
504
539
                }
505
 
                
 
540
                /*
506
541
                public IType GetType (IReturnType returnType, bool searchDeep)
507
542
                {
508
543
                        if (returnType == null)
528
563
                                        ptype = CreateInstantiatedGenericType (ptype, part.GenericArguments);
529
564
                        }
530
565
                        return ptype;
531
 
                }
 
566
                }*/
532
567
                
533
568
                public IType GetType (string typeName)
534
569
                {
766
801
                        int i = typeName.IndexOf ('`');
767
802
                        if (i != -1)
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) 
775
 
                                                return type;
 
810
                                        if (type.FullName == typeName)
 
811
                                                result.Add (type);
776
812
                                        foreach (IType inner in type.InnerTypes) {
777
813
                                                typeStack.Push (inner);
778
814
                                        }
779
815
                                }
780
816
                        }
 
817
                        if (result.Count == 1)
 
818
                                return result[0];
 
819
                        if (result.Count > 1)
 
820
                                return new CompoundType (result);
781
821
                        return null;
782
822
                }
783
823