From 0a625baf52e949b454ea197039a824d59be4f272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Mon, 10 Jan 2005 22:12:35 +0000 Subject: [PATCH] Worked on code completion layer. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@39 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/Main/Base/Project/Src/Dom/IClass.cs | 6 + .../Base/Project/Src/Dom/ICompilationUnit.cs | 9 ++ src/Main/Base/Project/Src/Dom/IDecoration.cs | 6 +- .../Src/Dom/Implementations/AbstractClass.cs | 89 ++++++++++- .../AbstractCompilationUnit.cs | 54 +++++++ .../Dom/Implementations/AbstractDecoration.cs | 24 ++- .../Src/Dom/Implementations/AbstractEvent.cs | 15 +- .../Src/Dom/Implementations/AbstractField.cs | 7 +- .../Dom/Implementations/AbstractIndexer.cs | 7 +- .../Src/Dom/Implementations/AbstractMember.cs | 4 + .../Src/Dom/Implementations/AbstractMethod.cs | 6 +- .../Implementations/AbstractNamedEntity.cs | 4 + .../Dom/Implementations/AbstractProperty.cs | 6 +- .../Src/Dom/NRefactoryResolver/Class.cs | 2 +- .../Src/Dom/NRefactoryResolver/Constructor.cs | 2 +- .../Src/Dom/NRefactoryResolver/Destructor.cs | 2 +- .../Src/Dom/NRefactoryResolver/Event.cs | 2 +- .../Src/Dom/NRefactoryResolver/Field.cs | 2 +- .../Src/Dom/NRefactoryResolver/Indexer.cs | 2 +- .../Src/Dom/NRefactoryResolver/Method.cs | 2 +- .../NRefactoryASTConvertVisitor.cs | 48 +++--- .../NRefactoryResolver/NRefactoryResolver.cs | 18 +-- .../Src/Dom/NRefactoryResolver/Property.cs | 2 +- .../Dom/ReflectionLayer/ReflectionClass.cs | 18 +-- .../Dom/ReflectionLayer/ReflectionEvent.cs | 2 +- .../Dom/ReflectionLayer/ReflectionField.cs | 2 +- .../Dom/ReflectionLayer/ReflectionIndexer.cs | 2 +- .../Dom/ReflectionLayer/ReflectionMethod.cs | 2 +- .../Dom/ReflectionLayer/ReflectionProperty.cs | 2 +- .../ClassBrowser/Nodes/ReferenceFolderNode.cs | 2 +- .../AmbienceReflectionDecorator.cs | 10 +- .../CaseSensitiveProjectContent.cs | 146 +----------------- .../Services/ParserService/IProjectContent.cs | 11 +- 33 files changed, 295 insertions(+), 221 deletions(-) diff --git a/src/Main/Base/Project/Src/Dom/IClass.cs b/src/Main/Base/Project/Src/Dom/IClass.cs index 479e0853c6..c28c611330 100644 --- a/src/Main/Base/Project/Src/Dom/IClass.cs +++ b/src/Main/Base/Project/Src/Dom/IClass.cs @@ -90,5 +90,11 @@ namespace ICSharpCode.SharpDevelop.Dom get; } + bool IsTypeInInheritanceTree(IClass possibleBaseClass); + + IMember SearchMember(string memberName); + + IClass GetInnermostClass(int caretLine, int caretColumn); + } } diff --git a/src/Main/Base/Project/Src/Dom/ICompilationUnit.cs b/src/Main/Base/Project/Src/Dom/ICompilationUnit.cs index 5e79249e26..14c1a7500d 100644 --- a/src/Main/Base/Project/Src/Dom/ICompilationUnit.cs +++ b/src/Main/Base/Project/Src/Dom/ICompilationUnit.cs @@ -58,5 +58,14 @@ namespace ICSharpCode.SharpDevelop.Dom List FoldingRegions { get; } + + + /// + /// Returns the innerst class in which the carret currently is, returns null + /// if the carret is outside any class boundaries. + /// + IClass GetInnermostClass(int caretLine, int caretColumn); + + List GetOuterClasses(int caretLine, int caretColumn); } } diff --git a/src/Main/Base/Project/Src/Dom/IDecoration.cs b/src/Main/Base/Project/Src/Dom/IDecoration.cs index 239c71333d..431cae11e7 100644 --- a/src/Main/Base/Project/Src/Dom/IDecoration.cs +++ b/src/Main/Base/Project/Src/Dom/IDecoration.cs @@ -12,10 +12,14 @@ namespace ICSharpCode.SharpDevelop.Dom { public interface IDecoration: IComparable { + IClass DeclaringType { + get; + } + ModifierEnum Modifiers { get; } - + List Attributes { get; } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractClass.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractClass.cs index d2a32d485c..8e2b31887b 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractClass.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractClass.cs @@ -40,11 +40,13 @@ namespace ICSharpCode.SharpDevelop.Dom } } - protected AbstractClass(ICompilationUnit compilationUnit) + protected AbstractClass(ICompilationUnit compilationUnit, IClass declaringType) : base(declaringType) { this.compilationUnit = compilationUnit; } + + public ICompilationUnit CompilationUnit { get { return compilationUnit; @@ -240,6 +242,91 @@ namespace ICSharpCode.SharpDevelop.Dom } } + + public bool IsTypeInInheritanceTree(IClass possibleBaseClass) + { + if (possibleBaseClass == null) { + return false; + } + + if (FullyQualifiedName == possibleBaseClass.FullyQualifiedName) { + return true; + } + + foreach (string baseClassName in BaseTypes) { + IClass baseClass = ProjectContent.SearchType(baseClassName, this, CompilationUnit, Region != null ? Region.BeginLine : -1, Region != null ? Region.BeginColumn : -1); + if (baseClass != null && baseClass.IsTypeInInheritanceTree(possibleBaseClass)) { + return true; + } + } + return false; + } + + public IMember SearchMember(string memberName) + { + if (memberName == null || memberName.Length == 0) { + return null; + } + foreach (IField f in Fields) { + if (f.Name == memberName) { + return f; + } + } + foreach (IProperty p in Properties) { + if (p.Name == memberName) { + return p; + } + } + foreach (IIndexer i in Indexer) { + if (i.Name == memberName) { + return i; + } + } + foreach (IEvent e in Events) { + if (e.Name == memberName) { + return e; + } + } + foreach (IMethod m in Methods) { + if (m.Name == memberName) { + return m; + } + } + if (ClassType == ClassType.Interface) { + foreach (string baseType in BaseTypes) { + int line = -1; + int col = -1; + if (Region != null) { + line = Region.BeginLine; + col = Region.BeginColumn; + } + IClass c = ProjectContent.SearchType(baseType, this, line, col); + if (c != null) { + return c.SearchMember(memberName); + } + } + } else { + IClass c = BaseClass; + return c.SearchMember(memberName); + } + return null; + } + + public IClass GetInnermostClass(int caretLine, int caretColumn) + { + if (InnerClasses == null) { + return this; + } + + foreach (IClass c in InnerClasses) { + if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + return c.GetInnermostClass(caretLine, caretColumn); + } + } + return this; + } + + public class ClassInheritanceEnumerator : IEnumerator, IEnumerable { IClass topLevelClass; diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractCompilationUnit.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractCompilationUnit.cs index 8673c2f4a7..b0764ff87f 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractCompilationUnit.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractCompilationUnit.cs @@ -102,6 +102,60 @@ namespace ICSharpCode.SharpDevelop.Dom this.projectContent = projectContent; } + public IClass GetInnermostClass(int caretLine, int caretColumn) + { + foreach (IClass c in Classes) { + if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + return c.GetInnermostClass(caretLine, caretColumn); + } + } + return null; + } + + + + /// + /// Returns all (nestet) classes in which the carret currently is exept + /// the innermost class, returns an empty collection if the carret is in + /// no class or only in the innermost class. + /// the most outer class is the last in the collection. + /// + public List GetOuterClasses(int caretLine, int caretColumn) + { + List classes = new List(); + IClass innerMostClass = GetInnermostClass(caretLine, caretColumn); + foreach (IClass c in Classes) { + if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + if (c != innerMostClass) { + GetOuterClasses(classes, c, caretLine, caretColumn); + if (!classes.Contains(c)) { + classes.Add(c); + } + } + break; + } + } + return classes; + } + + void GetOuterClasses(List classes, IClass curClass, int caretLine, int caretColumn) + { + if (curClass != null && curClass.InnerClasses.Count > 0) { + IClass innerMostClass = GetInnermostClass(caretLine, caretColumn); + foreach (IClass c in curClass.InnerClasses) { + if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { + if (c != innerMostClass) { + GetOuterClasses(classes, c, caretLine, caretColumn); + if (!classes.Contains(c)) { + classes.Add(c); + } + } + break; + } + } + } + } + public override string ToString() { return String.Format("[AbstractCompilationUnit: classes = {0}, fileName = {1}]", classes.Count, diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs index e772c0326b..c1df015859 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs @@ -17,8 +17,16 @@ namespace ICSharpCode.SharpDevelop.Dom protected ModifierEnum modifiers = ModifierEnum.None; protected List attributes = null; + IClass declaringType; object userData = null; + public IClass DeclaringType { + get { + return declaringType; + } + } + + public object UserData { get { return userData; @@ -143,19 +151,25 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public virtual int CompareTo(IDecoration value) { + public AbstractDecoration(IClass declaringType) + { + this.declaringType = declaringType; + } + + public virtual int CompareTo(IDecoration value) + { int cmp; - if(0 != (cmp = (int)(Modifiers - value.Modifiers))) + if (0 != (cmp = (int)(Modifiers - value.Modifiers))) { return cmp; + } return DiffUtility.Compare(Attributes, value.Attributes); } - int IComparable.CompareTo(object value) { + int IComparable.CompareTo(object value) + { return CompareTo((IDecoration)value); } - - } } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractEvent.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractEvent.cs index 5d056e2600..1ccb345a54 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractEvent.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractEvent.cs @@ -7,7 +7,8 @@ using System; using System.Reflection; -namespace ICSharpCode.SharpDevelop.Dom { +namespace ICSharpCode.SharpDevelop.Dom +{ [Serializable] public abstract class AbstractEvent : AbstractMember, IEvent { @@ -35,8 +36,13 @@ namespace ICSharpCode.SharpDevelop.Dom { return eventAttributes; } } - - public virtual int CompareTo(IEvent value) { + + public AbstractEvent(IClass declaringType) : base(declaringType) + { + } + + public virtual int CompareTo(IEvent value) + { int cmp; if(0 != (cmp = base.CompareTo((IDecoration)value))) @@ -59,7 +65,8 @@ namespace ICSharpCode.SharpDevelop.Dom { return Region.CompareTo(value.Region); } - int IComparable.CompareTo(object value) { + int IComparable.CompareTo(object value) + { return CompareTo((IEvent)value); } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractField.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractField.cs index 73d600c4ee..b2aab20a49 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractField.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractField.cs @@ -7,7 +7,8 @@ using System; using System.Reflection; -namespace ICSharpCode.SharpDevelop.Dom { +namespace ICSharpCode.SharpDevelop.Dom +{ [Serializable] public abstract class AbstractField : AbstractMember, IField { @@ -17,6 +18,10 @@ namespace ICSharpCode.SharpDevelop.Dom { } } + public AbstractField(IClass declaringType) : base(declaringType) + { + } + public virtual int CompareTo(IField field) { int cmp; diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractIndexer.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractIndexer.cs index f7cc4440d4..f101ea0c75 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractIndexer.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractIndexer.cs @@ -55,7 +55,12 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public virtual int CompareTo(IIndexer value) { + public AbstractIndexer(IClass declaringType) : base(declaringType) + { + } + + public virtual int CompareTo(IIndexer value) + { int cmp; cmp = base.CompareTo((IDecoration)value); if (cmp != 0) { diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs index 4332cc3395..a1b69da2d0 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs @@ -36,5 +36,9 @@ namespace ICSharpCode.SharpDevelop.Dom returnType = value; } } + public AbstractMember(IClass declaringType) : base(declaringType) + { + } + } } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractMethod.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractMethod.cs index 6c965951a9..537dad587d 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractMethod.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractMethod.cs @@ -46,7 +46,11 @@ namespace ICSharpCode.SharpDevelop.Dom return returnType == null || Name == "#ctor"; } } - + + public AbstractMethod(IClass declaringType) : base(declaringType) + { + } + public override string ToString() { return String.Format("[AbstractMethod: FullyQualifiedName={0}, ReturnType = {1}, IsConstructor={2}, Modifier={3}]", diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractNamedEntity.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractNamedEntity.cs index 0b4af1fc88..9aa70522fa 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractNamedEntity.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractNamedEntity.cs @@ -80,5 +80,9 @@ namespace ICSharpCode.SharpDevelop.Dom return false; } } + + public AbstractNamedEntity(IClass declaringType) : base(declaringType) + { + } } } diff --git a/src/Main/Base/Project/Src/Dom/Implementations/AbstractProperty.cs b/src/Main/Base/Project/Src/Dom/Implementations/AbstractProperty.cs index 2fc3999b6a..baaf8637f2 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/AbstractProperty.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/AbstractProperty.cs @@ -82,7 +82,11 @@ namespace ICSharpCode.SharpDevelop.Dom { return SetterRegion != null; } } - + + public AbstractProperty(IClass declaringType) : base(declaringType) + { + } + public virtual int CompareTo(IProperty value) { int cmp; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Class.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Class.cs index c5cdeb2d5d..9e757a9adb 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Class.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Class.cs @@ -10,7 +10,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver { public class Class : AbstractClass { - public Class(ICompilationUnit cu, ClassType t, Modifier m, IRegion region) : base(cu) + public Class(ICompilationUnit cu, ClassType t, Modifier m, IRegion region, IClass declaringType) : base(cu, declaringType) { classType = t; this.region = region; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Constructor.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Constructor.cs index a879f5fd6a..c1b4dcf886 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Constructor.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Constructor.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver modifiers = modifiers | m; } - public Constructor(Modifier m, IRegion region, IRegion bodyRegion) + public Constructor(Modifier m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType) { FullyQualifiedName = "#ctor"; this.region = region; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Destructor.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Destructor.cs index 3889440b8e..335527dd7f 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Destructor.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Destructor.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver modifiers = modifiers | m; } - public Destructor(string className, Modifier m, IRegion region, IRegion bodyRegion) + public Destructor(string className, Modifier m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType) { FullyQualifiedName = "~" + className; this.region = region; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Event.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Event.cs index 252aa8b180..a92d7a6e26 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Event.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Event.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver modifiers = modifiers | m; } - public Event(string name, ReturnType type, Modifier m, IRegion region, IRegion bodyRegion) + public Event(string name, ReturnType type, Modifier m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType) { FullyQualifiedName = name; returnType = type; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Field.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Field.cs index 37e58eaf02..901456d3c3 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Field.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Field.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver modifiers = modifiers | m; } - public Field(ReturnType type, string fullyQualifiedName, Modifier m, IRegion region) + public Field(ReturnType type, string fullyQualifiedName, Modifier m, IRegion region, IClass declaringType) : base(declaringType) { this.returnType = type; this.FullyQualifiedName = fullyQualifiedName; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Indexer.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Indexer.cs index 1b480566ef..9f03de29e8 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Indexer.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Indexer.cs @@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver modifiers = modifiers | m; } - public Indexer(ReturnType type, List parameters, Modifier m, IRegion region, IRegion bodyRegion) + public Indexer(ReturnType type, List parameters, Modifier m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType) { returnType = type; this.Parameters = parameters; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Method.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Method.cs index 6a0097e895..074cc69550 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Method.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Method.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver modifiers = modifiers | m; } - public Method(string name, ReturnType type, Modifier m, IRegion region, IRegion bodyRegion) + public Method(string name, ReturnType type, Modifier m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType) { FullyQualifiedName = name; returnType = type; diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs index fde7f2237a..291ed946b7 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs @@ -21,7 +21,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver { ICompilationUnit cu; Stack currentNamespace = new Stack(); - Stack currentClass = new Stack(); + Stack currentClass = new Stack(); public ICompilationUnit Cu { get { @@ -34,6 +34,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver cu = new CompilationUnit(projectContent); } + Class GetCurrentClass() + { + return currentClass.Count == 0 ? null : currentClass.Peek(); + } + + // TODO: kill abstract compilation unit, replace with implementation. Maybe the whole Abstract layer ? public class CompilationUnit : AbstractCompilationUnit { @@ -155,11 +161,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.TypeDeclaration typeDeclaration, object data) { DefaultRegion region = GetRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation); - Class c = new Class(cu, TranslateClassType(typeDeclaration.Type), typeDeclaration.Modifier, region); + Class c = new Class(cu, TranslateClassType(typeDeclaration.Type), typeDeclaration.Modifier, region, GetCurrentClass()); c.Attributes.AddRange(VisitAttributes(typeDeclaration.Attributes)); if (currentClass.Count > 0) { - Class cur = ((Class)currentClass.Peek()); + Class cur = GetCurrentClass(); cur.InnerClasses.Add(c); c.FullyQualifiedName = cur.FullyQualifiedName + '.' + typeDeclaration.Name; } else { @@ -185,11 +191,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.DelegateDeclaration delegateDeclaration, object data) { DefaultRegion region = GetRegion(delegateDeclaration.StartLocation, delegateDeclaration.EndLocation); - Class c = new Class(cu, ClassType.Delegate, delegateDeclaration.Modifier, region); + Class c = new Class(cu, ClassType.Delegate, delegateDeclaration.Modifier, region, GetCurrentClass()); c.Attributes.AddRange(VisitAttributes(delegateDeclaration.Attributes)); c.BaseTypes.Add("System.Delegate"); if (currentClass.Count > 0) { - Class cur = ((Class)currentClass.Peek()); + Class cur = GetCurrentClass(); cur.InnerClasses.Add(c); c.FullyQualifiedName = cur.FullyQualifiedName + '.' + delegateDeclaration.Name; } else { @@ -200,7 +206,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } cu.Classes.Add(c); } - Method invokeMethod = new Method("Invoke", new ReturnType(delegateDeclaration.ReturnType), delegateDeclaration.Modifier, null, null); + Method invokeMethod = new Method("Invoke", new ReturnType(delegateDeclaration.ReturnType), delegateDeclaration.Modifier, null, null, GetCurrentClass()); c.Methods.Add(invokeMethod); return c; } @@ -210,9 +216,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver DefaultRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation); DefaultRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1)); ReturnType type = new ReturnType(methodDeclaration.TypeReference); - Class c = (Class)currentClass.Peek(); + Class c = GetCurrentClass(); - Method method = new Method(methodDeclaration.Name, type, methodDeclaration.Modifier, region, bodyRegion); + Method method = new Method(methodDeclaration.Name, type, methodDeclaration.Modifier, region, bodyRegion, GetCurrentClass()); method.Attributes.AddRange(VisitAttributes(methodDeclaration.Attributes)); List parameters = new List(); if (methodDeclaration.Parameters != null) { @@ -231,9 +237,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver { DefaultRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation); DefaultRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1)); - Class c = (Class)currentClass.Peek(); + Class c = GetCurrentClass(); - Constructor constructor = new Constructor(constructorDeclaration.Modifier, region, bodyRegion); + Constructor constructor = new Constructor(constructorDeclaration.Modifier, region, bodyRegion, GetCurrentClass()); constructor.Attributes.AddRange(VisitAttributes(constructorDeclaration.Attributes)); List parameters = new List(); if (constructorDeclaration.Parameters != null) { @@ -253,9 +259,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver DefaultRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation); DefaultRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1)); - Class c = (Class)currentClass.Peek(); + Class c = GetCurrentClass(); - Destructor destructor = new Destructor(c.Name, destructorDeclaration.Modifier, region, bodyRegion); + Destructor destructor = new Destructor(c.Name, destructorDeclaration.Modifier, region, bodyRegion, GetCurrentClass()); destructor.Attributes.AddRange(VisitAttributes(destructorDeclaration.Attributes)); c.Methods.Add(destructor); return null; @@ -265,12 +271,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public override object Visit(AST.FieldDeclaration fieldDeclaration, object data) { DefaultRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation); - Class c = (Class)currentClass.Peek(); + Class c = GetCurrentClass(); if (currentClass.Count > 0) { for (int i = 0; i < fieldDeclaration.Fields.Count; ++i) { AST.VariableDeclaration field = (AST.VariableDeclaration)fieldDeclaration.Fields[i]; - Field f = new Field(new ReturnType(fieldDeclaration.GetTypeForField(i)), field.Name, fieldDeclaration.Modifier, region); + Field f = new Field(new ReturnType(fieldDeclaration.GetTypeForField(i)), field.Name, fieldDeclaration.Modifier, region, GetCurrentClass()); f.Attributes.AddRange(VisitAttributes(fieldDeclaration.Attributes)); if (c.ClassType == ClassType.Enum) { f.SetModifiers(ModifierEnum.Const | ModifierEnum.SpecialName); @@ -288,9 +294,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver DefaultRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd); ReturnType type = new ReturnType(propertyDeclaration.TypeReference); - Class c = (Class)currentClass.Peek(); + Class c = GetCurrentClass(); - Property property = new Property(propertyDeclaration.Name, type, propertyDeclaration.Modifier, region, bodyRegion); + Property property = new Property(propertyDeclaration.Name, type, propertyDeclaration.Modifier, region, bodyRegion, GetCurrentClass()); property.Attributes.AddRange(VisitAttributes(propertyDeclaration.Attributes)); c.Properties.Add(property); return null; @@ -301,17 +307,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver DefaultRegion region = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation); DefaultRegion bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd); ReturnType type = new ReturnType(eventDeclaration.TypeReference); - Class c = (Class)currentClass.Peek(); + Class c = GetCurrentClass(); Event e = null; if (eventDeclaration.VariableDeclarators != null) { foreach (ICSharpCode.NRefactory.Parser.AST.VariableDeclaration varDecl in eventDeclaration.VariableDeclarators) { - e = new Event(varDecl.Name, type, eventDeclaration.Modifier, region, bodyRegion); + e = new Event(varDecl.Name, type, eventDeclaration.Modifier, region, bodyRegion, GetCurrentClass()); e.Attributes.AddRange(VisitAttributes(eventDeclaration.Attributes)); c.Events.Add(e); } } else { - e = new Event(eventDeclaration.Name, type, eventDeclaration.Modifier, region, bodyRegion); + e = new Event(eventDeclaration.Name, type, eventDeclaration.Modifier, region, bodyRegion, GetCurrentClass()); e.Attributes.AddRange(VisitAttributes(eventDeclaration.Attributes)); c.Events.Add(e); } @@ -323,7 +329,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver DefaultRegion region = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation); DefaultRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart, indexerDeclaration.BodyEnd); List parameters = new List(); - Indexer i = new Indexer(new ReturnType(indexerDeclaration.TypeReference), parameters, indexerDeclaration.Modifier, region, bodyRegion); + Indexer i = new Indexer(new ReturnType(indexerDeclaration.TypeReference), parameters, indexerDeclaration.Modifier, region, bodyRegion, GetCurrentClass()); i.Attributes.AddRange(VisitAttributes(indexerDeclaration.Attributes)); if (indexerDeclaration.Parameters != null) { foreach (AST.ParameterDeclarationExpression par in indexerDeclaration.Parameters) { @@ -332,7 +338,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver parameters.Add(p); } } - Class c = (Class)currentClass.Peek(); + Class c = GetCurrentClass(); c.Indexer.Add(i); return null; } diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs index 023051f9ea..a2a94c8a3b 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs @@ -148,7 +148,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null); if (cu != null) { - callingClass = projectContent.GetInnermostClass(cu, caretLine, caretColumn); + callingClass = cu.GetInnermostClass(caretLine, caretColumn); } TypeVisitor typeVisitor = new TypeVisitor(this); @@ -345,7 +345,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver ArrayList SearchMethod(ArrayList methods, IClass curType, string memberName) { - bool isClassInInheritanceTree = projectContent.IsClassInInheritanceTree(curType, callingClass); + bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType); foreach (IMethod m in curType.Methods) { if (IsSameName(m.Name, memberName) && @@ -373,7 +373,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver public ArrayList SearchIndexer(ArrayList indexer, IClass curType) { - bool isClassInInheritanceTree = projectContent.IsClassInInheritanceTree(curType, callingClass); + bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType); foreach (IIndexer i in curType.Indexer) { if (projectContent.MustBeShown(curType, i, callingClass, showStatic, isClassInInheritanceTree) && !((i.Modifiers & ModifierEnum.Override) == ModifierEnum.Override)) { indexer.Add(i); @@ -395,7 +395,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver return null; } IClass curType = SearchType(type.FullyQualifiedName, callingClass, cu); - bool isClassInInheritanceTree = projectContent.IsClassInInheritanceTree(curType, callingClass); + bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType); if (curType == null) { return null; @@ -544,7 +544,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } // try if there exists a static member in outer classes named typeName - List classes = projectContent.GetOuterClasses(cu, caretLine, caretColumn); + List classes = cu.GetOuterClasses(caretLine, caretColumn); foreach (IClass c in classes) { t = SearchMember(callingClass == null ? null : new ReturnType(c.FullyQualifiedName), typeName); if (t != null) { @@ -679,7 +679,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null); if (cu != null) { - callingClass = projectContent.GetInnermostClass(cu, caretLine, caretColumn); + callingClass = cu.GetInnermostClass(caretLine, caretColumn); if (callingClass != null) { result.AddRange(projectContent.GetNamespaceContents(callingClass.Namespace)); } @@ -715,12 +715,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver NRefactoryASTConvertVisitor cSharpVisitor = new NRefactoryASTConvertVisitor(parseInfo.MostRecentCompilationUnit != null ? parseInfo.MostRecentCompilationUnit.ProjectContent : null); cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null); if (cu != null) { - callingClass = projectContent.GetInnermostClass(cu, caretLine, caretColumn); + callingClass = cu.GetInnermostClass(caretLine, caretColumn); if (callingClass != null) { IMethod method = GetMethod(caretLine, caretColumn); if (method != null) { foreach (IParameter p in method.Parameters) { - result.Add(new Field(new ReturnType(p.ReturnType.Name, p.ReturnType.ArrayDimensions, p.ReturnType.PointerNestingLevel), p.Name, Modifier.None, method.Region)); + result.Add(new Field(new ReturnType(p.ReturnType.Name, p.ReturnType.ArrayDimensions, p.ReturnType.PointerNestingLevel), p.Name, Modifier.None, method.Region, callingClass)); } } result.AddRange(projectContent.GetNamespaceContents(callingClass.Namespace)); @@ -738,7 +738,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) { // LocalLookupVariable in no known Type in DisplayBindings.TextEditor // so add Field for the Variables - result.Add(new Field(new ReturnType(v.TypeRef), name, Modifier.None, new DefaultRegion(v.StartPos, v.EndPos))); + result.Add(new Field(new ReturnType(v.TypeRef), name, Modifier.None, new DefaultRegion(v.StartPos, v.EndPos), callingClass)); break; } } diff --git a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Property.cs b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Property.cs index 4f531824d2..0cc7c14fd3 100644 --- a/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Property.cs +++ b/src/Main/Base/Project/Src/Dom/NRefactoryResolver/Property.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver modifiers = modifiers | m; } - public Property(string fullyQualifiedName, ReturnType type, Modifier m, IRegion region, IRegion bodyRegion) + public Property(string fullyQualifiedName, ReturnType type, Modifier m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType) { this.FullyQualifiedName = fullyQualifiedName; returnType = type; diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs index 24c3cc751e..1ceb5459bd 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs @@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Dom get { List innerClasses = new List(); foreach (Type nestedType in type.GetNestedTypes(flags)) { - innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType)); + innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, this)); } return innerClasses; } @@ -38,7 +38,7 @@ namespace ICSharpCode.SharpDevelop.Dom get { List fields = new List(); foreach (FieldInfo field in type.GetFields(flags)) { - IField newField = new ReflectionField(field); + IField newField = new ReflectionField(field, this); if (!newField.IsInternal) { fields.Add(newField); } @@ -58,7 +58,7 @@ namespace ICSharpCode.SharpDevelop.Dom p = propertyInfo.GetIndexParameters(); } catch (Exception) {} if (p == null || p.Length == 0) { - properties.Add(new ReflectionProperty(propertyInfo)); + properties.Add(new ReflectionProperty(propertyInfo, this)); } } @@ -77,7 +77,7 @@ namespace ICSharpCode.SharpDevelop.Dom p = propertyInfo.GetIndexParameters(); } catch (Exception) {} if (p != null && p.Length != 0) { - indexer.Add(new ReflectionIndexer(propertyInfo)); + indexer.Add(new ReflectionIndexer(propertyInfo, this)); } } @@ -90,7 +90,7 @@ namespace ICSharpCode.SharpDevelop.Dom List methods = new List(); foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) { - IMethod newMethod = new ReflectionMethod(constructorInfo); + IMethod newMethod = new ReflectionMethod(constructorInfo, this); if (!newMethod.IsInternal) { methods.Add(newMethod); } @@ -98,7 +98,7 @@ namespace ICSharpCode.SharpDevelop.Dom foreach (MethodInfo methodInfo in type.GetMethods(flags)) { if (!methodInfo.IsSpecialName) { - IMethod newMethod = new ReflectionMethod(methodInfo); + IMethod newMethod = new ReflectionMethod(methodInfo, this); if (!newMethod.IsInternal) { methods.Add(newMethod); } @@ -113,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Dom List events = new List(); foreach (EventInfo eventInfo in type.GetEvents(flags)) { - IEvent newEvent = new ReflectionEvent(eventInfo); + IEvent newEvent = new ReflectionEvent(eventInfo, this); if (!newEvent.IsInternal) { events.Add(newEvent); @@ -134,7 +134,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public ReflectionClass(ICompilationUnit compilationUnit, Type type) : base(compilationUnit) + public ReflectionClass(ICompilationUnit compilationUnit, Type type, IClass declaringType) : base(compilationUnit, declaringType) { this.type = type; FullyQualifiedName = type.FullName.Replace("+", "."); @@ -143,7 +143,7 @@ namespace ICSharpCode.SharpDevelop.Dom if (IsDelegate(type)) { classType = ClassType.Delegate; MethodInfo invoke = type.GetMethod("Invoke"); - ReflectionMethod newMethod = new ReflectionMethod(invoke); + ReflectionMethod newMethod = new ReflectionMethod(invoke, this); Methods.Add(newMethod); } else if (type.IsInterface) { classType = ClassType.Interface; diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionEvent.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionEvent.cs index 4f72e46ee2..e6cad1010a 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionEvent.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionEvent.cs @@ -24,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public ReflectionEvent(EventInfo eventInfo) + public ReflectionEvent(EventInfo eventInfo, IClass declaringType) : base(declaringType) { this.eventInfo = eventInfo; FullyQualifiedName = String.Concat(eventInfo.DeclaringType.FullName, ".", eventInfo.Name); diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionField.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionField.cs index 65261ba0ad..c46cfa0329 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionField.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionField.cs @@ -24,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public ReflectionField(FieldInfo fieldInfo) + public ReflectionField(FieldInfo fieldInfo, IClass declaringType) : base(declaringType) { this.fieldInfo = fieldInfo; System.Diagnostics.Debug.Assert(fieldInfo != null); diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionIndexer.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionIndexer.cs index 871046448c..375791bbcc 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionIndexer.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionIndexer.cs @@ -52,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Dom return propertyName.ToString(); } - public ReflectionIndexer(PropertyInfo propertyInfo) + public ReflectionIndexer(PropertyInfo propertyInfo, IClass declaringType) : base(declaringType) { this.propertyInfo = propertyInfo; // indexers does have the same name as the object that declare the indexers diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionMethod.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionMethod.cs index a1b673e415..f800d82093 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionMethod.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionMethod.cs @@ -71,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Dom } } - public ReflectionMethod(MethodBase methodBase) + public ReflectionMethod(MethodBase methodBase, IClass declaringType) : base(declaringType) { this.methodBase = methodBase; string name = methodBase.Name; diff --git a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs index e6ae67d6d6..b77f468045 100644 --- a/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs +++ b/src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom set { } } - public ReflectionProperty(PropertyInfo propertyInfo) + public ReflectionProperty(PropertyInfo propertyInfo, IClass declaringType) : base(declaringType) { this.propertyInfo = propertyInfo; FullyQualifiedName = String.Concat(propertyInfo.DeclaringType.FullName, ".", propertyInfo.Name); diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ReferenceFolderNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ReferenceFolderNode.cs index ff339694c5..27e5733f13 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ReferenceFolderNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ReferenceFolderNode.cs @@ -97,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.Gui Nodes.Clear(); foreach (Type type in assembly.GetTypes()) { if (!type.FullName.StartsWith("<") && type.IsPublic) { - IClass c = new ReflectionClass(null, type); + IClass c = new ReflectionClass(null, type, null); TreeNode node = GetNodeByPath(c.Namespace, true); new ClassNode(item.Project, c).AddTo(node); } diff --git a/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs b/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs index 47fbb34a4a..0299b8c9f2 100644 --- a/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs +++ b/src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs @@ -94,27 +94,27 @@ namespace ICSharpCode.Core public string Convert(Type type) { - return conv.Convert(new ReflectionClass(null, type)); + return conv.Convert(new ReflectionClass(null, type, null)); } public string Convert(FieldInfo field) { - return conv.Convert(new ReflectionField(field)); + return conv.Convert(new ReflectionField(field, null)); } public string Convert(PropertyInfo property) { - return conv.Convert(new ReflectionProperty(property)); + return conv.Convert(new ReflectionProperty(property, null)); } public string Convert(EventInfo e) { - return conv.Convert(new ReflectionEvent(e)); + return conv.Convert(new ReflectionEvent(e, null)); } public string Convert(MethodBase m) { - return conv.Convert(new ReflectionMethod(m)); + return conv.Convert(new ReflectionMethod(m, null)); } public string Convert(ParameterInfo param) diff --git a/src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs index 94ba71b9b7..e398b9f79f 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs @@ -76,7 +76,7 @@ namespace ICSharpCode.Core foreach (Type type in assembly.GetTypes()) { if (!type.FullName.StartsWith("<") && type.IsPublic) { - newProjectContent.AddClassToNamespaceList(new ReflectionClass(assemblyCompilationUnit, type)); + newProjectContent.AddClassToNamespaceList(new ReflectionClass(assemblyCompilationUnit, type, null)); } } string fileName = LookupLocalizedXmlDoc(assembly.Location); @@ -304,80 +304,6 @@ namespace ICSharpCode.Core return true; } - /// - /// Returns the innerst class in which the carret currently is, returns null - /// if the carret is outside any class boundaries. - /// - public IClass GetInnermostClass(ICompilationUnit cu, int caretLine, int caretColumn) - { - if (cu != null) { - foreach (IClass c in cu.Classes) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { - return GetInnermostClass(c, caretLine, caretColumn); - } - } - } - return null; - } - - IClass GetInnermostClass(IClass curClass, int caretLine, int caretColumn) - { - if (curClass == null) { - return null; - } - if (curClass.InnerClasses == null) { - return curClass; - } - foreach (IClass c in curClass.InnerClasses) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { - return GetInnermostClass(c, caretLine, caretColumn); - } - } - return curClass; - } - - /// - /// Returns all (nestet) classes in which the carret currently is exept - /// the innermost class, returns an empty collection if the carret is in - /// no class or only in the innermost class. - /// the most outer class is the last in the collection. - /// - public List GetOuterClasses(ICompilationUnit cu, int caretLine, int caretColumn) - { - List classes = new List(); - if (cu != null) { - foreach (IClass c in cu.Classes) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { - if (c != GetInnermostClass(cu, caretLine, caretColumn)) { - GetOuterClasses(classes, c, cu, caretLine, caretColumn); - if (!classes.Contains(c)) { - classes.Add(c); - } - } - break; - } - } - } - - return classes; - } - - void GetOuterClasses(List classes, IClass curClass, ICompilationUnit cu, int caretLine, int caretColumn) - { - if (curClass != null) { - foreach (IClass c in curClass.InnerClasses) { - if (c != null && c.Region != null && c.Region.IsInside(caretLine, caretColumn)) { - if (c != GetInnermostClass(cu, caretLine, caretColumn)) { - GetOuterClasses(classes, c, cu, caretLine, caretColumn); - if (!classes.Contains(c)) { - classes.Add(c); - } - } - break; - } - } - } - } public string SearchNamespace(string name, ICompilationUnit unit, int caretLine, int caretColumn) { @@ -473,21 +399,6 @@ namespace ICSharpCode.Core return null; } - public bool IsClassInInheritanceTree(IClass possibleBaseClass, IClass c) - { - if (possibleBaseClass == null || c == null) { - return false; - } - if (possibleBaseClass.FullyQualifiedName == c.FullyQualifiedName) { - return true; - } - foreach (string baseClass in c.BaseTypes) { - if (IsClassInInheritanceTree(possibleBaseClass, SearchType(baseClass, c, c.CompilationUnit, c.Region != null ? c.Region.BeginLine : -1, c.Region != null ? c.Region.BeginColumn : -1))) { - return true; - } - } - return false; - } bool IsInnerClass(IClass c, IClass possibleInnerClass) { @@ -536,7 +447,7 @@ namespace ICSharpCode.Core public ArrayList ListTypes(ArrayList types, IClass curType, IClass callingClass) { // Console.WriteLine("ListTypes()"); - bool isClassInInheritanceTree = IsClassInInheritanceTree(curType, callingClass); + bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType); foreach (IClass c in curType.InnerClasses) { if (((c.ClassType == ClassType.Class) || (c.ClassType == ClassType.Struct)) && IsAccessible(curType, c, callingClass, isClassInInheritanceTree)) { @@ -567,7 +478,7 @@ namespace ICSharpCode.Core return members; } - bool isClassInInheritanceTree = IsClassInInheritanceTree(curType, callingClass); + bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType); if (showStatic) { foreach (IClass c in curType.InnerClasses) { @@ -618,55 +529,6 @@ namespace ICSharpCode.Core return members; } - public IMember SearchMember(IClass declaringType, string memberName) - { - if (declaringType == null || memberName == null || memberName.Length == 0) { - return null; - } - foreach (IField f in declaringType.Fields) { - if (f.Name == memberName) { - return f; - } - } - foreach (IProperty p in declaringType.Properties) { - if (p.Name == memberName) { - return p; - } - } - foreach (IIndexer i in declaringType.Indexer) { - if (i.Name == memberName) { - return i; - } - } - foreach (IEvent e in declaringType.Events) { - if (e.Name == memberName) { - return e; - } - } - foreach (IMethod m in declaringType.Methods) { - if (m.Name == memberName) { - return m; - } - } - if (declaringType.ClassType == ClassType.Interface) { - foreach (string baseType in declaringType.BaseTypes) { - int line = -1; - int col = -1; - if (declaringType.Region != null) { - line = declaringType.Region.BeginLine; - col = declaringType.Region.BeginColumn; - } - IClass c = SearchType(baseType, declaringType, line, col); - if (c != null) { - return SearchMember(c, memberName); - } - } - } else { - IClass c = declaringType.BaseClass; - return SearchMember(c, memberName); - } - return null; - } public Position GetPosition(string fullMemberName) { @@ -699,7 +561,7 @@ namespace ICSharpCode.Core if (i >= name.Length) { return new Position(cu, curClass.Region != null ? curClass.Region.BeginLine : -1, curClass.Region != null ? curClass.Region.BeginColumn : -1); } - IMember member = SearchMember(curClass, name[i]); + IMember member = curClass.SearchMember(name[i]); if (member == null || member.Region == null) { return new Position(cu, -1, -1); } diff --git a/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs index 0dc90ae5a0..b9ff9f53d7 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs @@ -35,23 +35,22 @@ namespace ICSharpCode.Core Hashtable AddClassToNamespaceList(IClass addClass); void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName, bool updateCommentTags); + IClass GetClass(string typeName); + bool NamespaceExists(string name); string[] GetNamespaceList(string subNameSpace); ArrayList GetNamespaceContents(string subNameSpace); - bool NamespaceExists(string name); - IClass GetInnermostClass(ICompilationUnit cu, int caretLine, int caretColumn); - List GetOuterClasses(ICompilationUnit cu, int caretLine, int caretColumn); + string SearchNamespace(string name, ICompilationUnit unit, int caretLine, int caretColumn); IClass SearchType(string name, IClass curType, int caretLine, int caretColumn); IClass SearchType(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn); - bool IsClassInInheritanceTree(IClass possibleBaseClass, IClass c); - bool IsAccessible(IClass c, IDecoration member, IClass callingClass, bool isClassInInheritanceTree); bool MustBeShown(IClass c, IDecoration member, IClass callingClass, bool showStatic, bool isClassInInheritanceTree); + ArrayList ListTypes(ArrayList types, IClass curType, IClass callingClass); ArrayList ListMembers(ArrayList members, IClass curType, IClass callingClass, bool showStatic); - IMember SearchMember(IClass declaringType, string memberName); + Position GetPosition(string fullMemberName); } }