Browse Source

Localization

pull/567/head
Peter Forstmeier 11 years ago
parent
commit
fdc5912ce1
  1. 119
      data/resources/StringResources.de.resx
  2. 18
      data/resources/StringResources.es-mx.resx
  3. 18
      data/resources/StringResources.es.resx
  4. 5102
      data/resources/StringResources.jp.resx
  5. 120
      data/resources/StringResources.resx
  6. 642
      data/resources/StringResources.ru.resx
  7. 4
      data/resources/languages/LanguageDefinition.xml
  8. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin
  9. 17
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs
  10. 6
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/FormattingOptionBinding.cs
  11. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormsDesigner/CSharpEventBindingService.cs
  12. 36
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs
  13. 26
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs
  14. 10
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs
  15. 9
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs
  16. 8
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SearchForIssuesDialog.xaml
  17. 49
      src/AddIns/BackendBindings/Python/PyWalker/AssemblyInfo.cs
  18. 441
      src/AddIns/BackendBindings/Python/PyWalker/CodeDomVisitor.cs
  19. 46
      src/AddIns/BackendBindings/Python/PyWalker/Indentation.cs
  20. 210
      src/AddIns/BackendBindings/Python/PyWalker/MainForm.Designer.cs
  21. 157
      src/AddIns/BackendBindings/Python/PyWalker/MainForm.cs
  22. 123
      src/AddIns/BackendBindings/Python/PyWalker/MainForm.resx
  23. 678
      src/AddIns/BackendBindings/Python/PyWalker/NRefactoryAstVisitor.cs
  24. 41
      src/AddIns/BackendBindings/Python/PyWalker/Program.cs
  25. 84
      src/AddIns/BackendBindings/Python/PyWalker/PyWalker.csproj
  26. 237
      src/AddIns/BackendBindings/Python/PyWalker/ResolveWalker.cs
  27. 31
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Configuration/AssemblyInfo.cs
  28. 79
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Python.Build.Tasks.csproj
  29. 105
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/SharpDevelop.Build.Python.targets
  30. 83
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/IPythonCompiler.cs
  31. 282
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompiler.cs
  32. 313
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompilerTask.cs
  33. 58
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/ResourceFile.cs
  34. 36
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/Resources.cs
  35. 49
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/AssemblyInfo.cs
  36. 90
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/CompileResourcesTestFixture.cs
  37. 120
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/CompileSingleSourceFileTestFixture.cs
  38. 84
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/DifferentTargetTypesTestFixture.cs
  39. 109
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/DummyPythonCompilerTask.cs
  40. 72
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/IOErrorTestFixture.cs
  41. 77
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/IncludeDebugInfoTestFixture.cs
  42. 59
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/LogicalResourceNamesTests.cs
  43. 72
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/MainEntryPointTestFixture.cs
  44. 67
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/MissingMainEntryPointTestFixture.cs
  45. 160
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/MockPythonCompiler.cs
  46. 116
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/PlatformTestFixture.cs
  47. 90
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/Python.Build.Tasks.Tests.csproj
  48. 57
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/PythonCompilerTests.cs
  49. 69
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/RelativeReferenceTestFixture.cs
  50. 69
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/RelativeResourceFileTestFixture.cs
  51. 79
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorFileNameWithDotCharTestFixture.cs
  52. 71
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorNullFileNameTestFixture.cs
  53. 119
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorTestFixture.cs
  54. 78
      src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorUnknownFileNameTestFixture.cs
  55. 206
      src/AddIns/BackendBindings/Python/PythonBinding.sln
  56. 31
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Configuration/AssemblyInfo.cs
  57. 25
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Lib/__future__.py
  58. 31
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Lib/runpy.py
  59. 14
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Lib/site.py
  60. 227
      src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin
  61. 319
      src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
  62. 138
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/ApplicationSettingsPanel.xfrm
  63. 71
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/CompilingOptionsPanel.xfrm
  64. 135
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/Python.xshd
  65. 100
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs
  66. 154
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ApplicationSettingsPanel.cs
  67. 108
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CompilingOptionsPanel.cs
  68. 68
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConstructorInfo.cs
  69. 170
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConvertProjectToPythonProjectCommand.cs
  70. 66
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConvertToPythonMenuCommand.cs
  71. 28
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonResolver.cs
  72. 90
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/MemberName.cs
  73. 2074
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs
  74. 159
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs
  75. 37
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonBuiltInModuleMemberName.cs
  76. 106
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonClass.cs
  77. 79
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonClassFields.cs
  78. 119
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonClassResolver.cs
  79. 56
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeBuilder.cs
  80. 69
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeCompletionBinding.cs
  81. 31
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeCompletionItemProvider.cs
  82. 253
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDeserializer.cs
  83. 388
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs
  84. 33
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilationUnit.cs
  85. 52
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerError.cs
  86. 59
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerSink.cs
  87. 39
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompletionItemList.cs
  88. 417
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs
  89. 32
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalkerException.cs
  90. 86
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
  91. 46
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs
  92. 103
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleHost.cs
  93. 36
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsolePad.cs
  94. 32
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConstructor.cs
  95. 533
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs
  96. 103
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerGenerator.cs
  97. 43
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerLoader.cs
  98. 37
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerLoaderProvider.cs
  99. 91
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonExpression.cs
  100. 208
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonExpressionFinder.cs
  101. Some files were not shown because too many files have changed in this diff Show More

119
data/resources/StringResources.de.resx

@ -294,7 +294,7 @@ Laden Sie ein AddIn aus dem Internet herunter, klicken Sie auf "AddIn installier @@ -294,7 +294,7 @@ Laden Sie ein AddIn aus dem Internet herunter, klicken Sie auf "AddIn installier
{1}
Sie werden nicht mehr funktionieren nachdem dieses AddIn deaktiviert wurde! Sind Sie sicher, dass Sie fortfahren möchten?</value>
Sie werden nicht mehr funktionieren, nachdem dieses AddIn deaktiviert wurde! Sind Sie sicher, dass Sie fortfahren möchten?</value>
</data>
<data name="AddInManager2.InstallDependentMessage" xml:space="preserve">
<value>Das Paket "{0}" benötigt noch mindestens ein zusätzliches Paket:
@ -332,6 +332,9 @@ Wenn Sie den Lizenzbedingungen nicht zustimmen, klicken Sie auf "Ablehnen".</val @@ -332,6 +332,9 @@ Wenn Sie den Lizenzbedingungen nicht zustimmen, klicken Sie auf "Ablehnen".</val
<data name="AddInManager2.OptionPanel.Add" xml:space="preserve">
<value>Hinzufügen</value>
</data>
<data name="AddInManager2.OptionPanel.AutoCheckForUpdates" xml:space="preserve">
<value>Automatisch nach Updates suchen</value>
</data>
<data name="AddInManager2.OptionPanel.MoveDown" xml:space="preserve">
<value>Nach unten</value>
</data>
@ -350,6 +353,9 @@ Wenn Sie den Lizenzbedingungen nicht zustimmen, klicken Sie auf "Ablehnen".</val @@ -350,6 +353,9 @@ Wenn Sie den Lizenzbedingungen nicht zustimmen, klicken Sie auf "Ablehnen".</val
<data name="AddInManager2.OptionPanel.Tree.AddIns" xml:space="preserve">
<value>AddIns</value>
</data>
<data name="AddInManager2.OptionPanel.Tree.General" xml:space="preserve">
<value>Allgemein</value>
</data>
<data name="AddInManager2.OptionPanel.Tree.Repositories" xml:space="preserve">
<value>Quellen</value>
</data>
@ -1201,9 +1207,7 @@ Ein Ausführungskommando kann in den Projektoptionen eingestellt werden.</value> @@ -1201,9 +1207,7 @@ Ein Ausführungskommando kann in den Projektoptionen eingestellt werden.</value>
<value>Ink</value>
</data>
<data name="ComponentInspector.EventLogList.NoEventsBeingLoggedMessage" xml:space="preserve">
<value>Sie protokollieren keine Ereignisse.
Wählen Sie ein Objekt oder ein Ereignis im Objekte-Panel und klicken Sie mit der rechten Maustaste oder benutzen Sie das "Aktion"-Menü um mit dem Protokollieren von Ereignissen zu beginnen.</value>
<value>Sie protokollieren keine Ereignisse. Wählen Sie ein Objekt oder ein Ereignis im Objekte-Panel und klicken Sie mit der rechten Maustaste oder benutzen Sie das "Aktion"-Menü um mit dem Protokollieren von Ereignissen zu beginnen.</value>
</data>
<data name="ComponentInspector.EventLogList.ParametersColumnHeader" xml:space="preserve">
<value>Parameter</value>
@ -1534,6 +1538,30 @@ Um ActiveX/COM-Objekte zu generieren, ziehen sie eine Klasse aus einer Typbiblio @@ -1534,6 +1538,30 @@ Um ActiveX/COM-Objekte zu generieren, ziehen sie eine Klasse aus einer Typbiblio
<data name="CQA.MainWindow.FormTitle" xml:space="preserve">
<value>Code-Qualitätsanalyse</value>
</data>
<data name="CSharpBinding.Formatting.AutoFormat" xml:space="preserve">
<value>Code automatisch formatieren</value>
</data>
<data name="CSharpBinding.Formatting.DefaultOptionReference" xml:space="preserve">
<value>(Standard)</value>
</data>
<data name="CSharpBinding.Formatting.GlobalOptionReference" xml:space="preserve">
<value>(Global)</value>
</data>
<data name="CSharpBinding.Formatting.NoPresetSelectedMessage" xml:space="preserve">
<value>Keine Formatierungsvoreinstellung ausgewählt!</value>
</data>
<data name="CSharpBinding.Formatting.PresetOverwriteQuestion" xml:space="preserve">
<value>Sind Sie sicher, dass Sie alle Formatierungseinstellungen zurücksetzen wollen?</value>
</data>
<data name="CSharpBinding.Formatting.ProjectOptionReference" xml:space="preserve">
<value>(Projekt)</value>
</data>
<data name="CSharpBinding.Formatting.ResetTo" xml:space="preserve">
<value>Zurücksetzen auf:</value>
</data>
<data name="CSharpBinding.Formatting.SolutionOptionReference" xml:space="preserve">
<value>(Projektmappe)</value>
</data>
<data name="CSharpBinding.GenerateNewHandlerInstructions" xml:space="preserve">
<value>Füge Reference zu Methode ein; drücke Tab oder Enter zweimal, um eine neue Methode anzulegen.</value>
</data>
@ -1650,6 +1678,9 @@ Beispiele: "120", "MainClass", "Main.cs, 120".</value> @@ -1650,6 +1678,9 @@ Beispiele: "120", "MainClass", "Main.cs, 120".</value>
<data name="Dialog.HighlightingEditor.ColorDlg.Italic" xml:space="preserve">
<value>Kursiv</value>
</data>
<data name="Dialog.HighlightingEditor.ColorDlg.Underline" xml:space="preserve">
<value>Unterstrichen</value>
</data>
<data name="Dialog.HighlightingEditor.Export" xml:space="preserve">
<value>Hervorhebungsfarben exportieren</value>
</data>
@ -1954,6 +1985,12 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value> @@ -1954,6 +1985,12 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value>
<data name="Dialog.Options.IDEOptions.CodeCompletion.ClearCache" xml:space="preserve">
<value>Cache leeren</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CommitOnCharacters" xml:space="preserve">
<value>Den gewählten Code completion-Eintrag bei Eingabe der folgenden Zeichen einfügen:</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CommitOnTabEnterOnly" xml:space="preserve">
<value>Den gewählten Code completion-Eintrag nur bei &lt;Tab&gt; oder &lt;Enter&gt; einfügen.</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CompleteWhenTyping" xml:space="preserve">
<value>Zeige Code Completion, wenn ein Buchstabe eingegeben wird</value>
</data>
@ -1975,6 +2012,18 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value> @@ -1975,6 +2012,18 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value>
<data name="Dialog.Options.IDEOptions.CodeCompletion.SaveItemCountBeforeNumber" xml:space="preserve">
<value>Speichere</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLabel" xml:space="preserve">
<value>Tooltip-Einstellungen</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLinkTarget" xml:space="preserve">
<value>Links in Tooltips führen zur</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLinkTargetDefinition" xml:space="preserve">
<value>Definition im Code</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLinkTargetDocumentation" xml:space="preserve">
<value>Dokumentation (falls verfügbar)</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.UseDataUsageCache" xml:space="preserve">
<value>Häufig benutzte Einträge bevorzugt markieren</value>
</data>
@ -2029,12 +2078,24 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value> @@ -2029,12 +2078,24 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value>
<data name="Dialog.Options.IDEOptions.Debugging.BreakAtBeginning" xml:space="preserve">
<value>Auf erster Anweisung des Programmes anhalten.</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ChooseExceptions" xml:space="preserve">
<value>Ausnahmen auswählen</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.EnableDecompiler" xml:space="preserve">
<value>Decompiler aktivieren</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.EnableEditAndContinue" xml:space="preserve">
<value>Bearbeiten und Fortfahren (EnC) aktivieren</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ExceptionFilter.ColumnExpression" xml:space="preserve">
<value>Voller Name der Ausnahme</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ExceptionFilter.ColumnIsActive" xml:space="preserve">
<value>Unterbrechen bei</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ExceptionFilterTitle" xml:space="preserve">
<value>Wählen Sie Ausnahmen aus, bei denen der Debugger anhalten soll</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.Exceptions" xml:space="preserve">
<value>Ausnahmen</value>
</data>
@ -2347,6 +2408,9 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value> @@ -2347,6 +2408,9 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value>
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HighlightBracketCheckBox" xml:space="preserve">
<value>&amp;Passende Klammer markieren</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HighlightCurrentLineCheckBox" xml:space="preserve">
<value>Aktuelle Zeile hervorheben</value>
</data>
<data name="Dialog.Options.IDEOptions.TextEditor.Markers.HighlightSymbolCheckBox" xml:space="preserve">
<value>Symbole hervorheben</value>
</data>
@ -2608,6 +2672,9 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value> @@ -2608,6 +2672,9 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen?</value>
<data name="Dialog.ProjectOptions.BuildOptions.VBOptionsDefaultValues" xml:space="preserve">
<value>Standardwerte für VB Optionen:</value>
</data>
<data name="Dialog.ProjectOptions.CodeFormatting" xml:space="preserve">
<value>Codeformatierung</value>
</data>
<data name="Dialog.ProjectOptions.Configuration" xml:space="preserve">
<value>Konfiguration</value>
</data>
@ -3314,6 +3381,9 @@ Bitte einen anderen Dateinamen wählen.</value> @@ -3314,6 +3381,9 @@ Bitte einen anderen Dateinamen wählen.</value>
<data name="ICSharpCode.CodeCoverage.CodeNotCovered" xml:space="preserve">
<value>Nicht abgedeckter Code</value>
</data>
<data name="ICSharpCode.CodeCoverage.CodePartCovered" xml:space="preserve">
<value>Code teilweise abgedeckt</value>
</data>
<data name="ICSharpCode.CodeCoverage.Column" xml:space="preserve">
<value>Spalte</value>
</data>
@ -3586,6 +3656,9 @@ Bitte stellen Sie den Pfad zur NAnt-Anwendung in den SharpDevelop-Optionen ein.< @@ -3586,6 +3656,9 @@ Bitte stellen Sie den Pfad zur NAnt-Anwendung in den SharpDevelop-Optionen ein.<
<data name="ICSharpCode.PythonBinding.UnknownTypeName" xml:space="preserve">
<value>Konnte Typ '{0}' nicht finden. Fehlt eine Assembly-Referenz?</value>
</data>
<data name="ICSharpCode.Refactoring.NoClassOrMemberUnderCursorError" xml:space="preserve">
<value>Es konnte keine Typ- oder Member-Definition an der Cursor-Position gefunden werden.</value>
</data>
<data name="ICSharpCode.Refactoring.NoClassOrOverridableSymbolUnderCursorError" xml:space="preserve">
<value>Das gewählte Element ist keine Klasse oder überschreibbares Mitglied, daher können keine Symbole angezeigt werden.</value>
</data>
@ -4305,6 +4378,9 @@ Grund: Der Wert zu dem zurückgesetzt werden soll ist ungültig weil sich eine a @@ -4305,6 +4378,9 @@ Grund: Der Wert zu dem zurückgesetzt werden soll ist ungültig weil sich eine a
<data name="ICSharpCode.SharpDevelop.Project.SolutionAlteredExternallyMessage" xml:space="preserve">
<value>Die Projektmappe wurde extern geändert.</value>
</data>
<data name="ICSharpCode.SharpDevelop.Project.SolutionFormattingOptions.Title" xml:space="preserve">
<value>Formatierungsoptionen der Projektmappe</value>
</data>
<data name="ICSharpCode.SharpDevelop.Project.UpgradeView.ChangeCompilerVersionLabel" xml:space="preserve">
<value>Neue &amp;Compilerversion:</value>
</data>
@ -5026,6 +5102,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -5026,6 +5102,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="MainWindow.Windows.ClassBrowser.OpenAssemblyFromGAC" xml:space="preserve">
<value>Assembly aus GAC öffnen...</value>
</data>
<data name="MainWindow.Windows.ClassBrowser.OpenInClassBrowser" xml:space="preserve">
<value>Im Klassenbrowser anzeigen</value>
</data>
<data name="MainWindow.Windows.ClassBrowser.SearchButton.ToolTip" xml:space="preserve">
<value>Suche nach Klassenname</value>
</data>
@ -5044,6 +5123,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -5044,6 +5123,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="MainWindow.Windows.CompilerMessageView.ToggleWordWrapButton.ToolTip" xml:space="preserve">
<value>Zeilenumbruch aktivieren/deaktivieren</value>
</data>
<data name="MainWindow.Windows.Debug.AddWatchExpression" xml:space="preserve">
<value>Ausdruck zur Überwachung hinzufügen</value>
</data>
<data name="MainWindow.Windows.Debug.Breakpoints" xml:space="preserve">
<value>Haltepunkte</value>
</data>
@ -5146,6 +5228,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -5146,6 +5228,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="MainWindow.Windows.Debug.ExceptionForm.Break" xml:space="preserve">
<value>Unterbrechen</value>
</data>
<data name="MainWindow.Windows.Debug.ExceptionForm.BreakOnHandled" xml:space="preserve">
<value>Unterbrechen bei behandelter ${ExceptionName}</value>
</data>
<data name="MainWindow.Windows.Debug.ExceptionForm.Continue" xml:space="preserve">
<value>Fortsetzen</value>
</data>
@ -5689,6 +5774,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -5689,6 +5774,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="ProjectComponent.ContextMenu.AddReference" xml:space="preserve">
<value>Referenz hinzufügen</value>
</data>
<data name="ProjectComponent.ContextMenu.AddServiceReference" xml:space="preserve">
<value>Service-Referenz hinzufügen</value>
</data>
<data name="ProjectComponent.ContextMenu.AddWebReference" xml:space="preserve">
<value>Web Referenz hinzufügen</value>
</data>
@ -6086,6 +6174,9 @@ Bitte einen anderen verwenden.</value> @@ -6086,6 +6174,9 @@ Bitte einen anderen verwenden.</value>
<data name="SharpDevelop.Refactoring.BaseClassesOf" xml:space="preserve">
<value>Basisklassen von ${Name}</value>
</data>
<data name="SharpDevelop.Refactoring.BaseMembersOf" xml:space="preserve">
<value>Basis-Member von ${Name}</value>
</data>
<data name="SharpDevelop.Refactoring.CannotPerformOperationBecauseOfSyntaxErrors" xml:space="preserve">
<value>Die Operation kann nicht ausgeführt werden, weil Ihr Sourcecode Fehler enthält:</value>
</data>
@ -6098,6 +6189,12 @@ Bitte einen anderen verwenden.</value> @@ -6098,6 +6189,12 @@ Bitte einen anderen verwenden.</value>
<data name="SharpDevelop.Refactoring.ClassesDerivingFrom" xml:space="preserve">
<value>Klassen, die von ${Name} erben</value>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRingCommand" xml:space="preserve">
<value>Aus Zwischenablagering</value>
</data>
<data name="SharpDevelop.Refactoring.ClipboardRingEmpty" xml:space="preserve">
<value>Der Zwischenablagering ist leer</value>
</data>
<data name="SharpDevelop.Refactoring.ConvertToAutomaticProperty" xml:space="preserve">
<value>In automatische Eigenschaft konvertieren</value>
</data>
@ -6128,6 +6225,9 @@ Bitte einen anderen verwenden.</value> @@ -6128,6 +6225,9 @@ Bitte einen anderen verwenden.</value>
<data name="SharpDevelop.Refactoring.FindBaseClassesCommand" xml:space="preserve">
<value>Finde Basisklassen</value>
</data>
<data name="SharpDevelop.Refactoring.FindBaseClassesOrMembersCommand" xml:space="preserve">
<value>Finde Basissymbole</value>
</data>
<data name="SharpDevelop.Refactoring.FindDerivedClassesCommand" xml:space="preserve">
<value>Abgeleitete Typen finden</value>
</data>
@ -6234,7 +6334,7 @@ Bitte einen anderen verwenden.</value> @@ -6234,7 +6334,7 @@ Bitte einen anderen verwenden.</value>
<value>Alle bekannten Projektformate</value>
</data>
<data name="SharpDevelop.Solution.CannotLoadOldSolution" xml:space="preserve">
<value>Diese Version von SharpDevelop kann keine Projekte, die mit Visual Studio .NET 2003 (oder früher) erstellt wurden.
<value>Diese Version von SharpDevelop kann keine Projekte laden, die mit Visual Studio .NET 2003 (oder früher) erstellt wurden.
Versuchen Sie das Projekt mit SharpDevelop 3.2 zu konvertieren, oder erstellen Sie ein neues Projekt und fügen Sie ihm die existierenden Quellcodedateien hinzu.</value>
</data>
<data name="SharpDevelop.Solution.CannotSave.IOException" xml:space="preserve">
@ -6563,6 +6663,9 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht @@ -6563,6 +6663,9 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht
<data name="StartPage.StartMenu.OpenCombineButton" xml:space="preserve">
<value>Projektmappe öffnen</value>
</data>
<data name="StartPage.StartMenu.RemoveRecentProject" xml:space="preserve">
<value>Aus der Liste der kürzlich verwendeten Projekte entfernen</value>
</data>
<data name="StartPage.StartPageContentName" xml:space="preserve">
<value>Startseite</value>
</data>
@ -6575,6 +6678,12 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht @@ -6575,6 +6678,12 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht
<data name="StatusBarService.CursorStatusBarPanelText" xml:space="preserve">
<value>Z ${Line} S ${Column} Zei ${Character}</value>
</data>
<data name="StatusBarService.SelectionStatusBarPanelTextMulti" xml:space="preserve">
<value>Lg ${Rows} * ${Cols} (${Total})</value>
</data>
<data name="StatusBarService.SelectionStatusBarPanelTextSingle" xml:space="preserve">
<value>Lg ${Length}</value>
</data>
<data name="Templates.File.Categories.Misc" xml:space="preserve">
<value>Sonstiges</value>
</data>

18
data/resources/StringResources.es-mx.resx

@ -1987,6 +1987,12 @@ Ejemplo: "120", "MainClass", "Main.cs, 120".</value> @@ -1987,6 +1987,12 @@ Ejemplo: "120", "MainClass", "Main.cs, 120".</value>
<data name="Dialog.Options.IDEOptions.CodeCompletion.ClearCache" xml:space="preserve">
<value>Borrar caché</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CommitOnCharacters" xml:space="preserve">
<value>Inserte entrada de autocompletado de código seleccionado escribiendo los siguientes caracteres:</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CommitOnTabEnterOnly" xml:space="preserve">
<value>Inserte solamente entrada de autocompletado de código seleccionado escribiendo &lt;Tab&gt; o &lt;Enter&gt;.</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CompleteWhenTyping" xml:space="preserve">
<value>Mostrar lista de completado después de escribir un carácter</value>
</data>
@ -2008,6 +2014,9 @@ Ejemplo: "120", "MainClass", "Main.cs, 120".</value> @@ -2008,6 +2014,9 @@ Ejemplo: "120", "MainClass", "Main.cs, 120".</value>
<data name="Dialog.Options.IDEOptions.CodeCompletion.SaveItemCountBeforeNumber" xml:space="preserve">
<value>Guardar</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLabel" xml:space="preserve">
<value>Preferencias de Tooltip</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLinkTarget" xml:space="preserve">
<value>Enlaces en tooltips deben ir en</value>
</data>
@ -3636,6 +3645,9 @@ Por favor configure la ubicación del archivo ejecutable de NAnt en las opciones @@ -3636,6 +3645,9 @@ Por favor configure la ubicación del archivo ejecutable de NAnt en las opciones
<data name="ICSharpCode.PythonBinding.UnknownTypeName" xml:space="preserve">
<value>No se pudo encontrar el tipo '{0}'.¿Falta una referencia a un ensamblado?</value>
</data>
<data name="ICSharpCode.Refactoring.NoClassOrMemberUnderCursorError" xml:space="preserve">
<value>No se pudo encontrar una definición de tipo o de miembro en la posición del cursor.</value>
</data>
<data name="ICSharpCode.Refactoring.NoClassOrOverridableSymbolUnderCursorError" xml:space="preserve">
<value>El elemento seleccionado no es una clase o miembro sobrescribible, así que no se puede mostrar ningún símbolo derivado.</value>
</data>
@ -6140,6 +6152,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -6140,6 +6152,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="SharpDevelop.Refactoring.BaseClassesOf" xml:space="preserve">
<value>Buscar clases base de ${Name}</value>
</data>
<data name="SharpDevelop.Refactoring.BaseMembersOf" xml:space="preserve">
<value>Miembros base de ${Name}</value>
</data>
<data name="SharpDevelop.Refactoring.CannotPerformOperationBecauseOfSyntaxErrors" xml:space="preserve">
<value>La operación no puede ser realizada debido a que su código fuente contiene errores:</value>
</data>
@ -6188,6 +6203,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -6188,6 +6203,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="SharpDevelop.Refactoring.FindBaseClassesCommand" xml:space="preserve">
<value>Buscar clases base</value>
</data>
<data name="SharpDevelop.Refactoring.FindBaseClassesOrMembersCommand" xml:space="preserve">
<value>Buscar símbolos base</value>
</data>
<data name="SharpDevelop.Refactoring.FindDerivedClassesCommand" xml:space="preserve">
<value>Buscar clases &amp;derivadas</value>
</data>

18
data/resources/StringResources.es.resx

@ -1984,6 +1984,12 @@ Para crear/manipular un objeto ActiveX/COM, arrastre una clase de un Control/Bib @@ -1984,6 +1984,12 @@ Para crear/manipular un objeto ActiveX/COM, arrastre una clase de un Control/Bib
<data name="Dialog.Options.IDEOptions.CodeCompletion.ClearCache" xml:space="preserve">
<value>Limpiar caché</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CommitOnCharacters" xml:space="preserve">
<value>Inserte la entrada de autocompletado de código seleccionada escribiendo los siguientes caracteres:</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CommitOnTabEnterOnly" xml:space="preserve">
<value>Inserte solamente la entrada de autocompletado de código seleccionado escribiendo &lt;Tab&gt; o &lt;Enter&gt;</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.CompleteWhenTyping" xml:space="preserve">
<value>Mostrar lista de completado después de escribir un carácter</value>
</data>
@ -2005,6 +2011,9 @@ Para crear/manipular un objeto ActiveX/COM, arrastre una clase de un Control/Bib @@ -2005,6 +2011,9 @@ Para crear/manipular un objeto ActiveX/COM, arrastre una clase de un Control/Bib
<data name="Dialog.Options.IDEOptions.CodeCompletion.SaveItemCountBeforeNumber" xml:space="preserve">
<value>Guardar</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLabel" xml:space="preserve">
<value>Preferencias de Tooltip</value>
</data>
<data name="Dialog.Options.IDEOptions.CodeCompletion.TooltipLinkTarget" xml:space="preserve">
<value>Enlaces en tooltips deben ir a</value>
</data>
@ -3637,6 +3646,9 @@ Por favor configure la ubicación del archivo ejecutable de NAnt en las opciones @@ -3637,6 +3646,9 @@ Por favor configure la ubicación del archivo ejecutable de NAnt en las opciones
<data name="ICSharpCode.PythonBinding.UnknownTypeName" xml:space="preserve">
<value>No se pudo encontrar el tipo '{0}'.¿Falta una referencia a un ensamblado?</value>
</data>
<data name="ICSharpCode.Refactoring.NoClassOrMemberUnderCursorError" xml:space="preserve">
<value>No se pudo encontrar definición de tipo o de miembro en la posición del cursor.</value>
</data>
<data name="ICSharpCode.Refactoring.NoClassOrOverridableSymbolUnderCursorError" xml:space="preserve">
<value>El elemento seleccionado no es una clase o miembro sobrescribible, así que no se puede mostrar ningún símbolo derivado.</value>
</data>
@ -6146,6 +6158,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -6146,6 +6158,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="SharpDevelop.Refactoring.BaseClassesOf" xml:space="preserve">
<value>Clases base de ${Name}</value>
</data>
<data name="SharpDevelop.Refactoring.BaseMembersOf" xml:space="preserve">
<value>Miembros base de ${Name}</value>
</data>
<data name="SharpDevelop.Refactoring.CannotPerformOperationBecauseOfSyntaxErrors" xml:space="preserve">
<value>La operación no puede ser realizada debido a que su código fuente contiene errores:</value>
</data>
@ -6194,6 +6209,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< @@ -6194,6 +6209,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension<
<data name="SharpDevelop.Refactoring.FindBaseClassesCommand" xml:space="preserve">
<value>Buscar clases base</value>
</data>
<data name="SharpDevelop.Refactoring.FindBaseClassesOrMembersCommand" xml:space="preserve">
<value>Buscar símbolos base</value>
</data>
<data name="SharpDevelop.Refactoring.FindDerivedClassesCommand" xml:space="preserve">
<value>Encontrar clases &amp;derivadas</value>
</data>

5102
data/resources/StringResources.jp.resx

File diff suppressed because it is too large Load Diff

120
data/resources/StringResources.resx

@ -6331,7 +6331,7 @@ Removed the end part of the original message ", reason '${Message}'" since this @@ -6331,7 +6331,7 @@ Removed the end part of the original message ", reason '${Message}'" since this
</data>
<data name="ResourceEditor.BitmapView.UpdateBitmap" xml:space="preserve">
<value>Update bitmap ...</value>
<comment>Text for the link label that make it possible to update the stored bitmap</comment>
<comment>Text for the button that makes it possible to update the stored bitmap</comment>
</data>
<data name="ResourceEditor.DeleteEntry.Confirm" xml:space="preserve">
<value>Do you really want to delete the selected resource(s)?</value>
@ -6713,8 +6713,7 @@ The resources files have been renamed/moved accordingly.</value> @@ -6713,8 +6713,7 @@ The resources files have been renamed/moved accordingly.</value>
<value>Section Visible</value>
</data>
<data name="SharpReport.ContextMenu.Settings" xml:space="preserve">
<value>Base Settings
</value>
<value>Base Settings</value>
</data>
<data name="SharpReport.Design" xml:space="preserve">
<value>Design</value>
@ -6737,6 +6736,10 @@ The resources files have been renamed/moved accordingly.</value> @@ -6737,6 +6736,10 @@ The resources files have been renamed/moved accordingly.</value>
<data name="SharpReport.DesignView.Toolbar.Printer" xml:space="preserve">
<value>Send report to printer</value>
</data>
<data name="Sharpreport.Error.NoPrinter" xml:space="preserve">
<value>To run SharpDevelop Reports you need at least one(1) installed Printer</value>
<comment>Errormessage when no printer is installed</comment>
</data>
<data name="SharpReport.Error.NoReport" xml:space="preserve">
<value>This is not a valid report created with 'SharpReport'.</value>
</data>
@ -6850,14 +6853,20 @@ The resources files have been renamed/moved accordingly.</value> @@ -6850,14 +6853,20 @@ The resources files have been renamed/moved accordingly.</value>
<value>Label</value>
</data>
<data name="SharpReport.Wizard.BaseSettings" xml:space="preserve">
<value>Basic Report Settings</value>
<value>Base settings</value>
</data>
<data name="SharpReport.Wizard.BaseSettings,ReportType" xml:space="preserve">
<value>Report Type</value>
<value>Report Type :</value>
</data>
<data name="SharpReport.Wizard.BaseSettings.FileName" xml:space="preserve">
<value>File Name :</value>
</data>
<data name="SharpReport.Wizard.BaseSettings.GraphicsUnit" xml:space="preserve">
<value>Graphics Unit</value>
</data>
<data name="SharpReport.Wizard.BaseSettings.Group" xml:space="preserve">
<value>Basic report settings</value>
</data>
<data name="SharpReport.Wizard.BaseSettings.ReportModel" xml:space="preserve">
<value>Report Model</value>
</data>
@ -6874,7 +6883,7 @@ The resources files have been renamed/moved accordingly.</value> @@ -6874,7 +6883,7 @@ The resources files have been renamed/moved accordingly.</value>
<value>Report Name :</value>
</data>
<data name="SharpReport.Wizard.BaseSettings.ReportType" xml:space="preserve">
<value>Report Type</value>
<value>Report Type :</value>
</data>
<data name="SharpReport.Wizard.Layout.Column" xml:space="preserve">
<value>Select the GroupColumn</value>
@ -6900,6 +6909,9 @@ The resources files have been renamed/moved accordingly.</value> @@ -6900,6 +6909,9 @@ The resources files have been renamed/moved accordingly.</value>
<data name="SharpReport.Wizard.PullModel.CommandText.ToolTip" xml:space="preserve">
<value>[Delete this text and enter a valid Sql String]</value>
</data>
<data name="SharpReport.Wizard.PushModel" xml:space="preserve">
<value>Push Data Model</value>
</data>
<data name="SharpReport.Wizard.PushModel.AvailableFields" xml:space="preserve">
<value>Available Fields</value>
</data>
@ -7498,7 +7510,7 @@ The resources files have been renamed/moved accordingly.</value> @@ -7498,7 +7510,7 @@ The resources files have been renamed/moved accordingly.</value>
<value>WPF Navigation Application</value>
</data>
<data name="Templates.SharpReport.NewReport" xml:space="preserve">
<value>Create a new Report using the Report Wizard</value>
<value>Create a new report using the Report Wizard</value>
</data>
<data name="XML.FormsDesigner.SideBar.CustomizeSidebar" xml:space="preserve">
<value>Configure Sidebar...</value>
@ -8199,21 +8211,101 @@ a line break</value> @@ -8199,21 +8211,101 @@ a line break</value>
<value>Break on</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ExceptionFilter.ColumnExpression" xml:space="preserve">
<value>Exception name expression (wildcards are allowed)</value>
<value>Full exception name</value>
</data>
<data name="Dialog.Options.IDEOptions.Debugging.ChooseExceptions" xml:space="preserve">
<value>Choose exceptions</value>
</data>
<data name="SharpReport.Wizard.BaseSettings.Description" xml:space="preserve">
<value>Base Settings and Page Layout</value>
<data name="MainWindow.Windows.Debug.ExceptionForm.BreakOnHandled" xml:space="preserve">
<value>Break on handled ${ExceptionName}</value>
</data>
<data name="SharpReport.Wizard.PageLayout" xml:space="preserve">
<value>Page Layout :</value>
<data name="MainWindow.Windows.TaskList.Solution" xml:space="preserve">
<value>Solution</value>
</data>
<data name="MainWindow.Windows.TaskList.Project" xml:space="preserve">
<value>Project</value>
</data>
<data name="MainWindow.Windows.TaskList.AllOpenedFiles" xml:space="preserve">
<value>All opened files</value>
</data>
<data name="MainWindow.Windows.TaskList.CurrentFile" xml:space="preserve">
<value>File</value>
</data>
<data name="MainWindow.Windows.TaskList.Namespace" xml:space="preserve">
<value>Namespace</value>
</data>
<data name="MainWindow.Windows.TaskList.CurrentClass" xml:space="preserve">
<value>Class/Module</value>
</data>
<data name="ResourceEditor.BitmapView.UpdateIcon" xml:space="preserve">
<value>Update icon ...</value>
<comment>Text for the button that makes it possible to update the stored icon</comment>
</data>
<data name="ResourceEditor.Messages.CantLoadResourceFromFile" xml:space="preserve">
<value>Can't load resource from file: {0}</value>
</data>
<data name="ResourceEditor.ResourceEdit.ContextMenu.AddBooleanEntry" xml:space="preserve">
<value>Add &amp;boolean entry</value>
</data>
<data name="ResourceEditor.Filter" xml:space="preserve">
<value>Filter:</value>
</data>
<data name="ResourceEditor.BitmapView.UpdateCursor" xml:space="preserve">
<value>Update cursor ...</value>
<comment>Text for the button that makes it possible to update the stored cursor</comment>
</data>
<data name="XML.MainMenu.SearchMenu.SearchForIssues" xml:space="preserve">
<value>Search For Issues...</value>
</data>
<data name="Dialog.SearchForIssues.AutoFix" xml:space="preserve">
<value>Automatically fix issues if possible</value>
</data>
<data name="Dialog.Options.ServicesReferencesText" xml:space="preserve">
<value>Service References</value>
</data>
<data name="XML.TextAreaContextMenu.Reformat" xml:space="preserve">
<value>Reformat</value>
</data>
<data name="Global.Reset" xml:space="preserve">
<value>Reset</value>
</data>
<data name="Dialog.ProjectOptions.CustomTool.RunOnBuild" xml:space="preserve">
<value>Run on Build</value>
</data>
<data name="Dialog.ProjectOptions.CustomTool.Filenames" xml:space="preserve">
<value>Filenames:</value>
</data>
<data name="Debugger.Visualizers.ColumnPickerLabel" xml:space="preserve">
<value>Columns:</value>
</data>
<data name="Global.Shortcuts.Ctrl" xml:space="preserve">
<value>Ctrl</value>
</data>
<data name="Global.Shortcuts.Shift" xml:space="preserve">
<value>Shift</value>
</data>
<data name="Global.Shortcuts.Alt" xml:space="preserve">
<value>Alt</value>
</data>
<data name="Global.Shortcuts.Win" xml:space="preserve">
<value>Win</value>
</data>
<data name="AddIns.Debugger.Console.Clear" xml:space="preserve">
<value>Clear console</value>
</data>
<data name="AddIns.Debugger.Console.DeleteHistory" xml:space="preserve">
<value>Delete history</value>
</data>
<data name="SharpReport.Wizard.Welcome" xml:space="preserve">
<value>Welcome to the SharpDevelop ReportWizard</value>
<value>Welcome to the SharpReport Wizard</value>
</data>
<data name="SharpReport.Wizard.BaseSettings.Description" xml:space="preserve">
<value>Basic report settings</value>
</data>
<data name="SharpReport.Wizard.PushModel.SelectProject" xml:space="preserve">
<value>Select a Project</value>
<value>Classes in selected Projecct</value>
</data>
<data name="SharpReport.Wizard.PageLayout" xml:space="preserve">
<value>Page Layout </value>
</data>
</root>

