FDT SWFBridge Examples

Showing 1-6 of 6 messages
FDT SWFBridge Examples Alan 5/29/12 8:29 AM
Here's an easily accessible list of example plugins. Feel free to add your own and I'll continue to post new ones to this thread.
Re: FDT SWFBridge Examples Alan 5/30/12 12:58 PM
I've added a very simple one that demos using a Quick Assist to do a text edit. 

It has a video and screenshots that demo it.

Re: FDT SWFBridge Examples Pavel fljōt Pevnitskiy 5/31/12 5:58 AM
So what's the difference here compared to code templates?
Re: FDT SWFBridge Examples Alan 5/31/12 7:30 AM
Good question. It's also reminded me that I need to create more context around the examples - instead of just cranking them out.

For that last example: SimpleQuickAssist, I'll explain why I added it. 

It shows....
  1. A simple example of hooking into FDT's plugin proposal list (CMD+2)
  2. How to evaluate which proposal was chosen ( you can aslo assign different callbacks for each proposal )
  3. How you can evaluate the context of the cursor. You can use this to determine which (if any) proposals to show.
  4. How to store a list of edites to a file (look here, I'm only adding one but you can have as many as you want)
  5. How to send / make a text edit to the file's model (see here).  
  6. How to work with line offsets. This is how you tell the model where to add text and how much.
This example is more about documenting how to use the API, not to demonstrate how far it can be taken. Once you understand what is going on, you start to realize the power.

Getting back to your question of how this is different than a template. It's not even comparable, really mostly to due #2 & #3. Templates are part of autocomplete, you start typing in a template name and hit autocomplete. As you type more of the template name, it gets filtered out. When you select it, the text just gets plopped into the editor.

With templates, you have no control over the context in which the text edit is either called or applied. It just plops down the text edit at the cursor offset and for the length of the text edit (template). There is no enforcement when you can / can't call a template. You can plop a template in the wrong place and break your code. 

Templates are also single shot. It just plops down text and that's it.

Now...suppose you wanted a 'smart' template that....

  • Depending on where I was (e.g. in a method body, is after a particular class declaration,  in a for loop, at the top of the file, at an import statement....), the template is different or doesn't show it self at all.
  • I want to have other things things happen after I select it. Suppose I want to organize and add imports as well.
  • Does more than just plop down code, perhaps it rewrites parts of the line I'm in - or even rewrites the line I'm at and pushes the old code into another method elsewhere.
...you get the idea

On Thursday, May 31, 2012 8:58:49 AM UTC-4, Pavel fljōt Pevnitskiy wrote:
So what's the difference here compared to code templates?
Re: FDT SWFBridge Examples Pavel fljōt Pevnitskiy 5/31/12 8:18 AM
Well now that's an Answer) include some of it in the readme.
Re: FDT SWFBridge Examples Alan 6/1/12 12:45 PM
Repositories have moved to a new home. I skipped any migration of repos, this was simply easier / faster.