Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-20045

Support intelligent re-quoting / entangled quoting.

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 4.5.1
    • Editors
    • None

    Description

      While it was never an issue in C/C++ because quotes are tied to char and string datatypes, other languages like JS and Python do not make a distinction between quotes. However occasionally the need arises to re-quote a string, anecdotally when working with SQL. and a value needs to be included where it hasn't been previously. 

      'SELECT X FROM T' + where clause = 'SELECT X FROM T WHERE Y='VALUE' '

      At this point the statement cannot be properly parsed. The outer quotes need to be changed to " 

      It is not expected that QtCreator detect this conflict, but having the user select text, or even just the starting or trailing quote, and changing the quote character should produce a change at the other quote:

       

      Cases: [ ] indicate selected characters:

      '[this is some text]' + " = "[this is some text]" (as opposed to "'[this is some text']'"

      [']this is some text' + " = "this is some text" ("entangled quotes")

      ']this is some text['] + " = "this is some text" ("entangled quotes")

      [this is some text] + ' = '[this is some text]' (goto first example)

      There is some ambiguity where behavior is not well-defined, but I think we can find a sensible behavior:

      'SELECT X FROM T WHERE Y='VALUE''

      The challenge is do we pair the first and second or first and last quotes? I think if we define start and inner quotes, we'll get an intelligent answer.

      'C  - start  quote

      C'C - inner quote

      C' end quote

      So the text within the span of change is the mating quote as defined by a stack of start and end quotes, with inner quotes ignored unless it's he last quote.  So the following examples will work:

      'SELECT X FROM T WHERE Y='VALUE'' - start inner inner end

      'SELECT X FROM T WHERE Y = 'VALUE' ' - start start end end

      'SELECT X FROM T WHERE Y = 'VALUE'' - start start inner end

      We do have do define C a little bit because a commas should not change the quote:

      'string 1','string 2' != "string 1','string1",  instead == "string 1",'string 2'

      Of course, these are not hard rules, they are just to describe the desired outcome. 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            davschul David Schulz
            scorp1us Jason Hihn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes