-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a477e48
commit 2e84c64
Showing
12 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
27 | ||
28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project = JQL and | ||
developer in ("Soney Mathew", "Kyle Painter", "Cristian Casais") | ||
ORDER BY created ASC, duedate DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'codemirror/mode/sql/sql'; | ||
|
||
export const id = 'jql-ast'; | ||
export const displayName = 'JQL AST'; | ||
export const mimeTypes = ['application/json']; | ||
export const fileExtension = 'jql'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import defaultParserInterface from './utils/defaultJqlAstParserInterface'; | ||
import pkg from '@atlassianlabs/jql-ast/package.json'; | ||
|
||
export default { | ||
...defaultParserInterface(pkg), | ||
loadParser(callback) { | ||
require(['@atlassianlabs/jql-ast'], callback); | ||
}, | ||
} |
29 changes: 29 additions & 0 deletions
29
website/src/parsers/jql-ast/utils/defaultJqlAstParserInterface.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import defaultParserInterface from '../../utils/defaultParserInterface'; | ||
|
||
export default (pkg) => ({ | ||
...defaultParserInterface, | ||
id: pkg.name+pkg.version, | ||
displayName: pkg.name+'@'+pkg.version, | ||
version: '', | ||
locationProps: new Set(['positions','position']), | ||
homepage: "https://www.npmjs.com/package/@atlassianlabs/jql-ast", | ||
|
||
parse(jqlParser, code) { | ||
return new jqlParser.JastBuilder().build(code); | ||
}, | ||
|
||
opensByDefault(node, key) { | ||
return key === 'query'; | ||
}, | ||
|
||
getNodeName(node) { | ||
return node.type; | ||
}, | ||
|
||
nodeToRange({ position }) { | ||
if (!position) { | ||
return; | ||
} | ||
return [position[0], position[1]]; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
project = JQL and | ||
developer in ("Soney Mathew", "Kyle Painter", "Cristian Casais") | ||
ORDER BY created ASC, duedate DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'codemirror/mode/sql/sql'; | ||
|
||
export const id = 'jql-parser'; | ||
export const displayName = 'JQL Parser'; | ||
export const mimeTypes = ['application/json']; | ||
export const fileExtension = 'jql'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import defaultParserInterface from '../utils/defaultParserInterface'; | ||
import pkg from '@atlassianlabs/jql-parser/package.json'; | ||
import { CharStreams, CommonTokenStream } from 'antlr4ts'; | ||
|
||
const ID = 'jql-parser'; | ||
function traverse(tree, map, lexer) { | ||
const name = tree.constructor.name; | ||
if (name === "TerminalNode") { | ||
const token = tree.symbol; | ||
map["type"] = lexer.vocabulary.getSymbolicName(token.type); | ||
map["text"] = token.text; | ||
map["position"] = { startIndex: token.startIndex, stopIndex: token.stopIndex }; | ||
} | ||
else { | ||
const children = []; | ||
map[name] = children; | ||
|
||
if (tree.children) { | ||
for (var i = 0; i < tree.children.length; i++) { | ||
const nested = {}; | ||
children.push(nested); | ||
traverse(tree.children[i], nested, lexer); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default { | ||
...defaultParserInterface, | ||
|
||
id: ID, | ||
displayName: pkg.name, | ||
version: pkg.version, | ||
homepage: 'https://www.npmjs.com/package/@atlassianlabs/jql-parser', | ||
locationProps: new Set(['position']), | ||
typeProps: new Set(['type']), | ||
|
||
loadParser(callback) { | ||
require(['@atlassianlabs/jql-parser'], callback); | ||
}, | ||
|
||
parse(jqlParser, code) { | ||
const chars = CharStreams.fromString(code); | ||
const lexer = new jqlParser.JQLLexer(chars); | ||
const tokenStream = new CommonTokenStream(lexer); | ||
const parser = new jqlParser.JQLParser(tokenStream); | ||
const map = {}; | ||
traverse(parser.jqlQuery(), map, lexer) | ||
return map; | ||
}, | ||
|
||
getNodeName(node) { | ||
return node.type; | ||
}, | ||
|
||
nodeToRange({ position }) { | ||
if (!position) { | ||
return; | ||
} | ||
return [position.startIndex, position.stopIndex]; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,24 @@ | |
dependencies: | ||
tslib "^2.2.0" | ||
|
||
"@atlassianlabs/[email protected]": | ||
version "0.0.1" | ||
resolved "https://registry.yarnpkg.com/@atlassianlabs/jql-ast/-/jql-ast-0.0.1.tgz#22116f4b58a69117a74c5e382bb97305bd9b3afb" | ||
integrity sha512-MTU/ibDIqdKNQKN1QeEXI26RIaPydlCeb4RBLRehaFiqny8ToPwIFIcmn60asUS/dRdPzum07oPIufjEFh/40g== | ||
dependencies: | ||
"@atlassianlabs/jql-parser" "^0.0.1" | ||
"@babel/runtime" "^7.15.4" | ||
antlr4ts "^0.5.0-alpha.3" | ||
memoize-one "^5.1.1" | ||
|
||
"@atlassianlabs/[email protected]", "@atlassianlabs/jql-parser@^0.0.1": | ||
version "0.0.1" | ||
resolved "https://registry.yarnpkg.com/@atlassianlabs/jql-parser/-/jql-parser-0.0.1.tgz#529bb5b05062f8e1953885e97b5b2de7a0804098" | ||
integrity sha512-ukuR58r6jNUSUiQ3F0rypVHPeYSwuLaLtjOcopWP8tRIPg65vLbTPbg3v1YSsKarx56m175UKJoN6y3QcZA+9A== | ||
dependencies: | ||
"@babel/runtime" "^7.15.4" | ||
antlr4ts "^0.5.0-alpha.3" | ||
|
||
"@babel/[email protected]": | ||
version "7.0.0-beta.44" | ||
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9" | ||
|
@@ -1082,6 +1100,13 @@ | |
dependencies: | ||
regenerator-runtime "^0.13.4" | ||
|
||
"@babel/runtime@^7.15.4": | ||
version "7.16.3" | ||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5" | ||
integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ== | ||
dependencies: | ||
regenerator-runtime "^0.13.4" | ||
|
||
"@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7": | ||
version "7.14.0" | ||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.0.tgz#46794bc20b612c5f75e62dd071e24dfd95f1cbe6" | ||
|
@@ -1860,6 +1885,11 @@ ansi-styles@^4.1.0: | |
"@types/color-name" "^1.1.1" | ||
color-convert "^2.0.1" | ||
|
||
antlr4ts@^0.5.0-alpha.3: | ||
version "0.5.0-alpha.4" | ||
resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" | ||
integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ== | ||
|
||
anymatch@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" | ||
|
@@ -7473,6 +7503,11 @@ mem@^4.0.0: | |
mimic-fn "^2.0.0" | ||
p-is-promise "^2.0.0" | ||
|
||
memoize-one@^5.1.1: | ||
version "5.2.1" | ||
resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.2.1.tgz#8337aa3c4335581839ec01c3d594090cebe8f00e" | ||
integrity sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q== | ||
|
||
memory-fs@^0.2.0: | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" | ||
|