Browse Source

Worked on code completion layer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@39 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 21 years ago
parent
commit
0a625baf52
  1. 6
      src/Main/Base/Project/Src/Dom/IClass.cs
  2. 9
      src/Main/Base/Project/Src/Dom/ICompilationUnit.cs
  3. 6
      src/Main/Base/Project/Src/Dom/IDecoration.cs
  4. 89
      src/Main/Base/Project/Src/Dom/Implementations/AbstractClass.cs
  5. 54
      src/Main/Base/Project/Src/Dom/Implementations/AbstractCompilationUnit.cs
  6. 24
      src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs
  7. 15
      src/Main/Base/Project/Src/Dom/Implementations/AbstractEvent.cs
  8. 7
      src/Main/Base/Project/Src/Dom/Implementations/AbstractField.cs
  9. 7
      src/Main/Base/Project/Src/Dom/Implementations/AbstractIndexer.cs
  10. 4
      src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs
  11. 6
      src/Main/Base/Project/Src/Dom/Implementations/AbstractMethod.cs
  12. 4
      src/Main/Base/Project/Src/Dom/Implementations/AbstractNamedEntity.cs
  13. 6
      src/Main/Base/Project/Src/Dom/Implementations/AbstractProperty.cs
  14. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Class.cs
  15. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Constructor.cs
  16. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Destructor.cs
  17. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Event.cs
  18. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Field.cs
  19. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Indexer.cs
  20. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Method.cs
  21. 48
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  22. 18
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  23. 2
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/Property.cs
  24. 18
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs
  25. 2
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionEvent.cs
  26. 2
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionField.cs
  27. 2
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionIndexer.cs
  28. 2
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionMethod.cs
  29. 2
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs
  30. 2
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ReferenceFolderNode.cs
  31. 10
      src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs
  32. 146
      src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs
  33. 11
      src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs

6
src/Main/Base/Project/Src/Dom/IClass.cs

@ -90,5 +90,11 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
bool IsTypeInInheritanceTree(IClass possibleBaseClass);
IMember SearchMember(string memberName);
IClass GetInnermostClass(int caretLine, int caretColumn);
} }
} }

9
src/Main/Base/Project/Src/Dom/ICompilationUnit.cs

@ -58,5 +58,14 @@ namespace ICSharpCode.SharpDevelop.Dom
List<FoldingRegion> FoldingRegions { List<FoldingRegion> FoldingRegions {
get; get;
} }
/// <summary>
/// Returns the innerst class in which the carret currently is, returns null
/// if the carret is outside any class boundaries.
/// </summary>
IClass GetInnermostClass(int caretLine, int caretColumn);
List<IClass> GetOuterClasses(int caretLine, int caretColumn);
} }
} }

6
src/Main/Base/Project/Src/Dom/IDecoration.cs

