Monday, August 15, 2005

Time to put on some Beach Boys records and surf some Eclipse code.

First, I search for *Template*.java, and get a number of hits.

Among them, I find:
which contains a definition of a constant NEWTYPE_ID that looks promising.

I want to see where the new types are created, so I right-click and look for references in the workspace for NEWTYPE_ID. It has 3 references, the first 2 of which don't lead much of anywhere, but the 3rd, "" leads to another utility class called "CodeGeneration" that has a static wrapper for the StubUtility.getCompilationUnitContent method.

This method CodeGeneration.getCompilationUnitContent is called in a few places, one of which is called "NewTypeWizardPage.createType." Looks like we're getting warm. This is a pretty long function - about 150 lines, and McCabe complexity around 19. In the middle of all that, it seems to handle two major cases. First case, top-level class (or not-inner-class as the function logic goes) - second case, inner class. Then in the midst of these code blocks, when you try to find where the action really is in all the subroutines, you find calls to a method "constructTypeStub" in the same class.

It is finally here, in org.eclipse.jdt.ui.wizards.constructTypeStub, where we find the code to build the text that creates a new type. It is here where I believe I'll want to make my change to interpolate the class comments in between the class's brackets.

Now I need to make a call as to how to design the solution, and make my problem and desired solution known to the Eclipse committers. But that's for the next installment...


Post a Comment

<< Home