Browse Source

Worked on SharpDevelop.Dom (just a step closer to being able to begin working on generics support :)).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@124 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
3539fc4de3
  1. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAmbience.cs
  2. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetAmbience.cs
  3. 4
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  4. 23
      src/Main/Base/Project/Src/Dom/IClass.cs
  5. 22
      src/Main/Base/Project/Src/Dom/IReturnType.cs
  6. 19
      src/Main/Base/Project/Src/Dom/ITypeParameter.cs
  7. 8
      src/Main/Base/Project/Src/Dom/Implementations/AbstractNamedEntity.cs
  8. 68
      src/Main/Base/Project/Src/Dom/Implementations/AbstractReturnType.cs
  9. 48
      src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs
  10. 9
      src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs
  11. 8
      src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs
  12. 10
      src/Main/Base/Project/Src/Dom/Implementations/DefaultIndexer.cs
  13. 45
      src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs
  14. 4
      src/Main/Base/Project/Src/Dom/Implementations/DefaultParameter.cs
  15. 7
      src/Main/Base/Project/Src/Dom/Implementations/DefaultProperty.cs
  16. 93
      src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs
  17. 35
      src/Main/Base/Project/Src/Dom/Implementations/DefaultTypeParameter.cs
  18. 90
      src/Main/Base/Project/Src/Dom/Implementations/LazyReturnType.cs
  19. 89
      src/Main/Base/Project/Src/Dom/Implementations/ProxyReturnType.cs
  20. 35
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  21. 224
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  22. 50
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/ReturnType.cs
  23. 69
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/TypeVisitor.cs
  24. 8
      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. 18
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionIndexer.cs
  28. 27
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionMethod.cs
  29. 9
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionParameter.cs
  30. 2
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionProperty.cs
  31. 21
      src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionReturnType.cs
  32. 32
      src/Main/Base/Project/Src/Dom/ResolveResult.cs
  33. 2
      src/Main/Base/Project/Src/Services/AmbienceService/AmbienceReflectionDecorator.cs
  34. 5
      src/Main/Base/Project/Src/Services/AmbienceService/NetAmbience.cs
  35. 10
      src/Main/Base/Project/Src/Services/ParserService/CaseSensitiveProjectContent.cs

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpAmbience.cs

@ -534,6 +534,7 @@ namespace ICSharpCode.Core
builder.Append("</a>"); builder.Append("</a>");
} }
/*
for (int i = 0; i < returnType.PointerNestingLevel; ++i) { for (int i = 0; i < returnType.PointerNestingLevel; ++i) {
builder.Append('*'); builder.Append('*');
} }
@ -545,6 +546,7 @@ namespace ICSharpCode.Core
} }
builder.Append(']'); builder.Append(']');
} }
*/
return builder.ToString(); return builder.ToString();
} }

2
src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetAmbience.cs

@ -504,6 +504,7 @@ namespace VBNetBinding
builder.Append("</a>"); builder.Append("</a>");
} }
/*
for (int i = 0; i < returnType.PointerNestingLevel; ++i) { for (int i = 0; i < returnType.PointerNestingLevel; ++i) {
builder.Append('*'); builder.Append('*');
} }
@ -515,6 +516,7 @@ namespace VBNetBinding
} }
builder.Append(')'); builder.Append(')');
} }
*/
return builder.ToString(); return builder.ToString();
} }

4
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -359,7 +359,6 @@
<Compile Include="Src\Dom\NRefactoryResolver\NRefactoryResolver.cs" /> <Compile Include="Src\Dom\NRefactoryResolver\NRefactoryResolver.cs" />
<Compile Include="Src\Dom\NRefactoryResolver\TypeVisitor.cs" /> <Compile Include="Src\Dom\NRefactoryResolver\TypeVisitor.cs" />
<Compile Include="Src\Dom\NRefactoryResolver\NRefactoryASTConvertVisitor.cs" /> <Compile Include="Src\Dom\NRefactoryResolver\NRefactoryASTConvertVisitor.cs" />
<Compile Include="Src\Dom\NRefactoryResolver\ReturnType.cs" />
<Compile Include="Src\Gui\Components\FontSelectionPanel.cs"> <Compile Include="Src\Gui\Components\FontSelectionPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -641,6 +640,9 @@
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.cs" /> <Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.cs" />
<Compile Include="Src\Dom\ITypeParameter.cs" /> <Compile Include="Src\Dom\ITypeParameter.cs" />
<Compile Include="Src\Dom\Implementations\DefaultTypeParameter.cs" /> <Compile Include="Src\Dom\Implementations\DefaultTypeParameter.cs" />
<Compile Include="Src\Dom\Implementations\ProxyReturnType.cs" />
<Compile Include="Src\Dom\Implementations\DefaultReturnType.cs" />
<Compile Include="Src\Dom\Implementations\LazyReturnType.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj"> <ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

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

@ -19,6 +19,18 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
/// <summary>
/// The default return type to use for this class.
/// </summary>
IReturnType DefaultReturnType { get; }
/// <summary>
/// The fully qualified name in the internal .NET notation (with `1 for generic types)
/// </summary>
string DotNetName {
get;
}
string Name { string Name {
get; get;
} }
@ -86,14 +98,15 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
bool IsTypeInInheritanceTree(IClass possibleBaseClass); IClass GetInnermostClass(int caretLine, int caretColumn);
List<IClass> GetAccessibleTypes(IClass callingClass);
IMember SearchMember(string memberName); bool IsTypeInInheritanceTree(IClass possibleBaseClass);
IClass GetInnermostClass(int caretLine, int caretColumn); //IMember SearchMember(string memberName);
ArrayList GetAccessibleTypes(IClass callingClass); /*
ArrayList GetAccessibleMembers(IClass callingClass, bool showStatic); ArrayList GetAccessibleMembers(IClass callingClass, bool showStatic);
*/
} }
} }

22
src/Main/Base/Project/Src/Dom/IReturnType.cs

@ -6,9 +6,11 @@
// </file> // </file>
using System; using System;
using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom namespace ICSharpCode.SharpDevelop.Dom
{ {
public interface IReturnType: IComparable public interface IReturnType
{ {
string FullyQualifiedName { string FullyQualifiedName {
get; get;
@ -22,18 +24,22 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
int PointerNestingLevel { string DotNetName {
get;
}
int ArrayCount { // ArrayDimensions.Length
get; get;
} }
/// <summary>
/// Gets the array ranks of the return type.
/// When the return type is not an array, this property returns null.
/// </summary>
int[] ArrayDimensions { int[] ArrayDimensions {
get; get;
} }
object DeclaredIn { List<IMethod> GetMethods();
get; List<IProperty> GetProperties();
} List<IField> GetFields();
List<IEvent> GetEvents();
List<IIndexer> GetIndexers();
} }
} }

19
src/Main/Base/Project/Src/Dom/ITypeParameter.cs

@ -16,7 +16,26 @@ namespace ICSharpCode.SharpDevelop.Dom
/// </summary> /// </summary>
public interface ITypeParameter public interface ITypeParameter
{ {
/// <summary>
/// The name of the type parameter (for example "T")
/// </summary>
string Name { get; } string Name { get; }
int Index { get; }
/// <summary>
/// The method this type parameter is defined for.
/// This property is null when the type parameter is for a class.
/// </summary>
IMethod Method { get; }
/// <summary>
/// The class this type parameter is defined for.
/// When the type parameter is defined for a method, this is the class containing
/// that method.
/// </summary>
IClass Class { get; }
// TODO: Constraint // TODO: Constraint
} }
} }

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

@ -33,9 +33,13 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public override string DocumentationTag { public virtual string DotNetName {
get { get {
return "T:" + FullyQualifiedName; if (this.DeclaringType != null) {
return this.DeclaringType.DotNetName + "." + this.Name;
} else {
return FullyQualifiedName;
}
} }
} }

68
src/Main/Base/Project/Src/Dom/Implementations/AbstractReturnType.cs