@ -12,10 +12,14 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
public interface IDecoration: IComparable public interface IDecoration: IComparable
{ {
IClass DeclaringType {
get;
}
ModifierEnum Modifiers { ModifierEnum Modifiers {
get; get;
} }
List<IAttributeSection> Attributes { List<IAttributeSection> Attributes {
get; get;
} }

89
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; this.compilationUnit = compilationUnit;
} }
public ICompilationUnit CompilationUnit { public ICompilationUnit CompilationUnit {
get { get {
return compilationUnit; 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 public class ClassInheritanceEnumerator : IEnumerator, IEnumerable
{ {
IClass topLevelClass; IClass topLevelClass;

54
src/Main/Base/Project/Src/Dom/Implementations/AbstractCompilationUnit.cs

@ -102,6 +102,60 @@ namespace ICSharpCode.SharpDevelop.Dom
this.projectContent = projectContent; 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;
}
/// <remarks>
/// 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.
/// </remarks>
public List<IClass> GetOuterClasses(int caretLine, int caretColumn)
{
List<IClass> classes = new List<IClass>();
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<IClass> 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() { public override string ToString() {
return String.Format("[AbstractCompilationUnit: classes = {0}, fileName = {1}]", return String.Format("[AbstractCompilationUnit: classes = {0}, fileName = {1}]",
classes.Count, classes.Count,

24
src/Main/Base/Project/Src/Dom/Implementations/AbstractDecoration.cs

@ -17,8 +17,16 @@ namespace ICSharpCode.SharpDevelop.Dom
protected ModifierEnum modifiers = ModifierEnum.None; protected ModifierEnum modifiers = ModifierEnum.None;
protected List<IAttributeSection> attributes = null; protected List<IAttributeSection> attributes = null;
IClass declaringType;
object userData = null; object userData = null;
public IClass DeclaringType {
get {
return declaringType;
}
}
public object UserData { public object UserData {
get { get {
return userData; 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; int cmp;
if(0 != (cmp = (int)(Modifiers - value.Modifiers))) if (0 != (cmp = (int)(Modifiers - value.Modifiers))) {
return cmp; return cmp;
}
return DiffUtility.Compare(Attributes, value.Attributes); return DiffUtility.Compare(Attributes, value.Attributes);
} }
int IComparable.CompareTo(object value) { int IComparable.CompareTo(object value)
{
return CompareTo((IDecoration)value); return CompareTo((IDecoration)value);
} }
} }
} }

15
src/Main/Base/Project/Src/Dom/Implementations/AbstractEvent.cs

@ -7,7 +7,8 @@
using System; using System;
using System.Reflection; using System.Reflection;
namespace ICSharpCode.SharpDevelop.Dom { namespace ICSharpCode.SharpDevelop.Dom
{
[Serializable] [Serializable]
public abstract class AbstractEvent : AbstractMember, IEvent public abstract class AbstractEvent : AbstractMember, IEvent
{ {
@ -35,8 +36,13 @@ namespace ICSharpCode.SharpDevelop.Dom {
return eventAttributes; return eventAttributes;
} }
} }
public virtual int CompareTo(IEvent value) { public AbstractEvent(IClass declaringType) : base(declaringType)
{
}
public virtual int CompareTo(IEvent value)
{
int cmp; int cmp;
if(0 != (cmp = base.CompareTo((IDecoration)value))) if(0 != (cmp = base.CompareTo((IDecoration)value)))
@ -59,7 +65,8 @@ namespace ICSharpCode.SharpDevelop.Dom {
return Region.CompareTo(value.Region); return Region.CompareTo(value.Region);
} }
int IComparable.CompareTo(object value) { int IComparable.CompareTo(object value)
{
return CompareTo((IEvent)value); return CompareTo((IEvent)value);
} }

7
src/Main/Base/Project/Src/Dom/Implementations/AbstractField.cs

@ -7,7 +7,8 @@
using System; using System;
using System.Reflection; using System.Reflection;
namespace ICSharpCode.SharpDevelop.Dom { namespace ICSharpCode.SharpDevelop.Dom
{
[Serializable] [Serializable]
public abstract class AbstractField : AbstractMember, IField 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) public virtual int CompareTo(IField field)
{ {
int cmp; int cmp;

7
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; int cmp;
cmp = base.CompareTo((IDecoration)value); cmp = base.CompareTo((IDecoration)value);
if (cmp != 0) { if (cmp != 0) {

4
src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs

@ -36,5 +36,9 @@ namespace ICSharpCode.SharpDevelop.Dom
returnType = value; returnType = value;
} }
} }
public AbstractMember(IClass declaringType) : base(declaringType)
{
}
} }
} }

6
src/Main/Base/Project/Src/Dom/Implementations/AbstractMethod.cs

@ -46,7 +46,11 @@ namespace ICSharpCode.SharpDevelop.Dom
return returnType == null || Name == "#ctor"; return returnType == null || Name == "#ctor";
} }
} }
public AbstractMethod(IClass declaringType) : base(declaringType)
{
}
public override string ToString() public override string ToString()
{ {
return String.Format("[AbstractMethod: FullyQualifiedName={0}, ReturnType = {1}, IsConstructor={2}, Modifier={3}]", return String.Format("[AbstractMethod: FullyQualifiedName={0}, ReturnType = {1}, IsConstructor={2}, Modifier={3}]",

4
src/Main/Base/Project/Src/Dom/Implementations/AbstractNamedEntity.cs

@ -80,5 +80,9 @@ namespace ICSharpCode.SharpDevelop.Dom
return false; return false;
} }
} }
public AbstractNamedEntity(IClass declaringType) : base(declaringType)
{
}
} }
} }

