|
@@ -151,7 +151,7 @@ This gives you an idea on how to add custom syntax to the newly generated postgr
|
|
|
|
|
|
|
|
We’ll start by adding a test, in `postgresqlAutocompleteParser.test.js` in the test folder inside the main describe function before the first `it('should...`:
|
|
We’ll start by adding a test, in `postgresqlAutocompleteParser.test.js` in the test folder inside the main describe function before the first `it('should...`:
|
|
|
|
|
|
|
|
- fdescribe('REINDEX', () => {
|
|
|
|
|
|
|
+ describe('REINDEX', () => {
|
|
|
it('should handle "REINDEX TABLE foo FORCE; |"', () => {
|
|
it('should handle "REINDEX TABLE foo FORCE; |"', () => {
|
|
|
assertAutoComplete({
|
|
assertAutoComplete({
|
|
|
beforeCursor: 'REINDEX TABLE foo FORCE; ',
|
|
beforeCursor: 'REINDEX TABLE foo FORCE; ',
|
|
@@ -177,7 +177,7 @@ We’ll start by adding a test, in `postgresqlAutocompleteParser.test.js` in the
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-When we now run `npm run test` there should be two failing tests.
|
|
|
|
|
|
|
+When we now run `npm run test -- postgresqlAutocompleteParser.test.js` there should be two failing tests.
|
|
|
|
|
|
|
|
Next we’ll have to add the keyword to the lexer, let’s open `sql.jisonlex` in the jison folder for postgresql and add the following new tokens:
|
|
Next we’ll have to add the keyword to the lexer, let’s open `sql.jisonlex` in the jison folder for postgresql and add the following new tokens:
|
|
|
|
|
|
|
@@ -210,7 +210,7 @@ Now let’s add the grammar, starting with the complete specification. For simpl
|
|
|
|
|
|
|
|
"DataDefinition" is an existing rule and this extends that rule with "ReindexStatement".
|
|
"DataDefinition" is an existing rule and this extends that rule with "ReindexStatement".
|
|
|
|
|
|
|
|
-Save the files and first run `node tools/jison/generateParsers.js postgresql` then `npm run test` and we should be down to one failing test.
|
|
|
|
|
|
|
+Save the files and first run `node tools/jison/generateParsers.js postgresql` then `npm run test -- postgresqlAutocompleteParser.test.js` and we should be down to one failing test.
|
|
|
|
|
|
|
|
For the next one we’ll add some keyword suggestions after the user has typed REINDEX, we’ll continue below the ReindexStatement in `sql_main.jison`:
|
|
For the next one we’ll add some keyword suggestions after the user has typed REINDEX, we’ll continue below the ReindexStatement in `sql_main.jison`:
|
|
|
|
|
|
|
@@ -225,7 +225,7 @@ For the next one we’ll add some keyword suggestions after the user has typed R
|
|
|
}
|
|
}
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
-Again, run `node tools/jison/generateParsers.js postgresql` then `npm run test` and the tests should both be green.
|
|
|
|
|
|
|
+Again, run `node tools/jison/generateParsers.js postgresql` then `npm run test -- postgresqlAutocompleteParser.test.js` and the tests should both be green.
|
|
|
|
|
|
|
|
We also want the autocompleter to suggest the keyword REINDEX when the user hasn’t typed anything, to do that let’s first add the following test with the other new ones in `postgresqlAutocompleteParser.test.js`:
|
|
We also want the autocompleter to suggest the keyword REINDEX when the user hasn’t typed anything, to do that let’s first add the following test with the other new ones in `postgresqlAutocompleteParser.test.js`:
|
|
|
|
|
|
|
@@ -241,9 +241,9 @@ We also want the autocompleter to suggest the keyword REINDEX when the user hasn
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-For this to pass we need to add REINDEX to the list of DDL and DML keywords in the file `sqlParseSupport.js` next to the generated parser (`desktop/core/src/desktop/js/parse/sql/postgresql/sqlParseSupport.js/`). Find the function `parser.suggestDdlAndDmlKeywords` and add ‘REINDEX’ to the keywords array. Now run `npm run test` and the three tests should pass.
|
|
|
|
|
|
|
+For this to pass we need to add REINDEX to the list of DDL and DML keywords in the file `sqlParseSupport.js` next to the generated parser (`desktop/core/src/desktop/js/parse/sql/postgresql/sqlParseSupport.js/`). Find the function `parser.suggestDdlAndDmlKeywords` and add ‘REINDEX’ to the keywords array. Now run `npm run test -- postgresqlAutocompleteParser.test.js` and the three tests should pass.
|
|
|
|
|
|
|
|
-Before you continue further be sure to remove the ‘f’ from ‘fdescribe’ in the spec to allow all other tests to run. Note that in this case there will be two new failing tests where the keyword ‘REINDEX’ has to be added.
|
|
|
|
|
|
|
+Before you continue further, note that in this case there will be two new failing tests where the keyword ‘REINDEX’ has to be added.
|
|
|
|
|
|
|
|
In order to use the newly generated parsers we have to add them to the webpack bundles:
|
|
In order to use the newly generated parsers we have to add them to the webpack bundles:
|
|
|
|
|
|