Browse Source

Added an option to turn off the aliases in the type system ast

builder.
newNRvisualizers
Mike Krüger 14 years ago
parent
commit
0f2e42a337
  1. 11
      ICSharpCode.NRefactory.CSharp/Refactoring/TypeSystemAstBuilder.cs

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

@ -55,6 +55,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
this.ShowTypeParameterConstraints = true; this.ShowTypeParameterConstraints = true;
this.ShowParameterNames = true; this.ShowParameterNames = true;
this.ShowConstantValues = true; this.ShowConstantValues = true;
this.UseAliases = true;
} }
/// <summary> /// <summary>
@ -129,6 +130,12 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
/// The default value is <c>false</c>. /// The default value is <c>false</c>.
/// </summary> /// </summary>
public bool ConvertUnboundTypeArguments { get; set;} public bool ConvertUnboundTypeArguments { get; set;}
/// <summary>
/// Controls if aliases should be used inside the type name or not.
/// The default value is <c>true</c>.
/// </summary>
public bool UseAliases { get; set;}
#endregion #endregion
#region Convert Type #region Convert Type
@ -218,6 +225,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
if (resolver != null) { if (resolver != null) {
// Look if there's an alias to the target type // Look if there's an alias to the target type
if (UseAliases) {
for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) { for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) {
foreach (var pair in usingScope.UsingAliases) { foreach (var pair in usingScope.UsingAliases) {
if (pair.Value is TypeResolveResult) { if (pair.Value is TypeResolveResult) {
@ -226,6 +234,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
} }
} }
} }
}
IList<IType> localTypeArguments; IList<IType> localTypeArguments;
if (typeDef.TypeParameterCount > outerTypeParameterCount) { if (typeDef.TypeParameterCount > outerTypeParameterCount) {
@ -318,6 +327,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
{ {
if (resolver != null) { if (resolver != null) {
// Look if there's an alias to the target namespace // Look if there's an alias to the target namespace
if (UseAliases) {
for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) { for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent) {
foreach (var pair in usingScope.UsingAliases) { foreach (var pair in usingScope.UsingAliases) {
NamespaceResolveResult nrr = pair.Value as NamespaceResolveResult; NamespaceResolveResult nrr = pair.Value as NamespaceResolveResult;
@ -326,6 +336,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
} }
} }
} }
}
int pos = ns.LastIndexOf('.'); int pos = ns.LastIndexOf('.');
if (pos < 0) { if (pos < 0) {

Loading…
Cancel
Save