642
data/resources/StringResources.ru.resx

File diff suppressed because it is too large Load Diff

4
data/resources/languages/LanguageDefinition.xml

@ -14,9 +14,9 @@ @@ -14,9 +14,9 @@
<Languages name="French" code="fr" icon="france.png" />
<Languages name="German" code="de" icon="germany.png" />
<!--<Languages name="Greek" code="el" icon="notyetdone.png" />-->
<!--<Languages name="Hungarian" code="hu" icon="hungary.png" />-->
<Languages name="Hungarian" code="hu" icon="hungary.png" />
<Languages name="Italian" code="it" icon="italy.png" />
<!--<Languages name="Japanese" code="jp" icon="japan.png" />-->
<Languages name="Japanese" code="jp" icon="japan.png" />
<Languages name="Korean" code="kr" icon="south_korea.png" />
<!--<Languages name="Lithuanian" code="lt" icon="lithuania.png" />-->
<Languages name="Norwegian" code="no" icon="norway.png" />

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

@ -165,7 +165,7 @@ @@ -165,7 +165,7 @@
<Path path = "/SharpDevelop/Workbench/MainMenu/Search">
<MenuItem id = "SearchForIssues"
label="Search For Issues..."
label="${res:XML.MainMenu.SearchMenu.SearchForIssues}"
class="CSharpBinding.Refactoring.SearchForIssuesCommand"/>
</Path>

17
src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs

@ -37,14 +37,19 @@ namespace CSharpBinding @@ -37,14 +37,19 @@ namespace CSharpBinding
public static class ExtensionMethods
{
public static TextEditorOptions ToEditorOptions(this ITextEditor editor)
{
return ToEditorOptions(editor.Options);
}
public static TextEditorOptions ToEditorOptions(this ITextEditorOptions options)
{
return new TextEditorOptions {
TabsToSpaces = editor.Options.ConvertTabsToSpaces,
TabSize = editor.Options.IndentationSize,
IndentSize = editor.Options.IndentationSize,
ContinuationIndent = editor.Options.IndentationSize,
LabelIndent = -editor.Options.IndentationSize,
WrapLineLength = editor.Options.VerticalRulerColumn,
TabsToSpaces = options.ConvertTabsToSpaces,
TabSize = options.IndentationSize,
IndentSize = options.IndentationSize,
ContinuationIndent = options.IndentationSize,
LabelIndent = -options.IndentationSize,
WrapLineLength = options.VerticalRulerColumn
};
}

6
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/FormattingOptionBinding.cs

@ -22,6 +22,7 @@ using System.Windows; @@ -22,6 +22,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.SharpDevelop;
using CSharpBinding.OptionPanels;
namespace CSharpBinding.FormattingStrategy
@ -143,9 +144,8 @@ namespace CSharpBinding.FormattingStrategy @@ -143,9 +144,8 @@ namespace CSharpBinding.FormattingStrategy
static void FillBoolComboValues(ComboBox comboBox)
{
// TODO Add located resources!
comboBox.Items.Add(new ComboBoxItem { Content = "Yes", Tag = true });
comboBox.Items.Add(new ComboBoxItem { Content = "No", Tag = false });
comboBox.Items.Add(new ComboBoxItem { Content = SD.ResourceService.GetString("Global.Yes"), Tag = true });
comboBox.Items.Add(new ComboBoxItem { Content = SD.ResourceService.GetString("Global.No"), Tag = false });
}
static void FillIntComboValues(ComboBox comboBox)

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormsDesigner/CSharpEventBindingService.cs

@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.TypeSystem; @@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring;
using CSharpBinding.Refactoring;
namespace CSharpBinding.FormsDesigner
@ -147,7 +148,8 @@ namespace CSharpBinding.FormsDesigner @@ -147,7 +148,8 @@ namespace CSharpBinding.FormsDesigner
var primary = loader.GetPrimaryTypeDefinition();
var evtHandler = primary.GetMethods(m => m.Name == methodName, GetMemberOptions.IgnoreInheritedMembers).FirstOrDefault();
if (evtHandler == null) {
generator.InsertEventHandler(primary, methodName, evt, true);
var insertionType = GeneralOptionsPanel.InsertTodoComment ? InsertEventHandlerBodyKind.TodoComment : InsertEventHandlerBodyKind.Nothing;
generator.InsertEventHandler(primary, methodName, evt, true, insertionType);
} else {
CSharpBinding.Parser.CSharpFullParseInformation parseInfo;
var node = evtHandler.GetDeclaration(out parseInfo) as MethodDeclaration;

36
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/Parser.cs

@ -38,7 +38,6 @@ using ICSharpCode.SharpDevelop; @@ -38,7 +38,6 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor.Search;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring;
namespace CSharpBinding.Parser
{
@ -51,38 +50,6 @@ namespace CSharpBinding.Parser @@ -51,38 +50,6 @@ namespace CSharpBinding.Parser
return Path.GetExtension(fileName).Equals(".CS", StringComparison.OrdinalIgnoreCase);
}
/*
void RetrieveRegions(ISyntaxTree cu, ICSharpCode.NRefactory.Parser.SpecialTracker tracker)
{
for (int i = 0; i < tracker.CurrentSpecials.Count; ++i) {
ICSharpCode.NRefactory.PreprocessingDirective directive = tracker.CurrentSpecials[i] as ICSharpCode.NRefactory.PreprocessingDirective;
if (directive != null) {
if (directive.Cmd == "#region") {
int deep = 1;
for (int j = i + 1; j < tracker.CurrentSpecials.Count; ++j) {
ICSharpCode.NRefactory.PreprocessingDirective nextDirective = tracker.CurrentSpecials[j] as ICSharpCode.NRefactory.PreprocessingDirective;
if (nextDirective != null) {
switch (nextDirective.Cmd) {
case "#region":
++deep;
break;
case "#endregion":
--deep;
if (deep == 0) {
cu.FoldingRegions.Add(new FoldingRegion(directive.Arg.Trim(), DomRegion.FromLocation(directive.StartPosition, nextDirective.EndPosition)));
goto end;
}
break;
}
}
}
end: ;
}
}
}
}
*/
public ITextSource GetFileContent(FileName fileName)
{
return SD.FileService.GetFileContent(fileName);
@ -94,7 +61,6 @@ namespace CSharpBinding.Parser @@ -94,7 +61,6 @@ namespace CSharpBinding.Parser
var csharpProject = parentProject as CSharpProject;
CSharpParser parser = new CSharpParser(csharpProject != null ? csharpProject.CompilerSettings : null);
parser.GenerateTypeSystemMode = !fullParseInformationRequested;
SyntaxTree cu = parser.Parse(fileContent, fileName);
cu.Freeze();
@ -135,7 +101,7 @@ namespace CSharpBinding.Parser @@ -135,7 +101,7 @@ namespace CSharpBinding.Parser
int endOffset;
int searchOffset = 0;
// HACK: workaround for parser bug: uses \n instead of \r\n in comment.Content
string commentContent = document.GetText(commentStartOffset, commentEndOffset - commentStartOffset + 1);
string commentContent = document.GetText(commentStartOffset, Math.Min(commentEndOffset - commentStartOffset + 1, commentEndOffset - commentStartOffset));
do {
int start = commentStartOffset + searchOffset;
int absoluteOffset = document.IndexOf(match, start, document.TextLength - start, StringComparison.Ordinal);

26
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs

@ -66,7 +66,7 @@ namespace CSharpBinding.Refactoring @@ -66,7 +66,7 @@ namespace CSharpBinding.Refactoring
AddAttribute(target.Region, attribute, "return");
}
public override void InsertEventHandler(ITypeDefinition target, string name, IEvent eventDefinition, bool jumpTo)
public override void InsertEventHandler(ITypeDefinition target, string name, IEvent eventDefinition, bool jumpTo, InsertEventHandlerBodyKind bodyKind = InsertEventHandlerBodyKind.ThrowNotImplementedException)
{
IUnresolvedTypeDefinition match = null;
@ -103,12 +103,30 @@ namespace CSharpBinding.Refactoring @@ -103,12 +103,30 @@ namespace CSharpBinding.Refactoring
decl.Parameters.AddRange(param);
using (Script script = context.StartScript()) {
// FIXME : will not work properly if there are no members.
int eolLen = 0;
if (last == match) {
script.InsertWithCursor("Insert event handler", Script.InsertPosition.End, decl).FireAndForget();
eolLen = 2;
script.AddTo((TypeDeclaration)node, decl);
} else {
script.InsertAfter(node, decl);
script.Select(throwStmt);
}
switch (bodyKind) {
case InsertEventHandlerBodyKind.TodoComment:
Comment comment = new Comment(" TODO: Implement " + name);
script.Replace(throwStmt, comment);
script.Select(comment);
break;
case InsertEventHandlerBodyKind.Nothing:
var segment = script.GetSegment(throwStmt);
if (script is DocumentScript && eolLen > 0) {
eolLen = ((DocumentScript)script).CurrentDocument.GetLineByOffset(segment.Offset).DelimiterLength;
}
script.RemoveText(segment.Offset, segment.Length - eolLen);
script.Select(segment.Offset, segment.Offset);
break;
case InsertEventHandlerBodyKind.ThrowNotImplementedException:
script.Select(throwStmt);
break;
}
}
}

10
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs

@ -81,6 +81,16 @@ namespace CSharpBinding.Refactoring @@ -81,6 +81,16 @@ namespace CSharpBinding.Refactoring
editor.Select(startOffset, endOffset - startOffset);
}
public override void Select(int startOffset, int endOffset)
{
editor.Select(Math.Min(startOffset, endOffset), Math.Abs(endOffset - startOffset));
}
public override void Select(TextLocation start, TextLocation end)
{
Select(editor.Document.GetOffset(start), editor.Document.GetOffset(end));
}
public override Task Link(params AstNode[] nodes)
{
var segs = nodes.Select(node => GetSegment(node)).ToArray();

9
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs

@ -44,6 +44,7 @@ namespace CSharpBinding.Refactoring @@ -44,6 +44,7 @@ namespace CSharpBinding.Refactoring
readonly ITextEditor editor;
readonly ITextSource textSource;
readonly TextLocation location;
readonly TextEditorOptions editorOptions;
IDocument document;
int selectionStart, selectionLength;
@ -86,6 +87,7 @@ namespace CSharpBinding.Refactoring @@ -86,6 +87,7 @@ namespace CSharpBinding.Refactoring
this.selectionStart = selectionStart;
this.selectionLength = selectionLength;
this.location = location;
this.editorOptions = SD.EditorControlService.GlobalOptions.ToEditorOptions();
InitializeServices();
}
@ -99,6 +101,7 @@ namespace CSharpBinding.Refactoring @@ -99,6 +101,7 @@ namespace CSharpBinding.Refactoring
this.selectionStart = editor.SelectionStart;
this.selectionLength = editor.SelectionLength;
this.location = location;
this.editorOptions = editor.ToEditorOptions();
InitializeServices();
}
@ -131,6 +134,12 @@ namespace CSharpBinding.Refactoring @@ -131,6 +134,12 @@ namespace CSharpBinding.Refactoring
}
}
public override TextEditorOptions TextEditorOptions {
get {
return editorOptions;
}
}
public IDocument Document {
get {
IDocument result = LazyInit.VolatileRead(ref document);

8
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SearchForIssuesDialog.xaml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
WindowStartupLocation="CenterOwner"
Closing="Window_Closing"
MinHeight="250" MinWidth="200"
Height="450" Width="400" Title="Search For Issues">
Height="450" Width="400" Title="{core:Localize XML.MainMenu.SearchMenu.SearchForIssues}">
<Grid Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -24,15 +24,15 @@ @@ -24,15 +24,15 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<Label Content="Search In:" />
<Label Content="{core:Localize Dialog.NewProject.SearchReplace.SearchIn}" />
<widgets:RadioButtonGroup Name="searchInRBG" Margin="0,6,0,0" sd:EnumBinding.EnumType="local:SearchForIssuesTarget" />
</StackPanel>
<Label Content="Issues:" Grid.Row="1" HorizontalAlignment="Left" />
<tv:SharpTreeView Name="treeView" Grid.Row="2" Margin="4,0,4,4" />
<CheckBox Name="fixCheckBox" Grid.Row="3" Margin="8,0,0,0" Checked="FixCheckBox_Checked" Unchecked="FixCheckBox_Unchecked"
HorizontalAlignment="Left" Content="Automatically fix issues if possible" />
HorizontalAlignment="Left" Content="{core:Localize Dialog.SearchForIssues.AutoFix}" />
<StackPanel Grid.Row="4" Margin="4" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Content="Search" Style="{x:Static core:GlobalStyles.ButtonStyle}" Name="searchButton" IsDefault="True" Click="searchButton_Click" Margin="0,0,5,0" />
<Button Content="{core:Localize MainWindow.Windows.ClassBrowser.CommitSearch.ToolTip}" Style="{x:Static core:GlobalStyles.ButtonStyle}" Name="searchButton" IsDefault="True" Click="searchButton_Click" Margin="0,0,5,0" />
<Button Content="{core:Localize Global.CloseButtonText}" Style="{x:Static core:GlobalStyles.ButtonStyle}" IsCancel="True" />
</StackPanel>
</Grid>

49
src/AddIns/BackendBindings/Python/PyWalker/AssemblyInfo.cs

@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#region Using directives
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PyWalker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PyWalker")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("0.1")]

441
src/AddIns/BackendBindings/Python/PyWalker/CodeDomVisitor.cs

@ -1,441 +0,0 @@ @@ -1,441 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.CodeDom;
using System.Collections;
using System.Reflection;
using System.Text;
namespace PyWalker
{
/// <summary>
/// Visits the code dom generated by PythonProvider.
/// </summary>
public class CodeDomVisitor
{
IOutputWriter writer;
public CodeDomVisitor(IOutputWriter writer)
{
this.writer = writer;
}
public void Visit(CodeCompileUnit unit)
{
VisitCodeCompileUnit(unit);
}
void VisitCodeCompileUnit(CodeCompileUnit unit)
{
WriteLine("VisitCodeCompileUnit");
foreach (CodeNamespace ns in unit.Namespaces) {
VisitCodeNamespace(ns);
}
}
void VisitCodeNamespace(CodeNamespace ns)
{
WriteLine("VisitCodeNamespace: " + ns.Name);
foreach (CodeNamespaceImport import in ns.Imports) {
VisitCodeNamespaceImport(import);
}
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
foreach (CodeTypeDeclaration type in ns.Types) {
VisitCodeTypeDeclaration(type);
}
}
}
void VisitCodeNamespaceImport(CodeNamespaceImport import)
{
WriteLine("VisitCodeNamespaceImport: " + import.Namespace);
}
void VisitCodeTypeDeclaration(CodeTypeDeclaration type)
{
WriteLine("VisitCodeTypeDeclaration: " + type.Name);
WriteLine(MemberAttributesToString(type.Attributes));
WriteLine("UserData: " + UserDataKeysToString(type.UserData));
WriteLine("VisitCodeTypeDeclaration: Custom attributes");
foreach (CodeAttributeDeclaration attributeDeclaration in type.CustomAttributes) {
VisitCodeAttributeDeclaration(attributeDeclaration);
}
WriteLine("TypeAttributes: " + TypeAttributesToString(type.TypeAttributes));
foreach (CodeTypeParameter parameter in type.TypeParameters) {
VisitCodeTypeParameter(parameter);
}
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
foreach (CodeTypeMember member in type.Members) {
CodeMemberMethod method = member as CodeMemberMethod;
CodeMemberField field = member as CodeMemberField;
if (method != null) {
VisitCodeMemberMethod(method);
} else if (field != null) {
VisitCodeMemberField(field);
} else {
WriteLine("Unhandled type member: " + member.GetType().Name);
}
}
}
}
void VisitCodeTypeParameter(CodeTypeParameter parameter)
{
WriteLine("VisitCodeTypeParameter: " + parameter.Name);
}
string TypeAttributesToString(TypeAttributes typeAttributes)
{
return typeAttributes.ToString();
}
void VisitCodeAttributeDeclaration(CodeAttributeDeclaration attributeDeclaration)
{
WriteLine("VisitCodeAttributeDeclaration: " + attributeDeclaration.Name);
}
void VisitCodeMemberMethod(CodeMemberMethod method)
{
WriteLine("VisitCodeMemberMethod: " + method.Name);
WriteLine(MemberAttributesToString(method.Attributes));
WriteLine("UserData: " + UserDataKeysToString(method.UserData));
foreach (CodeParameterDeclarationExpression param in method.Parameters) {
VisitCodeParameterDeclarationExpression(param);
}
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
WriteLine("Method.Statements.Count: " + method.Statements.Count);
foreach (CodeStatement statement in method.Statements) {
VisitCodeStatement(statement);
}
}
}
void VisitCodeStatement(CodeStatement statement)
{
WriteLine("VisitCodeStatement: " + statement.GetType().Name);
CodeVariableDeclarationStatement codeVariableDeclarationStatement = statement as CodeVariableDeclarationStatement;
CodeAssignStatement codeAssignStatement = statement as CodeAssignStatement;
CodeConditionStatement codeConditionStatement = statement as CodeConditionStatement;
CodeIterationStatement codeIterationStatement = statement as CodeIterationStatement;
CodeExpressionStatement codeExpressionStatement = statement as CodeExpressionStatement;
CodeTryCatchFinallyStatement codeTryCatchFinallyStatement = statement as CodeTryCatchFinallyStatement;
if (codeVariableDeclarationStatement != null) {
VisitCodeVariableDeclarationStatement(codeVariableDeclarationStatement);
} else if (codeAssignStatement != null) {
VisitCodeAssignStatement(codeAssignStatement);
} else if (codeConditionStatement != null) {
VisitCodeConditionStatement(codeConditionStatement);
} else if (codeIterationStatement != null) {
VisitCodeIterationStatement(codeIterationStatement);
} else if (codeExpressionStatement != null) {
VisitCodeExpressionStatement(codeExpressionStatement);
} else if (codeTryCatchFinallyStatement != null) {
VisitCodeTryCatchFinallyStatement(codeTryCatchFinallyStatement);
} else {
WriteLine("Unhandled statement: " + statement.GetType().Name);
}
}
void VisitCodeAssignStatement(CodeAssignStatement assignStatement)
{
WriteLine("VisitCodeAssignmentStatement");
WriteLine("Left follows");
VisitCodeExpression(assignStatement.Left);
WriteLine("Right follows");
VisitCodeExpression(assignStatement.Right);
}
void VisitCodeParameterDeclarationExpression(CodeParameterDeclarationExpression expression)
{
WriteLine("VisitCodeParameterDeclarationExpression: " + expression.Name);
WriteLine("BaseType: " + expression.Type.BaseType);
}
void VisitCodeVariableDeclarationStatement(CodeVariableDeclarationStatement codeVariableDeclarationStatement)
{
WriteLine("VisitCodeVariableDeclarationStatement: " + codeVariableDeclarationStatement.Name);
WriteLine("BaseType: " + codeVariableDeclarationStatement.Type.BaseType);
WriteLine("UserData: " + UserDataKeysToString(codeVariableDeclarationStatement.UserData));
WriteLine("InitExpression follows");
VisitCodeExpression(codeVariableDeclarationStatement.InitExpression);
}
void VisitCodeExpression(CodeExpression expression)
{
if (expression != null) {
WriteLine("VisitCodeExpression: " + expression.GetType().Name);
CodePrimitiveExpression primitiveExpression = expression as CodePrimitiveExpression;
CodeFieldReferenceExpression fieldReferenceExpression = expression as CodeFieldReferenceExpression;
CodeThisReferenceExpression thisReferenceExpression = expression as CodeThisReferenceExpression;
CodeObjectCreateExpression createExpression = expression as CodeObjectCreateExpression;
CodeBinaryOperatorExpression binaryExpression = expression as CodeBinaryOperatorExpression;
CodeMethodReferenceExpression methodReferenceExpression = expression as CodeMethodReferenceExpression;
CodeMethodInvokeExpression methodInvokeExpression = expression as CodeMethodInvokeExpression;
CodeVariableReferenceExpression variableReferenceExpression = expression as CodeVariableReferenceExpression;
if (primitiveExpression != null) {
VisitCodePrimitiveExpression(primitiveExpression);
} else if (fieldReferenceExpression != null) {
VisitCodeFieldReferenceExpression(fieldReferenceExpression);
} else if (thisReferenceExpression != null) {
VisitCodeThisReferenceExpression(thisReferenceExpression);
} else if (createExpression != null) {
VisitObjectCreateExpression(createExpression);
} else if (binaryExpression != null) {
VisitCodeBinaryOperatorExpression(binaryExpression);
} else if (methodReferenceExpression != null) {
VisitCodeMethodReferenceExpression(methodReferenceExpression);
} else if (methodInvokeExpression != null) {
VisitCodeMethodInvokeExpression(methodInvokeExpression);
} else if (variableReferenceExpression != null) {
VisitCodeVariableReferenceExpression(variableReferenceExpression);
}
} else {
WriteLine("VisitCodeExpression: Null");
}
}
void VisitCodePrimitiveExpression(CodePrimitiveExpression expression)
{
WriteLine("VisitCodePrimitiveExpression: " + expression.Value);
}
void VisitCodeFieldReferenceExpression(CodeFieldReferenceExpression expression)
{
WriteLine("VisitFieldReferenceExpression: " + expression.FieldName);
WriteLine("Target object follows");
VisitCodeExpression(expression.TargetObject);
}
void VisitCodeThisReferenceExpression(CodeThisReferenceExpression expression)
{
WriteLine("VisitCodeThisReferenceExpression");
WriteLine("UserData: " + UserDataKeysToString(expression.UserData));
}
void VisitCodeMemberField(CodeMemberField field)
{
WriteLine("VisitCodeMemberField: " + field.Name);
WriteLine("UserData: " + UserDataKeysToString(field.UserData));
WriteLine(MemberAttributesToString(field.Attributes));
WriteLine("InitExpression follows");
VisitCodeExpression(field.InitExpression);
}
void VisitObjectCreateExpression(CodeObjectCreateExpression createExpression)
{
WriteLine("VisitObjectCreateExpression: Type: " + createExpression.CreateType.BaseType);
foreach (CodeExpression expression in createExpression.Parameters) {
VisitCodeExpression(expression);
}
}
void VisitCodeConditionStatement(CodeConditionStatement conditionStatement)
{
WriteLine("VisitCodeConditionStatement");
WriteLine("Condition follows");
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
VisitCodeExpression(conditionStatement.Condition);
}
WriteLine("TrueStatements follow");
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
foreach (CodeStatement statement in conditionStatement.TrueStatements) {
VisitCodeStatement(statement);
}
}
WriteLine("FalseStatements follow");
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
foreach (CodeStatement statement in conditionStatement.FalseStatements) {
VisitCodeStatement(statement);
}
}
}
void VisitCodeBinaryOperatorExpression(CodeBinaryOperatorExpression expression)
{
WriteLine("VisitBinaryOperatorExpression: " + expression.Operator);
WriteLine("Left follows");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeExpression(expression.Left);
}
WriteLine("Right follows");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeExpression(expression.Right);
}
}
void VisitCodeIterationStatement(CodeIterationStatement statement)
{
WriteLine("VisitIterationStatement");
WriteLine("Init statement follows");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeStatement(statement.InitStatement);
}
WriteLine("Increment statement follows");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeStatement(statement.IncrementStatement);
}
WriteLine("Test expression follows");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeExpression(statement.TestExpression);
}
WriteLine("Statements follow");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
foreach (CodeStatement currentStatement in statement.Statements) {
VisitCodeStatement(currentStatement);
}
}
}
void VisitCodeMethodInvokeExpression(CodeMethodInvokeExpression expression)
{
WriteLine("VisitCodeMethodInvokeExpression");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeExpression(expression.Method);
}
}
void VisitCodeMethodReferenceExpression(CodeMethodReferenceExpression expression)
{
WriteLine("VisitCodeMethodReferenceExpression: " + expression.MethodName);
WriteLine("Target Object follows");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeExpression(expression.TargetObject);
}
}
void VisitCodeExpressionStatement(CodeExpressionStatement statement)
{
WriteLine("VisitCodeExpressionStatement");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
VisitCodeExpression(statement.Expression);
}
}
void VisitCodeVariableReferenceExpression(CodeVariableReferenceExpression expression)
{
WriteLine("VisitCodeVariableReferenceExpression: " + expression.VariableName);
}
void VisitCodeTryCatchFinallyStatement(CodeTryCatchFinallyStatement tryStatement)
{
WriteLine("VisitCodeTryCatchFinallyStatement");
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
WriteLine("Try statements follow: Count: " + tryStatement.TryStatements.Count);
foreach (CodeStatement statement in tryStatement.TryStatements) {
VisitCodeStatement(statement);
}
WriteLine("Catch clauses follow: Count: " + tryStatement.CatchClauses.Count);
foreach (CodeCatchClause catchClause in tryStatement.CatchClauses) {
VisitCodeCatchClause(catchClause);
}
WriteLine("Finally statements follow: Count: " + tryStatement.FinallyStatements);
foreach (CodeStatement statement in tryStatement.FinallyStatements) {
VisitCodeStatement(statement);
}
}
}
void VisitCodeCatchClause(CodeCatchClause catchClause)
{
WriteLine("VisitCodeCatchClause");
WriteLine("Exception caught: " + catchClause.CatchExceptionType.BaseType);
WriteLine("Exception variable: " + catchClause.LocalName);
WriteLine("Catch statements follow: Count: " + catchClause.Statements.Count);
using (IDisposable currentLevel = Indentation.IncrementLevel()) {
foreach (CodeStatement statement in catchClause.Statements) {
VisitCodeStatement(statement);
}
}
}
string MemberAttributesToString(MemberAttributes attributes)
{
StringBuilder s = new StringBuilder();
s.Append("Attributes: ");
if ((attributes & MemberAttributes.Public) == MemberAttributes.Public) {
s.Append("Public, ");
}
if ((attributes & MemberAttributes.Private) == MemberAttributes.Private) {
s.Append("Private, ");
}
if ((attributes & MemberAttributes.Family) == MemberAttributes.Family) {
s.Append("Family, ");
}
if ((attributes & MemberAttributes.Final) == MemberAttributes.Final) {
s.Append("Final, ");
}
return s.ToString();
}
string UserDataKeysToString(IDictionary userData)
{
StringBuilder s = new StringBuilder();
ICollection keys = userData.Keys;
foreach (object o in keys) {
string name = o as string;
if (name != null) {
s.Append(name);
s.Append(", ");
}
}
return s.ToString();
}
/// <summary>
/// Writes a line and indents it to the current level.
/// </summary>
void WriteLine(string s)
{
writer.WriteLine(GetIndent() + s);
}
string GetIndent()
{
StringBuilder indent = new StringBuilder();
for (int i = 0; i < Indentation.CurrentLevel; ++i) {
indent.Append('\t');
}
return indent.ToString();
}
}
}

46
src/AddIns/BackendBindings/Python/PyWalker/Indentation.cs

@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace PyWalker
{
class Indentation : IDisposable
{
static int currentLevel;
public static int CurrentLevel {
get { return currentLevel; }
}
Indentation()
{
currentLevel++;
}
public void Dispose()
{
currentLevel--;
}
public static IDisposable IncrementLevel()
{
return new Indentation();
}
}
}

210
src/AddIns/BackendBindings/Python/PyWalker/MainForm.Designer.cs generated

@ -1,210 +0,0 @@ @@ -1,210 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace PyWalker
{
partial class MainForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </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.components = new System.ComponentModel.Container();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.codeTextBox = new System.Windows.Forms.RichTextBox();
this.runCSharpNRefactoryVisitor = new System.Windows.Forms.Button();
this.runNRefactoryCSharpCodeDomVisitor = new System.Windows.Forms.Button();
this.runCSharpToPythonButton = new System.Windows.Forms.Button();
this.runRoundTripButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button();
this.runAstWalkerButton = new System.Windows.Forms.Button();
this.walkerOutputTextBox = new System.Windows.Forms.RichTextBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.SuspendLayout();
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.Location = new System.Drawing.Point(0, 0);
this.splitContainer.Name = "splitContainer";
this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.Controls.Add(this.codeTextBox);
//
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.runCSharpNRefactoryVisitor);
this.splitContainer.Panel2.Controls.Add(this.runNRefactoryCSharpCodeDomVisitor);
this.splitContainer.Panel2.Controls.Add(this.runCSharpToPythonButton);
this.splitContainer.Panel2.Controls.Add(this.runRoundTripButton);
this.splitContainer.Panel2.Controls.Add(this.clearButton);
this.splitContainer.Panel2.Controls.Add(this.runAstWalkerButton);
this.splitContainer.Panel2.Controls.Add(this.walkerOutputTextBox);
this.splitContainer.Size = new System.Drawing.Size(515, 386);
this.splitContainer.SplitterDistance = 138;
this.splitContainer.TabIndex = 0;
//
// codeTextBox
//
this.codeTextBox.AcceptsTab = true;
this.codeTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.codeTextBox.Location = new System.Drawing.Point(0, 0);
this.codeTextBox.Name = "codeTextBox";
this.codeTextBox.Size = new System.Drawing.Size(515, 138);
this.codeTextBox.TabIndex = 0;
this.codeTextBox.Text = "";
this.codeTextBox.WordWrap = false;
//
// runCSharpNRefactoryVisitor
//
this.runCSharpNRefactoryVisitor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.runCSharpNRefactoryVisitor.Location = new System.Drawing.Point(261, 218);
this.runCSharpNRefactoryVisitor.Name = "runCSharpNRefactoryVisitor";
this.runCSharpNRefactoryVisitor.Size = new System.Drawing.Size(117, 23);
this.runCSharpNRefactoryVisitor.TabIndex = 8;
this.runCSharpNRefactoryVisitor.Text = "Visit C# AST";
this.toolTip.SetToolTip(this.runCSharpNRefactoryVisitor, "Walks the NRefactory AST generated from the C# code.");
this.runCSharpNRefactoryVisitor.UseVisualStyleBackColor = true;
this.runCSharpNRefactoryVisitor.Click += new System.EventHandler(this.RunCSharpNRefactoryVisitorClick);
//
// runNRefactoryCSharpCodeDomVisitor
//
this.runNRefactoryCSharpCodeDomVisitor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.runNRefactoryCSharpCodeDomVisitor.Location = new System.Drawing.Point(384, 218);
this.runNRefactoryCSharpCodeDomVisitor.Name = "runNRefactoryCSharpCodeDomVisitor";
this.runNRefactoryCSharpCodeDomVisitor.Size = new System.Drawing.Size(127, 23);
this.runNRefactoryCSharpCodeDomVisitor.TabIndex = 7;
this.runNRefactoryCSharpCodeDomVisitor.Text = "Visit C# Code DOM";
this.toolTip.SetToolTip(this.runNRefactoryCSharpCodeDomVisitor, "Visits the code dom generated from the C# code by the NRefactory code dom visitor" +
".");
this.runNRefactoryCSharpCodeDomVisitor.UseVisualStyleBackColor = true;
this.runNRefactoryCSharpCodeDomVisitor.Click += new System.EventHandler(this.RunNRefactoryCSharpCodeDomVisitorClick);
//
// runCSharpToPythonButton
//
this.runCSharpToPythonButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.runCSharpToPythonButton.Location = new System.Drawing.Point(261, 192);
this.runCSharpToPythonButton.Name = "runCSharpToPythonButton";
this.runCSharpToPythonButton.Size = new System.Drawing.Size(117, 23);
this.runCSharpToPythonButton.TabIndex = 6;
this.runCSharpToPythonButton.Text = "C# to Python";
this.toolTip.SetToolTip(this.runCSharpToPythonButton, "Takes the code dom generated from the NRefactory parser and converts it to python" +
" using the python generator.");
this.runCSharpToPythonButton.UseVisualStyleBackColor = true;
this.runCSharpToPythonButton.Click += new System.EventHandler(this.RunCSharpToPythonClick);
//
// runRoundTripButton
//
this.runRoundTripButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.runRoundTripButton.Location = new System.Drawing.Point(138, 191);
this.runRoundTripButton.Name = "runRoundTripButton";
this.runRoundTripButton.Size = new System.Drawing.Size(117, 23);
this.runRoundTripButton.TabIndex = 4;
this.runRoundTripButton.Text = "Round Trip";
this.toolTip.SetToolTip(this.runRoundTripButton, "Generates a code dom from the python code and then generates python code from the" +
" code dom.");
this.runRoundTripButton.UseVisualStyleBackColor = true;
this.runRoundTripButton.Click += new System.EventHandler(this.RunRoundTripButtonClick);
//
// clearButton
//
this.clearButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.clearButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.clearButton.Location = new System.Drawing.Point(138, 218);
this.clearButton.Name = "clearButton";
this.clearButton.Size = new System.Drawing.Size(117, 23);
this.clearButton.TabIndex = 2;
this.clearButton.Text = "Clear";
this.clearButton.UseVisualStyleBackColor = true;
this.clearButton.Click += new System.EventHandler(this.ClearButtonClick);
//
// runAstWalkerButton
//
this.runAstWalkerButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.runAstWalkerButton.Location = new System.Drawing.Point(384, 191);
this.runAstWalkerButton.Name = "runAstWalkerButton";
this.runAstWalkerButton.Size = new System.Drawing.Size(127, 23);
this.runAstWalkerButton.TabIndex = 1;
this.runAstWalkerButton.Text = "Visit AST";
this.toolTip.SetToolTip(this.runAstWalkerButton, "Walks the python AST generated from the python code.");
this.runAstWalkerButton.UseVisualStyleBackColor = true;
this.runAstWalkerButton.Click += new System.EventHandler(this.RunAstWalkerButtonClick);
//
// walkerOutputTextBox
//
this.walkerOutputTextBox.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.walkerOutputTextBox.Location = new System.Drawing.Point(0, 2);
this.walkerOutputTextBox.Name = "walkerOutputTextBox";
this.walkerOutputTextBox.Size = new System.Drawing.Size(515, 184);
this.walkerOutputTextBox.TabIndex = 0;
this.walkerOutputTextBox.Text = "";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(515, 386);
this.Controls.Add(this.splitContainer);
this.Name = "MainForm";
this.Text = "PyWalker";
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
this.splitContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.Button runCSharpNRefactoryVisitor;
private System.Windows.Forms.Button runNRefactoryCSharpCodeDomVisitor;
private System.Windows.Forms.Button runCSharpToPythonButton;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Button runRoundTripButton;
private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.Button runAstWalkerButton;
private System.Windows.Forms.RichTextBox walkerOutputTextBox;
private System.Windows.Forms.RichTextBox codeTextBox;
private System.Windows.Forms.SplitContainer splitContainer;
}
}

