Browse Source

Merged SD 2.1 rev. 2226:2312 to trunk:

- Unit Tests window changes: It now has an All Tests root node when multiple test projects exist in a solution. Added a toolbar button and menu item to run all the tests in the solution independent of the currently selected test. Added a run with code coverage toolbar button.
- Fixed SD2-1123. Code coverage vist count list view is now sortable by column.
- Fixed finding generic code-completion members by their Reflection name - fixes problems with Code analysis line numbers not showing for generic classes.
- Fixed SD2-1275: Searching using an invalid regex shows search in progress dialog
- The LocalizedStringFile property in a WiX project is no longer escaped when the project is saved after making changes in the Application tab of the project options.
- Removed Run All Tests context menu item from Unit Tests window. Code coverage window opened after all tests have been run with code coverage and there were no test failures. No longer using a static NCover runner which was raising events in two RunTestWithCodeCoverageCommand instances (toolbar, context menu) and causing one to try to read a test results file which no longer existed.
- Fixed SD2-1252: Don't steal file associations from Visual Studio
- Fixed SD2-1286: Nested With statements result in stack overflow
- Update to NSvn 1.0.0.2727

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2333 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
bb872596e6
  1. BIN
      AddIns/SharpReport/de/PdfSharp.resources.dll
  2. BIN
      data/resources/StringResources.de.resources
  3. BIN
      data/resources/StringResources.es-mx.resources
  4. BIN
      data/resources/StringResources.es.resources
  5. BIN
      data/resources/StringResources.kr.resources
  6. BIN
      data/resources/StringResources.nl.resources
  7. BIN
      data/resources/StringResources.no.resources
  8. BIN
      data/resources/StringResources.pt.resources
  9. BIN
      data/resources/StringResources.ro.resources
  10. BIN
      data/resources/StringResources.tr.resources
  11. 1
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/ApplicationSettingsPanel.cs
  12. 6
      src/AddIns/Misc/CodeCoverage/CodeCoverage.sln
  13. 17
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin
  14. 2
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj
  15. 8
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs
  16. 36
      src/AddIns/Misc/CodeCoverage/Project/Src/NCoverRunnerSingleton.cs
  17. 23
      src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs
  18. 140
      src/AddIns/Misc/CodeCoverage/Project/Src/SequencePointListViewSorter.cs
  19. 1
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverage.Tests.csproj
  20. 165
      src/AddIns/Misc/CodeCoverage/Test/ListViewSortingTestFixture.cs
  21. 2
      src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.addin
  22. 7
      src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.csproj
  23. 17
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs
  24. 129
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs
  25. 74
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.Designer.cs
  26. 130
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs
  27. 106
      src/AddIns/Misc/UnitTesting/Src/AllTestsTreeNode.cs
  28. 36
      src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs
  29. 122
      src/AddIns/Misc/UnitTesting/Src/TestTreeView.cs
  30. 210
      src/AddIns/Misc/UnitTesting/Test/Tree/MultipleTestProjectsTestFixture.cs
  31. 19
      src/AddIns/Misc/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs
  32. 2
      src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj
  33. 32
      src/AddIns/Misc/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs
  34. 5
      src/AddIns/Misc/UnitTesting/UnitTesting.addin
  35. 1
      src/AddIns/Misc/UnitTesting/UnitTesting.csproj
  36. 254
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  37. 34
      src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs
  38. 26
      src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs
  39. 2
      src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
  40. 8
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceInFilesManager.cs
  41. 12
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs
  42. 2
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/BruteForceSearchStrategy.cs
  43. 10
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/ISearchStrategy.cs
  44. 5
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/RegExSearchStrategy.cs
  45. 2
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/WildcardSearchStrategy.cs
  46. 22
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs
  47. 10
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/IProjectContent.cs
  48. BIN
      src/Main/StartUp/Project/Resources/BitmapResources.resources
  49. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources
  50. 6
      src/Setup/Setup.wxs

BIN
AddIns/SharpReport/de/PdfSharp.resources.dll

Binary file not shown.

BIN
data/resources/StringResources.de.resources

Binary file not shown.

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.kr.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

BIN
data/resources/StringResources.no.resources

Binary file not shown.

BIN
data/resources/StringResources.pt.resources

Binary file not shown.

BIN
data/resources/StringResources.ro.resources

Binary file not shown.

BIN
data/resources/StringResources.tr.resources

Binary file not shown.

1
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/ApplicationSettingsPanel.cs

@ -28,6 +28,7 @@ namespace ICSharpCode.WixBinding @@ -28,6 +28,7 @@ namespace ICSharpCode.WixBinding
ConnectBrowseButton("localizedStringFileBrowseButton", "localizedStringFileTextBox", "${res:ICSharpCode.WixBinding.WixLocalizationFileFilterName} (*.wxl)|*.wxl|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
b = helper.BindString("localizedStringFileTextBox", "LocalizedStringFile");
b.TreatPropertyValueAsLiteral = false;
b.CreateLocationButton("localizedStringFileTextBox");
b = helper.BindEnum<WixOutputType>("outputTypeComboBox", "OutputType");

6
src/AddIns/Misc/CodeCoverage/CodeCoverage.sln

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.1856

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
# SharpDevelop 2.1.0.2312
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}"

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

@ -71,6 +71,23 @@ @@ -71,6 +71,23 @@
</ComplexCondition>
</Path>
<Path name = "/SharpDevelop/Pads/UnitTestsPad/Toolbar">
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="RunningTests"/>
</Not>
</And>
<ToolbarItem id = "RunWithCodeCoverage"
insertbefore = "Stop"
insertafter = "Run"
icon = "CodeCoverage.Icons.16x16.Run"
tooltip = "${res:ICSharpCode.UnitTesting.RunWithCoverage}"
class = "ICSharpCode.CodeCoverage.RunTestWithCodeCoverageCommand"/>
</ComplexCondition>
</Path>
<Path path = "/SharpDevelop/BackendBindings/ProjectOptions/AllManaged">
<DialogPanel id = "CodeCoverage"
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"

2
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj

@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
<Compile Include="Src\CodeCoverageMethodTreeNode.cs" />
<Compile Include="Src\CodeCoverageClassTreeNode.cs" />
<Compile Include="Src\CodeCoverageNamespaceTreeNode.cs" />
<Compile Include="Src\SequencePointListViewSorter.cs" />
<Compile Include="Src\ToggleCodeCoverageCommand.cs" />
<Compile Include="Src\CodeCoverageHighlighter.cs" />
<Compile Include="Src\CodeCoverageTextMarker.cs" />
@ -61,7 +62,6 @@ @@ -61,7 +62,6 @@
<Compile Include="Src\CodeCoverageDisplayItem.cs" />
<Compile Include="Src\ColorPickerComboBox.cs" />
<Compile Include="Src\NCoverRunner.cs" />
<Compile Include="Src\NCoverRunnerSingleton.cs" />
<Compile Include="Src\NCoverExitEventArgs.cs" />
<Compile Include="Src\CodeCoverageProjectOptionsPanel.cs" />
<EmbeddedResource Include="Resources\CodeCoverageProjectOptionsPanel.xfrm" />

8
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs

@ -31,6 +31,7 @@ namespace ICSharpCode.CodeCoverage @@ -31,6 +31,7 @@ namespace ICSharpCode.CodeCoverage
ToolStrip toolStrip;
bool showSourceCodePanel;
bool showVisitCountPanel = true;
SequencePointListViewSorter sequencePointListViewSorter;
public CodeCoverageControl()
{
@ -338,7 +339,7 @@ namespace ICSharpCode.CodeCoverage @@ -338,7 +339,7 @@ namespace ICSharpCode.CodeCoverage
listView.FullRowSelect = true;
listView.HideSelection = false;
listView.ItemActivate += ListViewItemActivate;
visitCountColumnHeader = new ColumnHeader();
visitCountColumnHeader.Text = StringParser.Parse("${res:ICSharpCode.CodeCoverage.VisitCount}");
visitCountColumnHeader.Width = 80;
@ -364,6 +365,9 @@ namespace ICSharpCode.CodeCoverage @@ -364,6 +365,9 @@ namespace ICSharpCode.CodeCoverage
startColumnColumnHeader,
endLineColumnHeader,
endColumnColumnHeader});
// Create custom list view sorter.
sequencePointListViewSorter = new SequencePointListViewSorter(listView);
}
void DisposeListView()
@ -383,6 +387,8 @@ namespace ICSharpCode.CodeCoverage @@ -383,6 +387,8 @@ namespace ICSharpCode.CodeCoverage
listView.ItemActivate -= ListViewItemActivate;
listView.Dispose();
listView = null;
sequencePointListViewSorter.Dispose();
}
void CreateVerticalSplitContainer()

36
src/AddIns/Misc/CodeCoverage/Project/Src/NCoverRunnerSingleton.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Single NCover runner that is used by all commands.
/// </summary>
/// <remarks>
public class NCoverRunnerSingleton
{
static NCoverRunner runner;
NCoverRunnerSingleton()
{
}
/// <summary>
/// Gets the <see cref="NCoverRunner"/> instance.
/// </summary>
public static NCoverRunner Runner {
get {
if (runner == null) {
runner = new NCoverRunner();
}
return runner;
}
}
}
}

23
src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs

@ -24,16 +24,14 @@ namespace ICSharpCode.CodeCoverage @@ -24,16 +24,14 @@ namespace ICSharpCode.CodeCoverage
public class RunTestWithCodeCoverageCommand : AbstractRunTestCommand
{
static MessageViewCategory category;
static NCoverRunner runner;
NCoverRunner runner;
string ncoverFileName;
public RunTestWithCodeCoverageCommand()
{
if (runner == null) {
runner = NCoverRunnerSingleton.Runner;
runner.NCoverExited += new NCoverExitEventHandler(NCoverExited);
runner.OutputLineReceived += new LineReceivedEventHandler(OutputLineReceived);
}
runner = new NCoverRunner();
runner.NCoverExited += new NCoverExitEventHandler(NCoverExited);
runner.OutputLineReceived += new LineReceivedEventHandler(OutputLineReceived);
}
protected override void RunTests(UnitTestApplicationStartHelper helper)
@ -65,6 +63,17 @@ namespace ICSharpCode.CodeCoverage @@ -65,6 +63,17 @@ namespace ICSharpCode.CodeCoverage
}
}
/// <summary>
/// Shows the code coverage results window only if there were no
/// test failures.
/// </summary>
protected override void OnAfterRunTests()
{
if (!TaskService.HasCriticalErrors(false)) {
ShowPad(WorkbenchSingleton.Workbench.GetPad(typeof(CodeCoveragePad)));
}
}
/// <summary>
/// Gets the message view output window.
/// </summary>
@ -126,8 +135,8 @@ namespace ICSharpCode.CodeCoverage @@ -126,8 +135,8 @@ namespace ICSharpCode.CodeCoverage
{
System.Diagnostics.Debug.Assert(e.Error.Length == 0);
WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished);
DisplayCoverageResults(runner.CoverageResultsFileName);
WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished);
}
void OutputLineReceived(object sender, LineReceivedEventArgs e)

140
src/AddIns/Misc/CodeCoverage/Project/Src/SequencePointListViewSorter.cs

@ -0,0 +1,140 @@ @@ -0,0 +1,140 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;
using System.Windows.Forms;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Sorts the list view that contains code coverage sequence
/// points.
/// </summary>
public class SequencePointListViewSorter : IComparer, IDisposable
{
ListView listView;
int column = -1;
SortOrder sortOrder = SortOrder.None;
const int VisitCountColumn = 0;
const int SequencePointLineColumn = 1;
const int SequencePointStartColumnColumn = 2;
const int SequencePointEndLineColumn = 3;
const int SequencePointEndColumnColumn = 4;
public SequencePointListViewSorter(ListView listView)
{
this.listView = listView;
listView.ListViewItemSorter = this;
listView.ColumnClick += ListViewColumnClick;
}
public void Dispose()
{
if (listView != null) {
listView.ColumnClick -= ListViewColumnClick;
}
}
/// <summary>
/// Compares two list view items and sorts them according
/// to the currently sorted column.
/// </summary>
public int Compare(object x, object y)
{
CodeCoverageSequencePoint lhs = null;
CodeCoverageSequencePoint rhs = null;
ListViewItem item = x as ListViewItem;
if (item != null) {
lhs = item.Tag as CodeCoverageSequencePoint;
}
item = y as ListViewItem;
if (item != null) {
rhs = item.Tag as CodeCoverageSequencePoint;
}
if (lhs != null && rhs != null) {
return Compare(lhs, rhs);
}
return 0;
}
/// <summary>
/// Sorts the list view by the specified column.
/// </summary>
public void Sort(int column)
{
if (this.column == column) {
ToggleSortOrder();
} else {
sortOrder = SortOrder.Ascending;
}
this.column = column;
listView.Sort();
}
/// <summary>
/// Compares two code coverage sequence points based on the
/// currently sorted column and sort order.
/// </summary>
int Compare(CodeCoverageSequencePoint x, CodeCoverageSequencePoint y)
{
int result = 0;
switch (column) {
case VisitCountColumn:
result = x.VisitCount - y.VisitCount;
break;
case SequencePointLineColumn:
result = x.Line - y.Line;
break;
case SequencePointStartColumnColumn:
result = x.Column - y.Column;
break;
case SequencePointEndLineColumn:
result = x.EndLine - y.EndLine;
break;
case SequencePointEndColumnColumn:
result = x.EndColumn - y.EndColumn;
break;
}
// Sort by secondary sort column?
if (result == 0 && column != SequencePointLineColumn) {
result = x.Line - y.Line;
}
if (sortOrder == SortOrder.Descending) {
return -result;
}
return result;
}
/// <summary>
/// Switches the sort order from ascending to descending
/// and vice versa.
/// </summary>
void ToggleSortOrder()
{
if (sortOrder == SortOrder.Ascending) {
sortOrder = SortOrder.Descending;
} else {
sortOrder = SortOrder.Ascending;
}
}
/// <summary>
/// User clicked a column header so sort that column.
/// </summary>
void ListViewColumnClick(object source, ColumnClickEventArgs e)
{
Sort(e.Column);
}
}
}

