Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.ITypeBinding;
Expand Down Expand Up @@ -486,7 +487,8 @@ private static ASTNode getDeclaringNode(ASTNode selectedNode) {
declaringNode= selectedNode;
} else if (selectedNode instanceof SimpleName) {
StructuralPropertyDescriptor locationInParent= selectedNode.getLocationInParent();
if (locationInParent == MethodDeclaration.NAME_PROPERTY || locationInParent == TypeDeclaration.NAME_PROPERTY) {
if (locationInParent == MethodDeclaration.NAME_PROPERTY || locationInParent == TypeDeclaration.NAME_PROPERTY
|| locationInParent == EnumConstantDeclaration.NAME_PROPERTY) {
declaringNode= selectedNode.getParent();
} else if (locationInParent == VariableDeclarationFragment.NAME_PROPERTY) {
declaringNode= selectedNode.getParent().getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3512,4 +3512,40 @@ public void foo() {
assertExpectedExistInProposals(proposals, new String[] {expected1});
}

@Test
public void testIssue2764() throws Exception {
Hashtable<String, String> options = JavaCore.getOptions();
options.put(JavaCore.COMPILER_PB_DEPRECATION, CompilerOptions.WARNING);
JavaCore.setOptions(options);
IPackageFragment pack2= fSourceFolder.createPackageFragment("test1", false, null);

String str1= """
package test1;

@Deprecated
public enum E {
BAR
}
""";
ICompilationUnit cu= pack2.createCompilationUnit("E.java", str1, false, null);

CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1, null);
assertCorrectLabels(proposals);
assertNumberOfProposals(proposals, 2);

String expected1= """
package test1;

@Deprecated
public enum E {
@Deprecated
BAR
}
""";

assertExpectedExistInProposals(proposals, new String[] {expected1});

}

}
Loading