From 33c72ed32718a410cf34d62ada555774c27b7808 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 8 Jan 2014 23:30:57 +0100 Subject: [PATCH] Fix #227: Class no longer available for code completion when file renamed --- .../Project/Src/CSharpSemanticHighlighter.cs | 2 +- .../ICSharpCode.AvalonEdit/Rendering/TextView.cs | 2 +- src/Main/SharpDevelop/Parser/ParserService.cs | 2 ++ src/Main/SharpDevelop/Parser/ParserServiceEntry.cs | 10 ++++++++-- src/Main/SharpDevelop/Project/Build/BuildEngine.cs | 4 ++-- src/Main/SharpDevelop/Project/ProjectService.cs | 11 ++--------- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs index f2097e94dd..283b7b784d 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs @@ -256,7 +256,7 @@ namespace CSharpBinding if (parseInfo == null) { if (invalidLines != null && !invalidLines.Contains(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) { diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs index 72012a58ff..48311f1280 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs @@ -1027,7 +1027,7 @@ namespace ICSharpCode.AvalonEdit.Rendering if (heightTree.GetIsCollapsed(documentLine.LineNumber)) 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); VisualLineTextSource textSource = new VisualLineTextSource(visualLine) { diff --git a/src/Main/SharpDevelop/Parser/ParserService.cs b/src/Main/SharpDevelop/Parser/ParserService.cs index 177292d2fa..b538c7f5ef 100644 --- a/src/Main/SharpDevelop/Parser/ParserService.cs +++ b/src/Main/SharpDevelop/Parser/ParserService.cs @@ -194,6 +194,7 @@ namespace ICSharpCode.SharpDevelop.Parser { if (project == null) throw new ArgumentNullException("project"); + //SD.Log.Debug("Add " + fileName + " to " + project); var entry = GetFileEntry(fileName, true); entry.AddOwnerProject(project, isLinkedFile); if (startAsyncParse) @@ -204,6 +205,7 @@ namespace ICSharpCode.SharpDevelop.Parser { if (project == null) throw new ArgumentNullException("project"); + //SD.Log.Debug("Remove " + fileName + " from " + project); var entry = GetFileEntry(fileName, false); if (entry != null) entry.RemoveOwnerProject(project); diff --git a/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs b/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs index ae9cfea5ba..f854e8ec94 100644 --- a/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs +++ b/src/Main/SharpDevelop/Parser/ParserServiceEntry.cs @@ -214,8 +214,9 @@ namespace ICSharpCode.SharpDevelop.Parser return new ProjectEntry(parentProject, parseInfo.UnresolvedFile, parseInfo); } else { 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 (!(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: return entries[index]; } @@ -271,6 +272,7 @@ namespace ICSharpCode.SharpDevelop.Parser #region ParseAsync Task runningAsyncParseTask; ITextSourceVersion runningAsyncParseFileContentVersion; + IProject runningAsyncParseProject; bool runningAsyncParseFullInfoRequested; public async Task ParseAsync(ITextSource fileContent, IProject parentProject, CancellationToken cancellationToken) @@ -312,8 +314,9 @@ namespace ICSharpCode.SharpDevelop.Parser int index = FindIndexForProject(parentProject); int versionComparison = CompareVersions(fileContent.Version); 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 (!(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: return Task.FromResult(entries[index]); } @@ -321,6 +324,7 @@ namespace ICSharpCode.SharpDevelop.Parser // Optimization: // if an equivalent task is already running, return that one instead if (runningAsyncParseTask != null && (!requestFullParseInformation || runningAsyncParseFullInfoRequested) + && runningAsyncParseProject == parentProject && runningAsyncParseFileContentVersion.BelongsToSameDocumentAs(fileContent.Version) && runningAsyncParseFileContentVersion.CompareAge(fileContent.Version) == 0) { @@ -338,12 +342,14 @@ namespace ICSharpCode.SharpDevelop.Parser lock (this) { runningAsyncParseTask = null; runningAsyncParseFileContentVersion = null; + runningAsyncParseProject = null; } } }, cancellationToken); if (fileContent != null && fileContent.Version != null && !cancellationToken.CanBeCanceled) { runningAsyncParseTask = task; runningAsyncParseFileContentVersion = fileContent.Version; + runningAsyncParseProject = parentProject; runningAsyncParseFullInfoRequested = requestFullParseInformation; } } diff --git a/src/Main/SharpDevelop/Project/Build/BuildEngine.cs b/src/Main/SharpDevelop/Project/Build/BuildEngine.cs index 2d443f257d..606555f8ec 100644 --- a/src/Main/SharpDevelop/Project/Build/BuildEngine.cs +++ b/src/Main/SharpDevelop/Project/Build/BuildEngine.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Project /// /// The project/solution to build /// The build options that should be used - /// The build feedback sink that receives the build output. + /// 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 /// will ensure that output from two projects building in parallel isn't interleaved. /// The progress monitor that receives build progress. The monitor will be disposed @@ -38,7 +38,7 @@ namespace ICSharpCode.SharpDevelop.Project public static Task BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor) { if (project == null) - throw new ArgumentNullException("solution"); + throw new ArgumentNullException("project"); if (options == null) throw new ArgumentNullException("options"); diff --git a/src/Main/SharpDevelop/Project/ProjectService.cs b/src/Main/SharpDevelop/Project/ProjectService.cs index f129259394..f4a788a578 100644 --- a/src/Main/SharpDevelop/Project/ProjectService.cs +++ b/src/Main/SharpDevelop/Project/ProjectService.cs @@ -137,7 +137,7 @@ namespace ICSharpCode.SharpDevelop.Project if (!CloseSolution(allowCancel: true)) return false; FileUtility.ObservedLoad(OpenSolutionInternal, fileName); - + return currentSolution != null; } @@ -147,13 +147,6 @@ namespace ICSharpCode.SharpDevelop.Project using (var progress = AsynchronousWaitDialog.ShowWaitDialog("Loading Solution...")) { solution = LoadSolutionFile(fileName, progress); - //(openSolution.Preferences as IMementoCapable).SetMemento(solutionProperties); - -// try { -// ApplyConfigurationAndReadProjectPreferences(); -// } catch (Exception ex) { -// MessageService.ShowException(ex); -// } this.CurrentSolution = solution; } @@ -263,7 +256,7 @@ namespace ICSharpCode.SharpDevelop.Project public event EventHandler SolutionClosing = delegate { }; public event EventHandler SolutionClosed = delegate { }; - public bool CloseSolution(bool allowCancel) + public bool CloseSolution(bool allowCancel = true) { SD.MainThread.VerifyAccess(); var solution = this.CurrentSolution;