Standardize Format Question

  1. 4 months ago

    jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    I'm hoping someone has an IDE script or something for this...

    I really like the Standardize Format option in the IDE. Thing is, I have some large projects that were written without the option turned on. They are under version control, so anytime I'm working I end up with a handful of lines that have only had uppercase added to a character or two, making a mess in my commit.

    It would be nice to be able to just standardize the whole project in one shot and have a single commit that is just "standardize format".

    Any ideas other than cursoring through every line manually to update the formatting? (that would take hours...)

  2. Jürg O

    Jun 11 Pre-Release Testers, Xojo Pro
    Edited 4 months ago

    @jim m It would be nice to be able to just standardize the whole project in one shot and have a single commit that is just "standardize format".

    I'd love that, too... And for that I've added this Feature Request in 2017: Feedback Case #47517

    A workaround would be an IDE Script, which iterates over the project, selects every "project item", traverses through it's "code items", select all, applies "Standardize Format". But it seems that's also not possible - according to this forum thread .

    So I guess our best chance is to let Xojo know that implementing this Feature Request is of interest to many developers :)

    @ThomasTempelmann : Maybe Arbed can do that?

  3. jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    I think IDE Communicator could be used... I'd just need to manually read the project and get all the items, then look at each item to get the dot notation for each method/event etc. (my doc generator has some code I could possibly recycle)

    Or... is there any way to get a list of the methods etc from a project item? I can select a method as long as I know it's name, but there's no way I can see to get the names? Getting the project items can be done, but not methods etc?

  4. Norman P

    Jun 11 Pre-Release Testers, Xojo Pro great-white-software.com/blog
    Edited 4 months ago

    there isnt
    had a long discussion with another user about this
    IDE script was not intended for this kind of usage amd grew up out of an early need to be able to do some automation of builds (way back in around 2005-2010) as builds were largely done by hand
    And it has remained mostly that way with a few bits & pieces added on over the years

    In order to facilitate the kind of usage you want to make of it IDE scripting would need to expose some kind of "project model" where you could have a ProjectItem (class, folder, module, etc) and then iterate over all of them in a project
    For each of these you would need a way to ask how many code items it contained of a certain type (method, constants properties, etc) and iterate over those
    And you would need to be able to ask each project item how many items it contained since folders and modules can contain other items
    Once you had these building blocks you could probably recursively iterate across an entire project and run a reformat script

    But you'd also want things like being able to add new items (apparently a fair number of people use ID scripting to generate code (?) )
    So you would need methods to add new properties, methods, events event handlers, properties, etc
    And constants - you would want to be able to create them with a specific name, type and default
    And then a mechanism to add specific localized values (regardless of whether its a localized string or not since localized values also work for integers etc but they are resolved at build time not runtime)

    It's a non-trivial amount of work to do
    And I know there is a FR for this
    Gee look at that :P
    Feedback Case #16236

    Yeah I've thought about this before :)

  5. jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    It looks like (for my purpose) the only thing missing is that subLocations doesn't return anything for a regular project item (class/window/etc). If it just dumped out a list of all the events/methods/properties etc. I could work with that. Or if item.properties, item.methods etc returned a list...
    It can select a method/property etc if I know the name, and I can iterate all the nested project items... just can't get any info about an item.

  6. Norman P

    Jun 11 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    Sublocations is what contained project items are there

  7. jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    Right, but a method is a location in a class... so wouldn't it make sense for subLocations("someclass") to return the subLocations of the class? typeOfCurrentLocation works on a method, therefore a method is a location. So either it should be called subItems, or return the locations like it says...
    That one addition would open a ton of possibilities...

  8. Norman P

    Jun 11 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    see my previous post
    https://forum.xojo.com/conversation/post/441037

    might it ? I suppose - have no idea about the implications of it
    it just never did and now I suspect there is other script code that might depend on its current behaviour so adding this might break things
    lord knows

  9. jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    Yeah, I could see where people might check for an empty return string to know they've reached a class/window/menubar... that would break if it was changed. They should be relying on TypeOfCurrentLocation, but that doesn't mean they are. *shrug*

  10. Norman P

    Jun 11 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    yup
    like https://graffitisuite.com/news/from-anthony-xojo-ide-scripting/

  11. jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    That doesn't rely on subLocations returning ""... it rely's on SelectProjectItem returning False to determine if an item is a folder, but that's not really related.

  12. Norman P

    Jun 11 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    that might work
    again I have no idea what would break if anything
    but it still leaves a lot of things that cannot be done very well with the current implementation
    and thats what that FR was about - addressing those things that cant be done well

  13. jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    Right... now that I'm messing with it, if you set location to a control... it reports Window for TypeOfCurrentLocation and "" for subLocations. Same results as if you select a window. It does let you select window.control.event though. I just wish there was a way to know about those locations.

    I think your FR goes a lot deeper than what I'm looking for.

  14. jim m

    Jun 11 Pre-Release Testers, Xojo Pro piDog.com

    @Jürg O For now, I hacked together a little app that you can drag a .xojo_project to. It just parses through the files and finds all the events and methods. Then it sends a script to the ide to select each one and then do "text=text" to fire the Standardize Format stuff.

    No handling for computed properties yet. I'm going to run it on one of my larger projects overnight and see how it does. Seems like it's probably going to take quite a while...
    If it looks like it mostly worked, I'd be happy to share.

or Sign Up to reply!