Skip to content

Commit 0ae7197

Browse files
authored
Merge pull request #61 from anboralabs/refactor-plugin
Refactor plugin
2 parents b09b485 + 000c24f commit 0ae7197

File tree

7 files changed

+187
-163
lines changed

7 files changed

+187
-163
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
<a href="https://www.buymeacoffee.com/dalgarins" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
2+
13
# intellij-firebase-highlighter
24

35
![Plugin](/images/highlighted.png)
46

57
## What is it?
6-
intellij-firebase-highlighter is an Intellij plugin for highlighting firebase rules.
8+
9+
intellij-firebase-highlighter is an Intellij plugin for highlighting firebase
10+
rules.
711

812
## How to use it?
913

@@ -13,21 +17,25 @@ intellij-firebase-highlighter is an Intellij plugin for highlighting firebase ru
1317
### Add plugin to Intellij IDE
1418

1519
- Clone repo
20+
1621
```sh
1722
git clone https://github.com/anboralabs/intellij-firebase-highlighter
1823
```
24+
1925
```
2026
- Find grammar directory
2127
- FirebaseRules.bnf -> Right click -> Generate Parser Code
2228
- FirebaseRules.flex -> Right click -> Run JFlex Generator
2329
```
2430

2531
- Install from disk
32+
2633
```
2734
- Go to https://github.com/anboralabs/intellij-firebase-highlighter/releases/tag/v1.0.0
2835
- download firebase-syntax-highlighting-1.0-SNAPSHOT.jar
2936
- Plugins -> Install From disk -> choose the file downloaded
3037
```
38+
3139
- Install from plugin store
3240

3341
![Market Place](/images/market_place.png)
@@ -42,14 +50,16 @@ git clone https://github.com/anboralabs/intellij-firebase-highlighter
4250

4351
![Color Settings](/images/color_settings.png)
4452

45-
4653
## Credits
54+
4755
The main ideas used here were borrowed from:
56+
4857
- https://github.com/ferronrsmith/intellij-fbp-highlighter
4958
- https://github.com/lark-parser/intellij-syntax-highlighting
5059
- https://github.com/klazuka/intellij-elm
5160