@ -4,18 +4,22 @@
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/> // <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/> // <version value="$version"/>
// </file> // </file>
using System; using System;
using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom namespace ICSharpCode.SharpDevelop.Dom
{ {
[Serializable] [Serializable]
public abstract class AbstractReturnType : System.MarshalByRefObject, IReturnType public abstract class AbstractReturnType : IReturnType
{ {
protected int pointerNestingLevel; public abstract List<IMethod> GetMethods();
protected int[] arrayDimensions; public abstract List<IProperty> GetProperties();
protected object declaredin = null; public abstract List<IField> GetFields();
public abstract List<IEvent> GetEvents();
public abstract List<IIndexer> GetIndexers();
string fullyQualifiedName = null; string fullyQualifiedName = null;
// int nameHashCode = -1;
public virtual string FullyQualifiedName { public virtual string FullyQualifiedName {
get { get {
@ -23,14 +27,9 @@ namespace ICSharpCode.SharpDevelop.Dom
return String.Empty; return String.Empty;
} }
return fullyQualifiedName; return fullyQualifiedName;
// return (string)AbstractNamedEntity.fullyQualifiedNames[nameHashCode];
} }
set { set {
fullyQualifiedName = value; fullyQualifiedName = value;
// nameHashCode = value.GetHashCode();
// if (AbstractNamedEntity.fullyQualifiedNames[nameHashCode] == null) {
// AbstractNamedEntity.fullyQualifiedNames[nameHashCode] = value;
// }
} }
} }
@ -39,10 +38,8 @@ namespace ICSharpCode.SharpDevelop.Dom
if (FullyQualifiedName == null) { if (FullyQualifiedName == null) {
return null; return null;
} }
int index = FullyQualifiedName.LastIndexOf('.'); int index = FullyQualifiedName.LastIndexOf('.');
return index < 0 ? FullyQualifiedName : FullyQualifiedName.Substring(index + 1); return index < 0 ? FullyQualifiedName : FullyQualifiedName.Substring(index + 1);
// string[] name = FullyQualifiedName.Split(new char[] {'.'});
// return name[name.Length - 1];
} }
} }
@ -56,53 +53,16 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public virtual int PointerNestingLevel { public virtual string DotNetName {
get {
return pointerNestingLevel;
}
}
public int ArrayCount {
get {
return ArrayDimensions.Length;
}
}
public virtual int[] ArrayDimensions {
get { get {
if (arrayDimensions == null) return new int[0]; return FullyQualifiedName;
return arrayDimensions;
} }
} }
public virtual int CompareTo(IReturnType value) { public int[] ArrayDimensions {
int cmp;
if (FullyQualifiedName != null) {
cmp = FullyQualifiedName.CompareTo(value.FullyQualifiedName);
if (cmp != 0) {
return cmp;
}
}
cmp = (PointerNestingLevel - value.PointerNestingLevel);
if (cmp != 0) {
return cmp;
}
return DiffUtility.Compare(ArrayDimensions, value.ArrayDimensions);
}
int IComparable.CompareTo(object value)
{
return CompareTo((IReturnType)value);
}
public virtual object DeclaredIn {
get { get {
return declaredin; return null;
} }
} }
} }
} }

48
src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs

