Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Enum Declaration not found in CompilationUnit
Enum Declaration not found in CompilationUnit [message #1824424] Wed, 15 April 2020 03:23 Go to next message
Eclipse UserFriend
If an ENUM is declared within a class JDT seems not to be able to resolve it. Most of the time it treats this enum as a field. Here is a reproducible test case.
public final class A{
    
    private enum Status {
        EXPLORED, NOT_EXPLORED, UNKNOWN;
    }
    private class BaritoneChunkCache {
        public Status isAlreadyExplored() {
            return Status.NOT_EXPLORED;
        }
    }
}


I am getting the following CompilationUnit for this code snippet:

public final class A {
  private enum Status;
  {
  }
private class BaritoneChunkCache {
    public Status isAlreadyExplored(){
      return Status.NOT_EXPLORED;
    }
  }}


My parsing code is:
parse (ICompilationUnit icu) {
	ASTParser parser = ASTParser.newParser(AST.JLS11);
	parser.setKind(ASTParser.K_COMPILATION_UNIT);
	parser.setSource(icu);
	parser.setResolveBindings(true);
	parser.setBindingsRecovery(true);
	return (CompilationUnit) parser.createAST(null);
}

Re: Enum Declaration not found in CompilationUnit [message #1824426 is a reply to message #1824424] Wed, 15 April 2020 04:07 Go to previous messageGo to next message
Eclipse UserFriend
Can you please create a bug in JDT Core so that it can be tracked : https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT
Re: Enum Declaration not found in CompilationUnit [message #1824436 is a reply to message #1824424] Wed, 15 April 2020 05:12 Go to previous messageGo to next message
Eclipse UserFriend
Interestingly, the AST VIEW shows the constants - didn't try the program though
[I sent a reply sometime back, but looks like it did not deliver, hence noting]
Re: Enum Declaration not found in CompilationUnit [message #1824441 is a reply to message #1824436] Wed, 15 April 2020 07:25 Go to previous message
Eclipse UserFriend
BTW, I should mention I am using JDT core 3.17. Is it something that has been fixed in the later versions?
Previous Topic:Missing re-launch Action Button
Next Topic:Eclipse design view tool fails when using generics
Goto Forum:
  


Current Time: Sat Aug 30 23:39:49 EDT 2025

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

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

Back to the top