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.

View | Details | Raw Unified | Return to bug 200479
Collapse All | Expand All

(-)a/db.sql.editor/src/org/netbeans/modules/db/sql/lexer/SQLLexer.java (-11 lines)
Lines 163-172 Link Here
163
                // If we are currently in a string literal.
163
                // If we are currently in a string literal.
164
                case ISI_STRING:
164
                case ISI_STRING:
165
                    switch (actChar) {
165
                    switch (actChar) {
166
                        case '\\': // NOI18N
167
                            // escape possible single quote #152325
168
                            state = State.ISA_BACK_SLASH_IN_STRING;
169
                            break;
170
                        case '\'': // NOI18N
166
                        case '\'': // NOI18N
171
                            state = State.ISA_QUOTE_IN_STRING;
167
                            state = State.ISA_QUOTE_IN_STRING;
172
                            break;
168
                            break;
Lines 185-195 Link Here
185
                    }
181
                    }
186
                    break;
182
                    break;
187
183
188
                // If we are after a back slash (\) in string.
189
                case ISA_BACK_SLASH_IN_STRING:
190
                    state = State.ISI_STRING;
191
                    break;
192
193
                // If we are currently in an identifier (e.g. a variable name),
184
                // If we are currently in an identifier (e.g. a variable name),
194
                // or a keyword.
185
                // or a keyword.
195
                case ISI_IDENTIFIER:
186
                case ISI_IDENTIFIER:
Lines 369-375 Link Here
369
                break;
360
                break;
370
361
371
            case ISI_STRING:
362
            case ISI_STRING:
372
            case ISA_BACK_SLASH_IN_STRING:
373
                id = SQLTokenId.INCOMPLETE_STRING; // XXX or string?
363
                id = SQLTokenId.INCOMPLETE_STRING; // XXX or string?
374
                part = PartType.START;
364
                part = PartType.START;
375
                break;
365
                break;
Lines 469-475 Link Here
469
        ISI_INT, // integer number
459
        ISI_INT, // integer number
470
        ISI_DOUBLE, // double number
460
        ISI_DOUBLE, // double number
471
        ISA_DOT, // after '.'
461
        ISA_DOT, // after '.'
472
        ISA_BACK_SLASH_IN_STRING, // after \ in string
473
        ISA_QUOTE_IN_STRING,        // encountered quote in string - could be sql99 escape
462
        ISA_QUOTE_IN_STRING,        // encountered quote in string - could be sql99 escape
474
        ISA_QUOTE_IN_IDENTIFIER     // encountered quote in identifier - could be sql99 escape
463
        ISA_QUOTE_IN_IDENTIFIER     // encountered quote in identifier - could be sql99 escape
475
    }
464
    }
(-)a/db.sql.editor/test/unit/src/org/netbeans/modules/db/sql/lexer/SQLLexerTest.java (-18 / +9 lines)
Lines 145-169 Link Here
145
        TokenSequence<SQLTokenId> seq = getTokenSequence("'incomplete");
145
        TokenSequence<SQLTokenId> seq = getTokenSequence("'incomplete");
146
        assertTokens(seq, SQLTokenId.INCOMPLETE_STRING);
146
        assertTokens(seq, SQLTokenId.INCOMPLETE_STRING);
147
    }
147
    }
148
148
    
149
    public void testEscapeSingleQuote() throws Exception {
149
    public void testSingleQuote() throws Exception {
150
        TokenSequence<SQLTokenId> seq = getTokenSequence("'Frank\\'s Book'");
150
        // See bug #200479 - the fix introduced with this text reverts a "fix"
151
        assertTrue(seq.moveNext());
151
        // for bug #152325 - the latter bug can't be fixed, as it is clear violation
152
        assertEquals(SQLTokenId.STRING, seq.token().id());
152
        // to SQL Standard - as this is a SQL lexer, not a MySQL lexer, this should
153
        assertEquals("'Frank\\'s Book'", seq.token().text().toString());
153
        // should follow the standard
154
154
        TokenSequence<SQLTokenId> seq = getTokenSequence("'\\'");
155
        seq = getTokenSequence("'Frank\\s Book'");
155
        assertTokens(seq, SQLTokenId.STRING, SQLTokenId.WHITESPACE);
156
        assertTrue(seq.moveNext());
157
        assertEquals(SQLTokenId.STRING, seq.token().id());
158
        assertEquals("'Frank\\s Book'", seq.token().text().toString());
159
160
        seq = getTokenSequence("'Frank\\");
161
        assertTokens(seq, SQLTokenId.INCOMPLETE_STRING);
162
163
        seq = getTokenSequence("'Frank\\'");
164
        assertTokens(seq, SQLTokenId.INCOMPLETE_STRING);
165
    }
156
    }
166
157
    
167
    /**
158
    /**
168
     * Check correct handling of multiline comments (bug #)
159
     * Check correct handling of multiline comments (bug #)
169
     *
160
     *

Return to bug 200479