Sunday, October 09, 2005

The thrilling conclusion...

After all that, I easily finished the changes to complete the 4 new code templates. I added 4 new tests to NewTypeWizardTest to make sure each one works.

I added one test body that is called 4 times with different parameters to cover the 4 different templates. This isn't done in any of the other tests in NewTypeWizardTest, which rely on a fair amount of repeated code. It's the one decent bit of software design I think I've introduced into the eclipse code, and it feels marginally satisfying considering I've had to hold my nose and work my code into designs I never would have used or allowed to perpetuate if I had ownership.

To make sure all was well, I fired up the new Eclipse, and tried each of the templates. I tried adding some of the template variables into the classes, and found you could do some neat code generation things, like embed the class name into a static variable name, or into a string you could use for default functions like logging or security. I added some test cases for things like this into the automated tests, and introduced a bug into the test because I was using the same string for result comparison both pre- and post-processing I had to add a "resultBody" string with the expected substitutions to get the tests to pass.

One last issue - I ran the tests, and both the ui automated suite and "AllAll" had a handful of errors each. None of them looked related to my code, so I figured I would go ahead and submit the patch anyway with some "cover my butt" verbage in the check-in comment.

- - - - - - - - - -

Created an attachment (id=27746) [edit]
Adds 4 new code templates for user-definable type bodies

Here is a new patch that adds 4 code templates users can use to put different
standard default bodies into newly created classes, interfaces, enums, and
annotations. This patch fixes the problem with earlier attempts with the type
name template variable not resolving correctly for inner classes. This patch
also does not introduce any new ${} template variables that are exposed to

The regression tests do not run entirely clean as of this patch, but since I
sync'ed to HEAD rather than an integ, I do not know if the tests would have
been clean before this change. The failed tests are: 5 failures in
RenameTypeTest from refactoring/AllAllTests, one failure in
ModifierCorrectionsQuickFixTest and 5 failures in ReorgQuickFixTest from
ui/AutomatedSuite. I don't think any of my changes caused these failures, and
don't know how to resolve them, but am willing to fix them if somebody can give
me a clue what I did.

- John

- - - - -

Created an attachment (id=27747) [edit]
Tests for user template patch

This patch introduces 4 new tests into NewTypeWizardTest to insure each typekind picks up its body template correctly. It also fixes up the code templatestore tests to include the new templates.

- - - - - - - - - - -

So here it is, the moment of truth. But as usual, I don't have to wait long for a reponse.

- - - - - - - - - - -

I would never copy an installation over an old one, just extract to a new
folder. I have a batch file where I simply have to update the path of the
installation directory.

I released your patch with the following changes:
- Introduced template id constants in CodeGeneration (CodeTemplateContextType is
not API)
- label description changes
- used lineDelimiter instead on '/n', added NPE check after getting the template
(as spec'ed)

Thanks a lot for your help!

Marking this bug as fixed, but feel free to add further improvements.

- - - - - - - - - -

This is looking encouraging. I was wondering if he'd catch the template ID constant thing after his earlier comments, so I wasn't surprised he changed that part. Seems like one more note of appreciation is appropriate...

- - - - - - - - - -

Great - Thanks! It was fun working with you on this.
I'll look forward to picking up the new feature in the next integ.
- John

- - - - - - - - - -

To which Martin wrote back:

- - - - - - - - - -

Thanks a lot for your time and endurance :-)! I think we have a good result!

- - - - - - - - - -

So ends the story of bug 108071 and my first eclipse contribution. I picked up the next integ, and indeed, the new code templates are in there working just like I've always wanted. So one developer can make a difference, and the open source develoment model looks like it's working as advertised.

I could go back to that code template default editing idea, or perhaps some changes to the Team Synchronization functions to add syncing to a label, but I have some other things in life I've been neglecting. So it's bye for now to eclipse contributions and see 'ya next time.


Post a Comment

<< Home