To be clear (and to make things easier), the plugin doesn’t have to do the 
indentation itself. It may be simpler (and probably preferred) to simply figure 
out what the new indentation rules should be and dynamically change the 
indentation preferences in NetBeans to the values you figured out. NetBeans 
already has indentation code so let it do the heavy lifting for you.

I haven’t looked at the code, but I assume NetBeans has an event for when a 
file is activated for editing (that is, the file is opened or switched to). I 
imagine that this plugin could just listen for that event, and in the handler:
look at the existing code to figure out what the indentation rules should be
the three preferences to figure out are standard indentation, label 
indentation, and continuation indentation
if you can’t figure out all three of the above settings by looking at the code, 
figure out sensible settings by looking at the current preferences
override NetBeans’ own preferences to those new values

…and you’re done!

One potential complication I foresee is that NetBeans itself overrides these 
preferences with its project-specific formatting preferences, so the plugin 
would need to make sure it overrides those as well. This plugin should not 
however change those project-specific preferences on disk—that would be a 
headache because version control would pick up the change. Again, I haven’t 
looked at the code so I don’t know if this is actually an issue.

-Alvin


> On Dec 10, 2019, at 12:46 PM, Alvin Thompson <[email protected]> wrote:
> 
> Hi,
> 
> Assuming that this email doesn't get flagged as spam due to the subject line, 
> this is just a reminder that I have a bounty for anyone who creates a 
> NetBeans plugin that detects and uses the existing indentation of the file 
> being edited. For any indentation info that can not be gleaned from the file, 
> it should fall back to the preferences. This really is an absolute must team 
> work these days.
> 
> You get $100 for coming up with the plugin, and another $100 if it gets 
> donated and makes it into NetBeans itself. But I imagine most people will 
> want to do this so that I have a slightly higher opinion of them.
> 
> I would do this myself but I am very, very lazy.
> 
> That is all,
> Alvin
> 

Reply via email to