157
src/AddIns/BackendBindings/Python/PyWalker/MainForm.cs

@ -1,157 +0,0 @@ @@ -1,157 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using IronPython;
using IronPython.Compiler;
using IronPython.Compiler.Ast;
using IronPython.Runtime;
using Microsoft.CSharp;
using Microsoft.Scripting;
using Microsoft.Scripting.Runtime;
using NRefactory = ICSharpCode.NRefactory;
namespace PyWalker
{
public partial class MainForm : Form, IOutputWriter
{
public MainForm()
{
InitializeComponent();
}
public void WriteLine(string s)
{
walkerOutputTextBox.Text += String.Concat(s, "\r\n");
}
void RunAstWalkerButtonClick(object sender, EventArgs e)
{
try {
IronPython.Hosting.Python.CreateEngine();
Clear();
PythonCompilerSink sink = new PythonCompilerSink();
SourceUnit source = DefaultContext.DefaultPythonContext.CreateFileUnit(@"D:\Temp.py", codeTextBox.Text);
CompilerContext context = new CompilerContext(source, new PythonCompilerOptions(), sink);
Parser parser = Parser.CreateParser(context, new PythonOptions());
PythonAst ast = parser.ParseFile(false);
if (sink.Errors.Count == 0) {
ResolveWalker walker = new ResolveWalker(this);
ast.Walk(walker);
} else {
walkerOutputTextBox.Text += "\r\n";
foreach (PythonCompilerError error in sink.Errors) {
walkerOutputTextBox.Text += error.ToString() + "\r\n";
}
}
} catch (Exception ex) {
walkerOutputTextBox.Text = ex.ToString();
}
}
void ClearButtonClick(object sender, EventArgs e)
{
Clear();
}
void Clear()
{
walkerOutputTextBox.Text = String.Empty;
}
/// <summary>
/// Round trips the Python code through the code DOM and back
/// to source code.
/// </summary>
void RunRoundTripButtonClick(object sender, EventArgs e)
{
try {
Clear();
// PythonProvider provider = new PythonProvider();
// CodeCompileUnit unit = provider.Parse(new StringReader(codeTextBox.Text));
// StringWriter writer = new StringWriter();
// CodeGeneratorOptions options = new CodeGeneratorOptions();
// options.BlankLinesBetweenMembers = false;
// options.IndentString = "\t";
// provider.GenerateCodeFromCompileUnit(unit, writer, options);
//
// walkerOutputTextBox.Text = writer.ToString();
} catch (Exception ex) {
walkerOutputTextBox.Text = ex.ToString();
}
}
/// <summary>
/// Converts the C# code to a code dom using the NRefactory
/// library and then visits the code dom.
/// </summary>
void RunCSharpToPythonClick(object sender, EventArgs e)
{
try {
Clear();
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(NRefactory.SupportedLanguage.CSharp);
walkerOutputTextBox.Text = converter.Convert(codeTextBox.Text);
} catch (Exception ex) {
walkerOutputTextBox.Text = ex.ToString();
}
}
/// <summary>
/// Converts C# to python using the code dom generated by the
/// NRefactory parser.
/// </summary>
void RunNRefactoryCSharpCodeDomVisitorClick(object sender, EventArgs e)
{
try {
Clear();
using (NRefactory.IParser parser = NRefactory.ParserFactory.CreateParser(NRefactory.SupportedLanguage.CSharp, new StringReader(codeTextBox.Text))) {
parser.ParseMethodBodies = false;
parser.Parse();
NRefactory.Visitors.CodeDomVisitor visitor = new NRefactory.Visitors.CodeDomVisitor();
visitor.VisitCompilationUnit(parser.CompilationUnit, null);
CodeDomVisitor codeDomVisitor = new CodeDomVisitor(this);
codeDomVisitor.Visit(visitor.codeCompileUnit);
}
} catch (Exception ex) {
walkerOutputTextBox.Text = ex.ToString();
}
}
void RunCSharpNRefactoryVisitorClick(object sender, EventArgs e)
{
try {
Clear();
using (NRefactory.IParser parser = NRefactory.ParserFactory.CreateParser(NRefactory.SupportedLanguage.CSharp, new StringReader(codeTextBox.Text))) {
parser.ParseMethodBodies = false;
parser.Parse();
NRefactoryAstVisitor visitor = new NRefactoryAstVisitor(this);
visitor.VisitCompilationUnit(parser.CompilationUnit, null);
}
} catch (Exception ex) {
walkerOutputTextBox.Text = ex.ToString();
}
}
}
}

123
src/AddIns/BackendBindings/Python/PyWalker/MainForm.resx

@ -1,123 +0,0 @@ @@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

678
src/AddIns/BackendBindings/Python/PyWalker/NRefactoryAstVisitor.cs

@ -1,678 +0,0 @@ @@ -1,678 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
namespace PyWalker
{
public class NRefactoryAstVisitor : AbstractAstVisitor
{
IOutputWriter writer;
public NRefactoryAstVisitor(IOutputWriter writer)
{
this.writer = writer;
}
public override object VisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data)
{
return base.VisitAddHandlerStatement(addHandlerStatement, data);
}
public override object VisitAddressOfExpression(AddressOfExpression addressOfExpression, object data)
{
return base.VisitAddressOfExpression(addressOfExpression, data);
}
public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
{
return base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
}
public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
{
return base.VisitArrayCreateExpression(arrayCreateExpression, data);
}
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
{
WriteLine("VisitAssignmentExpression");
return base.VisitAssignmentExpression(assignmentExpression, data);
}
public override object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute, object data)
{
return base.VisitAttribute(attribute, data);
}
public override object VisitAttributeSection(AttributeSection attributeSection, object data)
{
return base.VisitAttributeSection(attributeSection, data);
}
public override object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data)
{
return base.VisitBaseReferenceExpression(baseReferenceExpression, data);
}
public override object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data)
{
return base.VisitBinaryOperatorExpression(binaryOperatorExpression, data);
}
public override object VisitBlockStatement(BlockStatement blockStatement, object data)
{
return base.VisitBlockStatement(blockStatement, data);
}
public override object VisitBreakStatement(BreakStatement breakStatement, object data)
{
return base.VisitBreakStatement(breakStatement, data);
}
public override object VisitCaseLabel(CaseLabel caseLabel, object data)
{
return base.VisitCaseLabel(caseLabel, data);
}
public override object VisitCastExpression(CastExpression castExpression, object data)
{
return base.VisitCastExpression(castExpression, data);
}
public override object VisitCatchClause(CatchClause catchClause, object data)
{
return base.VisitCatchClause(catchClause, data);
}
public override object VisitCheckedExpression(CheckedExpression checkedExpression, object data)
{
return base.VisitCheckedExpression(checkedExpression, data);
}
public override object VisitCheckedStatement(CheckedStatement checkedStatement, object data)
{
return base.VisitCheckedStatement(checkedStatement, data);
}
public override object VisitClassReferenceExpression(ClassReferenceExpression classReferenceExpression, object data)
{
return base.VisitClassReferenceExpression(classReferenceExpression, data);
}
public override object VisitCollectionInitializerExpression(CollectionInitializerExpression collectionInitializerExpression, object data)
{
WriteLine("VisitCollectionInitializerExpression");
return base.VisitCollectionInitializerExpression(collectionInitializerExpression, data);
}
public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
{
WriteLine("VisitCodeCompileUnit");
return base.VisitCompilationUnit(compilationUnit, data);
}
public override object VisitConditionalExpression(ConditionalExpression conditionalExpression, object data)
{
return base.VisitConditionalExpression(conditionalExpression, data);
}
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
WriteLine("VisitConstructorDeclaration");
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
public override object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
{
WriteLine("VisitConstructorInitializer");
return base.VisitConstructorInitializer(constructorInitializer, data);
}
public override object VisitContinueStatement(ContinueStatement continueStatement, object data)
{
return base.VisitContinueStatement(continueStatement, data);
}
public override object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
{
return base.VisitDeclareDeclaration(declareDeclaration, data);
}
public override object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
{
return base.VisitDefaultValueExpression(defaultValueExpression, data);
}
public override object VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data)
{
return base.VisitDelegateDeclaration(delegateDeclaration, data);
}
public override object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data)
{
return base.VisitDestructorDeclaration(destructorDeclaration, data);
}
public override object VisitDirectionExpression(DirectionExpression directionExpression, object data)
{
return base.VisitDirectionExpression(directionExpression, data);
}
public override object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data)
{
return base.VisitDoLoopStatement(doLoopStatement, data);
}
public override object VisitElseIfSection(ElseIfSection elseIfSection, object data)
{
return base.VisitElseIfSection(elseIfSection, data);
}
public override object VisitEmptyStatement(EmptyStatement emptyStatement, object data)
{
WriteLine("VisitEmptyStatement");
return base.VisitEmptyStatement(emptyStatement, data);
}
public override object VisitEndStatement(EndStatement endStatement, object data)
{
return base.VisitEndStatement(endStatement, data);
}
public override object VisitEraseStatement(EraseStatement eraseStatement, object data)
{
return base.VisitEraseStatement(eraseStatement, data);
}
public override object VisitErrorStatement(ErrorStatement errorStatement, object data)
{
return base.VisitErrorStatement(errorStatement, data);
}
public override object VisitEventAddRegion(EventAddRegion eventAddRegion, object data)
{
return base.VisitEventAddRegion(eventAddRegion, data);
}
public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
return base.VisitEventDeclaration(eventDeclaration, data);
}
public override object VisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data)
{
return base.VisitEventRaiseRegion(eventRaiseRegion, data);
}
public override object VisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data)
{
return base.VisitEventRemoveRegion(eventRemoveRegion, data);
}
public override object VisitExitStatement(ExitStatement exitStatement, object data)
{
return base.VisitExitStatement(exitStatement, data);
}
public override object VisitExpressionRangeVariable(ExpressionRangeVariable expressionRangeVariable, object data)
{
return base.VisitExpressionRangeVariable(expressionRangeVariable, data);
}
public override object VisitExpressionStatement(ExpressionStatement expressionStatement, object data)
{
WriteLine("VisitExpressionStatement");
return base.VisitExpressionStatement(expressionStatement, data);
}
public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
WriteLine("VisitFieldDeclaration: " + fieldDeclaration.Fields[0].Name);
return base.VisitFieldDeclaration(fieldDeclaration, data);
}
public override object VisitFixedStatement(FixedStatement fixedStatement, object data)
{
return base.VisitFixedStatement(fixedStatement, data);
}
public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
{
return base.VisitForeachStatement(foreachStatement, data);
}
public override object VisitForNextStatement(ForNextStatement forNextStatement, object data)
{
return base.VisitForNextStatement(forNextStatement, data);
}
public override object VisitForStatement(ForStatement forStatement, object data)
{
return base.VisitForStatement(forStatement, data);
}
public override object VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, object data)
{
return base.VisitGotoCaseStatement(gotoCaseStatement, data);
}
public override object VisitGotoStatement(GotoStatement gotoStatement, object data)
{
return base.VisitGotoStatement(gotoStatement, data);
}
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
WriteLine("VisitIdentifierExpression");
return base.VisitIdentifierExpression(identifierExpression, data);
}
public override object VisitIfElseStatement(IfElseStatement ifElseStatement, object data)
{
return base.VisitIfElseStatement(ifElseStatement, data);
}
public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data)
{
return base.VisitIndexerExpression(indexerExpression, data);
}
public override object VisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data)
{
return base.VisitInnerClassTypeReference(innerClassTypeReference, data);
}
public override object VisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data)
{
return base.VisitInterfaceImplementation(interfaceImplementation, data);
}
public override object VisitInvocationExpression(InvocationExpression invocationExpression, object data)
{
return base.VisitInvocationExpression(invocationExpression, data);
}
public override object VisitLabelStatement(LabelStatement labelStatement, object data)
{
return base.VisitLabelStatement(labelStatement, data);
}
public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
{
return base.VisitLambdaExpression(lambdaExpression, data);
}
public override object VisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
{
WriteLine("VisitLocalVariableDeclaration");
return base.VisitLocalVariableDeclaration(localVariableDeclaration, data);
}
public override object VisitLockStatement(LockStatement lockStatement, object data)
{
return base.VisitLockStatement(lockStatement, data);
}
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
{
WriteLine("VisitMemberReferenceExpression");
return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
}
public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{
WriteLine("VisitMethodDeclaration");
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
return base.VisitMethodDeclaration(methodDeclaration, data);
}
}
public override object VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data)
{
return base.VisitNamedArgumentExpression(namedArgumentExpression, data);
}
public override object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
WriteLine("VisitNamespaceDeclaration");
return base.VisitNamespaceDeclaration(namespaceDeclaration, data);
}
public override object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
{
WriteLine("VisitObjectCreateExpression");
return base.VisitObjectCreateExpression(objectCreateExpression, data);
}
public override object VisitOnErrorStatement(OnErrorStatement onErrorStatement, object data)
{
return base.VisitOnErrorStatement(onErrorStatement, data);
}
public override object VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data)
{
return base.VisitOperatorDeclaration(operatorDeclaration, data);
}
public override object VisitOptionDeclaration(OptionDeclaration optionDeclaration, object data)
{
return base.VisitOptionDeclaration(optionDeclaration, data);
}
public override object VisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data)
{
return base.VisitParameterDeclarationExpression(parameterDeclarationExpression, data);
}
public override object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
{
return base.VisitParenthesizedExpression(parenthesizedExpression, data);
}
public override object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data)
{
return base.VisitPointerReferenceExpression(pointerReferenceExpression, data);
}
public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
{
return base.VisitPrimitiveExpression(primitiveExpression, data);
}
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
public override object VisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data)
{
return base.VisitPropertyGetRegion(propertyGetRegion, data);
}
public override object VisitPropertySetRegion(PropertySetRegion propertySetRegion, object data)
{
return base.VisitPropertySetRegion(propertySetRegion, data);
}
public override object VisitQueryExpression(QueryExpression queryExpression, object data)
{
return base.VisitQueryExpression(queryExpression, data);
}
public override object VisitQueryExpressionAggregateClause(QueryExpressionAggregateClause queryExpressionAggregateClause, object data)
{
return base.VisitQueryExpressionAggregateClause(queryExpressionAggregateClause, data);
}
public override object VisitQueryExpressionDistinctClause(QueryExpressionDistinctClause queryExpressionDistinctClause, object data)
{
return base.VisitQueryExpressionDistinctClause(queryExpressionDistinctClause, data);
}
public override object VisitQueryExpressionFromClause(QueryExpressionFromClause queryExpressionFromClause, object data)
{
return base.VisitQueryExpressionFromClause(queryExpressionFromClause, data);
}
public override object VisitQueryExpressionGroupClause(QueryExpressionGroupClause queryExpressionGroupClause, object data)
{
return base.VisitQueryExpressionGroupClause(queryExpressionGroupClause, data);
}
public override object VisitQueryExpressionGroupJoinVBClause(QueryExpressionGroupJoinVBClause queryExpressionGroupJoinVBClause, object data)
{
return base.VisitQueryExpressionGroupJoinVBClause(queryExpressionGroupJoinVBClause, data);
}
public override object VisitQueryExpressionGroupVBClause(QueryExpressionGroupVBClause queryExpressionGroupVBClause, object data)
{
return base.VisitQueryExpressionGroupVBClause(queryExpressionGroupVBClause, data);
}
public override object VisitQueryExpressionJoinClause(QueryExpressionJoinClause queryExpressionJoinClause, object data)
{
return base.VisitQueryExpressionJoinClause(queryExpressionJoinClause, data);
}
public override object VisitQueryExpressionJoinConditionVB(QueryExpressionJoinConditionVB queryExpressionJoinConditionVB, object data)
{
return base.VisitQueryExpressionJoinConditionVB(queryExpressionJoinConditionVB, data);
}
public override object VisitQueryExpressionJoinVBClause(QueryExpressionJoinVBClause queryExpressionJoinVBClause, object data)
{
return base.VisitQueryExpressionJoinVBClause(queryExpressionJoinVBClause, data);
}
public override object VisitQueryExpressionLetClause(QueryExpressionLetClause queryExpressionLetClause, object data)
{
return base.VisitQueryExpressionLetClause(queryExpressionLetClause, data);
}
public override object VisitQueryExpressionLetVBClause(QueryExpressionLetVBClause queryExpressionLetVBClause, object data)
{
return base.VisitQueryExpressionLetVBClause(queryExpressionLetVBClause, data);
}
public override object VisitQueryExpressionOrderClause(QueryExpressionOrderClause queryExpressionOrderClause, object data)
{
return base.VisitQueryExpressionOrderClause(queryExpressionOrderClause, data);
}
public override object VisitQueryExpressionOrdering(QueryExpressionOrdering queryExpressionOrdering, object data)
{
return base.VisitQueryExpressionOrdering(queryExpressionOrdering, data);
}
public override object VisitQueryExpressionPartitionVBClause(QueryExpressionPartitionVBClause queryExpressionPartitionVBClause, object data)
{
return base.VisitQueryExpressionPartitionVBClause(queryExpressionPartitionVBClause, data);
}
public override object VisitQueryExpressionSelectClause(QueryExpressionSelectClause queryExpressionSelectClause, object data)
{
return base.VisitQueryExpressionSelectClause(queryExpressionSelectClause, data);
}
public override object VisitQueryExpressionSelectVBClause(QueryExpressionSelectVBClause queryExpressionSelectVBClause, object data)
{
return base.VisitQueryExpressionSelectVBClause(queryExpressionSelectVBClause, data);
}
public override object VisitQueryExpressionWhereClause(QueryExpressionWhereClause queryExpressionWhereClause, object data)
{
return base.VisitQueryExpressionWhereClause(queryExpressionWhereClause, data);
}
public override object VisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data)
{
return base.VisitRaiseEventStatement(raiseEventStatement, data);
}
public override object VisitReDimStatement(ReDimStatement reDimStatement, object data)
{
return base.VisitReDimStatement(reDimStatement, data);
}
public override object VisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data)
{
return base.VisitRemoveHandlerStatement(removeHandlerStatement, data);
}
public override object VisitResumeStatement(ResumeStatement resumeStatement, object data)
{
return base.VisitResumeStatement(resumeStatement, data);
}
public override object VisitReturnStatement(ReturnStatement returnStatement, object data)
{
return base.VisitReturnStatement(returnStatement, data);
}
public override object VisitSizeOfExpression(SizeOfExpression sizeOfExpression, object data)
{
return base.VisitSizeOfExpression(sizeOfExpression, data);
}
public override object VisitStackAllocExpression(StackAllocExpression stackAllocExpression, object data)
{
return base.VisitStackAllocExpression(stackAllocExpression, data);
}
public override object VisitStopStatement(StopStatement stopStatement, object data)
{
return base.VisitStopStatement(stopStatement, data);
}
public override object VisitSwitchSection(SwitchSection switchSection, object data)
{
return base.VisitSwitchSection(switchSection, data);
}
public override object VisitSwitchStatement(SwitchStatement switchStatement, object data)
{
return base.VisitSwitchStatement(switchStatement, data);
}
public override object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data)
{
return base.VisitTemplateDefinition(templateDefinition, data);
}
public override object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data)
{
WriteLine("VisitThisReferenceExpression");
return base.VisitThisReferenceExpression(thisReferenceExpression, data);
}
public override object VisitThrowStatement(ThrowStatement throwStatement, object data)
{
return base.VisitThrowStatement(throwStatement, data);
}
public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
{
return base.VisitTryCatchStatement(tryCatchStatement, data);
}
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
WriteLine("VisitTypeDeclaration");
using (IDisposable indentLevel = Indentation.IncrementLevel()) {
return base.VisitTypeDeclaration(typeDeclaration, data);
}
}
public override object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data)
{
return base.VisitTypeOfExpression(typeOfExpression, data);
}
public override object VisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data)
{
return base.VisitTypeOfIsExpression(typeOfIsExpression, data);
}
public override object VisitTypeReference(TypeReference typeReference, object data)
{
return base.VisitTypeReference(typeReference, data);
}
public override object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
{
return base.VisitTypeReferenceExpression(typeReferenceExpression, data);
}
public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
{
return base.VisitUnaryOperatorExpression(unaryOperatorExpression, data);
}
public override object VisitUncheckedExpression(UncheckedExpression uncheckedExpression, object data)
{
return base.VisitUncheckedExpression(uncheckedExpression, data);
}
public override object VisitUncheckedStatement(UncheckedStatement uncheckedStatement, object data)
{
return base.VisitUncheckedStatement(uncheckedStatement, data);
}
public override object VisitUnsafeStatement(UnsafeStatement unsafeStatement, object data)
{
return base.VisitUnsafeStatement(unsafeStatement, data);
}
public override object VisitUsing(Using @using, object data)
{
WriteLine("VisitUsing");
return base.VisitUsing(@using, data);
}
public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
{
WriteLine("VisitUsingDeclaration");
return base.VisitUsingDeclaration(usingDeclaration, data);
}
public override object VisitUsingStatement(UsingStatement usingStatement, object data)
{
WriteLine("VisitUsingStatement");
return base.VisitUsingStatement(usingStatement, data);
}
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
WriteLine("VisitVariableDeclaration");
return base.VisitVariableDeclaration(variableDeclaration, data);
}
public override object VisitWithStatement(WithStatement withStatement, object data)
{
return base.VisitWithStatement(withStatement, data);
}
public override object VisitYieldStatement(YieldStatement yieldStatement, object data)
{
return base.VisitYieldStatement(yieldStatement, data);
}
/// <summary>
/// Writes a line and indents it to the current level.
/// </summary>
void WriteLine(string s)
{
writer.WriteLine(GetIndent() + s);
}
string GetIndent()
{
StringBuilder indent = new StringBuilder();
for (int i = 0; i < Indentation.CurrentLevel; ++i) {
indent.Append('\t');
}
return indent.ToString();
}
}
}

