Closed feifeiniu-se closed 1 year ago
@feifeiniu-se
Methods recursiveGetKeys()
and getStartingContextPoint()
declare a variable named enum
, which is a reserved keyword since Java 1.5
So, the parser fails to parse the body of these methods.
The way to overcome this is to set the parser with Java 1.4 compatibility
Map<String, String> options = JavaCore.getOptions();
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
parser.setCompilerOptions(options);
However, checking whether the file contains a variable named enum
has a computation cost, and thus I don't want to implement this check.
This is the diff of the methods.
It is clear that parameter NamingEnumeration enum
becomes a local variable (Localize Parameter refactoring) and Context parentContext
is an added parameter.
The same parameter Context parentContext
is also added in method getStartingContextPoint()
https://github.com/apache/commons-configuration/commit/92bf8ccdad173f1f5d4a506043d443fd0cac09a6, in this commit, I didn't see any Add Parameter refactoring, but change parameter "NamingEnumeration enum" into "Context parentContext", the original method declaration didn't exist "private recursiveGetKeys(keys List) : void".