|
|
@ -14,38 +14,8 @@ using ICSharpCode.SharpDevelop.Gui; |
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.SharpDevelop.Project |
|
|
|
namespace ICSharpCode.SharpDevelop.Project |
|
|
|
{ |
|
|
|
{ |
|
|
|
public class ParseableFileContentEntry |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public FileName FileName { get; private set; } |
|
|
|
|
|
|
|
ITextBuffer openContent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ITextBuffer GetContent() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (openContent != null) |
|
|
|
|
|
|
|
return openContent; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
return new StringTextBuffer(ICSharpCode.AvalonEdit.Utils.FileReader.ReadFileContent(FileName, ParserService.DefaultFileEncoding)); |
|
|
|
|
|
|
|
} catch (IOException) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} catch (UnauthorizedAccessException) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal ParseableFileContentEntry(FileName fileName, FileName[] viewContentFileNamesCollection) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this.FileName = fileName; |
|
|
|
|
|
|
|
foreach (FileName name in viewContentFileNamesCollection) { |
|
|
|
|
|
|
|
if (FileUtility.IsEqualFileName(name, this.FileName)) { |
|
|
|
|
|
|
|
openContent = WorkbenchSingleton.SafeThreadFunction(ParserService.GetParseableFileContent, this.FileName.ToString()); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Can be used to create ParseableFileContentEntry for ProjectItems.
|
|
|
|
/// Can be used to create ITextBuffer for ProjectItems.
|
|
|
|
/// This class is thread-safe.
|
|
|
|
/// This class is thread-safe.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class ParseableFileContentFinder |
|
|
|
public class ParseableFileContentFinder |
|
|
@ -55,9 +25,19 @@ namespace ICSharpCode.SharpDevelop.Project |
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the file contents for the specified project items.
|
|
|
|
/// Retrieves the file contents for the specified project items.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public ParseableFileContentEntry Create(FileName fileName) |
|
|
|
public ITextBuffer Create(FileName fileName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new ParseableFileContentEntry(fileName, viewContentFileNamesCollection); |
|
|
|
foreach (FileName name in viewContentFileNamesCollection) { |
|
|
|
|
|
|
|
if (FileUtility.IsEqualFileName(name, fileName)) |
|
|
|
|
|
|
|
return WorkbenchSingleton.SafeThreadFunction(ParserService.GetParseableFileContent, fileName.ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
return new StringTextBuffer(ICSharpCode.AvalonEdit.Utils.FileReader.ReadFileContent(fileName, ParserService.DefaultFileEncoding)); |
|
|
|
|
|
|
|
} catch (IOException) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} catch (UnauthorizedAccessException) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |