Browse Source

Merge changes from SharpDevelop into the main NRefactory repository.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
023e13b21d
  1. 1
      ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs
  2. 10
      ICSharpCode.NRefactory/CSharp/Ast/AstLocation.cs
  3. 4
      ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs
  4. 10
      ICSharpCode.NRefactory/CSharp/Refactoring/RefactoringContext.cs
  5. 459
      ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs
  6. 6
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  7. 4
      ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
  8. 2
      ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs
  9. 2
      ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs
  10. 5
      ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs
  11. 11
      ICSharpCode.NRefactory/TypeSystem/Implementation/MinimalResolveContext.cs
  12. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs

1
ICSharpCode.NRefactory/CSharp/Analysis/DefiniteAssignmentAnalysis.cs

@ -23,6 +23,7 @@ using System.Linq; @@ -23,6 +23,7 @@ using System.Linq;
using System.Threading;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.NRefactory.CSharp.Analysis

10
ICSharpCode.NRefactory/CSharp/Ast/AstLocation.cs

@ -133,5 +133,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -133,5 +133,15 @@ namespace ICSharpCode.NRefactory.CSharp
{
return !(left < right);
}
public static implicit operator AstLocation(ICSharpCode.Editor.TextLocation location)
{
return new AstLocation(location.Line, location.Column);
}
public static implicit operator ICSharpCode.Editor.TextLocation(AstLocation location)
{
return new ICSharpCode.Editor.TextLocation(location.Line, location.Column);
}
}
}

4
ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs

