Bug 155167 - Code formatting, folding and bracket matching
Code formatting, folding and bracket matching
Status: NEW
Product: db
Classification: Unclassified
Component: SQL Editor
All All
: P3 with 5 votes (vote)
Assigned To: Libor Fischmeistr
: 146553 185452 (view as bug list)
Depends on: 193557
  Show dependency treegraph
Reported: 2008-12-10 17:37 UTC by Roman Mostyka
Modified: 2014-09-18 18:21 UTC (History)
2 users (show)

See Also:

add bracket matching (15.44 KB, patch)
2012-05-19 20:48 UTC, matthias42
Details | Diff
add SQL-99 escape handling to lexer (6.94 KB, patch)
2012-05-19 20:48 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Mostyka 2008-12-10 17:37:44 UTC
Add code formatting, folding and bracket matching for SQL editor.
Comment 1 Jiri Rechtacek 2009-10-16 14:05:11 UTC
Reassigned to new owner.
Comment 2 matthias42 2012-05-17 11:06:17 UTC
*** Bug 146553 has been marked as a duplicate of this bug. ***
Comment 3 matthias42 2012-05-17 11:06:30 UTC
*** Bug 185452 has been marked as a duplicate of this bug. ***
Comment 4 matthias42 2012-05-19 20:48:12 UTC
Created attachment 119649 [details]
add bracket matching
Comment 5 matthias42 2012-05-19 20:48:59 UTC
Created attachment 119650 [details]
add SQL-99 escape handling to lexer
Comment 6 matthias42 2012-05-19 20:51:35 UTC
The last two patches can only be applied after the changes started in bug #193557 are applied. I'll have a look at code formatting next.
Comment 7 Jaroslav Havlin 2012-06-18 13:59:53 UTC
I've tested the proposed bracket matching, and it seems to contain a bug.
If SQL editor contains a word whose first and last letters are the same (e.g. "samples"), and the cursor is at the beginning or end of the word, this pair of letters is highlighted (I guess it is not intentional).

Why have you decided to implement a custom bracket matcher? Do you think the the default one is not sufficient (http://hg.netbeans.org/core-main/rev/dbca6e992987)?

I think that escape handling is a non-standard feature of MySQL (if I am wrong please correct me). Cannot it cause problems when writing SQL for other databases?

Thank you very much.
Comment 8 matthias42 2012-06-26 19:59:08 UTC
Hey, thanks for your feedback! Your right there is a bug in the bracket matcher. 

The bracket matching differs in the respect, that different things are matched. I intended this behavior:

- match round brackets outside identifiers and strings
- match quoting characters:
  - ' for strings
  - `" and the pair [] for identifiers

The changed quote handling in the lexer is correct for the SQL-99 standard. There is no backslash to escape special meaning, but doubling the character to be protected (which is only the used quoting symbol). See




Before any of the two patches can be applied, they need another round (please give some feedback, if your interested). The backet matched needs to be bugfixed and the lexer change should get another fix to mark partly quoted identiefiers as errors (same as the string error marking).

The lexer change is needed, because else a structure like "'identifier''with_embedded_quotes'" is cut into two tokens:
"'identifier'" and "'with_embedded_quotes'" which is wrong. In the current situation the token sequence is mainly used for syntax highlighting, in which this is not a problem, but the correct token would be the complete sequence "'identifier''with_embedded_quotes'".
Comment 9 matthias42 2012-07-12 19:42:37 UTC
Comment on attachment 119650 [details]
add SQL-99 escape handling to lexer

Moved patch to bug #183478 (it does not really belong here)
Comment 10 Jaroslav Havlin 2013-02-12 12:42:33 UTC
The patch was applied. Thank you, Matthias!
Comment 11 Quality Engineering 2013-02-14 02:19:38 UTC
Integrated into 'main-golden', will be available in build *201302132300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/bc7d23461f89
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #155167: Braces matcher for SQL editor
Comment 12 matthias42 2014-09-18 18:21:36 UTC
Because I was just wondering whether this can be closed - remaining are:

- Code folding
- Code formating

Both depend on a sql parser - at least at the current point I don't see another coherent possibility with structural knowledge.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo