Browse Source

Fix #227: Class no longer available for code completion when file renamed

pull/315/head
Daniel Grunwald 12 years ago
parent
commit
33c72ed327
  1. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs
  2. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  3. 2
      src/Main/SharpDevelop/Parser/ParserService.cs
  4. 10
      src/Main/SharpDevelop/Parser/ParserServiceEntry.cs
  5. 4
      src/Main/SharpDevelop/Project/Build/BuildEngine.cs
  6. 11
      src/Main/SharpDevelop/Project/ProjectService.cs

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs

@ -256,7 +256,7 @@ namespace CSharpBinding
if (parseInfo == null) { if (parseInfo == null) {
if (invalidLines != null && !invalidLines.Contains(documentLine)) { if (invalidLines != null && !invalidLines.Contains(documentLine)) {
invalidLines.Add(documentLine); invalidLines.Add(documentLine);
Debug.WriteLine("Semantic highlighting for line {0} - marking as invalid", lineNumber); //Debug.WriteLine("Semantic highlighting for line {0} - marking as invalid", lineNumber);
} }
if (cachedLine != null) { if (cachedLine != null) {

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -1027,7 +1027,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
if (heightTree.GetIsCollapsed(documentLine.LineNumber)) if (heightTree.GetIsCollapsed(documentLine.LineNumber))
throw new InvalidOperationException("Trying to build visual line from collapsed line"); throw new InvalidOperationException("Trying to build visual line from collapsed line");
Debug.WriteLine("Building line " + documentLine.LineNumber); //Debug.WriteLine("Building line " + documentLine.LineNumber);
VisualLine visualLine = new VisualLine(this, documentLine); VisualLine visualLine = new VisualLine(this, documentLine);
VisualLineTextSource textSource = new VisualLineTextSource(visualLine) { VisualLineTextSource textSource = new VisualLineTextSource(visualLine) {

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

@ -194,6 +194,7 @@ namespace ICSharpCode.SharpDevelop.Parser
{ {
if (project == null) if (project == null)
throw new ArgumentNullException("project"); throw new ArgumentNullException("project");
//SD.Log.Debug("Add " + fileName + " to " + project);
var entry = GetFileEntry(fileName, true); var entry = GetFileEntry(fileName, true);
entry.AddOwnerProject(project, isLinkedFile); entry.AddOwnerProject(project, isLinkedFile);
if (startAsyncParse) if (startAsyncParse)
@ -204,6 +205,7 @@ namespace ICSharpCode.SharpDevelop.Parser
{ {
if (project == null) if (project == null)
throw new ArgumentNullException("project"); throw new ArgumentNullException("project");
//SD.Log.Debug("Remove " + fileName + " from " + project);
var entry = GetFileEntry(fileName, false); var entry = GetFileEntry(fileName, false);
if (entry != null) if (entry != null)
entry.RemoveOwnerProject(project); entry.RemoveOwnerProject(project);

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

@ -214,8 +214,9 @@ namespace ICSharpCode.SharpDevelop.Parser
return new ProjectEntry(parentProject, parseInfo.UnresolvedFile, parseInfo); return new ProjectEntry(parentProject, parseInfo.UnresolvedFile, parseInfo);
} else { } else {
if (versionComparison == 0 && index >= 0) { if (versionComparison == 0 && index >= 0) {
// Ensure we have parse info for the specified project (entry.UnresolvedFile is null for newly registered projects)
// If full parse info is requested, ensure we have full parse info. // If full parse info is requested, ensure we have full parse info.
if (!(fullParseInformationRequested && entries[index].CachedParseInformation == null)) { if (entries[index].UnresolvedFile != null && !(fullParseInformationRequested && entries[index].CachedParseInformation == null)) {
// We already have the requested version parsed, just return it: // We already have the requested version parsed, just return it:
return entries[index]; return entries[index];
} }
@ -271,6 +272,7 @@ namespace ICSharpCode.SharpDevelop.Parser
#region ParseAsync #region ParseAsync
Task<ProjectEntry> runningAsyncParseTask; Task<ProjectEntry> runningAsyncParseTask;
ITextSourceVersion runningAsyncParseFileContentVersion; ITextSourceVersion runningAsyncParseFileContentVersion;
IProject runningAsyncParseProject;
bool runningAsyncParseFullInfoRequested; bool runningAsyncParseFullInfoRequested;
public async Task<ParseInformation> ParseAsync(ITextSource fileContent, IProject parentProject, CancellationToken cancellationToken) public async Task<ParseInformation> ParseAsync(ITextSource fileContent, IProject parentProject, CancellationToken cancellationToken)
@ -312,8 +314,9 @@ namespace ICSharpCode.SharpDevelop.Parser
int index = FindIndexForProject(parentProject); int index = FindIndexForProject(parentProject);
int versionComparison = CompareVersions(fileContent.Version); int versionComparison = CompareVersions(fileContent.Version);
if (versionComparison == 0 && index >= 0) { if (versionComparison == 0 && index >= 0) {
// Ensure we have parse info for the specified project (entry.UnresolvedFile is null for newly registered projects)
// If full parse info is requested, ensure we have full parse info. // If full parse info is requested, ensure we have full parse info.
if (!(requestFullParseInformation && entries[index].CachedParseInformation == null)) { if (entries[index].UnresolvedFile != null && !(requestFullParseInformation && entries[index].CachedParseInformation == null)) {
// We already have the requested version parsed, just return it: // We already have the requested version parsed, just return it:
return Task.FromResult(entries[index]); return Task.FromResult(entries[index]);
} }
@ -321,6 +324,7 @@ namespace ICSharpCode.SharpDevelop.Parser
// Optimization: // Optimization:
// if an equivalent task is already running, return that one instead // if an equivalent task is already running, return that one instead
if (runningAsyncParseTask != null && (!requestFullParseInformation || runningAsyncParseFullInfoRequested) if (runningAsyncParseTask != null && (!requestFullParseInformation || runningAsyncParseFullInfoRequested)
&& runningAsyncParseProject == parentProject
&& runningAsyncParseFileContentVersion.BelongsToSameDocumentAs(fileContent.Version) && runningAsyncParseFileContentVersion.BelongsToSameDocumentAs(fileContent.Version)
&& runningAsyncParseFileContentVersion.CompareAge(fileContent.Version) == 0) && runningAsyncParseFileContentVersion.CompareAge(fileContent.Version) == 0)
{ {
@ -338,12 +342,14 @@ namespace ICSharpCode.SharpDevelop.Parser
lock (this) { lock (this) {
runningAsyncParseTask = null; runningAsyncParseTask = null;
runningAsyncParseFileContentVersion = null; runningAsyncParseFileContentVersion = null;
runningAsyncParseProject = null;
} }
} }
}, cancellationToken); }, cancellationToken);
if (fileContent != null && fileContent.Version != null && !cancellationToken.CanBeCanceled) { if (fileContent != null && fileContent.Version != null && !cancellationToken.CanBeCanceled) {
runningAsyncParseTask = task; runningAsyncParseTask = task;
runningAsyncParseFileContentVersion = fileContent.Version; runningAsyncParseFileContentVersion = fileContent.Version;
runningAsyncParseProject = parentProject;
runningAsyncParseFullInfoRequested = requestFullParseInformation; runningAsyncParseFullInfoRequested = requestFullParseInformation;
} }
} }

4
src/Main/SharpDevelop/Project/Build/BuildEngine.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary> /// </summary>
/// <param name="project">The project/solution to build</param> /// <param name="project">The project/solution to build</param>
/// <param name="options">The build options that should be used</param> /// <param name="options">The build options that should be used</param>
/// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output. /// <param name="buildFeedbackSink">The build feedback sink that receives the build output.
/// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine /// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
/// will ensure that output from two projects building in parallel isn't interleaved.</param> /// will ensure that output from two projects building in parallel isn't interleaved.</param>
/// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed /// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
@ -38,7 +38,7 @@ namespace ICSharpCode.SharpDevelop.Project
public static Task<BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor) public static Task<BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor)
{ {
if (project == null) if (project == null)
throw new ArgumentNullException("solution"); throw new ArgumentNullException("project");
if (options == null) if (options == null)
throw new ArgumentNullException("options"); throw new ArgumentNullException("options");

11
src/Main/SharpDevelop/Project/ProjectService.cs

@ -137,7 +137,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (!CloseSolution(allowCancel: true)) if (!CloseSolution(allowCancel: true))
return false; return false;
FileUtility.ObservedLoad(OpenSolutionInternal, fileName); FileUtility.ObservedLoad(OpenSolutionInternal, fileName);
return currentSolution != null; return currentSolution != null;
} }
@ -147,13 +147,6 @@ namespace ICSharpCode.SharpDevelop.Project
using (var progress = AsynchronousWaitDialog.ShowWaitDialog("Loading Solution...")) { using (var progress = AsynchronousWaitDialog.ShowWaitDialog("Loading Solution...")) {
solution = LoadSolutionFile(fileName, progress); solution = LoadSolutionFile(fileName, progress);
//(openSolution.Preferences as IMementoCapable).SetMemento(solutionProperties);
// try {
// ApplyConfigurationAndReadProjectPreferences();
// } catch (Exception ex) {
// MessageService.ShowException(ex);
// }
this.CurrentSolution = solution; this.CurrentSolution = solution;
} }
@ -263,7 +256,7 @@ namespace ICSharpCode.SharpDevelop.Project
public event EventHandler<SolutionClosingEventArgs> SolutionClosing = delegate { }; public event EventHandler<SolutionClosingEventArgs> SolutionClosing = delegate { };
public event EventHandler<SolutionEventArgs> SolutionClosed = delegate { }; public event EventHandler<SolutionEventArgs> SolutionClosed = delegate { };
public bool CloseSolution(bool allowCancel) public bool CloseSolution(bool allowCancel = true)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
var solution = this.CurrentSolution; var solution = this.CurrentSolution;

Loading…
Cancel
Save