Browse Source

fix #220: Cannot rename an identifier starting with an @

pull/520/head
Siegfried Pammer 11 years ago
parent
commit
00d2fd1d66
  1. 5
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs
  2. 5
      src/Main/Base/Project/Refactoring/CodeGenerator.cs
  3. 3
      src/Main/Base/Project/Src/Editor/Commands/FindReferencesCommand.cs

5
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs

@ -211,5 +211,10 @@ namespace CSharpBinding.Refactoring
script.ChangeModifier(entityDeclaration, entityDeclaration.Modifiers | Modifiers.Virtual); script.ChangeModifier(entityDeclaration, entityDeclaration.Modifiers | Modifiers.Virtual);
} }
} }
public override string EscapeIdentifier(string identifier)
{
return "@" + identifier;
}
} }
} }

5
src/Main/Base/Project/Refactoring/CodeGenerator.cs

@ -83,6 +83,11 @@ namespace ICSharpCode.SharpDevelop.Refactoring
return newName; return newName;
} }
public virtual string EscapeIdentifier(string identifier)
{
throw new NotSupportedException("Feature not supported!");
}
public virtual void AddField(ITypeDefinition declaringType, Accessibility accessibility, IType fieldType, string name) public virtual void AddField(ITypeDefinition declaringType, Accessibility accessibility, IType fieldType, string name)
{ {
throw new NotSupportedException("Feature not supported!"); throw new NotSupportedException("Feature not supported!");

3
src/Main/Base/Project/Src/Editor/Commands/FindReferencesCommand.cs

@ -126,7 +126,8 @@ namespace ICSharpCode.SharpDevelop.Editor.Commands
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
return false; return false;
if ((language.CodeDomProvider == null) || !language.CodeDomProvider.IsValidIdentifier(name)) if ((language.CodeDomProvider == null) || (!language.CodeDomProvider.IsValidIdentifier(name) &&
!language.CodeDomProvider.IsValidIdentifier(language.CodeGenerator.EscapeIdentifier(name))))
return false; return false;
return true; return true;

Loading…
Cancel
Save