Problem with enums when building an AST [message #1106621] |
Wed, 11 September 2013 06:34  |
Eclipse User |
|
|
|
Hi
When obtaining a compilation unit from the following basic enum:
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY;
}
The compilation unit doesn't contain anything and I get the following messages, from within the compilation unit.
Messages:
Syntax error on token "enum", interface expected
Syntax error on token ",", delete this token
I got this problem before and updated all my libraries to the most current being shipped with Eclipse Kepler, but the problem remains.
Any help, would be appreciated.
Thanks
|
|
|
|
|
Re: Problem with enums when building an AST [message #1117754 is a reply to message #1108175] |
Thu, 26 September 2013 15:35  |
Eclipse User |
|
|
|
Fixed it with:
public static CompilationUnit GetCU(String path) {
ASTParser parser = ASTParser.newParser(AST.JLS4);
String f = readFile(path);
parser.setSource(f.toCharArray());
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_7, options);
parser.setCompilerOptions(options);
return (CompilationUnit) parser.createAST(null);
}
|
|
|
Powered by
FUDForum. Page generated in 0.03029 seconds