Browse Source

Update the type system when files get removed from the project.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
e9d03395a3
  1. 9
      src/Main/Base/Project/Parser/IParserService.cs
  2. 5
      src/Main/SharpDevelop/Parser/ParserService.cs
  3. 11
      src/Main/SharpDevelop/Parser/ParserServiceEntry.cs

9
src/Main/Base/Project/Parser/IParserService.cs

@ -262,13 +262,20 @@ namespace ICSharpCode.SharpDevelop.Parser @@ -262,13 +262,20 @@ namespace ICSharpCode.SharpDevelop.Parser
/// The parser services tries to use the project that contains the file directly (non-linked)
/// as the primary parent project.
/// </param>
/// <remarks>
/// If the file was already parsed (e.g. because it also belongs to another project),
/// this method invokes <c>project.UpdateParseInformation(null, existingUnresolvedFile);</c>.
/// Otherwise, the project will be notified of the new file the next time it is parsed.
/// </remarks>
void AddOwnerProject(FileName fileName, IProject project, bool startAsyncParse, bool isLinkedFile);
/// <summary>
/// Removes a project from the owners of the file.
/// </summary>
/// <remarks>
/// This method invokes <c>project.UpdateParseInformation(existingUnresolvedFile, null);</c>.
/// (unless existingUnresolvedFile==null)
/// </summary>
/// </remarks>
void RemoveOwnerProject(FileName fileName, IProject project);
/// <summary>

5
src/Main/SharpDevelop/Parser/ParserService.cs

@ -194,7 +194,10 @@ namespace ICSharpCode.SharpDevelop.Parser @@ -194,7 +194,10 @@ namespace ICSharpCode.SharpDevelop.Parser
{
if (project == null)
throw new ArgumentNullException("project");
GetFileEntry(fileName, true).AddOwnerProject(project, isLinkedFile);
var entry = GetFileEntry(fileName, true);
entry.AddOwnerProject(project, isLinkedFile);
if (startAsyncParse)
entry.ParseFileAsync(null, project, CancellationToken.None).FireAndForget();
}
public void RemoveOwnerProject(FileName fileName, IProject project)

11
src/Main/SharpDevelop/Parser/ParserServiceEntry.cs

@ -83,16 +83,27 @@ namespace ICSharpCode.SharpDevelop.Parser @@ -83,16 +83,27 @@ namespace ICSharpCode.SharpDevelop.Parser
public void RemoveOwnerProject(IProject project)
{
Debug.Assert(project != null);
ProjectEntry oldEntry;
bool removedLastOwner = false;
lock (this) {
int index = FindIndexForProject(project);
if (index < 0)
throw new InvalidOperationException("The project does not own the file");
oldEntry = entries[index];
if (entries.Count == 1) {
entries[0] = default(ProjectEntry);
removedLastOwner = true;
} else {
entries.RemoveAt(index);
}
}
if (oldEntry.UnresolvedFile != null) {
project.OnParseInformationUpdated(new ParseInformationEventArgs(project, oldEntry.UnresolvedFile, null));
}
if (removedLastOwner) {
// allow the parser service to forget this entry
parserService.RegisterForCacheExpiry(this);
}
}
#endregion

Loading…
Cancel
Save