6
src/Main/Base/Project/Src/Dom/Implementations/AbstractProperty.cs

@ -82,7 +82,11 @@ namespace ICSharpCode.SharpDevelop.Dom {
return SetterRegion != null; return SetterRegion != null;
} }
} }
public AbstractProperty(IClass declaringType) : base(declaringType)
{
}
public virtual int CompareTo(IProperty value) public virtual int CompareTo(IProperty value)
{ {
int cmp; int cmp;

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Class.cs

@ -10,7 +10,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
{ {
public class Class : AbstractClass 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; classType = t;
this.region = region; this.region = region;

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Constructor.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
modifiers = modifiers | m; 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"; FullyQualifiedName = "#ctor";
this.region = region; this.region = region;

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Destructor.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
modifiers = modifiers | m; 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; FullyQualifiedName = "~" + className;
this.region = region; this.region = region;

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Event.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
modifiers = modifiers | m; 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; FullyQualifiedName = name;
returnType = type; returnType = type;

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Field.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
modifiers = modifiers | m; 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.returnType = type;
this.FullyQualifiedName = fullyQualifiedName; this.FullyQualifiedName = fullyQualifiedName;

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Indexer.cs

@ -13,7 +13,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
modifiers = modifiers | m; modifiers = modifiers | m;
} }
public Indexer(ReturnType type, List<IParameter> parameters, Modifier m, IRegion region, IRegion bodyRegion) public Indexer(ReturnType type, List<IParameter> parameters, Modifier m, IRegion region, IRegion bodyRegion, IClass declaringType) : base(declaringType)
{ {
returnType = type; returnType = type;
this.Parameters = parameters; this.Parameters = parameters;

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Method.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
modifiers = modifiers | m; 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; FullyQualifiedName = name;
returnType = type; returnType = type;

48
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs

@ -21,7 +21,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
{ {
ICompilationUnit cu; ICompilationUnit cu;
Stack currentNamespace = new Stack(); Stack currentNamespace = new Stack();
Stack currentClass = new Stack(); Stack<Class> currentClass = new Stack<Class>();
public ICompilationUnit Cu { public ICompilationUnit Cu {
get { get {
@ -34,6 +34,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
cu = new CompilationUnit(projectContent); 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 ? // TODO: kill abstract compilation unit, replace with implementation. Maybe the whole Abstract layer ?
public class CompilationUnit : AbstractCompilationUnit public class CompilationUnit : AbstractCompilationUnit
{ {
@ -155,11 +161,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.TypeDeclaration typeDeclaration, object data) public override object Visit(AST.TypeDeclaration typeDeclaration, object data)
{ {
DefaultRegion region = GetRegion(typeDeclaration.StartLocation, typeDeclaration.EndLocation); 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)); c.Attributes.AddRange(VisitAttributes(typeDeclaration.Attributes));
if (currentClass.Count > 0) { if (currentClass.Count > 0) {
Class cur = ((Class)currentClass.Peek()); Class cur = GetCurrentClass();
cur.InnerClasses.Add(c); cur.InnerClasses.Add(c);
c.FullyQualifiedName = cur.FullyQualifiedName + '.' + typeDeclaration.Name; c.FullyQualifiedName = cur.FullyQualifiedName + '.' + typeDeclaration.Name;
} else { } else {
@ -185,11 +191,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.DelegateDeclaration delegateDeclaration, object data) public override object Visit(AST.DelegateDeclaration delegateDeclaration, object data)
{ {
DefaultRegion region = GetRegion(delegateDeclaration.StartLocation, delegateDeclaration.EndLocation); 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.Attributes.AddRange(VisitAttributes(delegateDeclaration.Attributes));
c.BaseTypes.Add("System.Delegate"); c.BaseTypes.Add("System.Delegate");
if (currentClass.Count > 0) { if (currentClass.Count > 0) {
Class cur = ((Class)currentClass.Peek()); Class cur = GetCurrentClass();
cur.InnerClasses.Add(c); cur.InnerClasses.Add(c);
c.FullyQualifiedName = cur.FullyQualifiedName + '.' + delegateDeclaration.Name; c.FullyQualifiedName = cur.FullyQualifiedName + '.' + delegateDeclaration.Name;
} else { } else {
@ -200,7 +206,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
cu.Classes.Add(c); 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); c.Methods.Add(invokeMethod);
return c; return c;
} }
@ -210,9 +216,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
DefaultRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation); DefaultRegion region = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1)); DefaultRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1));
ReturnType type = new ReturnType(methodDeclaration.TypeReference); 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)); method.Attributes.AddRange(VisitAttributes(methodDeclaration.Attributes));
List<IParameter> parameters = new List<IParameter>(); List<IParameter> parameters = new List<IParameter>();
if (methodDeclaration.Parameters != null) { if (methodDeclaration.Parameters != null) {
@ -231,9 +237,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
{ {
DefaultRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation); DefaultRegion region = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1)); 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)); constructor.Attributes.AddRange(VisitAttributes(constructorDeclaration.Attributes));
List<IParameter> parameters = new List<IParameter>(); List<IParameter> parameters = new List<IParameter>();
if (constructorDeclaration.Parameters != null) { if (constructorDeclaration.Parameters != null) {
@ -253,9 +259,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
DefaultRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation); DefaultRegion region = GetRegion(destructorDeclaration.StartLocation, destructorDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(destructorDeclaration.EndLocation, destructorDeclaration.Body != null ? destructorDeclaration.Body.EndLocation : new Point(-1, -1)); 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)); destructor.Attributes.AddRange(VisitAttributes(destructorDeclaration.Attributes));
c.Methods.Add(destructor); c.Methods.Add(destructor);
return null; return null;
@ -265,12 +271,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(AST.FieldDeclaration fieldDeclaration, object data) public override object Visit(AST.FieldDeclaration fieldDeclaration, object data)
{ {
DefaultRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation); DefaultRegion region = GetRegion(fieldDeclaration.StartLocation, fieldDeclaration.EndLocation);
Class c = (Class)currentClass.Peek(); Class c = GetCurrentClass();
if (currentClass.Count > 0) { if (currentClass.Count > 0) {
for (int i = 0; i < fieldDeclaration.Fields.Count; ++i) { for (int i = 0; i < fieldDeclaration.Fields.Count; ++i) {
AST.VariableDeclaration field = (AST.VariableDeclaration)fieldDeclaration.Fields[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)); f.Attributes.AddRange(VisitAttributes(fieldDeclaration.Attributes));
if (c.ClassType == ClassType.Enum) { if (c.ClassType == ClassType.Enum) {
f.SetModifiers(ModifierEnum.Const | ModifierEnum.SpecialName); f.SetModifiers(ModifierEnum.Const | ModifierEnum.SpecialName);
@ -288,9 +294,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
DefaultRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd); DefaultRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd);
ReturnType type = new ReturnType(propertyDeclaration.TypeReference); 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)); property.Attributes.AddRange(VisitAttributes(propertyDeclaration.Attributes));
c.Properties.Add(property); c.Properties.Add(property);
return null; return null;
@ -301,17 +307,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
DefaultRegion region = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation); DefaultRegion region = GetRegion(eventDeclaration.StartLocation, eventDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd); DefaultRegion bodyRegion = GetRegion(eventDeclaration.BodyStart, eventDeclaration.BodyEnd);
ReturnType type = new ReturnType(eventDeclaration.TypeReference); ReturnType type = new ReturnType(eventDeclaration.TypeReference);
Class c = (Class)currentClass.Peek(); Class c = GetCurrentClass();
Event e = null; Event e = null;
if (eventDeclaration.VariableDeclarators != null) { if (eventDeclaration.VariableDeclarators != null) {
foreach (ICSharpCode.NRefactory.Parser.AST.VariableDeclaration varDecl in eventDeclaration.VariableDeclarators) { 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)); e.Attributes.AddRange(VisitAttributes(eventDeclaration.Attributes));
c.Events.Add(e); c.Events.Add(e);
} }
} else { } 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)); e.Attributes.AddRange(VisitAttributes(eventDeclaration.Attributes));
c.Events.Add(e); c.Events.Add(e);
} }
@ -323,7 +329,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
DefaultRegion region = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation); DefaultRegion region = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart, indexerDeclaration.BodyEnd); DefaultRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart, indexerDeclaration.BodyEnd);
List<IParameter> parameters = new List<IParameter>(); List<IParameter> parameters = new List<IParameter>();
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)); i.Attributes.AddRange(VisitAttributes(indexerDeclaration.Attributes));
if (indexerDeclaration.Parameters != null) { if (indexerDeclaration.Parameters != null) {
foreach (AST.ParameterDeclarationExpression par in indexerDeclaration.Parameters) { foreach (AST.ParameterDeclarationExpression par in indexerDeclaration.Parameters) {
@ -332,7 +338,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
parameters.Add(p); parameters.Add(p);
} }
} }
Class c = (Class)currentClass.Peek(); Class c = GetCurrentClass();
c.Indexer.Add(i); c.Indexer.Add(i);
return null; return null;
} }

