From b7c53722fed485e99431b3875da8f3bd794f6d17 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 8 Aug 2005 18:58:47 +0000 Subject: [PATCH] Copy GacUtil2 to tools directory. Small bugfix for code completion and ErrorList. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@340 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/src/BaseControls/TocPad.cs | 11 ++-- .../Implementations/SearchClassReturnType.cs | 51 +++++++++++++++---- .../Src/Gui/Pads/ErrorList/ErrorList.cs | 1 + .../ParserService/DefaultProjectContent.cs | 17 ------- .../Services/ParserService/IProjectContent.cs | 8 --- src/SharpDevelop.sln | 4 +- src/Tools/GacUtil2/GacUtil2.csproj | 32 ++++++++++++ src/Tools/GacUtil2/GacUtil2.sln | 6 +++ src/Tools/Tools.build | 11 ++++ 9 files changed, 99 insertions(+), 42 deletions(-) create mode 100644 src/Tools/GacUtil2/GacUtil2.csproj create mode 100644 src/Tools/GacUtil2/GacUtil2.sln diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs index a151ea0f7f..64936530a5 100644 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs +++ b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs @@ -191,11 +191,12 @@ namespace HtmlHelp2 private void FakeHelpControl() { - tocControl = null; - Panel nohelpPanel = new Panel(); - Controls.Add(nohelpPanel); - nohelpPanel.Dock = DockStyle.Fill; - nohelpPanel.BorderStyle = BorderStyle.Fixed3D; + tocControl = null; + Label nohelpLabel = new Label(); + nohelpLabel.Dock = DockStyle.Fill; + nohelpLabel.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}"); + nohelpLabel.TextAlign = ContentAlignment.MiddleCenter; + Controls.Add(nohelpLabel); } public void LoadToc() diff --git a/src/Main/Base/Project/Src/Dom/Implementations/SearchClassReturnType.cs b/src/Main/Base/Project/Src/Dom/Implementations/SearchClassReturnType.cs index 97fbbf8121..e332b4ca9c 100644 --- a/src/Main/Base/Project/Src/Dom/Implementations/SearchClassReturnType.cs +++ b/src/Main/Base/Project/Src/Dom/Implementations/SearchClassReturnType.cs @@ -59,23 +59,52 @@ namespace ICSharpCode.SharpDevelop.Dom return declaringClass.GetHashCode() ^ name.GetHashCode(); } + // we need to use a static Dictionary as cache to provide a easy was to clear all cached + // BaseTypes. + // When the cached BaseTypes could not be cleared as soon as the parse information is updated + // (in contrast to a check if the parse information was updated when the base type is needed + // the next time), we can get a memory leak: + // The cached type of a property in Class1 is Class2. Then Class2 is updated, but the property + // in Class1 is not needed again -> the reference causes the GC to keep the old version + // of Class2 in memory. + // The solution is this static cache which is cleared when some parse information updates. + // That way, there can never be any reference to an out-of-date class. + static Dictionary cache; + + static SearchClassReturnType() + { + cache = new Dictionary(); + ParserService.ParserUpdateStepFinished += OnParserUpdateStepFinished; + } + + static void OnParserUpdateStepFinished(object sender, ParserUpdateStepEventArgs e) + { + if (e.Updated) { + // clear the cache completely when the information was updated + lock (cache) { + cache.Clear(); + } + } + } + bool isSearching; - IReturnType cachedBaseType; - int cachedVersion = -1; public override IReturnType BaseType { get { if (isSearching) return null; - if (pc.Version == cachedVersion) - return cachedBaseType; - try { - isSearching = true; - cachedBaseType = pc.SearchType(name, declaringClass, caretLine, caretColumn); - cachedVersion = pc.Version; - return cachedBaseType; - } finally { - isSearching = false; + IReturnType type; + lock (cache) { + if (cache.TryGetValue(this, out type)) + return type; + try { + isSearching = true; + type = pc.SearchType(name, declaringClass, caretLine, caretColumn); + cache[this] = type; + return type; + } finally { + isSearching = false; + } } } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorList.cs b/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorList.cs index f21cf723aa..d4e407a0e0 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorList.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ErrorList/ErrorList.cs @@ -305,6 +305,7 @@ namespace ICSharpCode.SharpDevelop.Gui void UpdateToolstripStatus() { ToolbarService.UpdateToolbar(toolStrip); + ToolbarService.UpdateToolbarText(toolStrip); } void InternalShowResults() diff --git a/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs index 39640ef71f..0d587e7338 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs @@ -37,21 +37,6 @@ namespace ICSharpCode.Core List> namespaces = new List>(); protected XmlDoc xmlDoc = new XmlDoc(); IUsing defaultImports; - int version; - - public int Version { - get { - return version; - } - } - - void IncrementVersion() - { - if (version == int.MaxValue) - version = 1; - else - version += 1; - } public IUsing DefaultImports { get { @@ -205,7 +190,6 @@ namespace ICSharpCode.Core public void AddClassToNamespaceList(IClass addClass) { - IncrementVersion(); lock (namespaces) { AddClassToNamespaceListInternal(addClass); } @@ -319,7 +303,6 @@ namespace ICSharpCode.Core public void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName, bool updateCommentTags) { - IncrementVersion(); if (updateCommentTags) { TaskService.UpdateCommentTags(fileName, parserOutput.TagComments); } diff --git a/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs b/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs index 909ebe945d..5834d784a0 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs @@ -55,14 +55,6 @@ namespace ICSharpCode.Core get; } - /// - /// Gets the version number of the project content. - /// Is incremented whenever a CompilationUnit is updated. - /// - int Version { - get; - } - string GetXmlDocumentation(string memberTag); void AddClassToNamespaceList(IClass addClass); diff --git a/src/SharpDevelop.sln b/src/SharpDevelop.sln index c4f02084f5..20c0fcf41a 100644 --- a/src/SharpDevelop.sln +++ b/src/SharpDevelop.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.336 +# SharpDevelop 2.0.0.339 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}" ProjectSection(SolutionItems) = postProject EndProjectSection @@ -84,6 +84,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "Main\Co EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}" EndProject +Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "Tools\Tools.build", "{2ba4dbc4-a228-45bf-9584-e017d596b45f}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/Tools/GacUtil2/GacUtil2.csproj b/src/Tools/GacUtil2/GacUtil2.csproj new file mode 100644 index 0000000000..41ffab1fb7 --- /dev/null +++ b/src/Tools/GacUtil2/GacUtil2.csproj @@ -0,0 +1,32 @@ + + + Exe + GacUtil2 + GacUtil2 + Debug + AnyCPU + {938FAB27-5DE2-4980-B8AA-1B892F959C63} + + + bin\Debug\ + false + DEBUG;TRACE + + + bin\Release\ + true + TRACE + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Tools/GacUtil2/GacUtil2.sln b/src/Tools/GacUtil2/GacUtil2.sln new file mode 100644 index 0000000000..71d67460eb --- /dev/null +++ b/src/Tools/GacUtil2/GacUtil2.sln @@ -0,0 +1,6 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# SharpDevelop 2.0.0.339 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GacUtil2", "GacUtil2.csproj", "{938FAB27-5DE2-4980-B8AA-1B892F959C63}" +EndProject +Global +EndGlobal diff --git a/src/Tools/Tools.build b/src/Tools/Tools.build index a4f5b66402..8e0c54fe57 100644 --- a/src/Tools/Tools.build +++ b/src/Tools/Tools.build @@ -6,6 +6,8 @@ + + @@ -14,6 +16,15 @@ + + + +