Block.methodBody creates a temporary MethodScope containing the method's parameter names, allowing code to create temporary variables and reference fields without risking a clash. However, nothing checks the passed in parameter list, leaving it vulnerable to refactoring and copy/paste errors.
Instead, enhance SourceParser to pull out parameters from method declarations directly, calling back into CompilationUnitBuilder to create the MethodScope.
Block is now redundant and has been deleted, leaving the Property classes a little tidier. SourceBuilder.subScope is similarly gone.
Note: As part of this work, I used the two different ways of obtaining the same information (source parsing and methodBlock calls) as a consistency check, and discovered a copy/paste error in SortedSetProperty, so I feel rather vindicated.
Block.methodBody creates a temporary MethodScope containing the method's parameter names, allowing code to create temporary variables and reference fields without risking a clash. However, nothing checks the passed in parameter list, leaving it vulnerable to refactoring and copy/paste errors.
Instead, enhance SourceParser to pull out parameters from method declarations directly, calling back into CompilationUnitBuilder to create the MethodScope.
Block is now redundant and has been deleted, leaving the Property classes a little tidier. SourceBuilder.subScope is similarly gone.
Note: As part of this work, I used the two different ways of obtaining the same information (source parsing and methodBlock calls) as a consistency check, and discovered a copy/paste error in SortedSetProperty, so I feel rather vindicated.