@ -52,6 +52,16 @@ namespace ICSharpCode.SharpDevelop.Dom
Modifiers = modifiers; Modifiers = modifiers;
} }
IReturnType defaultReturnType;
public IReturnType DefaultReturnType {
get {
if (defaultReturnType == null)
defaultReturnType = new DefaultReturnType(this);
return defaultReturnType;
}
}
public ICompilationUnit CompilationUnit { public ICompilationUnit CompilationUnit {
get { get {
return compilationUnit; return compilationUnit;
@ -80,6 +90,22 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public override string DotNetName {
get {
if (typeParameters == null || typeParameters.Count == 0) {
return FullyQualifiedName;
} else {
return FullyQualifiedName + "`" + typeParameters.Count;
}
}
}
public override string DocumentationTag {
get {
return "T:" + DotNetName;
}
}
public List<string> BaseTypes { public List<string> BaseTypes {
get { get {
if (baseTypes == null) { if (baseTypes == null) {
@ -247,7 +273,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public bool IsTypeInInheritanceTree(IClass possibleBaseClass) public bool IsTypeInInheritanceTree(IClass possibleBaseClass)
{ {
if (possibleBaseClass == null) { if (possibleBaseClass == null) {
@ -267,6 +292,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return false; return false;
} }
/*
public IMember SearchMember(string memberName) public IMember SearchMember(string memberName)
{ {
if (memberName == null || memberName.Length == 0) { if (memberName == null || memberName.Length == 0) {
@ -316,6 +342,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
return null; return null;
} }
*/
public IClass GetInnermostClass(int caretLine, int caretColumn) public IClass GetInnermostClass(int caretLine, int caretColumn)
{ {
@ -331,9 +358,9 @@ namespace ICSharpCode.SharpDevelop.Dom
return this; return this;
} }
public ArrayList GetAccessibleTypes(IClass callingClass) public List<IClass> GetAccessibleTypes(IClass callingClass)
{ {
ArrayList types = new ArrayList(); List<IClass> types = new List<IClass>();
bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(this); bool isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(this);
foreach (IClass c in InnerClasses) { foreach (IClass c in InnerClasses) {
@ -344,28 +371,18 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
IClass baseClass = BaseClass; IClass baseClass = BaseClass;
if (baseClass != null) { if (baseClass != null) {
types.AddRange(baseClass.GetAccessibleTypes(callingClass).ToArray()); types.AddRange(baseClass.GetAccessibleTypes(callingClass));
} }
return types; return types;
} }
/*
public ArrayList GetAccessibleMembers(IClass callingClass, bool showStatic) public ArrayList GetAccessibleMembers(IClass callingClass, bool showStatic)
{ {
ArrayList members = new ArrayList(); ArrayList members = new ArrayList();
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
// enums must be handled specially, because there are several things defined we don't want to show
// and enum members have neither the modifier nor the modifier public
/*if (ClassType == ClassType.Enum) {
foreach (IField f in Fields) {
if (f.IsLiteral) {
members.Add(f);
}
}
members.AddRange(ProjectContent.GetClass("System.Enum").GetAccessibleMembers(callingClass, showStatic).ToArray());
return members;
}*/
bool isClassInInheritanceTree = false; bool isClassInInheritanceTree = false;
if (callingClass != null) if (callingClass != null)
@ -419,6 +436,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return members; return members;
} }
*/
public class ClassInheritanceEnumerator : IEnumerator, IEnumerable public class ClassInheritanceEnumerator : IEnumerator, IEnumerable
{ {

9
src/Main/Base/Project/Src/Dom/Implementations/DefaultEvent.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public override string DocumentationTag { public override string DocumentationTag {
get { get {
return "E:" + this.FullyQualifiedName; return "E:" + this.DotNetName;
} }
} }
@ -65,13 +65,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
if (ReturnType != null) {
cmp = ReturnType.CompareTo(value.ReturnType);
if (cmp != 0) {
return cmp;
}
}
return Region.CompareTo(value.Region); return Region.CompareTo(value.Region);
} }

8
src/Main/Base/Project/Src/Dom/Implementations/DefaultField.cs

@ -14,7 +14,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
public override string DocumentationTag { public override string DocumentationTag {
get { get {
return "F:" + this.FullyQualifiedName; return "F:" + this.DotNetName;
} }
} }
@ -52,12 +52,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
if (ReturnType != null) {
cmp = ReturnType.CompareTo(field.ReturnType);
if (cmp != 0) {
return cmp;
}
}
if (Region != null) { if (Region != null) {
return Region.CompareTo(field.Region); return Region.CompareTo(field.Region);
} }

10
src/Main/Base/Project/Src/Dom/Implementations/DefaultIndexer.cs

@ -19,7 +19,8 @@ namespace ICSharpCode.SharpDevelop.Dom
public override string DocumentationTag { public override string DocumentationTag {
get { get {
return "P:" + this.FullyQualifiedName; // TODO: We have to specify the parameters here
return "P:" + this.DotNetName;
} }
} }
@ -83,13 +84,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
if (ReturnType != null) {
cmp = ReturnType.CompareTo(value.ReturnType);
if (cmp != 0) {
return cmp;
}
}
if (Region != null) { if (Region != null) {
cmp = Region.CompareTo(value.Region); cmp = Region.CompareTo(value.Region);
if (cmp != 0) { if (cmp != 0) {

45
src/Main/Base/Project/Src/Dom/Implementations/DefaultMethod.cs

@ -5,6 +5,7 @@
// <version value="$version"/> // <version value="$version"/>
// </file> // </file>
using System; using System;
using System.Text;
using System.Reflection; using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
@ -14,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public class Constructor : DefaultMethod public class Constructor : DefaultMethod
{ {
public Constructor(ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType) public Constructor(ModifierEnum m, IRegion region, IRegion bodyRegion, IClass declaringType)
: base("#ctor", new ICSharpCode.SharpDevelop.Dom.NRefactoryResolver.ReturnType(declaringType.FullyQualifiedName), : base("#ctor", declaringType.DefaultReturnType,
m, region, bodyRegion, declaringType) m, region, bodyRegion, declaringType)
{ {
} }
@ -35,10 +36,34 @@ namespace ICSharpCode.SharpDevelop.Dom
protected IRegion bodyRegion; protected IRegion bodyRegion;
List<IParameter> parameters = null; List<IParameter> parameters = null;
List<ITypeParameter> typeParameters = null;
public override string DotNetName {
get {
if (typeParameters == null || typeParameters.Count == 0)
return base.DotNetName;
else
return base.DotNetName + "``" + typeParameters.Count;
}
}
public override string DocumentationTag { public override string DocumentationTag {
get { get {
return "M:" + this.FullyQualifiedName; string dotnetName = this.DotNetName;
StringBuilder b = new StringBuilder("M:", dotnetName.Length + 2);
b.Append(dotnetName);
List<IParameter> paras = this.Parameters;
if (paras.Count > 0) {
b.Append('(');
for (int i = 0; i < paras.Count; ++i) {
if (i > 0) b.Append(',');
if (paras[i].ReturnType != null) {
b.Append(paras[i].ReturnType.DotNetName);
}
}
b.Append(')');
}
return b.ToString();
} }
} }
@ -48,6 +73,15 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public virtual List<ITypeParameter> TypeParameters {
get {
if (typeParameters == null) {
typeParameters = new List<ITypeParameter>();
}
return typeParameters;
}
}
public virtual List<IParameter> Parameters { public virtual List<IParameter> Parameters {
get { get {
if (parameters == null) { if (parameters == null) {
@ -104,13 +138,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
if (ReturnType != null) {
cmp = ReturnType.CompareTo(value.ReturnType);
if (cmp != 0) {
return cmp;
}
}
if (Region != null) { if (Region != null) {
cmp = Region.CompareTo(value.Region); cmp = Region.CompareTo(value.Region);
if (cmp != 0) { if (cmp != 0) {

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

@ -123,10 +123,6 @@ namespace ICSharpCode.SharpDevelop.Dom
return cmp; return cmp;
} }
} }
if (ReturnType != null) {
if(0 != (cmp = ReturnType.CompareTo(value.ReturnType)))
return cmp;
}
if(0 != (cmp = (int)(Modifier - value.Modifier))) if(0 != (cmp = (int)(Modifier - value.Modifier)))
return cmp; return cmp;

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

@ -24,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.Dom {
public override string DocumentationTag { public override string DocumentationTag {
get { get {
return "P:" + this.FullyQualifiedName; return "P:" + this.DotNetName;
} }
} }
@ -109,11 +109,6 @@ namespace ICSharpCode.SharpDevelop.Dom {
} }
} }
if (ReturnType != null) {
if(0 != (cmp = ReturnType.CompareTo(value.ReturnType)))
return cmp;
}
if(0 != (cmp = Region.CompareTo(value.Region))) if(0 != (cmp = Region.CompareTo(value.Region)))
return cmp; return cmp;

93
src/Main/Base/Project/Src/Dom/Implementations/DefaultReturnType.cs

@ -0,0 +1,93 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
[Serializable]
public class DefaultReturnType : AbstractReturnType
{
IClass c;
public DefaultReturnType(IClass c)
{
if (c == null)
throw new ArgumentNullException("c");
this.c = c;
}
public override List<IMethod> GetMethods()
{
List<IMethod> l = new List<IMethod>();
foreach (IClass bc in c.ClassInheritanceTree) {
l.AddRange(bc.Methods);
}
return l;
}
public override List<IProperty> GetProperties()
{
List<IProperty> l = new List<IProperty>();
foreach (IClass bc in c.ClassInheritanceTree) {
l.AddRange(bc.Properties);
}
return l;
}
public override List<IField> GetFields()
{
List<IField> l = new List<IField>();
foreach (IClass bc in c.ClassInheritanceTree) {
l.AddRange(bc.Fields);
}
return l;
}
public override List<IEvent> GetEvents()
{
List<IEvent> l = new List<IEvent>();
foreach (IClass bc in c.ClassInheritanceTree) {
l.AddRange(bc.Events);
}
return l;
}
public override List<IIndexer> GetIndexers()
{
return c.Indexer;
}
public override string FullyQualifiedName {
get {
return c.FullyQualifiedName;
}
set {
}
}
public override string Name {
get {
return c.Name;
}
}
public override string Namespace {
get {
return c.Namespace;
}
}
public override string DotNetName {
get {
return c.DotNetName;
}
}
}
}

35
src/Main/Base/Project/Src/Dom/Implementations/DefaultTypeParameter.cs

@ -24,9 +24,42 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public DefaultTypeParameter(string name) int index;
public int Index {
get {
return index;
}
}
IMethod method;
IClass targetClass;
public IMethod Method {
get {
return method;
}
}
public IClass Class {
get {
return targetClass;
}
}
public DefaultTypeParameter(IMethod method, string name, int index)
{
this.method = method;
this.targetClass = method.DeclaringType;
this.name = name;
this.index = index;
}
public DefaultTypeParameter(IClass targetClass, string name, int index)
{ {
this.targetClass = targetClass;
this.name = name; this.name = name;
this.index = index;
} }
public DefaultTypeParameter(Type type) public DefaultTypeParameter(Type type)

90
src/Main/Base/Project/Src/Dom/Implementations/LazyReturnType.cs

@ -0,0 +1,90 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Context used to resolve lazy return types.
/// </summary>
public interface IResolveContext
{
IReturnType Resolve(object data);
}
/// <summary>
/// The LazyReturnType is the most used return type:
/// It is not bound to a class, but only resolved when necessary.
/// </summary>
public sealed class LazyReturnType : ProxyReturnType
{
IResolveContext context;
object data;
public LazyReturnType(IResolveContext context, object data)
{
if (context == null)
throw new ArgumentNullException("context");
if (data == null)
throw new ArgumentNullException("data");
this.context = context;
this.data = data;
}
public override IReturnType BaseType {
get {
return context.Resolve(data);
}
}
public override string ToString()
{
return String.Format("[LazyReturnType: context = {0}, data = {1}]",
context,
data);
}
}
public class GetClassResolveContext : IResolveContext
{
IProjectContent content;
public GetClassResolveContext(IProjectContent content)
{
this.content = content;
}
public IReturnType Resolve(object data)
{
IClass c = content.GetClass((string)data);
return (c != null) ? c.DefaultReturnType : null;
}
}
public class SearchClassResolveContext : IResolveContext
{
IClass declaringClass;
int caretLine;
int caretColumn;
public SearchClassResolveContext(IClass declaringClass, int caretLine, int caretColumn)
{
this.declaringClass = declaringClass;
this.caretLine = caretLine;
this.caretColumn = caretColumn;
}
public IReturnType Resolve(object data)
{
IClass c = declaringClass.ProjectContent.SearchType((string)data, declaringClass, caretLine, caretColumn);
return (c != null) ? c.DefaultReturnType : null;
}
}
}

89
src/Main/Base/Project/Src/Dom/Implementations/ProxyReturnType.cs

@ -0,0 +1,89 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version value="$version"/>
// </file>
using System;
using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Dom
{
[Serializable]
public abstract class ProxyReturnType : IReturnType
{
public abstract IReturnType BaseType {
get;
}
public virtual string FullyQualifiedName {
get {
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.FullyQualifiedName : null;
}
}
public virtual string Name {
get {
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.Name : null;
}
}
public virtual string Namespace {
get {
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.Namespace : null;
}
}
public virtual string DotNetName {
get {
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.DotNetName : null;
}
}
/// <summary>
/// Gets the array ranks of the return type.
/// When the return type is not an array, this property returns null.
/// </summary>
public virtual int[] ArrayDimensions {
get {
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.ArrayDimensions : null;
}
}
public List<IMethod> GetMethods()
{
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.GetMethods() : new List<IMethod>();
}
public List<IProperty> GetProperties()
{
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.GetProperties() : new List<IProperty>();
}
public List<IField> GetFields()
{
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.GetFields() : new List<IField>();
}
public List<IEvent> GetEvents()
{
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.GetEvents() : new List<IEvent>();
}
public List<IIndexer> GetIndexers()
{
IReturnType baseType = BaseType;
return (baseType != null) ? baseType.GetIndexers() : new List<IIndexer>();
}
}
}

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

@ -214,7 +214,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
cu.Classes.Add(c); cu.Classes.Add(c);
} }
DefaultMethod invokeMethod = new DefaultMethod("Invoke", new ReturnType(delegateDeclaration.ReturnType), ConvertModifier(delegateDeclaration.Modifier), null, null, c); DefaultMethod invokeMethod = new DefaultMethod("Invoke", CreateReturnType(delegateDeclaration.ReturnType), ConvertModifier(delegateDeclaration.Modifier), null, null, c);
c.Methods.Add(invokeMethod); c.Methods.Add(invokeMethod);
return c; return c;
} }
@ -223,20 +223,18 @@ 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); IReturnType type = CreateReturnType(methodDeclaration.TypeReference);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultMethod method = new DefaultMethod(methodDeclaration.Name, type, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); DefaultMethod method = new DefaultMethod(methodDeclaration.Name, type, ConvertModifier(methodDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
method.Attributes.AddRange(VisitAttributes(methodDeclaration.Attributes)); method.Attributes.AddRange(VisitAttributes(methodDeclaration.Attributes));
List<IParameter> parameters = new List<IParameter>();
if (methodDeclaration.Parameters != null) { if (methodDeclaration.Parameters != null) {
foreach (AST.ParameterDeclarationExpression par in methodDeclaration.Parameters) { foreach (AST.ParameterDeclarationExpression par in methodDeclaration.Parameters) {
ReturnType parType = new ReturnType(par.TypeReference); IReturnType parType = CreateReturnType(par.TypeReference);
DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DefaultRegion(par.StartLocation, methodDeclaration.Body.EndLocation)); DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DefaultRegion(par.StartLocation, methodDeclaration.Body.EndLocation));
parameters.Add(p); method.Parameters.Add(p);
} }
} }
method.Parameters = parameters;
c.Methods.Add(method); c.Methods.Add(method);
return null; return null;
} }
@ -249,15 +247,13 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
Constructor constructor = new Constructor(ConvertModifier(constructorDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); Constructor constructor = new Constructor(ConvertModifier(constructorDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
constructor.Attributes.AddRange(VisitAttributes(constructorDeclaration.Attributes)); constructor.Attributes.AddRange(VisitAttributes(constructorDeclaration.Attributes));
List<IParameter> parameters = new List<IParameter>();
if (constructorDeclaration.Parameters != null) { if (constructorDeclaration.Parameters != null) {
foreach (AST.ParameterDeclarationExpression par in constructorDeclaration.Parameters) { foreach (AST.ParameterDeclarationExpression par in constructorDeclaration.Parameters) {
ReturnType parType = new ReturnType(par.TypeReference); IReturnType parType = CreateReturnType(par.TypeReference);
DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DefaultRegion(par.StartLocation, constructorDeclaration.Body.EndLocation)); DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DefaultRegion(par.StartLocation, constructorDeclaration.Body.EndLocation));
parameters.Add(p); constructor.Parameters.Add(p);
} }
} }
constructor.Parameters = parameters;
c.Methods.Add(constructor); c.Methods.Add(constructor);
return null; return null;
} }
@ -284,11 +280,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
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];
ReturnType retType; IReturnType retType;
if (c.ClassType == ClassType.Enum) if (c.ClassType == ClassType.Enum)
retType = new ReturnType(c.FullyQualifiedName); retType = c.DefaultReturnType;
else else
retType = new ReturnType(fieldDeclaration.GetTypeForField(i)); retType = CreateReturnType(fieldDeclaration.GetTypeForField(i));
DefaultField f = new DefaultField(retType, field.Name, ConvertModifier(fieldDeclaration.Modifier), region, c); DefaultField f = new DefaultField(retType, field.Name, ConvertModifier(fieldDeclaration.Modifier), region, c);
f.Attributes.AddRange(VisitAttributes(fieldDeclaration.Attributes)); f.Attributes.AddRange(VisitAttributes(fieldDeclaration.Attributes));
if (c.ClassType == ClassType.Enum) { if (c.ClassType == ClassType.Enum) {
@ -306,7 +302,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
DefaultRegion region = GetRegion(propertyDeclaration.StartLocation, propertyDeclaration.EndLocation); DefaultRegion region = GetRegion(propertyDeclaration.StartLocation, propertyDeclaration.EndLocation);
DefaultRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd); DefaultRegion bodyRegion = GetRegion(propertyDeclaration.BodyStart, propertyDeclaration.BodyEnd);
ReturnType type = new ReturnType(propertyDeclaration.TypeReference); IReturnType type = CreateReturnType(propertyDeclaration.TypeReference);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultProperty property = new DefaultProperty(propertyDeclaration.Name, type, ConvertModifier(propertyDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); DefaultProperty property = new DefaultProperty(propertyDeclaration.Name, type, ConvertModifier(propertyDeclaration.Modifier), region, bodyRegion, GetCurrentClass());
@ -319,7 +315,7 @@ 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); IReturnType type = CreateReturnType(eventDeclaration.TypeReference);
DefaultClass c = GetCurrentClass(); DefaultClass c = GetCurrentClass();
DefaultEvent e = null; DefaultEvent e = null;
@ -342,11 +338,11 @@ 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>();
DefaultIndexer i = new DefaultIndexer(new ReturnType(indexerDeclaration.TypeReference), parameters, ConvertModifier(indexerDeclaration.Modifier), region, bodyRegion, GetCurrentClass()); DefaultIndexer i = new DefaultIndexer(CreateReturnType(indexerDeclaration.TypeReference), parameters, ConvertModifier(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) {
ReturnType parType = new ReturnType(par.TypeReference); IReturnType parType = CreateReturnType(par.TypeReference);
DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DefaultRegion(par.StartLocation, indexerDeclaration.EndLocation)); DefaultParameter p = new DefaultParameter(par.ParameterName, parType, new DefaultRegion(par.StartLocation, indexerDeclaration.EndLocation));
parameters.Add(p); parameters.Add(p);
} }
@ -355,5 +351,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
c.Indexer.Add(i); c.Indexer.Add(i);
return null; return null;
} }
IReturnType CreateReturnType(AST.TypeReference reference)
{
return null;
}
} }
} }

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

@ -147,10 +147,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
IReturnType returnType; IReturnType returnType;
if (fieldReferenceExpression.FieldName == null || fieldReferenceExpression.FieldName == "") { if (fieldReferenceExpression.FieldName == null || fieldReferenceExpression.FieldName == "") {
if (fieldReferenceExpression.TargetObject is TypeReferenceExpression) { if (fieldReferenceExpression.TargetObject is TypeReferenceExpression) {
returnType = new ReturnType(((TypeReferenceExpression)fieldReferenceExpression.TargetObject).TypeReference); // TODO: !!!
/*returnType = new ReturnType(((TypeReferenceExpression)fieldReferenceExpression.TargetObject).TypeReference);
IClass c = projectContent.GetClass(returnType.FullyQualifiedName); IClass c = projectContent.GetClass(returnType.FullyQualifiedName);
if (c != null) if (c != null)
return new TypeResolveResult(callingClass, callingMember, returnType, c); return new TypeResolveResult(callingClass, callingMember, returnType, c);
*/
} }
} }
returnType = fieldReferenceExpression.TargetObject.AcceptVisitor(typeVisitor, null) as IReturnType; returnType = fieldReferenceExpression.TargetObject.AcceptVisitor(typeVisitor, null) as IReturnType;
@ -164,7 +166,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
IClass c = SearchType(name, this.CallingClass, this.CompilationUnit); IClass c = SearchType(name, this.CallingClass, this.CompilationUnit);
if (c != null) { if (c != null) {
return new TypeResolveResult(callingClass, callingMember, new ReturnType(c.FullyQualifiedName), c); return new TypeResolveResult(callingClass, callingMember, c.DefaultReturnType, c);
} }
return null; return null;
} }
@ -182,15 +184,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
IReturnType type = expr.AcceptVisitor(typeVisitor, null) as IReturnType; IReturnType type = expr.AcceptVisitor(typeVisitor, null) as IReturnType;
if (type == null || type.FullyQualifiedName == "" || type.PointerNestingLevel != 0) { if (type == null || type.FullyQualifiedName == "") {
return null; return null;
} }
if (expr is ObjectCreateExpression && type.ArrayCount == 0) { if (expr is ObjectCreateExpression) {
IClass c = projectContent.GetClass(type.FullyQualifiedName); foreach (IMethod m in type.GetMethods()) {
if (c == null) if (m.IsConstructor && !m.IsStatic)
return null;
foreach (IMethod m in c.Methods) {
if (m.IsConstructor)
return CreateMemberResolveResult(m); return CreateMemberResolveResult(m);
} }
return null; return null;
@ -200,13 +199,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
IReturnType FixType(IReturnType type) IReturnType FixType(IReturnType type)
{ {
if (type == null) return type;
return null;
IClass returnClass = SearchType(type.FullyQualifiedName, callingClass, cu);
if (returnClass != null && returnClass.FullyQualifiedName != type.FullyQualifiedName)
return new ReturnType(returnClass.FullyQualifiedName, type.ArrayDimensions, type.PointerNestingLevel);
else
return type;
} }
#region Resolve Identifier #region Resolve Identifier
@ -229,23 +222,25 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return new LocalResolveResult(callingMember, field, true); return new LocalResolveResult(callingMember, field, true);
} }
} }
IMember member = GetMember(callingClass, identifier); if (callingClass != null) {
if (member != null) { IMember member = GetMember(callingClass.DefaultReturnType, identifier);
return CreateMemberResolveResult(member); if (member != null) {
} return CreateMemberResolveResult(member);
ResolveResult result = ResolveMethod(callingClass, identifier); }
if (result != null) ResolveResult result = ResolveMethod(callingClass.DefaultReturnType, identifier);
return result; if (result != null)
return result;
IClass c = SearchType(identifier, this.CallingClass, cu); IClass c = SearchType(identifier, callingClass, cu);
if (c != null) { if (c != null) {
return new TypeResolveResult(callingClass, callingMember, new ReturnType(c.FullyQualifiedName), c); return new TypeResolveResult(callingClass, callingMember, c.DefaultReturnType, c);
}
} }
// 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 = cu.GetOuterClasses(caretLine, caretColumn); List<IClass> classes = cu.GetOuterClasses(caretLine, caretColumn);
foreach (IClass c2 in classes) { foreach (IClass c2 in classes) {
member = GetMember(c2, identifier); IMember member = GetMember(c2.DefaultReturnType, identifier);
if (member != null && member.IsStatic) { if (member != null && member.IsStatic) {
return new MemberResolveResult(callingClass, callingMember, member); return new MemberResolveResult(callingClass, callingMember, member);
} }
@ -263,25 +258,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
#region ResolveMethod #region ResolveMethod
ResolveResult ResolveMethod(IReturnType type, string identifier) ResolveResult ResolveMethod(IReturnType type, string identifier)
{ {
if (type == null || type.PointerNestingLevel != 0) if (type == null)
return null;
IClass curType;
if (type.ArrayDimensions != null && type.ArrayDimensions.Length > 0)
curType = SearchType("System.Array", null, null);
else
curType = SearchType(type.FullyQualifiedName, null, null);
return ResolveMethod(curType, identifier);
}
ResolveResult ResolveMethod(IClass c, string identifier)
{
if (c == null)
return null; return null;
foreach (IClass curType in c.ClassInheritanceTree) { foreach (IMethod method in type.GetMethods()) {
foreach (IMethod method in c.Methods) { if (IsSameName(identifier, method.Name))
if (IsSameName(identifier, method.Name)) return new MethodResolveResult(callingClass, callingMember, method.DeclaringType, identifier);
return new MethodResolveResult(callingClass, callingMember, c, identifier);
}
} }
return null; return null;
} }
@ -409,45 +390,21 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
/// </summary> /// </summary>
public ArrayList SearchMethod(IReturnType type, string memberName) public ArrayList SearchMethod(IReturnType type, string memberName)
{ {
if (type == null || type.PointerNestingLevel != 0) { ArrayList methods = new ArrayList();
return new ArrayList(1); if (type == null)
}
IClass curType;
if (type.ArrayDimensions != null && type.ArrayDimensions.Length > 0) {
curType = SearchType("System.Array", null, null);
} else {
curType = SearchType(type.FullyQualifiedName, null, null);
}
return SearchMethod(new ArrayList(), curType, memberName);
}
/// <summary>
/// Gets the list of methods on the class that have the specified name.
/// </summary>
public ArrayList SearchMethod(IClass type, string memberName)
{
return SearchMethod(new ArrayList(), type, memberName);
}
ArrayList SearchMethod(ArrayList methods, IClass curType, string memberName)
{
if (curType == null)
return methods; return methods;
bool isClassInInheritanceTree = false;
if (callingClass != null)
isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType);
foreach (IMethod m in curType.Methods) { //bool isClassInInheritanceTree = false;
if (IsSameName(m.Name, memberName) && //if (callingClass != null)
m.IsAccessible(callingClass, isClassInInheritanceTree) && // isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType);
!((m.Modifiers & ModifierEnum.Override) == ModifierEnum.Override)) {
foreach (IMethod m in type.GetMethods()) {
if (IsSameName(m.Name, memberName)
// && m.IsAccessible(callingClass, isClassInInheritanceTree)
) {
methods.Add(m); methods.Add(m);
} }
} }
IClass baseClass = curType.BaseClass;
if (baseClass != null) {
return SearchMethod(methods, baseClass, memberName);
}
return methods; return methods;
} }
#endregion #endregion
@ -484,79 +441,43 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
// no methods or indexer // no methods or indexer
public IReturnType SearchMember(IReturnType type, string memberName) public IReturnType SearchMember(IReturnType type, string memberName)
{ {
if (type == null || memberName == null || memberName == "") { if (type == null)
return null;
}
if (type.PointerNestingLevel != 0) {
return null;
}
IClass curType;
if (type.ArrayDimensions != null && type.ArrayDimensions.Length > 0) {
curType = SearchType("System.Array", null, null);
} else {
curType = SearchType(type.FullyQualifiedName, callingClass, cu);
}
return SearchMember(curType, memberName);
}
public IMember GetMember(IReturnType type, string memberName)
{
if (type == null || memberName == null || memberName == "") {
return null;
}
if (type.PointerNestingLevel != 0) {
return null;
}
IClass curType;
if (type.ArrayDimensions != null && type.ArrayDimensions.Length > 0) {
curType = SearchType("System.Array", null, null);
} else {
curType = SearchType(type.FullyQualifiedName, callingClass, cu);
}
return GetMember(curType, memberName);
}
public IReturnType SearchMember(IClass curType, string memberName)
{
if (curType == null)
return null; return null;
bool isClassInInheritanceTree = false; //bool isClassInInheritanceTree = false;
if (callingClass != null) //if (callingClass != null)
isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType); // isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(curType);
foreach (IClass c in curType.InnerClasses) { //foreach (IClass c in curType.InnerClasses) {
if (IsSameName(c.Name, memberName) && c.IsAccessible(callingClass, isClassInInheritanceTree)) { // if (IsSameName(c.Name, memberName) && c.IsAccessible(callingClass, isClassInInheritanceTree)) {
return new ReturnType(c.FullyQualifiedName); // return new ReturnType(c.FullyQualifiedName);
} // }
} //}
IMember member = GetMember(curType, memberName); IMember member = GetMember(type, memberName);
if (member == null) if (member == null)
return null; return null;
else else
return member.ReturnType; return member.ReturnType;
} }
private IMember GetMember(IClass c, string memberName) public IMember GetMember(IReturnType type, string memberName)
{ {
if (c == null) if (type == null)
return null; return null;
bool isClassInInheritanceTree = false; //bool isClassInInheritanceTree = false;
if (callingClass != null) //if (callingClass != null)
isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(c); // isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(c);
foreach (IClass curType in c.ClassInheritanceTree) { foreach (IProperty p in type.GetProperties()) {
foreach (IProperty p in curType.Properties) { if (IsSameName(p.Name, memberName)) {
if (IsSameName(p.Name, memberName) && p.IsAccessible(callingClass, isClassInInheritanceTree)) { return p;
return p;
}
} }
foreach (IField f in curType.Fields) { }
if (IsSameName(f.Name, memberName) && f.IsAccessible(callingClass, isClassInInheritanceTree)) { foreach (IField f in type.GetFields()) {
return f; if (IsSameName(f.Name, memberName)) {
} return f;
} }
foreach (IEvent e in curType.Events) { }
if (IsSameName(e.Name, memberName) && e.IsAccessible(callingClass, isClassInInheritanceTree)) { foreach (IEvent e in type.GetEvents()) {
return e; if (IsSameName(e.Name, memberName)) {
} return e;
} }
} }
return null; return null;
@ -594,7 +515,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
// try if there exists a nonstatic member named typeName // try if there exists a nonstatic member named typeName
IReturnType t = SearchMember(callingClass, typeName); IReturnType t = SearchMember(callingClass.DefaultReturnType, typeName);
if (t != null) { if (t != null) {
return t; return t;
} }
@ -602,7 +523,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 = cu.GetOuterClasses(caretLine, caretColumn); List<IClass> classes = cu.GetOuterClasses(caretLine, caretColumn);
foreach (IClass c in classes) { foreach (IClass c in classes) {
IMember member = GetMember(c, typeName); IMember member = GetMember(c.DefaultReturnType, typeName);
if (member != null && member.IsStatic) { if (member != null && member.IsStatic) {
return member.ReturnType; return member.ReturnType;
} }
@ -631,9 +552,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
IClass c = SearchType(v.TypeRef.SystemType, callingClass, cu); IClass c = SearchType(v.TypeRef.SystemType, callingClass, cu);
if (c != null) { if (c != null) {
return new ReturnType(c.FullyQualifiedName, v.TypeRef.RankSpecifier, v.TypeRef.PointerNestingLevel); return c.DefaultReturnType;
} else { } else {
return new ReturnType(v.TypeRef); //return new ReturnType(v.TypeRef);
return null;
} }
} }
@ -711,17 +633,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
IMethod method = callingMember as IMethod; IMethod method = callingMember as IMethod;
if (method != null) { if (method != null) {
foreach (IParameter p in method.Parameters) { foreach (IParameter p in method.Parameters) {
result.Add(new DefaultField(new ReturnType(p.ReturnType.Name, p.ReturnType.ArrayDimensions, p.ReturnType.PointerNestingLevel), p.Name, ModifierEnum.None, method.Region, callingClass)); result.Add(new DefaultField(p.ReturnType, p.Name, ModifierEnum.None, method.Region, callingClass));
} }
} }
result.AddRange(projectContent.GetNamespaceContents(callingClass.Namespace)); result.AddRange(projectContent.GetNamespaceContents(callingClass.Namespace));
bool inStatic = true; bool inStatic = true;
if (callingMember != null) if (callingMember != null)
inStatic = callingMember.IsStatic; inStatic = callingMember.IsStatic;
result.AddRange(callingClass.GetAccessibleMembers(callingClass, inStatic).ToArray()); //result.AddRange(callingClass.GetAccessibleMembers(callingClass, inStatic).ToArray());
if (inStatic == false) { //if (inStatic == false) {
result.AddRange(callingClass.GetAccessibleMembers(callingClass, !inStatic).ToArray()); // result.AddRange(callingClass.GetAccessibleMembers(callingClass, !inStatic).ToArray());
} //}
} }
} }
foreach (string name in lookupTableVisitor.variables.Keys) { foreach (string name in lookupTableVisitor.variables.Keys) {
@ -731,7 +653,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 DefaultField(new ReturnType(v.TypeRef), name, ModifierEnum.None, new DefaultRegion(v.StartPos, v.EndPos), callingClass)); //result.Add(new DefaultField(new ReturnType(v.TypeRef), name, ModifierEnum.None, new DefaultRegion(v.StartPos, v.EndPos), callingClass));
break; break;
} }
} }