18
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs

@ -148,7 +148,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null); cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null);
if (cu != null) { if (cu != null) {
callingClass = projectContent.GetInnermostClass(cu, caretLine, caretColumn); callingClass = cu.GetInnermostClass(caretLine, caretColumn);
} }
TypeVisitor typeVisitor = new TypeVisitor(this); TypeVisitor typeVisitor = new TypeVisitor(this);
@ -345,7 +345,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
ArrayList SearchMethod(ArrayList methods, IClass curType, string memberName) 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) { foreach (IMethod m in curType.Methods) {
if (IsSameName(m.Name, memberName) && if (IsSameName(m.Name, memberName) &&
@ -373,7 +373,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public ArrayList SearchIndexer(ArrayList indexer, IClass curType) public ArrayList SearchIndexer(ArrayList indexer, IClass curType)
{ {
bool isClassInInheritanceTree = projectContent.IsClassInInheritanceTree(curType, callingClass); bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType);
foreach (IIndexer i in curType.Indexer) { foreach (IIndexer i in curType.Indexer) {
if (projectContent.MustBeShown(curType, i, callingClass, showStatic, isClassInInheritanceTree) && !((i.Modifiers & ModifierEnum.Override) == ModifierEnum.Override)) { if (projectContent.MustBeShown(curType, i, callingClass, showStatic, isClassInInheritanceTree) && !((i.Modifiers & ModifierEnum.Override) == ModifierEnum.Override)) {
indexer.Add(i); indexer.Add(i);
@ -395,7 +395,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return null; return null;
} }
IClass curType = SearchType(type.FullyQualifiedName, callingClass, cu); IClass curType = SearchType(type.FullyQualifiedName, callingClass, cu);
bool isClassInInheritanceTree = projectContent.IsClassInInheritanceTree(curType, callingClass); bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType);
if (curType == null) { if (curType == null) {
return null; return null;
@ -544,7 +544,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
// try if there exists a static member in outer classes named typeName // try if there exists a static member in outer classes named typeName
List<IClass> classes = projectContent.GetOuterClasses(cu, caretLine, caretColumn); List<IClass> classes = cu.GetOuterClasses(caretLine, caretColumn);
foreach (IClass c in classes) { foreach (IClass c in classes) {
t = SearchMember(callingClass == null ? null : new ReturnType(c.FullyQualifiedName), typeName); t = SearchMember(callingClass == null ? null : new ReturnType(c.FullyQualifiedName), typeName);
if (t != null) { if (t != null) {
@ -679,7 +679,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null); cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null);
if (cu != null) { if (cu != null) {
callingClass = projectContent.GetInnermostClass(cu, caretLine, caretColumn); callingClass = cu.GetInnermostClass(caretLine, caretColumn);
if (callingClass != null) { if (callingClass != null) {
result.AddRange(projectContent.GetNamespaceContents(callingClass.Namespace)); 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); NRefactoryASTConvertVisitor cSharpVisitor = new NRefactoryASTConvertVisitor(parseInfo.MostRecentCompilationUnit != null ? parseInfo.MostRecentCompilationUnit.ProjectContent : null);
cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null); cu = (ICompilationUnit)cSharpVisitor.Visit(fileCompilationUnit, null);
if (cu != null) { if (cu != null) {
callingClass = projectContent.GetInnermostClass(cu, caretLine, caretColumn); callingClass = cu.GetInnermostClass(caretLine, caretColumn);
if (callingClass != null) { if (callingClass != null) {
IMethod method = GetMethod(caretLine, caretColumn); IMethod method = GetMethod(caretLine, caretColumn);
if (method != null) { if (method != null) {
foreach (IParameter p in method.Parameters) { 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)); 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)) { if (IsInside(new Point(caretColumn, caretLine), v.StartPos, v.EndPos)) {
// LocalLookupVariable in no known Type in DisplayBindings.TextEditor // LocalLookupVariable in no known Type in DisplayBindings.TextEditor
// so add Field for the Variables // 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; break;
} }
} }

2
src/Main/Base/Project/Src/Dom/NRefactoryResolver/Property.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
modifiers = modifiers | m; 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; this.FullyQualifiedName = fullyQualifiedName;
returnType = type; returnType = type;

18
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionClass.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get { get {
List<IClass> innerClasses = new List<IClass>(); List<IClass> innerClasses = new List<IClass>();
foreach (Type nestedType in type.GetNestedTypes(flags)) { foreach (Type nestedType in type.GetNestedTypes(flags)) {
innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType)); innerClasses.Add(new ReflectionClass(CompilationUnit, nestedType, this));
} }
return innerClasses; return innerClasses;
} }
@ -38,7 +38,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get { get {
List<IField> fields = new List<IField>(); List<IField> fields = new List<IField>();
foreach (FieldInfo field in type.GetFields(flags)) { foreach (FieldInfo field in type.GetFields(flags)) {
IField newField = new ReflectionField(field); IField newField = new ReflectionField(field, this);
if (!newField.IsInternal) { if (!newField.IsInternal) {
fields.Add(newField); fields.Add(newField);
} }
@ -58,7 +58,7 @@ namespace ICSharpCode.SharpDevelop.Dom
p = propertyInfo.GetIndexParameters(); p = propertyInfo.GetIndexParameters();
} catch (Exception) {} } catch (Exception) {}
if (p == null || p.Length == 0) { 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(); p = propertyInfo.GetIndexParameters();
} catch (Exception) {} } catch (Exception) {}
if (p != null && p.Length != 0) { 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<IMethod> methods = new List<IMethod>(); List<IMethod> methods = new List<IMethod>();
foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) { foreach (ConstructorInfo constructorInfo in type.GetConstructors(flags)) {
IMethod newMethod = new ReflectionMethod(constructorInfo); IMethod newMethod = new ReflectionMethod(constructorInfo, this);
if (!newMethod.IsInternal) { if (!newMethod.IsInternal) {
methods.Add(newMethod); methods.Add(newMethod);
} }
@ -98,7 +98,7 @@ namespace ICSharpCode.SharpDevelop.Dom
foreach (MethodInfo methodInfo in type.GetMethods(flags)) { foreach (MethodInfo methodInfo in type.GetMethods(flags)) {
if (!methodInfo.IsSpecialName) { if (!methodInfo.IsSpecialName) {
IMethod newMethod = new ReflectionMethod(methodInfo); IMethod newMethod = new ReflectionMethod(methodInfo, this);
if (!newMethod.IsInternal) { if (!newMethod.IsInternal) {
methods.Add(newMethod); methods.Add(newMethod);
} }
@ -113,7 +113,7 @@ namespace ICSharpCode.SharpDevelop.Dom
List<IEvent> events = new List<IEvent>(); List<IEvent> events = new List<IEvent>();
foreach (EventInfo eventInfo in type.GetEvents(flags)) { foreach (EventInfo eventInfo in type.GetEvents(flags)) {
IEvent newEvent = new ReflectionEvent(eventInfo); IEvent newEvent = new ReflectionEvent(eventInfo, this);
if (!newEvent.IsInternal) { if (!newEvent.IsInternal) {
events.Add(newEvent); 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; this.type = type;
FullyQualifiedName = type.FullName.Replace("+", "."); FullyQualifiedName = type.FullName.Replace("+", ".");
@ -143,7 +143,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (IsDelegate(type)) { if (IsDelegate(type)) {
classType = ClassType.Delegate; classType = ClassType.Delegate;
MethodInfo invoke = type.GetMethod("Invoke"); MethodInfo invoke = type.GetMethod("Invoke");
ReflectionMethod newMethod = new ReflectionMethod(invoke); ReflectionMethod newMethod = new ReflectionMethod(invoke, this);
Methods.Add(newMethod); Methods.Add(newMethod);
} else if (type.IsInterface) { } else if (type.IsInterface) {
classType = ClassType.Interface; classType = ClassType.Interface;

2
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; this.eventInfo = eventInfo;
FullyQualifiedName = String.Concat(eventInfo.DeclaringType.FullName, ".", eventInfo.Name); FullyQualifiedName = String.Concat(eventInfo.DeclaringType.FullName, ".", eventInfo.Name);

2
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; this.fieldInfo = fieldInfo;
System.Diagnostics.Debug.Assert(fieldInfo != null); System.Diagnostics.Debug.Assert(fieldInfo != null);

2
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionIndexer.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return propertyName.ToString(); return propertyName.ToString();
} }
public ReflectionIndexer(PropertyInfo propertyInfo) public ReflectionIndexer(PropertyInfo propertyInfo, IClass declaringType) : base(declaringType)
{ {
this.propertyInfo = propertyInfo; this.propertyInfo = propertyInfo;
// indexers does have the same name as the object that declare the indexers // indexers does have the same name as the object that declare the indexers

2
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; this.methodBase = methodBase;
string name = methodBase.Name; string name = methodBase.Name;

2
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom
set { set {
} }
} }
public ReflectionProperty(PropertyInfo propertyInfo) public ReflectionProperty(PropertyInfo propertyInfo, IClass declaringType) : base(declaringType)
{ {
this.propertyInfo = propertyInfo; this.propertyInfo = propertyInfo;
FullyQualifiedName = String.Concat(propertyInfo.DeclaringType.FullName, ".", propertyInfo.Name); FullyQualifiedName = String.Concat(propertyInfo.DeclaringType.FullName, ".", propertyInfo.Name);

2
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ReferenceFolderNode.cs

@ -97,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.Gui
Nodes.Clear(); Nodes.Clear();
foreach (Type type in assembly.GetTypes()) { foreach (Type type in assembly.GetTypes()) {
if (!type.FullName.StartsWith("<") && type.IsPublic) { 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); TreeNode node = GetNodeByPath(c.Namespace, true);
new ClassNode(item.Project, c).AddTo(node); new ClassNode(item.Project, c).AddTo(node);
} }

10
src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs

@ -94,27 +94,27 @@ namespace ICSharpCode.Core
public string Convert(Type type) 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) public string Convert(FieldInfo field)
{ {
return conv.Convert(new ReflectionField(field)); return conv.Convert(new ReflectionField(field, null));
} }
public string Convert(PropertyInfo property) public string Convert(PropertyInfo property)
{ {
return conv.Convert(new ReflectionProperty(property)); return conv.Convert(new ReflectionProperty(property, null));
} }
public string Convert(EventInfo e) public string Convert(EventInfo e)
{ {
return conv.Convert(new ReflectionEvent(e)); return conv.Convert(new ReflectionEvent(e, null));
} }
public string Convert(MethodBase m) public string Convert(MethodBase m)
{ {
return conv.Convert(new ReflectionMethod(m)); return conv.Convert(new ReflectionMethod(m, null));
} }
public string Convert(ParameterInfo param) public string Convert(ParameterInfo param)

146
src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs

@ -76,7 +76,7 @@ namespace ICSharpCode.Core
foreach (Type type in assembly.GetTypes()) { foreach (Type type in assembly.GetTypes()) {
if (!type.FullName.StartsWith("<") && type.IsPublic) { if (!type.FullName.StartsWith("<") && type.IsPublic) {
newProjectContent.AddClassToNamespaceList(new ReflectionClass(assemblyCompilationUnit, type)); newProjectContent.AddClassToNamespaceList(new ReflectionClass(assemblyCompilationUnit, type, null));
} }
} }
string fileName = LookupLocalizedXmlDoc(assembly.Location); string fileName = LookupLocalizedXmlDoc(assembly.Location);
@ -304,80 +304,6 @@ namespace ICSharpCode.Core
return true; return true;
} }
/// <remarks>
/// Returns the innerst class in which the carret currently is, returns null
/// if the carret is outside any class boundaries.
/// </remarks>
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;
}
/// <remarks>
/// 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.
/// </remarks>
public List<IClass> GetOuterClasses(ICompilationUnit cu, int caretLine, int caretColumn)
{
List<IClass> classes = new List<IClass>();
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<IClass> 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) public string SearchNamespace(string name, ICompilationUnit unit, int caretLine, int caretColumn)
{ {
@ -473,21 +399,6 @@ namespace ICSharpCode.Core
return null; 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) bool IsInnerClass(IClass c, IClass possibleInnerClass)
{ {
@ -536,7 +447,7 @@ namespace ICSharpCode.Core
public ArrayList ListTypes(ArrayList types, IClass curType, IClass callingClass) public ArrayList ListTypes(ArrayList types, IClass curType, IClass callingClass)
{ {
// Console.WriteLine("ListTypes()"); // Console.WriteLine("ListTypes()");
bool isClassInInheritanceTree = IsClassInInheritanceTree(curType, callingClass); bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType);
foreach (IClass c in curType.InnerClasses) { foreach (IClass c in curType.InnerClasses) {
if (((c.ClassType == ClassType.Class) || (c.ClassType == ClassType.Struct)) && if (((c.ClassType == ClassType.Class) || (c.ClassType == ClassType.Struct)) &&
IsAccessible(curType, c, callingClass, isClassInInheritanceTree)) { IsAccessible(curType, c, callingClass, isClassInInheritanceTree)) {
@ -567,7 +478,7 @@ namespace ICSharpCode.Core
return members; return members;
} }
bool isClassInInheritanceTree = IsClassInInheritanceTree(curType, callingClass); bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType);
if (showStatic) { if (showStatic) {
foreach (IClass c in curType.InnerClasses) { foreach (IClass c in curType.InnerClasses) {
@ -618,55 +529,6 @@ namespace ICSharpCode.Core
return members; 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) public Position GetPosition(string fullMemberName)
{ {
@ -699,7 +561,7 @@ namespace ICSharpCode.Core
if (i >= name.Length) { if (i >= name.Length) {
return new Position(cu, curClass.Region != null ? curClass.Region.BeginLine : -1, curClass.Region != null ? curClass.Region.BeginColumn : -1); 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) { if (member == null || member.Region == null) {
return new Position(cu, -1, -1); return new Position(cu, -1, -1);
} }

11
src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs

@ -35,23 +35,22 @@ namespace ICSharpCode.Core
Hashtable AddClassToNamespaceList(IClass addClass); Hashtable AddClassToNamespaceList(IClass addClass);
void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName, bool updateCommentTags); void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName, bool updateCommentTags);
IClass GetClass(string typeName); IClass GetClass(string typeName);
bool NamespaceExists(string name);
string[] GetNamespaceList(string subNameSpace); string[] GetNamespaceList(string subNameSpace);
ArrayList GetNamespaceContents(string subNameSpace); ArrayList GetNamespaceContents(string subNameSpace);
bool NamespaceExists(string name);
IClass GetInnermostClass(ICompilationUnit cu, int caretLine, int caretColumn);
List<IClass> GetOuterClasses(ICompilationUnit cu, int caretLine, int caretColumn);
string SearchNamespace(string name, ICompilationUnit unit, 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, int caretLine, int caretColumn);
IClass SearchType(string name, IClass curType, ICompilationUnit unit, 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 IsAccessible(IClass c, IDecoration member, IClass callingClass, bool isClassInInheritanceTree);
bool MustBeShown(IClass c, IDecoration member, IClass callingClass, bool showStatic, bool isClassInInheritanceTree); bool MustBeShown(IClass c, IDecoration member, IClass callingClass, bool showStatic, bool isClassInInheritanceTree);
ArrayList ListTypes(ArrayList types, IClass curType, IClass callingClass); ArrayList ListTypes(ArrayList types, IClass curType, IClass callingClass);
ArrayList ListMembers(ArrayList members, IClass curType, IClass callingClass, bool showStatic); ArrayList ListMembers(ArrayList members, IClass curType, IClass callingClass, bool showStatic);
IMember SearchMember(IClass declaringType, string memberName);
Position GetPosition(string fullMemberName); Position GetPosition(string fullMemberName);
} }
} }

Loading…
Cancel
Save