SQL AutoComplete

Questions on using RSyntaxTextArea should go here.

Moderator: robert

SQL AutoComplete

Postby X-Root » Thu Dec 02, 2010 11:25 pm

is AutoComplete library is available to use now ?

if yes can you give me a small example ?
X-Root
 
Posts: 1
Joined: Thu Dec 02, 2010 11:20 pm

Re: SQL AutoComplete

Postby robert » Fri Dec 03, 2010 7:56 pm

Hi X-Root,

Are you asking specifically about SQL code completion? If so, that isn't available out-of-the-box, and I'm not familiar enough with it myself to be comfortable adding it. If you've used RSyntaxTextArea's AutoComplete library some already, and feel ambitious, you can try to create your own, in which case I'd invite you to look at the C and Shell language supports in RSTALanguageSupport. They're both pretty straightforward examples of adding code completion support to RSTA (provided what completions you want to make available are mostly static).

Also, if you do choose to go this route, if you'd like to share your implementation, I'd be happy to add it into the RSTALanguageSupport repository so others can benefit from your hard work. The only thing is you'd have to be comfortable with licensing your code LGPL.
User avatar
robert
 
Posts: 639
Joined: Sat May 10, 2008 5:16 pm

Re: SQL AutoComplete

Postby franz » Fri Jul 29, 2011 3:49 pm

Hi,

we are also planning to use RSTA and the Autocompletion package for an SQL editor. We made some tests with the libraries and are surprised how fast we could integrate RSTA in an existing swing application.

  • Is it possible to reuse the autocompletion feature for a command line tool? We are querying our database not only from a swing application. But I saw, that the auto completion interface requires swing specific objects as input parameters. Do you think this should be feasible?
  • We also want to autocomplete the Identifiers of database objects, that means 'STRG+Space' would for example suggest all tables and views currently existing in the database. How would you think this task should be implemented using RSTA and Autocompletion package at its best?
  • What is the difference between Shorthand Completion and Code Templates? When should I use the one or the other?
  • In later steps we would like to make the autocompletion feature more and more context-sensitive. I saw that your java code completion uses parsing techniques, so I think it should be possible to use a parser of our choice and step by step, we could refine and filter the possible completions to make our SQL auto completion more and more context-sensitive using RSTA and Autocompletion package?

Thanks for answering this long list of questions!

Kind regards,

Franz
franz
 
Posts: 5
Joined: Fri Jul 29, 2011 3:29 pm

Re: SQL AutoComplete

Postby Guest » Tue Aug 02, 2011 8:58 am

Hi,
I sent a reply some days ago with my account 'franz'. But it seems that logged in users' posts need to be approved, whereas guests can reply immediately?
Seems to be a bug to me...

Kind regards,
Franz
Guest
 

Re: SQL AutoComplete

Postby robert » Tue Aug 02, 2011 11:52 am

Hi Franz,

Sorry, I missed your post. I also took the liberty of removing your "test" posts, I'm assuming you won't mind!

As for your questions:

  • This wouldn't be feasible for the reason you noticed - it's very heavily tied into Swing. It would take some heavy refactoring and I'm not sure I'm motivated to do the task, since command line code auto-completion probably has a limited audience.
  • Possible performance issues aside, the simplest way do to that is to create your own CompletionProvider, probably subclassing DefaultCompletionProvider, as it does the most work for you (Javadoc for the API is here). You'd override getCompletionsImpl() to hit the database and figure out what completions match the text at the current caret position. You'd clear the protected "completions" List member inherited from AbstractCompletionProvider on each call, and refill it with all possible completions.
  • Code templates were added way before ShorthandCompletions came to be. You're right that they essentially provide the same functionality. There is a bug in CodeTemplateManager, however, so that it always looks to insert templates on space chars being typed; whatever you pass to CodeTemplateManager.setInsertTrigger() is ignored. On the other hand, code templates allow you to place the caret in the middle of text inserted, while ShorthandCompletions always place the caret after the text inserted. I've considered fixing this deficiency for ShorthandCompletions, but haven't done any work on it yet. So long story short, if you're using the AutoComplete library I'd probably stick with ShorthandCompletions, but take the "gotchas" above into consideration when choosing which one to use.
  • Absolutely. When you go that far, you tend to move away from using DefaultCompletionProvider and use one of the abstract classes it's based on to give you more flexibility.

Hope this helps! Let me know if you need any more assistance.
User avatar
robert
 
Posts: 639
Joined: Sat May 10, 2008 5:16 pm

Re: SQL AutoComplete

Postby franz » Thu Aug 04, 2011 5:07 pm

Hi Robert,
thanks for your answers.
We managed to use the TokenMakerMaker and generated our own SQLTokenMaker for syntax highlighting. For auto completion, we took the CCompletionProvider as a template and it works great so far. A step we still have to accomplish is to generate the XML file for auto completion (functions, keywords,...), but this should be finished next week. To autocomplete table names, view names, schema names and so on (all the metadata), we will override and reuse the getCompletionsImpl from LanguageAwareCompletionProvider which loads the XML and will add the metadata information, if a database connection is available.

That's it?

Kind regards,

Franz
franz
 
Posts: 5
Joined: Fri Jul 29, 2011 3:29 pm

Re: SQL AutoComplete

Postby robert » Mon Aug 08, 2011 1:14 am

Yes, that sounds like a plan. Let me know how it goes!
User avatar
robert
 
Posts: 639
Joined: Sat May 10, 2008 5:16 pm

Re: SQL AutoComplete

Postby goran_schwarz » Tue Aug 23, 2011 12:47 pm

Franz, how is your work progressing?
I would want to try it if you have anything that works :)

Regards
Goran
goran_schwarz
 
Posts: 4
Joined: Tue Aug 23, 2011 12:38 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron