Browse Source

ICSharpCode.Core: For <MenuItem type="CheckBox">, the checked attribute can now be specified. Doing so enables lazy loading by using that value as default (until the item is clicked). The value can depend on properties stored in the PropertyService.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1930 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
75ccdb10ea
  1. 18
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin
  2. 20
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageOptions.cs
  3. 5
      src/Libraries/NRefactory/Project/Src/Ast/Enums.cs
  4. 10
      src/Libraries/NRefactory/Project/Src/Ast/General/Statement.cs
  5. 4
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  6. 2
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
  7. 2
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  8. 29
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/Gui/MenuCheckBox.cs
  9. 34
      src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

18
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
url = "http://ncover.org"
description = "Code Coverage AddIn for SharpDevelop using NCover">
<Manifest>
<Manifest>
<Identity name = "ICSharpCode.CodeCoverage"/>
<Dependency addin = "ICSharpCode.UnitTesting"/>
</Manifest>
@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
</Runtime>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "CodeCoveragePad"
<Pad id = "CodeCoveragePad"
category = "Tools"
title = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "Bookmarks"
@ -52,9 +52,9 @@ @@ -52,9 +52,9 @@
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<DialogPanel id = "CodeCoverageOptionsPanel"
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "NAnt"
class = "ICSharpCode.CodeCoverage.CodeCoverageOptionsPanel"/>
class = "ICSharpCode.CodeCoverage.CodeCoverageOptionsPanel"/>
</Path>
<Path name = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands">
@ -72,20 +72,22 @@ @@ -72,20 +72,22 @@
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
class = "ICSharpCode.CodeCoverage.CodeCoverageProjectOptionsPanel"/>
</Path>
<Path name = "/SharpDevelop/Workbench/MainMenu/Edit/Format">
<MenuItem id = "ShowCodeCoverage"
insertafter = "Indent"
insertafter = "Indent"
label = "${res:ICSharpCode.CodeCoverage.ShowCoverage}"
checked = "${property:CodeCoverage.Options/CodeCoverageHighlighted??False}"
type = "CheckBox"
class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/>
</Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ContextMenu">
<MenuItem id = "ShowCodeCoverage"
insertafter = "Indent"
insertafter = "Indent"
insertbefore = "FileMode"
label = "${res:ICSharpCode.CodeCoverage.ShowCoverage}"
checked = "${property:CodeCoverage.Options/CodeCoverageHighlighted??False}"
type = "CheckBox"
class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/>
</Path>

20
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageOptions.cs

@ -21,6 +21,8 @@ namespace ICSharpCode.CodeCoverage @@ -21,6 +21,8 @@ namespace ICSharpCode.CodeCoverage
public static readonly string NotVisitedColorProperty = "NotVisitedColor";
public static readonly string NotVisitedForeColorProperty = "NotVisitedForeColor";
public static readonly string NCoverFileNameProperty = "NCoverFileName";
// This name is also referenced by CodeCoverage.addin
public static readonly string CodeCoverageHighlightedProperty = "CodeCoverageHighlighted";
public static readonly string ShowSourceCodePanelProperty = "ShowSourceCodePanel";
public static readonly string ShowVisitCountPanelProperty = "ShowVisitCountPanel";
@ -29,14 +31,14 @@ namespace ICSharpCode.CodeCoverage @@ -29,14 +31,14 @@ namespace ICSharpCode.CodeCoverage
static Properties properties;
static CodeCoverageOptions()
{
{
properties = PropertyService.Get(OptionsProperty, new Properties());
}
public static Properties Properties {
public static Properties Properties {
get {
return properties;
}
}
}
/// <summary>
@ -99,10 +101,10 @@ namespace ICSharpCode.CodeCoverage @@ -99,10 +101,10 @@ namespace ICSharpCode.CodeCoverage
set {
Properties.Set<Color>(VisitedColorProperty, value);
}
}
}
/// <summary>
/// Gets the foreground colour that will be used when highlighting
/// Gets the foreground colour that will be used when highlighting
/// visited code.
/// </summary>
public static Color VisitedForeColor
@ -114,7 +116,7 @@ namespace ICSharpCode.CodeCoverage @@ -114,7 +116,7 @@ namespace ICSharpCode.CodeCoverage
set {
Properties.Set<Color>(VisitedForeColorProperty, value);
}
}
}
/// <summary>
/// Gets the colour that will be used when highlighting code that has not
@ -129,10 +131,10 @@ namespace ICSharpCode.CodeCoverage @@ -129,10 +131,10 @@ namespace ICSharpCode.CodeCoverage
set {
Properties.Set<Color>(NotVisitedColorProperty, value);
}
}
}
/// <summary>
/// Gets the foreground colour that will be used when highlighting
/// Gets the foreground colour that will be used when highlighting
/// code that has not been visited.
/// </summary>
public static Color NotVisitedForeColor
@ -144,6 +146,6 @@ namespace ICSharpCode.CodeCoverage @@ -144,6 +146,6 @@ namespace ICSharpCode.CodeCoverage
set {
Properties.Set<Color>(NotVisitedForeColorProperty, value);
}
}
}
}
}

5
src/Libraries/NRefactory/Project/Src/Ast/Enums.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.Ast @@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.Ast
Internal = 0x0002,
Protected = 0x0004,
Public = 0x0008,
Dim = 0x0010, // VB.NET SPECIFIC
Dim = 0x0010, // VB.NET SPECIFIC, for fields/local variables only
// Scope
Abstract = 0x0010, // == MustOverride/MustInherit
@ -45,6 +45,7 @@ namespace ICSharpCode.NRefactory.Ast @@ -45,6 +45,7 @@ namespace ICSharpCode.NRefactory.Ast
Default = 0x40000, // VB specific
Fixed = 0x80000, // C# specific (fixed size arrays in unsafe structs)
/// <summary>Generated code, not part of parsed code</summary>
Synthetic = 0x200000,
/// <summary>Only for VB properties.</summary>
WriteOnly = 0x400000, // VB specific
@ -236,7 +237,9 @@ namespace ICSharpCode.NRefactory.Ast @@ -236,7 +237,9 @@ namespace ICSharpCode.NRefactory.Ast
PostIncrement,
PostDecrement,
/// <summary>Dereferencing pointer</summary>
Star,
/// <summary>Get address of</summary>
BitWiseAnd
}

10
src/Libraries/NRefactory/Project/Src/Ast/General/Statement.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.NRefactory.Ast @@ -26,7 +26,7 @@ namespace ICSharpCode.NRefactory.Ast
public static Statement CheckNull(Statement statement)
{
return statement == null ? NullStatement.Instance : statement;
return statement ?? NullStatement.Instance;
}
}
@ -51,15 +51,11 @@ namespace ICSharpCode.NRefactory.Ast @@ -51,15 +51,11 @@ namespace ICSharpCode.NRefactory.Ast
static NullStatement nullStatement = new NullStatement();
public override bool IsNull {
get {
return true;
}
get { return true; }
}
public static NullStatement Instance {
get {
return nullStatement;
}
get { return nullStatement; }
}
NullStatement()

4
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

