Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@124 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
35 changed files with 665 additions and 447 deletions
@ -0,0 +1,93 @@
@@ -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; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,90 @@
@@ -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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,89 @@
@@ -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>(); |
||||
} |
||||
} |
||||
} |
@ -1,50 +0,0 @@
@@ -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); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue