Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 170322 Details for
Bug 314836
ASTParser fails on enums when setSource(char[] source) is used
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
JUnit test to reproduce the error.
EnumTestCase.java (text/plain), 1.51 KB, created by
David Schuler
on 2010-05-28 05:46:29 EDT
(
hide
)
Description:
JUnit test to reproduce the error.
Filename:
MIME Type:
Creator:
David Schuler
Created:
2010-05-28 05:46:29 EDT
Size:
1.51 KB
patch
obsolete
>package test; > >import static org.junit.Assert.*; > >import org.eclipse.core.runtime.IProgressMonitor; >import org.eclipse.jdt.core.dom.AST; >import org.eclipse.jdt.core.dom.ASTParser; >import org.eclipse.jdt.core.dom.ASTVisitor; >import org.eclipse.jdt.core.dom.CompilationUnit; >import org.eclipse.jdt.core.dom.EnumConstantDeclaration; >import org.eclipse.jdt.core.dom.Message; >import org.junit.Test; > >public class EnumTestCase { > > private int enumCount; > > @Test > public void testSetSource() throws Exception { > String enumString = "enum A { E1, E2; }"; > ASTParser parser = ASTParser.newParser(AST.JLS3); > // If the following lines are activated test passes. > // Hashtable options = JavaCore.getOptions(); > // options.put("org.eclipse.jdt.core.compiler.source", "1.6"); > // parser.setCompilerOptions(options); > parser.setKind(ASTParser.K_COMPILATION_UNIT); > parser.setSource(enumString.toCharArray()); > parser.setResolveBindings(false); > final CompilationUnit compU = (CompilationUnit) parser > .createAST((IProgressMonitor) null); > compU.accept(new ASTVisitor() { > @Override > public boolean visit(EnumConstantDeclaration node) { > enumCount++; > return super.visit(node); > } > /* > * Just to display the error message. > */ > @Override > public void endVisit(CompilationUnit node) { > Message[] messages = node.getMessages(); > for (Message message : messages) { > System.out.println(message.getMessage()); > } > super.endVisit(node); > } > }); > assertEquals("Expected 2 enum constants", 2, enumCount); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 314836
: 170322 |
170559
|
170625