diff --git a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs
index b869388229..ae6361230a 100644
--- a/ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs
+++ b/ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs
@@ -147,7 +147,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
get { return false; }
}
- EntityType IEntity.EntityType {
+ EntityType ISymbol.EntityType {
get { return EntityType.Operator; }
}
@@ -243,7 +243,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
get { return "operator"; }
}
- string INamedElement.Name {
+ public string Name {
get { return "operator"; }
}
diff --git a/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs b/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
index 97b568b23d..12458abeed 100644
--- a/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
+++ b/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
@@ -3145,6 +3145,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
this.name = name;
}
+ public EntityType EntityType {
+ get { return EntityType.Variable; }
+ }
+
public string Name {
get { return name; }
}
diff --git a/ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs b/ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs
index 3dada0d603..7dfa6c3b00 100644
--- a/ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs
+++ b/ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs
@@ -268,10 +268,14 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
get { return fullName; }
}
- string INamespace.Name {
+ public string Name {
get { return name; }
}
+ EntityType ISymbol.EntityType {
+ get { return EntityType.Namespace; }
+ }
+
INamespace INamespace.ParentNamespace {
get { return parentNamespace; }
}
diff --git a/ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs b/ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs
index 026260ad74..7197689660 100644
--- a/ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs
+++ b/ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs
@@ -162,10 +162,14 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
get { return NamespaceDeclaration.BuildQualifiedName(parentNamespace.FullName, name); }
}
- string INamespace.Name {
+ public string Name {
get { return name; }
}
+ EntityType ISymbol.EntityType {
+ get { return EntityType.Namespace; }
+ }
+
INamespace INamespace.ParentNamespace {
get { return parentNamespace; }
}
diff --git a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
index 6b1ee2d1b8..aab5480a98 100644
--- a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
+++ b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
@@ -143,6 +143,7 @@
+
diff --git a/ICSharpCode.NRefactory/TypeSystem/EntityType.cs b/ICSharpCode.NRefactory/TypeSystem/EntityType.cs
index 513da15bca..e47b349fcd 100644
--- a/ICSharpCode.NRefactory/TypeSystem/EntityType.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/EntityType.cs
@@ -23,15 +23,51 @@ namespace ICSharpCode.NRefactory.TypeSystem
public enum EntityType : byte
{
None,
+ ///
TypeDefinition,
+ ///
Field,
+ ///
+ /// The symbol is a property, but not an indexer.
+ ///
+ ///
Property,
+ ///
+ /// The symbol is an indexer, not a regular property.
+ ///
+ ///
Indexer,
+ ///
Event,
+ ///
+ /// The symbol is a method which is not an operator/constructor/destructor or accessor.
+ ///
+ ///
Method,
+ ///
+ /// The symbol is a user-defined operator.
+ ///
+ ///
Operator,
+ ///
Constructor,
+ ///
Destructor,
- Accessor
+ ///
+ /// The accessor method for a property getter/setter or event add/remove.
+ ///
+ ///
+ Accessor,
+ ///
+ Namespace,
+ ///
+ /// The symbol is a variable, but not a parameter.
+ ///
+ ///
+ Variable,
+ ///
+ Parameter,
+ ///
+ TypeParameter,
}
}
diff --git a/ICSharpCode.NRefactory/TypeSystem/IEntity.cs b/ICSharpCode.NRefactory/TypeSystem/IEntity.cs
index 6877254a5c..147c658780 100644
--- a/ICSharpCode.NRefactory/TypeSystem/IEntity.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/IEntity.cs
@@ -93,12 +93,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
///
/// Represents a resolved entity.
///
- public interface IEntity : ICompilationProvider, INamedElement, IHasAccessibility
+ public interface IEntity : ISymbol, ICompilationProvider, INamedElement, IHasAccessibility
{
///
- /// Gets the entity type.
+ /// Gets the short name of the entity.
///
- EntityType EntityType { get; }
+ new string Name { get; }
///
/// Gets the complete entity region (including header+body)
diff --git a/ICSharpCode.NRefactory/TypeSystem/INamespace.cs b/ICSharpCode.NRefactory/TypeSystem/INamespace.cs
index c272749da6..213f2f87b4 100644
--- a/ICSharpCode.NRefactory/TypeSystem/INamespace.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/INamespace.cs
@@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
///
/// Represents a resolved namespace.
///
- public interface INamespace : ICompilationProvider
+ public interface INamespace : ISymbol, ICompilationProvider
{
// No pointer back to unresolved namespace:
// multiple unresolved namespaces (from different assemblies) get
@@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
///
/// Gets the short name of this namespace (e.g. "Collections").
///
- string Name { get; }
+ new string Name { get; }
///
/// Gets the parent namespace.
diff --git a/ICSharpCode.NRefactory/TypeSystem/ISymbol.cs b/ICSharpCode.NRefactory/TypeSystem/ISymbol.cs
new file mode 100644
index 0000000000..44bd70d172
--- /dev/null
+++ b/ICSharpCode.NRefactory/TypeSystem/ISymbol.cs
@@ -0,0 +1,39 @@
+// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this
+// software and associated documentation files (the "Software"), to deal in the Software
+// without restriction, including without limitation the rights to use, copy, modify, merge,
+// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+// to whom the Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or
+// substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+using System;
+
+namespace ICSharpCode.NRefactory.TypeSystem
+{
+ ///
+ /// Interface for type system symbols.
+ ///
+ public interface ISymbol
+ {
+ ///
+ /// This property returns an enum specifying which kind of symbol this is
+ /// (which derived interfaces of ISymbol are implemented)
+ ///
+ EntityType EntityType { get; }
+
+ ///
+ /// Gets the short name of the symbol.
+ ///
+ string Name { get; }
+ }
+}
diff --git a/ICSharpCode.NRefactory/TypeSystem/ITypeParameter.cs b/ICSharpCode.NRefactory/TypeSystem/ITypeParameter.cs
index 350ae19e09..53150cb332 100644
--- a/ICSharpCode.NRefactory/TypeSystem/ITypeParameter.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/ITypeParameter.cs
@@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
///
/// Type parameter of a generic class/method.
///
- public interface ITypeParameter : IType
+ public interface ITypeParameter : IType, ISymbol
{
///
/// Get the type of this type parameter's owner.
@@ -84,6 +84,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
///
int Index { get; }
+ ///
+ /// Gets the name of the type parameter.
+ ///
+ new string Name { get; }
+
///
/// Gets the list of attributes declared on this type parameter.
///
diff --git a/ICSharpCode.NRefactory/TypeSystem/IVariable.cs b/ICSharpCode.NRefactory/TypeSystem/IVariable.cs
index 33838d6e89..253fe99a57 100644
--- a/ICSharpCode.NRefactory/TypeSystem/IVariable.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/IVariable.cs
@@ -23,12 +23,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
///
/// Represents a variable (name/type pair).
///
- public interface IVariable
+ public interface IVariable : ISymbol
{
///
/// Gets the name of the variable.
///
- string Name { get; }
+ new string Name { get; }
///
/// Gets the declaration region of the variable.
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
index 29c957f879..7f42522f78 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
@@ -62,6 +62,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.variance = variance;
}
+ EntityType ISymbol.EntityType {
+ get { return EntityType.TypeParameter; }
+ }
+
public EntityType OwnerType {
get { return ownerType; }
}
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs
index 2abe29b165..29af6c5c45 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs
@@ -62,6 +62,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.defaultValue = defaultValue;
}
+ EntityType ISymbol.EntityType {
+ get { return EntityType.Parameter; }
+ }
+
public IList Attributes {
get { return attributes; }
}
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
index 1aa07cb17b..7264312ec3 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
@@ -403,7 +403,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return ns.FullName; }
}
- string INamespace.Name {
+ EntityType ISymbol.EntityType {
+ get { return EntityType.Namespace; }
+ }
+
+ public string Name {
get { return ns.Name; }
}
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs
index 7706e8c247..6e09244648 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs
@@ -228,6 +228,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.context = context;
}
+ EntityType ISymbol.EntityType { get { return EntityType.Parameter; } }
public IType Type { get; internal set; }
public string Name { get; internal set; }
public DomRegion Region { get; internal set; }
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DummyTypeParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DummyTypeParameter.cs
index ecd6cb30a5..aa07c2995b 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DummyTypeParameter.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DummyTypeParameter.cs
@@ -126,6 +126,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.index = index;
}
+ EntityType ISymbol.EntityType {
+ get { return EntityType.TypeParameter; }
+ }
+
public override string Name {
get {
return (ownerType == EntityType.Method ? "!!" : "!") + index;
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
index cbdb7f2b98..5524d64e09 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
@@ -91,6 +91,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
}
}
+ public EntityType EntityType {
+ get { return EntityType.Namespace; }
+ }
+
public ICompilation Compilation {
get { return compilation; }
}
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMember.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMember.cs
index 243b846401..b243ea47ed 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMember.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMember.cs
@@ -405,6 +405,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.newType = newType;
}
+ EntityType ISymbol.EntityType { get { return EntityType.Parameter; } }
+
public IList Attributes {
get { return originalParameter.Attributes; }
}