41
src/AddIns/BackendBindings/Python/PyWalker/Program.cs

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Forms;
namespace PyWalker
{
/// <summary>
/// Class with program entry point.
/// </summary>
internal sealed class Program
{
/// <summary>
/// Program entry point.
/// </summary>
[STAThread]
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}

84
src/AddIns/BackendBindings/Python/PyWalker/PyWalker.csproj

@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{55329704-6046-48EC-8A20-5C80B3092A63}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>WinExe</OutputType>
<RootNamespace>PyWalker</RootNamespace>
<AssemblyName>PyWalker</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<StartAction>Project</StartAction>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="IronPython">
<HintPath>..\RequiredLibraries\IronPython.dll</HintPath>
</Reference>
<Reference Include="IronPython.Modules">
<HintPath>..\RequiredLibraries\IronPython.Modules.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Dynamic">
<HintPath>..\RequiredLibraries\Microsoft.Dynamic.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting">
<HintPath>..\RequiredLibraries\Microsoft.Scripting.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CodeDomVisitor.cs" />
<Compile Include="Indentation.cs" />
<Compile Include="MainForm.cs" />
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="NRefactoryAstVisitor.cs" />
<Compile Include="Program.cs" />
<Compile Include="ResolveWalker.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\PythonBinding\Project\PythonBinding.csproj">
<Project>{8D732610-8FC6-43BA-94C9-7126FD7FE361}</Project>
<Name>PythonBinding</Name>
</ProjectReference>
</ItemGroup>
</Project>

237
src/AddIns/BackendBindings/Python/PyWalker/ResolveWalker.cs

@ -1,237 +0,0 @@ @@ -1,237 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using IronPython;
using IronPython.Compiler;
using IronPython.Compiler.Ast;
namespace PyWalker
{
public interface IOutputWriter
{
void WriteLine(string s);
}
public class ResolveWalker : PythonWalker
{
IOutputWriter writer;
public ResolveWalker(IOutputWriter writer)
{
this.writer = writer;
}
public override bool Walk(AndExpression node)
{
writer.WriteLine("And");
return base.Walk(node);
}
public override bool Walk(AssertStatement node)
{
writer.WriteLine("Assert");
return base.Walk(node);
}
public override bool Walk(Arg node)
{
writer.WriteLine("Arg: " + node.Name.ToString());
return base.Walk(node);
}
public override bool Walk(AugmentedAssignStatement node)
{
writer.WriteLine("AugmentedAssignStatement");
return base.Walk(node);
}
public override bool Walk(AssignmentStatement node)
{
writer.WriteLine("AssignmentStatement");
return base.Walk(node);
}
public override bool Walk(BackQuoteExpression node)
{
writer.WriteLine("BackQuote");
return base.Walk(node);
}
public override bool Walk(BinaryExpression node)
{
writer.WriteLine("Binary");
return base.Walk(node);
}
public override bool Walk(BreakStatement node)
{
writer.WriteLine("Breaks");
return base.Walk(node);
}
public override bool Walk(ClassDefinition node)
{
if (node.Bases.Count > 0) {
writer.WriteLine("Class: " + node.Name + " BaseTypes: " + GetBaseTypes(node.Bases));
} else {
writer.WriteLine("Class: " + node.Name);
}
return base.Walk(node);
}
public override bool Walk(ConditionalExpression node)
{
writer.WriteLine("ConditionalExpression");
return base.Walk(node);
}
public override bool Walk(ConstantExpression node)
{
writer.WriteLine("ConstantExpression");
return base.Walk(node);
}
public override bool Walk(ContinueStatement node)
{
writer.WriteLine("Continue");
return base.Walk(node);
}
public override bool Walk(PrintStatement node)
{
writer.WriteLine("PrintStatement");
return base.Walk(node);
}
public override bool Walk(FunctionDefinition node)
{
writer.WriteLine("FunctionDefinition");
return base.Walk(node);
}
public override bool Walk(CallExpression node)
{
writer.WriteLine("Call");
return base.Walk(node);
}
public override bool Walk(DictionaryExpression node)
{
writer.WriteLine("Dict");
return base.Walk(node);
}
public override bool Walk(DottedName node)
{
writer.WriteLine("DottedName");
return base.Walk(node);
}
public override bool Walk(ExpressionStatement node)
{
writer.WriteLine("Expr");
return base.Walk(node);
}
public override bool Walk(GlobalStatement node)
{
writer.WriteLine("Global");
return base.Walk(node);
}
public override bool Walk(NameExpression node)
{
writer.WriteLine("Name: " + node.Name);
return base.Walk(node);
}
public override bool Walk(MemberExpression node)
{
writer.WriteLine("Member: " + node.Name);
return base.Walk(node);
}
public override bool Walk(FromImportStatement node)
{
writer.WriteLine("FromImport: " + node.Root.MakeString());
return base.Walk(node);
}
public override bool Walk(ImportStatement node)
{
writer.WriteLine("Import: " + GetImports(node.Names));
return base.Walk(node);
}
public override bool Walk(IndexExpression node)
{
writer.WriteLine("Index: " + node.Index.ToString());
return base.Walk(node);
}
public override bool Walk(UnaryExpression node)
{
writer.WriteLine("Unary");
return base.Walk(node);
}
public override bool Walk(SuiteStatement node)
{
writer.WriteLine("Suite");
return base.Walk(node);
}
public override bool Walk(ErrorExpression node)
{
writer.WriteLine("Error");
return base.Walk(node);
}
public override bool Walk(IfStatement node)
{
writer.WriteLine("If");
return base.Walk(node);
}
string GetImports(IList<DottedName> names)
{
StringBuilder s = new StringBuilder();
foreach (DottedName name in names) {
s.Append(name.MakeString());
s.Append(',');
}
return s.ToString();
}
string GetBaseTypes(IList<Expression> types)
{
StringBuilder s = new StringBuilder();
foreach (Expression expression in types) {
NameExpression nameExpression = expression as NameExpression;
if (nameExpression != null) {
s.Append(nameExpression.Name.ToString());
s.Append(',');
}
}
return s.ToString();
}
}
}

31
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Configuration/AssemblyInfo.cs

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Reflection;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("Python.Build.Tasks")]
[assembly: AssemblyDescription("Provides IronPython build tasks for the IronPython addin.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

79
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Python.Build.Tasks.csproj

@ -1,79 +0,0 @@ @@ -1,79 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{D332F2D1-2CF1-43B7-903C-844BD5211A7E}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Python.Build.Tasks</RootNamespace>
<AssemblyName>Python.Build.Tasks</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\..\AddIns\BackendBindings\PythonBinding\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\..\..\..\..\AddIns\BackendBindings\PythonBinding\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="IronPython">
<HintPath>..\..\RequiredLibraries\IronPython.dll</HintPath>
</Reference>
<Reference Include="IronPython.Modules">
<HintPath>..\..\RequiredLibraries\IronPython.Modules.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Tasks" />
<Reference Include="Microsoft.Build.Utilities.v3.5">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="Microsoft.Dynamic">
<HintPath>..\..\RequiredLibraries\Microsoft.Dynamic.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting">
<HintPath>..\..\RequiredLibraries\Microsoft.Scripting.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\IPythonCompiler.cs" />
<Compile Include="Src\PythonCompiler.cs" />
<Compile Include="Src\PythonCompilerException.cs" />
<Compile Include="Src\PythonCompilerTask.cs" />
<Compile Include="Src\ResourceFile.cs" />
<Compile Include="Src\Resources.cs" />
<None Include="SharpDevelop.Build.Python.targets">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

105
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/SharpDevelop.Build.Python.targets

@ -1,105 +0,0 @@ @@ -1,105 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<UsingTask
TaskName="ICSharpCode.Python.Build.Tasks.PythonCompilerTask"
AssemblyFile="$(PythonBinPath)\Python.Build.Tasks.dll"/>
<UsingTask
TaskName="Microsoft.Build.Tasks.CreateCSharpManifestResourceName"
AssemblyName="Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(PythonBinPath)\SharpDevelop.Build.Python.targets</MSBuildAllProjects>
<DefaultLanguageSourceExtension>.py</DefaultLanguageSourceExtension>
<Language>Python</Language>
</PropertyGroup>
<PropertyGroup>
<CreateManifestResourceNamesDependsOn></CreateManifestResourceNamesDependsOn>
</PropertyGroup>
<Target
Name="CreateManifestResourceNames"
Condition="'@(EmbeddedResource)' != ''"
DependsOnTargets="$(CreateManifestResourceNamesDependsOn)"
>
<ItemGroup>
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
<!-- Create manifest names for culture and non-culture Resx files, and for non-culture Non-Resx resources -->
<CreateCSharpManifestResourceName
ResourceFiles="@(EmbeddedResource)"
RootNamespace="$(RootNamespace)"
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and ('%(EmbeddedResource.WithCulture)' == 'false' or '%(EmbeddedResource.Type)' == 'Resx')">
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
</CreateCSharpManifestResourceName>
<!-- Create manifest names for all culture non-resx resources -->
<CreateCSharpManifestResourceName
ResourceFiles="@(EmbeddedResource)"
RootNamespace="$(RootNamespace)"
PrependCultureAsDirectory="false"
Condition="'%(EmbeddedResource.ManifestResourceName)' == '' and '%(EmbeddedResource.WithCulture)' == 'true' and '%(EmbeddedResource.Type)' == 'Non-Resx'">
<Output TaskParameter="ResourceFilesWithManifestResourceNames" ItemName="_Temporary" />
</CreateCSharpManifestResourceName>
<ItemGroup>
<EmbeddedResource Remove="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' == ''"/>
<EmbeddedResource Include="@(_Temporary)" />
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
</Target>
<Target
Name="CoreCompile"
Inputs="$(MSBuildAllProjects);
@(Compile);
@(_CoreCompileResourceInputs);
@(ReferencePath)"
Outputs="@(IntermediateAssembly)"
DependsOnTargets="$(CoreCompileDependsOn)"
>
<PythonCompilerTask
EmitDebugInformation="$(DebugSymbols)"
MainFile="$(MainFile)"
Platform="$(PlatformTarget)"
OutputAssembly="@(IntermediateAssembly)"
References="@(ReferencePath)"
Resources="@(_CoreCompileResourceInputs)"
Sources="@(Compile)"
TargetType="$(OutputType)"/>
</Target>
<Import Project="$(MSBuildBinPath)\Microsoft.Common.targets"/>
<PropertyGroup>
<PrepareForRunDependsOn>
CopyFilesToOutputDirectory;CopyIntermediateAssemblyDllToOutputDirectory
</PrepareForRunDependsOn>
</PropertyGroup>
<Target
Name="PrepareForRun"
DependsOnTargets="$(PrepareForRunDependsOn)"
/>
<ItemGroup>
<IntermediateAssemblyDll Include="$(IntermediateOutputPath)$(TargetName).dll"/>
</ItemGroup>
<!-- The Python compiler generates a separate dll if an exe is compiled which needs to
be copied to the output folder -->
<Target
Name="CopyIntermediateAssemblyDllToOutputDirectory"
>
<Copy SourceFiles="@(IntermediateAssemblyDll)"
DestinationFolder="$(OutDir)"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Condition="'$(OutputType)'=='exe' Or '$(OutputType)'=='winexe'">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>
</Project>

83
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/IPythonCompiler.cs

@ -1,83 +0,0 @@ @@ -1,83 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
namespace ICSharpCode.Python.Build.Tasks
{
/// <summary>
/// Python compiler interface.
/// </summary>
public interface IPythonCompiler : IDisposable
{
/// <summary>
/// Gets or sets the source files to compile.
/// </summary>
IList<string> SourceFiles { get; set; }
/// <summary>
/// Gets or sets the filenames of the referenced assemblies.
/// </summary>
IList<string> ReferencedAssemblies { get; set; }
/// <summary>
/// Gets or sets the resources to be compiled.
/// </summary>
IList<ResourceFile> ResourceFiles { get; set; }
/// <summary>
/// Executes the compiler.
/// </summary>
void Compile();
/// <summary>
/// Gets or sets the type of the compiled assembly (e.g. windows app,
/// console app or dll).
/// </summary>
PEFileKinds TargetKind { get; set; }
/// <summary>
/// Gets or sets the nature of the code in the executable produced by the compiler.
/// </summary>
PortableExecutableKinds ExecutableKind { get; set; }
/// <summary>
/// Gets or sets the machine that will be targeted by the compiler.
/// </summary>
ImageFileMachine Machine { get; set; }
/// <summary>
/// Gets or sets the file that contains the main entry point.
/// </summary>
string MainFile { get; set; }
/// <summary>
/// Gets or sets the output assembly filename.
/// </summary>
string OutputAssembly { get; set; }
/// <summary>
/// Gets or sets whether the compiler should include debug
/// information in the created assembly.
/// </summary>
bool IncludeDebugInformation { get; set; }
}
}

282
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompiler.cs

@ -1,282 +0,0 @@ @@ -1,282 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using IronPython.Hosting;
using IronPython.Runtime;
using IronPython.Runtime.Operations;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
namespace ICSharpCode.Python.Build.Tasks
{
/// <summary>
/// Wraps the IronPython.Hosting.PythonCompiler class so it
/// implements the IPythonCompiler interface.
/// </summary>
public class PythonCompiler : IPythonCompiler
{
IList<string> sourceFiles;
IList<string> referencedAssemblies;
IList<ResourceFile> resourceFiles;
PEFileKinds targetKind = PEFileKinds.Dll;
PortableExecutableKinds executableKind = PortableExecutableKinds.ILOnly;
ImageFileMachine machine = ImageFileMachine.I386;
string mainFile = String.Empty;
bool includeDebugInformation;
string outputAssembly = String.Empty;
public PythonCompiler()
{
}
public IList<string> SourceFiles {
get { return sourceFiles; }
set { sourceFiles = value; }
}
public IList<string> ReferencedAssemblies {
get { return referencedAssemblies; }
set { referencedAssemblies = value; }
}
public IList<ResourceFile> ResourceFiles {
get { return resourceFiles; }
set { resourceFiles = value; }
}
public PEFileKinds TargetKind {
get { return targetKind; }
set { targetKind = value; }
}
public PortableExecutableKinds ExecutableKind {
get { return executableKind; }
set { executableKind = value; }
}
public ImageFileMachine Machine {
get { return machine; }
set { machine = value; }
}
public string MainFile {
get { return mainFile; }
set { mainFile = value; }
}
public string OutputAssembly {
get { return outputAssembly; }
set { outputAssembly = value; }
}
public bool IncludeDebugInformation {
get { return includeDebugInformation; }
set { includeDebugInformation = value; }
}
/// <summary>
/// The compilation requires us to change into the compile output folder since the
/// AssemblyBuilder.Save does not use a full path when generating the assembly.
/// </summary>
public void Compile()
{
VerifyParameters();
// Compile the source files to a dll first.
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine();
Dictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary.Add("mainModule", mainFile);
string outputAssemblyDll = Path.ChangeExtension(outputAssembly, ".dll");
ClrModule.CompileModules(DefaultContext.Default, outputAssemblyDll, dictionary, ToStringArray(sourceFiles));
// Generate an executable if required.
if (targetKind != PEFileKinds.Dll) {
// Change into compilation folder.
string originalFolder = Directory.GetCurrentDirectory();
try {
string compileFolder = Path.Combine(originalFolder, Path.GetDirectoryName(outputAssembly));
Directory.SetCurrentDirectory(compileFolder);
GenerateExecutable(outputAssemblyDll);
} finally {
Directory.SetCurrentDirectory(originalFolder);
}
}
}
/// <summary>
/// Verifies the compiler parameters that have been set correctly.
/// </summary>
public void VerifyParameters()
{
if ((mainFile == null) && (targetKind != PEFileKinds.Dll)) {
throw new PythonCompilerException(Resources.NoMainFileSpecified);
}
}
public void Dispose()
{
}
/// <summary>
/// Generates an executable from the already compiled dll.
/// </summary>
void GenerateExecutable(string outputAssemblyDll)
{
string outputAssemblyFileNameWithoutExtension = Path.GetFileNameWithoutExtension(outputAssembly);
AssemblyName assemblyName = new AssemblyName(outputAssemblyFileNameWithoutExtension);
AssemblyBuilder assemblyBuilder = PythonOps.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(outputAssemblyFileNameWithoutExtension, assemblyName.Name + ".exe");
TypeBuilder typeBuilder = moduleBuilder.DefineType("PythonMain", TypeAttributes.Public);
MethodBuilder mainMethod = typeBuilder.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, typeof(int), new Type[0]);
MarkMainMethodAsSTA(mainMethod);
GenerateMainMethodBody(mainMethod, outputAssemblyDll);
// Add resources.
AddResources(moduleBuilder);
// Create executable.
typeBuilder.CreateType();
assemblyBuilder.SetEntryPoint(mainMethod, targetKind);
assemblyBuilder.Save(assemblyName.Name + ".exe", executableKind, machine);
}
void MarkMainMethodAsSTA(MethodBuilder mainMethod)
{
mainMethod.SetCustomAttribute(typeof(STAThreadAttribute).GetConstructor(Type.EmptyTypes), new byte[0]);
}
void GenerateMainMethodBody(MethodBuilder mainMethod, string outputAssemblyDll)
{
ILGenerator generator = mainMethod.GetILGenerator();
LocalBuilder exeAssemblyLocalVariable = generator.DeclareLocal(typeof(Assembly));
LocalBuilder directoryLocalVariable = generator.DeclareLocal(typeof(string));
LocalBuilder fileNameLocalVariable = generator.DeclareLocal(typeof(string));
generator.EmitCall(OpCodes.Call, typeof(Assembly).GetMethod("GetExecutingAssembly", new Type[0], new ParameterModifier[0]), null);
generator.Emit(OpCodes.Stloc_0);
generator.Emit(OpCodes.Ldloc_0);
generator.EmitCall(OpCodes.Callvirt, typeof(Assembly).GetMethod("get_Location"), null);
generator.EmitCall(OpCodes.Call, typeof(Path).GetMethod("GetDirectoryName", new Type[] {typeof(String)}, new ParameterModifier[0]), null);
generator.Emit(OpCodes.Stloc_1);
generator.Emit(OpCodes.Ldloc_1);
generator.Emit(OpCodes.Ldstr, Path.GetFileName(outputAssemblyDll));
generator.EmitCall(OpCodes.Call, typeof(Path).GetMethod("Combine", new Type[] {typeof(String), typeof(String)}, new ParameterModifier[0]), null);
generator.Emit(OpCodes.Stloc_2);
generator.Emit(OpCodes.Ldloc_2);
generator.EmitCall(OpCodes.Call, typeof(Assembly).GetMethod("LoadFile", new Type[] {typeof(String)}, new ParameterModifier[0]), null);
generator.Emit(OpCodes.Ldstr, Path.GetFileNameWithoutExtension(mainFile));
// Add referenced assemblies.
AddReferences(generator);
generator.EmitCall(OpCodes.Call, typeof(PythonOps).GetMethod("InitializeModule"), new Type[0]);
generator.Emit(OpCodes.Ret);
}
/// <summary>
/// Converts an IList<string> into a string[].
/// </summary>
string[] ToStringArray(IList<string> items)
{
string[] array = new string[items.Count];
items.CopyTo(array, 0);
return array;
}
/// <summary>
/// Adds reference information to the IL.
/// </summary>
void AddReferences(ILGenerator generator)
{
if (referencedAssemblies.Count > 0) {
generator.Emit(OpCodes.Ldc_I4, referencedAssemblies.Count);
generator.Emit(OpCodes.Newarr, typeof(String));
for (int i = 0; i < referencedAssemblies.Count; ++i) {
generator.Emit(OpCodes.Dup);
generator.Emit(OpCodes.Ldc_I4, i);
string assemblyFileName = referencedAssemblies[i];
Assembly assembly = Assembly.ReflectionOnlyLoadFrom(assemblyFileName);
generator.Emit(OpCodes.Ldstr, assembly.FullName);
generator.Emit(OpCodes.Stelem_Ref);
}
} else {
generator.Emit(OpCodes.Ldnull);
}
}
/// <summary>
/// Embeds resources into the assembly.
/// </summary>
void AddResources(ModuleBuilder moduleBuilder)
{
foreach (ResourceFile resourceFile in resourceFiles) {
AddResource(moduleBuilder, resourceFile);
}
}
/// <summary>
/// Embeds a single resource into the assembly.
/// </summary>
void AddResource(ModuleBuilder moduleBuilder, ResourceFile resourceFile)
{
string fileName = resourceFile.FileName;
string extension = Path.GetExtension(fileName).ToLowerInvariant();
if (extension == ".resources") {
string fullFileName = Path.GetFileName(fileName);
IResourceWriter resourceWriter = moduleBuilder.DefineResource(fullFileName, resourceFile.Name, ResourceAttributes.Public);
AddResources(resourceWriter, fileName);
} else {
moduleBuilder.DefineManifestResource(resourceFile.Name, new FileStream(fileName, FileMode.Open), ResourceAttributes.Public);
}
}
void AddResources(IResourceWriter resourceWriter, string fileName)
{
ResourceReader resourceReader = new ResourceReader(fileName);
using (resourceReader) {
IDictionaryEnumerator enumerator = resourceReader.GetEnumerator();
while (enumerator.MoveNext()) {
string key = enumerator.Key as string;
Stream resourceStream = enumerator.Value as Stream;
if (resourceStream != null) {
BinaryReader reader = new BinaryReader(resourceStream);
MemoryStream stream = new MemoryStream();
byte[] bytes = reader.ReadBytes((int)resourceStream.Length);
stream.Write(bytes, 0, bytes.Length);
resourceWriter.AddResource(key, stream);
} else {
resourceWriter.AddResource(key, enumerator.Value);
}
}
}
}
}
}

313
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/PythonCompilerTask.cs

@ -1,313 +0,0 @@ @@ -1,313 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using IronPython.Hosting;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Scripting;
namespace ICSharpCode.Python.Build.Tasks
{
/// <summary>
/// Python compiler task.
/// </summary>
public class PythonCompilerTask : Task
{
IPythonCompiler compiler;
ITaskItem[] sources;
ITaskItem[] references;
ITaskItem[] resources;
string targetType;
string mainFile;
string outputAssembly;
bool emitDebugInformation;
string platform;
public PythonCompilerTask()
: this(new PythonCompiler())
{
}
public PythonCompilerTask(IPythonCompiler compiler)
{
this.compiler = compiler;
}
/// <summary>
/// Gets or sets the source files that will be compiled.
/// </summary>
public ITaskItem[] Sources {
get { return sources; }
set { sources = value; }
}
/// <summary>
/// Gets or sets the resources to be compiled.
/// </summary>
public ITaskItem[] Resources {
get { return resources; }
set { resources = value; }
}
/// <summary>
/// Gets or sets the output assembly type.
/// </summary>
public string TargetType {
get { return targetType; }
set { targetType = value; }
}
/// <summary>
/// Gets or sets the file that contains the main entry point.
/// </summary>
public string MainFile {
get { return mainFile; }
set { mainFile = value; }
}
/// <summary>
/// Gets or sets the output assembly filename.
/// </summary>
public string OutputAssembly {
get { return outputAssembly; }
set { outputAssembly = value; }
}
/// <summary>
/// Gets or sets the platform that will be targeted by the compiler (e.g. x86).
/// </summary>
public string Platform {
get { return platform; }
set { platform = value; }
}
/// <summary>
/// Gets or sets whether the compiler should include debug
/// information in the created assembly.
/// </summary>
public bool EmitDebugInformation {
get { return emitDebugInformation; }
set { emitDebugInformation = value; }
}
/// <summary>
/// Gets or sets the assembly references.
/// </summary>
public ITaskItem[] References {
get { return references; }
set { references = value; }
}
/// <summary>
/// Executes the compiler.
/// </summary>
public override bool Execute()
{
using (compiler) {
// Set what sort of assembly we are generating
// (e.g. WinExe, Exe or Dll)
compiler.TargetKind = GetPEFileKind(targetType);
compiler.ExecutableKind = GetExecutableKind(platform);
compiler.Machine = GetMachine(platform);
compiler.SourceFiles = GetFiles(sources, false);
compiler.ReferencedAssemblies = GetFiles(references, true);
compiler.ResourceFiles = GetResourceFiles(resources);
compiler.MainFile = mainFile;
compiler.OutputAssembly = outputAssembly;
compiler.IncludeDebugInformation = emitDebugInformation;
// Compile the code.
try {
compiler.Compile();
return true;
} catch (SyntaxErrorException ex) {
LogSyntaxError(ex);
} catch (IOException ex) {
LogError(ex.Message);
} catch (PythonCompilerException ex) {
LogError(ex.Message);
}
}
return false;
}
/// <summary>
/// Gets the current folder where this task is being executed from.
/// </summary>
protected virtual string GetCurrentFolder()
{
return Directory.GetCurrentDirectory();
}
/// <summary>
/// Logs any error message that occurs during compilation. Default implementation
/// is to use the MSBuild task's base.Log.LogError(...)
/// </summary>
protected virtual void LogError(string message, string errorCode, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber)
{
Log.LogError(null, errorCode, null, file, lineNumber, columnNumber, endLineNumber, endColumnNumber, message);
}
void LogError(string message)
{
LogError(message, null, null, 0, 0, 0, 0);
}
void LogSyntaxError(SyntaxErrorException ex)
{
string fileName = GetFileName(ex, sources);
LogError(ex.Message, ex.ErrorCode.ToString(), fileName, ex.Line, ex.Column, ex.RawSpan.End.Line, ex.RawSpan.End.Column);
}
/// <summary>
/// Matches the syntax exception SourcePath against filenames being compiled. The
/// syntax exception only contains the file name without its path and without its file extension.
/// </summary>
string GetFileName(SyntaxErrorException ex, ITaskItem[] sources)
{
if (ex.SourcePath == null) {
return null;
}
string sourcePath = ex.SourcePath.Replace('\\', '.');
foreach (ITaskItem item in sources) {
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item.ItemSpec);
if (fileNameWithoutExtension == sourcePath) {
return item.ItemSpec;
}
}
string fileName = sourcePath + ".py";
return Path.Combine(GetCurrentFolder(), fileName);
}
/// <summary>
/// Maps from the target type string to the PEFileKind
/// needed by the compiler.
/// </summary>
static PEFileKinds GetPEFileKind(string targetType)
{
if (targetType != null) {
switch (targetType.ToLowerInvariant()) {
case "winexe":
return PEFileKinds.WindowApplication;
case "library":
return PEFileKinds.Dll;
}
}
return PEFileKinds.ConsoleApplication;
}
/// <summary>
/// Converts from an array of ITaskItems to a list of
/// strings, each containing the ITaskItem filename.
/// </summary>
IList<string> GetFiles(ITaskItem[] taskItems, bool fullPath)
{
List<string> files = new List<string>();
if (taskItems != null) {
foreach (ITaskItem item in taskItems) {
string fileName = item.ItemSpec;
if (fullPath) {
fileName = GetFullPath(item.ItemSpec);
}
files.Add(fileName);
}
}
return files;
}
/// <summary>
/// Converts the string into a PortableExecutableKinds enum.
/// </summary>
PortableExecutableKinds GetExecutableKind(string platform)
{
switch (platform) {
case "x86":
return PortableExecutableKinds.ILOnly | PortableExecutableKinds.Required32Bit;
case "Itanium":
case "x64":
return PortableExecutableKinds.ILOnly | PortableExecutableKinds.PE32Plus;
}
return PortableExecutableKinds.ILOnly;
}
/// <summary>
/// Gets the machine associated with a PortalExecutableKind.
/// </summary>
ImageFileMachine GetMachine(string platform)
{
switch (platform) {
case "Itanium":
return ImageFileMachine.IA64;
case "x64":
return ImageFileMachine.AMD64;
}
return ImageFileMachine.I386;
}
/// <summary>
/// Converts from an array of ITaskItems to a list of
/// ResourceFiles.
/// </summary>
/// <remarks>
/// The resource name is the filename without any preceding
/// path information.
/// </remarks>
IList<ResourceFile> GetResourceFiles(ITaskItem[] taskItems)
{
List<ResourceFile> files = new List<ResourceFile>();
if (taskItems != null) {
foreach (ITaskItem item in taskItems) {
string resourceFileName = GetFullPath(item.ItemSpec);
string resourceName = GetResourceName(item);
ResourceFile resourceFile = new ResourceFile(resourceName, resourceFileName);
files.Add(resourceFile);
}
}
return files;
}
string GetResourceName(ITaskItem item)
{
string logicalResourceName = item.GetMetadata("LogicalName");
if (!String.IsNullOrEmpty(logicalResourceName)) {
return logicalResourceName;
}
return Path.GetFileName(item.ItemSpec);
}
/// <summary>
/// Takes a relative path to a file and turns it into the full path using the current folder
/// as the base directory.
/// </summary>
string GetFullPath(string fileName)
{
if (!Path.IsPathRooted(fileName)) {
return Path.GetFullPath(Path.Combine(GetCurrentFolder(), fileName));
}
return fileName;
}
}
}

58
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/ResourceFile.cs

@ -1,58 +0,0 @@ @@ -1,58 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.Python.Build.Tasks
{
/// <summary>
/// Stores the name and filename of a resource that will be embedded by the PythonCompiler.
/// </summary>
public class ResourceFile
{
string name;
string fileName;
bool isPublic;
public ResourceFile(string name, string fileName) : this(name, fileName, true)
{
}
public ResourceFile(string name, string fileName, bool isPublic)
{
this.name = name;
this.fileName = fileName;
this.isPublic = isPublic;
}
public string Name {
get { return name; }
set { name = value; }
}
public string FileName {
get { return fileName; }
set { fileName = value; }
}
public bool IsPublic {
get { return isPublic; }
set { isPublic = value; }
}
}
}

36
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Project/Src/Resources.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.Python.Build.Tasks
{
public class Resources
{
Resources()
{
}
/// <summary>
/// No main file specified when trying to compile an application
/// </summary>
public static string NoMainFileSpecified {
get { return "No main file specified."; }
}
}
}

49
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/AssemblyInfo.cs

@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("Python.Build.Tasks.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Python.Build.Tasks.Tests")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("0.3")]

90
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/CompileResourcesTestFixture.cs

@ -1,90 +0,0 @@ @@ -1,90 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using IronPython.Hosting;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that resources are compiled using the PythonCompilerTask.
/// </summary>
[TestFixture]
public class CompileResourcesTestFixture
{
MockPythonCompiler mockCompiler;
TaskItem resourceTaskItem;
ResourceFile resourceFile;
PythonCompilerTask compiler;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new PythonCompilerTask(mockCompiler);
TaskItem sourceTaskItem = new TaskItem("test.py");
compiler.Sources = new ITaskItem[] {sourceTaskItem};
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
resourceTaskItem = new TaskItem(@"C:\Projects\Test\Test.resources");
compiler.Resources = new ITaskItem[] {resourceTaskItem};
compiler.Execute();
if (mockCompiler.ResourceFiles != null && mockCompiler.ResourceFiles.Count > 0) {
resourceFile = mockCompiler.ResourceFiles[0];
}
}
[Test]
public void OneResourceFile()
{
Assert.AreEqual(1, mockCompiler.ResourceFiles.Count);
}
[Test]
public void ResourceFileName()
{
Assert.AreEqual(resourceTaskItem.ItemSpec, resourceFile.FileName);
}
/// <summary>
/// The resource name should be the same as the filename without
/// any preceding path information.
/// </summary>
[Test]
public void ResourceName()
{
Assert.AreEqual("Test.resources", resourceFile.Name);
}
[Test]
public void CompilerTaskResources()
{
ITaskItem[] resources = compiler.Resources;
Assert.AreEqual(resourceTaskItem, resources[0]);
}
}
}

120
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/CompileSingleSourceFileTestFixture.cs

@ -1,120 +0,0 @@ @@ -1,120 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that the python compiler task compiles a single source file.
/// </summary>
[TestFixture]
public class CompileSingleSourceFileTestFixture
{
MockPythonCompiler mockCompiler;
TaskItem sourceTaskItem;
TaskItem systemXmlReferenceTaskItem;
TaskItem systemDataReferenceTaskItem;
PythonCompilerTask compiler;
bool success;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new PythonCompilerTask(mockCompiler);
sourceTaskItem = new TaskItem("test.py");
compiler.Sources = new ITaskItem[] {sourceTaskItem};
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
systemDataReferenceTaskItem = new TaskItem(@"C:\Windows\Microsoft.NET\Framework\2.0\System.Data.dll");
systemXmlReferenceTaskItem = new TaskItem(@"C:\Windows\Microsoft.NET\Framework\2.0\System.Xml.dll");
compiler.References = new ITaskItem[] {systemDataReferenceTaskItem, systemXmlReferenceTaskItem};
success = compiler.Execute();
}
[Test]
public void CompilationSucceeded()
{
Assert.IsTrue(success);
}
[Test]
public void OneSourceFile()
{
Assert.AreEqual(1, mockCompiler.SourceFiles.Count);
}
[Test]
public void SourceFileName()
{
Assert.AreEqual("test.py", mockCompiler.SourceFiles[0]);
}
[Test]
public void IsCompileCalled()
{
Assert.IsTrue(mockCompiler.CompileCalled);
}
[Test]
public void IsDisposeCalled()
{
Assert.IsTrue(mockCompiler.DisposeCalled);
}
[Test]
public void TargetKindIsExe()
{
Assert.AreEqual(PEFileKinds.ConsoleApplication, mockCompiler.TargetKind);
}
[Test]
public void OutputAssembly()
{
Assert.AreEqual("test.exe", mockCompiler.OutputAssembly);
}
[Test]
public void DebugInfo()
{
Assert.IsFalse(mockCompiler.IncludeDebugInformation);
}
[Test]
public void TwoReferences()
{
Assert.AreEqual(2, mockCompiler.ReferencedAssemblies.Count);
}
[Test]
public void PythonCompilerTaskReferences()
{
ITaskItem[] references = compiler.References;
Assert.AreEqual(systemDataReferenceTaskItem, references[0]);
Assert.AreEqual(systemXmlReferenceTaskItem, references[1]);
}
}
}

84
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/DifferentTargetTypesTestFixture.cs

@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that the PythonCompiler correctly compiles to a
/// windows app when the TargetType is set to WinExe".
/// </summary>
[TestFixture]
public class DifferentTargetTypesTestFixture
{
MockPythonCompiler mockCompiler;
TaskItem sourceTaskItem;
PythonCompilerTask compilerTask;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compilerTask = new PythonCompilerTask(mockCompiler);
sourceTaskItem = new TaskItem("test.py");
compilerTask.Sources = new ITaskItem[] {sourceTaskItem};
}
[Test]
public void CompiledToWindowsApp()
{
compilerTask.TargetType = "WinExe";
compilerTask.Execute();
Assert.AreEqual(PEFileKinds.WindowApplication, mockCompiler.TargetKind);
}
[Test]
public void CompiledToWindowsAppWhenTargetTypeLowerCase()
{
compilerTask.TargetType = "winexe";
compilerTask.Execute();
Assert.AreEqual(PEFileKinds.WindowApplication, mockCompiler.TargetKind);
}
[Test]
public void CompiledToDll()
{
compilerTask.TargetType = "Library";
compilerTask.Execute();
Assert.AreEqual(PEFileKinds.Dll, mockCompiler.TargetKind);
}
[Test]
public void NullTargetTypeCompilesToConsoleApp()
{
compilerTask.TargetType = null;
compilerTask.Execute();
Assert.AreEqual(PEFileKinds.ConsoleApplication, mockCompiler.TargetKind);
}
}
}

109
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/DummyPythonCompilerTask.cs

@ -1,109 +0,0 @@ @@ -1,109 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Python.Build.Tasks;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Overrides the GetCurrentFolder to return a predefined string.
/// </summary>
public class DummyPythonCompilerTask : PythonCompilerTask
{
string currentFolder;
string loggedErrorMessage;
string loggedErrorCode;
string loggedErrorFile;
int loggedStartColumn = -1;
int loggedStartLine = -1;
int loggedEndLine = -1;
int loggedEndColumn = -1;
public DummyPythonCompilerTask(IPythonCompiler compiler, string currentFolder)
: base(compiler)
{
this.currentFolder = currentFolder;
}
/// <summary>
/// Gets the error message passed to the LogError method.
/// </summary>
public string LoggedErrorMessage {
get { return loggedErrorMessage; }
}
/// <summary>
/// Gets the error code passed to the LogError method.
/// </summary>
public string LoggedErrorCode {
get { return loggedErrorCode; }
}
/// <summary>
/// Gets the file passed to the LogError method.
/// </summary>
public string LoggedErrorFile {
get { return loggedErrorFile; }
}
/// <summary>
/// Gets the start line passed to the LogError method.
/// </summary>
public int LoggedStartLine {
get { return loggedStartLine; }
}
/// <summary>
/// Gets the end line passed to the LogError method.
/// </summary>
public int LoggedEndLine {
get { return loggedEndLine; }
}
/// <summary>
/// Gets the start column passed to the LogError method.
/// </summary>
public int LoggedStartColumn {
get { return loggedStartColumn; }
}
/// <summary>
/// Gets the end column passed to the LogError method.
/// </summary>
public int LoggedEndColumn {
get { return loggedEndColumn; }
}
protected override string GetCurrentFolder()
{
return currentFolder;
}
protected override void LogError(string message, string errorCode, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber)
{
loggedErrorMessage = message;
loggedErrorCode = errorCode;
loggedErrorFile = file;
loggedStartColumn = columnNumber;
loggedStartLine = lineNumber;
loggedEndColumn = endColumnNumber;
loggedEndLine = endLineNumber;
}
}
}

72
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/IOErrorTestFixture.cs

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using System.Reflection.Emit;
using IronPython.Runtime;
using IronPython.Runtime.Operations;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that an IOException is caught and logged.
/// </summary>
[TestFixture]
public class IOErrorTestFixture
{
MockPythonCompiler mockCompiler;
DummyPythonCompilerTask compiler;
bool success;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py");
compiler.Sources = new ITaskItem[] {sourceFile};
mockCompiler.ThrowExceptionAtCompile = PythonOps.IOError("Could not find main file test.py");
success = compiler.Execute();
}
[Test]
public void ExecuteFailed()
{
Assert.IsFalse(success);
}
[Test]
public void IsExceptionMessageLogged()
{
Assert.AreEqual("Could not find main file test.py", compiler.LoggedErrorMessage);
}
}
}

77
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/IncludeDebugInfoTestFixture.cs

@ -1,77 +0,0 @@ @@ -1,77 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that the compiler includes debug info in the
/// generated assembly.
/// </summary>
[TestFixture]
public class IncludeDebugInfoTestFixture
{
MockPythonCompiler mockCompiler;
TaskItem sourceTaskItem;
PythonCompilerTask compiler;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new PythonCompilerTask(mockCompiler);
sourceTaskItem = new TaskItem("test.py");
compiler.Sources = new ITaskItem[] {sourceTaskItem};
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
compiler.EmitDebugInformation = true;
compiler.Execute();
}
[Test]
public void DebugInfoIncluded()
{
Assert.IsTrue(mockCompiler.IncludeDebugInformation);
}
[Test]
public void PythonCompilerTaskTargetType()
{
Assert.AreEqual("Exe", compiler.TargetType);
}
[Test]
public void PythonCompilerTaskOutputAssembly()
{
Assert.AreEqual("test.exe", compiler.OutputAssembly);
}
[Test]
public void PythonCompilerTaskEmitDebugInfo()
{
Assert.AreEqual(true, compiler.EmitDebugInformation);
}
}
}

59
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/LogicalResourceNamesTests.cs

@ -1,59 +0,0 @@ @@ -1,59 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
[TestFixture]
public class LogicalResourceNamesTests
{
MockPythonCompiler mockCompiler;
PythonCompilerTask compilerTask;
void CreatePythonCompilerTask()
{
mockCompiler = new MockPythonCompiler();
compilerTask = new PythonCompilerTask(mockCompiler);
compilerTask.TargetType = "Exe";
compilerTask.OutputAssembly = "test.exe";
}
[Test]
public void Execute_ResourceHasLogicalNameSetInTaskItemMetadata_ResourceNamePassedToCompilerUsesLogicalName()
{
CreatePythonCompilerTask();
TaskItem resourceTaskItem = new TaskItem("test.xaml");
resourceTaskItem.SetMetadata("LogicalName", "MyLogicalResourceName");
compilerTask.Resources = new ITaskItem[] {resourceTaskItem};
compilerTask.Execute();
ResourceFile resourceFile = mockCompiler.ResourceFiles[0];
string resourceName = resourceFile.Name;
string expectedResourceName = "MyLogicalResourceName";
Assert.AreEqual(expectedResourceName, resourceName);
}
}
}

72
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/MainEntryPointTestFixture.cs

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that the main entry point is set in the PythonCompiler
/// by the PythonCompilerTask.
/// </summary>
[TestFixture]
public class MainEntryPointTestFixture
{
MockPythonCompiler mockCompiler;
PythonCompilerTask compilerTask;
TaskItem mainTaskItem;
TaskItem classTaskItem;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compilerTask = new PythonCompilerTask(mockCompiler);
mainTaskItem = new TaskItem("main.py");
classTaskItem = new TaskItem("class1.py");
compilerTask.Sources = new ITaskItem[] {mainTaskItem, classTaskItem};
compilerTask.MainFile = "main.py";
compilerTask.Execute();
}
[Test]
public void MainFile()
{
Assert.AreEqual("main.py", mockCompiler.MainFile);
}
[Test]
public void TaskMainFile()
{
Assert.AreEqual("main.py", compilerTask.MainFile);
}
[Test]
public void TaskSources()
{
ITaskItem[] sources = compilerTask.Sources;
Assert.AreEqual(sources[0], mainTaskItem);
Assert.AreEqual(sources[1], classTaskItem);
}
}
}

67
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/MissingMainEntryPointTestFixture.cs

@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that an error is reported when the mainFile is missing and we are trying to compile
/// an executable.
/// </summary>
[TestFixture]
public class MissingMainEntryPointTestFixture
{
MockPythonCompiler mockCompiler;
DummyPythonCompilerTask compiler;
bool success;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py");
compiler.Sources = new ITaskItem[] {sourceFile};
mockCompiler.ThrowExceptionAtCompile = new PythonCompilerException("Missing main file.");
success = compiler.Execute();
}
[Test]
public void ExecuteFailed()
{
Assert.IsFalse(success);
}
[Test]
public void IsExceptionMessageLogged()
{
Assert.AreEqual("Missing main file.", compiler.LoggedErrorMessage);
}
}
}

160
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/MockPythonCompiler.cs

@ -1,160 +0,0 @@ @@ -1,160 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using IronPython.Hosting;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Implements the IPythonCompiler interface so the
/// PythonCompiler task can be tested.
/// </summary>
public class MockPythonCompiler : IPythonCompiler
{
IList<string> sourceFiles;
bool compileCalled;
bool disposeCalled;
PEFileKinds targetKind;
PortableExecutableKinds executableKind;
ImageFileMachine machine;
string mainFile;
string outputAssembly;
bool includeDebugInformation;
IList<string> referencedAssemblies;
IList<ResourceFile> resourceFiles;
Exception throwExceptionAtCompile;
public MockPythonCompiler()
{
}
/// <summary>
/// Gets or sets the source files to compiler.
/// </summary>
public IList<string> SourceFiles {
get { return sourceFiles; }
set { sourceFiles = value; }
}
/// <summary>
/// Gets or sets the filenames of the referenced assemblies.
/// </summary>
public IList<string> ReferencedAssemblies {
get { return referencedAssemblies; }
set { referencedAssemblies = value; }
}
/// <summary>
/// Gets or sets the resources to be compiled.
/// </summary>
public IList<ResourceFile> ResourceFiles {
get { return resourceFiles; }
set { resourceFiles = value; }
}
/// <summary>
/// Gets or sets the exception that will be thrown when the Compile method is called.
/// </summary>
public Exception ThrowExceptionAtCompile {
get { return throwExceptionAtCompile; }
set { throwExceptionAtCompile = value; }
}
/// <summary>
/// Compiles the source code.
/// </summary>
public void Compile()
{
compileCalled = true;
if (throwExceptionAtCompile != null) {
throw throwExceptionAtCompile;
}
}
/// <summary>
/// Disposes the compiler.
/// </summary>
public void Dispose()
{
disposeCalled = true;
}
/// <summary>
/// Gets or sets the type of the compiled assembly.
/// </summary>
public PEFileKinds TargetKind {
get { return targetKind; }
set { targetKind = value; }
}
public PortableExecutableKinds ExecutableKind {
get { return executableKind; }
set { executableKind = value; }
}
public ImageFileMachine Machine {
get { return machine; }
set { machine = value; }
}
/// <summary>
/// Gets or sets the file that contains the main entry point.
/// </summary>
public string MainFile {
get { return mainFile; }
set { mainFile = value; }
}
/// <summary>
/// Gets or sets the output assembly filename.
/// </summary>
public string OutputAssembly {
get { return outputAssembly; }
set { outputAssembly = value; }
}
/// <summary>
/// Gets or sets whether the compiler should include debug
/// information in the created assembly.
/// </summary>
public bool IncludeDebugInformation {
get { return includeDebugInformation; }
set { includeDebugInformation = value; }
}
/// <summary>
/// Gets whether the Compile method has been called.
/// </summary>
public bool CompileCalled {
get { return compileCalled; }
}
/// <summary>
/// Gets whether the Dispose method has been called.
/// </summary>
public bool DisposeCalled {
get { return disposeCalled; }
}
}
}

