Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 07:23 Go to next message
Mohammad Rafid Ul Islam is currently offline Mohammad Rafid Ul IslamFriend
Messages: 9
Registered: August 2019
Junior Member
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 08:07 Go to previous messageGo to next message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 132
Registered: February 2010
Location: Bangalore, India
Senior Member
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

Sarika Sinha
JDT Programmer
Re: Enum Declaration not found in CompilationUnit [message #1824436 is a reply to message #1824424] Wed, 15 April 2020 09:12 Go to previous messageGo to next message
Manoj N Palat is currently offline Manoj N PalatFriend
Messages: 19
Registered: October 2014
Junior Member
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]


Manoj N Palat
Eclipse Java Development Tools (JDT).
Re: Enum Declaration not found in CompilationUnit [message #1824441 is a reply to message #1824436] Wed, 15 April 2020 11:25 Go to previous message
Mohammad Rafid Ul Islam is currently offline Mohammad Rafid Ul IslamFriend
Messages: 9
Registered: August 2019
Junior Member
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 Dec 14 16:07:58 GMT 2024

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

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

Back to the top