Browse Source

ParserService: allow GetExistingParseInformation with specified project content.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4830 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
ca3f8791b6
  1. 5
      src/Main/Base/Project/Src/Project/Items/ItemType.cs
  2. 2
      src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs
  3. 43
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  4. 5
      src/Main/Base/Test/Utils/MockTextMarker.cs

5
src/Main/Base/Project/Src/Project/Items/ItemType.cs

@ -60,7 +60,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -60,7 +60,10 @@ namespace ICSharpCode.SharpDevelop.Project
/// Gets a collection of item types that are known not to be used for files.
/// </summary>
public static readonly ReadOnlyCollectionWrapper<ItemType> NonFileItemTypes
= new ReadOnlyCollectionWrapper<ItemType>(new List<ItemType>(ReferenceItemTypes) { Folder, WebReferences, Import });
= new ReadOnlyCollectionWrapper<ItemType>(
new List<ItemType>(ReferenceItemTypes) {
Folder, WebReferences, Import
});
readonly string itemName;

2
src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

@ -263,7 +263,7 @@ namespace ICSharpCode.SharpDevelop @@ -263,7 +263,7 @@ namespace ICSharpCode.SharpDevelop
ParseableFileContentFinder finder = new ParseableFileContentFinder();
var fileContents =
from p in project.Items.AsParallel().WithCancellation(token)
where !ItemType.NonFileItemTypes.Contains(p.ItemType)
where !ItemType.NonFileItemTypes.Contains(p.ItemType) && !String.IsNullOrEmpty(p.FileName)
select finder.Create(p);
fileContents.ForAll(
entry => {

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

@ -329,18 +329,32 @@ namespace ICSharpCode.SharpDevelop @@ -329,18 +329,32 @@ namespace ICSharpCode.SharpDevelop
}
}
public ParseInformation GetParseInformation()
public ParseInformation GetParseInformation(IProjectContent content)
{
ParseInformation p = this.parseInfo; // read volatile
ParseInformation p = GetExistingParseInformation(content);
if (p != null)
return p;
else
return ParseFile(null, null);
return ParseFile(content, null);
}
public ParseInformation GetExistingParseInformation()
public ParseInformation GetExistingParseInformation(IProjectContent content)
{
return this.parseInfo; // read volatile
if (content == null) {
return this.parseInfo; // read volatile
} else {
ParseInformation p = this.parseInfo; // read volatile
if (p != null && p.CompilationUnit.ProjectContent == content)
return p;
lock (this) {
if (this.oldUnits != null) {
ICompilationUnit cu = this.oldUnits.FirstOrDefault(c => c.ProjectContent == content);
return cu != null ? new ParseInformation(cu) : null;
} else {
return null;
}
}
}
}
public ParseInformation ParseFile(IProjectContent parentProjectContent, ITextBuffer fileContent)
@ -513,7 +527,7 @@ namespace ICSharpCode.SharpDevelop @@ -513,7 +527,7 @@ namespace ICSharpCode.SharpDevelop
/// The returned ParseInformation might be stale (re-parse is not forced).</returns>
public static ParseInformation GetParseInformation(string fileName)
{
return GetFileEntry(fileName, true).GetParseInformation();
return GetFileEntry(fileName, true).GetParseInformation(null);
}
/// <summary>
@ -525,7 +539,22 @@ namespace ICSharpCode.SharpDevelop @@ -525,7 +539,22 @@ namespace ICSharpCode.SharpDevelop
{
FileEntry entry = GetFileEntry(fileName, false);
if (entry != null)
return entry.GetExistingParseInformation();
return entry.GetExistingParseInformation(null);
else
return null;
}
/// <summary>
/// Gets parse information for the specified file in the context of the
/// specified project content.
/// This method is thread-safe.
/// </summary>
/// <returns>Returns the ParseInformation for the specified file, or null if the file has not been parsed for that project content.</returns>
public static ParseInformation GetExistingParseInformation(IProjectContent content, string fileName)
{
FileEntry entry = GetFileEntry(fileName, false);
if (entry != null)
return entry.GetExistingParseInformation(content);
else
return null;
}

5
src/Main/Base/Test/Utils/MockTextMarker.cs

@ -52,10 +52,11 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils @@ -52,10 +52,11 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils
}
public Nullable<Color> BackgroundColor { get; set; }
public Nullable<Color> ForegroundColor { get; set; }
public TextMarkerType MarkerType { get; set; }
public Color MarkerColor { get; set; }
public object Tag { get; set; }
public object ToolTip { get; set; }
public void Delete()
{

Loading…
Cancel
Save