Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25ef603

Browse files
Fixing bug that Enum with constructors is not compiled correctly
1 parent 6ac0497 commit 25ef603

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/net/sf/j2s/core/astvisitors/MethodReferenceASTVisitor.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.jdt.core.dom.BodyDeclaration;
2121
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
2222
import org.eclipse.jdt.core.dom.ConstructorInvocation;
23+
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
2324
import org.eclipse.jdt.core.dom.IMethodBinding;
2425
import org.eclipse.jdt.core.dom.Javadoc;
2526
import org.eclipse.jdt.core.dom.MethodDeclaration;
@@ -88,6 +89,22 @@ public boolean visit(ConstructorInvocation node) {
8889
return super.visit(node);
8990
}
9091

92+
/* (non-Javadoc)
93+
* @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.EnumConstantDeclaration)
94+
*/
95+
public boolean visit(EnumConstantDeclaration node) {
96+
IMethodBinding constructorBinding = node.resolveConstructorBinding();
97+
String key = constructorBinding.getKey();
98+
if (key != null) {
99+
key = key.replaceAll("%?<[^>]+>", "");
100+
}
101+
if (methodSignature.equals(key)) {
102+
isReferenced = true;
103+
return false;
104+
}
105+
return super.visit(node);
106+
}
107+
91108
/* (non-Javadoc)
92109
* @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MethodInvocation)
93110
*/

0 commit comments

Comments
 (0)