diff --git a/src/Main/Base/Project/Src/Project/Items/ItemType.cs b/src/Main/Base/Project/Src/Project/Items/ItemType.cs index 1a7f658d52..56e63a7485 100644 --- a/src/Main/Base/Project/Src/Project/Items/ItemType.cs +++ b/src/Main/Base/Project/Src/Project/Items/ItemType.cs @@ -60,7 +60,10 @@ namespace ICSharpCode.SharpDevelop.Project /// Gets a collection of item types that are known not to be used for files. /// public static readonly ReadOnlyCollectionWrapper NonFileItemTypes - = new ReadOnlyCollectionWrapper(new List(ReferenceItemTypes) { Folder, WebReferences, Import }); + = new ReadOnlyCollectionWrapper( + new List(ReferenceItemTypes) { + Folder, WebReferences, Import + }); readonly string itemName; diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs index 952d398417..1654bedd85 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs @@ -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 => { diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs index 0ebfd830c4..b7d4791514 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs @@ -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 /// The returned ParseInformation might be stale (re-parse is not forced). public static ParseInformation GetParseInformation(string fileName) { - return GetFileEntry(fileName, true).GetParseInformation(); + return GetFileEntry(fileName, true).GetParseInformation(null); } /// @@ -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; + } + + /// + /// Gets parse information for the specified file in the context of the + /// specified project content. + /// This method is thread-safe. + /// + /// Returns the ParseInformation for the specified file, or null if the file has not been parsed for that project content. + public static ParseInformation GetExistingParseInformation(IProjectContent content, string fileName) + { + FileEntry entry = GetFileEntry(fileName, false); + if (entry != null) + return entry.GetExistingParseInformation(content); else return null; } diff --git a/src/Main/Base/Test/Utils/MockTextMarker.cs b/src/Main/Base/Test/Utils/MockTextMarker.cs index ac38cc5465..e5c3a48bb2 100644 --- a/src/Main/Base/Test/Utils/MockTextMarker.cs +++ b/src/Main/Base/Test/Utils/MockTextMarker.cs @@ -52,10 +52,11 @@ namespace ICSharpCode.SharpDevelop.Tests.Utils } public Nullable BackgroundColor { get; set; } - public Nullable 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() {