Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Problems with enums when building AST
Problems with enums when building AST [message #1117726] Thu, 26 September 2013 19:00 Go to next message
j vl is currently offline j vlFriend
Messages: 5
Registered: September 2013
Junior Member
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.

This is how I obtain the ompilation unit:

public static CompilationUnit GetCU(String path) {
	ASTParser parser = ASTParser.newParser(AST.JLS4);

	String f = null;
	f = readFile(path);
	parser.setSource(f.toCharArray());

	parser.setKind(ASTParser.K_COMPILATION_UNIT);
	return (CompilationUnit) parser.createAST(null);
}


Any help, would be appreciated.

Thanks
Re: Problems with enums when building AST [message #1117753 is a reply to message #1117726] Thu, 26 September 2013 19:34 Go to previous message
j vl is currently offline j vlFriend
Messages: 5
Registered: September 2013
Junior Member
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);
	}
Previous Topic:JSF Support
Next Topic:Problem with enums when building an AST
Goto Forum:
  


Current Time: Thu Apr 25 08:04:13 GMT 2024

Powered by FUDForum. Page generated in 0.02794 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top