@ -115,7 +115,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -115,7 +115,7 @@ namespace ICSharpCode.NRefactory.CSharp
return FindEntity(topLevelTypeDefinitions, location);
}
public ITypeDefinition GetTypeDefinition(AstLocation location)
public ITypeDefinition GetInnerMostTypeDefinition(AstLocation location)
{
ITypeDefinition parent = null;
ITypeDefinition type = GetTopLevelTypeDefinition(location);
@ -128,7 +128,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -128,7 +128,7 @@ namespace ICSharpCode.NRefactory.CSharp
public IMember GetMember(AstLocation location)
{
ITypeDefinition type = GetTypeDefinition(location);
ITypeDefinition type = GetInnerMostTypeDefinition(location);
if (type == null)
return null;
return FindEntity(type.Methods, location)

10
ICSharpCode.NRefactory/CSharp/Refactoring/RefactoringContext.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// RefactoringContext.cs
//
// Author:
@ -25,9 +25,9 @@ @@ -25,9 +25,9 @@
// THE SOFTWARE.
using System;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem;
using System.Collections.Generic;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.CSharp.Refactoring
{
@ -127,12 +127,12 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -127,12 +127,12 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
}
}
public static class ExtensionMethods
public static class RefactoringExtensions
{
#region ConvertTypes
public static ICSharpCode.NRefactory.CSharp.AstType ConvertToAstType (this IType type)
{
var builder = new TypeSystemAstBuilder ();
var builder = new TypeSystemAstBuilder (MinimalResolveContext.Instance);
return builder.ConvertType (type);
}
#endregion

459
ICSharpCode.NRefactory/CSharp/Refactoring/TypeSystemAstBuilder.cs

@ -8,6 +8,7 @@ using System.Linq; @@ -8,6 +8,7 @@ using System.Linq;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.NRefactory.CSharp.Refactoring
{
@ -17,6 +18,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -17,6 +18,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
public class TypeSystemAstBuilder
{
readonly CSharpResolver resolver;
readonly ITypeResolveContext context;
/// <summary>
/// Creates a new TypeSystemAstBuilder.
@ -24,11 +26,73 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -24,11 +26,73 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
/// <param name="resolver">
/// A resolver initialized for the position where the type will be inserted.
/// </param>
public TypeSystemAstBuilder(CSharpResolver resolver = null)
public TypeSystemAstBuilder(CSharpResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
this.resolver = resolver;
this.context = resolver.Context;
InitProperties();
}
public TypeSystemAstBuilder(ITypeResolveContext context)
{
if (context == null)
throw new ArgumentNullException("context");
this.context = context;
InitProperties();
}
#region Properties
void InitProperties()
{
this.ShowAccessibility = true;
this.ShowModifiers = true;
this.ShowBaseTypes = true;
this.ShowTypeParameters = true;
this.ShowTypeParameterConstraints = true;
this.ShowParameterNames = true;
this.ShowConstantValues = true;
}
/// <summary>
/// Controls the accessibility modifiers are shown.
/// </summary>
public bool ShowAccessibility { get; set; }
/// <summary>
/// Controls the non-accessibility modifiers are shown.
/// </summary>
public bool ShowModifiers { get; set; }
/// <summary>
/// Controls whether base type references are shown.
/// </summary>
public bool ShowBaseTypes { get; set; }
/// <summary>
/// Controls whether type parameter declarations are shown.
/// </summary>
public bool ShowTypeParameters { get; set; }
/// <summary>
/// Controls whether contraints on type parameter declarations are shown.
/// Has no effect if ShowTypeParameters is false.
/// </summary>
public bool ShowTypeParameterConstraints { get; set; }
/// <summary>
/// Controls whether the names of parameters are shown.
/// </summary>
public bool ShowParameterNames { get; set; }
/// <summary>
/// Controls whether to show default values of optional parameters, and the values of constant fields.
/// </summary>
public bool ShowConstantValues { get; set; }
#endregion
#region Convert Type
public AstType ConvertType(IType type)
{
if (type == null)
@ -49,7 +113,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -49,7 +113,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
if (pt.Name == "Nullable" && pt.Namespace == "System" && pt.TypeParameterCount == 1) {
return ConvertType(pt.TypeArguments[0]).MakeNullableType();
}
return ConvertTypeDefinition(pt.GetDefinition(), pt.TypeArguments);
return ConvertTypeHelper(pt.GetDefinition(), pt.TypeArguments);
}
ITypeDefinition typeDef = type as ITypeDefinition;
if (typeDef != null) {
@ -59,15 +123,15 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -59,15 +123,15 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
for (int i = 0; i < typeArguments.Length; i++) {
typeArguments[i] = SharedTypes.UnboundTypeArgument;
}
return ConvertTypeDefinition(typeDef, typeArguments);
return ConvertTypeHelper(typeDef, typeArguments);
} else {
return ConvertTypeDefinition(typeDef, EmptyList<IType>.Instance);
return ConvertTypeHelper(typeDef, EmptyList<IType>.Instance);
}
}
return new SimpleType(type.Name);
}
AstType ConvertTypeDefinition(ITypeDefinition typeDef, IList<IType> typeArguments)
AstType ConvertTypeHelper(ITypeDefinition typeDef, IList<IType> typeArguments)
{
Debug.Assert(typeArguments.Count >= typeDef.TypeParameterCount);
switch (ReflectionHelper.GetTypeCode(typeDef)) {
@ -144,7 +208,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -144,7 +208,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
MemberType result = new MemberType();
if (typeDef.DeclaringTypeDefinition != null) {
// Handle nested types
result.Target = ConvertTypeDefinition(typeDef.DeclaringTypeDefinition, typeArguments);
result.Target = ConvertTypeHelper(typeDef.DeclaringTypeDefinition, typeArguments);
} else {
// Handle top-level types
if (string.IsNullOrEmpty(typeDef.Namespace)) {
@ -238,5 +302,388 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -238,5 +302,388 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
NamespaceResolveResult nrr = resolver.ResolveSimpleName(firstNamespacePart, EmptyList<IType>.Instance) as NamespaceResolveResult;
return nrr != null && !nrr.IsError && nrr.NamespaceName == firstNamespacePart;
}
#endregion
#region Convert Constant Value
public Expression ConvertConstantValue(IConstantValue constantValue)
{
if (constantValue == null)
throw new ArgumentNullException("constantValue");
IType type = constantValue.GetValueType(context);
object val = constantValue.GetValue(context);
if (val == null) {
if (type.IsReferenceType(context) == true)
return new NullReferenceExpression();
else
return new DefaultValueExpression(ConvertType(type));
} else if (type.Kind == TypeKind.Enum) {
throw new NotImplementedException();
} else {
return new PrimitiveExpression(val);
}
}
#endregion
#region Convert Parameter
public ParameterDeclaration ConvertParameter(IParameter parameter)
{
if (parameter == null)
throw new ArgumentNullException("parameter");
ParameterDeclaration decl = new ParameterDeclaration();
if (parameter.IsRef) {
decl.ParameterModifier = ParameterModifier.Ref;
} else if (parameter.IsOut) {
decl.ParameterModifier = ParameterModifier.Out;
} else if (parameter.IsParams) {
decl.ParameterModifier = ParameterModifier.Params;
}
decl.Type = ConvertType(parameter.Type.Resolve(context));
if (this.ShowParameterNames) {
decl.Name = parameter.Name;
}
if (parameter.IsOptional && this.ShowConstantValues) {
decl.DefaultExpression = ConvertConstantValue(parameter.DefaultValue);
}
return decl;
}
#endregion
#region Convert Entity
public AstNode ConvertEntity(IEntity entity)
{
if (entity == null)
throw new ArgumentNullException("entity");
switch (entity.EntityType) {
case EntityType.TypeDefinition:
return ConvertTypeDefinition((ITypeDefinition)entity);
case EntityType.Field:
return ConvertField((IField)entity);
case EntityType.Property:
return ConvertProperty((IProperty)entity);
case EntityType.Indexer:
return ConvertIndexer((IProperty)entity);
case EntityType.Event:
return ConvertEvent((IEvent)entity);
case EntityType.Method:
return ConvertMethod((IMethod)entity);
case EntityType.Operator:
return ConvertOperator((IMethod)entity);
case EntityType.Constructor:
return ConvertConstructor((IMethod)entity);
case EntityType.Destructor:
return ConvertDestructor((IMethod)entity);
default:
throw new ArgumentException("Invalid value for EntityType: " + entity.EntityType);
}
}
AttributedNode ConvertTypeDefinition(ITypeDefinition typeDefinition)
{
Modifiers modifiers = ModifierFromAccessibility(typeDefinition.Accessibility);
if (this.ShowModifiers) {
if (typeDefinition.IsStatic) {
modifiers |= Modifiers.Static;
} else if (typeDefinition.IsAbstract) {
modifiers |= Modifiers.Abstract;
} else if (typeDefinition.IsSealed) {
modifiers |= Modifiers.Sealed;
}
if (typeDefinition.IsShadowing) {
modifiers |= Modifiers.New;
}
}
ClassType classType;
switch (typeDefinition.Kind) {
case TypeKind.Struct:
classType = ClassType.Struct;
break;
case TypeKind.Enum:
classType = ClassType.Enum;
break;
case TypeKind.Interface:
classType = ClassType.Interface;
break;
case TypeKind.Delegate:
IMethod invoke = typeDefinition.GetDelegateInvokeMethod();
if (invoke != null)
return ConvertDelegate(invoke, modifiers);
else
goto default;
default:
classType = ClassType.Class;
break;
}
TypeDeclaration decl = new TypeDeclaration();
decl.Modifiers = modifiers;
decl.ClassType = classType;
decl.Name = typeDefinition.Name;
if (this.ShowTypeParameters) {
foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
decl.TypeParameters.Add(ConvertTypeParameter(tp));
}
}
if (this.ShowBaseTypes) {
foreach (ITypeReference baseType in typeDefinition.BaseTypes) {
decl.BaseTypes.Add(ConvertType(baseType.Resolve(context)));
}
}
if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
var constraint = ConvertTypeParameterConstraint(tp);
if (constraint != null)
decl.Constraints.Add(constraint);
}
}
return decl;
}
DelegateDeclaration ConvertDelegate(IMethod invokeMethod, Modifiers modifiers)
{
ITypeDefinition d = invokeMethod.DeclaringTypeDefinition;
DelegateDeclaration decl = new DelegateDeclaration();
decl.Modifiers = modifiers;
decl.ReturnType = ConvertType(invokeMethod.ReturnType.Resolve(context));
decl.Name = d.Name;
if (this.ShowTypeParameters) {
foreach (ITypeParameter tp in d.TypeParameters) {
decl.TypeParameters.Add(ConvertTypeParameter(tp));
}
}
foreach (IParameter p in invokeMethod.Parameters) {
decl.Parameters.Add(ConvertParameter(p));
}
if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
foreach (ITypeParameter tp in d.TypeParameters) {
var constraint = ConvertTypeParameterConstraint(tp);
if (constraint != null)
decl.Constraints.Add(constraint);
}
}
return decl;
}
AstNode ConvertField(IField field)
{
FieldDeclaration decl = new FieldDeclaration();
Modifiers m = GetMemberModifiers(field);
if (field.IsConst) {
m &= ~Modifiers.Static;
m |= Modifiers.Const;
} else if (field.IsReadOnly) {
m |= Modifiers.Readonly;
} else if (field.IsVolatile) {
m |= Modifiers.Volatile;
}
decl.Modifiers = m;
decl.ReturnType = ConvertType(field.ReturnType.Resolve(context));
Expression initializer = null;
if (field.IsConst && this.ShowConstantValues)
initializer = ConvertConstantValue(field.ConstantValue);
decl.Variables.Add(new VariableInitializer(field.Name, initializer));
return decl;
}
Accessor ConvertAccessor(IAccessor accessor)
{
if (accessor == null)
return Accessor.Null;
Accessor decl = new Accessor();
decl.Modifiers = ModifierFromAccessibility(accessor.Accessibility);
return decl;
}
PropertyDeclaration ConvertProperty(IProperty property)
{
PropertyDeclaration decl = new PropertyDeclaration();
decl.Modifiers = GetMemberModifiers(property);
decl.ReturnType = ConvertType(property.ReturnType.Resolve(context));
decl.Name = property.Name;
decl.Getter = ConvertAccessor(property.Getter);
decl.Setter = ConvertAccessor(property.Setter);
return decl;
}
IndexerDeclaration ConvertIndexer(IProperty indexer)
{
IndexerDeclaration decl = new IndexerDeclaration();
decl.Modifiers = GetMemberModifiers(indexer);
decl.ReturnType = ConvertType(indexer.ReturnType.Resolve(context));
foreach (IParameter p in indexer.Parameters) {
decl.Parameters.Add(ConvertParameter(p));
}
decl.Getter = ConvertAccessor(indexer.Getter);
decl.Setter = ConvertAccessor(indexer.Setter);
return decl;
}
EventDeclaration ConvertEvent(IEvent ev)
{
EventDeclaration decl = new EventDeclaration();
decl.Modifiers = GetMemberModifiers(ev);
decl.ReturnType = ConvertType(ev.ReturnType.Resolve(context));
decl.Variables.Add(new VariableInitializer(ev.Name));
return decl;
}
MethodDeclaration ConvertMethod(IMethod method)
{
MethodDeclaration decl = new MethodDeclaration();
decl.Modifiers = GetMemberModifiers(method);
decl.ReturnType = ConvertType(method.ReturnType.Resolve(context));
decl.Name = method.Name;
if (this.ShowTypeParameters) {
foreach (ITypeParameter tp in method.TypeParameters) {
decl.TypeParameters.Add(ConvertTypeParameter(tp));
}
}
foreach (IParameter p in method.Parameters) {
decl.Parameters.Add(ConvertParameter(p));
}
if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
foreach (ITypeParameter tp in method.TypeParameters) {
var constraint = ConvertTypeParameterConstraint(tp);
if (constraint != null)
decl.Constraints.Add(constraint);
}
}
return decl;
}
AstNode ConvertOperator(IMethod op)
{
OperatorType? opType = OperatorDeclaration.GetOperatorType(op.Name);
if (opType == null)
return ConvertMethod(op);
OperatorDeclaration decl = new OperatorDeclaration();
decl.Modifiers = GetMemberModifiers(op);
decl.OperatorType = opType.Value;
decl.ReturnType = ConvertType(op.ReturnType.Resolve(context));
foreach (IParameter p in op.Parameters) {
decl.Parameters.Add(ConvertParameter(p));
}
return decl;
}
ConstructorDeclaration ConvertConstructor(IMethod ctor)
{
ConstructorDeclaration decl = new ConstructorDeclaration();
decl.Modifiers = GetMemberModifiers(ctor);
decl.Name = ctor.DeclaringTypeDefinition.Name;
foreach (IParameter p in ctor.Parameters) {
decl.Parameters.Add(ConvertParameter(p));
}
return decl;
}
DestructorDeclaration ConvertDestructor(IMethod dtor)
{
DestructorDeclaration decl = new DestructorDeclaration();
decl.Name = dtor.DeclaringTypeDefinition.Name;
return decl;
}
#endregion
#region Convert Modifiers
Modifiers ModifierFromAccessibility(Accessibility accessibility)
{
if (!this.ShowAccessibility)
return Modifiers.None;
switch (accessibility) {
case Accessibility.Private:
return Modifiers.Private;
case Accessibility.Public:
return Modifiers.Public;
case Accessibility.Protected:
return Modifiers.Protected;
case Accessibility.Internal:
return Modifiers.Internal;
case Accessibility.ProtectedOrInternal:
case Accessibility.ProtectedAndInternal:
return Modifiers.Protected | Modifiers.Internal;
default:
return Modifiers.None;
}
}
Modifiers GetMemberModifiers(IMember member)
{
Modifiers m = ModifierFromAccessibility(member.Accessibility);
if (this.ShowModifiers) {
if (member.IsStatic) {
m |= Modifiers.Static;
} else {
if (member.IsAbstract)
m |= Modifiers.Abstract;
if (member.IsOverride)
m |= Modifiers.Override;
if (member.IsVirtual && !member.IsAbstract && !member.IsOverride)
m |= Modifiers.Virtual;
if (member.IsSealed)
m |= Modifiers.Sealed;
}
if (member.IsShadowing)
m |= Modifiers.New;
}
return m;
}
#endregion
#region Convert Type Parameter
TypeParameterDeclaration ConvertTypeParameter(ITypeParameter tp)
{
TypeParameterDeclaration decl = new TypeParameterDeclaration();
decl.Variance = tp.Variance;
decl.Name = tp.Name;
return decl;
}
Constraint ConvertTypeParameterConstraint(ITypeParameter tp)
{
if (tp.Constraints.Count == 0 && !tp.HasDefaultConstructorConstraint && !tp.HasReferenceTypeConstraint && !tp.HasValueTypeConstraint) {
return null;
}
Constraint c = new Constraint();
c.TypeParameter = tp.Name;
if (tp.HasReferenceTypeConstraint) {
c.BaseTypes.Add(new PrimitiveType("class"));
} else if (tp.HasValueTypeConstraint) {
c.BaseTypes.Add(new PrimitiveType("struct"));
}
foreach (ITypeReference tr in tp.Constraints) {
c.BaseTypes.Add(ConvertType(tr.Resolve(context)));
}
if (tp.HasDefaultConstructorConstraint) {
c.BaseTypes.Add(new PrimitiveType("new"));
}
return c;
}
#endregion
#region Convert Variable
public VariableDeclarationStatement ConvertVariable(IVariable v)
{
VariableDeclarationStatement decl = new VariableDeclarationStatement();
decl.Modifiers = v.IsConst ? Modifiers.Const : Modifiers.None;
decl.Type = ConvertType(v.Type.Resolve(context));
Expression initializer = null;
if (v.IsConst)
initializer = ConvertConstantValue(v.ConstantValue);
decl.Variables.Add(new VariableInitializer(v.Name, initializer));
return decl;
}
#endregion
}
}

