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 @@ -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);
}

7
samples/CSharpCodeCompletion/MainForm.cs

@ -102,9 +102,10 @@ class A @@ -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"));

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

@ -39,23 +39,26 @@ namespace ICSharpCode.SharpDevelop @@ -39,23 +39,26 @@ namespace ICSharpCode.SharpDevelop
parser = AddInTree.BuildItems<ParserDescriptor>("/Workspace/Parser", null, false);
registries = AddInTree.BuildItems<ProjectContentRegistryDescriptor>("/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;
}
}
/// <summary>
/// Gets the cache directory used for DOM persistence.
/// Gets/Sets the cache directory used for DOM persistence.
/// </summary>
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 {

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

@ -124,8 +124,12 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -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);
}
}
}

31
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/XmlDoc.cs

@ -240,20 +240,23 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -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 @@ -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 {

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

@ -46,6 +46,7 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -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 @@ -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 @@ -24,6 +24,7 @@ namespace ICSharpCode.SharpDevelop.Sda
string propertiesName;
string configDirectory;
string dataDirectory;
string domPersistencePath;
string resourceAssemblyName = "SharpDevelop";
internal List<string> addInDirectories = new List<string>();
internal List<string> addInFiles = new List<string>();
@ -120,6 +121,15 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -120,6 +121,15 @@ namespace ICSharpCode.SharpDevelop.Sda
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>
/// Find AddIns by searching all .addin files recursively in <paramref name="addInDir"/>.
/// </summary>

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

@ -18,7 +18,6 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -18,7 +18,6 @@ namespace ICSharpCode.SharpDevelop.Sda
public sealed class WorkbenchSettings
{
bool runOnNewThread = true;
bool useTipOfTheDay;
Collection<string> fileList = new Collection<string>();
/// <summary>
@ -34,19 +33,6 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -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>
/// Put files to open at workbench startup into this collection.
/// </summary>

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

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@ -113,8 +114,24 @@ namespace ICSharpCode.SharpDevelop @@ -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 @@ -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]);
}

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

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

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

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
<runtime>
<!--
@ -39,6 +40,20 @@ @@ -39,6 +40,20 @@
<probing privatePath="Tools\NUnit"/>
</assemblyBinding>
</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>
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<mapping>

Loading…
Cancel
Save