37 changed files with 2835 additions and 8 deletions
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory |
||||
{ |
||||
/// <summary>
|
||||
/// Enum that describes the accessibility of an entity.
|
||||
/// </summary>
|
||||
public enum Accessibility |
||||
{ |
||||
/// <summary>
|
||||
/// The entity is completely inaccessible. This is used for C# explicit interface implementations.
|
||||
/// </summary>
|
||||
None, |
||||
/// <summary>
|
||||
/// The entity is only accessible within the same class.
|
||||
/// </summary>
|
||||
Private, |
||||
/// <summary>
|
||||
/// The entity is accessible everywhere.
|
||||
/// </summary>
|
||||
Public, |
||||
/// <summary>
|
||||
/// The entity is only accessible within the same class and in derived classes.
|
||||
/// </summary>
|
||||
Protected, |
||||
/// <summary>
|
||||
/// The entity is accessible within the same project content.
|
||||
/// </summary>
|
||||
Internal, |
||||
/// <summary>
|
||||
/// The entity is accessible both everywhere in the project content, and in all derived classes.
|
||||
/// </summary>
|
||||
ProtectedOrInternal, |
||||
/// <summary>
|
||||
/// The entity is accessible in derived classes within the same project content.
|
||||
/// </summary>
|
||||
ProtectedAndInternal |
||||
} |
||||
} |
||||
@ -0,0 +1,135 @@
@@ -0,0 +1,135 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Globalization; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[Serializable] |
||||
public struct DomRegion : IEquatable<DomRegion> |
||||
{ |
||||
readonly string fileName; |
||||
readonly int beginLine; |
||||
readonly int endLine; |
||||
readonly int beginColumn; |
||||
readonly int endColumn; |
||||
|
||||
public readonly static DomRegion Empty = new DomRegion(null, -1, -1); |
||||
|
||||
public bool IsEmpty { |
||||
get { |
||||
return BeginLine <= 0; |
||||
} |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
public int BeginLine { |
||||
get { |
||||
return beginLine; |
||||
} |
||||
} |
||||
|
||||
/// <value>
|
||||
/// if the end line is == -1 the end column is -1 too
|
||||
/// this stands for an unknwon end
|
||||
/// </value>
|
||||
public int EndLine { |
||||
get { |
||||
return endLine; |
||||
} |
||||
} |
||||
|
||||
public int BeginColumn { |
||||
get { |
||||
return beginColumn; |
||||
} |
||||
} |
||||
|
||||
/// <value>
|
||||
/// if the end column is == -1 the end line is -1 too
|
||||
/// this stands for an unknown end
|
||||
/// </value>
|
||||
public int EndColumn { |
||||
get { |
||||
return endColumn; |
||||
} |
||||
} |
||||
|
||||
public DomRegion(string fileName, int beginLine, int beginColumn, int endLine, int endColumn) |
||||
{ |
||||
if (fileName == null) |
||||
throw new ArgumentNullException("fileName"); |
||||
this.fileName = fileName; |
||||
this.beginLine = beginLine; |
||||
this.beginColumn = beginColumn; |
||||
this.endLine = endLine; |
||||
this.endColumn = endColumn; |
||||
} |
||||
|
||||
public DomRegion(string fileName, int beginLine, int beginColumn) |
||||
{ |
||||
if (fileName == null) |
||||
throw new ArgumentNullException("fileName"); |
||||
this.fileName = fileName; |
||||
this.beginLine = beginLine; |
||||
this.beginColumn = beginColumn; |
||||
this.endLine = -1; |
||||
this.endColumn = -1; |
||||
} |
||||
|
||||
/// <remarks>
|
||||
/// Returns true, if the given coordinates (row, column) are in the region.
|
||||
/// This method assumes that for an unknown end the end line is == -1
|
||||
/// </remarks>
|
||||
public bool IsInside(int row, int column) |
||||
{ |
||||
if (IsEmpty) |
||||
return false; |
||||
return row >= BeginLine && |
||||
(row <= EndLine || EndLine == -1) && |
||||
(row != BeginLine || column >= BeginColumn) && |
||||
(row != EndLine || column <= EndColumn); |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return string.Format( |
||||
CultureInfo.InvariantCulture, |
||||
"[DomRegion FileName={0}, BeginLine={1}, EndLine={2}, BeginColumn={3}, EndColumn={4}]", |
||||
fileName, beginLine, endLine, beginColumn, endColumn); |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
return obj is DomRegion && Equals((DomRegion)obj); |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
unchecked { |
||||
return BeginColumn + 1100009 * BeginLine + 1200007 * BeginColumn + 1300021 * EndColumn; |
||||
} |
||||
} |
||||
|
||||
public bool Equals(DomRegion other) |
||||
{ |
||||
return BeginLine == other.BeginLine && BeginColumn == other.BeginColumn |
||||
&& EndLine == other.EndLine && EndColumn == other.EndColumn |
||||
&& fileName == other.fileName; |
||||
} |
||||
|
||||
public static bool operator ==(DomRegion left, DomRegion right) |
||||
{ |
||||
return left.Equals(right); |
||||
} |
||||
|
||||
public static bool operator !=(DomRegion left, DomRegion right) |
||||
{ |
||||
return !left.Equals(right); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
public enum EntityType |
||||
{ |
||||
Class, |
||||
Field, |
||||
Property, |
||||
Indexer, |
||||
Event, |
||||
Method, |
||||
Operator, |
||||
Constructor, |
||||
Destructor |
||||
} |
||||
} |
||||
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an attribute.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IAttributeContract))] |
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] |
||||
public interface IAttribute : IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the code region of this attribute.
|
||||
/// </summary>
|
||||
DomRegion Region { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the attribute.
|
||||
/// </summary>
|
||||
ITypeReference AttributeType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the positional arguments passed to the attribute.
|
||||
/// </summary>
|
||||
IList<IConstantValue> PositionalArguments { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the named arguments passed to the attribute.
|
||||
/// </summary>
|
||||
IList<KeyValuePair<string, IConstantValue>> NamedArguments { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IAttribute))] |
||||
abstract class IAttributeContract : IFreezableContract, IAttribute |
||||
{ |
||||
DomRegion IAttribute.Region { |
||||
get { return DomRegion.Empty; } |
||||
} |
||||
|
||||
ITypeReference IAttribute.AttributeType { |
||||
get { |
||||
Contract.Ensures(Contract.Result<ITypeReference>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<IConstantValue> IAttribute.PositionalArguments { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IConstantValue>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<KeyValuePair<string, IConstantValue>> IAttribute.NamedArguments { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<KeyValuePair<string, IConstantValue>>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(IConstantValueContract))] |
||||
public interface IConstantValue : IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the type of the constant value.
|
||||
/// </summary>
|
||||
IType GetValueType(ITypeResolveContext context); |
||||
|
||||
/// <summary>
|
||||
/// Gets the .NET value of the constant value.
|
||||
/// Possible return values are:
|
||||
/// - primitive integers
|
||||
/// - float/double
|
||||
/// - bool
|
||||
/// - string
|
||||
/// - IType (for typeof-expressions)
|
||||
/// and arrays of these values. Enum values are returned using the underlying primitive integer.
|
||||
/// </summary>
|
||||
object GetValue(ITypeResolveContext context); |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IConstantValue))] |
||||
abstract class IConstantValueContract : IFreezableContract, IConstantValue |
||||
{ |
||||
IType IConstantValue.GetValueType(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
Contract.Ensures(Contract.Result<IType>() != null); |
||||
return null; |
||||
} |
||||
|
||||
object IConstantValue.GetValue(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(IEntityContract))] |
||||
public interface IEntity : INamedElement, IFreezable |
||||
{ |
||||
EntityType EntityType { get; } |
||||
|
||||
DomRegion Region { get; } |
||||
DomRegion BodyRegion { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the declaring class.
|
||||
/// For members, this is the class that contains the member.
|
||||
/// For nested classes, this is the outer class. For top-level classes, this property returns null.
|
||||
/// </summary>
|
||||
ITypeDefinition DeclaringTypeDefinition { get; } |
||||
|
||||
IList<IAttribute> Attributes { get; } |
||||
|
||||
string Documentation { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this entity is static.
|
||||
/// Returns true if either the 'static' or the 'const' modifier is set.
|
||||
/// </summary>
|
||||
bool IsStatic { |
||||
get; |
||||
} |
||||
|
||||
Accessibility Accessibility { get; } |
||||
|
||||
bool IsAbstract { get; } |
||||
|
||||
bool IsSealed { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this member is declared to be shadowing another member with the same name.
|
||||
/// </summary>
|
||||
bool IsShadowing { |
||||
get; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this member is generated by a macro/compiler feature.
|
||||
/// </summary>
|
||||
bool IsSynthetic { |
||||
get; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The project content in which this entity is defined.
|
||||
/// This property never returns null.
|
||||
/// </summary>
|
||||
IProjectContent ProjectContent { |
||||
get; |
||||
} |
||||
|
||||
//bool IsAccessible(IClass callingClass, bool isAccessThoughReferenceOfCurrentClass);
|
||||
} |
||||
|
||||
[ContractClassFor(typeof(IEntity))] |
||||
abstract class IEntityContract : INamedElementContract, IEntity |
||||
{ |
||||
EntityType IEntity.EntityType { |
||||
get { return default(EntityType); } |
||||
} |
||||
|
||||
DomRegion IEntity.Region { |
||||
get { return DomRegion.Empty; } |
||||
} |
||||
|
||||
DomRegion IEntity.BodyRegion { |
||||
get { return DomRegion.Empty; } |
||||
} |
||||
|
||||
ITypeDefinition IEntity.DeclaringTypeDefinition { |
||||
get { return null; } |
||||
} |
||||
|
||||
IList<IAttribute> IEntity.Attributes { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IAttribute>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string IEntity.Documentation { |
||||
get { return null; } |
||||
} |
||||
|
||||
bool IEntity.IsStatic { |
||||
get { return false; } |
||||
} |
||||
|
||||
Accessibility IEntity.Accessibility { |
||||
get { return default(Accessibility); } |
||||
} |
||||
|
||||
bool IEntity.IsAbstract { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IEntity.IsSealed { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IEntity.IsShadowing { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IEntity.IsSynthetic { |
||||
get { return false; } |
||||
} |
||||
|
||||
IProjectContent IEntity.ProjectContent { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IProjectContent>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
bool IFreezable.IsFrozen { |
||||
get { return false; } |
||||
} |
||||
|
||||
void IFreezable.Freeze() |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(IEventContract))] |
||||
public interface IEvent : IMember |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the add method.
|
||||
/// </summary>
|
||||
IMethod AddMethod { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the remove method.
|
||||
/// </summary>
|
||||
IMethod RemoveMethod { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the raise method.
|
||||
/// </summary>
|
||||
IMethod RaiseMethod { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IEvent))] |
||||
abstract class IEventContract : IMemberContract, IEvent |
||||
{ |
||||
IMethod IEvent.AddMethod { |
||||
get { return null; } |
||||
} |
||||
|
||||
IMethod IEvent.RemoveMethod { |
||||
get { return null; } |
||||
} |
||||
|
||||
IMethod IEvent.RaiseMethod { |
||||
get { return null; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an explicit interface implementation.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IExplicitInterfaceImplementationContract))] |
||||
public interface IExplicitInterfaceImplementation : IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the type of the interface.
|
||||
/// </summary>
|
||||
ITypeReference InterfaceType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the member name.
|
||||
/// </summary>
|
||||
string MemberName { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IExplicitInterfaceImplementation))] |
||||
abstract class IExplicitInterfaceImplementationContract : IFreezableContract, IExplicitInterfaceImplementation |
||||
{ |
||||
ITypeReference IExplicitInterfaceImplementation.InterfaceType { |
||||
get { |
||||
Contract.Ensures(Contract.Result<ITypeReference>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string IExplicitInterfaceImplementation.MemberName { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a field or constant.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IFieldContract))] |
||||
public interface IField : IMember, IVariable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the name of the field.
|
||||
/// </summary>
|
||||
new string Name { get; } // solve ambiguity between INamedElement.Name and IVariable.Name
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this field is a constant (C#-like const).
|
||||
/// </summary>
|
||||
bool IsConst { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this field is readonly.
|
||||
/// </summary>
|
||||
bool IsReadOnly { get; } |
||||
|
||||
/// <summary>
|
||||
/// If this field is a constant, retrieves the value.
|
||||
/// </summary>
|
||||
IConstantValue ConstantValue { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IField))] |
||||
abstract class IFieldContract : IMemberContract, IField |
||||
{ |
||||
string IField.Name { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
bool IField.IsConst { |
||||
get { |
||||
IField @this = this; |
||||
Contract.Ensures(Contract.Result<bool>() == (@this.ConstantValue != null)); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool IField.IsReadOnly { |
||||
get { return false; } |
||||
} |
||||
|
||||
IConstantValue IField.ConstantValue { |
||||
get { return null; } |
||||
} |
||||
|
||||
string IVariable.Name { |
||||
get { throw new NotImplementedException(); } |
||||
} |
||||
|
||||
ITypeReference IVariable.Type { |
||||
get { throw new NotImplementedException(); } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(IFreezableContract))] |
||||
public interface IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
|
||||
/// </summary>
|
||||
bool IsFrozen { get; } |
||||
|
||||
/// <summary>
|
||||
/// Freezes this instance.
|
||||
/// </summary>
|
||||
void Freeze(); |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IFreezable))] |
||||
abstract class IFreezableContract : IFreezable |
||||
{ |
||||
bool IFreezable.IsFrozen { |
||||
get { return default(bool); } |
||||
} |
||||
|
||||
void IFreezable.Freeze() |
||||
{ |
||||
IFreezable self = this; |
||||
Contract.Ensures(self.IsFrozen); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(IInterningProviderContract))] |
||||
public interface IInterningProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Intern the specified string.
|
||||
/// </summary>
|
||||
string InternString(string s); |
||||
|
||||
/// <summary>
|
||||
/// Interns the specified object.
|
||||
/// The object must implement <see cref="ISupportsInterning"/>, otherwise it will be returned without being interned.
|
||||
/// </summary>
|
||||
T InternObject<T>(T obj); |
||||
|
||||
IList<T> InternObjectList<T>(IList<T> list); |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IInterningProvider))] |
||||
abstract class IInterningProviderContract : IInterningProvider |
||||
{ |
||||
string IInterningProvider.InternString(string s) |
||||
{ |
||||
Contract.Ensures((Contract.Result<string>() == null) == (s == null)); |
||||
Contract.Ensures(string.IsNullOrEmpty(Contract.Result<string>()) == string.IsNullOrEmpty(s)); |
||||
return s; |
||||
} |
||||
|
||||
T IInterningProvider.InternObject<T>(T obj) |
||||
{ |
||||
Contract.Ensures((Contract.Result<T>() == null) == (obj == null)); |
||||
return obj; |
||||
} |
||||
|
||||
IList<T> IInterningProvider.InternObjectList<T>(IList<T> list) |
||||
{ |
||||
Contract.Ensures((Contract.Result<IList<T>>() == null) == (list == null)); |
||||
return list; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,115 @@
@@ -0,0 +1,115 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Method/field/entity.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IMemberContract))] |
||||
public interface IMember : IEntity |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the type definition that contains the member. This property never returns null.
|
||||
/// </summary>
|
||||
new ITypeDefinition DeclaringTypeDefinition { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the declaring type (incl. type arguments, if any).
|
||||
/// This property never returns null.
|
||||
/// If this is not a specialized member, the value returned is equal to <see cref="DeclaringTypeDefinition"/>.
|
||||
/// </summary>
|
||||
IType DeclaringType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the generic member this member is based on.
|
||||
/// Returns null if this is not a specialized member.
|
||||
/// Specialized members are the result of overload resolution with type substitution.
|
||||
/// </summary>
|
||||
IMember GenericMember { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the return type of this member.
|
||||
/// This property never returns null.
|
||||
/// </summary>
|
||||
ITypeReference ReturnType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of interfaces this member is implementing explicitly.
|
||||
/// </summary>
|
||||
IList<IExplicitInterfaceImplementation> InterfaceImplementations { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets if the member is virtual. Is true only if the "virtual" modifier was used, but non-virtual
|
||||
/// members can be overridden, too; if they are already overriding a method.
|
||||
/// </summary>
|
||||
bool IsVirtual { |
||||
get; |
||||
} |
||||
|
||||
bool IsOverride { |
||||
get; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the member can be overridden. Returns true when the member is "virtual" or "override" but not "sealed".
|
||||
/// </summary>
|
||||
bool IsOverridable { |
||||
get; |
||||
} |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IMember))] |
||||
abstract class IMemberContract : IEntityContract, IMember |
||||
{ |
||||
ITypeDefinition IMember.DeclaringTypeDefinition { |
||||
get { |
||||
Contract.Ensures(Contract.Result<ITypeDefinition>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IType IMember.DeclaringType { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IType>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IMember IMember.GenericMember { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
ITypeReference IMember.ReturnType { |
||||
get { |
||||
Contract.Ensures(Contract.Result<ITypeReference>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<IExplicitInterfaceImplementation> IMember.InterfaceImplementations { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IExplicitInterfaceImplementation>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
bool IMember.IsVirtual { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IMember.IsOverride { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IMember.IsOverridable { |
||||
get { return false; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a method, constructor, destructor or operator.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IMethodContract))] |
||||
public interface IMethod : IParameterizedMember |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the attributes associated with the return type.
|
||||
/// </summary>
|
||||
IList<IAttribute> ReturnTypeAttributes { get; } |
||||
|
||||
IList<ITypeParameter> TypeParameters { get; } |
||||
|
||||
// handles is VB-specific and not part of the public API, so
|
||||
// we don't really need it
|
||||
//IList<string> HandlesClauses { get; }
|
||||
|
||||
bool IsExtensionMethod { get; } |
||||
bool IsConstructor { get; } |
||||
bool IsDestructor { get; } |
||||
bool IsOperator { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IMethod))] |
||||
abstract class IMethodContract : IParameterizedMemberContract, IMethod |
||||
{ |
||||
IList<IAttribute> IMethod.ReturnTypeAttributes { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IAttribute>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<ITypeParameter> IMethod.TypeParameters { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<ITypeParameter>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
// IList<string> IMethod.HandlesClauses {
|
||||
// get {
|
||||
// Contract.Ensures(Contract.Result<IList<string>>() != null);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
bool IMethod.IsExtensionMethod { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IMethod.IsConstructor { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IMethod.IsDestructor { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IMethod.IsOperator { |
||||
get { return false; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(INamedElementContract))] |
||||
public interface INamedElement |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the fully qualified name of the class the return type is pointing to.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// "System.Int32" for int[]<br/>
|
||||
/// "System.Collections.Generic.List" for List<string>
|
||||
/// </returns>
|
||||
string FullName { |
||||
get; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the short name of the class the return type is pointing to.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// "Int32" or "int" (depending how the return type was created) for int[]<br/>
|
||||
/// "List" for List<string>
|
||||
/// </returns>
|
||||
string Name { |
||||
get; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the namespace of the class the return type is pointing to.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// "System" for int[]<br/>
|
||||
/// "System.Collections.Generic" for List<string>
|
||||
/// </returns>
|
||||
string Namespace { |
||||
get; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the full dotnet name of the return type. The DotnetName is used for the
|
||||
/// documentation tags.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// "System.Int[]" for int[]<br/>
|
||||
/// "System.Collections.Generic.List{System.String}" for List<string>
|
||||
/// </returns>
|
||||
string DotNetName { |
||||
get; |
||||
} |
||||
} |
||||
|
||||
[ContractClassFor(typeof(INamedElement))] |
||||
abstract class INamedElementContract : INamedElement |
||||
{ |
||||
string INamedElement.FullName { |
||||
get { |
||||
Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>())); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string INamedElement.Name { |
||||
get { |
||||
Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>())); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string INamedElement.Namespace { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string INamedElement.DotNetName { |
||||
get { |
||||
Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>())); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(IParameterContract))] |
||||
public interface IParameter : IVariable, IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the list of attributes.
|
||||
/// </summary>
|
||||
IList<IAttribute> Attributes { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the default value of optional parameters.
|
||||
/// </summary>
|
||||
IConstantValue DefaultValue { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the code region where the parameter is defined.
|
||||
/// </summary>
|
||||
DomRegion Region { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this parameter is a C# 'ref' parameter.
|
||||
/// </summary>
|
||||
bool IsRef { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this parameter is a C# 'out' parameter.
|
||||
/// </summary>
|
||||
bool IsOut { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this parameter is a C# 'params' parameter.
|
||||
/// </summary>
|
||||
bool IsParams { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this parameter is optional.
|
||||
/// </summary>
|
||||
bool IsOptional { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IParameter))] |
||||
abstract class IParameterContract : IVariableContract, IParameter |
||||
{ |
||||
IList<IAttribute> IParameter.Attributes { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IAttribute>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IConstantValue IParameter.DefaultValue { |
||||
get { return null; } |
||||
} |
||||
|
||||
DomRegion IParameter.Region { |
||||
get { return DomRegion.Empty; } |
||||
} |
||||
|
||||
bool IParameter.IsRef { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IParameter.IsOut { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IParameter.IsParams { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IParameter.IsOptional { |
||||
get { |
||||
IParameter @this = this; |
||||
Contract.Ensures(Contract.Result<bool>() == (@this.DefaultValue != null)); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool IFreezable.IsFrozen { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
void IFreezable.Freeze() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a method or property.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IParameterizedMemberContract))] |
||||
public interface IParameterizedMember : IMember |
||||
{ |
||||
IList<IParameter> Parameters { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IParameterizedMember))] |
||||
abstract class IParameterizedMemberContract : IMemberContract, IParameterizedMember |
||||
{ |
||||
IList<IParameter> IParameterizedMember.Parameters { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IParameter>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Mutable container of all classes in an assembly.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IProjectContentContract))] |
||||
public interface IProjectContent : ITypeResolveContext |
||||
{ |
||||
LanguageProperties Language { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IProjectContent))] |
||||
abstract class IProjectContentContract : ITypeResolveContextContract, IProjectContent |
||||
{ |
||||
LanguageProperties IProjectContent.Language { |
||||
get { |
||||
Contract.Ensures(Contract.Result<LanguageProperties>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a property or indexer.
|
||||
/// </summary>
|
||||
public interface IProperty : IParameterizedMember |
||||
{ |
||||
IMethod GetMethod { get; } |
||||
IMethod SetMethod { get; } |
||||
|
||||
bool IsIndexer { get; } |
||||
} |
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Interface for DOM objects that support interning.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(ISupportsInterningContract))] |
||||
public interface ISupportsInterning : IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// Interns child objects and strings.
|
||||
/// </summary>
|
||||
void PrepareForInterning(IInterningProvider provider); |
||||
|
||||
/// <summary>
|
||||
/// Gets a hash code for interning.
|
||||
/// </summary>
|
||||
int GetHashCodeForInterning(); |
||||
|
||||
/// <summary>
|
||||
/// Equality test for interning.
|
||||
/// </summary>
|
||||
bool EqualsForInterning(ISupportsInterning other); |
||||
} |
||||
|
||||
[ContractClassFor(typeof(ISupportsInterning))] |
||||
abstract class ISupportsInterningContract : IFreezableContract, ISupportsInterning |
||||
{ |
||||
void ISupportsInterning.PrepareForInterning(IInterningProvider provider) |
||||
{ |
||||
Contract.Requires(provider != null); |
||||
} |
||||
|
||||
int ISupportsInterning.GetHashCodeForInterning() |
||||
{ |
||||
return 0; |
||||
} |
||||
|
||||
bool ISupportsInterning.EqualsForInterning(ISupportsInterning other) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,126 @@
@@ -0,0 +1,126 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(ITypeContract))] |
||||
public interface IType : ITypeReference, INamedElement, IEquatable<IType> |
||||
{ |
||||
/// <summary>
|
||||
/// Gets whether the type is a reference type or value type.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// true, if the type is a reference type.
|
||||
/// false, if the type is a value type.
|
||||
/// null, if the type is not known (e.g. unconstrained generic type parameter or type not found)
|
||||
/// </returns>
|
||||
bool? IsReferenceType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the element type of array or pointer types.
|
||||
/// </summary>
|
||||
IType GetElementType(); |
||||
|
||||
/// <summary>
|
||||
/// Gets the underlying type definition.
|
||||
/// Can return null for types which do not have a type definition (for example type parameters)
|
||||
/// </summary>
|
||||
ITypeDefinition GetDefinition(); |
||||
|
||||
/// <summary>
|
||||
/// Gets the parent type, if this is a nested type.
|
||||
/// Returns null for top-level types.
|
||||
/// </summary>
|
||||
IType DeclaringType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this type is an array type.
|
||||
/// </summary>
|
||||
bool IsArrayType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this type is a pointer type.
|
||||
/// </summary>
|
||||
bool IsPointerType { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the number of type parameters.
|
||||
/// </summary>
|
||||
int TypeParameterCount { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IType))] |
||||
abstract class ITypeContract : ITypeReferenceContract, IType |
||||
{ |
||||
Nullable<bool> IType.IsReferenceType { |
||||
get { return null; } |
||||
} |
||||
|
||||
bool IType.IsArrayType { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IType.IsPointerType { |
||||
get { return false; } |
||||
} |
||||
|
||||
int IType.TypeParameterCount { |
||||
get { |
||||
Contract.Ensures(Contract.Result<int>() >= 0); |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
IType IType.DeclaringType { |
||||
get { return null; } |
||||
} |
||||
|
||||
string INamedElement.FullName { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string INamedElement.Name { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string INamedElement.Namespace { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
string INamedElement.DotNetName { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IType IType.GetElementType() |
||||
{ |
||||
Contract.Ensures(Contract.Result<IType>() != null); |
||||
return null; |
||||
} |
||||
|
||||
ITypeDefinition IType.GetDefinition() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
bool IEquatable<IType>.Equals(IType other) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,198 @@
@@ -0,0 +1,198 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a class, enum, interface, struct, delegate or VB module.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(ITypeDefinitionContract))] |
||||
public interface ITypeDefinition : IType, IEntity |
||||
{ |
||||
ClassType ClassType { get; } |
||||
|
||||
IList<ITypeReference> BaseTypes { get; } |
||||
IList<ITypeParameter> TypeParameters { get; } |
||||
|
||||
/// <summary>
|
||||
/// If this is a partial class, gets the compound class containing information from all parts.
|
||||
/// If this is not a partial class, a reference to this class is returned.
|
||||
///
|
||||
/// This method will always retrieve the latest version of the class, which might not contain this class as a part.
|
||||
/// </summary>
|
||||
ITypeDefinition GetCompoundClass(); |
||||
|
||||
/// <summary>
|
||||
/// If this is a compound class (combination of class parts), this method retrieves all individual class parts.
|
||||
/// Otherwise, a list containing <c>this</c> is returned.
|
||||
/// </summary>
|
||||
IList<ITypeDefinition> GetParts(); |
||||
|
||||
IList<ITypeDefinition> InnerClasses { get; } |
||||
IList<IField> Fields { get; } |
||||
IList<IProperty> Properties { get; } |
||||
IList<IMethod> Methods { get; } |
||||
IList<IEvent> Events { get; } |
||||
IEnumerable<IMember> Members { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(ITypeDefinition))] |
||||
abstract class ITypeDefinitionContract : ITypeContract, ITypeDefinition |
||||
{ |
||||
ClassType ITypeDefinition.ClassType { |
||||
get { return default(ClassType); } |
||||
} |
||||
|
||||
IList<ITypeReference> ITypeDefinition.BaseTypes { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<ITypeReference>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<ITypeParameter> ITypeDefinition.TypeParameters { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<ITypeParameter>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<ITypeDefinition> ITypeDefinition.InnerClasses { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<ITypeDefinition>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<IField> ITypeDefinition.Fields { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IField>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<IProperty> ITypeDefinition.Properties { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IProperty>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<IMethod> ITypeDefinition.Methods { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IMethod>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<IEvent> ITypeDefinition.Events { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IEvent>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IEnumerable<IMember> ITypeDefinition.Members { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IEnumerable<IMember>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
ITypeDefinition ITypeDefinition.GetCompoundClass() |
||||
{ |
||||
Contract.Ensures(Contract.Result<ITypeDefinition>() != null); |
||||
return null; |
||||
} |
||||
|
||||
IList<ITypeDefinition> ITypeDefinition.GetParts() |
||||
{ |
||||
Contract.Ensures(Contract.Result<IList<ITypeDefinition>>() != null); |
||||
return null; |
||||
} |
||||
|
||||
#region IEntity
|
||||
EntityType IEntity.EntityType { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
DomRegion IEntity.Region { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
DomRegion IEntity.BodyRegion { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
ITypeDefinition IEntity.DeclaringTypeDefinition { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
IList<IAttribute> IEntity.Attributes { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
string IEntity.Documentation { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
bool IEntity.IsStatic { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
Accessibility IEntity.Accessibility { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
bool IEntity.IsAbstract { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
bool IEntity.IsSealed { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
bool IEntity.IsShadowing { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
bool IEntity.IsSynthetic { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
IProjectContent IEntity.ProjectContent { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,146 @@
@@ -0,0 +1,146 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Type parameter of a generic class/method.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(ITypeParameterContract))] |
||||
public interface ITypeParameter : IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// The name of the type parameter (for example "T")
|
||||
/// </summary>
|
||||
string Name { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the type parameter in the type parameter list of the owning method/class.
|
||||
/// </summary>
|
||||
int Index { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of attributes declared on this type parameter.
|
||||
/// </summary>
|
||||
IList<IAttribute> Attributes { get; } |
||||
|
||||
/// <summary>
|
||||
/// The method this type parameter is defined for.
|
||||
/// This property is null when the type parameter is for a class.
|
||||
/// </summary>
|
||||
IMethod ParentMethod { 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>
|
||||
ITypeDefinition ParentClass { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the contraints of this type parameter.
|
||||
/// </summary>
|
||||
IList<ITypeReference> Constraints { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets if the type parameter has the 'new()' constraint.
|
||||
/// </summary>
|
||||
bool HasConstructableConstraint { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets if the type parameter has the 'class' constraint.
|
||||
/// </summary>
|
||||
bool HasReferenceTypeConstraint { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets if the type parameter has the 'struct' constraint.
|
||||
/// </summary>
|
||||
bool HasValueTypeConstraint { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the type that was used to bind this type parameter.
|
||||
/// This property returns null for generic methods/classes, it
|
||||
/// is non-null only for constructed versions of generic methods.
|
||||
/// </summary>
|
||||
IType BoundTo { get; } |
||||
|
||||
/// <summary>
|
||||
/// If this type parameter was bound, returns the unbound version of it.
|
||||
/// </summary>
|
||||
ITypeParameter UnboundTypeParameter { get; } |
||||
} |
||||
|
||||
|
||||
[ContractClassFor(typeof(ITypeParameter))] |
||||
abstract class ITypeParameterContract : IFreezableContract, ITypeParameter |
||||
{ |
||||
string ITypeParameter.Name { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
int ITypeParameter.Index { |
||||
get { |
||||
Contract.Ensures(Contract.Result<int>() >= 0); |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
IList<IAttribute> ITypeParameter.Attributes { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<IAttribute>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IMethod ITypeParameter.ParentMethod { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
ITypeDefinition ITypeParameter.ParentClass { |
||||
get { |
||||
Contract.Ensures(Contract.Result<ITypeDefinition>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
IList<ITypeReference> ITypeParameter.Constraints { |
||||
get { |
||||
Contract.Ensures(Contract.Result<IList<ITypeReference>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
bool ITypeParameter.HasConstructableConstraint { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool ITypeParameter.HasReferenceTypeConstraint { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool ITypeParameter.HasValueTypeConstraint { |
||||
get { return false; } |
||||
} |
||||
|
||||
IType ITypeParameter.BoundTo { |
||||
get { return null; } |
||||
} |
||||
|
||||
ITypeParameter ITypeParameter.UnboundTypeParameter { |
||||
get { |
||||
ITypeParameter @this = this; |
||||
Contract.Ensures((Contract.Result<ITypeParameter>() != null) == (@this.BoundTo != null)); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
[ContractClass(typeof(ITypeReferenceContract))] |
||||
public interface ITypeReference : IFreezable |
||||
{ |
||||
/// <summary>
|
||||
/// Resolves this type reference.
|
||||
/// </summary>
|
||||
IType Resolve(ITypeResolveContext context); |
||||
|
||||
/// <summary>
|
||||
/// Gets the base type. May return null.
|
||||
/// </summary>
|
||||
IType GetBaseType(ITypeResolveContext context); |
||||
|
||||
/// <summary>
|
||||
/// Gets inner classes (including inherited inner classes).
|
||||
/// </summary>
|
||||
IList<IType> GetNestedTypes(ITypeResolveContext context); |
||||
|
||||
/// <summary>
|
||||
/// Gets all methods that can be called on this return type.
|
||||
/// </summary>
|
||||
IList<IMethod> GetMethods(ITypeResolveContext context); |
||||
|
||||
/// <summary>
|
||||
/// Gets all properties that can be called on this return type.
|
||||
/// </summary>
|
||||
IList<IProperty> GetProperties(ITypeResolveContext context); |
||||
|
||||
/// <summary>
|
||||
/// Gets all fields that can be called on this return type.
|
||||
/// </summary>
|
||||
IList<IField> GetFields(ITypeResolveContext context); |
||||
|
||||
/// <summary>
|
||||
/// Gets all events that can be called on this return type.
|
||||
/// </summary>
|
||||
IList<IEvent> GetEvents(ITypeResolveContext context); |
||||
} |
||||
|
||||
[ContractClassFor(typeof(ITypeReference))] |
||||
abstract class ITypeReferenceContract : IFreezableContract, ITypeReference |
||||
{ |
||||
IType ITypeReference.Resolve(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
Contract.Ensures(Contract.Result<IType>() != null); |
||||
return null; |
||||
} |
||||
|
||||
IType ITypeReference.GetBaseType(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
return null; |
||||
} |
||||
|
||||
IList<IType> ITypeReference.GetNestedTypes(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
Contract.Ensures(Contract.Result<IList<IType>>() != null); |
||||
return null; |
||||
} |
||||
|
||||
IList<IMethod> ITypeReference.GetMethods(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
Contract.Ensures(Contract.Result<IList<IMethod>>() != null); |
||||
return null; |
||||
} |
||||
|
||||
IList<IProperty> ITypeReference.GetProperties(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
Contract.Ensures(Contract.Result<IList<IProperty>>() != null); |
||||
return null; |
||||
} |
||||
|
||||
IList<IField> ITypeReference.GetFields(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
Contract.Ensures(Contract.Result<IList<IField>>() != null); |
||||
return null; |
||||
} |
||||
|
||||
IList<IEvent> ITypeReference.GetEvents(ITypeResolveContext context) |
||||
{ |
||||
Contract.Requires(context != null); |
||||
Contract.Ensures(Contract.Result<IList<IEvent>>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Context representing the set of assemblies in which a type is being searched.
|
||||
/// </summary>
|
||||
[ContractClass(typeof(ITypeResolveContextContract))] |
||||
public interface ITypeResolveContext |
||||
{ |
||||
ITypeDefinition GetClass(string fullTypeName, int typeParameterCount, StringComparer nameComparer); |
||||
} |
||||
|
||||
[ContractClassFor(typeof(ITypeResolveContext))] |
||||
abstract class ITypeResolveContextContract : ITypeResolveContext |
||||
{ |
||||
ITypeDefinition ITypeResolveContext.GetClass(string fullTypeName, int typeParameterCount, StringComparer nameComparer) |
||||
{ |
||||
Contract.Requires(fullTypeName != null); |
||||
Contract.Requires(typeParameterCount >= 0); |
||||
Contract.Requires(nameComparer != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a variable (name/return type pair).
|
||||
/// </summary>
|
||||
[ContractClass(typeof(IVariableContract))] |
||||
public interface IVariable |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the name of the variable.
|
||||
/// </summary>
|
||||
string Name { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the variable.
|
||||
/// </summary>
|
||||
ITypeReference Type { get; } |
||||
} |
||||
|
||||
[ContractClassFor(typeof(IVariable))] |
||||
abstract class IVariableContract : IVariable |
||||
{ |
||||
string IVariable.Name { |
||||
get { |
||||
Contract.Ensures(Contract.Result<string>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
ITypeReference IVariable.Type { |
||||
get { |
||||
Contract.Ensures(Contract.Result<ITypeReference>() != null); |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for immutable objects. Provides implementation for IFreezable that reports the
|
||||
/// object as always-frozen.
|
||||
/// </summary>
|
||||
public abstract class Immutable : IFreezable |
||||
{ |
||||
bool IFreezable.IsFrozen { |
||||
get { return true; } |
||||
} |
||||
|
||||
void IFreezable.Freeze() |
||||
{ |
||||
} |
||||
} |
||||
|
||||
public abstract class AbstractFreezable : IFreezable |
||||
{ |
||||
bool isFrozen; |
||||
|
||||
/// <summary>
|
||||
/// Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
|
||||
/// </summary>
|
||||
public bool IsFrozen { |
||||
get { return isFrozen; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Freezes this instance.
|
||||
/// </summary>
|
||||
public void Freeze() |
||||
{ |
||||
if (!isFrozen) { |
||||
FreezeInternal(); |
||||
isFrozen = true; |
||||
} |
||||
} |
||||
|
||||
protected virtual void FreezeInternal() |
||||
{ |
||||
} |
||||
|
||||
protected void CheckBeforeMutation() |
||||
{ |
||||
if (isFrozen) |
||||
throw new InvalidOperationException("Cannot mutate frozen " + GetType().Name); |
||||
} |
||||
|
||||
protected static IList<T> FreezeList<T>(IList<T> list) where T : IFreezable |
||||
{ |
||||
if (list == null || list.Count == 0) |
||||
return EmptyList<T>.Instance; |
||||
list = new ReadOnlyCollection<T>(list.ToArray()); |
||||
foreach (T item in list) { |
||||
item.Freeze(); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
protected static IList<string> FreezeList(IList<string> list) |
||||
{ |
||||
if (list == null || list.Count == 0) |
||||
return EmptyList<string>.Instance; |
||||
else |
||||
return new ReadOnlyCollection<string>(list.ToArray()); |
||||
} |
||||
} |
||||
|
||||
static class EmptyList<T> |
||||
{ |
||||
public static readonly ReadOnlyCollection<T> Instance = new ReadOnlyCollection<T>(new T[0]); |
||||
} |
||||
} |
||||
@ -0,0 +1,114 @@
@@ -0,0 +1,114 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Default implementation for IType interface.
|
||||
/// </summary>
|
||||
public abstract class AbstractType : AbstractFreezable, IType |
||||
{ |
||||
public virtual string FullName { |
||||
get { |
||||
string ns = this.Namespace; |
||||
string name = this.Name; |
||||
if (string.IsNullOrEmpty(ns)) { |
||||
return name; |
||||
} else { |
||||
string combinedName = ns + "." + name; |
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName)); |
||||
return combinedName; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public abstract string Name { get; } |
||||
|
||||
public virtual string Namespace { |
||||
get { return string.Empty; } |
||||
} |
||||
|
||||
public virtual string DotNetName { |
||||
get { return this.FullName; } |
||||
} |
||||
|
||||
public abstract bool? IsReferenceType { get; } |
||||
|
||||
public virtual bool IsArrayType { |
||||
get { return false; } |
||||
} |
||||
|
||||
public virtual bool IsPointerType { |
||||
get { return false; } |
||||
} |
||||
|
||||
public virtual int TypeParameterCount { |
||||
get { return 0; } |
||||
} |
||||
|
||||
public virtual IType DeclaringType { |
||||
get { return null; } |
||||
} |
||||
|
||||
public virtual IType GetElementType() |
||||
{ |
||||
throw new InvalidOperationException(); |
||||
} |
||||
|
||||
public virtual ITypeDefinition GetDefinition() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public IType Resolve(ITypeResolveContext context) |
||||
{ |
||||
return this; |
||||
} |
||||
|
||||
public IType GetBaseType(ITypeResolveContext context) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public virtual IList<IType> GetNestedTypes(ITypeResolveContext context) |
||||
{ |
||||
return EmptyList<IType>.Instance; |
||||
} |
||||
|
||||
public virtual IList<IMethod> GetMethods(ITypeResolveContext context) |
||||
{ |
||||
return EmptyList<IMethod>.Instance; |
||||
} |
||||
|
||||
public virtual IList<IProperty> GetProperties(ITypeResolveContext context) |
||||
{ |
||||
return EmptyList<IProperty>.Instance; |
||||
} |
||||
|
||||
public virtual IList<IField> GetFields(ITypeResolveContext context) |
||||
{ |
||||
return EmptyList<IField>.Instance; |
||||
} |
||||
|
||||
public virtual IList<IEvent> GetEvents(ITypeResolveContext context) |
||||
{ |
||||
return EmptyList<IEvent>.Instance; |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
return Equals(obj as IType); |
||||
} |
||||
|
||||
public abstract override int GetHashCode(); |
||||
public abstract bool Equals(IType other); |
||||
} |
||||
} |
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
public abstract class AbstractTypeReference : Immutable, ITypeReference |
||||
{ |
||||
public abstract IType Resolve(ITypeResolveContext context); |
||||
|
||||
public virtual IType GetBaseType(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context).GetBaseType(context); |
||||
} |
||||
|
||||
public virtual IList<IType> GetNestedTypes(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context).GetNestedTypes(context); |
||||
} |
||||
|
||||
public virtual IList<IMethod> GetMethods(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context).GetMethods(context); |
||||
} |
||||
|
||||
public virtual IList<IProperty> GetProperties(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context).GetProperties(context); |
||||
} |
||||
|
||||
public virtual IList<IField> GetFields(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context).GetFields(context); |
||||
} |
||||
|
||||
public virtual IList<IEvent> GetEvents(ITypeResolveContext context) |
||||
{ |
||||
return Resolve(context).GetEvents(context); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Default implementation for IExplicitInterfaceImplementation.
|
||||
/// </summary>
|
||||
public sealed class DefaultExplicitInterfaceImplementation : IExplicitInterfaceImplementation |
||||
{ |
||||
public ITypeReference InterfaceType { get; private set; } |
||||
public string MemberName { get; private set; } |
||||
|
||||
public DefaultExplicitInterfaceImplementation(ITypeReference interfaceType, string memberName) |
||||
{ |
||||
if (interfaceType == null) |
||||
throw new ArgumentNullException("interfaceType"); |
||||
if (memberName == null) |
||||
throw new ArgumentNullException("memberName"); |
||||
this.InterfaceType = interfaceType; |
||||
this.MemberName = memberName; |
||||
} |
||||
|
||||
bool IFreezable.IsFrozen { |
||||
get { return true; } |
||||
} |
||||
|
||||
void IFreezable.Freeze() |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,141 @@
@@ -0,0 +1,141 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Default implementation for IParameter.
|
||||
/// </summary>
|
||||
public sealed class DefaultParameter : AbstractFreezable, IParameter, ISupportsInterning |
||||
{ |
||||
string name = string.Empty; |
||||
ITypeReference type = SharedTypes.UnknownType; |
||||
IList<IAttribute> attributes; |
||||
IConstantValue defaultValue; |
||||
DomRegion region; |
||||
byte flags; |
||||
|
||||
protected override void FreezeInternal() |
||||
{ |
||||
type.Freeze(); |
||||
attributes = FreezeList(attributes); |
||||
if (defaultValue != null) |
||||
defaultValue.Freeze(); |
||||
base.FreezeInternal(); |
||||
} |
||||
|
||||
[ContractInvariantMethod] |
||||
void ObjectInvariant() |
||||
{ |
||||
Contract.Invariant(type != null); |
||||
Contract.Invariant(name != null); |
||||
} |
||||
|
||||
public string Name { |
||||
get { return name; } |
||||
set { |
||||
if (value == null) |
||||
throw new ArgumentNullException(); |
||||
Contract.EndContractBlock(); |
||||
CheckBeforeMutation(); |
||||
name = value; |
||||
} |
||||
} |
||||
|
||||
public ITypeReference Type { |
||||
get { return type; } |
||||
set { |
||||
if (value == null) |
||||
throw new ArgumentNullException(); |
||||
Contract.EndContractBlock(); |
||||
CheckBeforeMutation(); |
||||
type = value; |
||||
} |
||||
} |
||||
|
||||
public IList<IAttribute> Attributes { |
||||
get { |
||||
if (attributes == null) |
||||
attributes = new List<IAttribute>(); |
||||
return attributes; |
||||
} |
||||
} |
||||
|
||||
public IConstantValue DefaultValue { |
||||
get { return defaultValue; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
defaultValue = value; |
||||
} |
||||
} |
||||
|
||||
public DomRegion Region { |
||||
get { return region; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
region = value; |
||||
} |
||||
} |
||||
|
||||
bool HasFlag(byte flag) |
||||
{ |
||||
return (this.flags & flag) != 0; |
||||
} |
||||
void SetFlag(byte flag, bool value) |
||||
{ |
||||
CheckBeforeMutation(); |
||||
if (value) |
||||
this.flags |= flag; |
||||
else |
||||
this.flags &= unchecked((byte)~flag); |
||||
} |
||||
|
||||
public bool IsRef { |
||||
get { return HasFlag(1); } |
||||
set { SetFlag(1, value); } |
||||
} |
||||
|
||||
public bool IsOut { |
||||
get { return HasFlag(2); } |
||||
set { SetFlag(2, value); } |
||||
} |
||||
|
||||
public bool IsParams { |
||||
get { return HasFlag(4); } |
||||
set { SetFlag(4, value); } |
||||
} |
||||
|
||||
public bool IsOptional { |
||||
get { return this.DefaultValue != null; } |
||||
} |
||||
|
||||
void ISupportsInterning.PrepareForInterning(IInterningProvider provider) |
||||
{ |
||||
CheckBeforeMutation(); |
||||
name = provider.InternString(name); |
||||
type = provider.InternObject(type); |
||||
attributes = provider.InternObjectList(attributes); |
||||
defaultValue = provider.InternObject(defaultValue); |
||||
} |
||||
|
||||
int ISupportsInterning.GetHashCodeForInterning() |
||||
{ |
||||
return type.GetHashCode() ^ (attributes != null ? attributes.GetHashCode() : 0) ^ (defaultValue != null ? defaultValue.GetHashCode() : 0); |
||||
} |
||||
|
||||
bool ISupportsInterning.EqualsForInterning(ISupportsInterning other) |
||||
{ |
||||
DefaultParameter p = other as DefaultParameter; |
||||
return p != null && type == p.type && attributes == p.attributes |
||||
&& defaultValue == p.defaultValue && region == p.region && flags == p.flags; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,409 @@
@@ -0,0 +1,409 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Globalization; |
||||
using System.Linq; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
public class DefaultTypeDefinition : AbstractFreezable, ITypeDefinition |
||||
{ |
||||
readonly IProjectContent projectContent; |
||||
readonly ITypeDefinition declaringTypeDefinition; |
||||
|
||||
readonly string ns; |
||||
readonly string name; |
||||
|
||||
ClassType classType; |
||||
IList<ITypeReference> baseTypes; |
||||
IList<ITypeParameter> typeParameters; |
||||
IList<ITypeDefinition> innerClasses; |
||||
IList<IField> fields; |
||||
IList<IMethod> methods; |
||||
IList<IProperty> properties; |
||||
IList<IEvent> events; |
||||
IList<IAttribute> attributes; |
||||
|
||||
DomRegion region; |
||||
DomRegion bodyRegion; |
||||
Accessibility accessibility; |
||||
|
||||
protected override void FreezeInternal() |
||||
{ |
||||
baseTypes = FreezeList(baseTypes); |
||||
typeParameters = FreezeList(typeParameters); |
||||
innerClasses = FreezeList(innerClasses); |
||||
fields = FreezeList(fields); |
||||
methods = FreezeList(methods); |
||||
properties = FreezeList(properties); |
||||
events = FreezeList(events); |
||||
attributes = FreezeList(attributes); |
||||
base.FreezeInternal(); |
||||
} |
||||
|
||||
public DefaultTypeDefinition(ITypeDefinition declaringTypeDefinition, string name) |
||||
{ |
||||
if (declaringTypeDefinition == null) |
||||
throw new ArgumentNullException("declaringTypeDefinition"); |
||||
if (string.IsNullOrEmpty(name)) |
||||
throw new ArgumentException("name"); |
||||
Contract.EndContractBlock(); |
||||
this.projectContent = declaringTypeDefinition.ProjectContent; |
||||
this.declaringTypeDefinition = declaringTypeDefinition; |
||||
this.name = name; |
||||
this.ns = declaringTypeDefinition.Namespace; |
||||
} |
||||
|
||||
public DefaultTypeDefinition(IProjectContent projectContent, string ns, string name) |
||||
{ |
||||
if (projectContent == null) |
||||
throw new ArgumentNullException("projectContent"); |
||||
if (string.IsNullOrEmpty(name)) |
||||
throw new ArgumentException("name"); |
||||
Contract.EndContractBlock(); |
||||
this.projectContent = projectContent; |
||||
this.ns = ns ?? string.Empty; |
||||
this.name = name; |
||||
} |
||||
|
||||
[ContractInvariantMethod] |
||||
void ObjectInvariant() |
||||
{ |
||||
Contract.Invariant(projectContent != null); |
||||
Contract.Invariant(!string.IsNullOrEmpty(name)); |
||||
Contract.Invariant(ns != null); |
||||
} |
||||
|
||||
public ClassType ClassType { |
||||
get { return classType; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
classType = value; |
||||
} |
||||
} |
||||
|
||||
public IList<ITypeReference> BaseTypes { |
||||
get { |
||||
if (baseTypes == null) |
||||
baseTypes = new List<ITypeReference>(); |
||||
return baseTypes; |
||||
} |
||||
} |
||||
|
||||
public IList<ITypeParameter> TypeParameters { |
||||
get { |
||||
if (typeParameters == null) |
||||
typeParameters = new List<ITypeParameter>(); |
||||
return typeParameters; |
||||
} |
||||
} |
||||
|
||||
public IList<ITypeDefinition> InnerClasses { |
||||
get { |
||||
if (innerClasses == null) |
||||
innerClasses = new List<ITypeDefinition>(); |
||||
return innerClasses; |
||||
} |
||||
} |
||||
|
||||
public IList<IField> Fields { |
||||
get { |
||||
if (fields == null) |
||||
fields = new List<IField>(); |
||||
return fields; |
||||
} |
||||
} |
||||
|
||||
public IList<IProperty> Properties { |
||||
get { |
||||
if (properties == null) |
||||
properties = new List<IProperty>(); |
||||
return properties; |
||||
} |
||||
} |
||||
|
||||
public IList<IMethod> Methods { |
||||
get { |
||||
if (methods == null) |
||||
methods = new List<IMethod>(); |
||||
return methods; |
||||
} |
||||
} |
||||
|
||||
public IList<IEvent> Events { |
||||
get { |
||||
if (events == null) |
||||
events = new List<IEvent>(); |
||||
return events; |
||||
} |
||||
} |
||||
|
||||
public IEnumerable<IMember> Members { |
||||
get { |
||||
return this.Fields.Concat<IMember>(this.Properties).Concat(this.Methods).Concat(this.Events); |
||||
} |
||||
} |
||||
|
||||
public bool? IsReferenceType { |
||||
get { |
||||
return this.ClassType == ClassType.Enum || this.ClassType == ClassType.Struct; |
||||
} |
||||
} |
||||
|
||||
bool IType.IsArrayType { |
||||
get { return false; } |
||||
} |
||||
|
||||
bool IType.IsPointerType { |
||||
get { return false; } |
||||
} |
||||
|
||||
public string FullName { |
||||
get { |
||||
if (declaringTypeDefinition != null) { |
||||
string combinedName = declaringTypeDefinition.FullName + "." + this.name; |
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName)); |
||||
return combinedName; |
||||
} else if (string.IsNullOrEmpty(ns)) { |
||||
return this.name; |
||||
} else { |
||||
string combinedName = this.ns + "." + this.name; |
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName)); |
||||
return combinedName; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public string Name { |
||||
get { return this.name; } |
||||
} |
||||
|
||||
public string Namespace { |
||||
get { return this.ns; } |
||||
} |
||||
|
||||
public string DotNetName { |
||||
get { |
||||
if (declaringTypeDefinition != null) { |
||||
int tpCount = this.TypeParameterCount - declaringTypeDefinition.TypeParameterCount; |
||||
string combinedName; |
||||
if (tpCount > 0) |
||||
combinedName = declaringTypeDefinition.DotNetName + "+" + this.Name + "`" + tpCount.ToString(CultureInfo.InvariantCulture); |
||||
else |
||||
combinedName = declaringTypeDefinition.DotNetName + "+" + this.Name; |
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName)); // help out the static checker
|
||||
return combinedName; |
||||
} else { |
||||
if (string.IsNullOrEmpty(ns)) { |
||||
return this.Name; |
||||
} else { |
||||
string combinedName = this.Namespace + "." + this.Name; |
||||
Contract.Assume(!string.IsNullOrEmpty(combinedName)); // help out the static checker
|
||||
return combinedName; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int TypeParameterCount { |
||||
get { return typeParameters != null ? typeParameters.Count : 0; } |
||||
} |
||||
|
||||
public EntityType EntityType { |
||||
get { return EntityType.Class; } |
||||
} |
||||
|
||||
public DomRegion Region { |
||||
get { return region; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
region = value; |
||||
} |
||||
} |
||||
|
||||
public DomRegion BodyRegion { |
||||
get { return bodyRegion; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
bodyRegion = value; |
||||
} |
||||
} |
||||
|
||||
public ITypeDefinition DeclaringTypeDefinition { |
||||
get { return declaringTypeDefinition; } |
||||
} |
||||
|
||||
public IType DeclaringType { |
||||
get { return declaringTypeDefinition; } |
||||
} |
||||
|
||||
public IList<IAttribute> Attributes { |
||||
get { |
||||
if (attributes == null) |
||||
attributes = new List<IAttribute>(); |
||||
return attributes; |
||||
} |
||||
} |
||||
|
||||
public virtual string Documentation { |
||||
get { return null; } |
||||
} |
||||
|
||||
public bool IsStatic { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public Accessibility Accessibility { |
||||
get { return accessibility; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
accessibility = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsAbstract { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsSealed { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsVirtual { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsOverride { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsOverridable { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsShadowing { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool IsSynthetic { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IProjectContent ProjectContent { |
||||
get { return projectContent; } |
||||
} |
||||
|
||||
public IType GetBaseType(ITypeResolveContext context) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ITypeDefinition GetCompoundClass() |
||||
{ |
||||
if (declaringTypeDefinition != null) { |
||||
return declaringTypeDefinition.GetCompoundClass().InnerClasses.FirstOrDefault(c => projectContent.Language.NameComparer.Equals(c.Name, this.Name)) ?? this; |
||||
} else { |
||||
return projectContent.GetClass(this.FullName, this.TypeParameterCount, projectContent.Language.NameComparer) ?? this; |
||||
} |
||||
} |
||||
|
||||
public virtual IList<ITypeDefinition> GetParts() |
||||
{ |
||||
return new ITypeDefinition[] { this }; |
||||
} |
||||
|
||||
public IType GetElementType() |
||||
{ |
||||
throw new InvalidOperationException(); |
||||
} |
||||
|
||||
public ITypeDefinition GetDefinition() |
||||
{ |
||||
return this; |
||||
} |
||||
|
||||
public IType Resolve(ITypeResolveContext context) |
||||
{ |
||||
return this; |
||||
} |
||||
|
||||
public IList<IType> GetNestedTypes(ITypeResolveContext context) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IList<IMethod> GetMethods(ITypeResolveContext context) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IList<IProperty> GetProperties(ITypeResolveContext context) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IList<IField> GetFields(ITypeResolveContext context) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IList<IEvent> GetEvents(ITypeResolveContext context) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
return Equals(obj as ITypeDefinition); |
||||
} |
||||
|
||||
public bool Equals(IType other) |
||||
{ |
||||
return Equals(other as ITypeDefinition); |
||||
} |
||||
|
||||
public bool Equals(ITypeDefinition other) |
||||
{ |
||||
if (other == null) |
||||
return false; |
||||
if (declaringTypeDefinition != null) { |
||||
return declaringTypeDefinition.Equals(other.DeclaringTypeDefinition) && this.Name == other.Name && this.TypeParameterCount == other.TypeParameterCount; |
||||
} else { |
||||
return other.DeclaringTypeDefinition == null && this.ProjectContent == other.ProjectContent |
||||
&& this.Namespace == other.Namespace && this.Name == other.Name && this.TypeParameterCount == other.TypeParameterCount; |
||||
} |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
if (declaringTypeDefinition != null) { |
||||
return declaringTypeDefinition.GetHashCode() ^ name.GetHashCode(); |
||||
} else { |
||||
return ns.GetHashCode() ^ name.GetHashCode() ^ projectContent.GetHashCode(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Type of the 'null' literal.
|
||||
/// </summary>
|
||||
sealed class NullType : AbstractType |
||||
{ |
||||
public override string Name { |
||||
get { return "null"; } |
||||
} |
||||
|
||||
public override bool? IsReferenceType { |
||||
get { return true; } |
||||
} |
||||
|
||||
public override bool Equals(IType other) |
||||
{ |
||||
return other is NullType; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return 362709548; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Type representing resolve errors.
|
||||
/// </summary>
|
||||
sealed class UnknownType : AbstractType |
||||
{ |
||||
public override string Name { |
||||
get { return "?"; } |
||||
} |
||||
|
||||
public override bool? IsReferenceType { |
||||
get { return null; } |
||||
} |
||||
|
||||
public override bool Equals(IType other) |
||||
{ |
||||
return other is UnknownType; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return 950772036; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics.Contracts; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Describes the properties of a language.
|
||||
/// </summary>
|
||||
public class LanguageProperties |
||||
{ |
||||
// TODO: is this class actually useful? consider removing it
|
||||
|
||||
public virtual StringComparer NameComparer { |
||||
get { |
||||
Contract.Ensures(Contract.Result<StringComparer>() != null); |
||||
Contract.Assume(StringComparer.Ordinal != null); |
||||
return StringComparer.Ordinal; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Contains static implementations of well-known types.
|
||||
/// </summary>
|
||||
public static class SharedTypes |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the type representing resolve errors.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "It's immutable")] |
||||
public readonly static IType UnknownType = new UnknownType(); |
||||
|
||||
/// <summary>
|
||||
/// The null type is used as type of the null literal. It is a reference type without any members that is a subtype of all reference types.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "It's immutable")] |
||||
public readonly static IType Null = new NullType(); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue