Browse Source

Introduce ISymbol as a common super-interface of IEntity, INamespace, IVariable and ITypeParameter.

pull/45/merge
Daniel Grunwald 12 years ago
parent
commit
5e9edc0f63
  1. 4
      ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs
  2. 4
      ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
  3. 6
      ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs
  4. 6
      ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs
  5. 1
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  6. 38
      ICSharpCode.NRefactory/TypeSystem/EntityType.cs
  7. 6
      ICSharpCode.NRefactory/TypeSystem/IEntity.cs
  8. 4
      ICSharpCode.NRefactory/TypeSystem/INamespace.cs
  9. 39
      ICSharpCode.NRefactory/TypeSystem/ISymbol.cs
  10. 7
      ICSharpCode.NRefactory/TypeSystem/ITypeParameter.cs
  11. 4
      ICSharpCode.NRefactory/TypeSystem/IVariable.cs
  12. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
  13. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs
  14. 6
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
  15. 1
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs
  16. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/DummyTypeParameter.cs
  17. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
  18. 2
      ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMember.cs

4
ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs

@ -147,7 +147,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
get { return false; } get { return false; }
} }
EntityType IEntity.EntityType { EntityType ISymbol.EntityType {
get { return EntityType.Operator; } get { return EntityType.Operator; }
} }
@ -243,7 +243,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
get { return "operator"; } get { return "operator"; }
} }
string INamedElement.Name { public string Name {
get { return "operator"; } get { return "operator"; }
} }

4
ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs

@ -3145,6 +3145,10 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
this.name = name; this.name = name;
} }
public EntityType EntityType {
get { return EntityType.Variable; }
}
public string Name { public string Name {
get { return name; } get { return name; }
} }

6
ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpAssembly.cs

@ -268,10 +268,14 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
get { return fullName; } get { return fullName; }
} }
string INamespace.Name { public string Name {
get { return name; } get { return name; }
} }
EntityType ISymbol.EntityType {
get { return EntityType.Namespace; }
}
INamespace INamespace.ParentNamespace { INamespace INamespace.ParentNamespace {
get { return parentNamespace; } get { return parentNamespace; }
} }

6
ICSharpCode.NRefactory.CSharp/TypeSystem/ResolvedUsingScope.cs

@ -162,10 +162,14 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem
get { return NamespaceDeclaration.BuildQualifiedName(parentNamespace.FullName, name); } get { return NamespaceDeclaration.BuildQualifiedName(parentNamespace.FullName, name); }
} }
string INamespace.Name { public string Name {
get { return name; } get { return name; }
} }
EntityType ISymbol.EntityType {
get { return EntityType.Namespace; }
}
INamespace INamespace.ParentNamespace { INamespace INamespace.ParentNamespace {
get { return parentNamespace; } get { return parentNamespace; }
} }

1
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -143,6 +143,7 @@
<Compile Include="TypeSystem\DefaultSolutionSnapshot.cs" /> <Compile Include="TypeSystem\DefaultSolutionSnapshot.cs" />
<Compile Include="TypeSystem\DomRegion.cs" /> <Compile Include="TypeSystem\DomRegion.cs" />
<Compile Include="TypeSystem\EntityType.cs" /> <Compile Include="TypeSystem\EntityType.cs" />
<Compile Include="TypeSystem\ISymbol.cs" />
<Compile Include="TypeSystem\TypeParameterSubstitution.cs" /> <Compile Include="TypeSystem\TypeParameterSubstitution.cs" />
<Compile Include="TypeSystem\TypeSystemExtensions.cs" /> <Compile Include="TypeSystem\TypeSystemExtensions.cs" />
<Compile Include="TypeSystem\FullTypeName.cs" /> <Compile Include="TypeSystem\FullTypeName.cs" />

38
ICSharpCode.NRefactory/TypeSystem/EntityType.cs

@ -23,15 +23,51 @@ namespace ICSharpCode.NRefactory.TypeSystem
public enum EntityType : byte public enum EntityType : byte
{ {
None, None,
/// <seealso cref="ITypeDefinition"/>
TypeDefinition, TypeDefinition,
/// <seealso cref="IField"/>
Field, Field,
/// <summary>
/// The symbol is a property, but not an indexer.
/// </summary>
/// <seealso cref="IProperty"/>
Property, Property,
/// <summary>
/// The symbol is an indexer, not a regular property.
/// </summary>
/// <seealso cref="IProperty"/>
Indexer, Indexer,
/// <seealso cref="IEvent"/>
Event, Event,
/// <summary>
/// The symbol is a method which is not an operator/constructor/destructor or accessor.
/// </summary>
/// <seealso cref="IMethod"/>
Method, Method,
/// <summary>
/// The symbol is a user-defined operator.
/// </summary>
/// <seealso cref="IMethod"/>
Operator, Operator,
/// <seealso cref="IMethod"/>
Constructor, Constructor,
/// <seealso cref="IMethod"/>
Destructor, Destructor,
Accessor /// <summary>
/// The accessor method for a property getter/setter or event add/remove.
/// </summary>
/// <seealso cref="IMethod"/>
Accessor,
/// <seealso cref="INamespace"/>
Namespace,
/// <summary>
/// The symbol is a variable, but not a parameter.
/// </summary>
/// <seealso cref="IVariable"/>
Variable,
/// <seealso cref="IParameter"/>
Parameter,
/// <seealso cref="ITypeParameter"/>
TypeParameter,
} }
} }