50
src/Main/Base/Project/Src/Dom/NRefactoryResolver/ReturnType.cs

@ -1,50 +0,0 @@
// created on 04.08.2003 at 18:08
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
{
public class ReturnType : AbstractReturnType
{
public new int PointerNestingLevel {
get {
return base.pointerNestingLevel;
}
set {
base.pointerNestingLevel = value;
}
}
public new int[] ArrayDimensions {
get {
return base.arrayDimensions;
}
set {
base.arrayDimensions = value;
}
}
public ReturnType(string fullyQualifiedName)
{
base.FullyQualifiedName = fullyQualifiedName;
}
public ReturnType(string fullyQualifiedName, int[] arrayDimensions, int pointerNestingLevel)
{
this.FullyQualifiedName = fullyQualifiedName;
this.arrayDimensions = arrayDimensions;
this.pointerNestingLevel = pointerNestingLevel;
}
public ReturnType(ICSharpCode.NRefactory.Parser.AST.TypeReference type)
{
base.FullyQualifiedName = type.SystemType;
base.arrayDimensions = type.RankSpecifier == null ? new int[] { } : type.RankSpecifier;
base.pointerNestingLevel = type.PointerNestingLevel;
}
public ReturnType Clone()
{
return new ReturnType(FullyQualifiedName, arrayDimensions, pointerNestingLevel);
}
}
}

