View unanswered posts | View active topics


Reply to topic  [ 55 posts ]  Go to page 1, 2, 3, 4  Next
FDFlexFormatter v0.2 
Author Message
Member

Joined: Thu Jul 30, 2009 12:41 pm
Posts: 12
Post FDFlexFormatter v0.2
Description

This is a MXML and AS3 coder formatter for FlashDevelop 3. It's a port of FlexFormatter, an Eclipse plugin by Ernest Pasour.
The formatter is working, no extensive tests where done although. Please try it and give me some feedback.

This plugin has LOTS of preferences, so a Preferences Editor should to be done.

I'll be releasing the sources as soon as possible, it would be great if I could add them to the Flashdevelop SVN.

Installation

Copy FDFlexFormatter.dll, Antlr3.Runtime.dll, Antlr3.Utility.dll into the plugins folder of your FD Application Files

Usage

Press Ctrl+Shift+2 while editing an AS3, MXML or XML file to format code (you can change the shortcut)

Download
Download the plugin:
This plugin has been included in FD4. Just press Ctrl+Shift+2

UPDATE [02-07-2009]
When formatting files with lots of text, the algorithm that calculates the position of the cursor was really slow.
I compiled a version that resets the cursor position to the beginning of the file as a temporary fix :D

Download it here (link not available):

UPDATE [03-07-2009]
Version 0.2
Fixes the set current position bug.
link not available


Last edited by fmotagarcia on Wed Sep 07, 2011 10:27 pm, edited 6 times in total.



Sun Aug 02, 2009 8:17 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10735
Location: Paris, France
Post Re: FDFlexFormatter v.1
Right, the preferences are not really friendly ;) I was lucky when I randomly changed the BraceStyle to 1.

It works, however it seems very CPU intensive - FD froze for several seconds when trying to reformat TweenLite's main class. I guess it is related to the way your plugin reads and writes the source code: you should work on a copy of the document text then change the source as a whole.


Sun Aug 02, 2009 8:37 pm
Profile WWW
Member

Joined: Thu Jul 30, 2009 12:41 pm
Posts: 12
Post Re: FDFlexFormatter v.1
The issue was really not with the parser/formatter. It was with the algorithm that calculates the cursor position. I guess I'll have to work on that :mrgreen:

Thanks for the feedback, by the way ;)


Sun Aug 02, 2009 9:37 pm
Profile
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1220
Location: Grizzly Flats, CA
Post Re: FDFlexFormatter v.1
If you haven't already, you might also look into placing the process in its own thread. Threading is an easy way to keep the interface from freezing, no matter how intensive your process is.

For example, I think the BackgroundWorker class will let you run a function as a different thread and respond to an event when it is finished.


Sun Aug 02, 2009 10:03 pm
Profile WWW
Member

Joined: Thu Feb 09, 2006 10:58 am
Posts: 943
Location: Israel
Post Re: FDFlexFormatter v.1
But would it let the ser to edit the file while it is being formatted?

_________________
MovieClipCommander


Sun Aug 02, 2009 11:54 pm
Profile
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1220
Location: Grizzly Flats, CA
Post Re: FDFlexFormatter v.1
If it was in a background thread it would theoretically let the user edit the page while it is being edited. You would either want the formatting to go so quickly that the user doesn't really notice, or try to find a way to lock out the file or otherwise make it clear that the file is being processed so the user is not surprised if their edits disappear.


Mon Aug 03, 2009 4:50 am
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10735
Location: Paris, France
Post Re: FDFlexFormatter v.1
I don't see any reason for the reformat to be so long - there is certainly something wrong in the processing.


Mon Aug 03, 2009 8:04 am
Profile WWW
Member

Joined: Thu Jul 30, 2009 12:41 pm
Posts: 12
Post Re: FDFlexFormatter v.1
I'm already fixing the algorithm for cursor position. That was taking about 10 to 15 sec's to process in my machine (while the reformat of the TweenLite base class took like 3sec's).

Please let me know how the NOGOTO version of the plugin performs.


Mon Aug 03, 2009 8:24 am
Profile
Member

Joined: Thu Feb 09, 2006 10:58 am
Posts: 943
Location: Israel
Post Re: FDFlexFormatter v.1
the NOGOTO works best for me. 1-2 seconds in medium size classes.

_________________
MovieClipCommander


Mon Aug 03, 2009 9:02 am
Profile
Member

Joined: Thu Sep 08, 2005 8:32 pm
Posts: 301
Location: Virginia
Post Re: FDFlexFormatter v.1
Just curious, any chance you might be using "binary search" approach to get the cursor location?

fmotagarcia wrote:
I'm already fixing the algorithm for cursor position. That was taking about 10 to 15 sec's to process in my machine (while the reformat of the TweenLite base class took like 3sec's).

Please let me know how the NOGOTO version of the plugin performs.

_________________
Image Open source makes me open my wallet for an open world of goods.


Tue Aug 04, 2009 4:57 am
Profile YIM WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10735
Location: Paris, France
Post Re: FDFlexFormatter v0.2
I can't believe restoring the cursor location is such a problem.

As I already suggested: insert a dummy text at cursor location, reformat, then find and remove the dummy text to position the cursor.


Tue Aug 04, 2009 5:30 am
Profile WWW
Member

Joined: Thu Jul 30, 2009 12:41 pm
Posts: 12
Post Re: FDFlexFormatter v0.2
The plugin is already restoring the cursor position with no delay issues. The new version is updated in my original post.

The "tracker text" solution is not as simple as it seems. I would have to create a rule to deal with the tracker text, and the string could not conflict with any existing rules (which are many, by the way). Otherwise the parsing would fail, or introduce unexpected results.

I'll post the code during this week, and everyone is welcome to improve the plugin :mrgreen:


Tue Aug 04, 2009 8:54 am
Profile
Member

Joined: Mon Aug 10, 2009 4:55 pm
Posts: 9
Post Re: FDFlexFormatter v0.2
Wow thanks, best plugin ever!
Now we just need a FD option to have the formatting done automatically when you type a } and then only format everything in the block that was just closed.


Mon Aug 10, 2009 8:25 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10735
Location: Paris, France
Post Re: FDFlexFormatter v0.2
The latest version works much better - only 2s to reformat Tweenlite (with starting braces on new lines).

Great job :)

Weird things happens with native XML (that was somewhat expected - that's not too bad):
Code:
var x:XML = <foo></foo>; // spaces are inserted before <foo>

var x:XML = <foo>
    <bar att={value}/>
</foo>; // gets formatted as one line XML

var x:XML = <foo {att}="value"/>; // syntax error


Mon Aug 10, 2009 9:42 pm
Profile WWW
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1220
Location: Grizzly Flats, CA
Post Re: FDFlexFormatter v0.2
Yeah, this is pretty cool!

I figured out how to get a few of my preferences to work out using the plugin. However, there's two that I just couldn't figure out that you might now how to do:

1. I like braces style 4, except that I couldn't get it to put a space between the parentheses of a function and the bracket

2. I like when it preseves the indenting, because it looks a lot cleaner in FlashDevelop that way. However, it does not preserve tabs for the last line in a function. Is there a setting to fix that?

Thanks and great job!


Mon Aug 10, 2009 10:00 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 55 posts ]  Go to page 1, 2, 3, 4  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.