6
ICSharpCode.NRefactory/TypeSystem/IEntity.cs

@ -93,12 +93,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Represents a resolved entity. /// Represents a resolved entity.
/// </summary> /// </summary>
public interface IEntity : ICompilationProvider, INamedElement, IHasAccessibility public interface IEntity : ISymbol, ICompilationProvider, INamedElement, IHasAccessibility
{ {
/// <summary> /// <summary>
/// Gets the entity type. /// Gets the short name of the entity.
/// </summary> /// </summary>
EntityType EntityType { get; } new string Name { get; }
/// <summary> /// <summary>
/// Gets the complete entity region (including header+body) /// Gets the complete entity region (including header+body)

4
ICSharpCode.NRefactory/TypeSystem/INamespace.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Represents a resolved namespace. /// Represents a resolved namespace.
/// </summary> /// </summary>
public interface INamespace : ICompilationProvider public interface INamespace : ISymbol, ICompilationProvider
{ {
// No pointer back to unresolved namespace: // No pointer back to unresolved namespace:
// multiple unresolved namespaces (from different assemblies) get // multiple unresolved namespaces (from different assemblies) get
@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Gets the short name of this namespace (e.g. "Collections"). /// Gets the short name of this namespace (e.g. "Collections").
/// </summary> /// </summary>
string Name { get; } new string Name { get; }
/// <summary> /// <summary>
/// Gets the parent namespace. /// Gets the parent namespace.

39
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
{
/// <summary>
/// Interface for type system symbols.
/// </summary>
public interface ISymbol
{
/// <summary>
/// This property returns an enum specifying which kind of symbol this is
/// (which derived interfaces of ISymbol are implemented)
/// </summary>
EntityType EntityType { get; }
/// <summary>
/// Gets the short name of the symbol.
/// </summary>
string Name { get; }
}
}

7
ICSharpCode.NRefactory/TypeSystem/ITypeParameter.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Type parameter of a generic class/method. /// Type parameter of a generic class/method.
/// </summary> /// </summary>
public interface ITypeParameter : IType public interface ITypeParameter : IType, ISymbol
{ {
/// <summary> /// <summary>
/// Get the type of this type parameter's owner. /// Get the type of this type parameter's owner.
@ -84,6 +84,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary> /// </summary>
int Index { get; } int Index { get; }
/// <summary>
/// Gets the name of the type parameter.
/// </summary>
new string Name { get; }
/// <summary> /// <summary>
/// Gets the list of attributes declared on this type parameter. /// Gets the list of attributes declared on this type parameter.
/// </summary> /// </summary>

4
ICSharpCode.NRefactory/TypeSystem/IVariable.cs

@ -23,12 +23,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Represents a variable (name/type pair). /// Represents a variable (name/type pair).
/// </summary> /// </summary>
public interface IVariable public interface IVariable : ISymbol
{ {
/// <summary> /// <summary>
/// Gets the name of the variable. /// Gets the name of the variable.
/// </summary> /// </summary>
string Name { get; } new string Name { get; }
/// <summary> /// <summary>
/// Gets the declaration region of the variable. /// Gets the declaration region of the variable.

4
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs

@ -62,6 +62,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.variance = variance; this.variance = variance;
} }
EntityType ISymbol.EntityType {
get { return EntityType.TypeParameter; }
}
public EntityType OwnerType { public EntityType OwnerType {
get { return ownerType; } get { return ownerType; }
} }

4
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs

@ -62,6 +62,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
} }
EntityType ISymbol.EntityType {
get { return EntityType.Parameter; }
}
public IList<IAttribute> Attributes { public IList<IAttribute> Attributes {
get { return attributes; } get { return attributes; }
} }

6
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs

@ -403,7 +403,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return ns.FullName; } get { return ns.FullName; }
} }
string INamespace.Name { EntityType ISymbol.EntityType {
get { return EntityType.Namespace; }
}
public string Name {
get { return ns.Name; } get { return ns.Name; }
} }

1
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs

@ -228,6 +228,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.context = context; this.context = context;
} }
EntityType ISymbol.EntityType { get { return EntityType.Parameter; } }
public IType Type { get; internal set; } public IType Type { get; internal set; }
public string Name { get; internal set; } public string Name { get; internal set; }
public DomRegion Region { get; internal set; } public DomRegion Region { get; internal set; }

4
ICSharpCode.NRefactory/TypeSystem/Implementation/DummyTypeParameter.cs

@ -126,6 +126,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.index = index; this.index = index;
} }
EntityType ISymbol.EntityType {
get { return EntityType.TypeParameter; }
}
public override string Name { public override string Name {
get { get {
return (ownerType == EntityType.Method ? "!!" : "!") + index; return (ownerType == EntityType.Method ? "!!" : "!") + index;

4
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 { public ICompilation Compilation {
get { return compilation; } get { return compilation; }
} }

2
ICSharpCode.NRefactory/TypeSystem/Implementation/SpecializedMember.cs

@ -405,6 +405,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.newType = newType; this.newType = newType;
} }
EntityType ISymbol.EntityType { get { return EntityType.Parameter; } }
public IList<IAttribute> Attributes { public IList<IAttribute> Attributes {
get { return originalParameter.Attributes; } get { return originalParameter.Attributes; }
} }

Loading…
Cancel
Save