6
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -60,7 +60,6 @@ @@ -60,7 +60,6 @@
<ItemGroup>
<Compile Include="CSharp\Analysis\ControlFlow.cs" />
<Compile Include="CSharp\Analysis\DefiniteAssignmentAnalysis.cs" />
<Compile Include="CSharp\Analysis\MinimalResolveContext.cs" />
<Compile Include="CSharp\Ast\AstNodeCollection.cs" />
<Compile Include="CSharp\Ast\Expressions\TypeReferenceExpression.cs" />
<Compile Include="CSharp\Ast\IAstVisitor.cs" />
@ -252,6 +251,7 @@ @@ -252,6 +251,7 @@
<Compile Include="TypeSystem\Implementation\GetClassTypeReference.cs" />
<Compile Include="TypeSystem\Implementation\CompositeTypeResolveContext.cs" />
<Compile Include="TypeSystem\Implementation\GetMembersHelper.cs" />
<Compile Include="TypeSystem\Implementation\MinimalResolveContext.cs" />
<Compile Include="TypeSystem\Implementation\TypeParameterSubstitution.cs" />
<Compile Include="TypeSystem\Implementation\NestedTypeReference.cs" />
<Compile Include="TypeSystem\Implementation\ProxyTypeResolveContext.cs" />
@ -427,6 +427,10 @@ @@ -427,6 +427,10 @@
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\ICSharpCode.Editor\ICSharpCode.Editor.csproj">
<Project>{F054A788-B591-4561-A8BA-AE745BBEB817}</Project>
<Name>ICSharpCode.Editor</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