5261
## License
62+
5363
```
5464
MIT License
5565
@@ -72,4 +82,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7282
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7383
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7484
SOFTWARE.
75-
```
85+
```

build.gradle

Lines changed: 3 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ grammarKit {
1313
}
1414

1515
group 'co.anbora.labs'
16-
version '2.5.3-SNAPSHOT'
16+
version '2.5.5-SNAPSHOT'
1717

1818
repositories {
1919
mavenCentral()
@@ -80,126 +80,7 @@ publishPlugin {
8080
}
8181

8282
patchPluginXml {
83-
changeNotes """
84-
<ul>
85-
<li><b>2.5.3</b> <em>(2021-04-12)</em> - Fixed minor issues</li>
86-
<ul>
87-
<li>Support for empty array </li>
88-
<li>Array indexing with a variable </li>
89-
<li>Fixed Issue with math operations </li>
90-
</ul>
91-
</li>
92-
<li><b>2.5.2</b> <em>(2021-04-08)</em> - Fixed blocker issue for android studio versions</li>
93-
<ul>
94-
<li>Fixed critical issue with android studio versions </li>
95-
</ul>
96-
</li>
97-
<li><b>2.5.1</b> <em>(2021-03-25)</em> - Added compatibility with newest versions</li>
98-
<ul>
99-
<li>Added compatibility with newest versions </li>
100-
<li>Fixed issue with access array </li>
101-
<li>Fixed issue with paths with dot </li>
102-
</ul>
103-
</li>
104-
<li><b>2.5.0</b> <em>(2021-03-17)</em> - Added basic code completation</li>
105-
<ul>
106-
<li>Added basic code completation </li>
107-
<li>Fixed issue with access index array </li>
108-
</ul>
109-
</li>
110-
<li><b>2.4.0</b> <em>(2021-02-14)</em> - Added code folding</li>
111-
<ul>
112-
<li>Added code folding </li>
113-
<li>Added brace matcher </li>
114-
</ul>
115-
</li>
116-
<li><b>2.3.0</b> <em>(2021-01-27)</em> - Added "is" keyword</li>
117-
<ul>
118-
<li>Allow "is" keyword </li>
119-
<li>Fixed issue with built in functions </li>
120-
</ul>
121-
</li>
122-
<li><b>2.2.1</b> <em>(2021-01-24)</em> - Added "let" keyword</li>
123-
<ul>
124-
<li>Allow "let" keyword in functions body </li>
125-
</ul>
126-
</li>
127-
<li><b>2.2.0</b> <em>(2021-01-23)</em> - Added actions</li>
128-
<ul>
129-
<li>Added actions to create rule files </li>
130-
<li>Allowed path in comparisons </li>
131-
</ul>
132-
</li>
133-
<li><b>2.1.1</b> <em>(2021-01-14)</em> - Upgrade plugin to intellij 2020.3</li>
134-
<ul>
135-
<li>Upgrade plugin to intellij 2020.3 </li>
136-
</ul>
137-
</li>
138-
<li><b>2.1.0</b> <em>(2021-01-10)</em> - Added Intellij formatting code support</li>
139-
<ul>
140-
<li>Added formatting code support </li>
141-
<li>Added oficial firebase icons </li>
142-
<li>Improved language bnf rules </li>
143-
</ul>
144-
</li>
145-
<li><b>2.0.0</b> <em>(2020-12-12)</em> - Added support block comments</li>
146-
<ul>
147-
<li>Added support for block comments </li>
148-
<li>Added support for keyboard combination: CMD + / </li>
149-
<li>Fixed issue with parenthesis and negation on expressions </li>
150-
</ul>
151-
</li>
152-
<li><b>1.1.5</b> <em>(2020-12-02)</em> - Added support for new IDE versions</li>
153-
<ul>
154-
<li>Added support for IDE version from build 192 </li>
155-
</ul>
156-
</li>
157-
<li><b>1.1.4</b> <em>(2020-11-29)</em> - Added operators support</li>
158-
<ul>
159-
<li>Added operation with numbers support: +, -, *, / </li>
160-
<li>Added operation with strings support: +, * </li>
161-
</ul>
162-
</li>
163-
<li><b>1.1.3</b> <em>(2020-11-19)</em> - comments issue</li>
164-
<ul>
165-
<li>Fixed false positive with comments in match body statement</li>
166-
</ul>
167-
</li>
168-
<li><b>1.1.2</b> <em>(2020-11-02)</em> - added arrays support</li>
169-
<ul>
170-
<li>Added support for arrays</li>
171-
</ul>
172-
</li>
173-
<li><b>1.1.1</b> <em>(2020-10-28)</em> - added built-in functions support</li>
174-
<ul>
175-
<li>Added support for functions: get, exists</li>
176-
<li>Fixed issues with functions and comments</li>
177-
</ul>
178-
</li>
179-
<li><b>1.1.0</b> <em>(2020-10-27)</em> - added highlight support</li>
180-
<ul>
181-
<li>Added support for highlight one line comments</li>
182-
<li>Added support for color change: strings, numbers and comments</li>
183-
</ul>
184-
</li>
185-
<li><b>1.0.2</b> <em>(2020-10-15)</em> - sintax checker</li>
186-
<ul>
187-
<li>Added "in" operator for javascript functions</li>
188-
</ul>
189-
</li>
190-
<li><b>1.0.1</b> <em>(2020-10-14)</em> - version compatibility</li>
191-
<ul>
192-
<li>Added version compatibility for all Intellij products</li>
193-
</ul>
194-
</li>
195-
<li><b>1.0.0</b> <em>(2020-10-10)</em> - initial release</li>
196-
<ul>
197-
<li>Initial Release</li>
198-
<li>Added changed notes</li>
199-
<li>Fixed plugin description</li>
200-
</ul>
201-
</li>
202-
</ul>
203-
"""
83+
changeNotes = file("src/main/html/change-notes.html").getText().toString()
84+
pluginDescription = file("src/main/html/description.html").getText().toString()
20485
sinceBuild = '203'
20586
}

src/main/grammar/FirebaseRules.bnf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ private FullPathStatementItem_recover ::= !(SLASH | '{' | IDENTIFIER | PATH_VARI
109109
PathStatement ::= (DOT? IDENTIFIER|PATH_VARIABLE)
110110

111111
//Allow Statement Begin
112-
AllowStatement ::= ALLOW_KEYWORD PermissionStatement COLON ConditionalStatement DOT_COMMA
113-
{
114-
pin=1
115-
}
112+
AllowStatement ::= EmptyAllowStm | ConditionalAllowStm
113+
private EmptyAllowStm ::= ALLOW_KEYWORD PermissionStatement DOT_COMMA
114+
private ConditionalAllowStm ::= ALLOW_KEYWORD PermissionStatement COLON ConditionalStatement DOT_COMMA
116115

117116
PermissionKeyWord ::= (GET_KEYWORD | READ_KEYWORD | WRITE_KEYWORD | LIST_KEYWORD
118117
| CREATE_KEYWORD | UPDATE_KEYWORD | DELETE_KEYWORD)
@@ -121,11 +120,11 @@ PermissionStatement ::= PermissionStatementItem+
121120
{
122121
pin=1
123122
}
124-
private PermissionStatementItem ::= !(':') PermissionKeyWord (',' | &':') {
123+
private PermissionStatementItem ::= !(':'|';') PermissionKeyWord (',' | &(':'|';')) {
125124
pin=1
126125
recoverWhile=Permission_recover
127126
}
128-
private Permission_recover ::= !(':' | GET_KEYWORD | READ_KEYWORD | WRITE_KEYWORD | LIST_KEYWORD
127+
private Permission_recover ::= !(':' |';' | GET_KEYWORD | READ_KEYWORD | WRITE_KEYWORD | LIST_KEYWORD
129128
| CREATE_KEYWORD | UPDATE_KEYWORD | DELETE_KEYWORD)
130129

131130
ConditionalStatement ::= IF_KEYWORD ConditionalExpression {
@@ -177,9 +176,10 @@ private FunctionBlockItems ::= !('}' | <<eof>>) VariableStatement* ReturnStateme
177176

178177
ParameterStatement ::= Expression(COMMA Expression)*
179178

180-
ReturnStatement ::= RETURN_KEYWORD ConditionalExpression DOT_COMMA {
179+
ReturnStatement ::= RETURN_KEYWORD ReturnBlock {
181180
pin=1
182181
}
182+
ReturnBlock ::= ConditionalExpression DOT_COMMA
183183

184184
Expression ::=
185185
OrExpr

src/main/html/change-notes.html

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
Versions:
2+
<ul>
3+
<li>All Intellij products support: 2.5.5</li>
4+
<li>Android Studio support: 2.5.4</li>
5+
</ul>
6+
7+
Plugin updates:
8+
<ul>
9+
<li><b>2.5.5</b> <em>(2021-04-22)</em> - Fixed minor issues</li>
10+
<ul>
11+
<li>Fixed formatting code issues </li>
12+
<li>Fixed issue with "allow" statement without conditional</li>
13+
</ul>
14+
<li><b>2.5.4</b> <em>(2021-04-16)</em> - Fixed minor issues</li>
15+
<ul>
16+
<li>Fixed formatting code issues </li>
17+
</ul>
18+
<li><b>2.5.3</b> <em>(2021-04-12)</em> - Fixed minor issues</li>
19+
<ul>
20+
<li>Support for empty array </li>
21+
<li>Array indexing with a variable </li>
22+
<li>Fixed Issue with math operations </li>
23+
</ul>
24+
</li>
25+
<li><b>2.5.2</b> <em>(2021-04-08)</em> - Fixed blocker issue for android studio versions</li>
26+
<ul>
27+
<li>Fixed critical issue with android studio versions </li>
28+
</ul>
29+
</li>
30+
<li><b>2.5.1</b> <em>(2021-03-25)</em> - Added compatibility with newest versions</li>
31+
<ul>
32+
<li>Added compatibility with newest versions </li>
33+
<li>Fixed issue with access array </li>
34+
<li>Fixed issue with paths with dot </li>
35+
</ul>
36+
</li>
37+
<li><b>2.5.0</b> <em>(2021-03-17)</em> - Added basic code completation</li>
38+
<ul>
39+
<li>Added basic code completation </li>
40+
<li>Fixed issue with access index array </li>
41+
</ul>
42+
</li>
43+
<li><b>2.4.0</b> <em>(2021-02-14)</em> - Added code folding</li>
44+
<ul>
45+
<li>Added code folding </li>
46+
<li>Added brace matcher </li>
47+
</ul>
48+
</li>
49+
<li><b>2.3.0</b> <em>(2021-01-27)</em> - Added "is" keyword</li>
50+
<ul>
51+
<li>Allow "is" keyword </li>
52+
<li>Fixed issue with built in functions </li>
53+
</ul>
54+
</li>
55+
<li><b>2.2.1</b> <em>(2021-01-24)</em> - Added "let" keyword</li>
56+
<ul>
57+
<li>Allow "let" keyword in functions body </li>
58+
</ul>
59+
</li>
60+
<li><b>2.2.0</b> <em>(2021-01-23)</em> - Added actions</li>
61+
<ul>
62+
<li>Added actions to create rule files </li>
63+
<li>Allowed path in comparisons </li>
64+
</ul>
65+
</li>
66+
<li><b>2.1.1</b> <em>(2021-01-14)</em> - Upgrade plugin to intellij 2020.3</li>
67+
<ul>
68+
<li>Upgrade plugin to intellij 2020.3 </li>
69+
</ul>
70+
</li>
71+
<li><b>2.1.0</b> <em>(2021-01-10)</em> - Added Intellij formatting code support</li>
72+
<ul>
73+
<li>Added formatting code support </li>
74+
<li>Added oficial firebase icons </li>
75+
<li>Improved language bnf rules </li>
76+
</ul>
77+
</li>
78+
<li><b>2.0.0</b> <em>(2020-12-12)</em> - Added support block comments</li>
79+
<ul>
80+
<li>Added support for block comments </li>
81+
<li>Added support for keyboard combination: CMD + / </li>
82+
<li>Fixed issue with parenthesis and negation on expressions </li>
83+
</ul>
84+
</li>
85+
<li><b>1.1.5</b> <em>(2020-12-02)</em> - Added support for new IDE versions</li>
86+
<ul>
87+
<li>Added support for IDE version from build 192 </li>
88+
</ul>
89+
</li>
90+
<li><b>1.1.4</b> <em>(2020-11-29)</em> - Added operators support</li>
91+
<ul>
92+
<li>Added operation with numbers support: +, -, *, / </li>
93+
<li>Added operation with strings support: +, * </li>
94+
</ul>
95+
</li>
96+
<li><b>1.1.3</b> <em>(2020-11-19)</em> - comments issue</li>
97+
<ul>
98+
<li>Fixed false positive with comments in match body statement</li>
99+
</ul>
100+
</li>
101+
<li><b>1.1.2</b> <em>(2020-11-02)</em> - added arrays support</li>
102+
<ul>
103+
<li>Added support for arrays</li>
104+
</ul>
105+
</li>
106+
<li><b>1.1.1</b> <em>(2020-10-28)</em> - added built-in functions support</li>
107+
<ul>
108+
<li>Added support for functions: get, exists</li>
109+
<li>Fixed issues with functions and comments</li>
110+
</ul>
111+
</li>
112+
<li><b>1.1.0</b> <em>(2020-10-27)</em> - added highlight support</li>
113+
<ul>
114+
<li>Added support for highlight one line comments</li>
115+
<li>Added support for color change: strings, numbers and comments</li>
116+
</ul>
117+
</li>
118+
<li><b>1.0.2</b> <em>(2020-10-15)</em> - sintax checker</li>
119+
<ul>
120+
<li>Added "in" operator for javascript functions</li>
121+
</ul>
122+
</li>
123+
<li><b>1.0.1</b> <em>(2020-10-14)</em> - version compatibility</li>
124+
<ul>
125+
<li>Added version compatibility for all Intellij products</li>
126+
</ul>
127+
</li>
128+
<li><b>1.0.0</b> <em>(2020-10-10)</em> - initial release</li>
129+
<ul>
130+
<li>Initial Release</li>
131+
<li>Added changed notes</li>
132+
<li>Fixed plugin description</li>
133+
</ul>
134+
</li>
135+
</ul>

src/main/html/description.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Provides support for the <a href="https://firebase.google.com/docs/rules/rules-language">Firebase rules</a> language.<br>
2+
3+
Features:<br>
4+
<ul>
5+
<li>Syntax highlighting</li>
6+
<li>Syntax checking</li>
7+
<li>Basic code completion</li>
8+
<li>Code formatting</li>
9+
</ul><br>
10+
Actions:<br>
11+
<ul>
12+
<li>Right click -> New -> Firestore rule file</li>
13+
<li>Right click -> New -> Storage rule file</li>
14+
</ul>

0 commit comments

Comments
 (0)