Browse Source

Fixed SD2-804: Renaming a class in a new unsaved file

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1393 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
71e17b5842
  1. 2
      src/Main/Base/Project/Src/Project/Items/ProjectItem.cs
  2. 3
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  3. 3
      src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs
  4. 58
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

2
src/Main/Base/Project/Src/Project/Items/ProjectItem.cs

@ -105,6 +105,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -105,6 +105,8 @@ namespace ICSharpCode.SharpDevelop.Project
[Browsable(false)]
public virtual string FileName {
get {
if (project == null)
return Include;
if (fileNameCache == null)
fileNameCache = Path.Combine(project.Directory, include);
return fileNameCache;

3
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -363,7 +363,8 @@ namespace ICSharpCode.Core @@ -363,7 +363,8 @@ namespace ICSharpCode.Core
public static void ParseViewContent(IViewContent viewContent)
{
string text = ((IEditable)viewContent).Text;
ParseInformation parseInformation = ParseFile(viewContent.FileName, text, !viewContent.IsUntitled, true);
ParseInformation parseInformation = ParseFile(viewContent.IsUntitled ? viewContent.UntitledName : viewContent.FileName,
text, !viewContent.IsUntitled, true);
if (parseInformation != null && viewContent is IParseInformationListener) {
((IParseInformationListener)viewContent).ParseInformationUpdated(parseInformation);
}

3
src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs

@ -28,8 +28,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -28,8 +28,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
{
foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (content is ITextEditorControlProvider &&
content.FileName != null &&
FileUtility.IsEqualFileName(content.FileName, fileName))
FileUtility.IsEqualFileName(content.IsUntitled ? content.UntitledName : content.FileName, fileName))
{
return new ProvidedDocumentInformation(((ITextEditorControlProvider)content).TextEditorControl.Document, fileName, 0);
}

58
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

@ -180,24 +180,24 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -180,24 +180,24 @@ namespace ICSharpCode.SharpDevelop.Refactoring
bool isLocal,
string fileName, string fileContent)
{
string lowerFileContent = fileContent.ToLower();
string lowerFileContent = fileContent.ToLowerInvariant();
string searchedText; // the text that is searched for
bool searchingIndexer = false;
if (member == null) {
searchedText = parentClass.Name.ToLower();
searchedText = parentClass.Name.ToLowerInvariant();
} else {
// When looking for a member, the name of the parent class does not always exist
// in the file where the member is accessed.
// (examples: derived classes, partial classes)
if (member is IMethod && ((IMethod)member).IsConstructor)
searchedText = parentClass.Name.ToLower();
searchedText = parentClass.Name.ToLowerInvariant();
else {
if (member is IProperty && ((IProperty)member).IsIndexer) {
searchingIndexer = true;
searchedText = GetIndexerExpressionStartToken(fileName);
} else {
searchedText = member.Name.ToLower();
searchedText = member.Name.ToLowerInvariant();
}
}
}
@ -335,28 +335,32 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -335,28 +335,32 @@ namespace ICSharpCode.SharpDevelop.Refactoring
return list;
}
/// <summary>
/// Gets the list of files that could have a reference to the specified class.
/// </summary>
static List<ProjectItem> GetPossibleFiles(IClass c)
{
if (c.DeclaringType != null) {
return GetPossibleFiles(c.DeclaringType, c);
}
List<ProjectItem> resultList = new List<ProjectItem>();
GetPossibleFilesInternal(resultList, c.ProjectContent, c.IsInternal);
return resultList;
}
/// <summary>
/// Gets the files of files that could have a reference to the <paramref name="member"/>
/// int the <paramref name="ownerClass"/>.
/// </summary>
static List<ProjectItem> GetPossibleFiles(IClass ownerClass, IDecoration member)
{
if (member == null)
return GetPossibleFiles(ownerClass);
List<ProjectItem> resultList = new List<ProjectItem>();
if (ProjectService.OpenSolution == null) {
FileProjectItem tempItem = new FileProjectItem(null, ItemType.Compile);
tempItem.Include = ownerClass.CompilationUnit.FileName;
resultList.Add(tempItem);
return resultList;
}
if (member == null) {
// get files possibly referencing ownerClass
while (ownerClass.DeclaringType != null) {
// for nested classes, treat class as member
member = ownerClass;
ownerClass = ownerClass.DeclaringType;
}
if (member == null) {
GetPossibleFilesInternal(resultList, ownerClass.ProjectContent, ownerClass.IsInternal);
return resultList;
}
}
if (member.IsPrivate) {
List<string> fileNames = GetFileNames(ownerClass);
foreach (string fileName in fileNames) {
@ -376,16 +380,18 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -376,16 +380,18 @@ namespace ICSharpCode.SharpDevelop.Refactoring
static ProjectItem FindItem(string fileName)
{
if (ProjectService.OpenSolution == null)
return null;
foreach (IProject p in ProjectService.OpenSolution.Projects) {
foreach (ProjectItem item in p.Items) {
if (FileUtility.IsEqualFileName(fileName, item.FileName)) {
return item;
if (ProjectService.OpenSolution != null) {
foreach (IProject p in ProjectService.OpenSolution.Projects) {
foreach (ProjectItem item in p.Items) {
if (FileUtility.IsEqualFileName(fileName, item.FileName)) {
return item;
}
}
}
}
return null;
FileProjectItem tempItem = new FileProjectItem(null, ItemType.Compile);
tempItem.Include = fileName;
return tempItem;
}
static void GetPossibleFilesInternal(List<ProjectItem> resultList, IProjectContent ownerProjectContent, bool internalOnly)

Loading…
Cancel
Save