4
ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs

@ -196,6 +196,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -196,6 +196,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
get { return moduleAttributes; }
}
public string AssemblyName {
get { return assemblyName; }
}
public override string ToString()
{
return "[CecilProjectContent " + assemblyName + "]";

2
ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs

@ -255,7 +255,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -255,7 +255,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
public static ITypeDefinition GetTypeDefinition (this IParsedFile file, int line, int column)
{
return file.GetTypeDefinition (new AstLocation (line, column));
return file.GetInnerMostTypeDefinition (new AstLocation (line, column));
}
/// <summary>

2
ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs

@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets the type (potentially a nested type) defined at the specified location.
/// Returns null if no type is defined at that location.
/// </summary>
ITypeDefinition GetTypeDefinition(AstLocation location);
ITypeDefinition GetInnerMostTypeDefinition(AstLocation location);
/// <summary>
/// Gets the member defined at the specified location.

5
ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs

@ -30,6 +30,11 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -30,6 +30,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
#endif
public interface IProjectContent : ITypeResolveContext, IAnnotatable
{
/// <summary>
/// Gets the assembly name (short name).
/// </summary>
string AssemblyName { get; }
/// <summary>
/// Gets the list of all assembly attributes in the project.
/// </summary>

11
ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs → ICSharpCode.NRefactory/TypeSystem/Implementation/MinimalResolveContext.cs

@ -21,15 +21,12 @@ using System.Collections.Generic; @@ -21,15 +21,12 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.CSharp.Analysis
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{
/// <summary>
/// Resolve context represents the minimal mscorlib required for evaluating constants.
/// </summary>
sealed class MinimalResolveContext : AbstractAnnotatable, IProjectContent, ISynchronizedTypeResolveContext
public sealed class MinimalResolveContext : AbstractAnnotatable, IProjectContent, ISynchronizedTypeResolveContext
{
static readonly Lazy<MinimalResolveContext> instance = new Lazy<MinimalResolveContext>(() => new MinimalResolveContext());
@ -175,5 +172,9 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -175,5 +172,9 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
{
throw new NotSupportedException();
}
public string AssemblyName {
get { return "MinimalResolveContext"; }
}
}
}

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

@ -50,6 +50,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -50,6 +50,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
}
#endregion
public virtual string AssemblyName {
get { return string.Empty; }
}
#region AssemblyAttributes
readonly List<IAttribute> assemblyAttributes = new List<IAttribute>(); // mutable assembly attribute storage
readonly List<IAttribute> moduleAttributes = new List<IAttribute>();

Loading…
Cancel
Save