Browse Source

Add optional "settingsPath" and "domPersistencePath" settings to SharpDevelop.exe.config. These can be used to redirect the settings/code completion cache to different folders, e.g. for running SharpDevelop from a USB stick.

Make XML documentation tooltips work even if the code completion cache is disabled.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2596 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
0acdde0b37
  1. 2
      samples/CSharpCodeCompletion/CodeCompletionProvider.cs
  2. 7
      samples/CSharpCodeCompletion/MainForm.cs
  3. 17
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  4. 8
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/ReflectionProjectContent.cs
  5. 31
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs
  6. 2
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs
  7. 10
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs
  8. 14
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs
  9. 22
      src/Main/StartUp/Project/SharpDevelopMain.cs
  10. 1
      src/Main/StartUp/Project/StartUp.csproj
  11. 15
      src/Main/StartUp/Project/app.template.config

2
samples/CSharpCodeCompletion/CodeCompletionProvider.cs

@ -119,7 +119,7 @@ namespace CSharpEditor
if (MainForm.IsVisualBasic) { if (MainForm.IsVisualBasic) {
finder = new Dom.VBNet.VBExpressionFinder(); finder = new Dom.VBNet.VBExpressionFinder();
} else { } 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); return finder.FindExpression(textArea.Document.TextContent, textArea.Caret.Offset - 1);
} }

7
samples/CSharpCodeCompletion/MainForm.cs

@ -102,9 +102,10 @@ class A
pcRegistry = new Dom.ProjectContentRegistry(); // Default .NET 2.0 registry pcRegistry = new Dom.ProjectContentRegistry(); // Default .NET 2.0 registry
// Persistence caches referenced project contents for faster loading. // Persistence lets SharpDevelop.Dom create a cache file on disk so that
// It also activates loading XML documentation files and caching them // future starts are faster.
// for faster loading and lower memory usage. // It also caches XML documentation files in an on-disk hash table, thus
// reducing memory usage.
pcRegistry.ActivatePersistence(Path.Combine(Path.GetTempPath(), pcRegistry.ActivatePersistence(Path.Combine(Path.GetTempPath(),
"CSharpCodeCompletion")); "CSharpCodeCompletion"));

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

@ -39,23 +39,26 @@ namespace ICSharpCode.SharpDevelop
parser = AddInTree.BuildItems<ParserDescriptor>("/Workspace/Parser", null, false); parser = AddInTree.BuildItems<ParserDescriptor>("/Workspace/Parser", null, false);
registries = AddInTree.BuildItems<ProjectContentRegistryDescriptor>("/Workspace/ProjectContentRegistry", null, false); registries = AddInTree.BuildItems<ProjectContentRegistryDescriptor>("/Workspace/ProjectContentRegistry", null, false);
domPersistencePath = Path.Combine(Path.GetTempPath(), "SharpDevelop" + RevisionClass.MainVersion); if (!string.IsNullOrEmpty(domPersistencePath)) {
#if DEBUG Directory.CreateDirectory(domPersistencePath);
domPersistencePath = Path.Combine(domPersistencePath, "Debug"); defaultProjectContentRegistry.ActivatePersistence(domPersistencePath);
#endif }
Directory.CreateDirectory(domPersistencePath);
defaultProjectContentRegistry.ActivatePersistence(domPersistencePath);
ProjectService.SolutionClosed += ProjectServiceSolutionClosed; ProjectService.SolutionClosed += ProjectServiceSolutionClosed;
} }
} }
/// <summary> /// <summary>
/// Gets the cache directory used for DOM persistence. /// Gets/Sets the cache directory used for DOM persistence.
/// </summary> /// </summary>
public static string DomPersistencePath { public static string DomPersistencePath {
get { get {
return domPersistencePath; return domPersistencePath;
} }
set {
if (parser != null)
throw new InvalidOperationException("Cannot set DomPersistencePath after ParserService was initialized");
domPersistencePath = value;
}
} }
public static ProjectContentRegistry DefaultProjectContentRegistry { public static ProjectContentRegistry DefaultProjectContentRegistry {

8
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/ReflectionProjectContent.cs

@ -124,8 +124,12 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
if (fileName != null && registry.persistence != null) { if (fileName != null) {
this.XmlDoc = XmlDoc.Load(fileName, Path.Combine(registry.persistence.CacheDirectory, "XmlDoc")); if (registry.persistence != null) {
this.XmlDoc = XmlDoc.Load(fileName, Path.Combine(registry.persistence.CacheDirectory, "XmlDoc"));
} else {
this.XmlDoc = XmlDoc.Load(fileName, null);
}
} }
} }