116
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/PlatformTestFixture.cs

@ -1,116 +0,0 @@ @@ -1,116 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests the platform information (e.g. x86) is correctly passed to the IPythonCompiler.
/// </summary>
[TestFixture]
public class PlatformTestFixture
{
MockPythonCompiler mockCompiler;
TaskItem sourceTaskItem;
PythonCompilerTask compilerTask;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compilerTask = new PythonCompilerTask(mockCompiler);
sourceTaskItem = new TaskItem("test.py");
compilerTask.Sources = new ITaskItem[] {sourceTaskItem};
}
[Test]
public void DefaultPlatformIsILOnly()
{
compilerTask.Execute();
Assert.AreEqual(PortableExecutableKinds.ILOnly, mockCompiler.ExecutableKind);
}
[Test]
public void DefaultMachineIs386()
{
compilerTask.Execute();
Assert.AreEqual(ImageFileMachine.I386, mockCompiler.Machine);
}
[Test]
public void ExecutableIsCompiledTo32Bit()
{
compilerTask.Platform = "x86";
compilerTask.Execute();
Assert.AreEqual(PortableExecutableKinds.ILOnly | PortableExecutableKinds.Required32Bit, mockCompiler.ExecutableKind);
}
[Test]
public void MachineWhenExecutableIsCompiledTo32Bit()
{
compilerTask.Platform = "x86";
compilerTask.Execute();
Assert.AreEqual(ImageFileMachine.I386, mockCompiler.Machine);
}
[Test]
public void ExecutableIsCompiledToItanium()
{
compilerTask.Platform = "Itanium";
compilerTask.Execute();
Assert.AreEqual(PortableExecutableKinds.ILOnly | PortableExecutableKinds.PE32Plus, mockCompiler.ExecutableKind);
}
[Test]
public void MachineWhenExecutableIsCompiledToItanium()
{
compilerTask.Platform = "Itanium";
compilerTask.Execute();
Assert.AreEqual(ImageFileMachine.IA64, mockCompiler.Machine);
}
[Test]
public void ExecutableIsCompiledTo64Bit()
{
compilerTask.Platform = "x64";
compilerTask.Execute();
Assert.AreEqual(PortableExecutableKinds.ILOnly | PortableExecutableKinds.PE32Plus, mockCompiler.ExecutableKind);
}
[Test]
public void MachineWhenExecutableIsCompiledTo64Bit()
{
compilerTask.Platform = "x64";
compilerTask.Execute();
Assert.AreEqual(ImageFileMachine.AMD64, mockCompiler.Machine);
}
}
}

90
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/Python.Build.Tasks.Tests.csproj

@ -1,90 +0,0 @@ @@ -1,90 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{833904AB-3CD4-4071-9B48-5770E44685AA}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>Python.Build.Tasks.Tests</RootNamespace>
<AssemblyName>Python.Build.Tasks.Tests</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\..\bin\UnitTests\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\..\..\..\..\bin\UnitTests\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="IronPython">
<HintPath>..\..\RequiredLibraries\IronPython.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Tasks" />
<Reference Include="Microsoft.Build.Utilities.v3.5">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="Microsoft.Dynamic">
<HintPath>..\..\RequiredLibraries\Microsoft.Dynamic.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting">
<HintPath>..\..\RequiredLibraries\Microsoft.Scripting.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CompileResourcesTestFixture.cs" />
<Compile Include="DifferentTargetTypesTestFixture.cs" />
<Compile Include="DummyPythonCompilerTask.cs" />
<Compile Include="IncludeDebugInfoTestFixture.cs" />
<Compile Include="IOErrorTestFixture.cs" />
<Compile Include="LogicalResourceNamesTests.cs" />
<Compile Include="MainEntryPointTestFixture.cs" />
<Compile Include="MissingMainEntryPointTestFixture.cs" />
<Compile Include="MockPythonCompiler.cs" />
<Compile Include="CompileSingleSourceFileTestFixture.cs" />
<Compile Include="PlatformTestFixture.cs" />
<Compile Include="PythonCompilerTests.cs" />
<Compile Include="RelativeReferenceTestFixture.cs" />
<Compile Include="RelativeResourceFileTestFixture.cs" />
<Compile Include="SyntaxErrorFileNameWithDotCharTestFixture.cs" />
<Compile Include="SyntaxErrorNullFileNameTestFixture.cs" />
<Compile Include="SyntaxErrorTestFixture.cs" />
<Compile Include="SyntaxErrorUnknownFileNameTestFixture.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project\Python.Build.Tasks.csproj">
<Project>{D332F2D1-2CF1-43B7-903C-844BD5211A7E}</Project>
<Name>Python.Build.Tasks</Name>
</ProjectReference>
</ItemGroup>
</Project>

57
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/PythonCompilerTests.cs

@ -1,57 +0,0 @@ @@ -1,57 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
[TestFixture]
public class PythonCompilerTests
{
[Test]
public void NoMainFileSpecifiedForWindowsApplication()
{
try {
PythonCompiler compiler = new PythonCompiler();
compiler.TargetKind = PEFileKinds.WindowApplication;
compiler.OutputAssembly = "test.exe";
compiler.SourceFiles = new string[0];
compiler.MainFile = null;
compiler.Compile();
Assert.Fail("Expected PythonCompilerException.");
} catch (PythonCompilerException ex) {
Assert.AreEqual(Resources.NoMainFileSpecified, ex.Message);
}
}
[Test]
public void NoMainSpecifiedForLibraryThrowsNoError()
{
PythonCompiler compiler = new PythonCompiler();
compiler.TargetKind = PEFileKinds.Dll;
compiler.OutputAssembly = "test.dll";
compiler.SourceFiles = new string[0];
compiler.MainFile = null;
compiler.VerifyParameters();
}
}
}

69
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/RelativeReferenceTestFixture.cs

@ -1,69 +0,0 @@ @@ -1,69 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that references with a relative path are converted to a full path before being
/// passed to the PythonCompiler.
/// </summary>
[TestFixture]
public class RelativeReferenceTestFixture
{
MockPythonCompiler mockCompiler;
TaskItem referenceTaskItem;
TaskItem fullPathReferenceTaskItem;
DummyPythonCompilerTask compiler;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
referenceTaskItem = new TaskItem(@"..\RequiredLibraries\MyReference.dll");
fullPathReferenceTaskItem = new TaskItem(@"C:\Projects\Test\MyTest.dll");
compiler.References = new ITaskItem[] {referenceTaskItem, fullPathReferenceTaskItem};
compiler.Execute();
}
[Test]
public void RelativePathReferenceItemPassedToCompilerWithFullPath()
{
string fileName = mockCompiler.ReferencedAssemblies[0];
Assert.AreEqual(@"C:\Projects\RequiredLibraries\MyReference.dll", fileName);
}
[Test]
public void FullPathReferenceItemUnchangedWhenPassedToCompiler()
{
string fileName = mockCompiler.ReferencedAssemblies[1];
Assert.AreEqual(fullPathReferenceTaskItem.ItemSpec, fileName);
}
}
}

69
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/RelativeResourceFileTestFixture.cs

@ -1,69 +0,0 @@ @@ -1,69 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection.Emit;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that resoures with a relative path are converted to a full path before being
/// passed to the PythonCompiler.
/// </summary>
[TestFixture]
public class RelativeResourceFileTestFixture
{
MockPythonCompiler mockCompiler;
TaskItem resourceTaskItem;
TaskItem fullPathResourceTaskItem;
DummyPythonCompilerTask compiler;
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
resourceTaskItem = new TaskItem(@"..\RequiredLibraries\MyResource.resx");
fullPathResourceTaskItem = new TaskItem(@"C:\Projects\Test\MyTest.resx");
compiler.Resources = new ITaskItem[] {resourceTaskItem, fullPathResourceTaskItem};
compiler.Execute();
}
[Test]
public void RelativePathReferenceItemPassedToCompilerWithFullPath()
{
string fileName = mockCompiler.ResourceFiles[0].FileName;
Assert.AreEqual(@"C:\Projects\RequiredLibraries\MyResource.resx", fileName);
}
[Test]
public void FullPathReferenceItemUnchangedWhenPassedToCompiler()
{
string fileName = mockCompiler.ResourceFiles[1].FileName;
Assert.AreEqual(fullPathResourceTaskItem.ItemSpec, fileName);
}
}
}

79
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorFileNameWithDotCharTestFixture.cs

@ -1,79 +0,0 @@ @@ -1,79 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using System.Reflection.Emit;
using IronPython.Runtime;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// If the project has a filename with a dot character in it (e.g. Resources.Designer.py) and this file
/// has a syntax error then IronPython's ClrModule.CompileModules method will throw a syntax error exception but the
/// filename will have a '\' replacing the dot character (i.e. Resources\Designer.py).
/// </summary>
[TestFixture]
public class SyntaxErrorFileNameWithDotCharTestFixture
{
MockPythonCompiler mockCompiler;
DummyPythonCompilerTask compiler;
bool success;
[TestFixtureSetUp]
public void SetUpFixture()
{
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine();
}
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\PythonApp.Program.py");
compiler.Sources = new ITaskItem[] {sourceFile};
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"PythonApp\Program", SourceCodeKind.InteractiveCode);
SourceLocation start = new SourceLocation(0, 1, 1);
SourceLocation end = new SourceLocation(0, 2, 3);
SourceSpan span = new SourceSpan(start, end);
SyntaxErrorException ex = new SyntaxErrorException("Error", source, span, 1000, Severity.FatalError);
mockCompiler.ThrowExceptionAtCompile = ex;
success = compiler.Execute();
}
[Test]
public void SourceFile()
{
Assert.AreEqual(@"D:\Projects\MyProject\PythonApp.Program.py", compiler.LoggedErrorFile);
}
}
}

71
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorNullFileNameTestFixture.cs

@ -1,71 +0,0 @@ @@ -1,71 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using System.Reflection.Emit;
using IronPython.Runtime;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
[TestFixture]
public class SyntaxErrorNullFileNameTestFixture
{
MockPythonCompiler mockCompiler;
DummyPythonCompilerTask compiler;
bool success;
[TestFixtureSetUp]
public void SetUpFixture()
{
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine();
}
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py");
compiler.Sources = new ITaskItem[] {sourceFile};
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"test", SourceCodeKind.InteractiveCode);
SyntaxErrorException ex = new SyntaxErrorException("Error", null, SourceSpan.None, 1000, Severity.FatalError);
mockCompiler.ThrowExceptionAtCompile = ex;
success = compiler.Execute();
}
[Test]
public void IsExceptionMessageLogged()
{
Assert.AreEqual("Error", compiler.LoggedErrorMessage);
}
}
}

119
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorTestFixture.cs

@ -1,119 +0,0 @@ @@ -1,119 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using System.Reflection.Emit;
using IronPython.Runtime;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// Tests that a syntax error exception is caught and logged.
/// </summary>
[TestFixture]
public class SyntaxErrorTestFixture
{
MockPythonCompiler mockCompiler;
DummyPythonCompilerTask compiler;
bool success;
[TestFixtureSetUp]
public void SetUpFixture()
{
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine();
}
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py");
compiler.Sources = new ITaskItem[] {sourceFile};
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"test", SourceCodeKind.InteractiveCode);
SourceLocation start = new SourceLocation(0, 1, 1);
SourceLocation end = new SourceLocation(0, 2, 3);
SourceSpan span = new SourceSpan(start, end);
SyntaxErrorException ex = new SyntaxErrorException("Error", source, span, 1000, Severity.FatalError);
mockCompiler.ThrowExceptionAtCompile = ex;
success = compiler.Execute();
}
[Test]
public void ExecuteFailed()
{
Assert.IsFalse(success);
}
[Test]
public void IsExceptionMessageLogged()
{
Assert.AreEqual("Error", compiler.LoggedErrorMessage);
}
[Test]
public void IsErrorCodeLogged()
{
Assert.AreEqual("1000", compiler.LoggedErrorCode);
}
[Test]
public void SourceFile()
{
Assert.AreEqual(@"D:\Projects\MyProject\test.py", compiler.LoggedErrorFile);
}
[Test]
public void SourceStartLine()
{
Assert.AreEqual(1, compiler.LoggedStartLine);
}
[Test]
public void SourceStartColumn()
{
Assert.AreEqual(1, compiler.LoggedStartColumn);
}
[Test]
public void SourceEndLine()
{
Assert.AreEqual(2, compiler.LoggedEndLine);
}
[Test]
public void SourceEndColumn()
{
Assert.AreEqual(3, compiler.LoggedEndColumn);
}
}
}

78
src/AddIns/BackendBindings/Python/Python.Build.Tasks/Test/SyntaxErrorUnknownFileNameTestFixture.cs

@ -1,78 +0,0 @@ @@ -1,78 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using System.Reflection.Emit;
using IronPython.Runtime;
using ICSharpCode.Python.Build.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;
using NUnit.Framework;
namespace Python.Build.Tasks.Tests
{
/// <summary>
/// If the filename returned from the SyntaxErrorException cannot be found in the project then
/// just use the project's folder concatenated with the filename.
/// </summary>
[TestFixture]
public class SyntaxErrorUnknownFileNameTestFixture
{
MockPythonCompiler mockCompiler;
DummyPythonCompilerTask compiler;
bool success;
[TestFixtureSetUp]
public void SetUpFixture()
{
ScriptEngine engine = IronPython.Hosting.Python.CreateEngine();
}
[SetUp]
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"D:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\test.py");
compiler.Sources = new ITaskItem[] {sourceFile};
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"test\unknown", SourceCodeKind.InteractiveCode);
SourceLocation start = new SourceLocation(0, 1, 1);
SourceLocation end = new SourceLocation(0, 2, 3);
SourceSpan span = new SourceSpan(start, end);
SyntaxErrorException ex = new SyntaxErrorException("Error", source, span, 1000, Severity.FatalError);
mockCompiler.ThrowExceptionAtCompile = ex;
success = compiler.Execute();
}
[Test]
public void SourceFile()
{
Assert.AreEqual(@"D:\Projects\MyProject\test.unknown.py", compiler.LoggedErrorFile);
}
}
}

206
src/AddIns/BackendBindings/Python/PythonBinding.sln

