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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Google, Inc. and others.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -40,6 +40,9 @@ public final class DesignerMethodBinding implements IMethodBinding {
private final String m_name;
private final int m_modifiers;
private final boolean m_constructor;
private final boolean m_compactConstructor;
private final boolean m_canonicalConstructor;
private final boolean m_syntheticRecordMethod;
private final boolean m_varargs;
private final ITypeBinding m_declaringClass;
private final ITypeBinding m_returnType;
Expand All @@ -59,6 +62,9 @@ public final class DesignerMethodBinding implements IMethodBinding {
m_name = binding.getName();
m_modifiers = binding.getModifiers();
m_constructor = binding.isConstructor();
m_compactConstructor = binding.isCompactConstructor();
m_canonicalConstructor = binding.isCanonicalConstructor();
m_syntheticRecordMethod = binding.isSyntheticRecordMethod();
m_varargs = binding.isVarargs();
m_declaringClass = context.get(binding.getDeclaringClass());
m_returnType = context.get(binding.getReturnType());
Expand Down Expand Up @@ -286,26 +292,26 @@ public boolean isRecovered() {

@Override
public IBinding getDeclaringMember() {
return null;
throw new IllegalArgumentException();
}

@Override
public IVariableBinding[] getSyntheticOuterLocals() {
return null;
throw new IllegalArgumentException();
}

@Override
public boolean isCompactConstructor() {
return false;
return m_compactConstructor;
}

@Override
public boolean isCanonicalConstructor() {
return false;
return m_canonicalConstructor;
}

@Override
public boolean isSyntheticRecordMethod() {
return false;
return m_syntheticRecordMethod;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -14,6 +14,7 @@

import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IModuleBinding;
import org.eclipse.jdt.core.dom.IPackageBinding;

/**
Expand Down Expand Up @@ -119,4 +120,9 @@ public boolean isRecovered() {
public org.eclipse.jdt.core.dom.IAnnotationBinding[] getAnnotations() {
throw new IllegalArgumentException();
}

@Override
public IModuleBinding getModule() {
throw new IllegalArgumentException();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -16,6 +16,7 @@
import org.eclipse.jdt.core.dom.IAnnotationBinding;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.IModuleBinding;
import org.eclipse.jdt.core.dom.IPackageBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
Expand Down Expand Up @@ -45,6 +46,8 @@ public final class DesignerTypeBinding implements ITypeBinding {
private final boolean m_nested;
private final boolean m_local;
private final boolean m_anonymous;
private final boolean m_record;
private final boolean m_intersectionType;
// generics
private final boolean m_genericType;
private final boolean m_parameterizedType;
Expand Down Expand Up @@ -96,6 +99,8 @@ public final class DesignerTypeBinding implements ITypeBinding {
m_member = binding.isMember();
m_local = binding.isLocal();
m_anonymous = binding.isAnonymous();
m_record = binding.isRecord();
m_intersectionType = binding.isIntersectionType();
// generics
m_genericType = binding.isGenericType();
m_parameterizedType = binding.isParameterizedType();
Expand Down Expand Up @@ -529,20 +534,39 @@ public IAnnotationBinding[] getTypeAnnotations() {
throw new IllegalArgumentException();
}

//
// New in Eclipse 3.11
//

@Override
public IBinding getDeclaringMember() {
return null;
throw new IllegalArgumentException();
}

//
// New in Eclipse 3.12
//

@Override
public boolean isIntersectionType() {
// TODO Auto-generated method stub
return false;
return m_intersectionType;
}

//
// New in Eclipse 3.14
//

@Override
public IModuleBinding getModule() {
throw new IllegalArgumentException();
}

//
// New in Eclipse 3.26
//

@Override
public boolean isRecord() {
// TODO Auto-generated method stub
return false;
return m_record;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.apache.commons.lang3.ArrayUtils;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Array;
Expand Down Expand Up @@ -84,7 +83,6 @@ public void _test_exit() throws Exception {
/**
* Object type.
*/
@Disabled
@Test
public void test_DesignerTypeBinding_1() throws Exception {
String code = "private java.util.List foo() {return null;}";
Expand All @@ -94,7 +92,6 @@ public void test_DesignerTypeBinding_1() throws Exception {
/**
* Primitive type.
*/
@Disabled
@Test
public void test_DesignerTypeBinding_2() throws Exception {
String code = "private int foo() {return 0;}";
Expand All @@ -104,7 +101,6 @@ public void test_DesignerTypeBinding_2() throws Exception {
/**
* Array type.
*/
@Disabled
@Test
public void test_DesignerTypeBinding_3() throws Exception {
String code = "private int[] foo() {return null;}";
Expand All @@ -114,7 +110,6 @@ public void test_DesignerTypeBinding_3() throws Exception {
/**
* Inner type.
*/
@Disabled
@Test
public void test_DesignerTypeBinding_4() throws Exception {
String code = "class Foo {} private Foo foo() {return null;}";
Expand Down Expand Up @@ -307,15 +302,14 @@ private static void assert_TypeBinding_names(ITypeBinding binding,
// DesignerPackageBinding
//
////////////////////////////////////////////////////////////////////////////
@Disabled
@Test
public void test_DesignerPackageBinding() throws Exception {
TypeDeclaration typeDeclaration = createTypeDeclaration_TestC("");
IPackageBinding originalBinding = typeDeclaration.resolveBinding().getPackage();
IPackageBinding ourBinding = m_lastEditor.getBindingContext().get(originalBinding);
assert_sameProperties(IPackageBinding.class, originalBinding, ourBinding, new String[]{
assert_sameProperties(IPackageBinding.class, originalBinding, ourBinding,
"getName",
"isUnnamed"});
"isUnnamed");
assert_methodFails(ourBinding, "isEqualTo", NULL_ARG);
}

Expand All @@ -327,25 +321,28 @@ public void test_DesignerPackageBinding() throws Exception {
/**
* Basic test for {@link DesignerMethodBinding}.
*/
@Disabled
@Test
public void test_DesignerMethodBinding_1() throws Exception {
TypeDeclaration typeDeclaration =
createTypeDeclaration_TestC(getSourceDQ(" private int foo() {", " return 0;", " }"));
MethodDeclaration methodDeclaration = typeDeclaration.getMethods()[0];
IMethodBinding originalBinding = methodDeclaration.resolveBinding();
IMethodBinding ourBinding = m_lastEditor.getBindingContext().get(originalBinding);
assert_sameProperties(IMethodBinding.class, originalBinding, ourBinding, new String[]{
assert_sameProperties(IMethodBinding.class, originalBinding, ourBinding,
"getDeclaringClass",
"getName",
"getReturnType",
"getParameterTypes",
"getParameterNames",
"getExceptionTypes",
"getMethodDeclaration",
"isConstructor",
"isCanonicalConstructor",
"isCompactConstructor",
"isSyntheticRecordMethod",
"getModifiers",
"getDeclaringMember",
"isVarargs"});
"getKey",
"isVarargs");
assert_methodFails(ourBinding, "getParameterAnnotations", new Object[]{0});
assert_methodFails(ourBinding, "isSubsignature", NULL_ARG);
assert_methodFails(ourBinding, "overrides", NULL_ARG);
Expand Down Expand Up @@ -415,7 +412,6 @@ public void test_DesignerMethodBinding_removeParameterType() throws Exception {
* When we remove parameter from generic {@link IMethodBinding} we should also update its
* {@link IMethodBinding#getMethodDeclaration()}.
*/
@Disabled
@Test
public void test_DesignerMethodBinding_removeParameterType_whenGenerics() throws Exception {
createTypeDeclaration_TestC(getSourceDQ(
Expand Down Expand Up @@ -447,20 +443,20 @@ public void test_DesignerMethodBinding_removeParameterType_whenGenerics() throws
/**
* Basic test for {@link DesignerVariableBinding}.
*/
@Disabled
@Test
public void test_DesignerVariableBinding_1() throws Exception {
TypeDeclaration typeDeclaration = createTypeDeclaration_TestC("private int m_value;");
FieldDeclaration fieldDeclaration = typeDeclaration.getFields()[0];
IVariableBinding originalBinding =
((VariableDeclarationFragment) fieldDeclaration.fragments().get(0)).resolveBinding();
IVariableBinding ourBinding = m_lastEditor.getBindingContext().get(originalBinding);
assert_sameProperties(IVariableBinding.class, originalBinding, ourBinding, new String[]{
assert_sameProperties(IVariableBinding.class, originalBinding, ourBinding,
"getName",
"getDeclaringClass",
"getType",
"isField",
"getModifiers"});
"isRecordComponent",
"getModifiers");
assert_methodFails(ourBinding, "isEqualTo", NULL_ARG);
}

Expand Down Expand Up @@ -500,7 +496,6 @@ public void test_DesignerVariableBinding_2() throws Exception {
/**
* Test for {@link BindingContext#getCopy(ITypeBinding)}.
*/
@Disabled
@Test
public void test_getCopy() throws Exception {
TypeDeclaration typeDeclaration = createTypeDeclaration_Test("""
Expand All @@ -526,7 +521,7 @@ public Test() {
*/
private static void assert_sameTypeBindings(ITypeBinding expectedBinding,
ITypeBinding actualBinding) throws Exception {
assert_sameProperties(ITypeBinding.class, expectedBinding, actualBinding, new String[]{
assert_sameProperties(ITypeBinding.class, expectedBinding, actualBinding,
"isPrimitive",
"isNullType",
"isArray",
Expand All @@ -549,15 +544,15 @@ private static void assert_sameTypeBindings(ITypeBinding expectedBinding,
"isGenericType",
"isParameterizedType",
"isTypeVariable",
"isRecord",
"getTypeArguments",
"getTypeDeclaration",
"getTypeParameters",
"getTypeBounds",
"getDeclaredMethods",
"getModifiers",
"getDeclaredModifiers",
"getDeclaringMember",
"isIntersectionType"});
"isIntersectionType");
}

/**
Expand Down Expand Up @@ -586,7 +581,7 @@ private static void assert_methodFails(Object actualObject, String methodName, O
private static void assert_sameProperties(Class<?> clazz,
Object expectedObject,
Object actualObject,
String methodNames[]) throws Exception {
String... methodNames) throws Exception {
Method[] allMethods = clazz.getMethods();
for (int i = 0; i < allMethods.length; i++) {
Method method = allMethods[i];
Expand Down
Loading