├── .gitignore
├── LICENSE
├── README.md
├── coffeelint.json
├── grammars
├── composer.cson
├── regular expression replacement (javascript).cson
└── regular expressions (javascript).cson
├── header.txt
├── package.json
├── settings
└── language-composer.cson
├── snippets
└── language-javascript.cson
└── spec
├── javascript-spec.coffee
└── regular-expression-replacement-spec.coffee
/.gitignore:
--------------------------------------------------------------------------------
1 | # Licensed under the Apache License, Version 2.0 (the "License");
2 | # you may not use this file except in compliance with the License.
3 | # You may obtain a copy of the License at
4 | #
5 | # http://www.apache.org/licenses/LICENSE-2.0
6 | #
7 | # Unless required by applicable law or agreed to in writing, software
8 | # distributed under the License is distributed on an "AS IS" BASIS,
9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | # See the License for the specific language governing permissions and
11 | # limitations under the License.
12 |
13 | # Logs
14 | logs
15 | *.log
16 | npm-debug.log*
17 |
18 | # Runtime data
19 | pids
20 | *.pid
21 | *.seed
22 |
23 | # Directory for instrumented libs generated by jscoverage/JSCover
24 | lib-cov
25 |
26 | # Coverage directory used by tools like istanbul
27 | coverage
28 |
29 | # nyc test coverage
30 | .nyc_output
31 |
32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
33 | .grunt
34 |
35 | # node-waf configuration
36 | .lock-wscript
37 |
38 | # Compiled binary addons (http://nodejs.org/api/addons.html)
39 | build/Release
40 |
41 | # Dependency directories
42 | node_modules
43 | jspm_packages
44 |
45 | # Optional npm cache directory
46 | .npm
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Composer language support in Atom
2 |
3 | :warning: :warning: :warning:
4 |
5 | **As of the 29th August 2019, the Hyperledger Composer project is in deprecated status. None of the maintainers are actively developing new features. None of the maintainers are actively providing support via GitHub issues. However, if you wish to submit code changes via pull requests, these will be merged.**
6 |
7 | **It is highly recommended that you use Hyperledger Fabric v1.4+ instead, which features significant improvements to the developer experience, including a new programming model.**
8 |
9 | **More information available here: [What's new in Hyperledger Fabric v1.4](https://hyperledger-fabric.readthedocs.io/en/release-1.4/whatsnew.html#improved-programming-model-for-developing-applications)**
10 |
11 | :warning: :warning: :warning:
12 |
13 | Adds syntax highlighting and snippets for Composer in Atom.
14 |
15 | ## Install
16 | You can install this atom plugin with a command line or from atom market place.
17 |
18 | ## Install atom plugin with a command line
19 |
20 | 1. Install the apm utility. See http://flight-manual.atom.io/getting-started/sections/installing-atom/
21 | if you do not have it installed.
22 |
23 | 2. Git clone this repository
24 |
25 | 3. Switch to the root directory of the clone on your local disk
26 |
27 | 4. Run the command 'apm link' in a terminal
28 |
29 | Relaunch Atom. You should now have syntax highlighting for Composer .cto files.
30 |
31 | ## Install atom plugin from the Atom market place
32 | 1. Open Atom application
33 |
34 | 2. Open the __Install Packages/Themes__ by click __Packages --> Settings View__ and select __Install Packages/Themes__
35 |
36 | 3. Select Install on the Settings menu
37 |
38 | 4. Type *composer-atom-plugin* or *composer-** in the Packages search field and you should see the composer-atom-plugin on the list
39 |
40 | You can select the composer-atom-plugin from the install packages and click on **Install** button to install it.
41 |
42 | You should now have syntax highlighting for Composer .cto files.
43 |
44 | ## License
45 | Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the [LICENSE](LICENSE) file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/.
46 |
--------------------------------------------------------------------------------
/coffeelint.json:
--------------------------------------------------------------------------------
1 | {
2 | "max_line_length": {
3 | "level": "ignore"
4 | },
5 | "no_empty_param_list": {
6 | "level": "error"
7 | },
8 | "arrow_spacing": {
9 | "level": "error"
10 | },
11 | "no_interpolation_in_single_quotes": {
12 | "level": "error"
13 | },
14 | "no_debugger": {
15 | "level": "error"
16 | },
17 | "prefer_english_operator": {
18 | "level": "error"
19 | },
20 | "colon_assignment_spacing": {
21 | "spacing": {
22 | "left": 0,
23 | "right": 1
24 | },
25 | "level": "error"
26 | },
27 | "braces_spacing": {
28 | "spaces": 0,
29 | "level": "error"
30 | },
31 | "spacing_after_comma": {
32 | "level": "error"
33 | },
34 | "no_stand_alone_at": {
35 | "level": "error"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/grammars/composer.cson:
--------------------------------------------------------------------------------
1 | 'scopeName': 'source.cto'
2 | 'fileTypes': [
3 | 'cto'
4 | ]
5 | 'firstLineMatch': '''(?x)
6 | # Hashbang
7 | ^\\#!.*(?:\\s|\\/|(?<=!)\\b)
8 | (?:node|iojs|JavaScript)
9 | (?:$|\\s)
10 | |
11 | # Modeline
12 | (?i:
13 | # Emacs
14 | -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
15 | (?:js|javascript)
16 | (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*=
20 | javascript
21 | (?=\\s|:|$)
22 | )
23 | '''
24 | 'name': 'Composer'
25 | 'patterns': [
26 | {
27 | # ES6 import
28 | 'begin': '(? [expression|{statements}]
489 | 'begin': '''(?x)
490 | (?=
491 | (?
494 | )
495 | '''
496 | 'end': '''(?x)
497 | (?<=})|
498 | ((?!
499 | \\s*{|
500 | \\G\\(|
501 | \\G[\\w$]+|
502 | \\s*/\\*|\\s*//
503 | )(?=\\s*\\S))
504 | '''
505 | 'patterns': [
506 | {
507 | 'include': '#comments'
508 | }
509 | {
510 | 'include': '#function_body'
511 | }
512 | {
513 | 'begin': '\\G'
514 | 'end': '(?<=(=>))'
515 | 'name': 'meta.function.arrow.js'
516 | 'patterns': [
517 | {
518 | 'include': '#arrow_function_innards'
519 | }
520 | ]
521 | }
522 | ]
523 | }
524 | {
525 | # [.]foo = ... => ...
526 | 'begin': '''(?x)
527 | (?=
528 | (\\.)?[a-zA-Z_$][\\w$]*
529 | \\s*(=)\\s*
530 | ((\\(([^\\(\\)]*)?\\))|[\\w$]+)
531 | \\s*=>
532 | )
533 | '''
534 | 'end': '''(?x)
535 | (?<=})|
536 | ((?!
537 | \\s*{|
538 | \\G(\\.)?[a-zA-Z_$][\\w$]*\\s*(=)\\s*\\(|
539 | \\G(\\.)?[a-zA-Z_$][\\w$]*\\s*(=)\\s*[\\w$]+|
540 | \\s*/\\*|\\s*//
541 | )(?=\\s*\\S))
542 | '''
543 | 'patterns': [
544 | {
545 | 'include': '#comments'
546 | }
547 | {
548 | 'include': '#function_body'
549 | }
550 | {
551 | 'begin': '\\G'
552 | 'end': '(?<=(=>))'
553 | 'name': 'meta.function.arrow.js'
554 | 'patterns': [
555 | {
556 | 'match': '\\G(\\.)?([a-zA-Z_$][\\w$]*)\\s*(=)'
557 | 'captures':
558 | '1':
559 | 'name': 'meta.delimiter.method.period.js'
560 | '2':
561 | 'name': 'entity.name.function.js'
562 | '3':
563 | 'name': 'keyword.operator.assignment.js'
564 | }
565 | {
566 | 'include': '#arrow_function_innards'
567 | }
568 | ]
569 | }
570 | ]
571 | }
572 | {
573 | # foo: ... => ...
574 | 'begin': '''(?x)
575 | (?=
576 | \\b[a-zA-Z_$][\\w$]*
577 | \\s*:\\s*
578 | ((\\(([^\\(\\)]*)?\\))|[\\w$]+)
579 | \\s*=>
580 | )
581 | '''
582 | 'end': '''(?x)
583 | (?<=})|
584 | ((?!
585 | \\s*{|
586 | \\G[\\w$]+\\s*:|
587 | \\s*/\\*|\\s*//
588 | )(?=\\s*\\S))
589 | '''
590 | 'patterns': [
591 | {
592 | 'include': '#comments'
593 | }
594 | {
595 | 'include': '#function_body'
596 | }
597 | {
598 | 'begin': '\\G'
599 | 'end': '(?<=(=>))'
600 | 'name': 'meta.function.arrow.json.js'
601 | 'patterns': [
602 | {
603 | 'match': '\\b([a-zA-Z_$][\\w$]*)\\s*(:)\\s*'
604 | 'captures':
605 | '1':
606 | 'name': 'entity.name.function.js'
607 | '2':
608 | 'name': 'keyword.operator.assignment.js'
609 | }
610 | {
611 | 'include': '#arrow_function_innards'
612 | }
613 | ]
614 | }
615 | ]
616 | }
617 | {
618 | # "foo": ... => ...
619 | 'begin': '''(?x)
620 | (?=
621 | ((\'[^\']*?\')|("[^"]*?"))
622 | \\s*:\\s*
623 | ((\\(([^\\(\\)]*)?\\))|[\\w$]+)
624 | \\s*=>
625 | )
626 | '''
627 | 'end': '''(?x)
628 | (?<=})|
629 | ((?!
630 | \\G((\'[^\']*?\')|("[^"]*?"))|
631 | \\s*{|
632 | \\s*/\\*|\\s*//
633 | )(?=\\s*\\S))
634 | '''
635 | 'patterns': [
636 | {
637 | 'include': '#comments'
638 | }
639 | {
640 | 'include': '#function_body'
641 | }
642 | {
643 | 'begin': '\\G'
644 | 'end': '(?<=(=>))'
645 | 'name': 'meta.function.arrow.json.js'
646 | 'patterns': [
647 | {
648 | 'match': '(?:((\')([^\']*?)(\'))|((")([^"]*?)(")))\\s*(:)'
649 | 'captures':
650 | '1':
651 | 'name': 'string.quoted.single.js'
652 | '2':
653 | 'name': 'punctuation.definition.string.begin.js'
654 | '3':
655 | 'name': 'entity.name.function.js'
656 | '4':
657 | 'name': 'punctuation.definition.string.end.js'
658 | '5':
659 | 'name': 'string.quoted.double.js'
660 | '6':
661 | 'name': 'punctuation.definition.string.begin.js'
662 | '7':
663 | 'name': 'entity.name.function.js'
664 | '8':
665 | 'name': 'punctuation.definition.string.end.js'
666 | '9':
667 | 'name': 'keyword.operator.assignment.js'
668 | }
669 | {
670 | 'include': '#arrow_function_innards'
671 | }
672 | ]
673 | }
674 | ]
675 | }
676 | {
677 | 'match': '(=>)'
678 | 'captures':
679 | '0':
680 | 'name': 'meta.function.arrow.js'
681 | '1':
682 | 'name': 'storage.type.function.arrow.js'
683 | }
684 | {
685 | 'match': '''(?x)
686 | \\b(class)
687 | (?:
688 | (?:\\s+(extends)\\s+([a-zA-Z_$][\\w$]*))
689 | |
690 | (?:
691 | (?:\\s+([a-zA-Z_$][\\w$]*))
692 | (?:\\s+(extends)\\s+([a-zA-Z_$][\\w$]*))?
693 | )
694 | )
695 | '''
696 | 'captures':
697 | '1':
698 | 'name': 'storage.type.class.js'
699 | '2':
700 | 'name': 'storage.modifier.js'
701 | '3':
702 | 'name': 'entity.other.inherited-class.js'
703 | '4':
704 | 'name': 'entity.name.type.class.js'
705 | '5':
706 | 'name': 'storage.modifier.js'
707 | '6':
708 | 'name': 'entity.other.inherited-class.js'
709 | 'name': 'meta.class.js'
710 | }
711 | {
712 | 'match': '(new)\\s+([\\w$]+[\\w.$]*)'
713 | 'name': 'meta.class.instance.constructor.js'
714 | 'captures':
715 | '1':
716 | 'name': 'keyword.operator.new.js'
717 | '2':
718 | 'name': 'entity.name.type.instance.js'
719 | 'patterns': [
720 | {
721 | 'match': '\\.'
722 | 'name': 'meta.delimiter.property.period.js'
723 | }
724 | ]
725 | }
726 | {
727 | # console
728 | # console.log(arg1, "arg2", [...])
729 | 'begin': '(?)'
770 | 'captures':
771 | '0':
772 | 'name': 'punctuation.definition.comment.html.js'
773 | '2':
774 | 'name': 'punctuation.definition.comment.html.js'
775 | 'name': 'comment.block.html.js'
776 | }
777 | {
778 | 'match': '(?|&&|\\|\\|)\\s*(/)(?![/*+?])(?=.*/)'
901 | 'beginCaptures':
902 | '1':
903 | 'name': 'punctuation.definition.string.begin.js'
904 | 'end': '(/)[gimuy]*'
905 | 'endCaptures':
906 | '1':
907 | 'name': 'punctuation.definition.string.end.js'
908 | 'name': 'string.regexp.js'
909 | 'patterns': [
910 | {
911 | 'include': 'source.js.regexp'
912 | }
913 | ]
914 | }
915 | {
916 | 'begin': '\\?'
917 | 'beginCaptures':
918 | '0':
919 | 'name': 'keyword.operator.ternary.js'
920 | 'end': ':'
921 | 'endCaptures':
922 | '0':
923 | 'name': 'keyword.operator.ternary.js'
924 | 'patterns': [
925 | {
926 | 'include': '#prevent_object_keys_matching'
927 | }
928 | {
929 | 'include': '$self'
930 | }
931 | ]
932 | }
933 | {
934 | 'include': '#operators'
935 | }
936 | {
937 | 'include': '#method_calls'
938 | }
939 | {
940 | 'include': '#function_calls'
941 | }
942 | {
943 | 'include': '#numbers'
944 | }
945 | {
946 | 'include': '#objects'
947 | }
948 | {
949 | 'include': '#properties'
950 | }
951 | {
952 | 'match': '((?>=|>>>=|\\|='
1072 | 'name': 'keyword.operator.assignment.compound.bitwise.js'
1073 | }
1074 | {
1075 | 'match': '!==|!=|<=|>=|===|==|<|>'
1076 | 'name': 'keyword.operator.comparison.js'
1077 | }
1078 | {
1079 | 'match': '&&|!|\\|\\|'
1080 | 'name': 'keyword.operator.logical.js'
1081 | }
1082 | {
1083 | 'match': '&|\\||\\^|~'
1084 | 'name': 'keyword.operator.bitwise.js'
1085 | }
1086 | {
1087 | 'match': '=|:'
1088 | 'name': 'keyword.operator.assignment.js'
1089 | }
1090 | {
1091 | 'match': '--'
1092 | 'name': 'keyword.operator.decrement.js'
1093 | }
1094 | {
1095 | 'match': '\\+\\+'
1096 | 'name': 'keyword.operator.increment.js'
1097 | }
1098 | {
1099 | 'match': '%|\\*|/|-|\\+'
1100 | 'name': 'keyword.operator.js'
1101 | }
1102 | ]
1103 | 'strings':
1104 | 'patterns': [
1105 | {
1106 | 'begin': '\''
1107 | 'beginCaptures':
1108 | '0':
1109 | 'name': 'punctuation.definition.string.begin.js'
1110 | 'end': '\''
1111 | 'endCaptures':
1112 | '0':
1113 | 'name': 'punctuation.definition.string.end.js'
1114 | 'name': 'string.quoted.single.js'
1115 | 'patterns': [
1116 | {
1117 | 'include': '#string_escapes'
1118 | }
1119 | {
1120 | 'match': "[^']*[^\\n\\r'\\\\]$"
1121 | 'name': 'invalid.illegal.string.js'
1122 | }
1123 | ]
1124 | }
1125 | {
1126 | 'begin': '"'
1127 | 'beginCaptures':
1128 | '0':
1129 | 'name': 'punctuation.definition.string.begin.js'
1130 | 'end': '"'
1131 | 'endCaptures':
1132 | '0':
1133 | 'name': 'punctuation.definition.string.end.js'
1134 | 'name': 'string.quoted.double.js'
1135 | 'patterns': [
1136 | {
1137 | 'include': '#string_escapes'
1138 | }
1139 | {
1140 | 'match': '[^"]*[^\\n\\r"\\\\]$'
1141 | 'name': 'invalid.illegal.string.js'
1142 | }
1143 | ]
1144 | }
1145 | {
1146 | 'begin': '((\\w+)?(html|HTML|Html))\\s*(`)'
1147 | 'beginCaptures':
1148 | '1':
1149 | 'name': 'entity.name.function.js'
1150 | '4':
1151 | 'name': 'punctuation.definition.string.begin.js'
1152 | 'end': '`'
1153 | 'endCaptures':
1154 | '0':
1155 | 'name': 'punctuation.definition.string.end.js'
1156 | 'name': 'string.quoted.template.html.js'
1157 | 'patterns': [
1158 | {
1159 | 'include': '#string_escapes'
1160 | }
1161 | {
1162 | 'include': '#interpolated_js'
1163 | }
1164 | {
1165 | 'include': 'text.html.basic'
1166 | }
1167 | ]
1168 | }
1169 | {
1170 | 'begin': '(Relay\\.QL)\\s*(`)'
1171 | 'beginCaptures':
1172 | '1':
1173 | 'name': 'entity.name.function.js'
1174 | '2':
1175 | 'name': 'punctuation.definition.string.begin.js'
1176 | 'end': '`'
1177 | 'endCaptures':
1178 | '0':
1179 | 'name': 'punctuation.definition.string.end.js'
1180 | 'name': 'string.quoted.template.graphql.js'
1181 | 'patterns': [
1182 | {
1183 | 'include': '#string_escapes'
1184 | }
1185 | {
1186 | 'include': '#interpolated_js'
1187 | }
1188 | {
1189 | 'include': 'source.graphql'
1190 | }
1191 | ]
1192 | }
1193 | {
1194 | 'begin': '`'
1195 | 'beginCaptures':
1196 | '0':
1197 | 'name': 'punctuation.definition.string.begin.js'
1198 | 'end': '`'
1199 | 'endCaptures':
1200 | '0':
1201 | 'name': 'punctuation.definition.string.end.js'
1202 | 'name': 'string.quoted.template.js'
1203 | 'patterns': [
1204 | {
1205 | 'include': '#string_escapes'
1206 | }
1207 | {
1208 | 'include': '#interpolated_js'
1209 | }
1210 | ]
1211 | }
1212 | ]
1213 | 'string_escapes':
1214 | 'patterns': [
1215 | {
1216 | 'match': '\\\\u(?![A-Fa-f0-9]{4}|{[A-Fa-f0-9]+})[^\'"]*'
1217 | 'name': 'invalid.illegal.unicode-escape.js'
1218 | }
1219 | {
1220 | 'match': '\\\\u(?:[A-Fa-f0-9]{4}|({)([A-Fa-f0-9]+)(}))'
1221 | 'name': 'constant.character.escape.js'
1222 | 'captures':
1223 | '1':
1224 | 'name': 'punctuation.definition.unicode-escape.begin.bracket.curly.js'
1225 | '2':
1226 | 'patterns': [
1227 | {
1228 | # Max codepoint: \u{10FFFF}
1229 | 'match': '[A-Fa-f\\d]{7,}|(?!10)[A-Fa-f\\d]{6}'
1230 | 'name': 'invalid.illegal.unicode-escape.js'
1231 | }
1232 | ]
1233 | '3':
1234 | 'name': 'punctuation.definition.unicode-escape.end.bracket.curly.js'
1235 | }
1236 | {
1237 | 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)'
1238 | 'name': 'constant.character.escape.js'
1239 | }
1240 | ]
1241 | 'function_params':
1242 | 'patterns': [
1243 | {
1244 | 'begin': '\\('
1245 | 'beginCaptures':
1246 | '0':
1247 | 'name': 'punctuation.definition.parameters.begin.bracket.round.js'
1248 | 'end': '\\)'
1249 | 'endCaptures':
1250 | '0':
1251 | 'name': 'punctuation.definition.parameters.end.bracket.round.js'
1252 | 'name': 'meta.parameters.js'
1253 | 'patterns': [
1254 | {
1255 | 'match': '(\\.\\.\\.)([a-zA-Z_$][\\w$]*)'
1256 | 'captures':
1257 | '1':
1258 | 'name': 'keyword.operator.spread.js'
1259 | '2':
1260 | 'name': 'variable.parameter.rest.function.js'
1261 | }
1262 | {
1263 | 'include': '$self'
1264 | }
1265 | {
1266 | 'match': '[a-zA-Z_$][\\w$]*'
1267 | 'name': 'variable.parameter.function.js'
1268 | }
1269 | ]
1270 | }
1271 | ]
1272 | 'function_body':
1273 | 'patterns': [
1274 | {
1275 | 'begin': '{'
1276 | 'beginCaptures':
1277 | '0':
1278 | 'name': 'punctuation.definition.function.body.begin.bracket.curly.js'
1279 | 'end': '}'
1280 | 'endCaptures':
1281 | '0':
1282 | 'name': 'punctuation.definition.function.body.end.bracket.curly.js'
1283 | 'patterns': [
1284 | {
1285 | 'include': '$self'
1286 | }
1287 | ]
1288 | }
1289 | ]
1290 | 'function_innards':
1291 | 'patterns': [
1292 | {
1293 | 'match': '(?:\\b(async)\\b\\s*)?\\b(function)\\b(?:\\s*(\\*))?'
1294 | 'captures':
1295 | '1':
1296 | 'name': 'storage.modifier.async.js'
1297 | '2':
1298 | 'name': 'storage.type.function.js'
1299 | '3':
1300 | 'name': 'storage.modifier.generator.js'
1301 | }
1302 | {
1303 | 'match': '[a-zA-Z_$][\\w$]*(?=\\s*\\()'
1304 | 'name': 'entity.name.function.js'
1305 | }
1306 | {
1307 | 'include': '#function_params'
1308 | }
1309 | {
1310 | 'include': '#comments'
1311 | }
1312 | ]
1313 | 'arrow_function_innards':
1314 | 'patterns': [
1315 | {
1316 | 'match': '=>'
1317 | 'name': 'storage.type.function.arrow.js'
1318 | }
1319 | {
1320 | 'include': '#function_params'
1321 | }
1322 | {
1323 | 'match': '([a-zA-Z_$][\\w$]*)(?=\\s*=>)'
1324 | 'captures':
1325 | '0':
1326 | 'name': 'meta.parameters.js'
1327 | '1':
1328 | 'name': 'variable.parameter.function.js'
1329 | }
1330 | {
1331 | 'match': '(\\d[\\w$]*)'
1332 | 'captures':
1333 | '0':
1334 | 'name': 'meta.parameters.js'
1335 | '1':
1336 | 'name': 'invalid.illegal.identifier.js'
1337 | }
1338 | ]
1339 | 'arguments':
1340 | 'patterns': [
1341 | {
1342 | 'begin': '\\('
1343 | 'beginCaptures':
1344 | '0':
1345 | 'name': 'punctuation.definition.arguments.begin.bracket.round.js'
1346 | 'end': '\\)'
1347 | 'endCaptures':
1348 | '0':
1349 | 'name': 'punctuation.definition.arguments.end.bracket.round.js'
1350 | 'name': 'meta.arguments.js'
1351 | 'patterns': [
1352 | {
1353 | 'include': '$self'
1354 | }
1355 | ]
1356 | }
1357 | ]
1358 | 'interpolated_js':
1359 | 'patterns': [
1360 | {
1361 | 'begin': '\\$\\{'
1362 | 'captures':
1363 | '0':
1364 | 'name': 'punctuation.section.embedded.js'
1365 | 'end': '\\}'
1366 | 'name': 'source.js.embedded.source'
1367 | 'patterns': [
1368 | {
1369 | 'begin': '{'
1370 | 'beginCaptures':
1371 | '0':
1372 | 'name': 'meta.brace.curly.js'
1373 | 'end': '}'
1374 | 'endCaptures':
1375 | '0':
1376 | 'name': 'meta.brace.curly.js'
1377 | 'patterns': [
1378 | {
1379 | 'include': '$self'
1380 | }
1381 | ]
1382 | }
1383 | {
1384 | 'include': '$self'
1385 | }
1386 | ]
1387 | }
1388 | ]
1389 | 'docblock':
1390 | 'patterns': [
1391 | {
1392 | 'match': '''(?x) (? # {Array} or {Object} type application
1427 | )
1428 | (?:
1429 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback
1430 | [a-zA-Z_$]+
1431 | (?:
1432 | (?:
1433 | [\\w$]*
1434 | (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers
1435 | ) |
1436 | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application
1437 | )
1438 | )*
1439 | \\) |
1440 | [a-zA-Z_$]+
1441 | (?:
1442 | (?:
1443 | [\\w$]*
1444 | (?:\\[\\])? # {string[]|number} type application, an array of strings or a number
1445 | ) |
1446 | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application
1447 | )
1448 | (?:
1449 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback
1450 | [a-zA-Z_$]+
1451 | (?:
1452 | [\\w$]* |
1453 | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application
1454 | )
1455 | )*
1456 | )
1457 | # Check for suffix
1458 | (?:\\[\\])? # {string[]} type application, an array of strings
1459 | =? # {string=} optional parameter
1460 | )})
1461 | \\s+
1462 | (
1463 | \\[ # [foo] optional parameter
1464 | \\s*
1465 | (?:
1466 | [a-zA-Z_$][\\w$]*
1467 | (?:
1468 | (?:\\[\\])? # Foo[].bar properties within an array
1469 | \\. # Foo.Bar namespaced parameter
1470 | [a-zA-Z_$][\\w$]*
1471 | )*
1472 | (?:
1473 | \\s*
1474 | = # [foo=bar] Default parameter value
1475 | \\s*
1476 | [\\w$\\s]*
1477 | )?
1478 | )
1479 | \\s*
1480 | \\] |
1481 | (?:
1482 | [a-zA-Z_$][\\w$]*
1483 | (?:
1484 | (?:\\[\\])? # Foo[].bar properties within an array
1485 | \\. # Foo.Bar namespaced parameter
1486 | [a-zA-Z_$][\\w$]*
1487 | )*
1488 | )?
1489 | )
1490 | \\s+
1491 | ((?:(?!\\*\\/).)*) # The type description
1492 | '''
1493 | 'captures':
1494 | '0':
1495 | 'name': 'other.meta.jsdoc'
1496 | '1':
1497 | 'name': 'entity.name.type.instance.jsdoc'
1498 | '2':
1499 | 'name': 'variable.other.jsdoc'
1500 | '3':
1501 | 'name': 'other.description.jsdoc'
1502 | }
1503 | {
1504 | 'match': '''(?x)
1505 | ({(?:
1506 | \\* | # {*} any type
1507 | \\? | # {?} unknown type
1508 |
1509 | (?: # Check for a prefix
1510 | \\? | # {?string} nullable type
1511 | ! | # {!string} non-nullable type
1512 | \\.{3} # {...string} variable number of parameters
1513 | )?
1514 |
1515 | (?:
1516 | \\( # Opening bracket of multiple types with parenthesis {(string|number)}
1517 | [a-zA-Z_$]+
1518 | (?:
1519 | [\\w$]* |
1520 | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application
1521 | )
1522 | (?:
1523 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback
1524 | [a-zA-Z_$]+
1525 | (?:
1526 | [\\w$]* |
1527 | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application
1528 | )
1529 | )*
1530 | \\) |
1531 | [a-zA-Z_$]+
1532 | (?:
1533 | [\\w$]* |
1534 | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application
1535 | )
1536 | (?:
1537 | [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback
1538 | [a-zA-Z_$]+
1539 | (?:
1540 | [\\w$]* |
1541 | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application
1542 | )
1543 | )*
1544 | )
1545 | # Check for suffix
1546 | (?:\\[\\])? # {string[]} type application, an array of strings
1547 | =? # {string=} optional parameter
1548 | )})
1549 | \\s+
1550 | ((?:(?!\\*\\/).)*) # The type description
1551 | '''
1552 | 'captures':
1553 | '0':
1554 | 'name': 'other.meta.jsdoc'
1555 | '1':
1556 | 'name': 'entity.name.type.instance.jsdoc'
1557 | '2':
1558 | 'name': 'other.description.jsdoc'
1559 | }
1560 | ]
1561 | 'comments':
1562 | 'patterns': [
1563 | {
1564 | 'begin': '/\\*\\*(?!/)'
1565 | 'beginCaptures':
1566 | '0':
1567 | 'name': 'punctuation.definition.comment.js'
1568 | 'end': '\\*/'
1569 | 'endCaptures':
1570 | '0':
1571 | 'name': 'punctuation.definition.comment.js'
1572 | 'name': 'comment.block.documentation.js'
1573 | 'patterns': [
1574 | {
1575 | 'include': '#docblock'
1576 | }
1577 | ]
1578 | }
1579 | {
1580 | 'begin': '/\\*'
1581 | 'beginCaptures':
1582 | '0':
1583 | 'name': 'punctuation.definition.comment.js'
1584 | 'end': '\\*/'
1585 | 'endCaptures':
1586 | '0':
1587 | 'name': 'punctuation.definition.comment.js'
1588 | 'name': 'comment.block.js'
1589 | }
1590 | {
1591 | 'begin': '(^[ \\t]+)?(?=//)'
1592 | 'beginCaptures':
1593 | '1':
1594 | 'name': 'punctuation.whitespace.comment.leading.js'
1595 | 'end': '(?!\\G)'
1596 | 'patterns': [
1597 | {
1598 | 'begin': '//'
1599 | 'beginCaptures':
1600 | '0':
1601 | 'name': 'punctuation.definition.comment.js'
1602 | 'end': '\\n'
1603 | 'name': 'comment.line.double-slash.js'
1604 | }
1605 | ]
1606 | }
1607 | ]
1608 | 'prevent_object_keys_matching':
1609 | 'patterns': [
1610 | {
1611 | # e.g. don't treat null as an object key in
1612 | # ? null :
1613 | # case null:
1614 | 'match': '(\\w+)(?=\\s*:)'
1615 | 'captures':
1616 | '1':
1617 | 'patterns': [
1618 | 'include': '$self'
1619 | ]
1620 | }
1621 | ]
1622 |
--------------------------------------------------------------------------------
/grammars/regular expression replacement (javascript).cson:
--------------------------------------------------------------------------------
1 | 'scopeName': 'source.cto.regexp.replacement'
2 | 'name': 'Regular Expression Replacement (Composer)'
3 | 'fileTypes': []
4 | 'patterns': [
5 | {
6 | 'include': '#regexp-replacement'
7 | }
8 | ]
9 | 'repository':
10 | 'regexp-replacement':
11 | 'patterns': [
12 | {
13 | 'match': '\\$([1-9][0-9]|[1-9]|0[1-9]|[&`\'])'
14 | 'name': 'variable.regexp.replacement'
15 | }
16 | {
17 | 'match': '\\$\\$'
18 | 'name': 'constant.character.escape.dollar.regexp.replacement'
19 | }
20 | {
21 | 'match': '\\\\[^$]'
22 | 'name': 'constant.character.escape.backslash.regexp.replacement'
23 | }
24 | ]
25 |
--------------------------------------------------------------------------------
/grammars/regular expressions (javascript).cson:
--------------------------------------------------------------------------------
1 | 'scopeName': 'source.cto.regexp'
2 | 'name': 'Regular Expressions (Composer)'
3 | 'fileTypes': []
4 | 'patterns': [
5 | {
6 | 'include': '#regexp'
7 | }
8 | ]
9 | 'repository':
10 | 'regex-character-class':
11 | 'patterns': [
12 | {
13 | 'match': '\\\\[wWsSdDtrnvf]|\\.'
14 | 'name': 'constant.character.character-class.regexp'
15 | }
16 | {
17 | 'match': '\\\\([0-7]{3}|x\\h\\h|u\\h\\h\\h\\h)'
18 | 'name': 'constant.character.numeric.regexp'
19 | }
20 | {
21 | 'match': '\\\\c[A-Z]'
22 | 'name': 'constant.character.control.regexp'
23 | }
24 | {
25 | 'match': '\\\\.'
26 | 'name': 'constant.character.escape.backslash.regexp'
27 | }
28 | ]
29 | 'regexp':
30 | 'patterns': [
31 | {
32 | 'match': '\\\\[bB]|\\^|\\$'
33 | 'name': 'keyword.control.anchor.regexp'
34 | }
35 | {
36 | 'match': '\\\\[1-9]\\d*'
37 | 'name': 'keyword.other.back-reference.regexp'
38 | }
39 | {
40 | 'match': '[?+*]|\\{(\\d+,\\d+|\\d+,|,\\d+|\\d+)\\}\\??'
41 | 'name': 'keyword.operator.quantifier.regexp'
42 | }
43 | {
44 | 'match': '\\|'
45 | 'name': 'keyword.operator.or.regexp'
46 | }
47 | {
48 | 'begin': '(\\()((\\?=)|(\\?!))'
49 | 'beginCaptures':
50 | '1':
51 | 'name': 'punctuation.definition.group.regexp'
52 | '3':
53 | 'name': 'meta.assertion.look-ahead.regexp'
54 | '4':
55 | 'name': 'meta.assertion.negative-look-ahead.regexp'
56 | 'end': '(\\))'
57 | 'endCaptures':
58 | '1':
59 | 'name': 'punctuation.definition.group.regexp'
60 | 'name': 'meta.group.assertion.regexp'
61 | 'patterns': [
62 | {
63 | 'include': '#regexp'
64 | }
65 | ]
66 | }
67 | {
68 | 'begin': '\\((\\?:)?'
69 | 'beginCaptures':
70 | '0':
71 | 'name': 'punctuation.definition.group.regexp'
72 | 'end': '\\)'
73 | 'endCaptures':
74 | '0':
75 | 'name': 'punctuation.definition.group.regexp'
76 | 'name': 'meta.group.regexp'
77 | 'patterns': [
78 | {
79 | 'include': '#regexp'
80 | }
81 | ]
82 | }
83 | {
84 | 'begin': '(\\[)(\\^)?'
85 | 'beginCaptures':
86 | '1':
87 | 'name': 'punctuation.definition.character-class.regexp'
88 | '2':
89 | 'name': 'keyword.operator.negation.regexp'
90 | 'end': '(\\])'
91 | 'endCaptures':
92 | '1':
93 | 'name': 'punctuation.definition.character-class.regexp'
94 | 'name': 'constant.other.character-class.set.regexp'
95 | 'patterns': [
96 | {
97 | 'captures':
98 | '1':
99 | 'name': 'constant.character.numeric.regexp'
100 | '2':
101 | 'name': 'constant.character.control.regexp'
102 | '3':
103 | 'name': 'constant.character.escape.backslash.regexp'
104 | '4':
105 | 'name': 'constant.character.numeric.regexp'
106 | '5':
107 | 'name': 'constant.character.control.regexp'
108 | '6':
109 | 'name': 'constant.character.escape.backslash.regexp'
110 | 'match': '(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))'
111 | 'name': 'constant.other.character-class.range.regexp'
112 | }
113 | {
114 | 'include': '#regex-character-class'
115 | }
116 | ]
117 | }
118 | {
119 | 'include': '#regex-character-class'
120 | }
121 | ]
122 |
--------------------------------------------------------------------------------
/header.txt:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "composer-atom-plugin",
3 | "version": "0.7.1",
4 | "description": "Adds syntax highlighting and snippets for Hyperledger Composer in Atom",
5 | "engines": {
6 | "atom": "*"
7 | },
8 | "homepage": "https://github.com/hyperledger/composer-atom-plugin",
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/hyperledger/composer-atom-plugin.git"
12 | },
13 | "license": "Apache-2.0",
14 | "bugs": {
15 | "url": "https://github.com/hyperledger/composer/issues"
16 | },
17 | "devDependencies": {
18 | "coffeelint": "^1.10.1"
19 | },
20 | "license-check-config": {
21 | "path": "header.txt",
22 | "blocking": true,
23 | "logInfo": false,
24 | "logError": true
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/settings/language-composer.cson:
--------------------------------------------------------------------------------
1 | '.source.cto':
2 | 'editor':
3 | 'commentStart': '// '
4 | 'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)'
5 | 'increaseIndentPattern': '(?x)
6 | \\{ [^}"\']* $
7 | | \\[ [^\\]"\']* $
8 | | \\( [^)"\']* $
9 | '
10 | 'decreaseIndentPattern': '(?x)
11 | ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])]
12 | '
13 |
--------------------------------------------------------------------------------
/snippets/language-javascript.cson:
--------------------------------------------------------------------------------
1 | '.source.cto':
2 | 'Object Method':
3 | 'prefix': 'kf'
4 | 'body': '${1:methodName}: function (${2:attribute}) {\n\t$3\n}${4:,}'
5 | 'Object key — key: "value"':
6 | 'prefix': 'kv'
7 | 'body': '${1:key}: ${2:\'${3:value}\'}${4:, }'
8 | 'Prototype':
9 | 'prefix': 'proto'
10 | 'body': '${1:ClassName}.prototype.${2:methodName} = function ($3) {\n\t$0\n};'
11 | 'do':
12 | 'prefix': 'do'
13 | 'body': 'do {\n\t$2\n} while (${1:true});'
14 | 'if':
15 | 'prefix': 'if'
16 | 'body': 'if (${1:true}) {\n\t$2\n}'
17 | 'if … else':
18 | 'prefix': 'ife'
19 | 'body': 'if (${1:true}) {\n\t$2\n} else {\n\t$3\n}'
20 | 'else':
21 | 'prefix': 'else'
22 | 'body': 'else {\n\t$1\n}'
23 | 'else if':
24 | 'prefix': 'elseif'
25 | 'body': 'else if (${1:true}) {\n\t$2\n}'
26 | 'for':
27 | 'prefix' : 'for'
28 | 'body' : 'for (var ${2:i} = 0; ${2:i} < ${1:array}.length; ${2:i}++) {\n\t${1:array}[${2:i}]$3\n}'
29 | 'for in':
30 | 'prefix': 'forin'
31 | 'body': 'for (var ${1:variable} in ${2:object}) {\n\t${3:if (${2:object}.hasOwnProperty(${1:variable})) {\n\t\t$4\n\t\\}}\n}'
32 | 'for of':
33 | 'prefix': 'forof'
34 | 'body': 'for (${1:variable} of ${2:iterable}) {\n\t$3\n}'
35 | 'Function':
36 | 'prefix': 'fun'
37 | 'body': 'function ${1:functionName}($2) {\n\t$0\n}'
38 | 'Anonymous Function':
39 | 'prefix': 'f'
40 | 'body': 'function ($1) {\n\t$2\n}'
41 | 'Generator':
42 | 'prefix': 'gen',
43 | 'body': 'function* ${1:functionName}($2) {\n\t$0\n}'
44 | 'Anonymous Generator':
45 | 'prefix': 'g'
46 | 'body': 'function* ($1) {\n\t$2\n}'
47 | 'getElementsByClassName':
48 | 'prefix': 'get'
49 | 'body': 'getElementsByClassName(${1:\'${2:className}\'})$3'
50 | 'getElementsByName':
51 | 'prefix': 'getn'
52 | 'body': 'getElementsByName(${1:\'${2:name}\'})$3'
53 | 'getElementsByTagName':
54 | 'prefix': 'gett'
55 | 'body': 'getElementsByTagName(${1:\'${2:tagName}\'})$3'
56 | 'getElementById':
57 | 'prefix': 'geti'
58 | 'body': 'getElementById(${1:\'${2:id}\'})$3'
59 | 'querySelector':
60 | 'prefix': 'qs'
61 | 'body': 'querySelector(${1:\'${2:query}\'})$3'
62 | 'querySelectorAll':
63 | 'prefix': 'qsa'
64 | 'body': 'querySelectorAll(${1:\'${2:query}\'})$3'
65 | 'Immediately-Invoked Function Expression':
66 | 'prefix': 'iife'
67 | 'body': '(function() {\n\t${1:\'use strict\';\n}\t$2\n}());'
68 | 'log':
69 | 'prefix': 'log'
70 | 'body': 'console.log($1);$0'
71 | 'warn':
72 | 'prefix': 'warn'
73 | 'body': 'console.warn($1);$0'
74 | 'error':
75 | 'prefix': 'error'
76 | 'body': 'console.error($1);$0'
77 | 'inspect':
78 | 'prefix': 'inspect'
79 | 'body': 'console.log(require(\'util\').inspect($0, { depth: null }));'
80 | 'new Promise':
81 | 'prefix': 'prom'
82 | 'body': 'new Promise(function(resolve, reject) {\n\t$1\n});$0'
83 | 'setInterval function':
84 | 'prefix': 'interval'
85 | 'body': 'setInterval(${2:function () {\n\t$3\n\\}}, ${1:10});'
86 | 'setTimeout function':
87 | 'prefix': 'timeout'
88 | 'body': 'setTimeout(${2:function () {\n\t$3\n\\}}, ${1:10});'
89 | 'switch':
90 | 'prefix': 'switch'
91 | 'body': 'switch (${1:expression}) {\n\tcase ${2:expression}:\n\t\t$4\n\t\tbreak;$5\n\tdefault:\n\t\t$3\n}'
92 | 'case':
93 | 'prefix': 'case'
94 | 'body': 'case ${1:expression}:\n\t$2\n\tbreak;'
95 | 'try':
96 | 'prefix': 'try'
97 | 'body': 'try {\n\t$1\n} catch (${2:e}) {\n\t$3\n}${4: finally {\n\t$5\n\\}}'
98 | 'while':
99 | 'prefix': 'while'
100 | 'body': 'while (${1:true}) {\n\t$2\n}'
101 | 'Start Docblock':
102 | 'prefix': '/**'
103 | 'body': '/**\n * $1\n */$0'
104 | 'CommonJS require':
105 | 'prefix': 'req'
106 | 'body': 'const ${1:module} = require(\'${1:module}\');'
107 | 'Class':
108 | 'prefix': 'class'
109 | 'body': 'class ${1:ClassName} {\n\tconstructor($2) {\n\t\t$3\n\t}\n}'
110 | 'export function':
111 | 'prefix': 'expfun'
112 | 'body': 'exports.${1:functionName} = function ($2) {\n\t${3:// body...}\n};'
113 | 'export module':
114 | 'prefix': 'expmod'
115 | 'body': 'module.exports = ${1:name};'
116 |
--------------------------------------------------------------------------------
/spec/regular-expression-replacement-spec.coffee:
--------------------------------------------------------------------------------
1 | ###
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | ###
14 |
15 | describe "Regular Expression Replacement grammar", ->
16 | grammar = null
17 |
18 | beforeEach ->
19 | waitsForPromise ->
20 | atom.packages.activatePackage("language-javascript")
21 |
22 | runs ->
23 | grammar = atom.grammars.grammarForScopeName("source.js.regexp.replacement")
24 |
25 | it "parses the grammar", ->
26 | expect(grammar).toBeTruthy()
27 | expect(grammar.scopeName).toBe "source.js.regexp.replacement"
28 |
29 | describe "basic strings", ->
30 | it "tokenizes with no extra scopes", ->
31 | {tokens} = grammar.tokenizeLine('Hello [world]. (hi to you)')
32 | expect(tokens[0]).toEqual value: 'Hello [world]. (hi to you)', scopes: ['source.js.regexp.replacement']
33 |
34 | describe "escaped characters", ->
35 | it "tokenizes with as an escape character", ->
36 | {tokens} = grammar.tokenizeLine('\\n')
37 | expect(tokens[0]).toEqual value: '\\n', scopes: ['source.js.regexp.replacement', 'constant.character.escape.backslash.regexp.replacement']
38 |
39 | it "tokenizes '$$' as an escaped '$' character", ->
40 | {tokens} = grammar.tokenizeLine('$$')
41 | expect(tokens[0]).toEqual value: '$$', scopes: ['source.js.regexp.replacement', 'constant.character.escape.dollar.regexp.replacement']
42 |
43 | it "doesn't treat '\\$' as an escaped '$' character", ->
44 | {tokens} = grammar.tokenizeLine('\\$')
45 | expect(tokens[0]).toEqual value: '\\$', scopes: ['source.js.regexp.replacement']
46 |
47 | it "tokenizes '$$1' as an escaped '$' character followed by a '1' character", ->
48 | {tokens} = grammar.tokenizeLine('$$1')
49 | expect(tokens[0]).toEqual value: '$$', scopes: ['source.js.regexp.replacement', 'constant.character.escape.dollar.regexp.replacement']
50 | expect(tokens[1]).toEqual value: '1', scopes: ['source.js.regexp.replacement']
51 |
52 | describe "Numeric placeholders", ->
53 | it "doesn't tokenize $0 as a variable", ->
54 | {tokens} = grammar.tokenizeLine('$0')
55 | expect(tokens[0]).toEqual value: '$0', scopes: ['source.js.regexp.replacement']
56 |
57 | it "doesn't tokenize $00 as a variable", ->
58 | {tokens} = grammar.tokenizeLine('$00')
59 | expect(tokens[0]).toEqual value: '$00', scopes: ['source.js.regexp.replacement']
60 |
61 | it "tokenizes $1 as a variable", ->
62 | {tokens} = grammar.tokenizeLine('$1')
63 | expect(tokens[0]).toEqual value: '$1', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
64 |
65 | it "tokenizes $01 as a variable", ->
66 | {tokens} = grammar.tokenizeLine('$01')
67 | expect(tokens[0]).toEqual value: '$01', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
68 |
69 | it "tokenizes $3 as a variable", ->
70 | {tokens} = grammar.tokenizeLine('$3')
71 | expect(tokens[0]).toEqual value: '$3', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
72 |
73 | it "tokenizes $10 as a variable", ->
74 | {tokens} = grammar.tokenizeLine('$10')
75 | expect(tokens[0]).toEqual value: '$10', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
76 |
77 | it "tokenizes $99 as a variable", ->
78 | {tokens} = grammar.tokenizeLine('$99')
79 | expect(tokens[0]).toEqual value: '$99', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
80 |
81 | it "doesn't tokenize the third numberic character in '$100' as a variable", ->
82 | {tokens} = grammar.tokenizeLine('$100')
83 | expect(tokens[0]).toEqual value: '$10', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
84 | expect(tokens[1]).toEqual value: '0', scopes: ['source.js.regexp.replacement']
85 |
86 | describe "Matched sub-string placeholder", ->
87 | it "tokenizes $& as a variable", ->
88 | {tokens} = grammar.tokenizeLine('$&')
89 | expect(tokens[0]).toEqual value: '$&', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
90 |
91 | describe "Preceeding portion placeholder", ->
92 | it "tokenizes $` as a variable", ->
93 | {tokens} = grammar.tokenizeLine('$`')
94 | expect(tokens[0]).toEqual value: '$`', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
95 |
96 | describe "Following portion placeholder", ->
97 | it "tokenizes $' as a variable", ->
98 | {tokens} = grammar.tokenizeLine('$\'')
99 | expect(tokens[0]).toEqual value: '$\'', scopes: ['source.js.regexp.replacement', 'variable.regexp.replacement']
100 |
--------------------------------------------------------------------------------