@ -1,206 +0,0 @@ @@ -1,206 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.3
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding.Tests", "PythonBinding\Test\PythonBinding.Tests.csproj", "{23B517C9-1ECC-4419-A13F-0B7136D085CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks", "Python.Build.Tasks\Project\Python.Build.Tasks.csproj", "{D332F2D1-2CF1-43B7-903C-844BD5211A7E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks.Tests", "Python.Build.Tasks\Test\Python.Build.Tasks.Tests.csproj", "{833904AB-3CD4-4071-9B48-5770E44685AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "..\..\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation", "..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj", "{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\..\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "..\..\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "..\..\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Scripting", "..\Scripting\Project\ICSharpCode.Scripting.csproj", "{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Scripting.Tests", "..\Scripting\Test\ICSharpCode.Scripting.Tests.csproj", "{85C09AD8-183B-403A-869A-7226646218A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PyWalker", "PyWalker\PyWalker.csproj", "{55329704-6046-48EC-8A20-5C80B3092A63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|Any CPU.Build.0 = Release|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Release|Any CPU.Build.0 = Release|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Release|Any CPU.Build.0 = Release|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Release|Any CPU.Build.0 = Release|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Release|Any CPU.Build.0 = Release|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|Any CPU.Build.0 = Release|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.Build.0 = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.Build.0 = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|Any CPU.ActiveCfg = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.Build.0 = Release|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.Build.0 = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Debug|Any CPU.Build.0 = Debug|x86
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Debug|Any CPU.ActiveCfg = Debug|x86
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Release|Any CPU.Build.0 = Release|x86
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Release|Any CPU.ActiveCfg = Release|x86
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Debug|x86.Build.0 = Debug|x86
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Debug|x86.ActiveCfg = Debug|x86
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Release|x86.Build.0 = Release|x86
{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}.Release|x86.ActiveCfg = Release|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Debug|Any CPU.Build.0 = Debug|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Debug|Any CPU.ActiveCfg = Debug|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Debug|x86.Build.0 = Debug|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Debug|x86.ActiveCfg = Debug|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Release|Any CPU.Build.0 = Release|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Release|Any CPU.ActiveCfg = Release|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Release|x86.Build.0 = Release|x86
{85C09AD8-183B-403A-869A-7226646218A9}.Release|x86.ActiveCfg = Release|x86
{55329704-6046-48EC-8A20-5C80B3092A63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55329704-6046-48EC-8A20-5C80B3092A63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55329704-6046-48EC-8A20-5C80B3092A63}.Debug|x86.Build.0 = Debug|Any CPU
{55329704-6046-48EC-8A20-5C80B3092A63}.Debug|x86.ActiveCfg = Debug|Any CPU
{55329704-6046-48EC-8A20-5C80B3092A63}.Release|Any CPU.Build.0 = Release|Any CPU
{55329704-6046-48EC-8A20-5C80B3092A63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55329704-6046-48EC-8A20-5C80B3092A63}.Release|x86.Build.0 = Release|Any CPU
{55329704-6046-48EC-8A20-5C80B3092A63}.Release|x86.ActiveCfg = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|x86.Build.0 = Debug|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|x86.ActiveCfg = Debug|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|x86.Build.0 = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|x86.ActiveCfg = Release|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|x86.Build.0 = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|x86.ActiveCfg = Debug|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|x86.Build.0 = Release|Any CPU
{1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|x86.ActiveCfg = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|x86.Build.0 = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|x86.ActiveCfg = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|x86.Build.0 = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|x86.ActiveCfg = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|x86.Build.0 = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|x86.ActiveCfg = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|x86.Build.0 = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|x86.ActiveCfg = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|x86.Build.0 = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|x86.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|x86.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|x86.ActiveCfg = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|x86.Build.0 = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Debug|x86.ActiveCfg = Debug|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|x86.Build.0 = Release|Any CPU
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}.Release|x86.ActiveCfg = Release|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|x86.Build.0 = Debug|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Debug|x86.ActiveCfg = Debug|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|x86.Build.0 = Release|Any CPU
{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}.Release|x86.ActiveCfg = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|x86.Build.0 = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|x86.ActiveCfg = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|x86.Build.0 = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|x86.ActiveCfg = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|x86.Build.0 = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|x86.ActiveCfg = Debug|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|x86.Build.0 = Release|Any CPU
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|x86.ActiveCfg = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|x86.Build.0 = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|x86.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|x86.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|x86.ActiveCfg = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|x86.Build.0 = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|x86.Build.0 = Release|Any CPU
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|x86.ActiveCfg = Release|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Debug|x86.Build.0 = Debug|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Debug|x86.ActiveCfg = Debug|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Release|x86.Build.0 = Release|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Release|x86.ActiveCfg = Release|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Debug|x86.Build.0 = Debug|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Debug|x86.ActiveCfg = Debug|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Release|x86.Build.0 = Release|Any CPU
{833904AB-3CD4-4071-9B48-5770E44685AA}.Release|x86.ActiveCfg = Release|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Debug|x86.Build.0 = Debug|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Debug|x86.ActiveCfg = Debug|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Release|x86.Build.0 = Release|Any CPU
{D332F2D1-2CF1-43B7-903C-844BD5211A7E}.Release|x86.ActiveCfg = Release|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Debug|x86.Build.0 = Debug|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Debug|x86.ActiveCfg = Debug|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Release|x86.Build.0 = Release|Any CPU
{23B517C9-1ECC-4419-A13F-0B7136D085CB}.Release|x86.ActiveCfg = Release|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Debug|x86.Build.0 = Debug|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Debug|x86.ActiveCfg = Debug|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|x86.Build.0 = Release|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

31
src/AddIns/BackendBindings/Python/PythonBinding/Project/Configuration/AssemblyInfo.cs

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Reflection;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("PythonBinding")]
[assembly: AssemblyDescription("IronPython addin for SharpDevelop.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

25
src/AddIns/BackendBindings/Python/PythonBinding/Project/Lib/__future__.py

@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
#####################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# This source code is subject to terms and conditions of the Microsoft Public License. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you cannot locate the Microsoft Public License, please send an email to
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
# by the terms of the Microsoft Public License.
#
# You must not remove this notice, or any other, from this software.
#
#
#####################################################################################
all_feature_names = ['nested_scopes', 'generators', 'division',
'absolute_import', 'with_statement', 'print_function',
'unicode_literals']
division=1
with_statement=1
generators=1
absolute_import=1
print_function=1
unicode_literals=1

31
src/AddIns/BackendBindings/Python/PythonBinding/Project/Lib/runpy.py

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
#####################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# This source code is subject to terms and conditions of the Microsoft Public License. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you cannot locate the Microsoft Public License, please send an email to
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
# by the terms of the Microsoft Public License.
#
# You must not remove this notice, or any other, from this software.
#
#
#####################################################################################
"""
Fake runpy.py which emulates what CPython does to properly support the '-m' flag.
If you have access to the CPython standard library, you most likely do not need this.
"""
import sys, nt
def run_module(modToRun, init_globals=None, run_name = '__main__', alter_sys = True):
if alter_sys:
for o in sys.path:
libpath = o + '\\' + modToRun + '.py'
if nt.access(libpath, nt.F_OK):
sys.argv[0] = libpath
break
__import__(modToRun)

14
src/AddIns/BackendBindings/Python/PythonBinding/Project/Lib/site.py

@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
#####################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# This source code is subject to terms and conditions of the Microsoft Public License. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you cannot locate the Microsoft Public License, please send an email to
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
# by the terms of the Microsoft Public License.
#
# You must not remove this notice, or any other, from this software.
#
#
#####################################################################################

227
src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin

@ -1,227 +0,0 @@ @@ -1,227 +0,0 @@
<AddIn name="Python Binding"
author="Matt Ward"
copyright="prj:///doc/copyright.txt"
description="Backend binding for IronPython"
addInManagerHidden="preinstalled">
<Manifest>
<Identity name="ICSharpCode.PythonBinding"/>
<Dependency addin="ICSharpCode.FormsDesigner"/>
</Manifest>
<Runtime>
<Import assembly=":ICSharpCode.SharpDevelop"/>
<Import assembly="$ICSharpCode.FormsDesigner/FormsDesigner.dll"/>
<Import assembly="$ICSharpCode.UnitTesting/UnitTesting.dll"/>
<Import assembly="IronPython.Modules.dll"/>
<Import assembly="PythonBinding.dll"/>
</Runtime>
<Path name="/SharpDevelop/ViewContent/AvalonEdit/SyntaxModes">
<SyntaxMode id="Python.SyntaxMode"
extensions=".py"
name="Python"
resource="ICSharpCode.PythonBinding.Resources.Python.xshd"/>
</Path>
<Path name="/SharpDevelop/Workbench/LanguageBindings">
<LanguageBinding id="Python"
class="ICSharpCode.PythonBinding.PythonLanguageBinding"
extensions=".py" />
</Path>
<!-- Add the "Python" entry to the Open File Dialog -->
<Path name="/SharpDevelop/Workbench/FileFilter">
<FileFilter id="Python"
insertbefore="Resources"
insertafter="Icons"
name="${res:ICSharpCode.PythonBinding.PythonFiles} (*.py)"
extensions="*.py"
mimeType = "text/plain"/>
</Path>
<!-- Add the "Python" entry to the Open Project Dialog -->
<Path name="/SharpDevelop/Workbench/Combine/FileFilter">
<FileFilter id="PythonProject"
insertbefore="AllFiles"
name="${res:ICSharpCode.PythonBinding.PythonProjectFiles} (*.pyproj)"
class="ICSharpCode.SharpDevelop.Project.LoadProject"
extensions="*.pyproj"/>
</Path>
<!-- File templates -->
<Path name="/SharpDevelop/BackendBindings/Templates">
<Directory id="Python" path="./Templates" />
</Path>
<!-- Python menu -->
<Path name="/SharpDevelop/Workbench/MainMenu">
<Condition name="ActiveContentExtension" activeextension=".py">
<MenuItem id="Python"
insertafter="Search"
insertbefore="Tools"
label="&amp;Python"
type="Menu">
<Condition name="IsProcessRunning" isprocessrunning="False" isdebugging="False" action="Disable">
<MenuItem id="Run"
icon="Icons.16x16.RunProgramIcon"
class="ICSharpCode.PythonBinding.RunDebugPythonCommand"
label="${res:XML.MainMenu.RunMenu.Run}"
shortcut="Control|Shift|R"/>
<MenuItem id="RunWithoutDebugger"
icon="Icons.16x16.Debug.StartWithoutDebugging"
class="ICSharpCode.PythonBinding.RunPythonCommand"
label="${res:XML.MainMenu.DebugMenu.RunWithoutDebug}"
shortcut="Control|Shift|W"/>
</Condition>
<Condition name="IsProcessRunning" isdebugging="True" action="Disable">
<MenuItem id="Stop"
icon="Icons.16x16.StopProcess"
class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"
label="${res:XML.MainMenu.DebugMenu.Stop}"/>
</Condition>
<MenuItem id="SendToPythonConsoleSeparator" type="Separator"/>
<MenuItem id="SendLineToPythonConsole"
class="ICSharpCode.PythonBinding.SendLineToPythonConsoleCommand"
label="${res:ICSharpCode.PythonBinding.SendLineToPythonConsole}"/>
<Condition name="IsTextSelected" action="Disable">
<MenuItem id="SendSelectedTextToPythonConsole"
class="ICSharpCode.PythonBinding.SendSelectedTextToPythonConsoleCommand"
label="${res:ICSharpCode.PythonBinding.SendSelectedTextToPythonConsole}"/>
</Condition>
</MenuItem>
</Condition>
</Path>
<!-- Python parser -->
<Path name="/SharpDevelop/Parser">
<Parser id="Python"
supportedextensions=".py"
projectfileextension=".pyproj"
class="ICSharpCode.PythonBinding.PythonParser"/>
</Path>
<!-- Register Python MSBuild project (.pyproj) -->
<Path name="/SharpDevelop/Workbench/ProjectBindings">
<ProjectBinding id="Python"
guid="{FD48973F-F585-4F70-812B-4D0503B36CE9}"
supportedextensions=".py"
projectfileextension=".pyproj"
class="ICSharpCode.PythonBinding.PythonProjectBinding" />
</Path>
<!-- The Python code completion binding -->
<Path name="/SharpDevelop/ViewContent/TextEditor/CodeCompletion">
<CodeCompletionBinding id="Python"
extensions=".py"
class="ICSharpCode.PythonBinding.PythonCodeCompletionBinding"/>
</Path>
<!--
Register path to SharpDevelop.Build.Python.targets for the MSBuild engine.
SharpDevelop.Build.Python.targets is in the PythonBinding AddIn directory
-->
<Path name="/SharpDevelop/MSBuildEngine/AdditionalProperties">
<String id="PythonBinPath" text="${AddInPath:ICSharpCode.PythonBinding}"/>
</Path>
<!-- Options panel -->
<Path name="/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<OptionPanel id="PythonOptionsPanel"
label="Python"
class="ICSharpCode.PythonBinding.PythonOptionsPanel"/>
</Path>
<!-- Project options panels -->
<Path path="/SharpDevelop/BackendBindings/ProjectOptions/Python">
<OptionPanel id="Application"
label="${res:Dialog.ProjectOptions.ApplicationSettings}"
class="ICSharpCode.PythonBinding.ApplicationSettingsPanel"/>
<OptionPanel id="BuildEvents"
label="${res:Dialog.ProjectOptions.BuildEvents}"
class="ICSharpCode.SharpDevelop.Gui.OptionPanels.BuildEvents"/>
<OptionPanel id="CompilingOptions"
label="${res:Dialog.ProjectOptions.BuildOptions}"
class="ICSharpCode.PythonBinding.CompilingOptionsPanel"/>
<OptionPanel id="DebugOptions"
label="${res:Dialog.ProjectOptions.DebugOptions}"
class="ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/>
</Path>
<!-- Python display binding -->
<Path name="/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id="PythonDisplayBinding"
type="Secondary"
fileNamePattern="\.py$"
languagePattern="^Python$"
class="ICSharpCode.PythonBinding.PythonFormsDesignerDisplayBinding" />
</Path>
<Path name="/SharpDevelop/Workbench/MainMenu/Tools/ConvertCode">
<ComplexCondition action="Disable">
<Or>
<Condition name="ActiveContentExtension" activeextension=".cs"/>
<Condition name="ActiveContentExtension" activeextension=".vb"/>
</Or>
<MenuItem id="ConvertToPython"
insertafter="CSharp"
insertbefore="VBNet"
label="Python"
class="ICSharpCode.PythonBinding.ConvertToPythonMenuCommand"/>
</ComplexCondition>
</Path>
<Path name="/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert">
<Condition name="ProjectActive" activeproject="C#">
<MenuItem id="CSharpProjectToPythonProjectConverter"
label="${res:ICSharpCode.PythonBinding.ConvertCSharpProjectToPythonProject}"
class="ICSharpCode.PythonBinding.ConvertProjectToPythonProjectCommand"/>
</Condition>
<Condition name="ProjectActive" activeproject="VBNet">
<MenuItem id="VBNetProjectToPythonProjectConverter"
label="${res:ICSharpCode.PythonBinding.ConvertVBNetProjectToPythonProject}"
class="ICSharpCode.PythonBinding.ConvertProjectToPythonProjectCommand"/>
</Condition>
</Path>
<Path name="/SharpDevelop/Workbench/Pads">
<Pad id="PythonConsole"
category="Tools"
title="${res:ICSharpCode.PythonBinding.PythonConsole}"
insertbefore="DefinitionView"
icon="PadIcons.Output"
defaultPosition="Bottom, Hidden"
class="ICSharpCode.PythonBinding.PythonConsolePad"/>
</Path>
<Path name="/Workspace/Icons">
<Icon id="PythonFileIcon"
extensions=".py"
resource="Python.ProjectBrowser.File"/>
<Icon id="PythonProjectIcon"
language="Python"
resource="Python.ProjectBrowser.Project"/>
</Path>
<Path name="/SharpDevelop/UnitTesting/TestFrameworks">
<TestFramework id="pyunit"
class="ICSharpCode.PythonBinding.PythonTestFramework"
supportedProjects=".pyproj"/>
</Path>
<Path name="/SharpDevelop/ViewContent/TextEditor/ContextMenu">
<Condition name="ActiveContentExtension" activeextension=".py">
<MenuItem id="SendToPythonConsoleSeparator"
insertafter="Indent"
type="Separator"/>
<MenuItem id="SendLineToPythonConsole"
class="ICSharpCode.PythonBinding.SendLineToPythonConsoleCommand"
label="${res:ICSharpCode.PythonBinding.SendLineToPythonConsole}"/>
<Condition name="IsTextSelected" action="Disable">
<MenuItem id="SendSelectedTextToPythonConsole"
class="ICSharpCode.PythonBinding.SendSelectedTextToPythonConsoleCommand"
label="${res:ICSharpCode.PythonBinding.SendSelectedTextToPythonConsole}"/>
</Condition>
</Condition>
</Path>
</AddIn>

319
src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj

@ -1,319 +0,0 @@ @@ -1,319 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{8D732610-8FC6-43BA-94C9-7126FD7FE361}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.PythonBinding</RootNamespace>
<AssemblyName>PythonBinding</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\..\AddIns\BackendBindings\PythonBinding\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\..\..\..\..\AddIns\BackendBindings\PythonBinding\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="Chiron">
<HintPath>..\..\RequiredLibraries\Chiron.exe</HintPath>
</Reference>
<Reference Include="ipy">
<HintPath>..\..\RequiredLibraries\ipy.exe</HintPath>
</Reference>
<Reference Include="IronPython">
<HintPath>..\..\RequiredLibraries\IronPython.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="IronPython.Modules">
<HintPath>..\..\RequiredLibraries\IronPython.Modules.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Dynamic">
<HintPath>..\..\RequiredLibraries\Microsoft.Dynamic.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Scripting">
<HintPath>..\..\RequiredLibraries\Microsoft.Scripting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Scripting.Metadata">
<HintPath>..\..\RequiredLibraries\Microsoft.Scripting.Metadata.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Src\ConstructorInfo.cs" />
<Compile Include="Src\ConvertProjectToPythonProjectCommand.cs" />
<Compile Include="Src\ConvertToPythonMenuCommand.cs" />
<Compile Include="Src\ApplicationSettingsPanel.cs" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AddInOptions.cs" />
<Compile Include="Src\CompilingOptionsPanel.cs" />
<Compile Include="Src\IPythonResolver.cs" />
<Compile Include="Src\MemberName.cs" />
<Compile Include="Src\PythonBuiltInModuleMemberName.cs" />
<Compile Include="Src\PythonClass.cs" />
<Compile Include="Src\PythonClassFields.cs" />
<Compile Include="Src\PythonClassMembers.cs" />
<Compile Include="Src\PythonClassResolver.cs" />
<Compile Include="Src\PythonCodeCompletionItemProvider.cs" />
<Compile Include="Src\PythonCompilationUnit.cs" />
<Compile Include="Src\PythonCompletionItemList.cs" />
<Compile Include="Src\PythonConsoleApplication.cs" />
<Compile Include="Src\PythonConstructor.cs" />
<Compile Include="Src\PythonFromImport.cs" />
<Compile Include="Src\PythonImport.cs" />
<Compile Include="Src\PythonInsightWindowHandler.cs" />
<Compile Include="Src\PythonLanguageBinding.cs" />
<Compile Include="Src\PythonLineIndenter.cs" />
<Compile Include="Src\PythonLocalVariableAssignment.cs" />
<Compile Include="Src\PythonLocalVariableResolver.cs" />
<Compile Include="Src\PythonMemberResolver.cs" />
<Compile Include="Src\PythonMethod.cs" />
<Compile Include="Src\PythonMethodDefinition.cs" />
<Compile Include="Src\PythonMethodGroupResolveResult.cs" />
<Compile Include="Src\PythonMethodOrClassBodyRegion.cs" />
<Compile Include="Src\PythonMethodReturnValueResolver.cs" />
<Compile Include="Src\PythonModule.cs" />
<Compile Include="Src\PythonModuleCompletionItems.cs" />
<Compile Include="Src\PythonModuleCompletionItemsFactory.cs" />
<Compile Include="Src\PythonImportResolver.cs" />
<Compile Include="Src\PythonNamespaceResolver.cs" />
<Compile Include="Src\PythonOptionsPanel.xaml.cs">
<DependentUpon>PythonOptionsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\PythonProperty.cs" />
<Compile Include="Src\PythonPropertyAssignment.cs" />
<Compile Include="Src\PythonResolverContext.cs" />
<Compile Include="Src\PythonSelfResolver.cs" />
<Compile Include="Src\PythonStandardLibraryPath.cs" />
<Compile Include="Src\PythonStandardModuleMethodResolver.cs" />
<Compile Include="Src\PythonStandardModuleMethodResolveResult.cs" />
<Compile Include="Src\PythonStandardModuleResolver.cs" />
<Compile Include="Src\PythonStandardModuleResolveResult.cs" />
<Compile Include="Src\PythonStandardModuleType.cs" />
<Compile Include="Src\PythonTestDebugger.cs" />
<Compile Include="Src\PythonTestFramework.cs" />
<Compile Include="Src\PythonTestResult.cs" />
<Compile Include="Src\PythonTestRunner.cs" />
<Compile Include="Src\PythonTestRunnerApplication.cs" />
<Compile Include="Src\PythonTestRunnerContext.cs" />
<Compile Include="Src\PythonTestRunnerResponseFile.cs" />
<Compile Include="Src\PythonUsingScope.cs" />
<Compile Include="Src\PythonWorkbench.cs" />
<Compile Include="Src\SendLineToPythonConsoleCommand.cs" />
<Compile Include="Src\SendSelectedTextToPythonConsoleCommand.cs" />
<Compile Include="Src\SysModuleCompletionItems.cs" />
<Compile Include="Src\NRefactoryToPythonConverter.cs" />
<Compile Include="Src\PythonAstWalker.cs" />
<Compile Include="Src\PythonCodeCompletionBinding.cs" />
<Compile Include="Src\PythonCodeDeserializer.cs" />
<Compile Include="Src\PythonCodeBuilder.cs" />
<Compile Include="Src\PythonCodeDomSerializer.cs" />
<Compile Include="Src\PythonCompilerError.cs" />
<Compile Include="Src\PythonCompilerSink.cs" />
<Compile Include="Src\PythonConsole.cs" />
<Compile Include="Src\PythonConsoleHost.cs" />
<Compile Include="Src\PythonConsolePad.cs" />
<Compile Include="Src\PythonControlFieldExpression.cs">
</Compile>
<Compile Include="Src\PythonDesignerGenerator.cs" />
<Compile Include="Src\PythonDesignerLoader.cs" />
<Compile Include="Src\PythonDesignerLoaderProvider.cs" />
<Compile Include="Src\PythonExpression.cs" />
<Compile Include="Src\PythonExpressionFinder.cs" />
<Compile Include="Src\PythonFormattingStrategy.cs" />
<Compile Include="Src\PythonFormsDesignerDisplayBinding.cs" />
<Compile Include="Src\PythonProjectBinding.cs" />
<Compile Include="Src\PythonComponentWalker.cs" />
<Compile Include="Src\PythonComponentWalkerException.cs" />
<Compile Include="Src\PythonImportCompletion.cs" />
<Compile Include="Src\PythonImportExpression.cs" />
<Compile Include="Src\PythonImportExpressionContext.cs" />
<Compile Include="Src\PythonLanguageProperties.cs" />
<Compile Include="Src\PythonImportModuleResolveResult.cs" />
<Compile Include="Src\PythonParser.cs" />
<Compile Include="Src\PythonProject.cs" />
<Compile Include="Src\PythonPropertyValueAssignment.cs" />
<Compile Include="Src\PythonResolver.cs" />
<Compile Include="Src\RunDebugPythonCommand.cs" />
<Compile Include="Src\RunPythonCommand.cs" />
<Compile Include="Src\PythonStandardModules.cs" />
<Compile Include="Src\StringTextContentProvider.cs" />
<None Include="..\..\RequiredLibraries\Chiron.exe.Config">
<Link>Chiron.exe.Config</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\RequiredLibraries\DLLs\IronPython.Wpf.dll">
<Link>DLLs\IronPython.Wpf.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\RequiredLibraries\License.Rtf">
<Link>License.Rtf</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Lib\runpy.py">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Lib\site.py">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Lib\__future__.py">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="PythonBinding.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="Resources\ApplicationSettingsPanel.xfrm" />
<EmbeddedResource Include="Resources\CompilingOptionsPanel.xfrm" />
<None Include="Templates\ConsoleProject.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\Empty.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\EmptyClass.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\EmptyForm.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\EmptyUserControl.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\FormsProject.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\LibraryProject.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="Resources\Python.xshd" />
<None Include="Templates\SilverlightApplication.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\WPFApplication.xpt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\WPFWindow.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestRunner\sdtest.py">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestRunner\sdtestrunner.py">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Lib" />
<Folder Include="DLLs" />
<Folder Include="TestRunner" />
<Folder Include="Templates" />
<Folder Include="Resources" />
<ProjectReference Include="..\..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
<Project>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</Project>
<Name>ICSharpCode.AvalonEdit</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj">
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project>
<Name>ICSharpCode.Core.Presentation</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Analysis\UnitTesting\UnitTesting.csproj">
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Scripting\Project\ICSharpCode.Scripting.csproj">
<Project>{7048AE18-EB93-4A84-82D0-DD60EB58ADBD}</Project>
<Name>ICSharpCode.Scripting</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\PythonOptionsPanel.xaml" />
</ItemGroup>
</Project>

138
src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/ApplicationSettingsPanel.xfrm

@ -1,138 +0,0 @@ @@ -1,138 +0,0 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="applicationSettingsPanel" />
<ClientSize value="{Width=456, Height=308}" />
<Controls>
<System.Windows.Forms.Button>
<Name value="mainFileBrowseButton" />
<Location value="403, 165" />
<Text value="..." />
<Anchor value="Top, Right" />
<Size value="40, 21" />
<TabIndex value="25" />
</System.Windows.Forms.Button>
<System.Windows.Forms.ComboBox>
<Name value="mainFileComboBox" />
<Size value="392, 21" />
<TabIndex value="24" />
<FormattingEnabled value="True" />
<Location value="3, 165" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.ComboBox>
<System.Windows.Forms.Label>
<Name value="mainFileLabel" />
<Location value="3, 149" />
<Text value="Main file:" />
<Anchor value="Top, Left, Right" />
<TextAlign value="BottomLeft" />
<Size value="436, 16" />
<TabIndex value="23" />
</System.Windows.Forms.Label>
<System.Windows.Forms.ComboBox>
<Name value="outputTypeComboBox" />
<Size value="159, 21" />
<TabIndex value="22" />
<FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" />
<Location value="3, 116" />
</System.Windows.Forms.ComboBox>
<System.Windows.Forms.Label>
<Name value="outputTypeLabel" />
<Location value="3, 100" />
<Text value="${res:Dialog.ProjectOptions.ApplicationSettings.OutputType}" />
<TextAlign value="BottomLeft" />
<Size value="159, 16" />
<TabIndex value="21" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="rootNamespaceTextBox" />
<TabIndex value="20" />
<Size value="440, 20" />
<Location value="3, 68" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="rootNamespaceLabel" />
<Location value="3, 52" />
<Text value="${res:Dialog.ProjectOptions.ApplicationSettings.RootNamespace}" />
<Anchor value="Top, Left, Right" />
<TextAlign value="BottomLeft" />
<Size value="440, 16" />
<TabIndex value="19" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="assemblyNameTextBox" />
<TabIndex value="18" />
<Size value="440, 20" />
<Location value="3, 24" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="assemblyNameLabel" />
<Location value="3, 8" />
<Text value="${res:Dialog.ProjectOptions.ApplicationSettings.AssemblyName}" />
<Anchor value="Top, Left, Right" />
<TextAlign value="BottomLeft" />
<Size value="440, 16" />
<TabIndex value="17" />
</System.Windows.Forms.Label>
<System.Windows.Forms.GroupBox>
<Name value="groupBox1" />
<Location value="3, 193" />
<Text value="${res:Dialog.ProjectOptions.ApplicationSettings.ProjectInformation}" />
<Anchor value="Top, Left, Right" />
<Size value="450, 112" />
<TabIndex value="16" />
<Controls>
<System.Windows.Forms.TextBox>
<Name value="outputNameTextBox" />
<TabIndex value="5" />
<ReadOnly value="True" />
<Size value="318, 20" />
<Location value="112, 80" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="outputNameLabel" />
<Location value="8, 80" />
<Text value="${res:Dialog.ProjectOptions.ApplicationSettings.OutputName}" />
<TextAlign value="MiddleRight" />
<Size value="100, 23" />
<TabIndex value="4" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="projectFileTextBox" />
<TabIndex value="3" />
<Size value="318, 20" />
<Location value="112, 56" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="projectFileLabel" />
<Location value="8, 52" />
<Text value="${res:Dialog.ProjectOptions.ApplicationSettings.ProjectFile}" />
<TextAlign value="MiddleRight" />
<Size value="100, 23" />
<TabIndex value="2" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="projectFolderTextBox" />
<TabIndex value="1" />
<ReadOnly value="True" />
<Size value="318, 20" />
<Location value="112, 28" />
<Anchor value="Top, Left, Right" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Label>
<Name value="projectFolderLabel" />
<Location value="8, 24" />
<Text value="${res:Dialog.ProjectOptions.ApplicationSettings.ProjectFolder}" />
<TextAlign value="MiddleRight" />
<Size value="100, 23" />
<TabIndex value="0" />
</System.Windows.Forms.Label>
</Controls>
</System.Windows.Forms.GroupBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>

71
src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/CompilingOptionsPanel.xfrm

@ -1,71 +0,0 @@ @@ -1,71 +0,0 @@
<Components version="1.0">
<System.Windows.Forms.UserControl>
<Name value="compilingOptionsPanel" />
<ClientSize value="{Width=510, Height=358}" />
<Controls>
<System.Windows.Forms.GroupBox>
<Name value="outputGroupBox" />
<Location value="3, -2" />
<UseCompatibleTextRendering value="True" />
<Text value="${res:Dialog.ProjectOptions.Build.Output}" />
<Size value="504, 362" />
<Anchor value="Top, Left, Right" />
<TabIndex value="2" />
<Controls>
<System.Windows.Forms.ComboBox>
<Name value="targetCpuComboBox" />
<TabIndex value="14" />
<Location value="12, 106" />
<Size value="180, 21" />
<FormattingEnabled value="True" />
<DropDownStyle value="DropDownList" />
</System.Windows.Forms.ComboBox>
<System.Windows.Forms.Label>
<Name value="targetCpuLabel" />
<Location value="12, 87" />
<UseCompatibleTextRendering value="True" />
<Text value="${res:Dialog.ProjectOptions.Build.TargetCPU}" />
<Size value="180, 16" />
<TextAlign value="MiddleLeft" />
<TabIndex value="13" />
</System.Windows.Forms.Label>
<System.Windows.Forms.CheckBox>
<Name value="debugInfoCheckBox" />
<CheckAlign value="MiddleRight" />
<Location value="12, 63" />
<Text value="${res:Dialog.ProjectOptions.Build.DebugInfo}" />
<TabIndex value="12" />
<Size value="180, 21" />
<UseCompatibleTextRendering value="True" />
</System.Windows.Forms.CheckBox>
<System.Windows.Forms.Label>
<Name value="outputPathLabel" />
<Location value="12, 17" />
<UseCompatibleTextRendering value="True" />
<Text value="${res:Dialog.ProjectOptions.Build.OutputPath}" />
<Size value="492, 16" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" />
<TabIndex value="3" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="outputPathTextBox" />
<TabIndex value="4" />
<Location value="12, 37" />
<Anchor value="Top, Left, Right" />
<Size value="448, 20" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Button>
<Name value="outputPathBrowseButton" />
<Location value="464, 37" />
<UseCompatibleTextRendering value="True" />
<Text value="..." />
<Size value="40, 21" />
<Anchor value="Top, Right" />
<TabIndex value="5" />
</System.Windows.Forms.Button>
</Controls>
</System.Windows.Forms.GroupBox>
</Controls>
</System.Windows.Forms.UserControl>
</Components>

135
src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/Python.xshd

@ -1,135 +0,0 @@ @@ -1,135 +0,0 @@
<SyntaxDefinition name="Python" extensions=".py" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Digits" foreground="DarkBlue" exampleText="0123456789" />
<Color name="DocComment" foreground="Green" exampleText='""" comment' />
<Color name="SingleQuoteDocComment" foreground="Green" exampleText="''' comment" />
<Color name="LineComment" foreground="Green" exampleText="# comment" />
<Color name="String" foreground="Blue" exampleText='name = "Joe"' />
<Color name="Char" foreground="Magenta" exampleText="char linefeed = '\n'" />
<Color name="Punctuation" exampleText="a(b.c);" />
<Color name="MethodCall" fontWeight="bold" foreground="MidnightBlue" exampleText="method(" />
<Color name="BuiltInStatements" fontWeight="bold" foreground="MidnightBlue" exampleText="print 'hello'" />
<Color name="ClassStatement" foreground="Blue" fontWeight="bold" exampleText="class Foo: pass" />
<Color name="ExceptionHandlingStatements" fontWeight="bold" foreground="Teal" exampleText="raise 'error'" />
<Color name="FunctionDefinition" fontWeight="bold" foreground="Blue" exampleText="def MyFunction" />
<Color name="Imports" fontWeight="bold" foreground="Green" exampleText="import System.Xml" />
<Color name="IterationStatements" fontWeight="bold" foreground="Blue" exampleText="for num in range(10,20):" />
<Color name="JumpStatements" foreground="Navy" exampleText="return val" />
<Color name="OperatorStatements" fontWeight="bold" foreground="DarkCyan" exampleText="not(a &amp;&amp; b)" />
<Color name="PassStatement" foreground="Gray" exampleText="pass" />
<Color name="NullStatement" foreground="Gray" exampleText="return None" />
<Color name="SelectionStatements" fontWeight="bold" foreground="Blue" exampleText="if (a):" />
<Color name="WithStatement" foreground="DarkViolet" exampleText='with open("a.txt") as file:' />
<Property name="LineComment" value="#"/>
<RuleSet ignoreCase="false">
<Span color="DocComment" multiline="true">
<Begin>"""</Begin>
<End>"""</End>
</Span>
<Span color="SingleQuoteDocComment" multiline="true">
<Begin>'''</Begin>
<End>'''</End>
</Span>
<Span color="LineComment">
<Begin>\#</Begin>
</Span>
<Span color="String">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<!-- span for escape sequences -->
<Span begin="\\" end="."/>
</RuleSet>
</Span>
<Span color="Char">
<Begin>'</Begin>
<End>'</End>
<RuleSet>
<!-- span for escape sequences -->
<Span begin="\\" end="."/>
</RuleSet>
</Span>
<Keywords color="BuiltInStatements">
<Word>assert</Word>
<Word>del</Word>
<Word>exec</Word>
<Word>global</Word>
<Word>lambda</Word>
<Word>print</Word>
</Keywords>
<Keywords color="ClassStatement">
<Word>class</Word>
</Keywords>
<Keywords color="ExceptionHandlingStatements">
<Word>except</Word>
<Word>finally</Word>
<Word>raise</Word>
<Word>try</Word>
</Keywords>
<Keywords color="FunctionDefinition">
<Word>def</Word>
</Keywords>
<Keywords color="Imports">
<Word>import</Word>
<Word>from</Word>
</Keywords>
<Keywords color="IterationStatements">
<Word>for</Word>
<Word>in</Word>
<Word>while</Word>
</Keywords>
<Keywords color="JumpStatements">
<Word>break</Word>
<Word>continue</Word>
<Word>yield</Word>
<Word>return</Word>
</Keywords>
<Keywords color="OperatorStatements">
<Word>and</Word>
<Word>as</Word>
<Word>is</Word>
<Word>not</Word>
<Word>or</Word>
</Keywords>
<Keywords color="PassStatement">
<Word>pass</Word>
</Keywords>
<Keywords color="SelectionStatements">
<Word>elif</Word>
<Word>else</Word>
<Word>if</Word>
</Keywords>
<Keywords color="WithStatement">
<Word>with</Word>
</Keywords>
<Keywords color="NullStatement">
<Word>None</Word>
</Keywords>
<Rule color="MethodCall">\b[\d\w_]+(?=(\s*\())</Rule>
<Rule color="Digits">\b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?</Rule>
<Rule color="Punctuation">
[?,.;()\[\]{}+\-/%*&lt;&gt;^+~!|&amp;]+
</Rule>
</RuleSet>
</SyntaxDefinition>

100
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs

@ -1,100 +0,0 @@ @@ -1,100 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Holds the options for the PythonBinding AddIn
/// </summary>
public class PythonAddInOptions
{
/// <summary>
/// The name of the options as read from the PropertyService.
/// </summary>
public static readonly string AddInOptionsName = "PythonBinding.Options";
/// <summary>
/// The default python console filename.
/// </summary>
public static readonly string DefaultPythonFileName = "ipy.exe";
#region Property names
public static readonly string PythonFileNameProperty = "PythonFileName";
public static readonly string PythonLibraryPathProperty = "PythonLibraryPath";
#endregion
Properties properties;
public PythonAddInOptions()
: this(PropertyService.Get(AddInOptionsName, new Properties()))
{
}
/// <summary>
/// Creates the addin options class which will use
/// the options from the properties class specified.
/// </summary>
public PythonAddInOptions(Properties properties)
{
this.properties = properties;
}
public string PythonLibraryPath {
get { return properties.Get<string>(PythonLibraryPathProperty, String.Empty); }
set { properties.Set(PythonLibraryPathProperty, value); }
}
public bool HasPythonLibraryPath {
get { return !String.IsNullOrEmpty(PythonLibraryPath); }
}
/// <summary>
/// Gets or sets the python console filename.
/// </summary>
public string PythonFileName {
get { return properties.Get<string>(PythonFileNameProperty, GetDefaultPythonFileName()); }
set {
if (String.IsNullOrEmpty(value)) {
properties.Set(PythonFileNameProperty, GetDefaultPythonFileName());
} else {
properties.Set(PythonFileNameProperty, value);
}
}
}
/// <summary>
/// Returns the full path to ipyw.exe which is installed in the
/// Python addin folder.
/// </summary>
string GetDefaultPythonFileName()
{
string path = GetPythonBindingAddInPath();
return Path.Combine(path, DefaultPythonFileName);
}
string GetPythonBindingAddInPath()
{
return StringParser.Parse("${addinpath:ICSharpCode.PythonBinding}");
}
}
}

154
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ApplicationSettingsPanel.cs

@ -1,154 +0,0 @@ @@ -1,154 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Python project's application settings panel.
/// </summary>
public class ApplicationSettingsPanel : AbstractXmlFormsProjectOptionPanel
{
const string AssemblyTextBoxName = "assemblyNameTextBox";
const string RootNamespaceTextBoxName = "rootNamespaceTextBox";
const string OutputTypeComboBoxName = "outputTypeComboBox";
const string MainFileComboBoxName = "mainFileComboBox";
public override void LoadPanelContents()
{
SetupFromManifestResource("ICSharpCode.PythonBinding.Resources.ApplicationSettingsPanel.xfrm");
InitializeHelper();
ConfigurationGuiBinding b = BindString(AssemblyTextBoxName, "AssemblyName", TextBoxEditMode.EditEvaluatedProperty);
CreateLocationButton(b, AssemblyTextBoxName);
AssemblyNameTextBox.TextChanged += AssemblyNameTextBoxTextChanged;
b = BindString(RootNamespaceTextBoxName, "RootNamespace", TextBoxEditMode.EditEvaluatedProperty);
CreateLocationButton(b, RootNamespaceTextBoxName);
b = BindEnum<OutputType>(OutputTypeComboBoxName, "OutputType");
CreateLocationButton(b, OutputTypeComboBoxName);
OutputTypeComboBox.SelectedIndexChanged += OutputTypeComboBoxSelectedIndexChanged;
b = BindString(MainFileComboBoxName, "MainFile", TextBoxEditMode.EditEvaluatedProperty);
CreateLocationButton(b, MainFileComboBoxName);
ConnectBrowseButtonControl("mainFileBrowseButton", "mainFileComboBox",
"${res:SharpDevelop.FileFilter.AllFiles}|*.*",
TextBoxEditMode.EditEvaluatedProperty);
Get<TextBox>("projectFolder").Text = project.Directory;
Get<TextBox>("projectFile").Text = Path.GetFileName(project.FileName);
Get<TextBox>("projectFile").ReadOnly = true;
RefreshOutputNameTextBox();
AddConfigurationSelector(this);
}
/// <summary>
/// Calls SetupFromXmlStream after creating a stream from the current
/// assembly using the specified manifest resource name.
/// </summary>
/// <param name="resource">The manifest resource name used
/// to create the stream.</param>
protected virtual void SetupFromManifestResource(string resource)
{
SetupFromXmlStream(typeof(ApplicationSettingsPanel).Assembly.GetManifestResourceStream(resource));
}
/// <summary>
/// Binds the string property to a text box control.
/// </summary>
protected virtual ConfigurationGuiBinding BindString(string control, string property, TextBoxEditMode textBoxEditMode)
{
return helper.BindString(control, property, textBoxEditMode);
}
/// <summary>
/// Binds an enum property to a control.
/// </summary>
protected virtual ConfigurationGuiBinding BindEnum<T>(string control, string property) where T : struct
{
return helper.BindEnum<T>(control, property);
}
/// <summary>
/// Associates a location button with a control.
/// </summary>
protected virtual ChooseStorageLocationButton CreateLocationButton(ConfigurationGuiBinding binding, string controlName)
{
return binding.CreateLocationButton(controlName);
}
/// <summary>
/// Adds a configuration selector to the specified control.
/// </summary>
protected virtual void AddConfigurationSelector(Control control)
{
helper.AddConfigurationSelector(control);
}
/// <summary>
/// Connects the browse button control to the target control.
/// </summary>
protected virtual void ConnectBrowseButtonControl(string browseButton, string target, string fileFilter, TextBoxEditMode textBoxEditMode)
{
ConnectBrowseButton(browseButton, target, fileFilter, textBoxEditMode);
}
/// <summary>
/// Refreshes the output name text box after the assembly name
/// has changed.
/// </summary>
protected void AssemblyNameTextBoxTextChanged(object source, EventArgs e)
{
RefreshOutputNameTextBox();
}
/// <summary>
/// Refreshes the output name text box after the output type has changed.
/// </summary>
protected void OutputTypeComboBoxSelectedIndexChanged(object source, EventArgs e)
{
RefreshOutputNameTextBox();
}
/// <summary>
/// Updates the output name text box based on the assembly name and
/// output type.
/// </summary>
void RefreshOutputNameTextBox()
{
string assemblyName = AssemblyNameTextBox.Text;
string extension = CompilableProject.GetExtension((OutputType)OutputTypeComboBox.SelectedIndex);
Get<TextBox>("outputName").Text = String.Concat(assemblyName, extension);
}
TextBox AssemblyNameTextBox {
get { return Get<TextBox>("assemblyName"); }
}
ComboBox OutputTypeComboBox {
get { return Get<ComboBox>("outputType"); }
}
}
}

108
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CompilingOptionsPanel.cs

@ -1,108 +0,0 @@ @@ -1,108 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Python project's compiling options panel.
/// </summary>
public class CompilingOptionsPanel : AbstractBuildOptions
{
public override void LoadPanelContents()
{
SetupFromManifestResource("ICSharpCode.PythonBinding.Resources.CompilingOptionsPanel.xfrm");
InitializeHelper();
ConfigurationGuiBinding b = BindString("outputPathTextBox", "OutputPath", TextBoxEditMode.EditRawProperty);
CreateLocationButton(b, "outputPathTextBox");
ConnectBrowseFolderButtonControl("outputPathBrowseButton", "outputPathTextBox", "${res:Dialog.Options.PrjOptions.Configuration.FolderBrowserDescription}", TextBoxEditMode.EditRawProperty);
b = BindBoolean("debugInfoCheckBox", "DebugInfo", false);
CreateLocationButton(b, "debugInfoCheckBox");
b = CreatePlatformTargetComboBox();
CreateLocationButton(b, "targetCpuComboBox");
AddConfigurationSelector(this);
}
/// <summary>
/// Calls SetupFromXmlStream after creating a stream from the current
/// assembly using the specified manifest resource name.
/// </summary>
/// <param name="resource">The manifest resource name used
/// to create the stream.</param>
protected virtual void SetupFromManifestResource(string resource)
{
SetupFromXmlStream(typeof(CompilingOptionsPanel).Assembly.GetManifestResourceStream(resource));
}
/// <summary>
/// Binds the string property to a text box control.
/// </summary>
protected virtual ConfigurationGuiBinding BindString(string control, string property, TextBoxEditMode textBoxEditMode)
{
return helper.BindString(control, property, textBoxEditMode);
}
/// <summary>
/// Binds the boolean property to a check box control.
/// </summary>
protected virtual ConfigurationGuiBinding BindBoolean(string control, string property, bool defaultValue)
{
return helper.BindBoolean(control, property, defaultValue);
}
/// <summary>
/// Associates a location button with a control.
/// </summary>
protected virtual ChooseStorageLocationButton CreateLocationButton(ConfigurationGuiBinding binding, string controlName)
{
return binding.CreateLocationButton(controlName);
}
/// <summary>
/// Connects the browse folder button control to the target control.
/// </summary>
protected virtual void ConnectBrowseFolderButtonControl(string browseButton, string target, string description, TextBoxEditMode textBoxEditMode)
{
ConnectBrowseFolder(browseButton, target, description, textBoxEditMode);
}
/// <summary>
/// Adds a configuration selector to the specified control.
/// </summary>
protected virtual void AddConfigurationSelector(Control control)
{
helper.AddConfigurationSelector(control);
}
/// <summary>
/// Creates the platform target combo box.
/// </summary>
protected virtual ConfigurationGuiBinding CreatePlatformTargetComboBox()
{
return base.CreatePlatformTarget();
}
}
}

68
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConstructorInfo.cs

@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.Ast;
namespace ICSharpCode.PythonBinding
{
public class PythonConstructorInfo
{
ConstructorDeclaration constructor;
List<FieldDeclaration> fields = new List<FieldDeclaration>();
PythonConstructorInfo(ConstructorDeclaration constructor, List<FieldDeclaration> fields)
{
this.constructor = constructor;
this.fields = fields;
}
/// <summary>
/// Gets the constructor information from a type declaration. Returns null if there is no
/// constructor defined or if there are no fields defined.
/// </summary>
public static PythonConstructorInfo GetConstructorInfo(TypeDeclaration type)
{
List<FieldDeclaration> fields = new List<FieldDeclaration>();
ConstructorDeclaration constructor = null;
foreach (INode node in type.Children) {
ConstructorDeclaration currentConstructor = node as ConstructorDeclaration;
FieldDeclaration field = node as FieldDeclaration;
if (currentConstructor != null) {
constructor = currentConstructor;
} else if (field != null) {
fields.Add(field);
}
}
if ((fields.Count > 0) || (constructor != null)) {
return new PythonConstructorInfo(constructor, fields);
}
return null;
}
public ConstructorDeclaration Constructor {
get { return constructor; }
}
public List<FieldDeclaration> Fields {
get { return fields; }
}
}
}

170
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConvertProjectToPythonProjectCommand.cs

@ -1,170 +0,0 @@ @@ -1,170 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Converter;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Converts a C# or VB.NET project to Python.
/// </summary>
public class ConvertProjectToPythonProjectCommand : LanguageConverter
{
public override string TargetLanguageName {
get { return PythonProjectBinding.LanguageName; }
}
/// <summary>
/// Creates an PythonProject.
/// </summary>
protected override IProject CreateProject(string targetProjectDirectory, IProject sourceProject)
{
// Add IronPython reference.
PythonProject targetProject = (PythonProject)base.CreateProject(targetProjectDirectory, sourceProject);
IProjectItemListProvider targetProjectItems = targetProject as IProjectItemListProvider;
targetProjectItems.AddProjectItem(CreateIronPythonReference(targetProject));
return targetProject;
}
/// <summary>
/// Converts C# and VB.NET files to Python and saves the files.
/// </summary>
protected override void ConvertFile(FileProjectItem sourceItem, FileProjectItem targetItem)
{
NRefactoryToPythonConverter converter = NRefactoryToPythonConverter.Create(sourceItem.Include);
if (converter != null) {
targetItem.Include = ChangeFileExtensionToPythonFileExtension(sourceItem.Include);
string code = GetParseableFileContent(sourceItem.FileName);
string pythonCode = converter.Convert(code);
PythonProject pythonTargetProject = (PythonProject)targetItem.Project;
if ((converter.EntryPointMethods.Count > 0) && !pythonTargetProject.HasMainFile) {
pythonTargetProject.AddMainFile(targetItem.Include);
// Add code to call main method at the end of the file.
pythonCode += "\r\n\r\n" + converter.GenerateMainMethodCall(converter.EntryPointMethods[0]);
}
SaveFile(targetItem.FileName, pythonCode, GetDefaultFileEncoding());
} else {
LanguageConverterConvertFile(sourceItem, targetItem);
}
}
/// <summary>
/// Adds the MainFile property since adding it in the CreateProject method would mean
/// it gets removed via the base class CopyProperties method.
/// </summary>
protected override void CopyProperties(IProject sourceProject, IProject targetProject)
{
base.CopyProperties(sourceProject, targetProject);
AddMainFile(sourceProject, (PythonProject)targetProject);
}
/// <summary>
/// Calls the LanguageConverter class method ConvertFile which copies the source file to the target
/// file without any modifications.
/// </summary>
protected virtual void LanguageConverterConvertFile(FileProjectItem sourceItem, FileProjectItem targetItem)
{
base.ConvertFile(sourceItem, targetItem);
}
/// <summary>
/// Writes the specified file to disk.
/// </summary>
protected virtual void SaveFile(string fileName, string content, Encoding encoding)
{
File.WriteAllText(fileName, content, encoding);
}
protected virtual Encoding GetDefaultFileEncoding()
{
return FileService.DefaultFileEncoding.GetEncoding();
}
/// <summary>
/// Gets the content of the file from the parser service.
/// </summary>
protected virtual string GetParseableFileContent(string fileName)
{
return ParserService.GetParseableFileContent(fileName).Text;
}
/// <summary>
/// Gets the project content for the specified project.
/// </summary>
protected virtual IProjectContent GetProjectContent(IProject project)
{
return ParserService.GetProjectContent(project);
}
ReferenceProjectItem CreateIronPythonReference(IProject project)
{
ReferenceProjectItem reference = new ReferenceProjectItem(project, "IronPython");
reference.SetMetadata("HintPath", @"$(PythonBinPath)\IronPython.dll");
return reference;
}
/// <summary>
/// Adds a MainFile if the source project has a StartupObject.
/// </summary>
void AddMainFile(IProject sourceProject, PythonProject targetProject)
{
string startupObject = GetStartupObject(sourceProject);
if (startupObject != null) {
IClass c = FindClass(sourceProject, startupObject);
if (c != null) {
string fileName = FileUtility.GetRelativePath(sourceProject.Directory, c.CompilationUnit.FileName);
targetProject.AddMainFile(ChangeFileExtensionToPythonFileExtension(fileName));
}
}
}
string GetStartupObject(IProject project)
{
MSBuildBasedProject msbuildProject = project as MSBuildBasedProject;
if (msbuildProject != null) {
return msbuildProject.GetProperty(null, null, "StartupObject");
}
return null;
}
IClass FindClass(IProject project, string name)
{
return GetProjectContent(project).GetClass(name, 0);
}
/// <summary>
/// Changes the extension to ".py"
/// </summary>
static string ChangeFileExtensionToPythonFileExtension(string fileName)
{
return Path.ChangeExtension(fileName, ".py");
}
}
}

66
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ConvertToPythonMenuCommand.cs

@ -1,66 +0,0 @@ @@ -1,66 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Core;
using ICSharpCode.Scripting;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Converts VB.NET or C# code to Python.
/// </summary>
public class ConvertToPythonMenuCommand : AbstractMenuCommand
{
ScriptingTextEditorViewContent view;
public override void Run()
{
Run(new PythonWorkbench());
}
protected void Run(IScriptingWorkbench workbench)
{
view = new ScriptingTextEditorViewContent(workbench);
string code = GeneratePythonCode();
ShowPythonCodeInNewWindow(code);
}
string GeneratePythonCode()
{
NRefactoryToPythonConverter converter = NRefactoryToPythonConverter.Create(view.PrimaryFileName);
converter.IndentString = view.TextEditorOptions.IndentationString;
return converter.Convert(view.EditableView.Text);
}
void ShowPythonCodeInNewWindow(string code)
{
NewFile("Generated.py", "Python", code);
}
/// <summary>
/// Creates a new file using the FileService by default.
/// </summary>
protected virtual void NewFile(string defaultName, string language, string content)
{
FileService.NewFile(defaultName, content);
}
}
}

28
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonResolver.cs

@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PythonBinding
{
public interface IPythonResolver
{
ResolveResult Resolve(PythonResolverContext resolverContext);
}
}

90
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/MemberName.cs

@ -1,90 +0,0 @@ @@ -1,90 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Split up an expression into a member name and a type name.
/// </summary>
/// <example>
/// "myObject.Field" => "myObject" + "Field"
/// "System.Console.WriteLine" => "System.Console" + "Console.WriteLine"
/// </example>
public class MemberName
{
string name = String.Empty;
string type = String.Empty;
public MemberName(string expression)
{
Parse(expression);
}
public MemberName(string typeName, string memberName)
{
this.type = typeName;
this.name = memberName;
}
void Parse(string expression)
{
if (!String.IsNullOrEmpty(expression)) {
int index = expression.LastIndexOf('.');
if (index > 0) {
type = expression.Substring(0, index);
name = expression.Substring(index + 1);
} else {
type = expression;
}
}
}
public string Name {
get { return name; }
}
public bool HasName {
get { return !String.IsNullOrEmpty(name); }
}
public string Type {
get { return type; }
}
public override string ToString()
{
return String.Format("Type: {0}, Member: {1}", type, name);
}
public override bool Equals(object obj)
{
MemberName rhs = obj as MemberName;
if (rhs != null) {
return (name == rhs.name) && (type == rhs.type);
}
return false;
}
public override int GetHashCode()
{
return name.GetHashCode() ^ type.GetHashCode();
}
}
}

2074
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs

File diff suppressed because it is too large Load Diff

159
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs

