diff --git a/samples/CSharpCodeCompletion/CodeCompletionProvider.cs b/samples/CSharpCodeCompletion/CodeCompletionProvider.cs index 76465e2061..72a29e6865 100644 --- a/samples/CSharpCodeCompletion/CodeCompletionProvider.cs +++ b/samples/CSharpCodeCompletion/CodeCompletionProvider.cs @@ -119,7 +119,7 @@ namespace CSharpEditor if (MainForm.IsVisualBasic) { finder = new Dom.VBNet.VBExpressionFinder(); } else { - finder = new Dom.CSharp.CSharpExpressionFinder(delegate { return mainForm.parseInformation; }); + finder = new Dom.CSharp.CSharpExpressionFinder(mainForm.parseInformation); } return finder.FindExpression(textArea.Document.TextContent, textArea.Caret.Offset - 1); } diff --git a/samples/CSharpCodeCompletion/MainForm.cs b/samples/CSharpCodeCompletion/MainForm.cs index 25ae52d32c..9a968fb04d 100644 --- a/samples/CSharpCodeCompletion/MainForm.cs +++ b/samples/CSharpCodeCompletion/MainForm.cs @@ -102,9 +102,10 @@ class A pcRegistry = new Dom.ProjectContentRegistry(); // Default .NET 2.0 registry - // Persistence caches referenced project contents for faster loading. - // It also activates loading XML documentation files and caching them - // for faster loading and lower memory usage. + // Persistence lets SharpDevelop.Dom create a cache file on disk so that + // future starts are faster. + // It also caches XML documentation files in an on-disk hash table, thus + // reducing memory usage. pcRegistry.ActivatePersistence(Path.Combine(Path.GetTempPath(), "CSharpCodeCompletion")); diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs index 4f5f0d84cd..531561bf6d 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs @@ -39,23 +39,26 @@ namespace ICSharpCode.SharpDevelop parser = AddInTree.BuildItems("/Workspace/Parser", null, false); registries = AddInTree.BuildItems("/Workspace/ProjectContentRegistry", null, false); - domPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.MainVersion); - #if DEBUG - domPersistencePath = Path.Combine(domPersistencePath, "Debug"); - #endif - Directory.CreateDirectory(domPersistencePath); - defaultProjectContentRegistry.ActivatePersistence(domPersistencePath); + if (!string.IsNullOrEmpty(domPersistencePath)) { + Directory.CreateDirectory(domPersistencePath); + defaultProjectContentRegistry.ActivatePersistence(domPersistencePath); + } ProjectService.SolutionClosed += ProjectServiceSolutionClosed; } } /// - /// Gets the cache directory used for DOM persistence. + /// Gets/Sets the cache directory used for DOM persistence. /// public static string DomPersistencePath { get { return domPersistencePath; } + set { + if (parser != null) + throw new InvalidOperationException("Cannot set DomPersistencePath after ParserService was initialized"); + domPersistencePath = value; + } } public static ProjectContentRegistry DefaultProjectContentRegistry { diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/ReflectionProjectContent.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/ReflectionProjectContent.cs index 1e99a45248..5ce02d0640 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/ReflectionProjectContent.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/ReflectionProjectContent.cs @@ -124,8 +124,12 @@ namespace ICSharpCode.SharpDevelop.Dom } } - if (fileName != null && registry.persistence != null) { - this.XmlDoc = XmlDoc.Load(fileName, Path.Combine(registry.persistence.CacheDirectory, "XmlDoc")); + if (fileName != null) { + if (registry.persistence != null) { + this.XmlDoc = XmlDoc.Load(fileName, Path.Combine(registry.persistence.CacheDirectory, "XmlDoc")); + } else { + this.XmlDoc = XmlDoc.Load(fileName, null); + } } } diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs index 4d26c89b7d..a7dd400a81 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs @@ -240,20 +240,23 @@ namespace ICSharpCode.SharpDevelop.Dom public static XmlDoc Load(string fileName, string cachePath) { //LoggingService.Debug("Loading XmlDoc for " + fileName); - Directory.CreateDirectory(cachePath); - string cacheName = cachePath + "/" + Path.GetFileNameWithoutExtension(fileName) - + "." + fileName.GetHashCode().ToString("x") + ".dat"; XmlDoc doc; - if (File.Exists(cacheName)) { - doc = new XmlDoc(); - if (doc.LoadFromBinary(cacheName, File.GetLastWriteTimeUtc(fileName))) { - //LoggingService.Debug("XmlDoc: Load from cache successful"); - return doc; - } else { - doc.Dispose(); - try { - File.Delete(cacheName); - } catch {} + string cacheName = null; + if (cachePath != null) { + Directory.CreateDirectory(cachePath); + cacheName = cachePath + "/" + Path.GetFileNameWithoutExtension(fileName) + + "." + fileName.GetHashCode().ToString("x") + ".dat"; + if (File.Exists(cacheName)) { + doc = new XmlDoc(); + if (doc.LoadFromBinary(cacheName, File.GetLastWriteTimeUtc(fileName))) { + //LoggingService.Debug("XmlDoc: Load from cache successful"); + return doc; + } else { + doc.Dispose(); + try { + File.Delete(cacheName); + } catch {} + } } } @@ -266,7 +269,7 @@ namespace ICSharpCode.SharpDevelop.Dom return new XmlDoc(); } - if (doc.xmlDescription.Count > cacheLength * 2) { + if (cachePath != null && doc.xmlDescription.Count > cacheLength * 2) { LoggingService.Debug("XmlDoc: Creating cache for " + fileName); DateTime date = File.GetLastWriteTimeUtc(fileName); try { diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs index 32475a060b..179249cd9a 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs @@ -46,6 +46,7 @@ namespace ICSharpCode.SharpDevelop.Sda if (properties.PropertiesName != null) { startup.PropertiesName = properties.PropertiesName; } + ParserService.DomPersistencePath = properties.DomPersistencePath; // disable RTL: translations for the RTL languages are inactive RightToLeftConverter.RightToLeftLanguages = new string[0]; @@ -262,3 +263,4 @@ namespace ICSharpCode.SharpDevelop.Sda } } + diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs index 930983d51c..463b110b07 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs @@ -24,6 +24,7 @@ namespace ICSharpCode.SharpDevelop.Sda string propertiesName; string configDirectory; string dataDirectory; + string domPersistencePath; string resourceAssemblyName = "SharpDevelop"; internal List addInDirectories = new List(); internal List addInFiles = new List(); @@ -120,6 +121,15 @@ namespace ICSharpCode.SharpDevelop.Sda set { propertiesName = value; } } + /// + /// Sets the directory used to store the code completion cache. + /// Use null (default) to disable the code completion cache. + /// + public string DomPersistencePath { + get { return domPersistencePath; } + set { domPersistencePath = value; } + } + /// /// Find AddIns by searching all .addin files recursively in . /// diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs index 8375b582ab..630185009a 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs @@ -18,7 +18,6 @@ namespace ICSharpCode.SharpDevelop.Sda public sealed class WorkbenchSettings { bool runOnNewThread = true; - bool useTipOfTheDay; Collection fileList = new Collection(); /// @@ -34,19 +33,6 @@ namespace ICSharpCode.SharpDevelop.Sda } } - /// - /// Gets/Sets whether the tip of the day is supported. - /// The default is false. - /// - public bool UseTipOfTheDay { - get { - return useTipOfTheDay; - } - set { - useTipOfTheDay = value; - } - } - /// /// Put files to open at workbench startup into this collection. /// diff --git a/src/Main/StartUp/Project/SharpDevelopMain.cs b/src/Main/StartUp/Project/SharpDevelopMain.cs index b462bd6dbc..addb4fd526 100644 --- a/src/Main/StartUp/Project/SharpDevelopMain.cs +++ b/src/Main/StartUp/Project/SharpDevelopMain.cs @@ -6,6 +6,7 @@ // using System; +using System.Configuration; using System.Diagnostics; using System.IO; using System.Reflection; @@ -113,8 +114,24 @@ namespace ICSharpCode.SharpDevelop Assembly exe = typeof(SharpDevelopMain).Assembly; startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); startup.AllowUserAddIns = true; - startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - "ICSharpCode/SharpDevelop3.0"); + + string configDirectory = ConfigurationManager.AppSettings["settingsPath"]; + if (String.IsNullOrEmpty(configDirectory)) { + startup.ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "ICSharpCode/SharpDevelop" + RevisionClass.MainVersion); + } else { + startup.ConfigDirectory = Path.Combine(Path.GetDirectoryName(exe.Location), configDirectory); + } + + startup.DomPersistencePath = ConfigurationManager.AppSettings["domPersistencePath"]; + if (string.IsNullOrEmpty(startup.DomPersistencePath)) { + startup.DomPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.MainVersion); + #if DEBUG + startup.DomPersistencePath = Path.Combine(startup.DomPersistencePath, "Debug"); + #endif + } else if (startup.DomPersistencePath == "none") { + startup.DomPersistencePath = null; + } startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns")); @@ -137,7 +154,6 @@ namespace ICSharpCode.SharpDevelop WorkbenchSettings workbenchSettings = new WorkbenchSettings(); workbenchSettings.RunOnNewThread = false; - workbenchSettings.UseTipOfTheDay = true; for (int i = 0; i < fileList.Length; i++) { workbenchSettings.InitialFileList.Add(fileList[i]); } diff --git a/src/Main/StartUp/Project/StartUp.csproj b/src/Main/StartUp/Project/StartUp.csproj index 20dc590695..45accba64e 100644 --- a/src/Main/StartUp/Project/StartUp.csproj +++ b/src/Main/StartUp/Project/StartUp.csproj @@ -42,6 +42,7 @@ + diff --git a/src/Main/StartUp/Project/app.template.config b/src/Main/StartUp/Project/app.template.config index 08d7523834..08c2a114f5 100644 --- a/src/Main/StartUp/Project/app.template.config +++ b/src/Main/StartUp/Project/app.template.config @@ -2,6 +2,7 @@
+ + + + + + + + +