| Summary: | support: comments in source | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] Data Tools | Reporter: | Jeremy Lindop <jeremyl> | ||||||
| Component: | SQL Query Builder | Assignee: | Brian Payton <bpayton> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | enhancement | ||||||||
| Priority: | P3 | CC: | bpayton, drigby | ||||||
| Version: | 1.5 | Keywords: | helpwanted | ||||||
| Target Milestone: | 1.7M5 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | 215237 | ||||||||
| Bug Blocks: | |||||||||
| Attachments: |
|
||||||||
|
Description
Jeremy Lindop
This is dependent on the SQL Query Parser correctly parsing both simple and bracketed comments (i.e. beginning with -- or bracketed inside /* */). 215239 215237 Removing SQB: prefix on bug title at PMC request
The problem is when a Kennigan & Richie (open) comment is on the same line as a token (or unterminated on that line), the leading whitespace is truncated.
see ( RS/* )
The source string in the SQL builder model preservers the spacing but when statement is read from the model it loses the whitespace.
SELECT *
FROM APP.CUSTOMERS/* This is where the leading whitespace of the K&R open commnent is removed */
/* This is preserved */
-- This is preserved
/* This is where the leading whitespace of the K&R open commnent is removed
*
*
* This is preserved
*
*
*/
WHERE CUSTOMERNUMBER > 103 AND CUSTOMERNUMBER < 120 -- This is preserved
org.eclipse.datatools.sqltools.parsers.sql.query.AbstractSQLQueryParser populates the domain model with sqoToAppendComment.getSourceInfo().getComments().add(comment);, the (comment) is dreived using org.eclipse.datatools.sqltools.parsers.sql.AbstractSQLQueryParser. The leading spaces are not preseverd, at best I will insert 1 space to stop the truncating and confusing look of lines where this has happend with K&R "/* */" style comments and is consitent with the "--" comment. Created attachment 119174 [details]
K&R style comment formatting
This patchBZ202602.txt is to add 1 leading space to any K&R style ("/* */") comment to visualy aid the format of the SQL statement ,when it is loaded/unloaded into the SQL Query Builder.
Hi Duncan, Rather than modifying the parsing side of things, it would make more sense to change the SQL Source Writer. Take a look at the appendComment(SQLComment comment, StringBuffer sb) method in the SQLQuerySourceWriter class in the plugin org.eclipse.datatools.modelbase.sql.query. Created attachment 119293 [details]
SQLQuerySourceWriter add a space to leading multiline comment
The example that follows has it's formatting preservedwhen entering or leaving the SQB Statement editor
Example:
UPDATE APP.TESTTABLE_LOOOOOOONGNAME
SET C2_VARCHAR_LONGNAME = (
SELECT C2_VARCHAR --<< WHAT HAPPENS HERE is ?
FROM APP.TESTTABLE /* <<THIS IS WHERE IT HAPPENS */
WHERE C1_INTEGER = 1), C3_CHAR_LOOOOOOOOOOONGNAME
/* this is the first line of comment
* 2nd
* 3rd
*/
= (
SELECT C3_CHAR -- << WHAT HAPPENS HERE is ?
FROM APP.TESTTABLE
WHERE C1_INTEGER = 1)
WHERE C1_INTEGER_LONGNAME = 1
OK, looks good. I'll check in the change. Checked in the change, tagged to v200901241145 (DTP_1_6_2_Branch) and v200901241150 (HEAD). |