@ -18,7 +18,7 @@ using ICSharpCode.NRefactory.Ast; @@ -18,7 +18,7 @@ using ICSharpCode.NRefactory.Ast;
namespace ICSharpCode.NRefactory.PrettyPrinter
{
public class CSharpOutputVisitor : IOutputAstVisitor
public sealed class CSharpOutputVisitor : IOutputAstVisitor
{
Errors errors = new Errors();
CSharpOutputFormatter outputFormatter;
@ -1077,7 +1077,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1077,7 +1077,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return null;
}
public virtual object VisitYieldStatement(YieldStatement yieldStatement, object data)
public object VisitYieldStatement(YieldStatement yieldStatement, object data)
{
Debug.Assert(yieldStatement != null);
Debug.Assert(yieldStatement.Statement != null);

2
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -41,12 +41,14 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -41,12 +41,14 @@ namespace ICSharpCode.SharpDevelop.Gui
}
// TODO: Debug statements only, remove me
#if DEBUG
if (dockPanel.ActiveDocument != null && !(dockPanel.ActiveDocument is IWorkbenchWindow)) {
if (firstTimeError) {
MessageBox.Show("ActiveDocument was " + dockPanel.ActiveDocument.GetType().FullName);
firstTimeError = false;
}
}
#endif
IWorkbenchWindow window = dockPanel.ActiveDocument as IWorkbenchWindow;
if (window == null || window.IsDisposed) {

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

@ -344,6 +344,8 @@ namespace ICSharpCode.SharpDevelop @@ -344,6 +344,8 @@ namespace ICSharpCode.SharpDevelop
static void ParserUpdateThread()
{
LoggingService.Info("ParserUpdateThread started");
Thread.Sleep(750);
// preload mscorlib, we're going to need it probably
IProjectContent dummyVar = defaultProjectContentRegistry.Mscorlib;

29
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/Gui/MenuCheckBox.cs

@ -21,15 +21,20 @@ namespace ICSharpCode.Core @@ -21,15 +21,20 @@ namespace ICSharpCode.Core
string description = String.Empty;
ICheckableMenuCommand menuCommand = null;
void CreateMenuCommand()
{
if (menuCommand == null) {
try {
menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
} catch (Exception e) {
MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
}
}
}
public ICheckableMenuCommand MenuCommand {
get {
if (menuCommand == null) {
try {
menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
} catch (Exception e) {
MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
}
}
CreateMenuCommand();
return menuCommand;
}
}
@ -80,8 +85,14 @@ namespace ICSharpCode.Core @@ -80,8 +85,14 @@ namespace ICSharpCode.Core
if (codon != null) {
ConditionFailedAction failedAction = codon.GetFailedAction(caller);
this.Visible = failedAction != ConditionFailedAction.Exclude;
if (MenuCommand != null) {
Checked = MenuCommand.IsChecked;
if (menuCommand == null && !string.IsNullOrEmpty(codon.Properties["checked"])) {
Checked = string.Equals(StringParser.Parse(codon.Properties["checked"]),
bool.TrueString, StringComparison.OrdinalIgnoreCase);
} else {
CreateMenuCommand();
if (menuCommand != null) {
Checked = menuCommand.IsChecked;
}
}
}
}

34
src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

@ -226,7 +226,7 @@ namespace ICSharpCode.Core @@ -226,7 +226,7 @@ namespace ICSharpCode.Core
return null;
}
case "PROPERTY":
return PropertyService.Get(propertyName);
return GetProperty(propertyName);
default:
if (propertyObjects.ContainsKey(prefix)) {
return Get(propertyObjects[prefix], propertyName);
@ -236,6 +236,38 @@ namespace ICSharpCode.Core @@ -236,6 +236,38 @@ namespace ICSharpCode.Core
}
}
/// <summary>
/// Allow special syntax to retrieve property values:
/// ${property:PropertyName}
/// ${property:PropertyName??DefaultValue}
/// ${property:ContainerName/PropertyName}
/// ${property:ContainerName/PropertyName??DefaultValue}
/// A container is a Properties instance stored in the PropertyService. This is
/// used by many AddIns to group all their properties into one container.
/// </summary>
static string GetProperty(string propertyName)
{
string defaultValue = "";
int pos = propertyName.LastIndexOf("??");
if (pos >= 0) {
defaultValue = propertyName.Substring(pos + 2);
propertyName = propertyName.Substring(0, pos);
}
pos = propertyName.IndexOf('/');
if (pos >= 0) {
Properties properties = PropertyService.Get(propertyName.Substring(0, pos), new Properties());
propertyName = propertyName.Substring(pos + 1);
pos = propertyName.IndexOf('/');
while (pos >= 0) {
properties = properties.Get(propertyName.Substring(0, pos), new Properties());
propertyName = propertyName.Substring(pos + 1);
}
return properties.Get(propertyName, defaultValue);
} else {
return PropertyService.Get(propertyName, defaultValue);
}
}
static string Get(object obj, string name)
{
Type type = obj.GetType();

Loading…
Cancel
Save