31
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) public static XmlDoc Load(string fileName, string cachePath)
{ {
//LoggingService.Debug("Loading XmlDoc for " + fileName); //LoggingService.Debug("Loading XmlDoc for " + fileName);
Directory.CreateDirectory(cachePath);
string cacheName = cachePath + "/" + Path.GetFileNameWithoutExtension(fileName)
+ "." + fileName.GetHashCode().ToString("x") + ".dat";
XmlDoc doc; XmlDoc doc;
if (File.Exists(cacheName)) { string cacheName = null;
doc = new XmlDoc(); if (cachePath != null) {
if (doc.LoadFromBinary(cacheName, File.GetLastWriteTimeUtc(fileName))) { Directory.CreateDirectory(cachePath);
//LoggingService.Debug("XmlDoc: Load from cache successful"); cacheName = cachePath + "/" + Path.GetFileNameWithoutExtension(fileName)
return doc; + "." + fileName.GetHashCode().ToString("x") + ".dat";
} else { if (File.Exists(cacheName)) {
doc.Dispose(); doc = new XmlDoc();
try { if (doc.LoadFromBinary(cacheName, File.GetLastWriteTimeUtc(fileName))) {
File.Delete(cacheName); //LoggingService.Debug("XmlDoc: Load from cache successful");
} catch {} return doc;
} else {
doc.Dispose();
try {
File.Delete(cacheName);
} catch {}
}
} }
} }
@ -266,7 +269,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return new XmlDoc(); return new XmlDoc();
} }
if (doc.xmlDescription.Count > cacheLength * 2) { if (cachePath != null && doc.xmlDescription.Count > cacheLength * 2) {
LoggingService.Debug("XmlDoc: Creating cache for " + fileName); LoggingService.Debug("XmlDoc: Creating cache for " + fileName);
DateTime date = File.GetLastWriteTimeUtc(fileName); DateTime date = File.GetLastWriteTimeUtc(fileName);
try { try {

2
src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs

@ -46,6 +46,7 @@ namespace ICSharpCode.SharpDevelop.Sda
if (properties.PropertiesName != null) { if (properties.PropertiesName != null) {
startup.PropertiesName = properties.PropertiesName; startup.PropertiesName = properties.PropertiesName;
} }
ParserService.DomPersistencePath = properties.DomPersistencePath;
// disable RTL: translations for the RTL languages are inactive // disable RTL: translations for the RTL languages are inactive
RightToLeftConverter.RightToLeftLanguages = new string[0]; RightToLeftConverter.RightToLeftLanguages = new string[0];
@ -262,3 +263,4 @@ namespace ICSharpCode.SharpDevelop.Sda
} }
} }

10
src/Main/ICSharpCode.SharpDevelop.Sda/Src/StartupSettings.cs

@ -24,6 +24,7 @@ namespace ICSharpCode.SharpDevelop.Sda
string propertiesName; string propertiesName;
string configDirectory; string configDirectory;
string dataDirectory; string dataDirectory;
string domPersistencePath;
string resourceAssemblyName = "SharpDevelop"; string resourceAssemblyName = "SharpDevelop";
internal List<string> addInDirectories = new List<string>(); internal List<string> addInDirectories = new List<string>();
internal List<string> addInFiles = new List<string>(); internal List<string> addInFiles = new List<string>();
@ -120,6 +121,15 @@ namespace ICSharpCode.SharpDevelop.Sda
set { propertiesName = value; } set { propertiesName = value; }
} }
/// <summary>
/// Sets the directory used to store the code completion cache.
/// Use null (default) to disable the code completion cache.
/// </summary>
public string DomPersistencePath {
get { return domPersistencePath; }
set { domPersistencePath = value; }
}
/// <summary> /// <summary>
/// Find AddIns by searching all .addin files recursively in <paramref name="addInDir"/>. /// Find AddIns by searching all .addin files recursively in <paramref name="addInDir"/>.
/// </summary> /// </summary>

