Browse Source

Migrated CreateProperties refactoring snippet to NR5.

pull/45/merge
Andreas Weizel 13 years ago
parent
commit
da7265e65d
  1. 68
      SharpDevelop.sln
  2. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin
  3. 6
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
  4. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/OverrideToStringCompletionData.cs
  5. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/AbstractInlineRefactorDialog.cs
  6. 60
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreateProperties.cs
  7. 20
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreatePropertiesCommand.cs
  8. 40
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreatePropertiesDialog.xaml
  9. 290
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreatePropertiesDialog.xaml.cs
  10. 12
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/FieldWrapper.cs
  11. 6
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/InsertCtorSnippetRefactoring.cs
  12. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/OverrideToStringMethodDialog.xaml.cs

68
SharpDevelop.sln

@ -1,10 +1,8 @@ @@ -1,10 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.3
# SharpDevelop 5.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}"
EndProject
@ -23,8 +21,6 @@ EndProject @@ -23,8 +21,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDevelop", "src\Main\SharpDevelop\SharpDevelop.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{2A232EF1-EB95-41C6-B63A-C106E0C95D3C}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "src\Libraries\cecil\Mono.Cecil.csproj", "{D68133BD-1E63-496E-9EDE-4FBDBF77B486}"
EndProject
@ -50,20 +46,14 @@ EndProject @@ -50,20 +46,14 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Decompiler", "src\Libraries\ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj", "{984CC812-9470-4A13-AFF9-CC44068D666C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{39327899-ED91-4F7F-988C-4FE4E17C014D}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Version Control", "Version Control", "{F208FF4F-E5D8-41D5-A7C7-B463976F156E}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitAddIn", "src\AddIns\VersionControl\GitAddIn\GitAddIn.csproj", "{83F15BA7-8478-4664-81BB-A82F146D88B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubversionAddIn", "src\AddIns\VersionControl\SubversionAddIn\SubversionAddIn.csproj", "{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Language Bindings", "Language Bindings", "{E0646C25-36F2-4524-969F-FA621353AB94}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding", "src\AddIns\BackendBindings\CSharpBinding\Project\CSharpBinding.csproj", "{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}"
EndProject
@ -82,8 +72,6 @@ EndProject @@ -82,8 +72,6 @@ EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VBBinding", "src\AddIns\BackendBindings\VBBinding\Project\VBBinding.vbproj", "{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace", "src\AddIns\Misc\SearchAndReplace\Project\SearchAndReplace.csproj", "{9196DD8A-B4D4-4780-8742-C5762E547FC2}"
EndProject
@ -92,8 +80,6 @@ EndProject @@ -92,8 +80,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddinScout", "src\AddIns\Misc\AddinScout\Project\AddinScout.csproj", "{4B8F0F98-8BE1-402B-AA8B-C8D548577B38}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UsageDataCollector", "UsageDataCollector", "{59A30AA6-D600-41AB-B7A1-9543469DBE36}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector\UsageDataCollector.csproj", "{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0}"
EndProject
@ -110,8 +96,6 @@ EndProject @@ -110,8 +96,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTemplating", "src\AddIns\Misc\TextTemplating\Project\TextTemplating.csproj", "{B5D8C3E6-42EC-4D4B-AD05-3644B32563EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManagement", "PackageManagement", "{87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement", "src\AddIns\Misc\PackageManagement\Project\PackageManagement.csproj", "{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}"
EndProject
@ -124,8 +108,6 @@ EndProject @@ -124,8 +108,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager2", "src\AddIns\Misc\AddInManager2\Project\AddInManager2.csproj", "{60480C2F-F228-4D86-B98F-AF75A7DCEC34}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Reports", "Reports", "{4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reports.Addin", "src\AddIns\Misc\Reports\ICSharpCode.Reports.Addin\ICSharpCode.Reports.Addin.csproj", "{6FB2FE2F-4E8C-4403-99AE-0474721FFD2E}"
EndProject
@ -134,8 +116,6 @@ EndProject @@ -134,8 +116,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Irony", "src\AddIns\Misc\Reports\Irony\Irony.csproj", "{9F0355DD-A394-4626-A2D9-112EBD1D36A9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
@ -150,8 +130,6 @@ EndProject @@ -150,8 +130,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsEditor", "src\AddIns\DisplayBindings\SettingsEditor\Project\SettingsEditor.csproj", "{85226AFB-CE71-4851-9A75-7EEC663A8E8A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{5FB020B2-B64B-4016-999A-CB8FD9274D72}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Addin", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Addin\ICSharpCode.Data.Addin.csproj", "{A9F12710-24E4-46D4-832C-6ECB395B9EAD}"
EndProject
@ -166,8 +144,6 @@ EndProject @@ -166,8 +144,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.SQLServer\ICSharpCode.Data.SQLServer.csproj", "{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{D54BEB89-8CBE-475C-8BB9-836D2FD71260}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
@ -182,8 +158,6 @@ EndProject @@ -182,8 +158,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEditor", "src\AddIns\DisplayBindings\ResourceEditor\Project\ResourceEditor.csproj", "{E378E217-0C0C-473F-88A2-BF9748207511}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{7019F43E-DFD7-4D1C-8C96-E75D55646DE7}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
@ -198,8 +172,6 @@ EndProject @@ -198,8 +172,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQuality", "src\AddIns\Analysis\CodeQuality\CodeQuality.csproj", "{D1DF9C2D-3A5E-4985-ACA4-648C604DB562}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
EndProject
@ -317,6 +289,10 @@ Global @@ -317,6 +289,10 @@ Global
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Release|Any CPU.Build.0 = Release|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Release|Any CPU.Build.0 = Release|Any CPU
{9196DD8A-B4D4-4780-8742-C5762E547FC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9196DD8A-B4D4-4780-8742-C5762E547FC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9196DD8A-B4D4-4780-8742-C5762E547FC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -497,10 +473,6 @@ Global @@ -497,10 +473,6 @@ Global
{3DF4060F-5EE0-41CF-8096-F27355FD5511}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DF4060F-5EE0-41CF-8096-F27355FD5511}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DF4060F-5EE0-41CF-8096-F27355FD5511}.Release|Any CPU.Build.0 = Release|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Release|Any CPU.Build.0 = Release|Any CPU
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -516,22 +488,18 @@ Global @@ -516,22 +488,18 @@ Global
{1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{D68133BD-1E63-496E-9EDE-4FBDBF77B486} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C}
{E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C}
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}
{53DCA265-3C3C-42F9-B647-F72BA678122B} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}
{DC393B66-92ED-4CAD-AB25-CFEF23F3D7C6} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}
{2FF700C2-A38A-48BD-A637-8CAFD4FE6237} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C}
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C}
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C}
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C}
{984CC812-9470-4A13-AFF9-CC44068D666C} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C}
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}
{53DCA265-3C3C-42F9-B647-F72BA678122B} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}
{DC393B66-92ED-4CAD-AB25-CFEF23F3D7C6} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}
{F208FF4F-E5D8-41D5-A7C7-B463976F156E} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{E0646C25-36F2-4524-969F-FA621353AB94} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{F3662720-9EA2-4591-BBC6-97361DCE50A9} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{7019F43E-DFD7-4D1C-8C96-E75D55646DE7} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{83F15BA7-8478-4664-81BB-A82F146D88B3} = {F208FF4F-E5D8-41D5-A7C7-B463976F156E}
{17F4D7E0-6933-4C2E-8714-FD7E98D625D5} = {F208FF4F-E5D8-41D5-A7C7-B463976F156E}
{E0646C25-36F2-4524-969F-FA621353AB94} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {E0646C25-36F2-4524-969F-FA621353AB94}
{E954F3CB-A446-492F-A664-2B376EBC86E8} = {E0646C25-36F2-4524-969F-FA621353AB94}
{70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94}
@ -540,27 +508,29 @@ Global @@ -540,27 +508,29 @@ Global
{E1B288A2-08EE-4318-8BBB-8AB72C69E33E} = {E0646C25-36F2-4524-969F-FA621353AB94}
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD} = {E0646C25-36F2-4524-969F-FA621353AB94}
{6D209CBB-D8C1-478A-BC30-D3FC87B7858F} = {E0646C25-36F2-4524-969F-FA621353AB94}
{F3662720-9EA2-4591-BBC6-97361DCE50A9} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{9196DD8A-B4D4-4780-8742-C5762E547FC2} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{4B8F0F98-8BE1-402B-AA8B-C8D548577B38} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{59A30AA6-D600-41AB-B7A1-9543469DBE36} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{D022A6CE-7438-41E8-AC64-F2DE18EC54C6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{80F76D10-0B44-4D55-B4BD-DAEB5464090C} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{E2FD63DA-8478-4066-934C-DA82A852C83A} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{B5D8C3E6-42EC-4D4B-AD05-3644B32563EF} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{60480C2F-F228-4D86-B98F-AF75A7DCEC34} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {59A30AA6-D600-41AB-B7A1-9543469DBE36}
{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1} = {87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D}
{A406803B-C584-43A3-BCEE-A0BB3132CB5F} = {87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D}
{752BD058-5517-48A1-BB27-5ED186FA052B} = {87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D}
{E0A5E80A-003B-4335-A9DC-A76E2E46D38D} = {87D549AF-8FCD-4E84-9C33-3DB6E42FEF6D}
{60480C2F-F228-4D86-B98F-AF75A7DCEC34} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3} = {F3662720-9EA2-4591-BBC6-97361DCE50A9}
{6FB2FE2F-4E8C-4403-99AE-0474721FFD2E} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3}
{7C3579BC-2A64-4108-82B5-3D07ADA079E7} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3}
{9F0355DD-A394-4626-A2D9-112EBD1D36A9} = {4ABB8D1E-3439-44C8-ACCE-1FA678ABBFB3}
{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
@ -568,25 +538,27 @@ Global @@ -568,25 +538,27 @@ Global
{8AA421C8-D7AF-4957-9F43-5135328ACB24} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{5FB020B2-B64B-4016-999A-CB8FD9274D72} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{D54BEB89-8CBE-475C-8BB9-836D2FD71260} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{0CD86A0B-73BB-4E7E-B476-AB84389164B1} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{E378E217-0C0C-473F-88A2-BF9748207511} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{A9F12710-24E4-46D4-832C-6ECB395B9EAD} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{B7823AE9-4B43-4859-8796-2EBDC116FBB8} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{BAD94D6E-4159-4CB6-B991-486F412D9BB6} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{EEF5E054-4192-4A57-8FBF-E860D808A51D} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{D54BEB89-8CBE-475C-8BB9-836D2FD71260} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{78CC29AC-CC79-4355-B1F2-97936DF198AC} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{0CD86A0B-73BB-4E7E-B476-AB84389164B1} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{E378E217-0C0C-473F-88A2-BF9748207511} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{7019F43E-DFD7-4D1C-8C96-E75D55646DE7} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{1F261725-6318-4434-A1B1-6C70CE4CD324} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{3EAA45A9-735C-4AC7-A799-947B93EA449D} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{44FA68C9-DAD1-4C3C-90BB-3435F0D1D128} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{D1DA3B8F-7313-4BDA-8880-461C5F007751} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{D1DF9C2D-3A5E-4985-ACA4-648C604DB562} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E} = {39327899-ED91-4F7F-988C-4FE4E17C014D}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}
{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {49CE38B8-0460-46BF-9DFF-5B33A0F9EB5E}
EndGlobalSection

4
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin

@ -158,8 +158,8 @@ @@ -158,8 +158,8 @@
<Path name="/SharpDevelop/ViewContent/AvalonEdit/SnippetElementProviders">
<Class id="ctor" class="CSharpBinding.Refactoring.InsertCtorSnippetRefactoring" />
<!--<Class id="switch" class="CSharpBinding.Refactoring.SwitchSnippetProvider" />
<Class id="propall" class="CSharpBinding.Refactoring.CreateProperties" />-->
<Class id="propall" class="CSharpBinding.Refactoring.CreateProperties" />
<!--<Class id="switch" class="CSharpBinding.Refactoring.SwitchSnippetProvider" /> -->
</Path>
<Path path = "/SharpDevelop/ViewContent/TextEditor/C#/IssueProviders">

6
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

@ -87,6 +87,11 @@ @@ -87,6 +87,11 @@
<Compile Include="Src\FormsDesigner\SecondaryDisplayBinding.cs" />
<Compile Include="Src\Parser\FoldingVisitor.cs" />
<Compile Include="Src\Refactoring\AbstractInlineRefactorDialog.cs" />
<Compile Include="Src\Refactoring\CreateProperties.cs" />
<Compile Include="Src\Refactoring\CreatePropertiesCommand.cs" />
<Compile Include="Src\Refactoring\CreatePropertiesDialog.xaml.cs">
<DependentUpon>CreatePropertiesDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Src\Refactoring\CSharpCodeGenerator.cs" />
<Compile Include="Src\Refactoring\CSharpSyntaxIssue.cs" />
<Compile Include="Src\Refactoring\FieldWrapper.cs" />
@ -212,6 +217,7 @@ @@ -212,6 +217,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\Refactoring\CreatePropertiesDialog.xaml" />
<Page Include="Src\Refactoring\InsertCtorDialog.xaml" />
<Page Include="Src\Refactoring\IssueOptions.xaml" />
<Page Include="Src\OptionPanels\BuildOptions.xaml" />

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/OverrideToStringCompletionData.cs

@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -10,15 +9,12 @@ using System.Threading; @@ -10,15 +9,12 @@ using System.Threading;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Parser;
using CSharpBinding.FormattingStrategy;
using CSharpBinding.Parser;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using CSharpBinding.Refactoring;

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/AbstractInlineRefactorDialog.cs

@ -15,9 +15,7 @@ using ICSharpCode.NRefactory.CSharp; @@ -15,9 +15,7 @@ using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Parser;
using CSharpBinding.Refactoring;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
namespace CSharpBinding.Refactoring

60
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreateProperties.cs

@ -3,17 +3,11 @@ @@ -3,17 +3,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using SharpRefactoring.Gui;
namespace CSharpBinding.Refactoring
{
@ -34,51 +28,27 @@ namespace CSharpBinding.Refactoring @@ -34,51 +28,27 @@ namespace CSharpBinding.Refactoring
if (textEditor == null)
return null;
IEditorUIService uiService = textEditor.GetService(typeof(IEditorUIService)) as IEditorUIService;
using (textEditor.Document.OpenUndoGroup()) {
IEditorUIService uiService = textEditor.GetService(typeof(IEditorUIService)) as IEditorUIService;
if (uiService == null)
return null;
ParseInformation parseInfo = ParserService.GetParseInformation(textEditor.FileName);
if (parseInfo == null)
return null;
CodeGenerator generator = parseInfo.CompilationUnit.Language.CodeGenerator;
// cannot use insertion position at this point, because it might not be
// valid, because we are still generating the elements.
// DOM is not updated
ICSharpCode.AvalonEdit.Document.TextLocation loc = context.Document.GetLocation(context.StartPosition);
IClass current = parseInfo.CompilationUnit.GetInnermostClass(loc.Line, loc.Column);
if (uiService == null)
return null;
if (current == null)
return null;
List<FieldWrapper> parameters = FindFields(current).Where(f => !current.Properties.Any(p => p.Name == f.PropertyName)).ToList();
if (!parameters.Any())
return null;
ITextAnchor anchor = textEditor.Document.CreateAnchor(context.InsertionPosition);
anchor.MovementType = AnchorMovementType.AfterInsertion;
ITextAnchor anchor = textEditor.Document.CreateAnchor(context.InsertionPosition);
anchor.MovementType = AnchorMovementType.BeforeInsertion;
// Since this snippet doesn't insert anything, fake insertion of 1 character to allow proper Ctrl+Z reaction
if (context.StartPosition == context.InsertionPosition) {
textEditor.Document.Insert(context.InsertionPosition, " ");
context.InsertionPosition++;
}
CreatePropertiesDialog dialog = new CreatePropertiesDialog(context, textEditor, anchor, current, parameters);
CreatePropertiesDialog dialog = new CreatePropertiesDialog(context, textEditor, anchor);
dialog.Element = uiService.CreateInlineUIElement(anchor, dialog);
dialog.Element = uiService.CreateInlineUIElement(anchor, dialog);
return dialog;
}
static IEnumerable<FieldWrapper> FindFields(IClass sourceClass)
{
int i = 0;
return dialog;
foreach (var f in sourceClass.Fields.Where(field => !field.IsConst
&& field.ReturnType != null)) {
yield return new FieldWrapper(f) { Index = i };
i++;
}
}
}

20
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreatePropertiesCommand.cs

@ -4,23 +4,21 @@ @@ -4,23 +4,21 @@
using System;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Refactoring;
using SharpRefactoring.Gui;
namespace CSharpBinding.Refactoring
{
public class CreatePropertiesCommand : AbstractRefactoringCommand
public class CreatePropertiesCommand // : AbstractRefactoringCommand
{
protected override void Run(ITextEditor textEditor, RefactoringProvider provider)
{
new Snippet {
Elements = {
new InlineRefactorSnippetElement(context => CreateProperties.CreateDialog(context), "")
}
}.Insert((TextArea)textEditor.GetService(typeof(TextArea)));
}
// protected override void Run(ITextEditor textEditor, RefactoringProvider provider)
// {
// new Snippet {
// Elements = {
// new InlineRefactorSnippetElement(context => CreateProperties.CreateDialog(context), "")
// }
// }.Insert((TextArea)textEditor.GetService(typeof(TextArea)));
// }
}
}

40
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreatePropertiesDialog.xaml

@ -6,35 +6,6 @@ @@ -6,35 +6,6 @@
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Cursor="Arrow" KeyboardNavigation.TabNavigation="Cycle">
<Grid.Resources>
<Style x:Key="ListViewItemFocusHighlight" TargetType="{x:Type ListViewItem}">
<!-- This style replaces the default ListViewItem template with one that highlights the focused item instead of the selected items -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin"
Value="true">
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@ -45,13 +16,20 @@ @@ -45,13 +16,20 @@
Text="{sd:Localize AddIns.SharpRefactoring.CreateProperties.Description}"
TextWrapping="Wrap" />
<CheckBox x:Name="implementInterface" Margin="3" Grid.Row="1" Content="{sd:Localize AddIns.SharpRefactoring.CreateProperties.Description.ImplementINotifyPropertyChanged}" />
<ListView x:Name="listBox" Grid.Row="2" SelectionMode="Multiple" KeyboardNavigation.TabNavigation="Cycle" ItemContainerStyle="{StaticResource ListViewItemFocusHighlight}" MaxHeight="300">
<ListView x:Name="listBox" Grid.Row="2" SelectionMode="Multiple" KeyboardNavigation.TabNavigation="Cycle" MaxHeight="300">
<ListView.View>
<GridView>
<GridViewColumn Header="{sd:Localize AddIns.SharpRefactoring.InsertCtor.VariableLabel}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Content="{Binding Text}" IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0" IsChecked="{Binding IsIncluded}" VerticalAlignment="Center" Margin="0,0,3,0" />
<TextBlock Grid.Column="1" Text="{Binding Text}" />
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

290
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CreatePropertiesDialog.xaml.cs

@ -4,13 +4,19 @@ @@ -4,13 +4,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Refactoring;
using CSharpBinding.Parser;
namespace CSharpBinding.Refactoring
{
@ -21,75 +27,231 @@ namespace CSharpBinding.Refactoring @@ -21,75 +27,231 @@ namespace CSharpBinding.Refactoring
{
IList<FieldWrapper> fields;
public CreatePropertiesDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor, IClass current, IList<FieldWrapper> availableFields)
public CreatePropertiesDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor)
: base(context, editor, anchor)
{
InitializeComponent();
}
protected override void Initialize()
{
base.Initialize();
this.listBox.ItemsSource = fields = availableFields;
var typeResolveContext = refactoringContext.GetTypeResolveContext();
if (typeResolveContext == null) {
return;
}
var resolvedCurrent = typeResolveContext.CurrentTypeDefinition;
fields = FindFields(resolvedCurrent).ToList();
this.listBox.ItemsSource = fields;
if (!fields.Any())
Visibility = System.Windows.Visibility.Collapsed;
if (fields.Any())
Visibility = System.Windows.Visibility.Visible;
implementInterface.IsChecked = !current.IsStatic && HasOnPropertyChanged(current);
if (current.IsStatic)
implementInterface.IsChecked = !resolvedCurrent.IsStatic && HasOnPropertyChanged(resolvedCurrent);
if (resolvedCurrent.IsStatic)
implementInterface.Visibility = System.Windows.Visibility.Collapsed;
listBox.UnselectAll();
SelectAllUnchecked();
}
static IEnumerable<FieldWrapper> FindFields(IType sourceClass)
{
int i = 0;
foreach (var f in sourceClass.GetFields().Where(field => !field.IsConst
&& field.ReturnType != null)) {
yield return new FieldWrapper(f) { Index = i };
i++;
}
}
protected override string GenerateCode(LanguageProperties language, IClass currentClass)
protected override string GenerateCode(ITypeDefinition currentClass)
{
StringBuilder builder = new StringBuilder();
IDocumentLine line = editor.Document.GetLineForOffset(anchor.Offset);
string indent = DocumentUtilitites.GetWhitespaceAfter(editor.Document, line.Offset);
bool implementInterface = this.implementInterface.IsChecked == true;
bool hasOnPropertyChanged = HasOnPropertyChanged(currentClass);
bool useEventArgs = false;
if (implementInterface && !currentClass.IsStatic) {
if (!hasOnPropertyChanged) {
var nodes = new List<AbstractNode>();
var rt = new GetClassReturnType(currentClass.ProjectContent, "System.ComponentModel.INotifyPropertyChanged", 0);
if (!currentClass.ClassInheritanceTree.Any(bt => bt.FullyQualifiedName == "System.ComponentModel.INotifyPropertyChanged")) {
int insertion = editor.Document.PositionToOffset(currentClass.BodyRegion.BeginLine, currentClass.BodyRegion.BeginColumn);
if (currentClass.BaseTypes.Count > 0)
editor.Document.Insert(insertion, ", INotifyPropertyChanged");
else
editor.Document.Insert(insertion, " : INotifyPropertyChanged");
AstNode insertionAnchorElement = refactoringContext.GetNode();
if ((insertionAnchorElement == null) || !(insertionAnchorElement.Parent is TypeDeclaration)) {
return null;
}
NewLineNode newLineNode = insertionAnchorElement as NewLineNode;
while (insertionAnchorElement.PrevSibling is NewLineNode)
insertionAnchorElement = insertionAnchorElement.PrevSibling ?? insertionAnchorElement;
using (Script script = refactoringContext.StartScript()) {
TypeDeclaration currentClassDeclaration = insertionAnchorElement.Parent as TypeDeclaration;
if (implementInterface && !currentClass.IsStatic) {
if (!hasOnPropertyChanged) {
var nodes = new List<AstNode>();
if (!currentClass.GetAllBaseTypeDefinitions().Any(bt => bt.FullName == "System.ComponentModel.INotifyPropertyChanged")) {
// int insertion = editor.Document.GetOffset(currentClass.BodyRegion.BeginLine, currentClass.BodyRegion.BeginColumn);
AstNode nodeBeforeClassBlock = currentClassDeclaration.LBraceToken;
if (nodeBeforeClassBlock.PrevSibling is NewLineNode) {
// There's a new line before the brace, insert before it!
nodeBeforeClassBlock = nodeBeforeClassBlock.PrevSibling;
}
int insertion = editor.Document.GetOffset(nodeBeforeClassBlock.StartLocation);
AstType interfaceTypeNode = refactoringContext.CreateShortType("System.ComponentModel", "INotifyPropertyChanged", 0);
var directBaseTypes = currentClass.DirectBaseTypes.Where(t => t.FullName != "System.Object");
// if ((directBaseTypes != null) && (directBaseTypes.Count() > 0)) {
if (currentClassDeclaration.BaseTypes.Count > 0) {
script.InsertText(insertion, ", " + interfaceTypeNode.GetText() + " ");
} else {
script.InsertText(insertion, " : " + interfaceTypeNode.GetText() + " ");
}
}
var rt = new GetClassTypeReference("System.ComponentModel", "INotifyPropertyChanged", 0);
var rtResolved = rt.Resolve(refactoringContext.Compilation);
var ev = rtResolved.GetEvents().First(e => e.Name == "PropertyChanged");
EventDeclaration propertyChangedEvent = new EventDeclaration();
propertyChangedEvent.Variables.Add(new VariableInitializer(ev.Name));
propertyChangedEvent.Modifiers = Modifiers.Public;
propertyChangedEvent.ReturnType = refactoringContext.CreateShortType(ev.ReturnType);
nodes.Add(propertyChangedEvent);
MethodDeclaration onEvent = CreateOnEventMethod(ev, currentClass);
nodes.Add(onEvent);
foreach (var node in nodes) {
script.InsertAfter(insertionAnchorElement, node);
AppendNewLine(script, insertionAnchorElement, newLineNode);
}
useEventArgs = false;
} else {
useEventArgs = currentClass.GetMethods().First(m => m.Name == "OnPropertyChanged").Parameters[0].Type.FullName != "System.String";
}
language.CodeGenerator.ImplementInterface(nodes, rt, false, currentClass);
var ev = rt.GetEvents().First(e => e.Name == "PropertyChanged");
MethodDeclaration onEvent = language.CodeGenerator.CreateOnEventMethod(new DefaultEvent(ev.Name, ev.ReturnType, ev.Modifiers, ev.Region, ev.BodyRegion, currentClass));
nodes.Add(onEvent);
onEvent.Parameters[0].TypeReference = new TypeReference("string", true);
onEvent.Parameters[0].ParameterName = "propertyName";
((RaiseEventStatement)onEvent.Body.Children[0]).Arguments[1] = new ObjectCreateExpression(new TypeReference("PropertyChangedEventArgs"), new List<Expression> { new IdentifierExpression("propertyName") });
foreach (var node in nodes)
builder.AppendLine(language.CodeGenerator.GenerateCode(node, indent));
useEventArgs = false;
} else {
useEventArgs = currentClass.DefaultReturnType.GetMethods().First(m => m.Name == "OnPropertyChanged").Parameters[0].ReturnType.FullyQualifiedName != "System.String";
}
}
foreach (FieldWrapper field in listBox.SelectedItems) {
var prop = language.CodeGenerator.CreateProperty(field.Field, true, field.AddSetter);
if (!field.Field.IsStatic && !currentClass.IsStatic && field.AddSetter && implementInterface) {
var invocation = new ExpressionStatement(CreateInvocation(field.PropertyName, useEventArgs));
var assignment = prop.SetRegion.Block.Children[0];
prop.SetRegion.Block.Children.Clear();
prop.SetRegion.Block.AddChild(
new IfElseStatement(
new BinaryOperatorExpression(new IdentifierExpression(field.MemberName), BinaryOperatorType.InEquality, new IdentifierExpression("value")),
new BlockStatement { Children = { assignment, invocation } }
)
);
foreach (FieldWrapper field in fields.Where(f => f.IsIncluded)) {
var prop = CreateProperty(field.Field, true, field.AddSetter);
if (!field.Field.IsStatic && !currentClass.IsStatic && field.AddSetter && implementInterface) {
var invocation = new ExpressionStatement(CreateInvocation(field.PropertyName, useEventArgs));
var assignment = prop.Setter.Body.Children.ElementAt(0) as Statement;
prop.Setter.Body = new BlockStatement();
BlockStatement elseBlock = new BlockStatement();
elseBlock.Add(assignment.Clone());
elseBlock.Add(invocation);
prop.Setter.Body.Add(
new IfElseStatement(
new BinaryOperatorExpression(new IdentifierExpression(field.MemberName), BinaryOperatorType.InEquality, new IdentifierExpression("value")),
elseBlock
)
);
}
script.InsertAfter(insertionAnchorElement, prop);
AppendNewLine(script, insertionAnchorElement, newLineNode);
}
builder.AppendLine(language.CodeGenerator.GenerateCode(prop, indent));
}
return builder.ToString().Trim();
return null;
}
MethodDeclaration CreateOnEventMethod(IEvent e, ITypeDefinition currentClass)
{
List<ParameterDeclaration> parameters = new List<ParameterDeclaration>();
// bool sender = false;
// if (e.ReturnType != null) {
// IMethod invoke = e.ReturnType.GetMethods().SingleOrDefault(m => m.Name=="Invoke" );
// if (invoke != null) {
// foreach (IParameter param in invoke.Parameters) {
// parameters.Add(new ParameterDeclaration(ConvertType(param.Type), param.Name));
// }
// if (parameters.Count > 0 && string.Equals(parameters[0].Name, "sender", StringComparison.InvariantCultureIgnoreCase)) {
// sender = true;
// parameters.RemoveAt(0);
// }
// }
// }
parameters.Add(new ParameterDeclaration(ConvertType(KnownTypeCode.String), "propertyName"));
Modifiers modifier;
if (e.IsStatic)
modifier = Modifiers.Private | Modifiers.Static;
else if ((e.DeclaringType.GetDefinition() != null) && e.DeclaringType.GetDefinition().IsSealed)
modifier = Modifiers.Private;
else
modifier = Modifiers.Protected | Modifiers.Virtual;
MethodDeclaration method = new MethodDeclaration {
Name = "On" + e.Name,
Modifiers = ConvertModifier(modifier, currentClass),
ReturnType = ConvertType(KnownTypeCode.Void)
};
method.Parameters.AddRange(parameters);
List<Expression> arguments = new List<Expression>();
// if (sender) {
if (e.IsStatic)
arguments.Add(new PrimitiveExpression(null, "null"));
else
arguments.Add(new ThisReferenceExpression());
// }
// foreach (ParameterDeclaration param in parameters) {
// arguments.Add(new IdentifierExpression(param.Name));
// }
arguments.Add(new ObjectCreateExpression(refactoringContext.CreateShortType("System.ComponentModel", "PropertyChangedEventArgs", 0),
new List<Expression> { new IdentifierExpression("propertyName") }));
method.Body = new BlockStatement();
// method.Body.Add(new RaiseEventStatement(e.Name, arguments));
method.Body.Add(new ExpressionStatement(new InvocationExpression(new MemberReferenceExpression(new ThisReferenceExpression(), e.Name), arguments)));
return method;
}
PropertyDeclaration CreateProperty(IField field, bool createGetter, bool createSetter)
{
IProject project = field.Compilation.GetProject();
if (project == null)
return null;
CodeGenerator codeGenerator = project.LanguageBinding.CodeGenerator;
string name = codeGenerator.GetPropertyName(field.Name);
CSharpFullParseInformation tempParseInformation;
PropertyDeclaration property = new PropertyDeclaration()
{
Modifiers = ConvertModifier(field.GetDeclaration(out tempParseInformation).Modifiers, field.DeclaringTypeDefinition),
Name = name
};
property.ReturnType = ConvertType(field.ReturnType);
if (createGetter) {
property.Getter = new Accessor()
{
Body = new BlockStatement()
};
property.Getter.Body.Add(new ReturnStatement(new IdentifierExpression(field.Name)));
}
if (createSetter) {
property.Setter = new Accessor()
{
Body = new BlockStatement()
};
property.Setter.Body.Add(new AssignmentExpression(new IdentifierExpression(field.Name), new IdentifierExpression("value")));
}
property.Modifiers = Modifiers.Public | (property.Modifiers & Modifiers.Static);
return property;
}
public static Modifiers ConvertModifier(Modifiers modifiers, ITypeDefinition targetContext)
{
IProject project = targetContext.ParentAssembly.GetProject();
if (targetContext != null && project != null && targetContext.DeclaringType != null) {
// if (project.LanguageBinding.IsClassWithImplicitlyStaticMembers(targetContext.CallingClass)) {
return modifiers & ~Modifiers.Static;
// }
}
if (modifiers.HasFlag(Modifiers.Static))
modifiers &= ~(Modifiers.Abstract | Modifiers.Sealed);
return modifiers;
}
string GetCodeFromRegion(DomRegion region)
@ -99,31 +261,45 @@ namespace CSharpBinding.Refactoring @@ -99,31 +261,45 @@ namespace CSharpBinding.Refactoring
return editor.Document.GetText(startOffset, endOffset - startOffset);
}
bool HasOnPropertyChanged(IClass currentClass)
bool HasOnPropertyChanged(ITypeDefinition currentClass)
{
return currentClass.DefaultReturnType.GetMethods().Any(m => m.Name == "OnPropertyChanged");
return currentClass.GetMethods().Any(m => m.Name == "OnPropertyChanged");
}
InvocationExpression CreateInvocation(string name, bool useEventArgs)
{
Expression arg = useEventArgs
? (Expression)new ObjectCreateExpression(new TypeReference("PropertyChangedEventArgs"), new List<Expression> { new PrimitiveExpression(name) })
? (Expression)new ObjectCreateExpression(refactoringContext.CreateShortType("System.ComponentModel", "PropertyChangedEventArgs", 0), new List<Expression> { new PrimitiveExpression(name) })
: (Expression)new PrimitiveExpression(name);
return new InvocationExpression(new IdentifierExpression("OnPropertyChanged"), new List<Expression> { arg });
}
void SelectAllChecked()
{
foreach (var param in fields) {
param.IsIncluded = true;
}
}
void SelectAllChecked(object sender, System.Windows.RoutedEventArgs e)
{
listBox.SelectAll();
SelectAllChecked();
}
void SelectAllUnchecked()
{
foreach (var param in fields) {
param.IsIncluded = false;
}
}
void SelectAllUnchecked(object sender, System.Windows.RoutedEventArgs e)
{
listBox.UnselectAll();
SelectAllUnchecked();
}
bool AllSelected {
get { return listBox.SelectedItems.Count == listBox.Items.Count; }
get { return fields.Count(p => p.IsIncluded) == fields.Count; }
}
protected override void OnKeyDown(KeyEventArgs e)

12
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/FieldWrapper.cs

@ -17,6 +17,7 @@ namespace CSharpBinding.Refactoring @@ -17,6 +17,7 @@ namespace CSharpBinding.Refactoring
/// </summary>
readonly IField field;
private string text;
bool isIncluded;
public IField Field {
get { return field; }
@ -38,6 +39,17 @@ namespace CSharpBinding.Refactoring @@ -38,6 +39,17 @@ namespace CSharpBinding.Refactoring
this.text = ambience.ConvertEntity(member);
}
public bool IsIncluded
{
get {
return isIncluded;
}
set {
isIncluded = value;
OnPropertyChanged("IsIncluded");
}
}
public string MemberName {
get { return field.Name; }
}

6
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/InsertCtorSnippetRefactoring.cs

@ -2,16 +2,10 @@ @@ -2,16 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Parser;
using CSharpBinding.Refactoring;
using ICSharpCode.SharpDevelop.Editor;

1
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/OverrideToStringMethodDialog.xaml.cs

@ -5,7 +5,6 @@ using System; @@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.Snippets;

Loading…
Cancel
Save