Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 33c72ed

Browse files
committed
Fix #227: Class no longer available for code completion when file renamed
1 parent 0ba4f20 commit 33c72ed

6 files changed

Lines changed: 16 additions & 15 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ HighlightedLine DoHighlightLine(int lineNumber, IDocumentLine documentLine, Cach
256256
if (parseInfo == null) {
257257
if (invalidLines != null && !invalidLines.Contains(documentLine)) {
258258
invalidLines.Add(documentLine);
259-
Debug.WriteLine("Semantic highlighting for line {0} - marking as invalid", lineNumber);
259+
//Debug.WriteLine("Semantic highlighting for line {0} - marking as invalid", lineNumber);
260260
}
261261

262262
if (cachedLine != null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ VisualLine BuildVisualLine(DocumentLine documentLine,
10271027
if (heightTree.GetIsCollapsed(documentLine.LineNumber))
10281028
throw new InvalidOperationException("Trying to build visual line from collapsed line");
10291029

1030-
Debug.WriteLine("Building line " + documentLine.LineNumber);
1030+
//Debug.WriteLine("Building line " + documentLine.LineNumber);
10311031

10321032
VisualLine visualLine = new VisualLine(this, documentLine);
10331033
VisualLineTextSource textSource = new VisualLineTextSource(visualLine) {

src/Main/SharpDevelop/Parser/ParserService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public void AddOwnerProject(FileName fileName, IProject project, bool startAsync
194194
{
195195
if (project == null)
196196
throw new ArgumentNullException("project");
197+
//SD.Log.Debug("Add " + fileName + " to " + project);
197198
var entry = GetFileEntry(fileName, true);
198199
entry.AddOwnerProject(project, isLinkedFile);
199200
if (startAsyncParse)
@@ -204,6 +205,7 @@ public void RemoveOwnerProject(FileName fileName, IProject project)
204205
{
205206
if (project == null)
206207
throw new ArgumentNullException("project");
208+
//SD.Log.Debug("Remove " + fileName + " from " + project);
207209
var entry = GetFileEntry(fileName, false);
208210
if (entry != null)
209211
entry.RemoveOwnerProject(project);

src/Main/SharpDevelop/Parser/ParserServiceEntry.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ ProjectEntry DoParse(ITextSource fileContent, IProject parentProject, bool fullP
214214
return new ProjectEntry(parentProject, parseInfo.UnresolvedFile, parseInfo);
215215
} else {
216216
if (versionComparison == 0 && index >= 0) {
217+
// Ensure we have parse info for the specified project (entry.UnresolvedFile is null for newly registered projects)
217218
// If full parse info is requested, ensure we have full parse info.
218-
if (!(fullParseInformationRequested && entries[index].CachedParseInformation == null)) {
219+
if (entries[index].UnresolvedFile != null && !(fullParseInformationRequested && entries[index].CachedParseInformation == null)) {
219220
// We already have the requested version parsed, just return it:
220221
return entries[index];
221222
}
@@ -271,6 +272,7 @@ ParseInformation ParseWithExceptionHandling(ITextSource fileContent, bool fullPa
271272
#region ParseAsync
272273
Task<ProjectEntry> runningAsyncParseTask;
273274
ITextSourceVersion runningAsyncParseFileContentVersion;
275+
IProject runningAsyncParseProject;
274276
bool runningAsyncParseFullInfoRequested;
275277

276278
public async Task<ParseInformation> ParseAsync(ITextSource fileContent, IProject parentProject, CancellationToken cancellationToken)
@@ -312,15 +314,17 @@ Task<ProjectEntry> DoParseAsync(ITextSource fileContent, IProject parentProject,
312314
int index = FindIndexForProject(parentProject);
313315
int versionComparison = CompareVersions(fileContent.Version);
314316
if (versionComparison == 0 && index >= 0) {
317+
// Ensure we have parse info for the specified project (entry.UnresolvedFile is null for newly registered projects)
315318
// If full parse info is requested, ensure we have full parse info.
316-
if (!(requestFullParseInformation && entries[index].CachedParseInformation == null)) {
319+
if (entries[index].UnresolvedFile != null && !(requestFullParseInformation && entries[index].CachedParseInformation == null)) {
317320
// We already have the requested version parsed, just return it:
318321
return Task.FromResult(entries[index]);
319322
}
320323
}
321324
// Optimization:
322325
// if an equivalent task is already running, return that one instead
323326
if (runningAsyncParseTask != null && (!requestFullParseInformation || runningAsyncParseFullInfoRequested)
327+
&& runningAsyncParseProject == parentProject
324328
&& runningAsyncParseFileContentVersion.BelongsToSameDocumentAs(fileContent.Version)
325329
&& runningAsyncParseFileContentVersion.CompareAge(fileContent.Version) == 0)
326330
{
@@ -338,12 +342,14 @@ Task<ProjectEntry> DoParseAsync(ITextSource fileContent, IProject parentProject,
338342
lock (this) {
339343
runningAsyncParseTask = null;
340344
runningAsyncParseFileContentVersion = null;
345+
runningAsyncParseProject = null;
341346
}
342347
}
343348
}, cancellationToken);
344349
if (fileContent != null && fileContent.Version != null && !cancellationToken.CanBeCanceled) {
345350
runningAsyncParseTask = task;
346351
runningAsyncParseFileContentVersion = fileContent.Version;
352+
runningAsyncParseProject = parentProject;
347353
runningAsyncParseFullInfoRequested = requestFullParseInformation;
348354
}
349355
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ sealed class BuildEngine
3030
/// </summary>
3131
/// <param name="project">The project/solution to build</param>
3232
/// <param name="options">The build options that should be used</param>
33-
/// <param name="realtimeBuildFeedbackSink">The build feedback sink that receives the build output.
33+
/// <param name="buildFeedbackSink">The build feedback sink that receives the build output.
3434
/// The output is nearly sent "as it comes in": sometimes output must wait because the BuildEngine
3535
/// will ensure that output from two projects building in parallel isn't interleaved.</param>
3636
/// <param name="progressMonitor">The progress monitor that receives build progress. The monitor will be disposed
3737
/// when the build completes.</param>
3838
public static Task<BuildResults> BuildAsync(IBuildable project, BuildOptions options, IBuildFeedbackSink buildFeedbackSink, IProgressMonitor progressMonitor)
3939
{
4040
if (project == null)
41-
throw new ArgumentNullException("solution");
41+
throw new ArgumentNullException("project");
4242
if (options == null)
4343
throw new ArgumentNullException("options");
4444

src/Main/SharpDevelop/Project/ProjectService.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public bool OpenSolutionOrProject(FileName fileName)
137137
if (!CloseSolution(allowCancel: true))
138138
return false;
139139
FileUtility.ObservedLoad(OpenSolutionInternal, fileName);
140-
140+
141141
return currentSolution != null;
142142
}
143143

@@ -147,13 +147,6 @@ void OpenSolutionInternal(FileName fileName)
147147
using (var progress = AsynchronousWaitDialog.ShowWaitDialog("Loading Solution...")) {
148148

149149
solution = LoadSolutionFile(fileName, progress);
150-
//(openSolution.Preferences as IMementoCapable).SetMemento(solutionProperties);
151-
152-
// try {
153-
// ApplyConfigurationAndReadProjectPreferences();
154-
// } catch (Exception ex) {
155-
// MessageService.ShowException(ex);
156-
// }
157150

158151
this.CurrentSolution = solution;
159152
}
@@ -263,7 +256,7 @@ static void LoadProjectInternal(string fileName)
263256
public event EventHandler<SolutionClosingEventArgs> SolutionClosing = delegate { };
264257
public event EventHandler<SolutionEventArgs> SolutionClosed = delegate { };
265258

266-
public bool CloseSolution(bool allowCancel)
259+
public bool CloseSolution(bool allowCancel = true)
267260
{
268261
SD.MainThread.VerifyAccess();
269262
var solution = this.CurrentSolution;

0 commit comments

Comments
 (0)