Skip to content

Commit

Permalink
Makes semantic analysis faster (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncordon authored Nov 23, 2023
1 parent 76f4ae9 commit 17909e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-peas-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@neo4j-cypher/language-support': patch
---

Improves speed of semantic analysis between 2x and 6x
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"use strict";
export function semanticAnalysis(queryText, callback) {
(function(root, module) {
if (typeof define === 'function' && define.amd) {
define(['exports'], function(exports) {
module(root, exports);
});
} else if (typeof exports === 'object' && exports !== null && typeof exports.nodeName !== 'string') {
module(global, exports);
module(globalThis, exports);
} else {
module(root, root);
}
Expand Down Expand Up @@ -1480,7 +1479,6 @@ export function semanticAnalysis(queryText, callback) {
sci_TreeSeqMap$OrderBy$Insertion$__clinit_();
sci_TreeSeqMap$OrderBy$Modification$__clinit_();
oncie_ListComprehension$__clinit_();
return cnsa_Main_analyzeQuery($args.data[0]);
}
function cnsa_Main_analyzeQuery($queryText) {
var $result, $semanticErrors, var$4, var$5, var$6, var$7, var$8, $$je;
Expand Down Expand Up @@ -222034,6 +222032,7 @@ export function semanticAnalysis(queryText, callback) {
c.accept = c.$accept$exported$0;
})();

$rt_exports.main([queryText], callback)
}));
}
// Initialize everything
$rt_exports.main([]);
$rt_exports.semanticAnalysis = $rt_mainStarter(($args) => cnsa_Main_analyzeQuery($args.data[0]));
}));
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface SemanticAnalysisError {
export function doSemanticAnalysis(query: string): SemanticAnalysisError[] {
try {
let semanticErrorsResult = undefined;
semanticAnalysis(query, (a) => {
semanticAnalysis([query], (a) => {
semanticErrorsResult = a;
});
const errors = semanticErrorsResult.$array.data;
Expand Down
1 change: 1 addition & 0 deletions packages/language-support/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"exclude": ["**/semanticAnalysis.js"],
"compilerOptions": {
"outDir": "out",
"declaration": true,
Expand Down

0 comments on commit 17909e3

Please sign in to comment.