1
src/AddIns/Misc/CodeCoverage/Test/CodeCoverage.Tests.csproj

@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
<Compile Include="CodeCoverageResultsTestFixture.cs" />
<Compile Include="CodeCoverageTreeViewTestFixture.cs" />
<Compile Include="DerivedCodeCoverageTreeView.cs" />
<Compile Include="ListViewSortingTestFixture.cs" />
<Compile Include="ModuleVisitedSequencePointsTestFixture.cs" />
<Compile Include="AddCodeCoverageMarkersTestFixture.cs" />
<Compile Include="MockDocument.cs" />

165
src/AddIns/Misc/CodeCoverage/Test/ListViewSortingTestFixture.cs

@ -0,0 +1,165 @@ @@ -0,0 +1,165 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Forms;
using ICSharpCode.CodeCoverage;
using NUnit.Framework;
namespace ICSharpCode.CodeCoverage.Tests
{
/// <summary>
/// Tests the sorting of the list view that shows
/// the code coverage sequence points (visit counts, etc).
/// Here we are not actually using the real list view, but
/// just a list view which has the same number of columns.
/// Eventually the sorter class will be replaced in
/// SharpDevelop 3.0 with the generic sorting classes.
/// </summary>
[TestFixture]
public class ListViewSortingTestFixture
{
ListView listView;
CodeCoverageSequencePoint firstSequencePoint;
CodeCoverageSequencePoint secondSequencePoint;
SequencePointListViewSorter sorter;
const int VisitCountColumn = 0;
const int SequencePointLineColumn = 1;
const int SequencePointStartColumnColumn = 2;
const int SequencePointEndLineColumn = 3;
const int SequencePointEndColumnColumn = 4;
[SetUp]
public void SetUp()
{
listView = new ListView();
sorter = new SequencePointListViewSorter(listView);
listView.Columns.Add("Visit Count");
listView.Columns.Add("Line");
listView.Columns.Add("Column");
listView.Columns.Add("End Line");
listView.Columns.Add("End Column");
// Add first sequence point.
firstSequencePoint = new CodeCoverageSequencePoint(String.Empty, 1, 5, 1, 5, 10);
ListViewItem item = new ListViewItem("First");
item.Tag = firstSequencePoint;
listView.Items.Add(item);
// Add second sequence point.
secondSequencePoint = new CodeCoverageSequencePoint(String.Empty, 0, 10, 2, 10, 8);
item = new ListViewItem("Second");
item.Tag = secondSequencePoint;
listView.Items.Add(item);
// Need to create the control's handle otherwise
// the list view will not sort.
listView.CreateControl();
}
[TearDown]
public void TearDown()
{
listView.Dispose();
}
[Test]
public void InitialOrderSameAsOrderAdded()
{
Assert.AreSame(firstSequencePoint, listView.Items[0].Tag);
Assert.AreSame(secondSequencePoint, listView.Items[1].Tag);
}
[Test]
public void SortVisitCountColumn()
{
sorter.Sort(VisitCountColumn);
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag);
}
[Test]
public void SortVisitCountColumnTwice()
{
sorter.Sort(VisitCountColumn);
sorter.Sort(VisitCountColumn);
Assert.AreSame(firstSequencePoint, listView.Items[0].Tag);
}
[Test]
public void SortLineColumnTwice()
{
sorter.Sort(SequencePointLineColumn);
sorter.Sort(SequencePointLineColumn);
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag);
}
[Test]
public void SortStartColumnTwice()
{
sorter.Sort(SequencePointStartColumnColumn);
sorter.Sort(SequencePointStartColumnColumn);
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag);
}
[Test]
public void SortEndLineTwice()
{
sorter.Sort(SequencePointEndLineColumn);
sorter.Sort(SequencePointEndLineColumn);
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag);
}
[Test]
public void SortEndColumn()
{
sorter.Sort(SequencePointEndColumnColumn);
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag);
}
[Test]
public void CompareNulls()
{
Assert.AreEqual(0, sorter.Compare(null, null));
}
[Test]
public void CompareNullRhs()
{
Assert.AreEqual(0, sorter.Compare(null, new ListViewItem()));
}
[Test]
public void CompareTwoListViewItemsWithNoTags()
{
sorter.Sort(VisitCountColumn);
Assert.AreEqual(0, sorter.Compare(new ListViewItem(), new ListViewItem()));
}
[Test]
public void CompareRhsListViewItemWithNoTag()
{
sorter.Sort(VisitCountColumn);
Assert.AreEqual(0, sorter.Compare(listView.Items[0], new ListViewItem()));
}
[Test]
public void SecondarySortByLineWhenVisitCountSame()
{
sorter.Sort(VisitCountColumn);
CodeCoverageSequencePoint pt1 = new CodeCoverageSequencePoint(String.Empty, 0, 1, 0, 0, 0);
CodeCoverageSequencePoint pt2 = new CodeCoverageSequencePoint(String.Empty, 0, 2, 0, 0, 0);
ListViewItem item1 = new ListViewItem();
item1.Tag = pt1;
ListViewItem item2 = new ListViewItem();
item2.Tag = pt2;
Assert.AreEqual(-1, sorter.Compare(item1, item2));
}
}
}

2
src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.addin

@ -73,12 +73,14 @@ @@ -73,12 +73,14 @@
text = "SharpDevelop 1.x ${res:ICSharpCode.FiletypeRegisterer.Project}"/>
</Path>
<!--
<Path name = "/Workspace/Autostart">
<Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup??False}" equals = "True">
<Class id = "RegisterFiletypes"
class = "ICSharpCode.FiletypeRegisterer.RegisterFiletypesCommand"/>
</Condition>
</Path>
-->
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/UIOptions">
<DialogPanel id = "RegisterFiletypes"

7
src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.csproj

@ -43,9 +43,6 @@ @@ -43,9 +43,6 @@
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\RegisterFiletypesCommand.cs" />
<Compile Include="Src\RegisterFiletypesPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<None Include="FiletypeRegisterer.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@ -77,6 +74,10 @@ @@ -77,6 +74,10 @@
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Src\RegisterFiletypesPanel.cs" />
<Compile Include="Src\RegisterFiletypesPanel.Designer.cs">
<DependentUpon>RegisterFiletypesPanel.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

17
src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs

@ -18,14 +18,12 @@ namespace ICSharpCode.FiletypeRegisterer @@ -18,14 +18,12 @@ namespace ICSharpCode.FiletypeRegisterer
string id;
string icon;
string text;
bool isDefault;
public FiletypeAssociation(string id, string icon, string text, bool isDefault)
public FiletypeAssociation(string id, string icon, string text)
{
this.id = id;
this.icon = icon;
this.text = text;
this.isDefault = isDefault;
}
public string Extension {
@ -45,12 +43,6 @@ namespace ICSharpCode.FiletypeRegisterer @@ -45,12 +43,6 @@ namespace ICSharpCode.FiletypeRegisterer
return text;
}
}
public bool IsDefault {
get {
return isDefault;
}
}
}
/// <summary>
@ -65,10 +57,6 @@ namespace ICSharpCode.FiletypeRegisterer @@ -65,10 +57,6 @@ namespace ICSharpCode.FiletypeRegisterer
/// <attribute name="text" use="required">
/// The description text.
/// </attribute>
/// <attribute name="autoRegister" use="optional">
/// Boolean value that specifies if the file type is registered on every startup, even if another
/// application has already registered it. Default=false
/// </attribute>
/// <returns>
/// A FiletypeAssociation describing the specified values.
/// </returns>
@ -101,8 +89,7 @@ namespace ICSharpCode.FiletypeRegisterer @@ -101,8 +89,7 @@ namespace ICSharpCode.FiletypeRegisterer
{
return new FiletypeAssociation(codon.Id,
StringParser.Parse(codon.Properties["icon"]),
StringParser.Parse(codon.Properties["text"]),
bool.TrueString.Equals(codon.Properties["autoRegister"], StringComparison.OrdinalIgnoreCase));
StringParser.Parse(codon.Properties["text"]));
}
}
}

129
src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs

