Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Commit

Permalink
update syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Abbott committed Oct 23, 2017
1 parent d6119fc commit 09dd9be
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.vsix
node_modules
node_modules
out
5 changes: 4 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
images
examples
node_modules
*.vsix
*.vsix
out
syntaxes/compare.ts
syntaxes/sample.rules
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# 1.0.1
- Add highlighting for additional syntax defined in the [Security Rules Reference](https://cloud.google.com/firestore/docs/reference/security/)

# 1.0.0
Initial release with basic syntax highlighting.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Firestore Rules
Basic highlighting for new [Firestore security rules](https://cloud.google.com/firestore/docs/reference/security/) with plans for snippets and tips.
Basic highlighting for new [Firestore security rules](https://cloud.google.com/firestore/docs/reference/security/). Priority for [additional language features](https://code.visualstudio.com/docs/extensionAPI/language-support), in decreasing order of likelihood that I'll get to it.

- Completions (underway in a branch) then update syntax highlighting
- Hovers
- Snippets
- Signature Helpers
- Incremental Formatting

![Basic example](./screenshots/basic.png)
8 changes: 0 additions & 8 deletions examples/basic.rules

This file was deleted.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"name": "vsfire",
"displayName": "Firebase",
"description": "Firestore Rules syntax highlight",
"version": "1.0.0",
"description": "Firestore Security Rules syntax highlighting",
"version": "1.0.1",
"publisher": "toba",
"keywords": ["firebase","firestore","rules"],
"icon": "images/logo.png",
"repository": {
"type": "git",
"url": "https://github.com/toba/firestore-rules.git"
"url": "https://github.com/toba/vsfire.git"
},
"bugs": {
"url": "https://github.com/toba/vsfire/issues"
},
"engines": {
"vscode": "^1.10.0"
Expand Down
Binary file modified screenshots/basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions syntaxes/compare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const o = {
field1: "string"
}

function something(p1:string, p2:number):void {
let x = 1 + Math.round(2);
if (x == 3) { return; }
if (o.field1 == "x") { return; }
return;
}
39 changes: 36 additions & 3 deletions syntaxes/firerules.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"match": "\\/\\/.*",
"name": "comment"
}, {
"match": "\\b(service|match)\\b",
"match": "\\b(service|match|exists|get)\\b",
"name": "support.function"
}, {
"match": "\\b(allow|if)\\b",
Expand All @@ -28,16 +28,49 @@
"name": "storage.modifier"
}, {
"match": "(=|!|>|<|\\||&)",
"name": "keyword.control"
"name": "keyword.operator"
}, {
"match": "\\b(true|false)\\b",
"match": "\\b(true|false|null)\\b",
"name": "constant.language"
}, {
"comment": "Match variable",
"match": "\\/({[^}]+})[\\s\\/]",
"captures": {
"1": { "name": "variable.parameter" }
}
},{
"comment": "request time object",
"match": "\\b(request)\\.(time)\\.(date|year|month|day|time|hours|minutes|seconds|nanos|dayOfWeek|dayOfYear|toMillis)\\(",
"captures": {
"1": { "name": "support.type" },
"2": { "name": "support.variable" },
"3": { "name": "support.function.builtin" }
}
}, {
"comment": "request object",
"match": "\\b(request)\\.(auth|path|resource|time)\\b",
"captures": {
"1": { "name": "support.type" },
"2": { "name": "support.type" }
}
}, {
"comment": "math object",
"match": "\\b(math)\\.(ceil|floor|round|abs|isInfinite|isNaN)\\(",
"captures": {
"1": { "name": "support.type" },
"2": { "name": "support.function.builtin" }
}
}, {
"comment": "document object",
"match": "\\b(document)\\.(size|matches)\\(",
"captures": {
"1": { "name": "support.type" },
"2": { "name": "entity.name.function" }
}
}, {
"comment": "bare objects",
"match": "\\b(request|math|document|user|duration)\\b",
"name": "support.type"
}
]
}
9 changes: 9 additions & 0 deletions syntaxes/sample.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Syntax defined in
// https://cloud.google.com/firestore/docs/reference/security/
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null && math.floor(request.time.day()) == 2;
}
}
}

0 comments on commit 09dd9be

Please sign in to comment.