diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..d888431217 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "formatting-styles/textmate"] + path = formatting-styles/textmate + url = https://github.com/sarl/sarl-textmate.git diff --git a/formatting-styles/textmate b/formatting-styles/textmate new file mode 160000 index 0000000000..b086c0665f --- /dev/null +++ b/formatting-styles/textmate @@ -0,0 +1 @@ +Subproject commit b086c0665f3e85b39182a846a661b95d147d0e2f diff --git a/formatting-styles/textmate/README b/formatting-styles/textmate/README deleted file mode 100644 index 3ad2fc2bee..0000000000 --- a/formatting-styles/textmate/README +++ /dev/null @@ -1,4 +0,0 @@ -1. MANUAL INSTALLATION - -Copy the sarl.plistfile into one of the following folders: -* Sublime Text 3: $HOME/.config/sublime-text-3/Packages/User/SARL/ diff --git a/formatting-styles/textmate/sarl.plist b/formatting-styles/textmate/sarl.plist deleted file mode 100644 index 181d20924c..0000000000 --- a/formatting-styles/textmate/sarl.plist +++ /dev/null @@ -1,138 +0,0 @@ -{ - foldingStartMarker = '\{\s*(//.*)?$'; - __sarlVersion = '0.6'; - scopeName = 'source.sarl'; - patterns = ( - { - endCaptures = { - 0 = { - name = 'punctuation.definition.comment.sarl' - } - }; - patterns = ( - { - match = '^\s*(\*)(?!/)'; - name = 'punctuation.definition.comment.sarl' - } - ); - name = 'comment.block.sarl'; - end = '(\*/)'; - comment = 'Multiline comments'; - beginCaptures = { - 0 = { - name = 'punctuation.definition.comment.sarl' - } - }; - begin = '(/\*+)' - }, - { - captures = { - 1 = { - name = 'comment.line.double-slash.sarl' - }; - 2 = { - name = 'comment.line.sarl' - } - }; - match = '\s*(//)(.*)$'; - comment = 'Single-line comment' - }, - { - endCaptures = { - 0 = { - name = 'punctuation.definition.string.begin.sarl' - } - }; - patterns = ( - { - match = '\\.'; - name = 'constant.character.escape.sarl' - } - ); - name = 'string.quoted.double.sarl'; - end = '"'; - comment = 'Double quoted strings of characters'; - beginCaptures = { - 0 = { - name = 'punctuation.definition.string.end.sarl' - } - }; - begin = '"' - }, - { - endCaptures = { - 0 = { - name = 'punctuation.definition.string.begin.sarl' - } - }; - patterns = ( - { - match = '\\.'; - name = 'constant.character.escape.sarl' - } - ); - name = 'string.quoted.single.sarl'; - end = ''''; - comment = 'Single quoted strings of characters'; - beginCaptures = { - 0 = { - name = 'punctuation.definition.string.end.sarl' - } - }; - begin = '''' - }, - { - match = '(?:[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fFdD]?)|(?:0[xX][0-9a-fA-F]+)|(?:[0-9]+[lL]?)'; - name = 'constant.numeric.sarl'; - comment = 'Numbers' - }, - { - match = '\@[_a-zA-Z$][_0-9a-zA-Z$]*'; - name = 'support.type.sarl'; - comment = 'Annotations' - }, - { - match = '\b(?:(?:false)|(?:it)|(?:null)|(?:occurrence)|(?:this)|(?:true)|(?:void))\b'; - name = 'constant.language.sarl'; - comment = 'SARL Literals and Constants' - }, - { - match = '\b(?:(?:boolean)|(?:byte)|(?:char)|(?:double)|(?:float)|(?:int)|(?:long)|(?:short)|(?:void))\b(?:\s*\[\s*\])*'; - name = 'storage.type.primitive.sarl'; - comment = 'Primitive types' - }, - { - match = '\b(?:(?:import)|(?:package))\b'; - name = 'keyword.other.special.sarl'; - comment = 'Special Keywords' - }, - { - match = '\b(?:(?:abstract)|(?:def)|(?:dispatch)|(?:final)|(?:native)|(?:override)|(?:private)|(?:protected)|(?:public)|(?:static)|(?:strictfp)|(?:synchronized)|(?:transient)|(?:val)|(?:var)|(?:volatile))\b'; - name = 'storage.modifier.sarl'; - comment = 'Modifiers' - }, - { - match = '\b(?:(?:agent)|(?:annotation)|(?:artifact)|(?:behavior)|(?:capacity)|(?:class)|(?:enum)|(?:event)|(?:interface)|(?:skill)|(?:space))\b'; - name = 'keyword.other.declaration.sarl'; - comment = 'Type Declarations' - }, - { - match = '\b(?:(?:as)|(?:break)|(?:case)|(?:catch)|(?:default)|(?:do)|(?:else)|(?:extends)|(?:extension)|(?:finally)|(?:fires)|(?:for)|(?:if)|(?:implements)|(?:instanceof)|(?:new)|(?:on)|(?:requires)|(?:return)|(?:super)|(?:switch)|(?:throw)|(?:throws)|(?:try)|(?:typeof)|(?:uses)|(?:while)|(?:with))\b'; - name = 'keyword.control.sarl'; - comment = 'Standard Keywords' - }, - { - match = '(?:\!)|(?:\!\=)|(?:\!\=\=)|(?:#)|(?:%)|(?:%\=)|(?:&)|(?:&&)|(?:\()|(?:\))|(?:\*)|(?:\*\*)|(?:\*/)|(?:\*\=)|(?:\+)|(?:\+\+)|(?:\+\=)|(?:,)|(?:\-)|(?:\-\-)|(?:\-\=)|(?:\-\>)|(?:\.)|(?:\.\.)|(?:\.\.\.)|(?:\.\.\<)|(?:/)|(?:/\*)|(?://)|(?:/\=)|(?:\:)|(?:\:\:)|(?:;)|(?:\<)|(?:\<\>)|(?:\=)|(?:\=\=)|(?:\=\=\=)|(?:\=\>)|(?:\>)|(?:\>\=)|(?:\?)|(?:\?\.)|(?:\?\:)|(?:@)|(?:\[)|(?:\\)|(?:\])|(?:\^)|(?:\{)|(?:\|)|(?:\|\|)|(?:\})'; - name = 'keyword.operator.sarl'; - comment = 'Operators and Punctuations' - } - ); - name = 'SARL'; - firstLineMatch = '^//.*\bsarl\b.'; - foldingStopMarker = '^\s*\}'; - version = '0.6'; - uuid = 'E95E1CA2-7D0E-39AA-83EB-5A611CE4122F'; - fileTypes = ( - 'sarl' - ) -} \ No newline at end of file diff --git a/formatting-styles/textmate/sarl.tmLanguage b/formatting-styles/textmate/sarl.tmLanguage deleted file mode 100644 index 3943e58a5d..0000000000 --- a/formatting-styles/textmate/sarl.tmLanguage +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - foldingStartMarker - \{\s*(//.*)?$ - __sarlVersion - 0.6 - scopeName - source.sarl - patterns - - - endCaptures - - 0 - - name - punctuation.definition.comment.sarl - - - patterns - - - match - ^\s*(\*)(?!/) - name - punctuation.definition.comment.sarl - - - name - comment.block.sarl - end - (\*/) - comment - Multiline comments - beginCaptures - - 0 - - name - punctuation.definition.comment.sarl - - - begin - (/\*+) - - - captures - - 1 - - name - comment.line.double-slash.sarl - - 2 - - name - comment.line.sarl - - - match - \s*(//)(.*)$ - comment - Single-line comment - - - endCaptures - - 0 - - name - punctuation.definition.string.begin.sarl - - - patterns - - - match - \\. - name - constant.character.escape.sarl - - - name - string.quoted.double.sarl - end - " - comment - Double quoted strings of characters - beginCaptures - - 0 - - name - punctuation.definition.string.end.sarl - - - begin - " - - - endCaptures - - 0 - - name - punctuation.definition.string.begin.sarl - - - patterns - - - match - \\. - name - constant.character.escape.sarl - - - name - string.quoted.single.sarl - end - ' - comment - Single quoted strings of characters - beginCaptures - - 0 - - name - punctuation.definition.string.end.sarl - - - begin - ' - - - match - (?:[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fFdD]?)|(?:0[xX][0-9a-fA-F]+)|(?:[0-9]+[lL]?) - name - constant.numeric.sarl - comment - Numbers - - - match - \@[_a-zA-Z$][_0-9a-zA-Z$]* - name - support.type.sarl - comment - Annotations - - - match - \b(?:(?:false)|(?:it)|(?:null)|(?:occurrence)|(?:this)|(?:true)|(?:void))\b - name - constant.language.sarl - comment - SARL Literals and Constants - - - match - \b(?:(?:boolean)|(?:byte)|(?:char)|(?:double)|(?:float)|(?:int)|(?:long)|(?:short)|(?:void))\b(?:\s*\[\s*\])* - name - storage.type.primitive.sarl - comment - Primitive types - - - match - \b(?:(?:import)|(?:package))\b - name - keyword.other.special.sarl - comment - Special Keywords - - - match - \b(?:(?:abstract)|(?:def)|(?:dispatch)|(?:final)|(?:native)|(?:override)|(?:private)|(?:protected)|(?:public)|(?:static)|(?:strictfp)|(?:synchronized)|(?:transient)|(?:val)|(?:var)|(?:volatile))\b - name - storage.modifier.sarl - comment - Modifiers - - - match - \b(?:(?:agent)|(?:annotation)|(?:artifact)|(?:behavior)|(?:capacity)|(?:class)|(?:enum)|(?:event)|(?:interface)|(?:skill)|(?:space))\b - name - keyword.other.declaration.sarl - comment - Type Declarations - - - match - \b(?:(?:as)|(?:break)|(?:case)|(?:catch)|(?:default)|(?:do)|(?:else)|(?:extends)|(?:extension)|(?:finally)|(?:fires)|(?:for)|(?:if)|(?:implements)|(?:instanceof)|(?:new)|(?:on)|(?:requires)|(?:return)|(?:super)|(?:switch)|(?:throw)|(?:throws)|(?:try)|(?:typeof)|(?:uses)|(?:while)|(?:with))\b - name - keyword.control.sarl - comment - Standard Keywords - - - match - (?:\!)|(?:\!\=)|(?:\!\=\=)|(?:#)|(?:%)|(?:%\=)|(?:&)|(?:&&)|(?:\()|(?:\))|(?:\*)|(?:\*\*)|(?:\*/)|(?:\*\=)|(?:\+)|(?:\+\+)|(?:\+\=)|(?:,)|(?:\-)|(?:\-\-)|(?:\-\=)|(?:\-\>)|(?:\.)|(?:\.\.)|(?:\.\.\.)|(?:\.\.\<)|(?:/)|(?:/\*)|(?://)|(?:/\=)|(?:\:)|(?:\:\:)|(?:;)|(?:\<)|(?:\<\>)|(?:\=)|(?:\=\=)|(?:\=\=\=)|(?:\=\>)|(?:\>)|(?:\>\=)|(?:\?)|(?:\?\.)|(?:\?\:)|(?:@)|(?:\[)|(?:\\)|(?:\])|(?:\^)|(?:\{)|(?:\|)|(?:\|\|)|(?:\}) - name - keyword.operator.sarl - comment - Operators and Punctuations - - - name - SARL - firstLineMatch - ^//.*\bsarl\b. - foldingStopMarker - ^\s*\} - version - 0.6 - uuid - E95E1CA2-7D0E-39AA-83EB-5A611CE4122F - fileTypes - - sarl - - - diff --git a/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/externalspec/AbstractExternalHighlightingFragment2.java b/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/externalspec/AbstractExternalHighlightingFragment2.java index b4669ed34c..8a9a740f88 100644 --- a/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/externalspec/AbstractExternalHighlightingFragment2.java +++ b/main/coreplugins/io.sarl.lang.mwe2/src/io/sarl/lang/mwe2/externalspec/AbstractExternalHighlightingFragment2.java @@ -620,7 +620,27 @@ protected void writeFile(String basename, T content, Function2 outputDirectoryFilter) { for (final String output : getOutputs()) { File directory = new File(output).getAbsoluteFile(); if (outputDirectoryFilter != null) { @@ -629,7 +649,7 @@ protected void writeFile(String basename, T content, Function2 literals, Set @Override protected void generateAdditionalFiles(String oldBasename, ITmStyleAppendable writtenAppendable) { if (writtenAppendable instanceof CombinedTmAppendable) { - final CombinedTmAppendable appendable = (CombinedTmAppendable) writtenAppendable; - final String language = getLanguageSimpleName().toLowerCase(); - final String newBasename = getBasename(MessageFormat.format(BASENAME_PATTERN_NEW, language)); - writeFile(newBasename, appendable.getNewSyntaxContent()); + generatePlistFile((CombinedTmAppendable) writtenAppendable); + } + generateLicenseFile(); + } + + /** Generate the Plist file. + * + * @param it the appendable used for generated the "tmLanguage" file. + */ + protected void generatePlistFile(CombinedTmAppendable it) { + final String language = getLanguageSimpleName().toLowerCase(); + final String newBasename = getBasename(MessageFormat.format(BASENAME_PATTERN_NEW, language)); + writeFile(newBasename, it.getNewSyntaxContent()); + } + + /** Generate the LICENSE file. + */ + protected void generateLicenseFile() { + final CharSequence licenseText = getLicenseText(); + if (licenseText != null) { + final String text = licenseText.toString(); + if (!Strings.isEmpty(text)) { + writeFile(LICENSE_FILE, text.getBytes()); + } } } + /** Replies the text of the license to write to the generated output. + * + * @return the text. + */ + protected CharSequence getLicenseText() { + final URL url = getClass().getResource(LICENSE_FILE); + if (url != null) { + final File filename = new File(url.getPath()); + return Files.readFileIntoString(filename.getAbsolutePath()); + } + return null; + } + /** Create the patterns. * * @param literals - the SARL literals. @@ -462,10 +502,23 @@ protected List createPatterns(Set literals, Set expressionKey @Override protected Object getReadmeFileContent(String basename) { return concat( - "1. MANUAL INSTALLATION", //$NON-NLS-1$ + "SARL highlighting for TextMate", //$NON-NLS-1$ + "==============================", //$NON-NLS-1$ + "", //$NON-NLS-1$ + "A TextMate package to apply syntax highlighting for the SARL language.", //$NON-NLS-1$ + "", //$NON-NLS-1$ + "1. INSTALLATION", //$NON-NLS-1$ + "", //$NON-NLS-1$ + "1.1. Manual", //$NON-NLS-1$ "", //$NON-NLS-1$ "Copy the " + basename + "file into one of the following folders:", //$NON-NLS-1$ //$NON-NLS-2$ - "* Sublime Text 3: $HOME/.config/sublime-text-3/Packages/User/SARL/"); //$NON-NLS-1$ + "* Sublime Text 3: $HOME/.config/sublime-text-3/Packages/User/SARL/", //$NON-NLS-1$ + "", //$NON-NLS-1$ + "1.2 With Sublime TextPackage Control", //$NON-NLS-1$ + "", //$NON-NLS-1$ + "If you have the Package Control package installed, you can install the highlighting format", //$NON-NLS-1$ + "from inside Sublime Text itself. Open the Command Palette and select \"Package Control: ", //$NON-NLS-1$ + "Install Package\", then search for \"SARL\"."); //$NON-NLS-1$ } /** Definition of a pattern.