@ -16,67 +16,29 @@ using Microsoft.Win32; @@ -16,67 +16,29 @@ using Microsoft.Win32;
namespace ICSharpCode.FiletypeRegisterer {
public class RegisterFiletypesCommand : AbstractCommand
public static class RegisterFiletypesCommand
{
readonly public static string uiFiletypesProperty = "SharpDevelop.Filetypes";
// used in .addin file
readonly public static string uiRegisterStartupProperty = "SharpDevelop.FiletypesRegisterStartup";
const int SHCNE_ASSOCCHANGED = 0x08000000;
const int SHCNF_IDLIST = 0x0;
public static string GetDefaultExtensions(List<FiletypeAssociation> list)
public static void RegisterToSharpDevelop(FiletypeAssociation type)
{
StringBuilder b = new StringBuilder();
foreach (FiletypeAssociation a in list) {
if (a.IsDefault) {
if (b.Length > 0)
b.Append('|');
b.Append(a.Extension);
}
}
return b.ToString();
string mainExe = Assembly.GetEntryAssembly().Location;
RegisterFiletype(type.Extension,
type.Text,
'"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"",
Path.GetFullPath(type.Icon));
}
public override void Run()
public static bool IsRegisteredToSharpDevelop(string extension)
{
List<FiletypeAssociation> list = FiletypeAssociationDoozer.GetList();
string openCommand = GetOpenCommand(extension);
// register Combine and Project by default
RegisterFiletypes(list, PropertyService.Get(uiFiletypesProperty, GetDefaultExtensions(list)));
if (string.IsNullOrEmpty(openCommand))
return false;
RegisterUnknownFiletypes(list);
string mainExe = Assembly.GetEntryAssembly().Location;
return openCommand.StartsWith(mainExe) || openCommand.StartsWith('"' + mainExe);
}
public static void RegisterFiletypes(List<FiletypeAssociation> allTypes, string types)
{
string[] singleTypes = types.Split('|');
string mainExe = Assembly.GetEntryAssembly().Location;
foreach (FiletypeAssociation type in allTypes) {
if (Array.IndexOf(singleTypes, type.Extension) >= 0) {
RegisterFiletype(type.Extension,
type.Text,
'"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"",
Path.GetFullPath(type.Icon));
}
}
}
public static void RegisterUnknownFiletypes(List<FiletypeAssociation> allTypes)
{
string mainExe = Assembly.GetEntryAssembly().Location;
string resPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes") + Path.DirectorySeparatorChar;
foreach (FiletypeAssociation type in allTypes) {
if (!IsRegisteredFileType(type.Extension)) {
RegisterFiletype(type.Extension,
type.Text,
'"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"",
Path.GetFullPath(type.Icon));
}
}
}
const string explorerFileExts = @"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts";
public static bool IsRegisteredFileType(string extension)
{
@ -89,11 +51,41 @@ namespace ICSharpCode.FiletypeRegisterer { @@ -89,11 +51,41 @@ namespace ICSharpCode.FiletypeRegisterer {
// registry access might be denied
}
try {
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes\\." + extension)) {
return key != null;
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(explorerFileExts + "\\." + extension)) {
if (key != null)
return true;
}
} catch (System.Security.SecurityException) {
return false;
// registry access might be denied
}
return false;
}
static string GetOpenCommand(string extension)
{
try {
string clsKeyName = null;
using (RegistryKey extKey = Registry.CurrentUser.OpenSubKey(explorerFileExts + "\\." + extension)) {
if (extKey != null)
clsKeyName = (string)extKey.GetValue("Progid", "");
}
if (clsKeyName == null) {
using (RegistryKey extKey = Registry.ClassesRoot.OpenSubKey("." + extension)) {
if (extKey != null)
clsKeyName = (string)extKey.GetValue("", "");
else
return null;
}
}
using (RegistryKey cmdKey = Registry.ClassesRoot.OpenSubKey(clsKeyName + "\\shell\\open\\command")) {
if (cmdKey != null)
return (string)cmdKey.GetValue("", "");
else
return null;
}
} catch (System.Security.SecurityException) {
// registry access might be denied
return null;
}
}
@ -106,9 +98,7 @@ namespace ICSharpCode.FiletypeRegisterer { @@ -106,9 +98,7 @@ namespace ICSharpCode.FiletypeRegisterer {
RegisterFiletype(Registry.CurrentUser.CreateSubKey("Software\\Classes"), extension, description, command, icon);
} catch {}
}
try {
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
} catch {}
NotifyShellAfterChanges();
}
static void RegisterFiletype(RegistryKey rootKey, string extension, string description, string command, string icon)
@ -123,6 +113,14 @@ namespace ICSharpCode.FiletypeRegisterer { @@ -123,6 +113,14 @@ namespace ICSharpCode.FiletypeRegisterer {
extKey.SetValue("", "SD." + extension + "file");
extKey.Close();
try {
extKey = Registry.CurrentUser.OpenSubKey(explorerFileExts + "\\." + extension, true);
if (extKey != null) {
extKey.DeleteValue("Progid");
extKey.Close();
}
} catch {}
clsKey = rootKey.CreateSubKey("SD." + extension + "file");
@ -140,9 +138,7 @@ namespace ICSharpCode.FiletypeRegisterer { @@ -140,9 +138,7 @@ namespace ICSharpCode.FiletypeRegisterer {
try {
UnRegisterFiletype(extension, Registry.CurrentUser.CreateSubKey("Software\\Classes"));
} catch {} // catch CreateSubKey(Software\Classes)-exceptions
try {
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
} catch {}
NotifyShellAfterChanges();
}
static void UnRegisterFiletype(string extension, RegistryKey root)
@ -173,5 +169,16 @@ namespace ICSharpCode.FiletypeRegisterer { @@ -173,5 +169,16 @@ namespace ICSharpCode.FiletypeRegisterer {
[System.Runtime.InteropServices.DllImport("shell32.dll")]
static extern void SHChangeNotify(int wEventId, int uFlags, IntPtr dwItem1, IntPtr dwItem2);
/// <summary>
/// Notify Windows explorer that shortcut icons have changed.
/// </summary>
static void NotifyShellAfterChanges()
{
const int SHCNE_ASSOCCHANGED = 0x08000000;
const int SHCNF_IDLIST = 0x0;
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
}
}
}

74
src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.Designer.cs generated

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
namespace ICSharpCode.FiletypeRegisterer
{
partial class RegisterFiletypesPanel
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the control.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.captionLabel = new System.Windows.Forms.Label();
this.fileTypesListBox = new System.Windows.Forms.CheckedListBox();
this.SuspendLayout();
//
// captionLabel
//
this.captionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.captionLabel.Location = new System.Drawing.Point(3, 0);
this.captionLabel.Name = "captionLabel";
this.captionLabel.Size = new System.Drawing.Size(328, 23);
this.captionLabel.TabIndex = 0;
this.captionLabel.Text = "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.RegisterFiletypesPanel.Ca" +
"ptionLabel}";
//
// fileTypesListBox
//
this.fileTypesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.fileTypesListBox.IntegralHeight = false;
this.fileTypesListBox.Location = new System.Drawing.Point(3, 26);
this.fileTypesListBox.Name = "fileTypesListBox";
this.fileTypesListBox.Size = new System.Drawing.Size(328, 299);
this.fileTypesListBox.TabIndex = 1;
//
// RegisterFiletypesPanel
//
this.Controls.Add(this.fileTypesListBox);
this.Controls.Add(this.captionLabel);
this.Name = "RegisterFiletypesPanel";
this.Size = new System.Drawing.Size(334, 328);
this.ResumeLayout(false);
}
private System.Windows.Forms.CheckedListBox fileTypesListBox;
private System.Windows.Forms.Label captionLabel;
}
}

130
src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs

@ -1,15 +1,12 @@ @@ -1,15 +1,12 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Georg Brandl" email="g.brandl@gmx.net"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
// created on 16.11.2002 at 21:14
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
@ -19,108 +16,57 @@ using ICSharpCode.SharpDevelop.Gui; @@ -19,108 +16,57 @@ using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.FiletypeRegisterer
{
class RegisterFiletypesPanel : AbstractOptionPanel {
ListView list = new ListView();
Label capLbl = new Label();
CheckBox regChk = new CheckBox();
Hashtable wasChecked = new Hashtable();
List<FiletypeAssociation> allTypes;
public RegisterFiletypesPanel()
public partial class RegisterFiletypesPanel : AbstractOptionPanel
{
sealed class ListEntry
{
allTypes = FiletypeAssociationDoozer.GetList();
internal readonly FiletypeAssociation Association;
internal readonly bool InitiallyChecked;
// Initialize dialog controls
InitializeComponent();
public ListEntry(FiletypeAssociation association)
{
this.Association = association;
this.InitiallyChecked = RegisterFiletypesCommand.IsRegisteredToSharpDevelop(association.Extension);
}
// Set previous values
SelectFiletypes(PropertyService.Get(RegisterFiletypesCommand.uiFiletypesProperty, RegisterFiletypesCommand.GetDefaultExtensions(allTypes)));
regChk.Checked = PropertyService.Get(RegisterFiletypesCommand.uiRegisterStartupProperty, false);
}
public override bool ReceiveDialogMessage(DialogMessage message)
{
if (message == DialogMessage.OK) {
UnRegisterFiletypes();
RegisterFiletypesCommand.RegisterFiletypes(allTypes, SelectedFiletypes);
PropertyService.Set(RegisterFiletypesCommand.uiFiletypesProperty, SelectedFiletypes);
PropertyService.Set(RegisterFiletypesCommand.uiRegisterStartupProperty, regChk.Checked);
public override string ToString()
{
return Association.Text + " (." + Association.Extension + ")";
}
return true;
}
string SelectedFiletypes
public RegisterFiletypesPanel()
{
get {
try {
string ret = "";
foreach(ListViewItem lv in list.Items) {
if(lv.Checked) ret += (string)lv.Tag + "|";
}
return ret;
} catch {
return "";
}
}
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
captionLabel.Text = StringParser.Parse(captionLabel.Text);
}
void UnRegisterFiletypes()
public override void LoadPanelContents()
{
foreach(ListViewItem lv in list.Items) {
if((!lv.Checked) && wasChecked.Contains((string)lv.Tag)) {
RegisterFiletypesCommand.UnRegisterFiletype((string)lv.Tag);
}
foreach (FiletypeAssociation assoc in FiletypeAssociationDoozer.GetList()) {
ListEntry entry = new ListEntry(assoc);
fileTypesListBox.Items.Add(entry, entry.InitiallyChecked);
}
}
void SelectFiletypes(string types) {
string[] singleTypes = types.Split('|');
foreach(string str in singleTypes) {
wasChecked[str] = true;
foreach(ListViewItem lv in list.Items) {
if(str == (string)lv.Tag) {
lv.Checked = true;
public override bool StorePanelContents()
{
for (int i = 0; i < fileTypesListBox.Items.Count; i++) {
bool newChecked = fileTypesListBox.GetItemChecked(i);
ListEntry entry = (ListEntry)fileTypesListBox.Items[i];
if (entry.InitiallyChecked != newChecked) {
if (newChecked) {
RegisterFiletypesCommand.RegisterToSharpDevelop(entry.Association);
} else {
RegisterFiletypesCommand.UnRegisterFiletype(entry.Association.Extension);
}
}
}
}
void InitializeComponent()
{
capLbl.Location = new Point(8, 8);
capLbl.Size = new Size(136, 16);
capLbl.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
capLbl.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.RegisterFiletypesPanel.CaptionLabel}");
list.Location = new Point(8, 30);
list.Size = new Size(136, 250);
list.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
list.View = View.List;
list.CheckBoxes = true;
FillList(list);
regChk.Location = new Point(8, 300);
regChk.Size = new Size(136, 20);
regChk.Anchor = capLbl.Anchor;
regChk.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.RegisterFiletypesPanel.RegisterCheckBox}");
this.Controls.AddRange(new Control[] {capLbl, list, regChk});
}
void FillList(ListView list)
{
foreach (FiletypeAssociation type in allTypes) {
ListViewItem lv;
lv = new ListViewItem(type.Text + " (." + type.Extension + ")");
lv.Tag = type.Extension;
list.Items.Add(lv);
}
return true;
}
}
}

106
src/AddIns/Misc/UnitTesting/Src/AllTestsTreeNode.cs

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
namespace ICSharpCode.UnitTesting
{
/// <summary>
/// All Tests root tree node that is added to the test tree when the
/// solution has multiple test projects.
/// </summary>
public class AllTestsTreeNode : TestTreeNode
{
public AllTestsTreeNode()
: base(null, StringParser.Parse("${res:ICSharpCode.UnitTesting.AllTestsTreeNode.Text}"))
{
}
/// <summary>
/// Raised when the all tests tree node is disposed.
/// </summary>
public event EventHandler Disposed;
/// <summary>
/// Disposes this tree node.
/// </summary>
public override void Dispose()
{
base.Dispose();
if (Disposed != null) {
Disposed(this, new EventArgs());
}
}
/// <summary>
/// Adds a new project node as a child of the All Tests node.
/// </summary>
public void AddProjectNode(TestProjectTreeNode node)
{
node.AddTo(this);
node.ImageIndexChanged += TestProjectTreeNodeImageIndexChanged;
}
/// <summary>
/// Removes the project node.
/// </summary>
public void RemoveProjectNode(TestProjectTreeNode node)
{
if (Nodes.Contains(node)) {
node.ImageIndexChanged -= TestProjectTreeNodeImageIndexChanged;
node.Remove();
}
}
void TestProjectTreeNodeImageIndexChanged(object source, EventArgs e)
{
UpdateImageListIndex();
}
/// <summary>
/// Sets the All Tests image index based on the current image
/// indexes of the child project tree nodes.
/// </summary>
void UpdateImageListIndex()
{
int ignored = 0;
int failed = 0;
int passed = 0;
int notRun = 0;
int total = Nodes.Count;
foreach (TestProjectTreeNode projectNode in Nodes) {
switch (projectNode.ImageIndex) {
case (int)TestTreeViewImageListIndex.TestFailed:
failed++;
break;
case (int)TestTreeViewImageListIndex.TestPassed:
passed++;
break;
case (int)TestTreeViewImageListIndex.TestIgnored:
ignored++;
break;
default: // Not run.
notRun++;
break;
}
}
// Update the image index based on the test project results.
if (failed > 0) {
UpdateImageListIndex(TestResultType.Failure);
} else if (ignored > 0) {
UpdateImageListIndex(TestResultType.Ignored);
} else if (passed > 0 && notRun == 0) {
UpdateImageListIndex(TestResultType.Success);
} else {
UpdateImageListIndex(TestResultType.None);
}
}
}
}

36
src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs

@ -117,6 +117,14 @@ namespace ICSharpCode.UnitTesting @@ -117,6 +117,14 @@ namespace ICSharpCode.UnitTesting
protected virtual void OnBeforeRunTests()
{
}
/// <summary>
/// Called after all tests have been run even if there have
/// been errors. If multiple projects are to be tested this is called only once.
/// </summary>
protected virtual void OnAfterRunTests()
{
}
protected abstract void RunTests(UnitTestApplicationStartHelper helper);
@ -141,6 +149,7 @@ namespace ICSharpCode.UnitTesting @@ -141,6 +149,7 @@ namespace ICSharpCode.UnitTesting
if (TaskService.SomethingWentWrong && ErrorListPad.ShowAfterBuild) {
ShowErrorList();
}
OnAfterRunTests();
}
}
@ -162,6 +171,16 @@ namespace ICSharpCode.UnitTesting @@ -162,6 +171,16 @@ namespace ICSharpCode.UnitTesting
{
}
/// <summary>
/// Brings the specified pad to the front.
/// </summary>
protected void ShowPad(PadDescriptor padDescriptor)
{
if (padDescriptor != null) {
WorkbenchSingleton.SafeThreadAsyncCall(padDescriptor.BringPadToFront);
}
}
/// <summary>
/// Runs the tests after building the project under test.
/// </summary>
@ -269,13 +288,6 @@ namespace ICSharpCode.UnitTesting @@ -269,13 +288,6 @@ namespace ICSharpCode.UnitTesting
return null;
}
void ShowPad(PadDescriptor padDescriptor)
{
if (padDescriptor != null) {
WorkbenchSingleton.SafeThreadAsyncCall(padDescriptor.BringPadToFront);
}
}
void ShowErrorList()
{
ShowPad(WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)));
@ -493,4 +505,14 @@ namespace ICSharpCode.UnitTesting @@ -493,4 +505,14 @@ namespace ICSharpCode.UnitTesting
WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished);
}
}
public class RunAllTestsInPadCommand : RunTestInPadCommand
{
public override void Run()
{
// To make sure all tests are run we set the Owner to null.
Owner = null;
base.Run();
}
}
}

122
src/AddIns/Misc/UnitTesting/Src/TestTreeView.cs

