From 718184554a03545d227525f81f5d1b49d31c826d Mon Sep 17 00:00:00 2001 From: Jon Crenshaw Date: Wed, 17 Feb 2016 21:54:08 -0800 Subject: [PATCH 1/2] Add Apex language support Include support for Salesforce's Java-like "Apex" language --- docs/options.md | 26 ++++++++++++++++++++++++- package.json | 1 + spec/beautify-languages-spec.coffee | 4 ++-- src/beautifiers/uncrustify/index.coffee | 3 +++ src/languages/apex.coffee | 26 +++++++++++++++++++++++++ src/languages/index.coffee | 1 + 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/languages/apex.coffee diff --git a/docs/options.md b/docs/options.md index c57fabe..7c0135b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -125,7 +125,31 @@ Supported options for each language. --- -#### [Arduino - Config Path](#arduino---config-path) +#### [Apex - Config Path](#apex---config-path) + +**Namespace**: `apex` + +**Key**: `configPath` + +**Type**: `string` + +**Supported Beautifiers**: [`Uncrustify`](#uncrustify) + +**Description**: + +Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "apex": { + "configPath": "" + } +} +``` + +#### [Arduino - Config Path](#arduino---config-path) **Namespace**: `arduino` diff --git a/package.json b/package.json index 2c7bd7d..28670b0 100644 --- a/package.json +++ b/package.json @@ -149,6 +149,7 @@ "c#", "uncrustify", "java", + "apex", "pawn", "vala", "d", diff --git a/spec/beautify-languages-spec.coffee b/spec/beautify-languages-spec.coffee index 293dc45..e5d1f03 100644 --- a/spec/beautify-languages-spec.coffee +++ b/spec/beautify-languages-spec.coffee @@ -21,7 +21,7 @@ describe "BeautifyLanguages", -> # Activate all of the languages allLanguages = [ - "c", "coffee-script", "css", "html", + "apex", "c", "coffee-script", "css", "html", "java", "javascript", "json", "less", "mustache", "objective-c", "perl", "php", "python", "ruby", "sass", "sql", "svg", @@ -61,7 +61,7 @@ describe "BeautifyLanguages", -> # Set Uncrustify config path # uncrustifyConfigPath = path.resolve(__dirname, "../examples/nested-jsbeautifyrc/uncrustify.cfg") - # uncrustifyLangs = ["c", "cpp", "objectivec", "cs", "d", "java", "pawn", "vala"] + # uncrustifyLangs = ["apex", "c", "cpp", "objectivec", "cs", "d", "java", "pawn", "vala"] # for lang in uncrustifyLangs # do (lang) -> # atom.config.set("atom-beautify.#{lang}_configPath", uncrustifyConfigPath) diff --git a/src/beautifiers/uncrustify/index.coffee b/src/beautifiers/uncrustify/index.coffee index 56f2c4d..f60a522 100644 --- a/src/beautifiers/uncrustify/index.coffee +++ b/src/beautifiers/uncrustify/index.coffee @@ -11,6 +11,7 @@ _ = require('lodash') module.exports = class Uncrustify extends Beautifier name: "Uncrustify" options: { + Apex: true C: true "C++": true "C#": true @@ -50,6 +51,8 @@ module.exports = class Uncrustify extends Beautifier # Select Uncrustify language lang = "C" # Default is C switch language + when "Apex" + lang = "Apex" when "C" lang = "C" when "C++" diff --git a/src/languages/apex.coffee b/src/languages/apex.coffee new file mode 100644 index 0000000..5757f4c --- /dev/null +++ b/src/languages/apex.coffee @@ -0,0 +1,26 @@ +module.exports = { + + name: "Apex" + namespace: "apex" + + ### + Supported Grammars + ### + grammars: [ + "Apex" + ] + + ### + Supported extensions + ### + extensions: [ + "cls" + ] + + options: + configPath: + type: 'string' + default: "" + description: "Path to uncrustify config file. i.e. uncrustify.cfg" + +} diff --git a/src/languages/index.coffee b/src/languages/index.coffee index 895b5b2..49afbd8 100644 --- a/src/languages/index.coffee +++ b/src/languages/index.coffee @@ -12,6 +12,7 @@ module.exports = class Languages # Supported unique configuration keys # Used for detecting nested configurations in .jsbeautifyrc languageNames: [ + "apex" "arduino" "c-sharp" "c" From f4000cc990c8644dfb2f2595d5c103fde9265c9a Mon Sep 17 00:00:00 2001 From: Jon Crenshaw Date: Fri, 19 Feb 2016 20:25:11 -0800 Subject: [PATCH 2/2] Add examples for Apex language --- .../apex/expected/test.java | 19 +++++++++++++++++++ .../apex/original/test.java | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 examples/nested-jsbeautifyrc/apex/expected/test.java create mode 100644 examples/nested-jsbeautifyrc/apex/original/test.java diff --git a/examples/nested-jsbeautifyrc/apex/expected/test.java b/examples/nested-jsbeautifyrc/apex/expected/test.java new file mode 100644 index 0000000..7417279 --- /dev/null +++ b/examples/nested-jsbeautifyrc/apex/expected/test.java @@ -0,0 +1,19 @@ +class Aligns { + final int SZF = 4; + final int SZ2F = 4; + final int aBarF; + final int[] someMoreIntsF; + final Tem edVarF; + final int aBarSetF=null; + final int[] someMoreIntsSetF=null; + final Tem edVarF=null; + int SZ = 4; + int SZ2 = 4; + int aBar; + int spacer; + int[] someMoreInts; + Tem edVar; + int aBarSet=null; + int[] someMoreIntsSet=null; + Tem edVar=null; +} diff --git a/examples/nested-jsbeautifyrc/apex/original/test.java b/examples/nested-jsbeautifyrc/apex/original/test.java new file mode 100644 index 0000000..07d46c0 --- /dev/null +++ b/examples/nested-jsbeautifyrc/apex/original/test.java @@ -0,0 +1,19 @@ +class Aligns { +final Integer SZF = 4; +final Integer SZ2F = 4; +final Integer aBarF; +final Integer[] someMoreIntegersF; +final Tem edVarF; +final Integer aBarSetF=null; +final Integer[] someMoreIntegersSetF=null; +final Tem edVarF=null; +Integer SZ = 4; +Integer SZ2 = 4; +Integer aBar; +Integer spacer; +Integer[] someMoreIntegers; +Tem edVar; +Integer aBarSet=null; +Integer[] someMoreIntegersSet=null; +Tem edVar=null; +}