From e851fe6a3dd4dc54f4409e95866dc5304c5a15bb Mon Sep 17 00:00:00 2001 From: SushiHangover Date: Thu, 5 Nov 2015 06:00:54 -0800 Subject: [PATCH] Initial Commit --- .gitignore | 40 ++ PlayScript.Addin.sln | 17 + PlayScript.Addin/PlayScript.Addin.csproj | 52 +++ .../PlayScript/ActionScriptLanguageBinding.cs | 84 +++++ .../PlayScript/PlayScriptLanguageBinding.cs | 103 ++++++ .../Project/PlayScriptCompilerParameters.cs | 306 +++++++++++++++ .../Project/PlayScriptProjectParameters.cs | 10 + PlayScript.Addin/Properties/AddinInfo.cs | 15 + PlayScript.Addin/Properties/AssemblyInfo.cs | 27 ++ .../Properties/Manifest.addin.xml | 38 ++ .../SyntaxMode/ActionScriptSyntaxMode.xml | 122 ++++++ .../SyntaxMode/PlayScriptSyntaxMode.xml | 348 ++++++++++++++++++ PlayScript.Addin/packages.config | 4 + 13 files changed, 1166 insertions(+) create mode 100644 .gitignore create mode 100644 PlayScript.Addin.sln create mode 100644 PlayScript.Addin/PlayScript.Addin.csproj create mode 100644 PlayScript.Addin/PlayScript/ActionScriptLanguageBinding.cs create mode 100644 PlayScript.Addin/PlayScript/PlayScriptLanguageBinding.cs create mode 100644 PlayScript.Addin/PlayScript/Project/PlayScriptCompilerParameters.cs create mode 100644 PlayScript.Addin/PlayScript/Project/PlayScriptProjectParameters.cs create mode 100644 PlayScript.Addin/Properties/AddinInfo.cs create mode 100644 PlayScript.Addin/Properties/AssemblyInfo.cs create mode 100644 PlayScript.Addin/Properties/Manifest.addin.xml create mode 100644 PlayScript.Addin/SyntaxMode/ActionScriptSyntaxMode.xml create mode 100644 PlayScript.Addin/SyntaxMode/PlayScriptSyntaxMode.xml create mode 100644 PlayScript.Addin/packages.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6527bbc --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +#Autosave files +*~ + +#build +[Oo]bj/ +[Bb]in/ +packages/ +TestResults/ + +# globs +Makefile.in +*.DS_Store +*.sln.cache +*.suo +*.cache +*.pidb +*.userprefs +*.usertasks +config.log +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.user +*.tar.gz +tarballs/ +test-results/ +Thumbs.db + +#Mac bundle stuff +*.dmg +*.app + +#resharper +*_Resharper.* +*.Resharper + +#dotCover +*.dotCover diff --git a/PlayScript.Addin.sln b/PlayScript.Addin.sln new file mode 100644 index 0000000..b53cb4c --- /dev/null +++ b/PlayScript.Addin.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlayScript.Addin", "PlayScript.Addin\PlayScript.Addin.csproj", "{DAE22D85-7821-4492-96BB-73B73CC6BA6D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DAE22D85-7821-4492-96BB-73B73CC6BA6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DAE22D85-7821-4492-96BB-73B73CC6BA6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DAE22D85-7821-4492-96BB-73B73CC6BA6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DAE22D85-7821-4492-96BB-73B73CC6BA6D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/PlayScript.Addin/PlayScript.Addin.csproj b/PlayScript.Addin/PlayScript.Addin.csproj new file mode 100644 index 0000000..c8ae287 --- /dev/null +++ b/PlayScript.Addin/PlayScript.Addin.csproj @@ -0,0 +1,52 @@ + + + + Debug + AnyCPU + {86F6BF2A-E449-4B3E-813B-9ACC37E5545F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {DAE22D85-7821-4492-96BB-73B73CC6BA6D} + Library + PlayScript.Addin + PlayScript.Addin + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + full + true + bin\Release + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PlayScript.Addin/PlayScript/ActionScriptLanguageBinding.cs b/PlayScript.Addin/PlayScript/ActionScriptLanguageBinding.cs new file mode 100644 index 0000000..291ca1a --- /dev/null +++ b/PlayScript.Addin/PlayScript/ActionScriptLanguageBinding.cs @@ -0,0 +1,84 @@ +using System; +using System.IO; +using System.Xml; +using System.Reflection; +using System.CodeDom.Compiler; +using System.Collections.Generic; + +using MonoDevelop.Projects; +using MonoDevelop.Core; +using Mono.TextEditor.Highlighting; + +namespace PlayScript.Addin +{ + public class ActionScriptLanguageBinding : IDotNetLanguageBinding + { + public ActionScriptLanguageBinding() { + SyntaxModeService.LoadStylesAndModes (Assembly.GetExecutingAssembly ()); + } + + public static IList SupportedPlatforms = new string[] { "anycpu", "x86", "x64", "itanium" }; + + public string Language { + get { + return "ActionScript"; + } + } + + public string ProjectStockIcon { + get { +// TODO: Add custom icon +// return "md-playscript-project"; + return "md-project"; + } + } + + public FilePath GetFileName (FilePath baseName) + { + return baseName + ".as"; + } + + public bool IsSourceCodeFile (FilePath fileName) + { + return StringComparer.OrdinalIgnoreCase.Equals (Path.GetExtension (fileName), ".as"); + } + + public string SingleLineCommentTag { get { return "//"; } } + public string BlockCommentStartTag { get { return "/*"; } } + public string BlockCommentEndTag { get { return "*/"; } } + + + public BuildResult Compile (ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor) + { + return null; + } + + public ConfigurationParameters CreateCompilationParameters (XmlElement projectOptions) + { + return null; + } + + public ProjectParameters CreateProjectParameters (XmlElement projectOptions) + { + return new PlayScriptProjectParameters (); + } + + + public CodeDomProvider GetCodeDomProvider () + { + return null; + } + + public ClrVersion[] GetSupportedClrVersions () + { + return new ClrVersion[] { + ClrVersion.Net_1_1, + ClrVersion.Net_2_0, + ClrVersion.Clr_2_1, + ClrVersion.Net_4_0, + ClrVersion.Net_4_5, + }; + } + } +} + diff --git a/PlayScript.Addin/PlayScript/PlayScriptLanguageBinding.cs b/PlayScript.Addin/PlayScript/PlayScriptLanguageBinding.cs new file mode 100644 index 0000000..59e03ed --- /dev/null +++ b/PlayScript.Addin/PlayScript/PlayScriptLanguageBinding.cs @@ -0,0 +1,103 @@ +using System; +using System.IO; +using System.Xml; +using System.Reflection; +using System.CodeDom.Compiler; +using System.Collections.Generic; + +using MonoDevelop.Projects; +using MonoDevelop.Core; +using Mono.TextEditor.Highlighting; + +namespace PlayScript.Addin +{ + public class PlayScriptLanguageBinding : IDotNetLanguageBinding + { + public PlayScriptLanguageBinding() { + SyntaxModeService.LoadStylesAndModes (Assembly.GetExecutingAssembly ()); + } +// CSharpCodeProvider provider; + + // Keep the platforms combo of CodeGenerationPanelWidget in sync with this list + public static IList SupportedPlatforms = new string[] { "anycpu", "x86", "x64", "itanium" }; + + public string Language { + get { + return "PlayScript"; + } + } + + public string ProjectStockIcon { + get { +// TODO: Add custom icon +// return "md-playscript-project"; + return "md-project"; + } + } + + public FilePath GetFileName (FilePath baseName) + { + return baseName + ".play"; + } + + public bool IsSourceCodeFile (FilePath fileName) + { + return StringComparer.OrdinalIgnoreCase.Equals (Path.GetExtension (fileName), ".play"); + } + + public string SingleLineCommentTag { get { return "//"; } } + public string BlockCommentStartTag { get { return "/*"; } } + public string BlockCommentEndTag { get { return "*/"; } } + + + public BuildResult Compile (ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor) + { +// return CSharpBindingCompilerManager.Compile (projectItems, configuration, configSelector, monitor); + return null; + } + + public ConfigurationParameters CreateCompilationParameters (XmlElement projectOptions) + { +// PlayScriptCompilerParameters pars = new PlayScriptCompilerParameters (); +// if (projectOptions != null) { +// string platform = projectOptions.GetAttribute ("Platform"); +// if (SupportedPlatforms.Contains (platform)) +// pars.PlatformTarget = platform; +// string debugAtt = projectOptions.GetAttribute ("DefineDebug"); +// if (string.Compare ("True", debugAtt, StringComparison.OrdinalIgnoreCase) == 0) +// pars.AddDefineSymbol ("DEBUG"); +// string releaseAtt = projectOptions.GetAttribute ("Release"); +// if (string.Compare ("True", releaseAtt, StringComparison.OrdinalIgnoreCase) == 0) +// pars.Optimize = true; +// } +// return pars; + return null; + } + + public ProjectParameters CreateProjectParameters (XmlElement projectOptions) + { + return new PlayScriptProjectParameters (); + } + + + public CodeDomProvider GetCodeDomProvider () + { +// if (provider == null) +// provider = new CSharpEnhancedCodeProvider (); +// return provider; + return null; + } + + public ClrVersion[] GetSupportedClrVersions () + { + return new ClrVersion[] { + ClrVersion.Net_1_1, + ClrVersion.Net_2_0, + ClrVersion.Clr_2_1, + ClrVersion.Net_4_0, + ClrVersion.Net_4_5, + }; + } + } +} + diff --git a/PlayScript.Addin/PlayScript/Project/PlayScriptCompilerParameters.cs b/PlayScript.Addin/PlayScript/Project/PlayScriptCompilerParameters.cs new file mode 100644 index 0000000..d6df327 --- /dev/null +++ b/PlayScript.Addin/PlayScript/Project/PlayScriptCompilerParameters.cs @@ -0,0 +1,306 @@ +using System; +using System.Collections.Generic; + +using MonoDevelop.Projects; +using MonoDevelop.Core.Serialization; + +namespace PlayScript.Addin +{ + public enum LangVersion { + Default = 0, + ISO_1 = 1, + ISO_2 = 2, + Version3 = 3, + Version4 = 4, + Version5 = 5 + } + + /// + /// This class handles project specific compiler parameters + /// + public class PlayScriptCompilerParameters: ConfigurationParameters + { + // Configuration parameters + + [ItemProperty ("WarningLevel")] + int warninglevel = 4; + + [ItemProperty ("NoWarn", DefaultValue = "")] + string noWarnings = String.Empty; + + [ItemProperty ("Optimize")] + bool optimize; + + [ItemProperty ("AllowUnsafeBlocks", DefaultValue = false)] + bool unsafecode = false; + + [ItemProperty ("CheckForOverflowUnderflow", DefaultValue = false)] + bool generateOverflowChecks; + + [ItemProperty ("DefineConstants", DefaultValue = "")] + string definesymbols = String.Empty; + + [ItemProperty ("GenerateDocumentation", DefaultValue = false)] + bool generateXmlDocumentation = false; + + [ItemProperty ("additionalargs", DefaultValue = "")] + string additionalArgs = string.Empty; + + [ItemProperty ("LangVersion", DefaultValue = "Default")] + string langVersion = "Default"; + + [ItemProperty ("NoStdLib", DefaultValue = false)] + bool noStdLib; + + [ItemProperty ("TreatWarningsAsErrors", DefaultValue = false)] + bool treatWarningsAsErrors; + + [ItemProperty("PlatformTarget", DefaultValue="anycpu")] + string platformTarget = "anycpu"; + + [ItemProperty("WarningsNotAsErrors", DefaultValue="")] + string warningsNotAsErrors = ""; + + [ItemProperty("DebugType", DefaultValue="")] + string debugType = ""; + + #region Members required for backwards compatibility. Not used for anything else. + + [ItemProperty ("StartupObject", DefaultValue = null)] + internal string mainclass; + + [ProjectPathItemProperty ("ApplicationIcon", DefaultValue = null)] + internal string win32Icon; + + [ProjectPathItemProperty ("Win32Resource", DefaultValue = null)] + internal string win32Resource; + + [ItemProperty ("CodePage", DefaultValue = null)] + internal string codePage; + + #endregion + + + protected override void OnEndLoad () + { + base.OnEndLoad (); + + // Backwards compatibility. Move parameters to the project parameters object + if (ParentConfiguration != null && ParentConfiguration.ProjectParameters != null) { + PlayScriptProjectParameters cparams = (PlayScriptProjectParameters) ParentConfiguration.ProjectParameters; +// if (win32Icon != null) { +// cparams.Win32Icon = win32Icon; +// win32Icon = null; +// } +// if (win32Resource != null) { +// cparams.Win32Resource = win32Resource; +// win32Resource = null; +// } +// if (mainclass != null) { +// cparams.MainClass = mainclass; +// mainclass = null; +// } +// if (!string.IsNullOrEmpty (codePage)) { +// cparams.CodePage = int.Parse (codePage); +// codePage = null; +// } + } + } + + public string AdditionalArguments { + get { return additionalArgs; } + set { additionalArgs = value ?? string.Empty; } + } + + public LangVersion LangVersion { + get { + var val = TryLangVersionFromString (langVersion); + if (val == null) { + throw new Exception ("Unknown LangVersion string '" + val + "'"); + } + return val.Value; + } + set { + var v = TryLangVersionToString (value); + if (v == null) { + throw new ArgumentOutOfRangeException ("Unknown LangVersion enum value '" + value + "'"); + } + langVersion = v; + } + } + +// public override void AddDefineSymbol (string symbol) +// { +// var symbols = new List (definesymbols.Split (new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); +// +// symbols.Add (symbol); +// +// definesymbols = string.Join (";", symbols) + ";"; +// } + +// public override bool HasDefineSymbol (string symbol) +// { +// var symbols = definesymbols.Split (new char[] { ';' }); +// +// foreach (var sym in symbols) { +// if (sym == symbol) +// return true; +// } +// +// return false; +// } + +// public override void RemoveDefineSymbol (string symbol) +// { +// var symbols = new List (definesymbols.Split (new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); +// +// symbols.Remove (symbol); +// +// if (symbols.Count > 0) +// definesymbols = string.Join (";", symbols) + ";"; +// else +// definesymbols = string.Empty; +// } + + #region Code Generation + + public string DefineSymbols { + get { + return definesymbols; + } + set { + definesymbols = value ?? string.Empty; + } + } + + public bool Optimize { + get { + return optimize; + } + set { + optimize = value; + } + } + + public bool UnsafeCode { + get { + return unsafecode; + } + set { + unsafecode = value; + } + } + + public bool GenerateOverflowChecks { + get { + return generateOverflowChecks; + } + set { + generateOverflowChecks = value; + } + } + + public bool GenerateXmlDocumentation { + get { + return generateXmlDocumentation; + } + set { + generateXmlDocumentation = value; + } + } + + public string PlatformTarget { + get { + return platformTarget; + } + set { + platformTarget = value ?? string.Empty; + } + } + + public string DebugType { + get { + return debugType; + } + set { + debugType = value; + } + } + + #endregion + + #region Errors and Warnings + public int WarningLevel { + get { + return warninglevel; + } + set { + warninglevel = value; + } + } + + public string NoWarnings { + get { + return noWarnings; + } + set { + noWarnings = value; + } + } + + public bool NoStdLib { + get { + return noStdLib; + } + set { + noStdLib = value; + } + } + + public bool TreatWarningsAsErrors { + get { + return treatWarningsAsErrors; + } + set { + treatWarningsAsErrors = value; + } + } + + public string WarningsNotAsErrors { + get { + return warningsNotAsErrors; + } + set { + warningsNotAsErrors = value; + } + } + #endregion + + static LangVersion? TryLangVersionFromString (string value) + { + switch (value) { + case "Default": return LangVersion.Default; + case "ISO-1": return LangVersion.ISO_1; + case "ISO-2": return LangVersion.ISO_2; + case "3": return LangVersion.Version3; + case "4": return LangVersion.Version4; + case "5": return LangVersion.Version5; + default: return null; + } + } + + internal static string TryLangVersionToString (LangVersion value) + { + switch (value) { + case LangVersion.Default: return "Default"; + case LangVersion.ISO_1: return "ISO-1"; + case LangVersion.ISO_2: return "ISO-2"; + case LangVersion.Version3: return "3"; + case LangVersion.Version4: return "4"; + case LangVersion.Version5: return "5"; + default: return null; + } + } + } + } + diff --git a/PlayScript.Addin/PlayScript/Project/PlayScriptProjectParameters.cs b/PlayScript.Addin/PlayScript/Project/PlayScriptProjectParameters.cs new file mode 100644 index 0000000..b31baea --- /dev/null +++ b/PlayScript.Addin/PlayScript/Project/PlayScriptProjectParameters.cs @@ -0,0 +1,10 @@ +using System; +using MonoDevelop.Projects; + +namespace PlayScript.Addin +{ + public class PlayScriptProjectParameters : ConfigurationParameters + { + } +} + diff --git a/PlayScript.Addin/Properties/AddinInfo.cs b/PlayScript.Addin/Properties/AddinInfo.cs new file mode 100644 index 0000000..d9c2e34 --- /dev/null +++ b/PlayScript.Addin/Properties/AddinInfo.cs @@ -0,0 +1,15 @@ +using System; +using Mono.Addins; +using Mono.Addins.Description; + +[assembly:Addin ( + "PlayScript.Addin", + Namespace = "PlayScript.Addin", + Version = "1.0" +)] + +[assembly:AddinName ("PlayScript.Addin")] +[assembly:AddinCategory ("IDE extensions")] +[assembly:AddinDescription ("PlayScript.Addin")] +[assembly:AddinAuthor ("sushihangover")] + diff --git a/PlayScript.Addin/Properties/AssemblyInfo.cs b/PlayScript.Addin/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d626b40 --- /dev/null +++ b/PlayScript.Addin/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("PlayScript.Addin")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("http://sushihangover.github.io")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("SushiHangover/RobertN")] +[assembly: AssemblyTrademark ("All rights reserved : SushiHangover/RobertN")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/PlayScript.Addin/Properties/Manifest.addin.xml b/PlayScript.Addin/Properties/Manifest.addin.xml new file mode 100644 index 0000000..b37efba --- /dev/null +++ b/PlayScript.Addin/Properties/Manifest.addin.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PlayScript.Addin/SyntaxMode/ActionScriptSyntaxMode.xml b/PlayScript.Addin/SyntaxMode/ActionScriptSyntaxMode.xml new file mode 100644 index 0000000..858953d --- /dev/null +++ b/PlayScript.Addin/SyntaxMode/ActionScriptSyntaxMode.xml @@ -0,0 +1,122 @@ + + + + // + + /* + */ + + + + " + " + + + + ' + ' + + + CSharpNumber + + + this + + + + new + typeof + + + + else + if + + + + do + for + while + + + + break + continue + return + + + + try + throw + catch + finally + + + + true + false + null + + + + void + + + + var + + + + function + class + + + + public + protected + private + internal + static + override + extends + + + + package + import + use + namespace + + + + + TODO + FIXME + HACK + UNDONE + + + diff --git a/PlayScript.Addin/SyntaxMode/PlayScriptSyntaxMode.xml b/PlayScript.Addin/SyntaxMode/PlayScriptSyntaxMode.xml new file mode 100644 index 0000000..738e9a8 --- /dev/null +++ b/PlayScript.Addin/SyntaxMode/PlayScriptSyntaxMode.xml @@ -0,0 +1,348 @@ + + + + // + /* + */ + " + ' + + #if + #else + #elif + #endif + #define + #undef + #warning + #error + #line + #region + #endregion + #pragma + + + + /// + // + + + /* + */ + + + + @" + " + + + + " + " + + + + ' + ' + + + CSharpNumber + + + + + - + * + / + % + ^ + + ? + : + + & + + = + ; + , + . + + + + ( + ) + < + > + { + } + [ + ] + + + + this + super + + + + as + is + new + sizeof + typeof + + + + else + if + switch + case + default + + + + do + for + each + in + while + + + + break + continue + goto + return + + + + extends + implements + yield + partial + global + where + by + descending + from + group + into + orderby + select + let + ascending + join + on + equals + + + + try + throw + catch + finally + + + + true + false + null + undefined + Infinitiy + + + + abstract + async + await + const + event + extern + override + readonly + final + static + virtual + volatile + public + protected + private + internal + dynamic + + + + bool + byte + char + decimal + double + float + int + long + sbyte + short + uint + ushort + ulong + object + string + var + String + Number + Boolean + + + + void + + + + package + import + use + namespace + + + + get + set + add + remove + value + + + + class + interface + enum + struct + function + property + indexer + + + + params + ref + out + + + + explicit + implicit + operator + + + + checked + unchecked + fixed + unsafe + lock + + + + + + true + false + + + + == + != + ! + && + || + + + + ( + ) + + + + /// + // + + + + /// + // + + + + + + hidden + default + + + + " + " + + + CSharpNumber + + /// + // + + + + + + TODO + FIXME + HACK + UNDONE + + + + + + \\(['"\\abfnrtv]|x[0-9a-fA-F]{2,4}|0\d\d) + + + + + "" + + + + <> + + + < + > + + + + + + + + + diff --git a/PlayScript.Addin/packages.config b/PlayScript.Addin/packages.config new file mode 100644 index 0000000..f853e23 --- /dev/null +++ b/PlayScript.Addin/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file