@ -1,159 +0,0 @@ @@ -1,159 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using Microsoft.Scripting;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.SharpDevelop.Dom;
using IronPython.Compiler;
using IronPython.Compiler.Ast;
using IronPython.Runtime;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Walks the python parse tree.
/// </summary>
public class PythonAstWalker : PythonWalker
{
PythonCompilationUnit compilationUnit;
IClass currentClass;
PythonModule module;
/// <summary>
/// All classes in a file take the namespace of the filename.
/// </summary>
public PythonAstWalker(IProjectContent projectContent, string fileName)
{
compilationUnit = new PythonCompilationUnit(projectContent, fileName);
}
/// <summary>
/// Returns the compilation unit created after the Walk method
/// has been called.
/// </summary>
public ICompilationUnit CompilationUnit {
get { return compilationUnit; }
}
/// <summary>
/// Walks the python statement returned from the parser.
/// </summary>
public void Walk(Statement statement)
{
statement.Walk(this);
}
public override bool Walk(ClassDefinition classDefinition)
{
if (classDefinition.Parent != null) {
PythonClass c = new PythonClass(compilationUnit, classDefinition);
WalkClassBody(c, classDefinition.Body);
}
return false;
}
void WalkClassBody(IClass c, Statement classBody)
{
currentClass = c;
classBody.Walk(this);
currentClass = null;
}
public override bool Walk(FunctionDefinition functionDefinition)
{
if (functionDefinition.Body == null) {
return false;
}
IClass c = GetClassBeingWalked();
PythonMethodDefinition methodDefinition = new PythonMethodDefinition(functionDefinition);
PythonMethod method = methodDefinition.CreateMethod(c);
if (method is PythonConstructor) {
FindFields(c, functionDefinition);
}
return false;
}
/// <summary>
/// If the current class is null then create a module so a method outside of a class can be
/// parsed.
/// </summary>
IClass GetClassBeingWalked()
{
if (currentClass == null) {
// Walking a method outside a class.
CreateModule();
return module;
}
return currentClass;
}
/// <summary>
/// Creates the module which will act as a class so it can hold any methods defined in the module.
/// </summary>
void CreateModule()
{
if (module == null) {
module = new PythonModule(compilationUnit);
}
}
void FindFields(IClass c, FunctionDefinition functionDefinition)
{
PythonClassFields fields = new PythonClassFields(functionDefinition);
fields.AddFields(c);
}
/// <summary>
/// Walks an import statement and adds it to the compilation unit's
/// Usings.
/// </summary>
public override bool Walk(ImportStatement node)
{
PythonImport import = new PythonImport(compilationUnit.ProjectContent, node);
compilationUnit.UsingScope.Usings.Add(import);
return false;
}
public override bool Walk(FromImportStatement node)
{
PythonFromImport import = new PythonFromImport(compilationUnit.ProjectContent, node);
compilationUnit.UsingScope.Usings.Add(import);
return false;
}
public override bool Walk(AssignmentStatement node)
{
if (currentClass != null) {
FindProperty(node);
return false;
}
return base.Walk(node);
}
void FindProperty(AssignmentStatement node)
{
PythonPropertyAssignment propertyAssignment = new PythonPropertyAssignment(node);
propertyAssignment.CreateProperty(currentClass);
}
}
}

37
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonBuiltInModuleMemberName.cs

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.PythonBinding
{
public class PythonBuiltInModuleMemberName : MemberName
{
public const string PythonBuiltInModuleName = "__builtin__";
public PythonBuiltInModuleMemberName(string memberName)
: base(PythonBuiltInModuleName, memberName)
{
}
public static bool IsBuiltInModule(string name)
{
return name == PythonBuiltInModuleName;
}
}
}

106
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonClass.cs

@ -1,106 +0,0 @@ @@ -1,106 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom;
using IronPython.Compiler.Ast;
namespace ICSharpCode.PythonBinding
{
public class PythonClass : DefaultClass
{
public PythonClass(ICompilationUnit compilationUnit, ClassDefinition classDefinition)
: base(compilationUnit, String.Empty)
{
GetFullyQualifiedName(classDefinition);
GetClassRegions(classDefinition);
AddBaseTypes(classDefinition.Bases);
compilationUnit.Classes.Add(this);
}
/// <summary>
/// Adds the namespace to the class name taken from the class definition.
/// </summary>
void GetFullyQualifiedName(ClassDefinition classDefinition)
{
string ns = CompilationUnit.UsingScope.NamespaceName;
FullyQualifiedName = String.Format("{0}.{1}", ns, classDefinition.Name);
}
void GetClassRegions(ClassDefinition classDefinition)
{
GetRegion(classDefinition);
BodyRegion = PythonMethodOrClassBodyRegion.GetBodyRegion(classDefinition);
}
/// <summary>
/// Gets the region of the scope statement (ClassDefinition).
/// </summary>
/// <remarks>
/// A class region includes the body.
/// </remarks>
void GetRegion(ScopeStatement statement)
{
Region = new DomRegion(statement.Start.Line, statement.Start.Column, statement.End.Line, statement.End.Column);
}
/// <summary>
/// Looks for any base types for the class defined in the
/// list of expressions and adds them to the class.
/// </summary>
void AddBaseTypes(IList<Expression> baseTypes)
{
foreach (Expression baseTypeExpression in baseTypes) {
AddBaseType(baseTypeExpression);
}
}
void AddBaseType(Expression baseTypeExpression)
{
NameExpression nameExpression = baseTypeExpression as NameExpression;
MemberExpression memberExpression = baseTypeExpression as MemberExpression;
if (nameExpression != null) {
AddBaseType(nameExpression.Name);
} else if (memberExpression != null) {
AddBaseType(memberExpression);
}
}
/// <summary>
/// Adds the named base type to the class.
/// </summary>
void AddBaseType(string name)
{
IReturnType returnType = CreateSearchClassReturnType(name);
BaseTypes.Add(returnType);
}
void AddBaseType(MemberExpression memberExpression)
{
string name = PythonControlFieldExpression.GetMemberName(memberExpression);
AddBaseType(name);
}
SearchClassReturnType CreateSearchClassReturnType(string name)
{
return new SearchClassReturnType(ProjectContent, this, 0, 0, name, 0);
}
}
}

79
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonClassFields.cs

@ -1,79 +0,0 @@ @@ -1,79 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Dom;
using IronPython.Compiler.Ast;
namespace ICSharpCode.PythonBinding
{
public class PythonClassFields : PythonWalker
{
FunctionDefinition functionDefinition;
IClass declaringType;
List<string> fieldNamesAdded;
public PythonClassFields(FunctionDefinition functionDefinition)
{
this.functionDefinition = functionDefinition;
}
public void AddFields(IClass declaringType)
{
this.declaringType = declaringType;
fieldNamesAdded = new List<string>();
functionDefinition.Body.Walk(this);
}
public override bool Walk(AssignmentStatement node)
{
string fieldName = GetFieldName(node);
AddFieldToDeclaringType(fieldName);
return false;
}
string GetFieldName(AssignmentStatement node)
{
string[] memberNames = PythonControlFieldExpression.GetMemberNames(node.Left[0] as MemberExpression);
return GetFieldName(memberNames);
}
string GetFieldName(string[] memberNames)
{
if (memberNames.Length > 1) {
if (PythonSelfResolver.IsSelfExpression(memberNames[0])) {
return memberNames[1];
}
}
return null;
}
void AddFieldToDeclaringType(string fieldName)
{
if (fieldName != null) {
if (!fieldNamesAdded.Contains(fieldName)) {
DefaultField field = new DefaultField(declaringType, fieldName);
declaringType.Fields.Add(field);
fieldNamesAdded.Add(fieldName);
}
}
}
}
}

119
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonClassResolver.cs

@ -1,119 +0,0 @@ @@ -1,119 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PythonBinding
{
public class PythonClassResolver : IPythonResolver
{
PythonResolverContext resolverContext;
public ResolveResult Resolve(PythonResolverContext resolverContext)
{
IClass matchingClass = GetClass(resolverContext);
if (matchingClass != null) {
return CreateTypeResolveResult(matchingClass);
}
return null;
}
public IClass GetClass(PythonResolverContext resolverContext)
{
string name = resolverContext.Expression;
return GetClass(resolverContext, name);
}
public IClass GetClass(PythonResolverContext resolverContext, string name)
{
this.resolverContext = resolverContext;
if (String.IsNullOrEmpty(name)) {
return null;
}
IClass matchedClass = resolverContext.GetClass(name);
if (matchedClass != null) {
return matchedClass;
}
matchedClass = GetClassFromImportedNames(name);
if (matchedClass != null) {
return matchedClass;
}
matchedClass = GetClassFromNamespaceThatImportsEverything(name);
if (matchedClass != null) {
return matchedClass;
}
return GetClassFromDottedImport(name);
}
TypeResolveResult CreateTypeResolveResult(IClass c)
{
return new TypeResolveResult(null, null, c);
}
IClass GetClassFromImportedNames(string name)
{
string moduleName = resolverContext.GetModuleForImportedName(name);
if (moduleName != null) {
name = resolverContext.UnaliasImportedName(name);
string fullyQualifiedName = GetQualifiedClassName(moduleName, name);
return resolverContext.GetClass(fullyQualifiedName);
}
return null;
}
string GetQualifiedClassName(string namespacePrefix, string className)
{
return namespacePrefix + "." + className;
}
IClass GetClassFromNamespaceThatImportsEverything(string name)
{
foreach (string moduleName in resolverContext.GetModulesThatImportEverything()) {
string fullyQualifiedName = GetQualifiedClassName(moduleName, name);
IClass matchedClass = resolverContext.GetClass(fullyQualifiedName);
if (matchedClass != null) {
return matchedClass;
}
}
return null;
}
IClass GetClassFromDottedImport(string name)
{
string moduleName = resolverContext.FindStartOfDottedModuleNameInImports(name);
if (moduleName != null) {
string fullyQualifiedName = UnaliasClassName(moduleName, name);
return resolverContext.GetClass(fullyQualifiedName);
}
return null;
}
string UnaliasClassName(string moduleName, string fullClassName)
{
string actualModuleName = resolverContext.UnaliasImportedModuleName(moduleName);
string lastPartOfClassName = fullClassName.Substring(moduleName.Length + 1);
return GetQualifiedClassName(actualModuleName, lastPartOfClassName);
}
}
}

56
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeBuilder.cs

@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Text;
using ICSharpCode.Scripting;
namespace ICSharpCode.PythonBinding
{
public class PythonCodeBuilder : ScriptingCodeBuilder
{
bool insertedCreateComponentsContainer;
public PythonCodeBuilder()
{
}
public PythonCodeBuilder(int initialIndent)
: base(initialIndent)
{
}
/// <summary>
/// Inserts the following line of code before all the other lines of code:
///
/// "self._components = System.ComponentModel.Container()"
///
/// This line will only be inserted once. Multiple calls to this method will only result in one
/// line of code being inserted.
/// </summary>
public void InsertCreateComponentsContainer()
{
if (!insertedCreateComponentsContainer) {
string text = String.Format("self._components = {0}()", typeof(Container).FullName);
InsertIndentedLine(text);
insertedCreateComponentsContainer = true;
}
}
}
}

69
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeCompletionBinding.cs

@ -1,69 +0,0 @@ @@ -1,69 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using System.Collections.Generic;
namespace ICSharpCode.PythonBinding
{
public class PythonCodeCompletionBinding : DefaultCodeCompletionBinding
{
public PythonCodeCompletionBinding()
{
base.insightHandler = new PythonInsightWindowHandler();
}
/// <summary>
/// Shows the code completion window if the keyword is handled.
/// </summary>
/// <param name="word">The keyword string.</param>
/// <returns>true if the keyword is handled; otherwise false.</returns>
public override bool HandleKeyword(ITextEditor editor, string word)
{
if (word != null) {
switch (word.ToLowerInvariant()) {
case "import":
case "from":
return HandleImportKeyword(editor);
}
}
return false;
}
bool HandleImportKeyword(ITextEditor editor)
{
AbstractCompletionItemProvider provider = CreateKeywordCompletionItemProvider();
ShowCodeCompletionWindow(provider, editor);
return true;
}
protected virtual AbstractCompletionItemProvider CreateKeywordCompletionItemProvider()
{
return new PythonCodeCompletionItemProvider();
}
protected virtual void ShowCodeCompletionWindow(AbstractCompletionItemProvider completionItemProvider, ITextEditor editor)
{
completionItemProvider.ShowCompletion(editor);
}
}
}

31
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeCompletionItemProvider.cs

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.PythonBinding
{
public class PythonCodeCompletionItemProvider : CodeCompletionItemProvider
{
protected override DefaultCompletionItemList CreateCompletionItemList()
{
return new PythonCompletionItemList();
}
}
}

253
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDeserializer.cs

@ -1,253 +0,0 @@ @@ -1,253 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Drawing;
using System.Reflection;
using ICSharpCode.Scripting;
using IronPython.Compiler;
using IronPython.Compiler.Ast;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Creates objects from python code.
/// </summary>
public class PythonCodeDeserializer
{
IComponentCreator componentCreator;
public PythonCodeDeserializer(IComponentCreator componentCreator)
{
this.componentCreator = componentCreator;
}
/// <summary>
/// Gets the arguments passed to the call expression.
/// </summary>
public List<object> GetArguments(CallExpression expression)
{
List<object> args = new List<object>();
foreach (Arg a in expression.Args) {
args.Add(Deserialize(a.Expression));
}
return args;
}
/// <summary>
/// Creates or gets the object specified in the python AST.
/// </summary>
/// <returns>
/// Null if the node cannot be deserialized.
/// </returns>
public object Deserialize(Node node)
{
if (node == null) {
throw new ArgumentNullException("node");
}
if (node is CallExpression) {
return Deserialize((CallExpression)node);
} else if (node is BinaryExpression) {
return Deserialize((BinaryExpression)node);
} else if (node is MemberExpression) {
return Deserialize((MemberExpression)node);
} else if (node is UnaryExpression) {
return Deserialize((UnaryExpression)node);
} else if (node is ConstantExpression) {
return Deserialize((ConstantExpression)node);
} else if (node is NameExpression) {
return Deserialize((NameExpression)node);
}
return null;
}
/// <summary>
/// Deserializes expressions of the form:
///
/// System.Windows.Form.AnchorStyles.Top | System.Windows.Form.AnchorStyles.Bottom
/// </summary>
public object Deserialize(BinaryExpression binaryExpression)
{
object lhs = Deserialize(binaryExpression.Left);
object rhs = Deserialize(binaryExpression.Right);
int value = Convert.ToInt32(lhs) | Convert.ToInt32(rhs);
return Enum.ToObject(lhs.GetType(), value);
}
/// <summary>
/// Deserializes expressions of the form:
///
/// 1) System.Drawing.Color.FromArgb(0, 192, 0)
/// 2) System.Array[String](["a", "b"])
/// </summary>
object Deserialize(CallExpression callExpression)
{
MemberExpression memberExpression = callExpression.Target as MemberExpression;
IndexExpression indexExpression = callExpression.Target as IndexExpression;
if (memberExpression != null) {
return DeserializeMethodCallExpression(callExpression, memberExpression);
} else if (indexExpression != null) {
return DeserializeCreateArrayExpression(callExpression, indexExpression);
}
return null;
}
/// <summary>
/// Deserializes expressions of the form:
///
/// 1) System.Windows.Forms.Cursors.AppStarting
/// </summary>
object Deserialize(MemberExpression memberExpression)
{
PythonControlFieldExpression field = PythonControlFieldExpression.Create(memberExpression);
Type type = GetType(field);
if (type != null) {
if (type.IsEnum) {
return Enum.Parse(type, field.MemberName);
} else {
BindingFlags propertyBindingFlags = BindingFlags.Public | BindingFlags.GetField | BindingFlags.Static | BindingFlags.Instance;
PropertyInfo propertyInfo = type.GetProperty(field.MemberName, propertyBindingFlags);
if (propertyInfo != null) {
return propertyInfo.GetValue(type, null);
}
}
}
return componentCreator.GetInstance(PythonControlFieldExpression.GetVariableName(field.MemberName));
}
/// <summary>
/// Deserializes expressions of the form:
///
/// 1) self
/// </summary>
object Deserialize(NameExpression nameExpression)
{
string name = nameExpression.Name;
if ("self" == name.ToLowerInvariant()) {
return componentCreator.RootComponent;
} else {
bool result;
if (Boolean.TryParse(name, out result)) {
return result;
}
}
return componentCreator.GetInstance(name);
}
Type GetType(PythonControlFieldExpression field)
{
string typeName = PythonControlFieldExpression.GetPrefix(field.FullMemberName);
return componentCreator.GetType(typeName);
}
/// <summary>
/// Deserializes a call expression where the target is an array expression.
///
/// System.Array[String](["a", "b"])
/// </summary>
object DeserializeCreateArrayExpression(CallExpression callExpression, IndexExpression target)
{
ListExpression list = callExpression.Args[0].Expression as ListExpression;
Type arrayType = GetType(target.Index as MemberExpression);
Array array = Array.CreateInstance(arrayType, list.Items.Count);
for (int i = 0; i < list.Items.Count; ++i) {
Expression listItemExpression = list.Items[i];
ConstantExpression constantExpression = listItemExpression as ConstantExpression;
MemberExpression memberExpression = listItemExpression as MemberExpression;
NameExpression nameExpression = listItemExpression as NameExpression;
CallExpression listItemCallExpression = listItemExpression as CallExpression;
if (constantExpression != null) {
array.SetValue(constantExpression.Value, i);
} else if (memberExpression != null) {
string name = PythonControlFieldExpression.GetVariableName(memberExpression.Name);
array.SetValue(componentCreator.GetComponent(name), i);
} else if (nameExpression != null) {
array.SetValue(componentCreator.GetInstance(nameExpression.Name), i);
} else if (listItemCallExpression != null) {
Type arrayInstanceType = GetType(listItemCallExpression.Target as MemberExpression);
object instance = componentCreator.CreateInstance(arrayInstanceType, GetArguments(listItemCallExpression), null, false);
array.SetValue(instance, i);
}
}
return array;
}
Type GetType(MemberExpression memberExpression)
{
string typeName = PythonControlFieldExpression.GetMemberName(memberExpression);
return componentCreator.GetType(typeName);
}
/// <summary>
/// Deserializes an expression of the form:
///
/// System.Drawing.Color.FromArgb(0, 192, 0)
/// </summary>
object DeserializeMethodCallExpression(CallExpression callExpression, MemberExpression memberExpression)
{
PythonControlFieldExpression field = PythonControlFieldExpression.Create(memberExpression);
Type type = GetType(field);
if (type != null) {
foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) {
if (method.Name == field.MemberName) {
if (method.GetParameters().Length == callExpression.Args.Count) {
return method.Invoke(null, GetArguments(callExpression).ToArray());
}
}
}
} else {
// Maybe it is a call to a constructor?
type = componentCreator.GetType(field.FullMemberName);
if (type != null) {
return componentCreator.CreateInstance(type, GetArguments(callExpression), null, false);
}
}
return null;
}
object Deserialize(UnaryExpression expression)
{
object rhs = Deserialize(expression.Expression);
switch (expression.Op) {
case PythonOperator.Negate:
return Negate(rhs);
}
return rhs;
}
object Negate(object value)
{
if (value is int) {
return -1 * (int)value;
} else if (value is double) {
return -1 * (double)value;
}
return value;
}
object Deserialize(ConstantExpression expression)
{
return expression.Value;
}
}
}

388
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs

@ -1,388 +0,0 @@ @@ -1,388 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.CodeDom;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using ICSharpCode.Scripting;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Used to generate Python code after the form has been changed in the designer.
/// </summary>
public class PythonCodeDomSerializer : IScriptingCodeDomSerializer
{
PythonCodeBuilder codeBuilder;
string indentString = String.Empty;
string rootResourceName = String.Empty;
IDesignerSerializationManager serializationManager;
public PythonCodeDomSerializer()
: this("\t")
{
}
public PythonCodeDomSerializer(string indentString)
{
this.indentString = indentString;
}
public string GenerateInitializeComponentMethodBody(IDesignerHost host, IDesignerSerializationManager serializationManager)
{
return GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 0);
}
public string GenerateInitializeComponentMethodBody(IDesignerHost host, IDesignerSerializationManager serializationManager, string rootNamespace, int initialIndent)
{
codeBuilder = new PythonCodeBuilder(initialIndent);
codeBuilder.IndentString = indentString;
CodeMemberMethod method = FindInitializeComponentMethod(host, serializationManager);
GetResourceRootName(rootNamespace, host.RootComponent);
AppendStatements(method.Statements);
return codeBuilder.ToString();
}
CodeMemberMethod FindInitializeComponentMethod(IDesignerHost host, IDesignerSerializationManager serializationManager)
{
this.serializationManager = serializationManager;
object rootComponent = host.RootComponent;
TypeCodeDomSerializer serializer = serializationManager.GetSerializer(rootComponent.GetType(), typeof(TypeCodeDomSerializer)) as TypeCodeDomSerializer;
CodeTypeDeclaration typeDec = serializer.Serialize(serializationManager, rootComponent, host.Container.Components) as CodeTypeDeclaration;
foreach (CodeTypeMember member in typeDec.Members) {
CodeMemberMethod method = member as CodeMemberMethod;
if (method != null) {
if (method.Name == "InitializeComponent") {
return method;
}
}
}
return null;
}
void AppendStatements(CodeStatementCollection statements)
{
foreach (CodeStatement statement in statements) {
AppendStatement(statement);
}
}
void AppendStatement(CodeStatement statement)
{
if (statement is CodeExpressionStatement) {
AppendExpressionStatement((CodeExpressionStatement)statement);
} else if (statement is CodeCommentStatement) {
AppendCommentStatement((CodeCommentStatement)statement);
} else if (statement is CodeAssignStatement) {
AppendAssignStatement((CodeAssignStatement)statement);
} else if (statement is CodeVariableDeclarationStatement) {
AppendVariableDeclarationStatement((CodeVariableDeclarationStatement)statement);
} else if (statement is CodeAttachEventStatement) {
AppendAttachEventStatement((CodeAttachEventStatement)statement);
} else {
Console.WriteLine("AppendStatement: " + statement.GetType().Name);
}
}
void AppendExpressionStatement(CodeExpressionStatement statement)
{
codeBuilder.AppendIndented(String.Empty);
AppendExpression(statement.Expression);
codeBuilder.AppendLine();
}
void AppendCommentStatement(CodeCommentStatement statement)
{
codeBuilder.AppendIndented(String.Empty);
codeBuilder.Append("# ");
codeBuilder.Append(statement.Comment.Text);
codeBuilder.AppendLine();
}
void AppendExpression(CodeExpression expression)
{
if (expression is CodeMethodInvokeExpression) {
AppendMethodInvokeExpression((CodeMethodInvokeExpression)expression);
} else if (expression is CodePropertyReferenceExpression) {
AppendPropertyReferenceExpression((CodePropertyReferenceExpression)expression);
} else if (expression is CodeObjectCreateExpression) {
AppendObjectCreateExpression((CodeObjectCreateExpression)expression);
} else if (expression is CodePrimitiveExpression) {
AppendPrimitiveExpression((CodePrimitiveExpression)expression);
} else if (expression is CodeFieldReferenceExpression) {
AppendFieldReferenceExpression((CodeFieldReferenceExpression)expression);
} else if (expression is CodeThisReferenceExpression) {
AppendThisReferenceExpression();
} else if (expression is CodeTypeReferenceExpression) {
AppendTypeReferenceExpression((CodeTypeReferenceExpression)expression);
} else if (expression is CodeArrayCreateExpression) {
AppendArrayCreateExpression((CodeArrayCreateExpression)expression);
} else if (expression is CodeVariableReferenceExpression) {
AppendVariableReferenceExpression((CodeVariableReferenceExpression)expression);
} else if (expression is CodeDelegateCreateExpression) {
AppendDelegateCreateExpression((CodeDelegateCreateExpression)expression);
} else if (expression is CodeCastExpression) {
AppendCastExpression((CodeCastExpression)expression);
} else if (expression is CodeBinaryOperatorExpression) {
AppendBinaryOperatorExpression((CodeBinaryOperatorExpression)expression);
} else {
Console.WriteLine("AppendExpression: " + expression.GetType().Name);
}
}
/// <summary>
/// Appends a method call (e.g. "self.SuspendLayout()");
/// </summary>
void AppendMethodInvokeExpression(CodeMethodInvokeExpression expression)
{
AppendMethodReferenceExpression(expression.Method);
AppendParameters(expression.Parameters);
}
void AppendMethodReferenceExpression(CodeMethodReferenceExpression expression)
{
AppendExpression(expression.TargetObject);
codeBuilder.Append(".");
codeBuilder.Append(expression.MethodName);
}
void AppendParameters(CodeExpressionCollection parameters)
{
codeBuilder.Append("(");
bool firstParameter = true;
foreach (CodeExpression expression in parameters) {
if (firstParameter) {
firstParameter = false;
} else {
codeBuilder.Append(", ");
}
AppendExpression(expression);
}
codeBuilder.Append(")");
}
void AppendAssignStatement(CodeAssignStatement statement)
{
codeBuilder.AppendIndented(String.Empty);
AppendExpression(statement.Left);
codeBuilder.Append(" = ");
AppendExpression(statement.Right);
codeBuilder.AppendLine();
}
void AppendPropertyReferenceExpression(CodePropertyReferenceExpression expression)
{
AppendExpression(expression.TargetObject);
codeBuilder.Append(".");
codeBuilder.Append(expression.PropertyName);
}
void AppendObjectCreateExpression(CodeObjectCreateExpression expression)
{
AppendTypeReference(expression.CreateType);
AppendParameters(expression.Parameters);
}
/// <summary>
/// Appends a constant (e.g. string or int).
/// </summary>
void AppendPrimitiveExpression(CodePrimitiveExpression expression)
{
codeBuilder.Append(PythonPropertyValueAssignment.ToString(expression.Value));
}
void AppendFieldReferenceExpression(CodeFieldReferenceExpression expression)
{
AppendExpression(expression.TargetObject);
codeBuilder.Append(".");
if (expression.FieldName != null) {
if (expression.TargetObject is CodeThisReferenceExpression) {
if (!IsInherited(expression.FieldName)) {
codeBuilder.Append("_");
}
}
codeBuilder.Append(expression.FieldName);
}
}
void AppendThisReferenceExpression()
{
codeBuilder.Append("self");
}
void AppendTypeReferenceExpression(CodeTypeReferenceExpression expression)
{
AppendTypeReference(expression.Type);
}
void AppendTypeReference(CodeTypeReference typeRef)
{
string typeRefText = typeRef.BaseType.Replace('+', '.');
codeBuilder.Append(typeRefText);
}
/// <summary>
/// Creates an array expression:
///
/// (System.Array[System.Object](\r\n" +
/// ["aaa",
/// "bbb",
/// "ccc\"]))
/// </summary>
void AppendArrayCreateExpression(CodeArrayCreateExpression expression)
{
codeBuilder.Append("System.Array[");
AppendTypeReference(expression.CreateType);
codeBuilder.Append("]");
AppendInitializers(expression.Initializers);
}
/// <summary>
/// Appends initializers for an array.
/// </summary>
void AppendInitializers(CodeExpressionCollection initalizers)
{
codeBuilder.Append("(");
codeBuilder.AppendLine();
codeBuilder.IncreaseIndent();
codeBuilder.AppendIndented("[");
bool firstInitializer = true;
foreach (CodeExpression expression in initalizers) {
if (firstInitializer) {
firstInitializer = false;
} else {
codeBuilder.Append(",");
codeBuilder.AppendLine();
codeBuilder.AppendIndented(String.Empty);
}
AppendExpression(expression);
}
codeBuilder.Append("])");
codeBuilder.DecreaseIndent();
}
/// <summary>
/// Appends a local variable declaration.
/// </summary>
void AppendVariableDeclarationStatement(CodeVariableDeclarationStatement statement)
{
if (statement.Name == "resources") {
codeBuilder.AppendIndented("resources = System.Resources.ResourceManager(\"");
codeBuilder.Append(rootResourceName);
codeBuilder.Append("\", System.Reflection.Assembly.GetEntryAssembly())");
codeBuilder.AppendLine();
} else {
codeBuilder.AppendIndented(statement.Name);
codeBuilder.Append(" = ");
AppendExpression(statement.InitExpression);
codeBuilder.AppendLine();
}
}
void AppendVariableReferenceExpression(CodeVariableReferenceExpression expression)
{
codeBuilder.Append(expression.VariableName);
}
void AppendAttachEventStatement(CodeAttachEventStatement statement)
{
codeBuilder.AppendIndented(String.Empty);
AppendExpression(statement.Event.TargetObject);
codeBuilder.Append(".");
codeBuilder.Append(statement.Event.EventName);
codeBuilder.Append(" += ");
AppendExpression(statement.Listener);
codeBuilder.AppendLine();
}
void AppendDelegateCreateExpression(CodeDelegateCreateExpression expression)
{
AppendExpression(expression.TargetObject);
codeBuilder.Append(".");
codeBuilder.Append(expression.MethodName);
}
void GetResourceRootName(string rootNamespace, IComponent component)
{
rootResourceName = component.Site.Name;
if (!String.IsNullOrEmpty(rootNamespace)) {
rootResourceName = rootNamespace + "." + rootResourceName;
}
}
void AppendCastExpression(CodeCastExpression expression)
{
AppendExpression(expression.Expression);
}
bool IsInherited(string componentName)
{
return IsInherited(serializationManager.GetInstance(componentName));
}
static bool IsInherited(object component)
{
InheritanceAttribute attribute = GetInheritanceAttribute(component);
if (attribute != null) {
return attribute.InheritanceLevel != InheritanceLevel.NotInherited;
}
return false;
}
static InheritanceAttribute GetInheritanceAttribute(object component)
{
if (component != null) {
AttributeCollection attributes = TypeDescriptor.GetAttributes(component);
return attributes[typeof(InheritanceAttribute)] as InheritanceAttribute;
}
return null;
}
/// <summary>
/// Appends expressions like "AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top"
/// </summary>
void AppendBinaryOperatorExpression(CodeBinaryOperatorExpression expression)
{
AppendExpression(expression.Left);
AppendBinaryOperator(expression.Operator);
AppendExpression(expression.Right);
}
void AppendBinaryOperator(CodeBinaryOperatorType operatorType)
{
codeBuilder.Append(" ");
switch (operatorType) {
case CodeBinaryOperatorType.BitwiseOr:
codeBuilder.Append("|");
break;
}
codeBuilder.Append(" ");
}
}
}

33
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilationUnit.cs

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PythonBinding
{
public class PythonCompilationUnit : DefaultCompilationUnit
{
public PythonCompilationUnit(IProjectContent projectContent, string fileName)
: base(projectContent)
{
this.FileName = fileName;
this.UsingScope = new PythonUsingScope(fileName);
}
}
}

52
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerError.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using Microsoft.Scripting;
using System;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Saves information about a parser error reported by the
/// PythonCompilerSink.
/// </summary>
public class PythonCompilerError
{
string path = String.Empty;
string message = String.Empty;
string lineText = String.Empty;
SourceSpan location;
int errorCode;
Severity severity;
public PythonCompilerError(string path, string message, string lineText, SourceSpan location, int errorCode, Severity severity)
{
this.path = path;
this.message = message;
this.lineText = lineText;
this.location = location;
this.errorCode = errorCode;
this.severity = severity;
}
public override string ToString()
{
return String.Concat("[", errorCode, "][Sev:", severity.ToString(), "]", message, "\r\nLine: ", location.Start.Line, lineText, "\r\n", path, "\r\n");
}
}
}

59
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompilerSink.cs

@ -1,59 +0,0 @@ @@ -1,59 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using Microsoft.Scripting;
using System;
using System.Collections.Generic;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Supresses exceptions thrown by the PythonParser when it
/// finds a parsing error. By default the simple compiler sink
/// throws an exception on a parsing error.
/// </summary>
public class PythonCompilerSink : ErrorSink
{
List<PythonCompilerError> errors = new List<PythonCompilerError>();
public PythonCompilerSink()
{
}
public override void Add(SourceUnit source, string message, SourceSpan span, int errorCode, Severity severity)
{
int line = GetLine(span.Start.Line);
errors.Add(new PythonCompilerError(source.Path, message, source.GetCodeLine(line), span, errorCode, severity));
}
public List<PythonCompilerError> Errors {
get { return errors; }
}
/// <summary>
/// Ensure the line number is valid.
/// </summary>
static int GetLine(int line)
{
if (line > 0) {
return line;
}
return 1;
}
}
}

39
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCompletionItemList.cs

@ -1,39 +0,0 @@ @@ -1,39 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
namespace ICSharpCode.PythonBinding
{
public class PythonCompletionItemList : DefaultCompletionItemList
{
public override CompletionItemListKeyResult ProcessInput(char key)
{
if (IsNormalKey(key)) {
return CompletionItemListKeyResult.NormalKey;
}
return base.ProcessInput(key);
}
bool IsNormalKey(char key)
{
return (key == '*') || (key == '(');
}
}
}

417
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs

@ -1,417 +0,0 @@ @@ -1,417 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.Scripting;
using ICSharpCode.SharpDevelop;
using IronPython.Compiler.Ast;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Visits the code's Python AST and creates a Windows Form.
/// </summary>
public class PythonComponentWalker : PythonWalker, IComponentWalker
{
IComponent component;
PythonControlFieldExpression fieldExpression;
IComponentCreator componentCreator;
bool walkingAssignment;
string componentName = String.Empty;
PythonCodeDeserializer deserializer;
ClassDefinition classDefinition;
bool walkingInitializeComponentMethod;
public PythonComponentWalker(IComponentCreator componentCreator)
{
this.componentCreator = componentCreator;
deserializer = new PythonCodeDeserializer(componentCreator);
}
/// <summary>
/// Creates a control either a UserControl or Form from the python code.
/// </summary>
public IComponent CreateComponent(string pythonCode)
{
PythonParser parser = new PythonParser();
PythonAst ast = parser.CreateAst(@"Control.py", new StringTextBuffer(pythonCode));
ast.Walk(this);
// Did we find the InitializeComponent method?
if (component == null) {
throw new PythonComponentWalkerException("Unable to find InitializeComponents method.");
}
return component;
}
/// <summary>
/// Gets the fully qualified name of the base class.
/// </summary>
public static string GetBaseClassName(ClassDefinition classDefinition)
{
if (classDefinition.Bases.Count > 0) {
Expression baseClassExpression = classDefinition.Bases[0];
NameExpression nameExpression = baseClassExpression as NameExpression;
MemberExpression memberExpression = baseClassExpression as MemberExpression;
if (nameExpression != null) {
return nameExpression.Name;
}
return PythonControlFieldExpression.GetMemberName(memberExpression);
}
return String.Empty;
}
public override bool Walk(ClassDefinition node)
{
classDefinition = node;
componentName = node.Name;
node.Body.Walk(this);
return false;
}
public override bool Walk(FunctionDefinition node)
{
if (IsInitializeComponentMethod(node)) {
Type type = GetComponentType();
component = componentCreator.CreateComponent(type, componentName);
IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture);
if (reader != null) {
reader.Dispose();
}
walkingInitializeComponentMethod = true;
node.Body.Walk(this);
walkingInitializeComponentMethod = false;
}
return false;
}
public override bool Walk(AssignmentStatement node)
{
if (!walkingInitializeComponentMethod) {
return false;
}
if (node.Left.Count > 0) {
MemberExpression lhsMemberExpression = node.Left[0] as MemberExpression;
NameExpression lhsNameExpression = node.Left[0] as NameExpression;
if (lhsMemberExpression != null) {
fieldExpression = PythonControlFieldExpression.Create(lhsMemberExpression);
WalkMemberExpressionAssignmentRhs(node.Right);
} else if (lhsNameExpression != null) {
CallExpression callExpression = node.Right as CallExpression;
if (callExpression != null) {
object instance = CreateInstance(lhsNameExpression.Name.ToString(), callExpression);
if (instance == null) {
ThrowCouldNotFindTypeException(callExpression.Target as MemberExpression);
}
}
}
}
return false;
}
public override bool Walk(ConstantExpression node)
{
if (!walkingInitializeComponentMethod) {
return false;
}
fieldExpression.SetPropertyValue(componentCreator, node.Value);
return false;
}
public override bool Walk(CallExpression node)
{
if (!walkingInitializeComponentMethod) {
return false;
}
if (walkingAssignment) {
WalkAssignmentRhs(node);
} else {
WalkMethodCall(node);
}
return false;
}
public override bool Walk(NameExpression node)
{
if (!walkingInitializeComponentMethod) {
return false;
}
fieldExpression.SetPropertyValue(componentCreator, node);
return false;
}
/// <summary>
/// Walks a statement of the form:
///
/// self.a += self.b
/// </summary>
public override bool Walk(AugmentedAssignStatement node)
{
if (!walkingInitializeComponentMethod) {
return false;
}
MemberExpression eventExpression = node.Left as MemberExpression;
string eventName = eventExpression.Name.ToString();
fieldExpression = PythonControlFieldExpression.Create(eventExpression);
MemberExpression eventHandlerExpression = node.Right as MemberExpression;
string eventHandlerName = eventHandlerExpression.Name.ToString();
IComponent currentComponent = fieldExpression.GetObject(componentCreator) as IComponent;
EventDescriptor eventDescriptor = TypeDescriptor.GetEvents(currentComponent).Find(eventName, false);
PropertyDescriptor propertyDescriptor = componentCreator.GetEventProperty(eventDescriptor);
propertyDescriptor.SetValue(currentComponent, eventHandlerName);
return false;
}
/// <summary>
/// Walks the binary expression which is the right hand side of an assignment statement.
/// </summary>
void WalkAssignment(BinaryExpression binaryExpression)
{
object value = deserializer.Deserialize(binaryExpression);
fieldExpression.SetPropertyValue(componentCreator, value);
}
/// <summary>
/// Walks the right hand side of an assignment to a member expression.
/// </summary>
void WalkMemberExpressionAssignmentRhs(Expression rhs)
{
MemberExpression rhsMemberExpression = rhs as MemberExpression;
if (rhsMemberExpression != null) {
object propertyValue = GetPropertyValueFromAssignmentRhs(rhsMemberExpression);
fieldExpression.SetPropertyValue(componentCreator, propertyValue);
} else {
walkingAssignment = true;
BinaryExpression binaryExpression = rhs as BinaryExpression;
if (binaryExpression != null) {
WalkAssignment(binaryExpression);
} else {
rhs.Walk(this);
}
walkingAssignment = false;
}
}
static bool IsInitializeComponentMethod(FunctionDefinition node)
{
string name = node.Name.ToString().ToLowerInvariant();
return name == "initializecomponent" || name == "initializecomponents";
}
/// <summary>
/// Adds a component to the list of created objects.
/// </summary>
void AddComponent(string name, object obj)
{
IComponent component = obj as IComponent;
if (component != null) {
string variableName = PythonControlFieldExpression.GetVariableName(name);
componentCreator.Add(component, variableName);
}
}
/// <summary>
/// Gets the type for the control being walked.
/// </summary>
Type GetComponentType()
{
string baseClass = GetBaseClassName(classDefinition);
Type type = componentCreator.GetType(baseClass);
if (type != null) {
return type;
}
if (baseClass.Contains("UserControl")) {
return typeof(UserControl);
}
return typeof(Form);
}
/// <summary>
/// Gets the property value from the member expression. The member expression is taken from the
/// right hand side of an assignment.
/// </summary>
object GetPropertyValueFromAssignmentRhs(MemberExpression memberExpression)
{
return deserializer.Deserialize(memberExpression);
}
/// <summary>
/// Walks the right hand side of an assignment where the assignment expression is a call expression.
/// Typically the call expression will be a constructor call.
///
/// Constructor call: System.Windows.Forms.Form()
/// </summary>
void WalkAssignmentRhs(CallExpression node)
{
MemberExpression memberExpression = node.Target as MemberExpression;
if (memberExpression != null) {
string name = fieldExpression.GetInstanceName(componentCreator);
object instance = CreateInstance(name, node);
if (instance != null) {
if (!fieldExpression.SetPropertyValue(componentCreator, instance)) {
AddComponent(fieldExpression.MemberName, instance);
}
} else {
object obj = deserializer.Deserialize(node);
if (obj != null) {
fieldExpression.SetPropertyValue(componentCreator, obj);
} else if (IsResource(memberExpression)) {
fieldExpression.SetPropertyValue(componentCreator, GetResource(node));
} else {
ThrowCouldNotFindTypeException(memberExpression);
}
}
} else if (node.Target is IndexExpression) {
WalkArrayAssignmentRhs(node);
}
}
/// <summary>
/// Walks a method call. Typical method calls are:
///
/// self._menuItem1.Items.AddRange(...)
///
/// This method will execute the method call.
/// </summary>
void WalkMethodCall(CallExpression node)
{
// Try to get the object being called. Try the form first then
// look for other controls.
object member = PythonControlFieldExpression.GetMember(component, node);
PythonControlFieldExpression field = PythonControlFieldExpression.Create(node);
if (member == null) {
member = field.GetMember(componentCreator);
}
// Execute the method on the object.
if (member != null) {
object[] args = deserializer.GetArguments(node).ToArray();
InvokeMethod(member, field.MethodName, args);
}
}
void InvokeMethod(object obj, string name, object[] args)
{
Type type = obj.GetType();
try {
type.InvokeMember(name, BindingFlags.InvokeMethod, Type.DefaultBinder, obj, args);
} catch (MissingMethodException ex) {
// Look for an explicitly implemented interface.
MethodInfo method = FindInterfaceMethod(type, name);
if (method != null) {
method.Invoke(obj, args);
} else {
throw ex;
}
}
}
/// <summary>
/// Looks for an explicitly implemented interface.
/// </summary>
MethodInfo FindInterfaceMethod(Type type, string name)
{
string nameMatch = "." + name;
foreach (MethodInfo method in type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)) {
if (method.Name.EndsWith(nameMatch)) {
return method;
}
}
return null;
}
/// <summary>
/// Creates a new instance with the specified name.
/// </summary>
object CreateInstance(string name, CallExpression node)
{
MemberExpression memberExpression = node.Target as MemberExpression;
if (memberExpression != null) {
string typeName = PythonControlFieldExpression.GetMemberName(memberExpression);
Type type = componentCreator.GetType(typeName);
if (type != null) {
if (type.IsAssignableFrom(typeof(ComponentResourceManager))) {
return componentCreator.CreateInstance(type, new object[0], name, false);
}
List<object> args = deserializer.GetArguments(node);
return componentCreator.CreateInstance(type, args, name, false);
}
}
return null;
}
/// <summary>
/// Returns true if the expression is of the form:
///
/// resources.GetObject(...) or
/// resources.GetString(...)
/// </summary>
bool IsResource(MemberExpression memberExpression)
{
string fullName = PythonControlFieldExpression.GetMemberName(memberExpression);
return fullName.StartsWith("resources.", StringComparison.InvariantCultureIgnoreCase);
}
object GetResource(CallExpression callExpression)
{
IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture);
if (reader != null) {
using (ResourceSet resources = new ResourceSet(reader)) {
List<object> args = deserializer.GetArguments(callExpression);
return resources.GetObject(args[0] as String);
}
}
return null;
}
/// <summary>
/// Walks the right hand side of an assignment when the assignment is an array creation.
/// </summary>
void WalkArrayAssignmentRhs(CallExpression callExpression)
{
object array = deserializer.Deserialize(callExpression);
fieldExpression.SetPropertyValue(componentCreator, array);
}
void ThrowCouldNotFindTypeException(MemberExpression memberExpression)
{
string typeName = PythonControlFieldExpression.GetMemberName(memberExpression);
throw new PythonComponentWalkerException(String.Format(StringParser.Parse("${res:ICSharpCode.PythonBinding.UnknownTypeName}"), typeName));
}
}
}

32
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalkerException.cs

@ -1,32 +0,0 @@ @@ -1,32 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Exception thrown by the PythonComponentWalker class.
/// </summary>
public class PythonComponentWalkerException : Exception
{
public PythonComponentWalkerException(string message) : base(message)
{
}
}
}

86
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs

@ -1,86 +0,0 @@ @@ -1,86 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Scripting;
using Microsoft.Scripting.Hosting.Shell;
namespace ICSharpCode.PythonBinding
{
public class PythonConsole : ThreadSafeScriptingConsole, IConsole, IMemberProvider
{
IScriptingConsoleTextEditor textEditor;
IControlDispatcher dispatcher;
public PythonConsole(IScriptingConsoleTextEditor textEditor, IControlDispatcher dispatcher)
: this(new ScriptingConsole(textEditor), dispatcher)
{
this.textEditor = textEditor;
}
PythonConsole(ScriptingConsole console, IControlDispatcher dispatcher)
: base(console, dispatcher)
{
this.dispatcher = dispatcher;
console.MemberProvider = this;
}
public ScriptingConsoleOutputStream CreateOutputStream()
{
return new ScriptingConsoleOutputStream(textEditor, dispatcher);
}
public CommandLine CommandLine { get; set; }
public TextWriter Output {
get { return null; }
set { }
}
public TextWriter ErrorOutput {
get { return null; }
set { }
}
/// <summary>
/// Gets the member names of the specified item.
/// </summary>
public IList<string> GetMemberNames(string name)
{
return CommandLine.GetMemberNames(name);
}
public IList<string> GetGlobals(string name)
{
return CommandLine.GetGlobals(name);
}
public void Write(string text, Style style)
{
base.Write(text, (ScriptingStyle)style);
}
public void WriteLine(string text, Style style)
{
base.WriteLine(text, (ScriptingStyle)style);
}
}
}

46
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs

@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using System.Text;
using ICSharpCode.Scripting;
namespace ICSharpCode.PythonBinding
{
public class PythonConsoleApplication : ScriptingConsoleApplication
{
PythonAddInOptions options;
public PythonConsoleApplication(PythonAddInOptions options)
{
this.options = options;
}
public override string FileName {
get { return options.PythonFileName; }
}
protected override void AddArguments(ScriptingCommandLineBuilder commandLine)
{
commandLine.AppendBooleanOptionIfTrue("-X:Debug", Debug);
commandLine.AppendQuotedStringIfNotEmpty(ScriptFileName);
commandLine.AppendStringIfNotEmpty(ScriptCommandLineArguments);
}
}
}

103
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleHost.cs

@ -1,103 +0,0 @@ @@ -1,103 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Text;
using System.Threading;
using ICSharpCode.Scripting;
using IronPython.Hosting;
using IronPython.Runtime;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Shell;
namespace ICSharpCode.PythonBinding
{
public class PythonConsoleHost : ConsoleHost, IScriptingConsoleHost
{
Thread thread;
PythonConsole pythonConsole;
public PythonConsoleHost(IScriptingConsoleTextEditor textEditor, IControlDispatcher dispatcher)
{
pythonConsole = new PythonConsole(textEditor, dispatcher);
}
public IScriptingConsole ScriptingConsole {
get { return pythonConsole; }
}
protected override Type Provider {
get { return typeof(PythonContext); }
}
/// <summary>
/// Runs the console host in its own thread.
/// </summary>
public void Run()
{
thread = new Thread(RunConsole);
thread.Start();
}
public void Dispose()
{
if (pythonConsole != null) {
pythonConsole.Dispose();
}
if (thread != null) {
thread.Join();
}
}
protected override CommandLine CreateCommandLine()
{
return new PythonCommandLine();
}
protected override OptionsParser CreateOptionsParser()
{
return new PythonOptionsParser();
}
/// <remarks>
/// After the engine is created the standard output is replaced with our custom Stream class so we
/// can redirect the stdout to the text editor window.
/// This can be done in this method since the Runtime object will have been created before this method
/// is called.
/// </remarks>
protected override IConsole CreateConsole(ScriptEngine engine, CommandLine commandLine, ConsoleOptions options)
{
ScriptingConsoleOutputStream stream = pythonConsole.CreateOutputStream();
SetOutput(stream);
pythonConsole.CommandLine = commandLine;
return pythonConsole;
}
protected virtual void SetOutput(ScriptingConsoleOutputStream stream)
{
Runtime.IO.SetOutput(stream, Encoding.UTF8);
}
void RunConsole()
{
Run(new string[0]);
}
}
}

36
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsolePad.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.Scripting;
namespace ICSharpCode.PythonBinding
{
public class PythonConsolePad : ScriptingConsolePad
{
protected override IScriptingConsoleHost CreateConsoleHost(IScriptingConsoleTextEditor consoleTextEditor,
IControlDispatcher dispatcher)
{
return new PythonConsoleHost(consoleTextEditor, dispatcher);
}
protected override string SyntaxHighlightingName {
get { return "Python"; }
}
}
}

32
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConstructor.cs

@ -1,32 +0,0 @@ @@ -1,32 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Dom;
using IronPython.Compiler.Ast;
namespace ICSharpCode.PythonBinding
{
public class PythonConstructor : PythonMethod
{
public PythonConstructor(IClass declaringType, FunctionDefinition methodDefinition)
: base(declaringType, methodDefinition, "#ctor")
{
}
}
}

533
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs

@ -1,533 +0,0 @@ @@ -1,533 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Scripting;
using IronPython.Compiler.Ast;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Represents a member field expression in a Control or Form:
///
/// self._textBox1
/// self._textBox1.Name
/// </summary>
public class PythonControlFieldExpression
{
string memberName = String.Empty;
string fullMemberName = String.Empty;
string variableName = String.Empty;
string methodName = String.Empty;
bool selfReference;
public PythonControlFieldExpression(string memberName, string variableName, string methodName, string fullMemberName)
{
this.memberName = memberName;
this.variableName = variableName;
this.methodName = methodName;
this.fullMemberName = fullMemberName;
selfReference = ContainsSelfReference(fullMemberName);
}
/// <summary>
/// From a member expression of the form: self._textBox1.Name this property will return "Name".
/// </summary>
public string MemberName {
get { return memberName; }
}
/// <summary>
/// From a member expression of the form: self._textBox1.Name this property will return "self._textBox1.Name".
/// </summary>
public string FullMemberName {
get { return fullMemberName; }
}
/// <summary>
/// From a member expression of the form: self._textBox1.Name this property will return "textBox1".
/// </summary>
public string VariableName {
get { return variableName; }
}
/// <summary>
/// Returns the method being called by the field reference.
/// </summary>
public string MethodName {
get { return methodName; }
}
/// <summary>
/// Returns whether the variable is for a field or not.
/// </summary>
public bool IsSelfReference {
get { return selfReference; }
}
public override string ToString()
{
return "[VariableName: " + variableName + " FullMemberName: " + fullMemberName + "]";
}
public override bool Equals(object obj)
{
PythonControlFieldExpression rhs = obj as PythonControlFieldExpression;
if (rhs != null) {
return rhs.fullMemberName == fullMemberName && rhs.variableName == variableName;
}
return false;
}
public override int GetHashCode()
{
return fullMemberName.GetHashCode();
}
/// <summary>
/// Creates a PythonControlField from a member expression:
///
/// self._textBox1
/// self._textBox1.Name
/// </summary>
public static PythonControlFieldExpression Create(MemberExpression expression)
{
return Create(GetMemberNames(expression));
}
/// <summary>
/// Creates a PythonControlField from a call expression:
///
/// self._menuItem1.Items.AddRange(...)
/// </summary>
public static PythonControlFieldExpression Create(CallExpression expression)
{
string[] allNames = GetMemberNames(expression.Target as MemberExpression);
// Remove last member since it is the method name.
int lastItemIndex = allNames.Length - 1;
string[] memberNames = new string[lastItemIndex];
Array.Copy(allNames, memberNames, lastItemIndex);
PythonControlFieldExpression field = Create(memberNames);
field.methodName = allNames[lastItemIndex];
return field;
}
/// <summary>
/// From a name such as "System.Windows.Forms.Cursors.AppStarting" this method returns:
/// "System.Windows.Forms.Cursors"
/// </summary>
public static string GetPrefix(string name)
{
int index = name.LastIndexOf('.');
if (index > 0) {
return name.Substring(0, index);
}
return name;
}
/// <summary>
/// Removes the underscore from the variable name.
/// </summary>
public static string GetVariableName(string name)
{
if (!String.IsNullOrEmpty(name)) {
if (name.Length > 0) {
if (name[0] == '_') {
return name.Substring(1);
}
}
}
return name;
}
/// <summary>
/// Gets the fully qualified name being referenced in the MemberExpression.
/// </summary>
public static string GetMemberName(MemberExpression expression)
{
return GetMemberName(GetMemberNames(expression));
}
/// <summary>
/// Gets the member names that make up the MemberExpression in order.
/// </summary>
public static string[] GetMemberNames(MemberExpression expression)
{
List<string> names = new List<string>();
while (expression != null) {
names.Insert(0, expression.Name);
NameExpression nameExpression = expression.Target as NameExpression;
expression = expression.Target as MemberExpression;
if (expression == null) {
if (nameExpression != null) {
names.Insert(0, nameExpression.Name);
}
}
}
return names.ToArray();
}
/// <summary>
/// Returns true if the variable has a property with the specified name.
/// </summary>
public bool HasPropertyValue(IComponentCreator componentCreator, string name)
{
object component = GetObject(componentCreator);
if (component != null) {
return TypeDescriptor.GetProperties(component).Find(name, true) != null;
}
return false;
}
/// <summary>
/// Gets the name of the instance. If the name matches a property of the current component being created
/// then this method returns null.
/// </summary>
public string GetInstanceName(IComponentCreator componentCreator)
{
if (IsSelfReference) {
if (!HasPropertyValue(componentCreator, memberName)) {
return variableName;
}
}
return null;
}
/// <summary>
/// Looks for a field in the component with the given name.
/// </summary>
public static object GetInheritedObject(string name, object component)
{
if (component != null) {
FieldInfo[] fields = component.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
foreach (FieldInfo field in fields) {
if (String.Equals(name, field.Name, StringComparison.InvariantCultureIgnoreCase)) {
return field.GetValue(component);
}
}
}
return null;
}
/// <summary>
/// Gets the object that the field expression variable refers to.
/// </summary>
/// <remarks>
/// This method will also check form's base class for any inherited objects that match
/// the object being referenced.
/// </remarks>
public object GetObject(IComponentCreator componentCreator)
{
if (variableName.Length > 0) {
object component = componentCreator.GetComponent(variableName);
if (component != null) {
return component;
}
return GetInheritedObject(variableName, componentCreator.RootComponent);
}
return componentCreator.RootComponent;
}
/// <summary>
/// Returns the object that the property is defined on. This method may just return the object
/// passed to it if the property is defined on that object.
/// </summary>
/// <remarks>The object parameter must be equivalent to the object referred to
/// by the variable name in this PythonControlFieldExpression
/// (e.g. button1 in self._button1.FlatAppearance.BorderSize).</remarks>
public object GetObjectForMemberName(object component)
{
string[] members = fullMemberName.Split('.');
int startIndex = GetMembersStartIndex(members);
object currentComponent = component;
for (int i = startIndex; i < members.Length - 1; ++i) {
PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(currentComponent).Find(members[i], true);
if (propertyDescriptor == null) {
return null;
}
currentComponent = propertyDescriptor.GetValue(currentComponent);
}
return currentComponent;
}
/// <summary>
/// Sets the property value that is referenced by this field expression.
/// </summary>
/// <remarks>
/// This method checks that the name expression matches a created instance before
/// converting the name expression as a string and setting the property value.
/// </remarks>
public bool SetPropertyValue(IComponentCreator componentCreator, NameExpression nameExpression)
{
object component = GetComponent(componentCreator);
PropertyDescriptor property = GetProperty(component, memberName);
if (property != null) {
string name = nameExpression.Name;
if (property.PropertyType != typeof(bool)) {
if ("self" == name) {
return SetPropertyValue(component, memberName, componentCreator.RootComponent);
} else {
object instance = componentCreator.GetInstance(name);
if (instance != null) {
return SetPropertyValue(component, memberName, instance);
}
}
}
return SetPropertyValue(component, memberName, name);
}
return false;
}
/// <summary>
/// Sets the property value that is referenced by this field expression.
/// </summary>
/// <remarks>
/// Checks the field expression to see if it references an class instance variable (e.g. self._treeView1)
/// or a variable that is local to the InitializeComponent method (e.g. treeNode1.BackColor)
/// </remarks>
public bool SetPropertyValue(IComponentCreator componentCreator, object propertyValue)
{
object component = GetComponent(componentCreator);
return SetPropertyValue(component, memberName, propertyValue);
}
/// <summary>
/// Converts the value to the property's type if required.
/// </summary>
public static object ConvertPropertyValue(PropertyDescriptor propertyDescriptor, object propertyValue)
{
if (propertyValue != null) {
Type propertyValueType = propertyValue.GetType();
if (!propertyDescriptor.PropertyType.IsAssignableFrom(propertyValueType)) {
if (propertyDescriptor.Converter.CanConvertFrom(propertyValueType)) {
return propertyDescriptor.Converter.ConvertFrom(propertyValue);
}
TypeConverter converter = TypeDescriptor.GetConverter(propertyValue);
return converter.ConvertTo(propertyValue, propertyDescriptor.PropertyType);
}
}
return propertyValue;
}
/// <summary>
/// Gets the member object that matches the field member.
///
/// For a field:
///
/// self._menuStrip.Items.AddRange()
///
/// This method returns:
///
/// Items
/// </summary>
public object GetMember(IComponentCreator componentCreator)
{
object obj = componentCreator.GetComponent(variableName);
if (obj == null) {
obj = componentCreator.GetInstance(variableName);
if (obj == null) {
obj = GetInheritedObject(memberName, componentCreator.RootComponent);
if ((obj == null) && !IsSelfReference) {
obj = componentCreator.GetInstance(fullMemberName);
}
}
}
if (obj != null) {
string[] memberNames = fullMemberName.Split('.');
int startIndex = GetMembersStartIndex(memberNames);
return GetMember(obj, memberNames, startIndex, memberNames.Length - 1);
}
return null;
}
/// <summary>
/// Gets the member object that matches the field member.
/// </summary>
/// <remarks>
/// The member names array should contain all items including self, for example:
///
/// self
/// Controls
/// </remarks>
public static object GetMember(object obj, CallExpression expression)
{
string[] memberNames = GetMemberNames(expression.Target as MemberExpression);
if (ContainsSelfReference(memberNames)) {
return GetMember(obj, memberNames, 1, memberNames.Length - 2);
}
return null;
}
/// <summary>
/// Gets the member that matches the last item in the memberNames array.
/// </summary>
/// <param name="startIndex">The point at which to start looking in the memberNames.</param>
/// <param name="endIndex">The last memberNames item to look at.</param>
static object GetMember(object obj, string[] memberNames, int startIndex, int endIndex)
{
for (int i = startIndex; i <= endIndex; ++i) {
Type type = obj.GetType();
string name = memberNames[i];
// Try class members excluding inherited members first.
BindingFlags propertyBindingFlags = BindingFlags.Public | BindingFlags.GetField | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly;
PropertyInfo property = type.GetProperty(name, propertyBindingFlags);
if (property == null) {
// Try inherited members.
propertyBindingFlags = propertyBindingFlags & ~BindingFlags.DeclaredOnly;
property = type.GetProperty(name, propertyBindingFlags);
}
if (property != null) {
obj = property.GetValue(obj, null);
} else {
return null;
}
}
return obj;
}
static string GetMemberName(string[] names)
{
return String.Join(".", names);
}
/// <summary>
/// Gets the variable name from an expression of the form:
///
/// self._textBox1.Name
///
/// Returns "textBox1"
/// </summary>
/// <remarks>
/// If there is no self part then the variable name is the first part of the name.
/// </remarks>
static string GetVariableNameFromSelfReference(string name)
{
if (ContainsSelfReference(name)) {
name = name.Substring(5);
}
int endIndex = name.IndexOf('.');
if (endIndex > 0) {
return GetVariableName(name.Substring(0, endIndex));
} else if (name.StartsWith("_")) {
return GetVariableName(name);
}
return String.Empty;
}
static PythonControlFieldExpression Create(string[] memberNames)
{
string memberName = String.Empty;
if (memberNames.Length > 1) {
memberName = memberNames[memberNames.Length - 1];
}
string fullMemberName = PythonControlFieldExpression.GetMemberName(memberNames);
return new PythonControlFieldExpression(memberName, GetVariableNameFromSelfReference(fullMemberName), String.Empty, fullMemberName);
}
static bool ContainsSelfReference(string name)
{
return name.StartsWith("self.", StringComparison.InvariantCultureIgnoreCase);
}
static bool ContainsSelfReference(string[] members)
{
if (members.Length > 0) {
return "self".Equals(members[0], StringComparison.InvariantCultureIgnoreCase);
}
return false;
}
/// <summary>
/// Returns the index into the members array where the members actually start.
/// The "self" and variable name are skipped.
/// </summary>
int GetMembersStartIndex(string[] members)
{
if (ContainsSelfReference(members)) {
// Skip self over when searching for member.
return 2;
}
return 1;
}
/// <summary>
/// Sets the value of a property on the component.
/// </summary>
bool SetPropertyValue(object component, string name, object propertyValue)
{
PropertyDescriptor property = GetProperty(component, name);
if (property != null) {
if (OverrideNameProperty(component, name)) {
propertyValue = variableName;
} else {
propertyValue = ConvertPropertyValue(property, propertyValue);
}
property.SetValue(component, propertyValue);
return true;
}
return false;
}
/// <summary>
/// Override the name property with the instance variable name when the component is a
/// ToolStripSeparator to support BindingNavigator separators using the same value for the
/// name property.
/// </summary>
bool OverrideNameProperty(object component, string property)
{
if (property == "Name") {
return component is ToolStripSeparator;
}
return false;
}
/// <summary>
/// Gets the component that this field refers to.
/// </summary>
object GetComponent(IComponentCreator componentCreator)
{
object component = null;
if (IsSelfReference) {
component = GetObject(componentCreator);
component = GetObjectForMemberName(component);
} else {
component = componentCreator.GetInstance(variableName);
}
return component;
}
static PropertyDescriptor GetProperty(object component, string name)
{
return TypeDescriptor.GetProperties(component).Find(name, true);
}
}
}

103
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerGenerator.cs

@ -1,103 +0,0 @@ @@ -1,103 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Text;
using ICSharpCode.FormsDesigner;
using ICSharpCode.Scripting;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Form's designer generator for the Python language.
/// </summary>
public class PythonDesignerGenerator : ScriptingDesignerGenerator
{
public PythonDesignerGenerator(ITextEditorOptions textEditorOptions)
: base(textEditorOptions)
{
}
public override IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
{
return new PythonCodeDomSerializer(options.IndentationString);
}
/// <summary>
/// Returns the generated event handler.
/// </summary>
public override string CreateEventHandler(string eventMethodName, string body, string indentation)
{
if (String.IsNullOrEmpty(body)) {
body = "pass";
}
StringBuilder eventHandler = new StringBuilder();
eventHandler.Append(indentation);
eventHandler.Append("def ");
eventHandler.Append(eventMethodName);
eventHandler.Append("(self, sender, e):");
eventHandler.AppendLine();
eventHandler.Append(indentation);
eventHandler.Append(TextEditorOptions.IndentationString);
eventHandler.Append(body);
return eventHandler.ToString();
}
/// <summary>
/// Converts from the DOM region to a document region.
/// </summary>
public override DomRegion GetBodyRegionInDocument(IMethod method)
{
DomRegion bodyRegion = method.BodyRegion;
return new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1);
}
public override int InsertEventHandler(IDocument document, string eventHandler)
{
int line = document.TotalNumberOfLines;
IDocumentLine lastLineSegment = document.GetLine(line);
int offset = lastLineSegment.Offset + lastLineSegment.Length;
string newContent = "\r\n" + eventHandler;
if (lastLineSegment.Length > 0) {
// Add an extra new line between the last line and the event handler.
newContent = "\r\n" + newContent;
}
document.Insert(offset, newContent);
// Set position so it points to the line
// where the event handler was inserted.
return line + 1;
}
}
}

43
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerLoader.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Security.Permissions;
using ICSharpCode.Scripting;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Loads the form or control's code so the forms designer can
/// display it.
/// </summary>
[PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
[PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
public class PythonDesignerLoader : ScriptingDesignerLoader
{
public PythonDesignerLoader(IScriptingDesignerGenerator generator)
: base(generator)
{
}
protected override IComponentWalker CreateComponentWalker(IComponentCreator componentCreator)
{
return new PythonComponentWalker(componentCreator);
}
}
}

37
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerLoaderProvider.cs

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel.Design.Serialization;
using ICSharpCode.FormsDesigner;
using ICSharpCode.Scripting;
namespace ICSharpCode.PythonBinding
{
public class PythonDesignerLoaderProvider : IDesignerLoaderProvider
{
public PythonDesignerLoaderProvider()
{
}
public DesignerLoader CreateLoader(IDesignerGenerator generator)
{
return new PythonDesignerLoader(generator as IScriptingDesignerGenerator);
}
}
}

91
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonExpression.cs

@ -1,91 +0,0 @@ @@ -1,91 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Hosting.Providers;
using Microsoft.Scripting.Runtime;
using IronPython.Compiler;
using IronPython.Runtime;
namespace ICSharpCode.PythonBinding
{
public class PythonExpression
{
Tokenizer tokenizer;
Token currentToken;
public PythonExpression(ScriptEngine engine, string expression)
{
Init(engine, expression);
}
void Init(ScriptEngine engine, string expression)
{
PythonContext context = HostingHelpers.GetLanguageContext(engine) as PythonContext;
SourceUnit source = CreateSourceUnit(context, expression);
CreateTokenizer(source);
}
SourceUnit CreateSourceUnit(PythonContext context, string expression)
{
StringTextContentProvider textProvider = new StringTextContentProvider(expression);
return context.CreateSourceUnit(textProvider, String.Empty, SourceCodeKind.SingleStatement);
}
void CreateTokenizer(SourceUnit source)
{
PythonCompilerSink sink = new PythonCompilerSink();
PythonCompilerOptions options = new PythonCompilerOptions();
tokenizer = new Tokenizer(sink, options);
tokenizer.Initialize(source);
}
public Token GetNextToken()
{
currentToken = tokenizer.GetNextToken();
return currentToken;
}
public Token CurrentToken {
get { return currentToken; }
}
public bool IsImportToken(Token token)
{
return token.Kind == IronPython.Compiler.TokenKind.KeywordImport;
}
public bool IsFromToken(Token token)
{
return token.Kind == IronPython.Compiler.TokenKind.KeywordFrom;
}
public bool IsDotToken(Token token)
{
return token.Kind == IronPython.Compiler.TokenKind.Dot;
}
public bool IsNameToken(Token token)
{
return token.Kind == IronPython.Compiler.TokenKind.Name;
}
}
}

208
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonExpressionFinder.cs

@ -1,208 +0,0 @@ @@ -1,208 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PythonBinding
{
/// <summary>
/// Finds python expressions for code completion.
/// </summary>
public class PythonExpressionFinder : IExpressionFinder
{
class ExpressionRange
{
public int Start;
public int End;
public int Length {
get { return End - Start + 1; }
}
}
ExpressionRange expressionRange = new ExpressionRange();
public PythonExpressionFinder()
{
}
/// <summary>
/// Finds an expression around the current offset.
/// </summary>
/// <remarks>
/// Currently not implemented. This method is used heavily
/// in refactoring.
/// </remarks>
public ExpressionResult FindFullExpression(string text, int offset)
{
return new ExpressionResult(null);
}
/// <summary>
/// Removes the last part of the expression.
/// </summary>
/// <example>
/// "array[i]" => "array"
/// "myObject.Field" => "myObject"
/// "myObject.Method(arg1, arg2)" => "myObject.Method"
/// </example>
public string RemoveLastPart(string expression)
{
MemberName memberName = new MemberName(expression);
return memberName.Type;
}
/// <summary>
/// Finds an expression before the current offset.
/// </summary>
/// <remarks>
/// The expression is found before the specified offset. The
/// offset is just before the current cursor position. For example,
/// if the user presses the dot character then the offset
/// will be just before the dot. All characters before the offset and
/// at the offset are considered when looking for
/// the expression. All characters afterwards are ignored.
/// </remarks>
public ExpressionResult FindExpression(string text, int offset)
{
if (!IsValidFindExpressionParameters(text, offset)) {
return new ExpressionResult(null);
}
expressionRange.End = offset - 1;
expressionRange.Start = FindExpressionStart(text, expressionRange.End);
if (IsImportExpression(text)) {
ExtendRangeToStartOfLine(text);
return CreatePythonImportExpressionResult(text, expressionRange);
}
return CreateDefaultExpressionResult(text, expressionRange);
}
bool IsValidFindExpressionParameters(string text, int offset)
{
return (text != null) && IsValidOffset(text, offset);
}
/// <summary>
/// This checks that the offset passed to the FindExpression method is valid. Usually the offset is
/// just after the last character in the text.
///
/// The offset must be:
///
/// 1) Greater than zero.
/// 2) Be inside the string.
/// 3) Be just after the end of the text.
/// </summary>
bool IsValidOffset(string text, int offset)
{
return (offset > 0) && (offset <= text.Length);
}
int FindExpressionStart(string text, int offset)
{
while (offset >= 0) {
char currentChar = text[offset];
switch (currentChar) {
case '\n':
case '\r':
case '\t':
case ' ':
return offset + 1;
}
offset--;
}
return 0;
}
bool IsImportExpression(string text)
{
if (PythonImportExpression.IsImportExpression(text, expressionRange.End)) {
return true;
}
if (IsSpaceCharacterBeforeExpression(text, expressionRange)) {
if (PythonImportExpression.IsImportExpression(text, expressionRange.Start)) {
return true;
}
}
return false;
}
bool IsSpaceCharacterBeforeExpression(string text, ExpressionRange range)
{
int characterBeforeExpressionOffset = range.Start - 1;
if (characterBeforeExpressionOffset >= 0) {
return text[characterBeforeExpressionOffset] == ' ';
}
return false;
}
void ExtendRangeToStartOfLine(string text)
{
if (expressionRange.Start > expressionRange.End) {
expressionRange.Start = expressionRange.End;
}
expressionRange.Start = FindLineStart(text, expressionRange.Start);
}
/// <summary>
/// Finds the start of the line in the text starting from the
/// offset and working backwards.
/// </summary>
int FindLineStart(string text, int offset)
{
while (offset >= 0) {
char currentChar = text[offset];
switch (currentChar) {
case '\n':
return offset + 1;
}
--offset;
}
return 0;
}
ExpressionResult CreatePythonImportExpressionResult(string text, ExpressionRange range)
{
return CreateExpressionResult(text, range, new PythonImportExpressionContext());
}
ExpressionResult CreateDefaultExpressionResult(string text, ExpressionRange range)
{
return CreateExpressionResult(text, range, ExpressionContext.Default);
}
ExpressionResult CreateExpressionResult(string text, ExpressionRange range, ExpressionContext context)
{
string expression = Substring(text, range);
return new ExpressionResult(expression, context);
}
/// <summary>
/// Gets the substring starting from the specified index and
/// finishing at the specified end index. The character at the
/// end index is included in the string.
/// </summary>
string Substring(string text, ExpressionRange range)
{
return text.Substring(range.Start, range.Length);
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save