This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 155167 - Code formatting, folding and bracket matching
Summary: Code formatting, folding and bracket matching
Status: NEW
Alias: None
Product: db
Classification: Unclassified
Component: SQL Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 6 votes (vote)
Assignee: Libor Fischmeistr
Keywords: NETFIX
: 146553 185452 257354 (view as bug list)
Depends on: 193557
  Show dependency tree
Reported: 2008-12-10 17:37 UTC by Roman Mostyka
Modified: 2016-01-04 18:04 UTC (History)
3 users (show)

See Also:
Exception Reporter:

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 (

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 (upload may still be in progress)
User: Jaroslav Havlin <>
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.
Comment 13 matthias42 2016-01-04 18:04:52 UTC
*** Bug 257354 has been marked as a duplicate of this bug. ***