Browse Source

Fixed SD2-911: 'Classes' pad updates its content incorrectly

ParserService does not give the choice whether to raise the ParseInformationUpdated event anymore - the classes pad depends on getting every update notification.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2104 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
acac08d13e
  1. 4
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs
  2. 2
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs
  3. 2
      src/AddIns/Misc/UnitTesting/Src/UnitTestsPad.cs
  4. 7
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs
  5. 2
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ProjectNode.cs
  6. 4
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/FileNode.cs
  7. 9
      src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventHandler.cs
  8. 2
      src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs
  9. 26
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  10. 6
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs
  11. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

4
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs

@ -304,7 +304,7 @@ namespace ICSharpCode.FormsDesigner @@ -304,7 +304,7 @@ namespace ICSharpCode.FormsDesigner
// get new initialize components
string content = viewContent.Document.TextContent;
ParseInformation info = ParserService.ParseFile(viewContent.TextEditorControl.FileName, content, false, true);
ParseInformation info = ParserService.ParseFile(viewContent.TextEditorControl.FileName, content, false);
ICompilationUnit cu = (ICompilationUnit)info.BestCompilationUnit;
foreach (IClass c in cu.Classes) {
if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
@ -329,7 +329,7 @@ namespace ICSharpCode.FormsDesigner @@ -329,7 +329,7 @@ namespace ICSharpCode.FormsDesigner
document = tecp.TextEditorControl.Document;
designerContent = document.TextContent;
}
ParserService.ParseFile(designerFile, designerContent, false, true);
ParserService.ParseFile(designerFile, designerContent, false);
initializeComponents = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
}
using (StringReader r = new StringReader(designerContent)) {

2
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/SecondaryDisplayBinding.cs

@ -95,7 +95,7 @@ namespace ICSharpCode.FormsDesigner @@ -95,7 +95,7 @@ namespace ICSharpCode.FormsDesigner
switch (fileExtension) {
case ".cs":
case ".vb":
ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false, true);
ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false);
if (IsDesignable(info))
return true;

2
src/AddIns/Misc/UnitTesting/Src/UnitTestsPad.cs