69
src/Main/Base/Project/Src/Dom/NRefactoryResolver/TypeVisitor.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(PrimitiveExpression primitiveExpression, object data) public override object Visit(PrimitiveExpression primitiveExpression, object data)
{ {
if (primitiveExpression.Value != null) { if (primitiveExpression.Value != null) {
return new ReturnType(primitiveExpression.Value.GetType().FullName); return ReflectionReturnType(primitiveExpression.Value.GetType());
} }
return null; return null;
} }
@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
for (int i = 0; i < types.Length; ++i) { for (int i = 0; i < types.Length; ++i) {
IReturnType type = method.Parameters[i].ReturnType; IReturnType type = method.Parameters[i].ReturnType;
if (type != null && types[i] != null) { if (type != null && types[i] != null) {
if (type.CompareTo(types[i]) == 0) if (type.Equals(types[i]))
points += 1; points += 1;
} }
} }
@ -108,7 +108,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (resolver.CallingClass == null) { if (resolver.CallingClass == null) {
return null; return null;
} }
ArrayList methods = resolver.SearchMethod(resolver.CallingClass, id); ArrayList methods = resolver.SearchMethod(resolver.CallingClass.DefaultReturnType, id);
return FindOverload(methods, invocationExpression, data); return FindOverload(methods, invocationExpression, data);
} }
// invocationExpression is delegate call // invocationExpression is delegate call
@ -132,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
// int. generates a FieldreferenceExpression with TargetObject TypeReferenceExpression and no FieldName // int. generates a FieldreferenceExpression with TargetObject TypeReferenceExpression and no FieldName
if (fieldReferenceExpression.FieldName == null || fieldReferenceExpression.FieldName == "") { if (fieldReferenceExpression.FieldName == null || fieldReferenceExpression.FieldName == "") {
if (fieldReferenceExpression.TargetObject is TypeReferenceExpression) { if (fieldReferenceExpression.TargetObject is TypeReferenceExpression) {
return new ReturnType(((TypeReferenceExpression)fieldReferenceExpression.TargetObject).TypeReference); return CreateReturnType(((TypeReferenceExpression)fieldReferenceExpression.TargetObject).TypeReference);
} }
} }
IReturnType returnType = fieldReferenceExpression.TargetObject.AcceptVisitor(this, data) as IReturnType; IReturnType returnType = fieldReferenceExpression.TargetObject.AcceptVisitor(this, data) as IReturnType;
@ -141,11 +141,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (name != null) { if (name != null) {
string n = resolver.SearchNamespace(name + "." + fieldReferenceExpression.FieldName, null); string n = resolver.SearchNamespace(name + "." + fieldReferenceExpression.FieldName, null);
if (n != null) { if (n != null) {
return new ReturnType(n); return NamespaceReturnType(n);
} }
IClass c = resolver.SearchType(name + "." + fieldReferenceExpression.FieldName, resolver.CallingClass, resolver.CompilationUnit); IClass c = resolver.SearchType(name + "." + fieldReferenceExpression.FieldName, resolver.CallingClass, resolver.CompilationUnit);
if (c != null) { if (c != null) {
return new ReturnType(c.FullyQualifiedName); return c.DefaultReturnType;
} }
return null; return null;
} }
@ -156,6 +156,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(PointerReferenceExpression pointerReferenceExpression, object data) public override object Visit(PointerReferenceExpression pointerReferenceExpression, object data)
{ {
return null;
/*
ReturnType type = pointerReferenceExpression.TargetObject.AcceptVisitor(this, data) as ReturnType; ReturnType type = pointerReferenceExpression.TargetObject.AcceptVisitor(this, data) as ReturnType;
if (type == null) { if (type == null) {
return null; return null;
@ -166,6 +168,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return null; return null;
} }
return resolver.SearchMember(type, pointerReferenceExpression.Identifier); return resolver.SearchMember(type, pointerReferenceExpression.Identifier);
*/
} }
public override object Visit(IdentifierExpression identifierExpression, object data) public override object Visit(IdentifierExpression identifierExpression, object data)
@ -175,18 +178,18 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
string name = resolver.SearchNamespace(identifierExpression.Identifier, resolver.CompilationUnit); string name = resolver.SearchNamespace(identifierExpression.Identifier, resolver.CompilationUnit);
if (name != null && name != "") { if (name != null && name != "") {
return new ReturnType(name); return NamespaceReturnType(name);
} }
IClass c = resolver.SearchType(identifierExpression.Identifier, resolver.CallingClass, resolver.CompilationUnit); IClass c = resolver.SearchType(identifierExpression.Identifier, resolver.CallingClass, resolver.CompilationUnit);
if (c != null) { if (c != null) {
return new ReturnType(c.FullyQualifiedName); return c.DefaultReturnType;;
} }
return resolver.DynamicLookup(identifierExpression.Identifier); return resolver.DynamicLookup(identifierExpression.Identifier);
} }
public override object Visit(TypeReferenceExpression typeReferenceExpression, object data) public override object Visit(TypeReferenceExpression typeReferenceExpression, object data)
{ {
return new ReturnType(typeReferenceExpression.TypeReference); return CreateReturnType(typeReferenceExpression.TypeReference);
} }
public override object Visit(UnaryOperatorExpression unaryOperatorExpression, object data) public override object Visit(UnaryOperatorExpression unaryOperatorExpression, object data)
@ -194,7 +197,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (unaryOperatorExpression == null) { if (unaryOperatorExpression == null) {
return null; return null;
} }
ReturnType expressionType = unaryOperatorExpression.Expression.AcceptVisitor(this, data) as ReturnType; IReturnType expressionType = unaryOperatorExpression.Expression.AcceptVisitor(this, data) as IReturnType;
// TODO: Little bug: unary operator MAY change the return type, // TODO: Little bug: unary operator MAY change the return type,
// but that is only a minor issue // but that is only a minor issue
switch (unaryOperatorExpression.Op) { switch (unaryOperatorExpression.Op) {
@ -213,10 +216,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
case UnaryOperatorType.PostDecrement: case UnaryOperatorType.PostDecrement:
break; break;
case UnaryOperatorType.Star: // dereference case UnaryOperatorType.Star: // dereference
--expressionType.PointerNestingLevel; //--expressionType.PointerNestingLevel;
break; break;
case UnaryOperatorType.BitWiseAnd: // get reference case UnaryOperatorType.BitWiseAnd: // get reference
++expressionType.PointerNestingLevel; //++expressionType.PointerNestingLevel;
break; break;
case UnaryOperatorType.None: case UnaryOperatorType.None:
break; break;
@ -231,12 +234,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(SizeOfExpression sizeOfExpression, object data) public override object Visit(SizeOfExpression sizeOfExpression, object data)
{ {
return new ReturnType("System.Int32"); return ReflectionReturnType(typeof(int));
} }
public override object Visit(TypeOfExpression typeOfExpression, object data) public override object Visit(TypeOfExpression typeOfExpression, object data)
{ {
return new ReturnType("System.Type"); return ReflectionReturnType(typeof(Type));
} }
public override object Visit(CheckedExpression checkedExpression, object data) public override object Visit(CheckedExpression checkedExpression, object data)
@ -251,18 +254,21 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object Visit(CastExpression castExpression, object data) public override object Visit(CastExpression castExpression, object data)
{ {
return new ReturnType(castExpression.CastTo.Type); return CreateReturnType(castExpression.CastTo);
} }
public override object Visit(StackAllocExpression stackAllocExpression, object data) public override object Visit(StackAllocExpression stackAllocExpression, object data)
{ {
ReturnType returnType = new ReturnType(stackAllocExpression.TypeReference); /*ReturnType returnType = new ReturnType(stackAllocExpression.TypeReference);
++returnType.PointerNestingLevel; ++returnType.PointerNestingLevel;
return returnType; return returnType;*/
return null;
} }
public override object Visit(IndexerExpression indexerExpression, object data) public override object Visit(IndexerExpression indexerExpression, object data)
{ {
return null;
/*
IReturnType type = (IReturnType)indexerExpression.TargetObject.AcceptVisitor(this, data); IReturnType type = (IReturnType)indexerExpression.TargetObject.AcceptVisitor(this, data);
if (type == null) { if (type == null) {
return null; return null;
@ -290,6 +296,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
int[] newArray = new int[type.ArrayDimensions.Length - 1]; int[] newArray = new int[type.ArrayDimensions.Length - 1];
Array.Copy(type.ArrayDimensions, 0, newArray, 0, type.ArrayDimensions.Length - 1); Array.Copy(type.ArrayDimensions, 0, newArray, 0, type.ArrayDimensions.Length - 1);
return new ReturnType(type.Name, newArray, type.PointerNestingLevel); return new ReturnType(type.Name, newArray, type.PointerNestingLevel);
*/
} }
public override object Visit(ClassReferenceExpression classReferenceExpression, object data) public override object Visit(ClassReferenceExpression classReferenceExpression, object data)
@ -297,7 +304,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (resolver.CallingClass == null) { if (resolver.CallingClass == null) {
return null; return null;
} }
return new ReturnType(resolver.CallingClass.FullyQualifiedName); return resolver.CallingClass.DefaultReturnType;
} }
public override object Visit(ThisReferenceExpression thisReferenceExpression, object data) public override object Visit(ThisReferenceExpression thisReferenceExpression, object data)
@ -305,7 +312,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (resolver.CallingClass == null) { if (resolver.CallingClass == null) {
return null; return null;
} }
return new ReturnType(resolver.CallingClass.FullyQualifiedName); return resolver.CallingClass.DefaultReturnType;
} }
public override object Visit(BaseReferenceExpression baseReferenceExpression, object data) public override object Visit(BaseReferenceExpression baseReferenceExpression, object data)
@ -317,7 +324,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (baseClass == null) { if (baseClass == null) {
return null; return null;
} }
return new ReturnType(baseClass.FullyQualifiedName); return baseClass.DefaultReturnType;
} }
public override object Visit(ObjectCreateExpression objectCreateExpression, object data) public override object Visit(ObjectCreateExpression objectCreateExpression, object data)
@ -326,18 +333,21 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
IClass c = resolver.SearchType(name, resolver.CallingClass, resolver.CompilationUnit); IClass c = resolver.SearchType(name, resolver.CallingClass, resolver.CompilationUnit);
if (c != null) if (c != null)
name = c.FullyQualifiedName; name = c.FullyQualifiedName;
return new ReturnType(name, objectCreateExpression.CreateType.RankSpecifier, objectCreateExpression.CreateType.PointerNestingLevel); return c.DefaultReturnType;
//return new ReturnType(name, objectCreateExpression.CreateType.RankSpecifier, objectCreateExpression.CreateType.PointerNestingLevel);
} }
public override object Visit(ArrayCreateExpression arrayCreateExpression, object data) public override object Visit(ArrayCreateExpression arrayCreateExpression, object data)
{ {
ReturnType type = new ReturnType(arrayCreateExpression.CreateType); IReturnType type = CreateReturnType(arrayCreateExpression.CreateType);
/*
if (arrayCreateExpression.Parameters != null && arrayCreateExpression.Parameters.Count > 0) { if (arrayCreateExpression.Parameters != null && arrayCreateExpression.Parameters.Count > 0) {
int[] newRank = new int[arrayCreateExpression.Rank.Length + 1]; int[] newRank = new int[arrayCreateExpression.Rank.Length + 1];
newRank[0] = arrayCreateExpression.Parameters.Count - 1; newRank[0] = arrayCreateExpression.Parameters.Count - 1;
Array.Copy(type.ArrayDimensions, 0, newRank, 1, type.ArrayDimensions.Length); Array.Copy(type.ArrayDimensions, 0, newRank, 1, type.ArrayDimensions.Length);
type.ArrayDimensions = newRank; type.ArrayDimensions = newRank;
} }
*/
return type; return type;
} }
@ -352,5 +362,20 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
// no calls allowed !!! // no calls allowed !!!
return null; return null;
} }
IReturnType CreateReturnType(TypeReference reference)
{
return null;
}
IReturnType NamespaceReturnType(string namespaceName)
{
return null;
}
IReturnType ReflectionReturnType(Type t)
{
return null;
}
} }
} }

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