14
src/Main/ICSharpCode.SharpDevelop.Sda/Src/WorkbenchSettings.cs

@ -18,7 +18,6 @@ namespace ICSharpCode.SharpDevelop.Sda
public sealed class WorkbenchSettings public sealed class WorkbenchSettings
{ {
bool runOnNewThread = true; bool runOnNewThread = true;
bool useTipOfTheDay;
Collection<string> fileList = new Collection<string>(); Collection<string> fileList = new Collection<string>();
/// <summary> /// <summary>
@ -34,19 +33,6 @@ namespace ICSharpCode.SharpDevelop.Sda
} }
} }
/// <summary>
/// Gets/Sets whether the tip of the day is supported.
/// The default is false.
/// </summary>
public bool UseTipOfTheDay {
get {
return useTipOfTheDay;
}
set {
useTipOfTheDay = value;
}
}
/// <summary> /// <summary>
/// Put files to open at workbench startup into this collection. /// Put files to open at workbench startup into this collection.
/// </summary> /// </summary>

22
src/Main/StartUp/Project/SharpDevelopMain.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using System.Configuration;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -113,8 +114,24 @@ namespace ICSharpCode.SharpDevelop
Assembly exe = typeof(SharpDevelopMain).Assembly; Assembly exe = typeof(SharpDevelopMain).Assembly;
startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), ".."); startup.ApplicationRootPath = Path.Combine(Path.GetDirectoryName(exe.Location), "..");
startup.AllowUserAddIns = true; 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")); startup.AddAddInsFromDirectory(Path.Combine(startup.ApplicationRootPath, "AddIns"));
@ -137,7 +154,6 @@ namespace ICSharpCode.SharpDevelop
WorkbenchSettings workbenchSettings = new WorkbenchSettings(); WorkbenchSettings workbenchSettings = new WorkbenchSettings();
workbenchSettings.RunOnNewThread = false; workbenchSettings.RunOnNewThread = false;
workbenchSettings.UseTipOfTheDay = true;
for (int i = 0; i < fileList.Length; i++) { for (int i = 0; i < fileList.Length; i++) {
workbenchSettings.InitialFileList.Add(fileList[i]); workbenchSettings.InitialFileList.Add(fileList[i]);
} }

1
src/Main/StartUp/Project/StartUp.csproj

@ -42,6 +42,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
</ItemGroup> </ItemGroup>

15
src/Main/StartUp/Project/app.template.config

@ -2,6 +2,7 @@
<configSections> <configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" /> <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections> </configSections>
<runtime> <runtime>
<!-- <!--
@ -39,6 +40,20 @@
<probing privatePath="Tools\NUnit"/> <probing privatePath="Tools\NUnit"/>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
<appSettings>
<!-- Use this configuration setting to store settings in a directory relative to the location
of SharpDevelop.exe instead of the user's profile directory. -->
<!-- <add key="settingsPath" value="..\Settings" /> -->
<!-- Use this setting to specify a different path for the code completion cache.
The cache contains information about referenced assemblies to speed up loading
the information on future SharpDevelop starts. -->
<!-- <add key="domPersistencePath" value="..\DomCache" /> -->
<!-- Use this setting to disable the code completion cache. Code completion will still be
available, but take longer to load and use more RAM. -->
<!-- <add key="domPersistencePath" value="none" /> -->
</appSettings>
<log4net> <log4net>
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"> <appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<mapping> <mapping>

Loading…
Cancel
Save