@ -31,9 +31,17 @@ namespace ICSharpCode.UnitTesting @@ -31,9 +31,17 @@ namespace ICSharpCode.UnitTesting
SourceCodeItemSelected = 1
}
/// <summary>
/// The All Tests tree root node that is added if multiple
/// test projects exist in the solution. If the solution contains
/// only one test project then no such node will be added.
/// </summary>
AllTestsTreeNode allTestsNode;
public TestTreeView()
{
ImageList = TestTreeViewImageList.ImageList;
CanClearSelection = false;
}
/// <summary>
@ -77,7 +85,8 @@ namespace ICSharpCode.UnitTesting @@ -77,7 +85,8 @@ namespace ICSharpCode.UnitTesting
/// </summary>
/// <remarks>
/// If the project is already in the tree then it will
/// not be added again.
/// not be added again. If a project is already in the tree then
/// an All Tests root node will be added.
/// </remarks>
public void AddProject(IProject project)
{
@ -88,7 +97,13 @@ namespace ICSharpCode.UnitTesting @@ -88,7 +97,13 @@ namespace ICSharpCode.UnitTesting
if (projectContent != null) {
TestProject testProject = new TestProject(project, projectContent);
TestProjectTreeNode node = new TestProjectTreeNode(testProject);
node.AddTo(this);
if (Nodes.Count == 0) {
node.AddTo(this);
} else {
AllTestsTreeNode allTestsNode = GetAllTestsNode();
allTestsNode.AddProjectNode(node);
}
// Sort the nodes.
SortNodes(Nodes, true);
@ -102,7 +117,14 @@ namespace ICSharpCode.UnitTesting @@ -102,7 +117,14 @@ namespace ICSharpCode.UnitTesting
/// </summary>
public void RemoveProject(IProject project)
{
RemoveProjectNode(GetProjectTreeNode(project));
TestProjectTreeNode projectNode = GetProjectTreeNode(project);
RemoveProjectNode(projectNode);
// Remove the All Tests node if it exists and there
// is only one project tree node left.
if (allTestsNode != null && GetProjectNodes().Count == 1) {
RemoveAllTestsNode();
}
}
/// <summary>
@ -111,7 +133,9 @@ namespace ICSharpCode.UnitTesting @@ -111,7 +133,9 @@ namespace ICSharpCode.UnitTesting
public IProject[] GetProjects()
{
List<IProject> projects = new List<IProject>();
foreach (TestProjectTreeNode projectNode in Nodes) {
// Get the project information.
foreach (TestProjectTreeNode projectNode in GetProjectNodes()) {
projects.Add(projectNode.Project);
}
return projects.ToArray();
@ -211,7 +235,7 @@ namespace ICSharpCode.UnitTesting @@ -211,7 +235,7 @@ namespace ICSharpCode.UnitTesting
/// </summary>
public void UpdateParseInfo(ICompilationUnit oldUnit, ICompilationUnit newUnit)
{
foreach (TestProjectTreeNode projectNode in Nodes) {
foreach (TestProjectTreeNode projectNode in GetProjectNodes()) {
TestProject testProject = projectNode.TestProject;
testProject.UpdateParseInfo(oldUnit, newUnit);
}
@ -223,7 +247,7 @@ namespace ICSharpCode.UnitTesting @@ -223,7 +247,7 @@ namespace ICSharpCode.UnitTesting
/// </summary>
public void ResetTestResults()
{
foreach (TestProjectTreeNode projectNode in Nodes) {
foreach (TestProjectTreeNode projectNode in GetProjectNodes()) {
TestProject testProject = projectNode.TestProject;
testProject.ResetTestResults();
}
@ -277,7 +301,7 @@ namespace ICSharpCode.UnitTesting @@ -277,7 +301,7 @@ namespace ICSharpCode.UnitTesting
/// </summary>
TestProjectTreeNode GetProjectTreeNode(IProject project)
{
foreach (TestProjectTreeNode projectNode in Nodes) {
foreach (TestProjectTreeNode projectNode in GetProjectNodes()) {
if (Object.ReferenceEquals(projectNode.Project, project)) {
return projectNode;
}
@ -285,11 +309,93 @@ namespace ICSharpCode.UnitTesting @@ -285,11 +309,93 @@ namespace ICSharpCode.UnitTesting
return null;
}
/// <summary>
/// Returns the test project tree nodes taking into account
/// if the All Tests root node exists.
/// </summary>
TreeNodeCollection GetProjectNodes()
{
if (allTestsNode != null) {
return allTestsNode.Nodes;
}
return Nodes;
}
/// <summary>
/// Removes the project node from the tree.
/// </summary>
void RemoveProjectNode(TestProjectTreeNode projectNode)
{
if (projectNode != null) {
projectNode.Remove();
if (allTestsNode != null) {
allTestsNode.RemoveProjectNode(projectNode);
} else {
projectNode.Remove();
}
}
}
/// <summary>
/// Gets the All Tests root node which is added if the tree is
/// showing multiple test projects. The All Tests root node will
/// be added if it does not exist.
/// </summary>
AllTestsTreeNode GetAllTestsNode()
{
if (allTestsNode == null) {
AddAllTestsNode();
}
return allTestsNode;
}
/// <summary>
/// Adds a new All Tests root node.
/// </summary>
void AddAllTestsNode()
{
// Save existing nodes (should only be one) before
// clearing so we can add these to the new All Tests node.
TreeNode[] projectNodes = new TreeNode[Nodes.Count];
Nodes.CopyTo(projectNodes, 0);
Nodes.Clear();
allTestsNode = new AllTestsTreeNode();
allTestsNode.Disposed += AllTestsNodeDisposed;
Nodes.Add(allTestsNode);
// Add the original project nodes to the new
// All Tests node.
foreach (TestProjectTreeNode node in projectNodes) {
allTestsNode.AddProjectNode(node);
}
}
/// <summary>
/// Removes the all tests node.
/// </summary>
void RemoveAllTestsNode()
{
// Remove the all tests node.
allTestsNode.Remove();
// Copy project nodes to the root.
foreach (TestTreeNode node in allTestsNode.Nodes) {
Nodes.Add(node);
}
// Dispose the all tests node.
AllTestsNodeDisposed(null, null);
}
/// <summary>
/// Ensures that if the TreeView's Clear method is called
/// directly the test tree does not think there is still
/// an All Tests node.
/// </summary>
void AllTestsNodeDisposed(object source, EventArgs e)
{
allTestsNode.Disposed -= AllTestsNodeDisposed;
allTestsNode = null;
}
}
}

210
src/AddIns/Misc/UnitTesting/Test/Tree/MultipleTestProjectsTestFixture.cs

@ -0,0 +1,210 @@ @@ -0,0 +1,210 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests.Tree
{
/// <summary>
/// When there are multiple test projects in a solution then the
/// test tree should have an All Tests root node.
/// </summary>
[TestFixture]
public class MultipleTestProjectsTestFixture
{
DummyParserServiceTestTreeView treeView;
MockCSharpProject firstProject;
MockCSharpProject secondProject;
AllTestsTreeNode allTestsTreeNode;
TestProject firstTestProject;
TestProject secondTestProject;
Solution solution;
[SetUp]
public void SetUp()
{
treeView = new DummyParserServiceTestTreeView();
// Create a solution with two test projects.
solution = new Solution();
// Create the first test project.
firstProject = new MockCSharpProject(solution);
firstProject.Name = "FirstTestProject";
ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(firstProject);
nunitFrameworkReferenceItem.Include = "NUnit.Framework";
ProjectService.AddProjectItem(firstProject, nunitFrameworkReferenceItem);
// Create the second test project.
secondProject = new MockCSharpProject(solution);
secondProject.Name = "SecondTestProject";
nunitFrameworkReferenceItem = new ReferenceProjectItem(secondProject);
nunitFrameworkReferenceItem.Include = "NUnit.Framework";
ProjectService.AddProjectItem(secondProject, nunitFrameworkReferenceItem);
// Add the projects to the solution.
solution.Folders.Add(firstProject);
solution.Folders.Add(secondProject);
// Create a dummy project content so the projects will be added
// to the tree.
treeView.ProjectContentForProject = new MockProjectContent();
// Add the solution to the tree.
treeView.AddSolution(solution);
allTestsTreeNode = treeView.Nodes[0] as AllTestsTreeNode;
firstTestProject = treeView.GetTestProject(firstProject);
secondTestProject = treeView.GetTestProject(secondProject);
}
[TearDown]
public void TearDown()
{
treeView.Dispose();
}
[Test]
public void OneAllTestsRootNode()
{
Assert.AreEqual(1, treeView.Nodes.Count);
}
[Test]
public void RootNodeIsAllTestsNode()
{
Assert.IsNotNull(allTestsTreeNode);
}
[Test]
public void AllTestsNodeText()
{
Assert.AreEqual(StringParser.Parse("${res:ICSharpCode.UnitTesting.AllTestsTreeNode.Text}"), treeView.Nodes[0].Text);
}
[Test]
public void GetProjectsAfterClear()
{
treeView.Clear();
Assert.AreEqual(0, treeView.GetProjects().Length);
}
/// <summary>
/// Tests that the All Tests node is removed when only one
/// project remains.
/// </summary>
[Test]
public void ProjectRemoved()
{
treeView.RemoveProject(firstProject);
Assert.AreEqual(1, treeView.GetProjects().Length);
Assert.IsInstanceOfType(typeof(TestProjectTreeNode), treeView.Nodes[0]);
}
/// <summary>
/// Tests that the all test node has the correct image index.
/// </summary>
[Test]
public void ProjectIgnoredTestResult()
{
TestClass c = new TestClass(new MockClass("Tests.TestFixture"));
firstTestProject.TestClasses.Add(c);
c.Result = TestResultType.Ignored;
Assert.AreEqual((int)TestTreeViewImageListIndex.TestIgnored, allTestsTreeNode.ImageIndex);
}
/// <summary>
/// Tests that a removed project does not affect the image index of the
/// All Tests root node.
/// </summary>
[Test]
public void IgnoredTestResultAfterProjectRemoved()
{
// Add an extra project so when we remove one the All Tests node
// is not removed.
MockCSharpProject project = new MockCSharpProject(solution);
project.Name = "ThirdTestProject";
ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);
nunitFrameworkReferenceItem.Include = "NUnit.Framework";
ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
// Add the project into a dummy project node.
TestProject testProject = new TestProject(project, new MockProjectContent());
DerivedTestProjectTreeNode projectNode = new DerivedTestProjectTreeNode(testProject);
allTestsTreeNode.AddProjectNode(projectNode);
// Remove an existing project.
treeView.RemoveProject(project);
// Modify the image index for the removed tree node.
projectNode.CallUpdateImageListIndex(TestResultType.Ignored);
// Image index of the all tests node should be unchanged.
Assert.AreEqual((int)TestTreeViewImageListIndex.TestNotRun, allTestsTreeNode.ImageIndex);
}
[Test]
public void ProjectFailedTestResult()
{
TestClass c = new TestClass(new MockClass("Tests.TestFixture"));
firstTestProject.TestClasses.Add(c);
c.Result = TestResultType.Failure;
Assert.AreEqual((int)TestTreeViewImageListIndex.TestFailed, allTestsTreeNode.ImageIndex);
}
[Test]
public void ProjectPassedTestResult()
{
TestClass c = new TestClass(new MockClass("Tests.TestFixture"));
firstTestProject.TestClasses.Add(c);
c.Result = TestResultType.Success;
Assert.AreEqual((int)TestTreeViewImageListIndex.TestNotRun, allTestsTreeNode.ImageIndex);
}
[Test]
public void AllTestsNodeImageIndexReset()
{
// Make one of the test projects pass so the all tests
// node's image index is changed.
ProjectPassedTestResult();
// Set the test class result back to not run.
firstTestProject.TestClasses[0].Result = TestResultType.None;
Assert.AreEqual((int)TestTreeViewImageListIndex.TestNotRun, allTestsTreeNode.ImageIndex);
}
[Test]
public void AllTestProjectsPassed()
{
TestClass c = new TestClass(new MockClass("Tests.TestFixture"));
firstTestProject.TestClasses.Add(c);
c.Result = TestResultType.Success;
c = new TestClass(new MockClass("Tests.TestFixture"));
secondTestProject.TestClasses.Add(c);
c.Result = TestResultType.Success;
Assert.AreEqual((int)TestTreeViewImageListIndex.TestPassed, allTestsTreeNode.ImageIndex);
}
[Test]
public void CanClearSelection()
{
Assert.IsFalse(treeView.CanClearSelection);
}
}
}

19
src/AddIns/Misc/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs

@ -81,6 +81,10 @@ namespace UnitTesting.Tests.Tree @@ -81,6 +81,10 @@ namespace UnitTesting.Tests.Tree
Assert.AreEqual(0, pad.TestTreeView.Nodes.Count);
}
/// <summary>
/// Add a new project and check that we also add an All Tests
/// root node and a new project node.
/// </summary>
[Test]
public void ProjectAdded()
{
@ -92,7 +96,10 @@ namespace UnitTesting.Tests.Tree @@ -92,7 +96,10 @@ namespace UnitTesting.Tests.Tree
pad.CallProjectAdded(project);
Assert.AreEqual(2, pad.TestTreeView.Nodes.Count);
Assert.AreEqual(2, pad.TestTreeView.GetProjects().Length);
Assert.AreEqual(1, pad.TestTreeView.Nodes.Count);
Assert.IsInstanceOfType(typeof(AllTestsTreeNode), pad.TestTreeView.Nodes[0]);
Assert.AreEqual(2, pad.TestTreeView.Nodes[0].Nodes.Count);
}
[Test]
@ -125,7 +132,10 @@ namespace UnitTesting.Tests.Tree @@ -125,7 +132,10 @@ namespace UnitTesting.Tests.Tree
// Project should be added since it has a reference to
// NUnit.
Assert.AreEqual(2, pad.TestTreeView.Nodes.Count);
Assert.AreEqual(2, pad.TestTreeView.GetProjects().Length);
Assert.AreEqual(1, pad.TestTreeView.Nodes.Count);
Assert.IsInstanceOfType(typeof(AllTestsTreeNode), pad.TestTreeView.Nodes[0]);
Assert.AreEqual(2, pad.TestTreeView.Nodes[0].Nodes.Count);
}
[Test]
@ -146,7 +156,10 @@ namespace UnitTesting.Tests.Tree @@ -146,7 +156,10 @@ namespace UnitTesting.Tests.Tree
pad.CallProjectItemAdded(refProjectItem);
Assert.AreEqual(2, pad.TestTreeView.Nodes.Count);
Assert.AreEqual(2, pad.TestTreeView.GetProjects().Length);
Assert.AreEqual(1, pad.TestTreeView.Nodes.Count);
Assert.IsInstanceOfType(typeof(AllTestsTreeNode), pad.TestTreeView.Nodes[0]);
Assert.AreEqual(2, pad.TestTreeView.Nodes[0].Nodes.Count);
}
[Test]

2
src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj

@ -57,9 +57,11 @@ @@ -57,9 +57,11 @@
<Compile Include="AssemblyInfo.cs" />
<Compile Include="NamespaceFilterTests.cs" />
<Compile Include="TestableConditionTests.cs" />
<Compile Include="Tree\MultipleTestProjectsTestFixture.cs" />
<Compile Include="Tree\TreeNodeContextMenuTestFixture.cs" />
<Compile Include="Tree\TreeNodeSortingTestFixture.cs" />
<Compile Include="Tree\OpenUnitTestsPadWithSolutionOpenTestFixture.cs" />
<Compile Include="Utils\DerivedTestProjectTreeNode.cs" />
<Compile Include="Utils\DerivedTestTreeView.cs" />
<Compile Include="Utils\DerivedUnitTestsPad.cs" />
<Compile Include="Utils\MockTestCase.cs" />

32
src/AddIns/Misc/UnitTesting/Test/Utils/DerivedTestProjectTreeNode.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.UnitTesting;
namespace UnitTesting.Tests.Utils
{
/// <summary>
/// Derived version of the TestProjectTreeNode class that
/// allows us to call the UpdateImageListIndex method directly.
/// </summary>
public class DerivedTestProjectTreeNode : TestProjectTreeNode
{
public DerivedTestProjectTreeNode(TestProject testProject)
: base(testProject)
{
}
/// <summary>
/// Calls the base class's UpdateImageListIndex method.
/// </summary>
public void CallUpdateImageListIndex(TestResultType result)
{
base.UpdateImageListIndex(result);
}
}
}

5
src/AddIns/Misc/UnitTesting/UnitTesting.addin

@ -94,7 +94,12 @@ @@ -94,7 +94,12 @@
<Condition name="RunningTests"/>
</Not>
</And>
<ToolbarItem id = "RunAll"
icon = "Icons.16x16.RunAllIcon"
tooltip = "${res:NUnitPad.NUnitPadContent.RunAllTests}"
class = "ICSharpCode.UnitTesting.RunAllTestsInPadCommand"/>
<ToolbarItem id = "Run"
insertafter="RunAll"
icon = "Icons.16x16.RunProgramIcon"
tooltip = "${res:NUnitPad.NUnitPadContent.RunItem}"
class = "ICSharpCode.UnitTesting.RunTestInPadCommand"/>

1
src/AddIns/Misc/UnitTesting/UnitTesting.csproj

@ -57,6 +57,7 @@ @@ -57,6 +57,7 @@
<None Include="UnitTesting.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Src\AllTestsTreeNode.cs" />
<Compile Include="Src\UnitTestCommands.cs" />
<Compile Include="Src\TestableCondition.cs" />
<Compile Include="Src\RunningTestsCondition.cs" />

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

@ -24,7 +24,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -24,7 +24,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
Errors errors = new Errors();
CSharpOutputFormatter outputFormatter;
PrettyPrintOptions prettyPrintOptions = new PrettyPrintOptions();
Stack<WithStatement> withExpressionStack = new Stack<WithStatement>();
bool printFullSystemType;
public string Text {
@ -166,7 +165,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -166,7 +165,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
} else if (typeReference.SystemType == "System.Nullable" && typeReference.GenericTypes != null
&& typeReference.GenericTypes.Count == 1 && !typeReference.IsGlobal)
{
TrackedVisit(typeReference.GenericTypes[0], null);
TrackVisit(typeReference.GenericTypes[0], null);
outputFormatter.PrintText("?");
} else {
if (typeReference.SystemType.Length > 0) {
@ -191,7 +190,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -191,7 +190,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data)
{
TrackedVisit(innerClassTypeReference.BaseType, data);
TrackVisit(innerClassTypeReference.BaseType, data);
outputFormatter.PrintToken(Tokens.Dot);
return VisitTypeReference((TypeReference)innerClassTypeReference, data);
}
@ -203,7 +202,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -203,7 +202,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return;
}
foreach (AttributeSection section in attributes) {
TrackedVisit(section, data);
TrackVisit(section, data);
}
}
void PrintFormattedComma()
@ -231,7 +230,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -231,7 +230,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
Debug.Assert(attributeSection.Attributes != null);
for (int j = 0; j < attributeSection.Attributes.Count; ++j) {
TrackedVisit((INode)attributeSection.Attributes[j], data);
TrackVisit((INode)attributeSection.Attributes[j], data);
if (j + 1 < attributeSection.Attributes.Count) {
PrintFormattedComma();
}
@ -255,7 +254,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -255,7 +254,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
PrintFormattedComma();
}
for (int i = 0; i < attribute.NamedArguments.Count; ++i) {
TrackedVisit((INode)attribute.NamedArguments[i], data);
TrackVisit((INode)attribute.NamedArguments[i], data);
if (i + 1 < attribute.NamedArguments.Count) {
PrintFormattedComma();
}
@ -271,7 +270,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -271,7 +270,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
TrackedVisit(namedArgumentExpression.Expression, data);
TrackVisit(namedArgumentExpression.Expression, data);
return null;
}
@ -288,7 +287,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -288,7 +287,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
printFullSystemType = true;
TrackedVisit(@using.Alias, data);
TrackVisit(@using.Alias, data);
printFullSystemType = false;
}
@ -300,7 +299,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -300,7 +299,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
foreach (Using u in usingDeclaration.Usings) {
TrackedVisit(u, data);
TrackVisit(u, data);
}
return null;
}
@ -335,7 +334,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -335,7 +334,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
TrackedVisit(f.Initializer, data);
TrackVisit(f.Initializer, data);
}
if (i < typeDeclaration.Children.Count - 1) {
outputFormatter.PrintToken(Tokens.Comma);
@ -379,12 +378,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -379,12 +378,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (i > 0) {
PrintFormattedComma();
}
TrackedVisit(typeDeclaration.BaseTypes[i], data);
TrackVisit(typeDeclaration.BaseTypes[i], data);
}
}
foreach (TemplateDefinition templateDefinition in typeDeclaration.Templates) {
TrackedVisit(templateDefinition, data);
TrackVisit(templateDefinition, data);
}
switch (typeDeclaration.Type) {
@ -429,7 +428,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -429,7 +428,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
for (int i = 0; i < templateDefinition.Bases.Count; ++i) {
TrackedVisit(templateDefinition.Bases[i], data);
TrackVisit(templateDefinition.Bases[i], data);
if (i + 1 < templateDefinition.Bases.Count) {
PrintFormattedComma();
}
@ -444,7 +443,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -444,7 +443,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
OutputModifier(delegateDeclaration.Modifier);
outputFormatter.PrintToken(Tokens.Delegate);
outputFormatter.Space();
TrackedVisit(delegateDeclaration.ReturnType, data);
TrackVisit(delegateDeclaration.ReturnType, data);
outputFormatter.Space();
outputFormatter.PrintIdentifier(delegateDeclaration.Name);
PrintTemplates(delegateDeclaration.Templates);
@ -455,7 +454,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -455,7 +454,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
AppendCommaSeparatedList(delegateDeclaration.Parameters);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
foreach (TemplateDefinition templateDefinition in delegateDeclaration.Templates) {
TrackedVisit(templateDefinition, data);
TrackVisit(templateDefinition, data);
}
outputFormatter.PrintToken(Tokens.Semicolon);
outputFormatter.NewLine();
@ -476,7 +475,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -476,7 +475,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(fieldDeclaration.Attributes, data);
outputFormatter.Indent();
OutputModifier(fieldDeclaration.Modifier);
TrackedVisit(fieldDeclaration.TypeReference, data);
TrackVisit(fieldDeclaration.TypeReference, data);
outputFormatter.Space();
AppendCommaSeparatedList(fieldDeclaration.Fields);
outputFormatter.PrintToken(Tokens.Semicolon);
@ -486,9 +485,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -486,9 +485,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(fieldDeclaration.Attributes, data);
outputFormatter.Indent();
OutputModifier(fieldDeclaration.Modifier);
TrackedVisit(fieldDeclaration.GetTypeForField(i), data);
TrackVisit(fieldDeclaration.GetTypeForField(i), data);
outputFormatter.Space();
TrackedVisit(fieldDeclaration.Fields[i], data);
TrackVisit(fieldDeclaration.Fields[i], data);
outputFormatter.PrintToken(Tokens.Semicolon);
outputFormatter.NewLine();
}
@ -501,14 +500,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -501,14 +500,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintIdentifier(variableDeclaration.Name);
if (!variableDeclaration.FixedArrayInitialization.IsNull) {
outputFormatter.PrintToken(Tokens.OpenSquareBracket);
TrackedVisit(variableDeclaration.FixedArrayInitialization, data);
TrackVisit(variableDeclaration.FixedArrayInitialization, data);
outputFormatter.PrintToken(Tokens.CloseSquareBracket);
}
if (!variableDeclaration.Initializer.IsNull) {
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
TrackedVisit(variableDeclaration.Initializer, data);
TrackVisit(variableDeclaration.Initializer, data);
}
return null;
}
@ -519,18 +518,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -519,18 +518,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Indent();
propertyDeclaration.Modifier &= ~Modifiers.ReadOnly;
OutputModifier(propertyDeclaration.Modifier);
TrackedVisit(propertyDeclaration.TypeReference, data);
TrackVisit(propertyDeclaration.TypeReference, data);
outputFormatter.Space();
if (propertyDeclaration.InterfaceImplementations.Count > 0) {
TrackedVisit(propertyDeclaration.InterfaceImplementations[0].InterfaceType, data);
TrackVisit(propertyDeclaration.InterfaceImplementations[0].InterfaceType, data);
outputFormatter.PrintToken(Tokens.Dot);
}
outputFormatter.PrintIdentifier(propertyDeclaration.Name);
outputFormatter.BeginBrace(this.prettyPrintOptions.PropertyBraceStyle);
TrackedVisit(propertyDeclaration.GetRegion, data);
TrackedVisit(propertyDeclaration.SetRegion, data);
TrackVisit(propertyDeclaration.GetRegion, data);
TrackVisit(propertyDeclaration.SetRegion, data);
outputFormatter.EndBrace();
return null;
@ -563,11 +562,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -563,11 +562,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
OutputModifier(eventDeclaration.Modifier);
outputFormatter.PrintToken(Tokens.Event);
outputFormatter.Space();
TrackedVisit(eventDeclaration.TypeReference, data);
TrackVisit(eventDeclaration.TypeReference, data);
outputFormatter.Space();
if (eventDeclaration.InterfaceImplementations.Count > 0) {
TrackedVisit(eventDeclaration.InterfaceImplementations[0].InterfaceType, data);
TrackVisit(eventDeclaration.InterfaceImplementations[0].InterfaceType, data);
outputFormatter.PrintToken(Tokens.Dot);
}
@ -577,7 +576,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -577,7 +576,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
TrackedVisit(eventDeclaration.Initializer, data);
TrackVisit(eventDeclaration.Initializer, data);
}
if (eventDeclaration.AddRegion.IsNull && eventDeclaration.RemoveRegion.IsNull) {
@ -585,8 +584,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -585,8 +584,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.NewLine();
} else {
outputFormatter.BeginBrace(this.prettyPrintOptions.PropertyBraceStyle);
TrackedVisit(eventDeclaration.AddRegion, data);
TrackedVisit(eventDeclaration.RemoveRegion, data);
TrackVisit(eventDeclaration.AddRegion, data);
TrackVisit(eventDeclaration.RemoveRegion, data);
outputFormatter.EndBrace();
}
return null;
@ -622,7 +621,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -622,7 +621,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(parameterDeclarationExpression.Attributes, data);
OutputModifier(parameterDeclarationExpression.ParamModifier, parameterDeclarationExpression);
if (!parameterDeclarationExpression.TypeReference.IsNull) {
TrackedVisit(parameterDeclarationExpression.TypeReference, data);
TrackVisit(parameterDeclarationExpression.TypeReference, data);
outputFormatter.Space();
}
outputFormatter.PrintIdentifier(parameterDeclarationExpression.ParameterName);
@ -634,10 +633,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -634,10 +633,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(methodDeclaration.Attributes, data);
outputFormatter.Indent();
OutputModifier(methodDeclaration.Modifier);
TrackedVisit(methodDeclaration.TypeReference, data);
TrackVisit(methodDeclaration.TypeReference, data);
outputFormatter.Space();
if (methodDeclaration.InterfaceImplementations.Count > 0) {
TrackedVisit(methodDeclaration.InterfaceImplementations[0].InterfaceType, data);
TrackVisit(methodDeclaration.InterfaceImplementations[0].InterfaceType, data);
outputFormatter.PrintToken(Tokens.Dot);
}
outputFormatter.PrintIdentifier(methodDeclaration.Name);
@ -660,7 +659,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -660,7 +659,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
AppendCommaSeparatedList(methodDeclaration.Parameters);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
foreach (TemplateDefinition templateDefinition in methodDeclaration.Templates) {
TrackedVisit(templateDefinition, null);
TrackVisit(templateDefinition, null);
}
OutputBlock(methodDeclaration.Body, this.prettyPrintOptions.MethodBraceStyle);
}
@ -678,14 +677,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -678,14 +677,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Explicit);
}
} else {
TrackedVisit(operatorDeclaration.TypeReference, data);
TrackVisit(operatorDeclaration.TypeReference, data);
}
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Operator);
outputFormatter.Space();
if (operatorDeclaration.IsConversionOperator) {
TrackedVisit(operatorDeclaration.TypeReference, data);
TrackVisit(operatorDeclaration.TypeReference, data);
} else {
switch (operatorDeclaration.OverloadableOperator) {
case OverloadableOperatorType.Add:
@ -796,7 +795,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -796,7 +795,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.OpenParenthesis);
AppendCommaSeparatedList(constructorDeclaration.Parameters);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
TrackedVisit(constructorDeclaration.ConstructorInitializer, data);
TrackVisit(constructorDeclaration.ConstructorInitializer, data);
OutputBlock(constructorDeclaration.Body, this.prettyPrintOptions.ConstructorBraceStyle);
return null;
}
@ -825,10 +824,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -825,10 +824,10 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VisitAttributes(indexerDeclaration.Attributes, data);
outputFormatter.Indent();
OutputModifier(indexerDeclaration.Modifier);
TrackedVisit(indexerDeclaration.TypeReference, data);
TrackVisit(indexerDeclaration.TypeReference, data);
outputFormatter.Space();
if (indexerDeclaration.InterfaceImplementations.Count > 0) {
TrackedVisit(indexerDeclaration.InterfaceImplementations[0].InterfaceType, data);
TrackVisit(indexerDeclaration.InterfaceImplementations[0].InterfaceType, data);
outputFormatter.PrintToken(Tokens.Dot);
}
outputFormatter.PrintToken(Tokens.This);
@ -846,8 +845,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -846,8 +845,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
outputFormatter.NewLine();
++outputFormatter.IndentationLevel;
TrackedVisit(indexerDeclaration.GetRegion, data);
TrackedVisit(indexerDeclaration.SetRegion, data);
TrackVisit(indexerDeclaration.GetRegion, data);
TrackVisit(indexerDeclaration.SetRegion, data);
--outputFormatter.IndentationLevel;
outputFormatter.Indent();
outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
@ -894,7 +893,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -894,7 +893,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.BeginBrace(braceStyle);
foreach (Statement stmt in blockStatement.Children) {
outputFormatter.Indent();
TrackedVisit(stmt, null);
if (stmt is BlockStatement) {
TrackVisit(stmt, BraceStyle.EndOfLine);
} else {
TrackVisit(stmt, null);
}
if (!outputFormatter.LastCharacterIsNewLine)
outputFormatter.NewLine();
}
@ -927,7 +930,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -927,7 +930,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.DoIndent = false;
outputFormatter.DoNewLine = false;
TrackedVisit(blockStatement.Children[0], null);
TrackVisit(blockStatement.Children[0], null);
outputFormatter.DoIndent = doIndent;
outputFormatter.DoNewLine = doNewLine;
@ -954,22 +957,22 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -954,22 +957,22 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data)
{
TrackedVisit(addHandlerStatement.EventExpression, data);
TrackVisit(addHandlerStatement.EventExpression, data);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.PlusAssign);
outputFormatter.Space();
TrackedVisit(addHandlerStatement.HandlerExpression, data);
TrackVisit(addHandlerStatement.HandlerExpression, data);
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
}
public override object TrackedVisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data)
{
TrackedVisit(removeHandlerStatement.EventExpression, data);
TrackVisit(removeHandlerStatement.EventExpression, data);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.MinusAssign);
outputFormatter.Space();
TrackedVisit(removeHandlerStatement.HandlerExpression, data);
TrackVisit(removeHandlerStatement.HandlerExpression, data);
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
}
@ -1008,7 +1011,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1008,7 +1011,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.NewLine();
outputFormatter.Indent();
}
TrackedVisit(eraseStatement.Expressions[i], data);
TrackVisit(eraseStatement.Expressions[i], data);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
@ -1052,7 +1055,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1052,7 +1055,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitExpressionStatement(ExpressionStatement expressionStatement, object data)
{
TrackedVisit(expressionStatement.Expression, data);
TrackVisit(expressionStatement.Expression, data);
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
}
@ -1066,9 +1069,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1066,9 +1069,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Indent();
}
OutputModifier(localVariableDeclaration.Modifier);
TrackedVisit(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("object"), data);
TrackVisit(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("object"), data);
outputFormatter.Space();
TrackedVisit(v, data);
TrackVisit(v, data);
outputFormatter.PrintToken(Tokens.Semicolon);
}
return null;
@ -1086,7 +1089,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1086,7 +1089,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
Debug.Assert(yieldStatement.Statement != null);
outputFormatter.PrintText("yield");
outputFormatter.Space();
TrackedVisit(yieldStatement.Statement, data);
TrackVisit(yieldStatement.Statement, data);
return null;
}
@ -1095,7 +1098,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1095,7 +1098,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Return);
if (!returnStatement.Expression.IsNull) {
outputFormatter.Space();
TrackedVisit(returnStatement.Expression, data);
TrackVisit(returnStatement.Expression, data);
}
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
@ -1108,13 +1111,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1108,13 +1111,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(ifElseStatement.Condition, data);
TrackVisit(ifElseStatement.Condition, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
PrintIfSection(ifElseStatement.TrueStatement);
foreach (ElseIfSection elseIfSection in ifElseStatement.ElseIfSections) {
TrackedVisit(elseIfSection, data);
TrackVisit(elseIfSection, data);
}
if (ifElseStatement.HasElseStatements) {
@ -1135,7 +1138,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1135,7 +1138,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
}
foreach (Statement stmt in statements) {
TrackedVisit(stmt, null);
TrackVisit(stmt, null);
}
if (statements.Count != 1) {
outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
@ -1154,7 +1157,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1154,7 +1157,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(elseIfSection.Condition, data);
TrackVisit(elseIfSection.Condition, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
WriteEmbeddedStatement(elseIfSection.EmbeddedStatement);
@ -1174,7 +1177,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1174,7 +1177,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.EmitSemicolon = false;
for (int i = 0; i < forStatement.Initializers.Count; ++i) {
INode node = (INode)forStatement.Initializers[i];
TrackedVisit(node, data);
TrackVisit(node, data);
if (i + 1 < forStatement.Initializers.Count) {
outputFormatter.PrintToken(Tokens.Comma);
}
@ -1186,7 +1189,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1186,7 +1189,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (this.prettyPrintOptions.SpacesAfterSemicolon) {
outputFormatter.Space();
}
TrackedVisit(forStatement.Condition, data);
TrackVisit(forStatement.Condition, data);
}
outputFormatter.EmitSemicolon = true;
outputFormatter.PrintToken(Tokens.Semicolon);
@ -1198,7 +1201,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1198,7 +1201,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
for (int i = 0; i < forStatement.Iterator.Count; ++i) {
INode node = (INode)forStatement.Iterator[i];
TrackedVisit(node, data);
TrackVisit(node, data);
if (i + 1 < forStatement.Iterator.Count) {
outputFormatter.PrintToken(Tokens.Comma);
}
@ -1217,11 +1220,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1217,11 +1220,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
void WriteEmbeddedStatement(Statement statement)
{
if (statement is BlockStatement) {
TrackedVisit(statement, prettyPrintOptions.StatementBraceStyle);
TrackVisit(statement, prettyPrintOptions.StatementBraceStyle);
} else {
++outputFormatter.IndentationLevel;
outputFormatter.NewLine();
TrackedVisit(statement, null);
TrackVisit(statement, null);
outputFormatter.NewLine();
--outputFormatter.IndentationLevel;
}
@ -1250,14 +1253,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1250,14 +1253,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(switchStatement.SwitchExpression, data);
TrackVisit(switchStatement.SwitchExpression, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
outputFormatter.NewLine();
++outputFormatter.IndentationLevel;
foreach (SwitchSection section in switchStatement.SwitchSections) {
TrackedVisit(section, data);
TrackVisit(section, data);
}
--outputFormatter.IndentationLevel;
outputFormatter.Indent();
@ -1268,13 +1271,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1268,13 +1271,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitSwitchSection(SwitchSection switchSection, object data)
{
foreach (CaseLabel label in switchSection.SwitchLabels) {
TrackedVisit(label, data);
TrackVisit(label, data);
}
++outputFormatter.IndentationLevel;
foreach (Statement stmt in switchSection.Children) {
outputFormatter.Indent();
TrackedVisit(stmt, data);
TrackVisit(stmt, data);
outputFormatter.NewLine();
}
@ -1304,7 +1307,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1304,7 +1307,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (caseLabel.BinaryOperatorType != BinaryOperatorType.None) {
Error(caseLabel, String.Format("Case labels with binary operators are unsupported : {0}", caseLabel.BinaryOperatorType));
}
TrackedVisit(caseLabel.Label, data);
TrackVisit(caseLabel.Label, data);
}
outputFormatter.PrintToken(Tokens.Colon);
if (!caseLabel.ToExpression.IsNull) {
@ -1324,11 +1327,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1324,11 +1327,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
} else {
outputFormatter.PrintText(" // TODO: to ");
TrackedVisit(caseLabel.ToExpression, data);
TrackVisit(caseLabel.ToExpression, data);
}
} else {
outputFormatter.PrintText(" // TODO: to ");
TrackedVisit(caseLabel.ToExpression, data);
TrackVisit(caseLabel.ToExpression, data);
}
}
outputFormatter.NewLine();
@ -1378,7 +1381,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1378,7 +1381,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
} else {
outputFormatter.PrintToken(Tokens.Case);
outputFormatter.Space();
TrackedVisit(gotoCaseStatement.Expression, data);
TrackVisit(gotoCaseStatement.Expression, data);
}
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
@ -1400,7 +1403,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1400,7 +1403,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (doLoopStatement.Condition.IsNull) {
outputFormatter.PrintToken(Tokens.True);
} else {
TrackedVisit(doLoopStatement.Condition, null);
TrackVisit(doLoopStatement.Condition, null);
}
if (doLoopStatement.ConditionType == ConditionType.Until) {
@ -1440,13 +1443,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1440,13 +1443,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(foreachStatement.TypeReference, data);
TrackVisit(foreachStatement.TypeReference, data);
outputFormatter.Space();
outputFormatter.PrintIdentifier(foreachStatement.VariableName);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.In);
outputFormatter.Space();
TrackedVisit(foreachStatement.Expression, data);
TrackVisit(foreachStatement.Expression, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
WriteEmbeddedStatement(foreachStatement.EmbeddedStatement);
@ -1461,7 +1464,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1461,7 +1464,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(lockStatement.LockExpression, data);
TrackVisit(lockStatement.LockExpression, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
WriteEmbeddedStatement(lockStatement.EmbeddedStatement);
@ -1480,7 +1483,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1480,7 +1483,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.DoNewLine = false;
outputFormatter.EmitSemicolon = false;
TrackedVisit(usingStatement.ResourceAcquisition, data);
TrackVisit(usingStatement.ResourceAcquisition, data);
outputFormatter.DoIndent = true;
outputFormatter.DoNewLine = true;
outputFormatter.EmitSemicolon = true;
@ -1494,9 +1497,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1494,9 +1497,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitWithStatement(WithStatement withStatement, object data)
{
withExpressionStack.Push(withStatement);
TrackedVisit(withStatement.Body, BraceStyle.EndOfLine);
withExpressionStack.Pop();
NotSupported(withStatement);
return null;
}
@ -1506,7 +1507,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1506,7 +1507,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
WriteEmbeddedStatement(tryCatchStatement.StatementBlock);
foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
TrackedVisit(catchClause, data);
TrackVisit(catchClause, data);
}
if (!tryCatchStatement.FinallyBlock.IsNull) {
@ -1543,7 +1544,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1543,7 +1544,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Throw);
if (!throwStatement.Expression.IsNull) {
outputFormatter.Space();
TrackedVisit(throwStatement.Expression, data);
TrackVisit(throwStatement.Expression, data);
}
outputFormatter.PrintToken(Tokens.Semicolon);
return null;
@ -1556,7 +1557,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1556,7 +1557,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(fixedStatement.TypeReference, data);
TrackVisit(fixedStatement.TypeReference, data);
outputFormatter.Space();
AppendCommaSeparatedList(fixedStatement.PointerDeclarators);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
@ -1605,14 +1606,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1605,14 +1606,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.OpenParenthesis);
if (!forNextStatement.TypeReference.IsNull) {
TrackedVisit(forNextStatement.TypeReference, data);
TrackVisit(forNextStatement.TypeReference, data);
outputFormatter.Space();
}
outputFormatter.PrintIdentifier(forNextStatement.VariableName);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space();
TrackedVisit(forNextStatement.Start, data);
TrackVisit(forNextStatement.Start, data);
outputFormatter.PrintToken(Tokens.Semicolon);
outputFormatter.Space();
outputFormatter.PrintIdentifier(forNextStatement.VariableName);
@ -1624,7 +1625,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1624,7 +1625,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
else
outputFormatter.PrintToken(Tokens.GreaterEqual);
outputFormatter.Space();
TrackedVisit(forNextStatement.End, data);
TrackVisit(forNextStatement.End, data);
outputFormatter.PrintToken(Tokens.Semicolon);
outputFormatter.Space();
outputFormatter.PrintIdentifier(forNextStatement.VariableName);
@ -1634,7 +1635,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1634,7 +1635,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.PlusAssign);
outputFormatter.Space();
TrackedVisit(forNextStatement.Step, data);
TrackVisit(forNextStatement.Step, data);
}
outputFormatter.PrintToken(Tokens.CloseParenthesis);
@ -1786,9 +1787,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1786,9 +1787,9 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(binaryOperatorExpression.Left, data);
TrackVisit(binaryOperatorExpression.Left, data);
PrintFormattedComma();
TrackedVisit(binaryOperatorExpression.Right, data);
TrackVisit(binaryOperatorExpression.Right, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
case BinaryOperatorType.Power:
@ -1797,13 +1798,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1797,13 +1798,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(binaryOperatorExpression.Left, data);
TrackVisit(binaryOperatorExpression.Left, data);
PrintFormattedComma();
TrackedVisit(binaryOperatorExpression.Right, data);
TrackVisit(binaryOperatorExpression.Right, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
}
TrackedVisit(binaryOperatorExpression.Left, data);
TrackVisit(binaryOperatorExpression.Left, data);
switch (binaryOperatorExpression.Op) {
case BinaryOperatorType.Add:
case BinaryOperatorType.Concat: // translate Concatenation to +
@ -1995,21 +1996,21 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -1995,21 +1996,21 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
Error(binaryOperatorExpression, String.Format("Unknown binary operator {0}", binaryOperatorExpression.Op));
return null;
}
TrackedVisit(binaryOperatorExpression.Right, data);
TrackVisit(binaryOperatorExpression.Right, data);
return null;
}
public override object TrackedVisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
{
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(parenthesizedExpression.Expression, data);
TrackVisit(parenthesizedExpression.Expression, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
}
public override object TrackedVisitInvocationExpression(InvocationExpression invocationExpression, object data)
{
TrackedVisit(invocationExpression.TargetObject, data);
TrackVisit(invocationExpression.TargetObject, data);
if (invocationExpression.TypeArguments != null && invocationExpression.TypeArguments.Count > 0) {
outputFormatter.PrintToken(Tokens.LessThan);
@ -2035,7 +2036,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2035,7 +2036,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
TrackedVisit(typeReferenceExpression.TypeReference, data);
TrackVisit(typeReferenceExpression.TypeReference, data);
return null;
}
@ -2061,11 +2062,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2061,11 +2062,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Plus);
break;
case UnaryOperatorType.PostDecrement:
TrackedVisit(unaryOperatorExpression.Expression, data);
TrackVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintToken(Tokens.Decrement);
return null;
case UnaryOperatorType.PostIncrement:
TrackedVisit(unaryOperatorExpression.Expression, data);
TrackVisit(unaryOperatorExpression.Expression, data);
outputFormatter.PrintToken(Tokens.Increment);
return null;
case UnaryOperatorType.Star:
@ -2078,13 +2079,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2078,13 +2079,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
Error(unaryOperatorExpression, String.Format("Unknown unary operator {0}", unaryOperatorExpression.Op));
return null;
}
TrackedVisit(unaryOperatorExpression.Expression, data);
TrackVisit(unaryOperatorExpression.Expression, data);
return null;
}
public override object TrackedVisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
TrackedVisit(assignmentExpression.Left, data);
TrackVisit(assignmentExpression.Left, data);
if (this.prettyPrintOptions.AroundAssignmentParentheses) {
outputFormatter.Space();
}
@ -2141,7 +2142,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2141,7 +2142,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (this.prettyPrintOptions.AroundAssignmentParentheses) {
outputFormatter.Space();
}
TrackedVisit(assignmentExpression.Right, data);
TrackVisit(assignmentExpression.Right, data);
return null;
}
@ -2152,7 +2153,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2152,7 +2153,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(sizeOfExpression.TypeReference, data);
TrackVisit(sizeOfExpression.TypeReference, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
}
@ -2164,7 +2165,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2164,7 +2165,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(typeOfExpression.TypeReference, data);
TrackVisit(typeOfExpression.TypeReference, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
}
@ -2176,25 +2177,25 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2176,25 +2177,25 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(defaultValueExpression.TypeReference, data);
TrackVisit(defaultValueExpression.TypeReference, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
}
public override object TrackedVisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data)
{
TrackedVisit(typeOfIsExpression.Expression, data);
TrackVisit(typeOfIsExpression.Expression, data);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Is);
outputFormatter.Space();
TrackedVisit(typeOfIsExpression.TypeReference, data);
TrackVisit(typeOfIsExpression.TypeReference, data);
return null;
}
public override object TrackedVisitAddressOfExpression(AddressOfExpression addressOfExpression, object data)
{
// C# 2.0 can reference methods directly
return TrackedVisit(addressOfExpression.Expression, data);
return TrackVisit(addressOfExpression.Expression, data);
}
public override object TrackedVisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
@ -2224,7 +2225,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2224,7 +2225,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.LambdaArrow);
outputFormatter.Space();
if (!lambdaExpression.ExpressionBody.IsNull) {
TrackedVisit(lambdaExpression.ExpressionBody, null);
TrackVisit(lambdaExpression.ExpressionBody, null);
}
if (!lambdaExpression.StatementBody.IsNull) {
OutputBlockAllowInline(lambdaExpression.StatementBody, this.prettyPrintOptions.MethodBraceStyle, false);
@ -2240,7 +2241,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2240,7 +2241,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(checkedExpression.Expression, data);
TrackVisit(checkedExpression.Expression, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
}
@ -2252,14 +2253,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2252,14 +2253,14 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
}
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(uncheckedExpression.Expression, data);
TrackVisit(uncheckedExpression.Expression, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
return null;
}
public override object TrackedVisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data)
{
TrackedVisit(pointerReferenceExpression.TargetObject, data);
TrackVisit(pointerReferenceExpression.TargetObject, data);
outputFormatter.PrintToken(Tokens.Pointer);
outputFormatter.PrintIdentifier(pointerReferenceExpression.Identifier);
return null;
@ -2268,19 +2269,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2268,19 +2269,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitCastExpression(CastExpression castExpression, object data)
{
if (castExpression.CastType == CastType.TryCast) {
TrackedVisit(castExpression.Expression, data);
TrackVisit(castExpression.Expression, data);
outputFormatter.Space();
outputFormatter.PrintToken(Tokens.As);
outputFormatter.Space();
TrackedVisit(castExpression.CastTo, data);
TrackVisit(castExpression.CastTo, data);
} else {
outputFormatter.PrintToken(Tokens.OpenParenthesis);
TrackedVisit(castExpression.CastTo, data);
TrackVisit(castExpression.CastTo, data);
outputFormatter.PrintToken(Tokens.CloseParenthesis);
if (this.prettyPrintOptions.SpacesAfterTypecast) {
outputFormatter.Space();
}
TrackedVisit(castExpression.Expression, data);
TrackVisit(castExpression.Expression, data);
}
return null;
}
@ -2289,12 +2290,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2289,12 +2290,12 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
{
outputFormatter.PrintToken(Tokens.Stackalloc);
outputFormatter.Space();
TrackedVisit(stackAllocExpression.TypeReference, data);
TrackVisit(stackAllocExpression.TypeReference, data);
outputFormatter.PrintToken(Tokens.OpenSquareBracket);
if (this.prettyPrintOptions.SpacesWithinBrackets) {
outputFormatter.Space();
}
TrackedVisit(stackAllocExpression.Expression, data);
TrackVisit(stackAllocExpression.Expression, data);
if (this.prettyPrintOptions.SpacesWithinBrackets) {
outputFormatter.Space();
}
@ -2304,7 +2305,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2304,7 +2305,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitIndexerExpression(IndexerExpression indexerExpression, object data)
{
TrackedVisit(indexerExpression.TargetObject, data);
TrackVisit(indexerExpression.TargetObject, data);
outputFormatter.PrintToken(Tokens.OpenSquareBracket);
if (this.prettyPrintOptions.SpacesWithinBrackets) {
outputFormatter.Space();
@ -2333,7 +2334,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2333,7 +2334,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.New);
if (!objectCreateExpression.CreateType.IsNull) {
outputFormatter.Space();
TrackedVisit(objectCreateExpression.CreateType, data);
TrackVisit(objectCreateExpression.CreateType, data);
}
if (objectCreateExpression.Parameters.Count > 0 || objectCreateExpression.ObjectInitializer.IsNull) {
if (prettyPrintOptions.NewParentheses) {
@ -2345,7 +2346,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2345,7 +2346,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
if (!objectCreateExpression.ObjectInitializer.IsNull) {
outputFormatter.Space();
TrackedVisit(objectCreateExpression.ObjectInitializer, data);
TrackVisit(objectCreateExpression.ObjectInitializer, data);
}
return null;
}
@ -2367,7 +2368,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2367,7 +2368,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
for (int i = 0; i < arrayCreateExpression.Arguments.Count; ++i) {
if (i > 0) PrintFormattedComma();
TrackedVisit(arrayCreateExpression.Arguments[i], data);
TrackVisit(arrayCreateExpression.Arguments[i], data);
}
if (this.prettyPrintOptions.SpacesWithinBrackets) {
outputFormatter.Space();
@ -2381,7 +2382,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2381,7 +2382,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (!arrayCreateExpression.ArrayInitializer.IsNull) {
outputFormatter.Space();
TrackedVisit(arrayCreateExpression.ArrayInitializer, data);
TrackVisit(arrayCreateExpression.ArrayInitializer, data);
}
return null;
}
@ -2389,14 +2390,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2389,14 +2390,11 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitFieldReferenceExpression(FieldReferenceExpression fieldReferenceExpression, object data)
{
Expression target = fieldReferenceExpression.TargetObject;
if (target.IsNull && withExpressionStack.Count > 0) {
target = ((WithStatement)withExpressionStack.Peek()).Expression;
}
if (target is BinaryOperatorExpression || target is CastExpression) {
outputFormatter.PrintToken(Tokens.OpenParenthesis);
}
TrackedVisit(target, data);
TrackVisit(target, data);
if (target is BinaryOperatorExpression || target is CastExpression) {
outputFormatter.PrintToken(Tokens.CloseParenthesis);
}
@ -2417,7 +2415,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2417,7 +2415,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space();
break;
}
TrackedVisit(directionExpression.Expression, data);
TrackVisit(directionExpression.Expression, data);
return null;
}
@ -2433,7 +2431,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2433,7 +2431,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitConditionalExpression(ConditionalExpression conditionalExpression, object data)
{
TrackedVisit(conditionalExpression.Condition, data);
TrackVisit(conditionalExpression.Condition, data);
if (this.prettyPrintOptions.ConditionalOperatorBeforeConditionSpace) {
outputFormatter.Space();
}
@ -2441,7 +2439,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2441,7 +2439,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (this.prettyPrintOptions.ConditionalOperatorAfterConditionSpace) {
outputFormatter.Space();
}
TrackedVisit(conditionalExpression.TrueExpression, data);
TrackVisit(conditionalExpression.TrueExpression, data);
if (this.prettyPrintOptions.ConditionalOperatorBeforeSeparatorSpace) {
outputFormatter.Space();
}
@ -2449,7 +2447,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2449,7 +2447,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (this.prettyPrintOptions.ConditionalOperatorAfterSeparatorSpace) {
outputFormatter.Space();
}
TrackedVisit(conditionalExpression.FalseExpression, data);
TrackVisit(conditionalExpression.FalseExpression, data);
return null;
}
@ -2541,7 +2539,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -2541,7 +2539,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
}
}
object TrackedVisit(INode node, object data)
object TrackVisit(INode node, object data)
{
return node.AcceptVisitor(this, data);
}

34
src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs

@ -67,6 +67,40 @@ namespace ICSharpCode.NRefactory.Visitors @@ -67,6 +67,40 @@ namespace ICSharpCode.NRefactory.Visitors
return null;
}
public override object VisitWithStatement(WithStatement withStatement, object data)
{
withStatement.Body.AcceptVisitor(new ReplaceWithAccessTransformer(withStatement.Expression), data);
base.VisitWithStatement(withStatement, data);
ReplaceCurrentNode(withStatement.Body);
return null;
}
sealed class ReplaceWithAccessTransformer : AbstractAstTransformer
{
readonly Expression replaceWith;
public ReplaceWithAccessTransformer(Expression replaceWith)
{
this.replaceWith = replaceWith;
}
public override object VisitFieldReferenceExpression(FieldReferenceExpression fieldReferenceExpression, object data)
{
if (fieldReferenceExpression.TargetObject.IsNull) {
fieldReferenceExpression.TargetObject = replaceWith;
return null;
} else {
return base.VisitFieldReferenceExpression(fieldReferenceExpression, data);
}
}
public override object VisitWithStatement(WithStatement withStatement, object data)
{
// do not visit the body of the WithStatement
return withStatement.Expression.AcceptVisitor(this, data);
}
}
static bool IsTypeLevel(INode node)
{
return node is MethodDeclaration || node is PropertyDeclaration || node is EventDeclaration

26
src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs

@ -556,6 +556,32 @@ static int static_Test2_j = 0;"); @@ -556,6 +556,32 @@ static int static_Test2_j = 0;");
"{\n\tEjes.AddLine(p1, p2);\n}");
}
[Test]
public void NestedWithStatements()
{
TestStatement(
"With tb1\n" +
" With .Font\n" +
" .Italic = True\n" +
" End With\n" +
"End With",
"{\n\t{\n\t\ttb1.Font.Italic = true;\n\t}\n}");
}
[Test]
public void NestedWithStatements2()
{
TestStatement(
"With tb1\n" +
" With .Something.Font\n" +
" .Italic = True\n" +
" End With\n" +
"End With",
"{\n\t{\n\t\ttb1.Something.Font.Italic = true;\n\t}\n}");
}
[Test]
public void StructureWithImplicitPublicField()
{

2
src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs

@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Gui.XmlForms; @@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Gui.XmlForms;
namespace ICSharpCode.SharpDevelop.Gui
{
public abstract class AbstractOptionPanel : BaseSharpDevelopUserControl, IDialogPanel
public class AbstractOptionPanel : BaseSharpDevelopUserControl, IDialogPanel
{
bool wasActivated = false;
bool isFinished = true;

8
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceInFilesManager.cs

@ -37,12 +37,12 @@ namespace SearchAndReplace @@ -37,12 +37,12 @@ namespace SearchAndReplace
find.DocumentIterator = SearchReplaceUtilities.CreateDocumentIterator(SearchOptions.DocumentIteratorType);
}
static bool InitializeSearchInFiles()
static bool InitializeSearchInFiles(IProgressMonitor monitor)
{
SetSearchOptions();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return false;
currentFileName = String.Empty;
@ -71,7 +71,7 @@ namespace SearchAndReplace @@ -71,7 +71,7 @@ namespace SearchAndReplace
public static void FindAll(IProgressMonitor monitor)
{
if (!InitializeSearchInFiles()) {
if (!InitializeSearchInFiles(monitor)) {
return;
}
@ -88,7 +88,7 @@ namespace SearchAndReplace @@ -88,7 +88,7 @@ namespace SearchAndReplace
public static void FindAll(int offset, int length, IProgressMonitor monitor)
{
if (!InitializeSearchInFiles()) {
if (!InitializeSearchInFiles(monitor)) {
return;
}

12
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchReplaceManager.cs

@ -103,7 +103,7 @@ namespace SearchAndReplace @@ -103,7 +103,7 @@ namespace SearchAndReplace
SetSearchOptions();
ClearSelection();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
List<TextEditorControl> textAreas = new List<TextEditorControl>();
int count;
@ -128,7 +128,7 @@ namespace SearchAndReplace @@ -128,7 +128,7 @@ namespace SearchAndReplace
SetSearchOptions();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
List<TextEditorControl> textAreas = new List<TextEditorControl>();
@ -191,7 +191,7 @@ namespace SearchAndReplace @@ -191,7 +191,7 @@ namespace SearchAndReplace
SetSearchOptions();
ClearSelection();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
List<TextEditorControl> textAreas = new List<TextEditorControl>();
@ -239,7 +239,7 @@ namespace SearchAndReplace @@ -239,7 +239,7 @@ namespace SearchAndReplace
SetSearchOptions();
find.Reset();
if (!find.SearchStrategy.CompilePattern())
if (!find.SearchStrategy.CompilePattern(monitor))
return;
for (int count = 0;; count++) {
@ -274,7 +274,7 @@ namespace SearchAndReplace @@ -274,7 +274,7 @@ namespace SearchAndReplace
return;
}
if (!find.SearchStrategy.CompilePattern()) {
if (!find.SearchStrategy.CompilePattern(monitor)) {
find.Reset();
lastResult = null;
return;
@ -319,7 +319,7 @@ namespace SearchAndReplace @@ -319,7 +319,7 @@ namespace SearchAndReplace
return;
}
if (!find.SearchStrategy.CompilePattern()) {
if (!find.SearchStrategy.CompilePattern(monitor)) {
find.Reset();
lastResult = null;
return;

2
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/BruteForceSearchStrategy.cs

@ -71,7 +71,7 @@ namespace SearchAndReplace @@ -71,7 +71,7 @@ namespace SearchAndReplace
return -1;
}
public bool CompilePattern()
public bool CompilePattern(ICSharpCode.SharpDevelop.Gui.IProgressMonitor monitor)
{
searchPattern = SearchOptions.MatchCase ? SearchOptions.FindPattern : SearchOptions.FindPattern.ToUpper();
return true;

10
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/ISearchStrategy.cs

@ -6,24 +6,26 @@ @@ -6,24 +6,26 @@
// </file>
using System;
using ICSharpCode.SharpDevelop.Gui;
namespace SearchAndReplace
{
/// <summary>
/// This interface is the basic interface which all
/// This interface is the basic interface which all
/// search algorithms must implement.
/// </summary>
public interface ISearchStrategy
{
/// <remarks>
/// Only with a call to this method the search strategy must
/// update their pattern information. This method will be called
/// update their pattern information. This method will be called
/// before the FindNext function.
/// The method might show a message box to the user if the pattern is invalid.
/// </remarks>
bool CompilePattern();
bool CompilePattern(IProgressMonitor monitor);
/// <remarks>
/// The find next method should search the next occurrence of the
/// The find next method should search the next occurrence of the
/// compiled pattern in the text using the textIterator and options.
/// </remarks>
SearchResult FindNext(ITextIterator textIterator);

5
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/RegExSearchStrategy.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Text.RegularExpressions;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace SearchAndReplace
{
@ -15,7 +16,7 @@ namespace SearchAndReplace @@ -15,7 +16,7 @@ namespace SearchAndReplace
{
Regex regex = null;
public bool CompilePattern()
public bool CompilePattern(IProgressMonitor monitor)
{
RegexOptions regexOptions = RegexOptions.Compiled;
if (!SearchOptions.MatchCase) {
@ -25,7 +26,9 @@ namespace SearchAndReplace @@ -25,7 +26,9 @@ namespace SearchAndReplace
regex = new Regex(SearchOptions.FindPattern, regexOptions);
return true;
} catch (ArgumentException ex) {
if (monitor != null) monitor.ShowingDialog = true;
MessageService.ShowError("${res:Dialog.NewProject.SearchReplace.ErrorParsingRegex}\n" + ex.Message);
if (monitor != null) monitor.ShowingDialog = false;
return false;
}
}

2
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Engine/SearchStrategy/WildcardSearchStrategy.cs

@ -164,7 +164,7 @@ namespace SearchAndReplace @@ -164,7 +164,7 @@ namespace SearchAndReplace
return -1;
}
public bool CompilePattern()
public bool CompilePattern(ICSharpCode.SharpDevelop.Gui.IProgressMonitor monitor)
{
CompilePattern(SearchOptions.FindPattern, !SearchOptions.MatchCase);
return true;

22
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

@ -841,13 +841,26 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -841,13 +841,26 @@ namespace ICSharpCode.SharpDevelop.Dom
return fallbackResult;
}
IClass GetClassByDotNetName(string className, bool lookInReferences)
{
className = className.Replace('+', '.');
if (className.Length > 2 && className[className.Length - 2] == '`') {
int typeParameterCount = className[className.Length - 1] - '0';
if (typeParameterCount < 0) typeParameterCount = 0;
className = className.Substring(0, className.Length - 2);
return GetClass(className, typeParameterCount, LanguageProperties.CSharp, lookInReferences);
} else {
return GetClass(className, 0, LanguageProperties.CSharp, lookInReferences);
}
}
/// <summary>
/// Gets the position of a member in this project content (not a referenced one).
/// </summary>
/// <param name="fullMemberName">Fully qualified member name (always case sensitive).</param>
/// <param name="fullMemberName">The full member name in Reflection syntax (always case sensitive, ` for generics)</param>
public IDecoration GetElement(string fullMemberName)
{
IClass curClass = GetClass(fullMemberName, 0, LanguageProperties.CSharp, false);
IClass curClass = GetClassByDotNetName(fullMemberName, false);
if (curClass != null) {
return curClass;
}
@ -865,7 +878,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -865,7 +878,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (pos2 > 0) {
string className = memberName.Substring(0, pos2);
memberName = memberName.Substring(pos2 + 1);
curClass = GetClass(className, 0, LanguageProperties.CSharp, false);
curClass = GetClassByDotNetName(className, false);
if (curClass != null) {
IMethod firstMethod = null;
foreach (IMethod m in curClass.Methods) {
@ -885,6 +898,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -885,6 +898,7 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
}
return firstMethod;
}
}
} else {
@ -892,7 +906,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -892,7 +906,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (pos > 0) {
string className = fullMemberName.Substring(0, pos);
string memberName = fullMemberName.Substring(pos + 1);
curClass = GetClass(className, 0, LanguageProperties.CSharp, false);
curClass = GetClassByDotNetName(className, false);
if (curClass != null) {
// get first method with that name, but prefer method without parameters
IMethod firstMethod = null;

10
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/IProjectContent.cs

@ -90,6 +90,16 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -90,6 +90,16 @@ namespace ICSharpCode.SharpDevelop.Dom
string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn);
SearchTypeResult SearchType(SearchTypeRequest request);
/// <summary>
/// Gets the position of a member in this project content (not a referenced one).
/// </summary>
/// <param name="fullMemberName">The full member name in Reflection syntax (always case sensitive, ` for generics)</param>
IDecoration GetElement(string fullMemberName);
/// <summary>
/// Gets the definition position of the class/member.
/// </summary>
/// <param name="fullMemberName">The full member name in Reflection syntax (always case sensitive, ` for generics)</param>
FilePosition GetPosition(string fullMemberName);
}

BIN
src/Main/StartUp/Project/Resources/BitmapResources.resources

Binary file not shown.

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.

6
src/Setup/Setup.wxs

@ -319,12 +319,10 @@ @@ -319,12 +319,10 @@
<!--
<ComponentRef Id="SharpQueryDll"/>
<ComponentRef Id="SharpQueryInteropMSDASCDll"/>
<ComponentRef Id="SharpReportCoreDll"/>
<ComponentRef Id="SharpReportDll"/>
<ComponentRef Id="ReportGeneratorDll"/>
<ComponentRef Id="SharpDevelopReportsCoreDll"/>
<ComponentRef Id="SharpDevelopReportsAddInDll"/>
<ComponentRef Id="PdfSharpDll"/>
<ComponentRef Id="PdfSharpDeResources"/>
<ComponentRef Id="SharpReportAddInDll"/>
-->
<ComponentRef Id="OracleDbToolsProviderDll"/>
<ComponentRef Id="ServerBrowserToolDll"/>

Loading…
Cancel
Save