@ -20,7 +20,7 @@ namespace ICSharpCode.SharpDevelop.Dom
BindingFlags flags = BindingFlags.Instance | BindingFlags flags = BindingFlags.Instance |
BindingFlags.Static | BindingFlags.Static |
BindingFlags.NonPublic | //BindingFlags.NonPublic |
BindingFlags.DeclaredOnly | BindingFlags.DeclaredOnly |
BindingFlags.Public; BindingFlags.Public;
@ -128,12 +128,6 @@ namespace ICSharpCode.SharpDevelop.Dom
return type.IsSubclassOf(typeof(Delegate)) && type != typeof(MulticastDelegate); return type.IsSubclassOf(typeof(Delegate)) && type != typeof(MulticastDelegate);
} }
public override string DocumentationTag {
get {
return "T:" + type.FullName;
}
}
public ReflectionClass(ICompilationUnit compilationUnit, Type type, IClass declaringType) : base(compilationUnit, declaringType) public ReflectionClass(ICompilationUnit compilationUnit, Type type, IClass declaringType) : base(compilationUnit, declaringType)
{ {
this.type = type; this.type = type;

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

@ -18,7 +18,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public override IReturnType ReturnType { public override IReturnType ReturnType {
get { get {
return new ReflectionReturnType(eventInfo.EventHandlerType); return ReflectionReturnType.Create(this, eventInfo.EventHandlerType);
} }
set { set {
} }

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

@ -18,7 +18,7 @@ namespace ICSharpCode.SharpDevelop.Dom
FieldInfo fieldInfo; FieldInfo fieldInfo;
public override IReturnType ReturnType { public override IReturnType ReturnType {
get { get {
return new ReflectionReturnType(fieldInfo.FieldType); return ReflectionReturnType.Create(this, fieldInfo.FieldType);
} }
set { set {
} }

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

@ -20,7 +20,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public override IReturnType ReturnType { public override IReturnType ReturnType {
get { get {
return new ReflectionReturnType(propertyInfo.PropertyType); return ReflectionReturnType.Create(this, propertyInfo.PropertyType);
} }
set { set {
} }
@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get { get {
List<IParameter> parameters = new List<IParameter>(); List<IParameter> parameters = new List<IParameter>();
foreach (ParameterInfo parameterInfo in propertyInfo.GetIndexParameters()) { foreach (ParameterInfo parameterInfo in propertyInfo.GetIndexParameters()) {
parameters.Add(new ReflectionParameter(parameterInfo)); parameters.Add(new ReflectionParameter(parameterInfo, DeclaringType.ProjectContent));
} }
return parameters; return parameters;
} }
@ -38,20 +38,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
string GetIndexerName(PropertyInfo propertyInfo)
{
StringBuilder propertyName = new StringBuilder("Item(");
ParameterInfo[] p = propertyInfo.GetIndexParameters();
for (int i = 0; i < p.Length; ++i) {
propertyName.Append(p[i].ParameterType.FullName);
if (i + 1 < p.Length) {
propertyName.Append(',');
}
}
propertyName.Append(')');
return propertyName.ToString();
}
public ReflectionIndexer(PropertyInfo propertyInfo, IClass declaringType) : base(declaringType) public ReflectionIndexer(PropertyInfo propertyInfo, IClass declaringType) : base(declaringType)
{ {
this.propertyInfo = propertyInfo; this.propertyInfo = propertyInfo;

27
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionMethod.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public override IReturnType ReturnType { public override IReturnType ReturnType {
get { get {
if (methodBase is MethodInfo) { if (methodBase is MethodInfo) {
return new ReflectionReturnType(((MethodInfo)methodBase).ReturnType); return ReflectionReturnType.Create(this, ((MethodInfo)methodBase).ReturnType);
} }
return null; return null;
} }
@ -40,7 +40,7 @@ namespace ICSharpCode.SharpDevelop.Dom
get { get {
List<IParameter> parameters = new List<IParameter>(); List<IParameter> parameters = new List<IParameter>();
foreach (ParameterInfo paramInfo in methodBase.GetParameters()) { foreach (ParameterInfo paramInfo in methodBase.GetParameters()) {
parameters.Add(new ReflectionParameter(paramInfo)); parameters.Add(new ReflectionParameter(paramInfo, DeclaringType.ProjectContent));
} }
return parameters; return parameters;
} }
@ -48,29 +48,6 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
string GetParamList(MethodBase methodBase)
{
StringBuilder propertyName = new StringBuilder("(");
ParameterInfo[] p = methodBase.GetParameters();
if (p.Length == 0) {
return String.Empty;
}
for (int i = 0; i < p.Length; ++i) {
propertyName.Append(p[i].ParameterType.FullName);
if (i + 1 < p.Length) {
propertyName.Append(',');
}
}
propertyName.Append(')');
return propertyName.ToString();
}
public override string DocumentationTag {
get {
return "M:" + FullyQualifiedName + GetParamList(methodBase);
}
}
public ReflectionMethod(MethodBase methodBase, IClass declaringType) public ReflectionMethod(MethodBase methodBase, IClass declaringType)
: base(declaringType, methodBase is ConstructorInfo ? "#ctor" : methodBase.Name) : base(declaringType, methodBase is ConstructorInfo ? "#ctor" : methodBase.Name)
{ {

9
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionParameter.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Xml; using System.Xml;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Dom namespace ICSharpCode.SharpDevelop.Dom
{ {
@ -14,22 +15,24 @@ namespace ICSharpCode.SharpDevelop.Dom
public class ReflectionParameter : DefaultParameter public class ReflectionParameter : DefaultParameter
{ {
ParameterInfo parameterInfo; ParameterInfo parameterInfo;
IProjectContent content;
public override IReturnType ReturnType { public override IReturnType ReturnType {
get { get {
return new ReflectionReturnType(parameterInfo.ParameterType); return ReflectionReturnType.Create(content, parameterInfo.ParameterType);
} }
set { set {
} }
} }
public ReflectionParameter(ParameterInfo parameterInfo) : base(parameterInfo.Name) public ReflectionParameter(ParameterInfo parameterInfo, IProjectContent content) : base(parameterInfo.Name)
{ {
this.parameterInfo = parameterInfo; this.parameterInfo = parameterInfo;
this.content = content;
if (parameterInfo.IsOut) { if (parameterInfo.IsOut) {
modifier |= ParameterModifier.Out; modifier |= ParameterModifier.Out;
} }
Type type = parameterInfo.ParameterType; Type type = parameterInfo.ParameterType;
// TODO read param attribute // TODO read param attribute
//if (type.IsArray && type != typeof(Array) && Attribute.IsDefined(parameterInfo, typeof(ParamArrayAttribute), true)) { //if (type.IsArray && type != typeof(Array) && Attribute.IsDefined(parameterInfo, typeof(ParamArrayAttribute), true)) {

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

@ -18,7 +18,7 @@ namespace ICSharpCode.SharpDevelop.Dom
public override IReturnType ReturnType { public override IReturnType ReturnType {
get { get {
return new ReflectionReturnType(propertyInfo.PropertyType); return ReflectionReturnType.Create(this, propertyInfo.PropertyType);
} }
set { set {
} }

21
src/Main/Base/Project/Src/Dom/ReflectionLayer/ReflectionReturnType.cs

@ -6,9 +6,29 @@
// </file> // </file>
using System; using System;
using System.Collections; using System.Collections;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Dom namespace ICSharpCode.SharpDevelop.Dom
{ {
public static class ReflectionReturnType
{
public static IReturnType Create(IProjectContent content, Type type)
{
string name = type.FullName;
if (name == null) {
// this could be a generic type
return null;
}
return new LazyReturnType(new GetClassResolveContext(content), name);
}
public static IReturnType Create(IMember member, Type type)
{
return Create(member.DeclaringType.ProjectContent, type);
}
}
/*
[Serializable] [Serializable]
public class ReflectionReturnType : AbstractReturnType public class ReflectionReturnType : AbstractReturnType
{ {
@ -54,4 +74,5 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
} }
*/
} }

32
src/Main/Base/Project/Src/Dom/ResolveResult.cs

@ -71,6 +71,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
/*
public virtual IClass GetResolvedClass(IProjectContent projectContent) public virtual IClass GetResolvedClass(IProjectContent projectContent)
{ {
if (resolvedType == null) if (resolvedType == null)
@ -79,13 +80,25 @@ namespace ICSharpCode.SharpDevelop.Dom
return ProjectContentRegistry.GetMscorlibContent().GetClass("System.Array"); return ProjectContentRegistry.GetMscorlibContent().GetClass("System.Array");
return projectContent.GetClass(resolvedType.FullyQualifiedName); return projectContent.GetClass(resolvedType.FullyQualifiedName);
} }
*/
public virtual ArrayList GetCompletionData(IProjectContent projectContent) public virtual ArrayList GetCompletionData(IProjectContent projectContent)
{ {
IClass c = GetResolvedClass(projectContent); if (resolvedType == null) return null;
if (c == null) ArrayList res = new ArrayList();
return null; foreach (IMethod m in resolvedType.GetMethods()) {
return c.GetAccessibleMembers(callingClass, false); res.Add(m);
}
foreach (IEvent e in resolvedType.GetEvents()) {
res.Add(e);
}
foreach (IField f in resolvedType.GetFields()) {
res.Add(f);
}
foreach (IProperty p in resolvedType.GetProperties()) {
res.Add(p);
}
return res;
} }
public virtual FilePosition GetDefinitionPosition() public virtual FilePosition GetDefinitionPosition()
@ -228,19 +241,12 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
/*
public override IClass GetResolvedClass(IProjectContent projectContent) public override IClass GetResolvedClass(IProjectContent projectContent)
{ {
return resolvedClass; return resolvedClass;
} }
*/
public override ArrayList GetCompletionData(IProjectContent projectContent)
{
IClass c = GetResolvedClass(projectContent);
if (c == null)
return null;
else
return c.GetAccessibleMembers(this.CallingClass, true);
}
public override FilePosition GetDefinitionPosition() public override FilePosition GetDefinitionPosition()
{ {

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

@ -119,7 +119,7 @@ namespace ICSharpCode.Core
public string Convert(ParameterInfo param) public string Convert(ParameterInfo param)
{ {
return conv.Convert(new ReflectionParameter(param)); return conv.Convert(new ReflectionParameter(param, null));
} }
public ArrayList LinkArrayList { public ArrayList LinkArrayList {

5
src/Main/Base/Project/Src/Services/AmbienceService/NetAmbience.cs

@ -267,7 +267,8 @@ namespace ICSharpCode.Core
builder.Append("</a>"); builder.Append("</a>");
} }
for (int i = 0; i < returnType.PointerNestingLevel; ++i) { // TODO: Re-write this!
/*for (int i = 0; i < returnType.PointerNestingLevel; ++i) {
builder.Append('*'); builder.Append('*');
} }
@ -277,7 +278,7 @@ namespace ICSharpCode.Core
builder.Append(','); builder.Append(',');
} }
builder.Append(']'); builder.Append(']');
} }*/
return builder.ToString(); return builder.ToString();
} }

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

@ -380,6 +380,7 @@ namespace ICSharpCode.Core
return null; return null;
} }
/*
public ArrayList ListMembers(ArrayList members, IClass curType, IClass callingClass, bool showStatic) public ArrayList ListMembers(ArrayList members, IClass curType, IClass callingClass, bool showStatic)
{ {
// Console.WriteLine("ListMembers()"); // Console.WriteLine("ListMembers()");
@ -447,7 +448,7 @@ namespace ICSharpCode.Core
return members; return members;
} }
*/
public Position GetPosition(string fullMemberName) public Position GetPosition(string fullMemberName)
{ {
@ -480,13 +481,14 @@ 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 = curClass.SearchMember(name[i]); return new Position(cu, -1, -1);
// TODO: reimplement this
/*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);
} }
return new Position(cu, member.Region.BeginLine, member.Region.BeginColumn); return new Position(cu, member.Region.BeginLine, member.Region.BeginColumn);*/
} }
#endregion #endregion
} }
} }

Loading…
Cancel
Save