Code Beautyfier for the IDE (also useful for jaPBe)
Posted: Sun Jan 06, 2008 5:17 am
While working on the OOP parser which outputs the converted code also in a beautyfied way, I thought this also would be nice as a standalone plugin.
Its a Plugin primary build for the IDE but it also does it's job with jaPBe properly.
The beautyfing will be performed on the selected code area.
It also does handle code to be indented within Macros properly like ...
And ... it does re-arrange the tokens of the selected code.
Like:
gets polished to ...
Also all unneeded white spaces at the end of codelines will be deleted.
To apply this function
The code is a simple merge of two modules: The code from Remi meiers lexer in combination with a Tokenarray and the Indentation tool of HeX0R.
http://www.purebasic.fr/german/viewtopic.php?t=8691
http://www.purebasic.fr/german/viewtopic.php?t=10418
In case of jaPBe Im forced to use "%FILE" instead of the argument "%TEMPFILE" as used in the IDE. This makes jaPBe overwriting the existing original code, so you can decide by altering the setup of the tool if you first want to try by letting the plugin writing the cleaned up code into a new file instead of overwriting the existing one.
Here's a howTo install of the pluigin for the IDE:
Now there is a new syntax for the arguments used.
When using this plugin with the IDE the argument "%TEMPFILE" is still obligatory. Beside Indentation there can be done a codebeautifying as well, just add the argument -b and for a proper alignment of PB contants Lines just add -c.
You also can set up individual entries in the tools section where only the indentation will be applied, or combined with -b, or even combined with -b and -c.
The argument syntax "%TEMPFILE" "%SELECTION" "%BEAUTIFY" will be no longer supported.
And for jaPBe:
In case of jaPBe instead of just "%TEMPFILE" you HAVE TO use "%FILE" "%SCI and if wanted followed by -b and -c (see above). Also here you can setup individual entries in the jaPBe's tools section using individual arguments.
As said, be aware the in the example above jaPBe does reload the cleaned up code into the current source. As this state actually is beta, you should work with copies for testing purposes or let the tool reload the code into a new source.
Means: This is beta, so no warranty.
Update: http://www.file-upload.net/download-600 ... y.exe.html
Here still a link to the old version - just in case.
An alternate version where the operators wont be separated by whitespaces:
http://www.file-upload.net/download-600 ... s.exe.html
Here as well a link to the old version.
... becomes ...
Changelog:
09.01.2007:
- New Syntax of arguments
- Selection now also supported for jaPBe
- Constand assignments now can be aligned horizontally to "=" (like in jaPBe's Select+ALT+STR+TAB)
06.01.2007:
-Bugfix if "If \number" was used, no whitespace Separator has been applied.
Its a Plugin primary build for the IDE but it also does it's job with jaPBe properly.
The beautyfing will be performed on the selected code area.
It also does handle code to be indented within Macros properly like ...
Code: Select all
Macro TestCode()
If x < 0
If r = j
z = x
EndMacro
Like:
Code: Select all
Procedure.l Functions (a,b,c, e.l, string="default" )
Protected j.l =0
if a+b /c= gVar
string="hello"
Endif
EndProcedure:FreeMemory( *mem)
#CONSTANT_A = $FF
#ERROR = 0
#DELETE_KEYWORD = "del"
Code: Select all
Procedure.l Functions(a, b, c, e.l, string = "default")
Protected j.l = 0
if a + b / c = gVar
string = "hello"
Endif
EndProcedure : FreeMemory(*mem)
#CONSTANT_A = $FF
#ERROR = 0
#DELETE_KEYWORD = "del"
To apply this function
The code is a simple merge of two modules: The code from Remi meiers lexer in combination with a Tokenarray and the Indentation tool of HeX0R.
http://www.purebasic.fr/german/viewtopic.php?t=8691
http://www.purebasic.fr/german/viewtopic.php?t=10418
In case of jaPBe Im forced to use "%FILE" instead of the argument "%TEMPFILE" as used in the IDE. This makes jaPBe overwriting the existing original code, so you can decide by altering the setup of the tool if you first want to try by letting the plugin writing the cleaned up code into a new file instead of overwriting the existing one.
Here's a howTo install of the pluigin for the IDE:
Now there is a new syntax for the arguments used.
When using this plugin with the IDE the argument "%TEMPFILE" is still obligatory. Beside Indentation there can be done a codebeautifying as well, just add the argument -b and for a proper alignment of PB contants Lines just add -c.
You also can set up individual entries in the tools section where only the indentation will be applied, or combined with -b, or even combined with -b and -c.
The argument syntax "%TEMPFILE" "%SELECTION" "%BEAUTIFY" will be no longer supported.
And for jaPBe:
In case of jaPBe instead of just "%TEMPFILE" you HAVE TO use "%FILE" "%SCI and if wanted followed by -b and -c (see above). Also here you can setup individual entries in the jaPBe's tools section using individual arguments.
As said, be aware the in the example above jaPBe does reload the cleaned up code into the current source. As this state actually is beta, you should work with copies for testing purposes or let the tool reload the code into a new source.
Means: This is beta, so no warranty.
Update: http://www.file-upload.net/download-600 ... y.exe.html
Here still a link to the old version - just in case.
An alternate version where the operators wont be separated by whitespaces:
http://www.file-upload.net/download-600 ... s.exe.html
Here as well a link to the old version.
Code: Select all
Procedure.l Functions (a,b,c, e.l, string="default" )
Protected j.l =0
if a+ b /c= gVar
string= #PB_Compiler_Home + "File.pbi"
Endif
EndProcedure:FreeMemory( *mem)
Code: Select all
Procedure.l Functions(a, b, c, e.l, string="default")
Protected j.l=0
if a+b/c=gVar
string=#PB_Compiler_Home+"File.pbi"
Endif
EndProcedure : FreeMemory(*mem)
Changelog:
09.01.2007:
- New Syntax of arguments
- Selection now also supported for jaPBe
- Constand assignments now can be aligned horizontally to "=" (like in jaPBe's Select+ALT+STR+TAB)
06.01.2007:
-Bugfix if "If \number" was used, no whitespace Separator has been applied.