Sublime Forum

Sublime insert statement syntax highlighting

#1

I have an insert statement and i double click on part of the columns i would like the corresponding value to pop up.

I have written the code for this “matching” - the column to the value.

I just have no idea how to trigger this popup/tooltip.

The example below e.g let bold signify the double click and italics is the value that would be shown in the tooltip/popup

INSERT INTO PERSON (NAME, AGE, ADDRESS, favColor, dates) VALUES (‘Mark’, 12, ‘Blah blah’, ‘red’, TO_DATE(‘2003/05/03 21:02:44’, ‘yyyy/mm/dd hh24:mi:ss’));

I have written the python matching logic (yes it’s ugly don’t judge me) I just dont know how to actually get this to be a plugin.

import re
str = "INSERT INTO PERSON (NAME, AGE, ADDRESS, favColor, dates) VALUES ('Mark', 12, 'Blah blah', 'red', TO_DATE('2003/05/03 21:02:44', 'yyyy/mm/dd hh24:mi:ss'));"
inputString = 'dates'
print str

myList = re.split(" values ", str, flags=re.IGNORECASE)

firstHalf = myList[0]
temp = firstHalf.split(" ")[3:]
firstHalf = "".join(temp)
print firstHalf

secondHalf = myList[1]

firstHalfSplitByCommas = firstHalf.split(",")
position = -1
for i in xrange(len(firstHalfSplitByCommas)):
  if firstHalfSplitByCommas[i].lower() == inputString.lower():
    # i is index 0 dont forget
    position = i
    print position
    print "found it yo"
    break

secondHalf = secondHalf.split("(", 1)[1]
secondHalf = "".join(secondHalf)
secondHalf = secondHalf.rsplit(");", 1)[0]

secondHalfListSplitByCommas = re.split(",(?![^(]*\\))", secondHalf)
//prints 12
print secondHalfListSplitByCommas[position]
0 Likes