@ -209,7 +209,7 @@ namespace ICSharpCode.UnitTesting @@ -209,7 +209,7 @@ namespace ICSharpCode.UnitTesting
void ParseInformationUpdated(object source, ParseInformationEventArgs e)
{
lock (pending) {
ICompilationUnit[] units = new ICompilationUnit[] {e.ParseInformation.BestCompilationUnit as ICompilationUnit, e.CompilationUnit};
ICompilationUnit[] units = new ICompilationUnit[] {e.ParseInformation.MostRecentCompilationUnit as ICompilationUnit, e.CompilationUnit};
pending.Add(units);
}
WorkbenchSingleton.SafeThreadAsyncCall(UpdateParseInfo);

7
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs

@ -106,14 +106,15 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser @@ -106,14 +106,15 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser
}
List<ICompilationUnit[]> pending = new List<ICompilationUnit[]> ();
// running on main thread, invoked by the parser thread when a compilation unit changed
void UpdateThread()
{
lock (pending) {
foreach (ICompilationUnit[] units in pending) {
ICompilationUnit nonNullUnit = units[1] ?? units[0];
foreach (TreeNode node in classBrowserTreeView.Nodes) {
AbstractProjectNode prjNode = node as AbstractProjectNode;
ICompilationUnit nonNullUnit = units[1] ?? units[0];
IProject project = (IProject)nonNullUnit.ProjectContent.Project;
if (prjNode != null && prjNode.Project.IsFileInProject(nonNullUnit.FileName)) {
prjNode.UpdateParseInformation(units[0], units[1]);
}
@ -126,7 +127,7 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser @@ -126,7 +127,7 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser
public void ParserServiceParseInformationUpdated(object sender, ParseInformationEventArgs e)
{
lock (pending) {
pending.Add(new ICompilationUnit[] { e.ParseInformation.BestCompilationUnit as ICompilationUnit, e.CompilationUnit});
pending.Add(new ICompilationUnit[] { e.ParseInformation.MostRecentCompilationUnit as ICompilationUnit, e.CompilationUnit});
}
WorkbenchSingleton.SafeThreadAsyncCall(UpdateThread);
}

2
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ProjectNode.cs

@ -36,6 +36,8 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser @@ -36,6 +36,8 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser
public override void UpdateParseInformation(ICompilationUnit oldUnit, ICompilationUnit unit)
{
LoggingService.Debug("UpdateParseInformation: old=" + oldUnit + " new=" + unit);
Dictionary<string, IClass> classDictionary = new Dictionary<string, IClass>();
Dictionary<string, bool> wasUpdatedDictionary = new Dictionary<string, bool>();

4
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/FileNode.cs

@ -210,10 +210,6 @@ namespace ICSharpCode.SharpDevelop.Project @@ -210,10 +210,6 @@ namespace ICSharpCode.SharpDevelop.Project
Project.Save();
} else if (MessageService.AskQuestion(GetQuestionText("${res:ProjectComponent.ContextMenu.Delete.Question}"))) {
FileService.RemoveFile(FileName, false);
if (IsLink) {
// we need to manually remove the link
Commands.ExcludeFileFromProject.ExcludeFileNode(this);
}
Project.Save();
}
}

9
src/Main/Base/Project/Src/Services/ParserService/ParseInformationEventHandler.cs

@ -24,11 +24,20 @@ namespace ICSharpCode.SharpDevelop @@ -24,11 +24,20 @@ namespace ICSharpCode.SharpDevelop
}
}
/// <summary>
/// Gets the parse information. The new compilation unit has not yet been added to the parse information
/// (but will be immediately after the event was executed, be careful when invoking back to the main thread),
/// you can use this property to get the previous compilation unit.
/// </summary>
public ParseInformation ParseInformation {
get {
return parseInformation;
}
}
/// <summary>
/// The new compilation unit.
/// </summary>
public ICompilationUnit CompilationUnit {
get {
return compilationUnit;

2
src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

@ -243,7 +243,7 @@ namespace ICSharpCode.SharpDevelop @@ -243,7 +243,7 @@ namespace ICSharpCode.SharpDevelop
if ((i % 5) == 2)
StatusBarService.ProgressMonitor.WorkDone = progressStart + i;
ParserService.ParseFile(this, enumerator.CurrentFileName, enumerator.CurrentFileContent, true, false);
ParserService.ParseFile(this, enumerator.CurrentFileName, enumerator.CurrentFileContent, true);
if (!initializing) return;
}

26
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -446,7 +446,7 @@ namespace ICSharpCode.SharpDevelop @@ -446,7 +446,7 @@ namespace ICSharpCode.SharpDevelop
}
int hash = text.GetHashCode();
if (!lastUpdateHash.ContainsKey(fileName) || lastUpdateHash[fileName] != hash) {
parseInformation = ParseFile(fileName, text, !viewContent.IsUntitled, true);
parseInformation = ParseFile(fileName, text, !viewContent.IsUntitled);
lastUpdateHash[fileName] = hash;
updated = true;
}
@ -465,7 +465,7 @@ namespace ICSharpCode.SharpDevelop @@ -465,7 +465,7 @@ namespace ICSharpCode.SharpDevelop
{
string text = ((IEditable)viewContent).Text;
ParseInformation parseInformation = ParseFile(viewContent.IsUntitled ? viewContent.UntitledName : viewContent.FileName,
text, !viewContent.IsUntitled, true);
text, !viewContent.IsUntitled);
if (parseInformation != null && viewContent is IParseInformationListener) {
((IParseInformationListener)viewContent).ParseInformationUpdated(parseInformation);
}
@ -493,7 +493,7 @@ namespace ICSharpCode.SharpDevelop @@ -493,7 +493,7 @@ namespace ICSharpCode.SharpDevelop
public static ParseInformation ParseFile(string fileName, string fileContent)
{
return ParseFile(fileName, fileContent, true, true);
return ParseFile(fileName, fileContent, true);
}
static IProjectContent GetProjectContent(string fileName)
@ -560,12 +560,12 @@ namespace ICSharpCode.SharpDevelop @@ -560,12 +560,12 @@ namespace ICSharpCode.SharpDevelop
}
}
public static ParseInformation ParseFile(string fileName, string fileContent, bool updateCommentTags, bool fireUpdate)
public static ParseInformation ParseFile(string fileName, string fileContent, bool updateCommentTags)
{
return ParseFile(null, fileName, fileContent, updateCommentTags, fireUpdate);
return ParseFile(null, fileName, fileContent, updateCommentTags);
}
public static ParseInformation ParseFile(IProjectContent fileProjectContent, string fileName, string fileContent, bool updateCommentTags, bool fireUpdate)
public static ParseInformation ParseFile(IProjectContent fileProjectContent, string fileName, string fileContent, bool updateCommentTags)
{
if (fileName == null) throw new ArgumentNullException("fileName");
@ -603,14 +603,14 @@ namespace ICSharpCode.SharpDevelop @@ -603,14 +603,14 @@ namespace ICSharpCode.SharpDevelop
if (updateCommentTags) {
TaskService.UpdateCommentTags(fileName, parserOutput.TagComments);
}
return UpdateParseInformation(parserOutput, fileName, updateCommentTags, fireUpdate);
return UpdateParseInformation(parserOutput, fileName, updateCommentTags);
} catch (Exception e) {
MessageService.ShowError(e);
}
return null;
}
public static ParseInformation UpdateParseInformation(ICompilationUnit parserOutput, string fileName, bool updateCommentTags, bool fireEvent)
public static ParseInformation UpdateParseInformation(ICompilationUnit parserOutput, string fileName, bool updateCommentTags)
{
if (!parsings.ContainsKey(fileName)) {
parsings[fileName] = new ParseInformation();
@ -618,12 +618,10 @@ namespace ICSharpCode.SharpDevelop @@ -618,12 +618,10 @@ namespace ICSharpCode.SharpDevelop
ParseInformation parseInformation = parsings[fileName];
if (fireEvent) {
try {
OnParseInformationUpdated(new ParseInformationEventArgs(fileName, parseInformation, parserOutput));
} catch (Exception e) {
MessageService.ShowError(e);
}
try {
OnParseInformationUpdated(new ParseInformationEventArgs(fileName, parseInformation, parserOutput));
} catch (Exception e) {
MessageService.ShowError(e);
}
if (parserOutput.ErrorsDuringCompile) {

6
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

@ -199,6 +199,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -199,6 +199,12 @@ namespace ICSharpCode.SharpDevelop.Refactoring
}
}
// It is possible that a class or member does not have a name (when parsing incomplete class definitions)
// - in that case, we cannot find references.
if (searchedText.Length == 0) {
return;
}
int pos = -1;
int exprPos;
IExpressionFinder expressionFinder = null;

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -466,7 +466,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -466,7 +466,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
ParseInformation parseInfo = ParserService.GetParseInformation(fileName);
if (parseInfo == null) {
parseInfo = ParserService.ParseFile(fileName,
textAreaControl.Document.TextContent, false, false);
textAreaControl.Document.TextContent, false);
}
textAreaControl.Document.FoldingManager.UpdateFoldings(fileName, parseInfo);
UpdateClassMemberBookmarks(parseInfo);

Loading…
Cancel
Save