Skip to content

Commit

Permalink
feature: add an explicit construct for imports in the metamodel (CtIm…
Browse files Browse the repository at this point in the history
…port) (#1707)
  • Loading branch information
surli authored and monperrus committed Nov 24, 2017
1 parent d0ab757 commit ade0049
Show file tree
Hide file tree
Showing 43 changed files with 716 additions and 199 deletions.
2 changes: 2 additions & 0 deletions src/main/java/spoon/Metamodel.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static Set<CtType<?>> getAllMetamodelInterfaces() {
result.add(factory.Type().get(spoon.reflect.reference.CtUnboundVariableReference.class));
result.add(factory.Type().get(spoon.reflect.reference.CtVariableReference.class));
result.add(factory.Type().get(spoon.reflect.reference.CtWildcardReference.class));
result.add(factory.Type().get(spoon.reflect.declaration.CtImport.class));
result.add(factory.Type().get(spoon.reflect.declaration.CtImportKind.class));
return result;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/spoon/reflect/cu/CompilationUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import spoon.processing.FactoryAccessor;
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtType;
import spoon.reflect.reference.CtReference;
import spoon.reflect.declaration.CtImport;

import java.io.File;
import java.util.Collection;
Expand Down Expand Up @@ -113,12 +113,12 @@ public interface CompilationUnit extends FactoryAccessor {
* Get the imports computed for this CU
* @return All the imports from the original source code
*/
Collection<CtReference> getImports();
Collection<CtImport> getImports();

/**
* Set the imports of this CU
* @param imports All the imports of the original source code
*/
void setImports(Collection<CtReference> imports);
void setImports(Collection<CtImport> imports);

}
65 changes: 65 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtImport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Copyright (C) 2006-2017 INRIA and contributors
* Spoon - http://spoon.gforge.inria.fr/
*
* This software is governed by the CeCILL-C License under French law and
* abiding by the rules of distribution of free software. You can use, modify
* and/or redistribute the software under the terms of the CeCILL-C license as
* circulated by CEA, CNRS and INRIA at http://www.cecill.info.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*/
package spoon.reflect.declaration;

import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;
import spoon.reflect.reference.CtReference;
import spoon.support.DerivedProperty;

import static spoon.reflect.path.CtRole.IMPORT_REFERENCE;

/**
* This element represents an import declaration.
* The given reference should be of type {@link spoon.reflect.reference.CtTypeReference},
* {@link spoon.reflect.reference.CtPackageReference}, {@link spoon.reflect.reference.CtExecutableReference},
* {@link spoon.reflect.reference.CtFieldReference} or {@link spoon.support.reflect.reference.CtWildcardStaticTypeMemberReferenceImpl}
*
* <pre>
* import static import static org.junit.Assert.*;
* </pre>
*
* It will be ignored in all other cases.
*
* Example:
* <pre>
* import java.io.File;
* </pre>
*/
public interface CtImport extends CtElement {
/**
* Returns the kind of import (see {@link CtImportKind})
*/
@DerivedProperty
CtImportKind getImportKind();

/**
* Returns the reference of the import.
*/
@PropertyGetter(role = IMPORT_REFERENCE)
CtReference getReference();

/**
* Sets the reference of the import.
* The import kind will be computed based on this reference.
*/
@PropertySetter(role = IMPORT_REFERENCE)
<T extends CtImport> T setReference(CtReference reference);

@Override
CtImport clone();
}
25 changes: 25 additions & 0 deletions src/main/java/spoon/reflect/declaration/CtImportKind.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (C) 2006-2017 INRIA and contributors
* Spoon - http://spoon.gforge.inria.fr/
*
* This software is governed by the CeCILL-C License under French law and
* abiding by the rules of distribution of free software. You can use, modify
* and/or redistribute the software under the terms of the CeCILL-C license as
* circulated by CEA, CNRS and INRIA at http://www.cecill.info.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*/
package spoon.reflect.declaration;

public enum CtImportKind {
TYPE,
ALL_TYPES,
ALL_STATIC_MEMBERS,
FIELD,
METHOD
}
11 changes: 11 additions & 0 deletions src/main/java/spoon/reflect/factory/CoreFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.declaration.CtImport;
import spoon.reflect.reference.CtIntersectionTypeReference;
import spoon.reflect.reference.CtLocalVariableReference;
import spoon.reflect.reference.CtPackageReference;
Expand Down Expand Up @@ -508,6 +509,11 @@ BodyHolderSourcePosition createBodyHolderSourcePosition(
*/
CtJavaDocTag createJavaDocTag();

/**
* Creates an import.
*/
CtImport createImport();

/**
* Gets the main factory of that core factory (cannot be <code>null</code>).
*/
Expand Down Expand Up @@ -541,4 +547,9 @@ BodyHolderSourcePosition createBodyHolderSourcePosition(
* This is in particular useful when one uses reflection.
*/
CtElement create(Class<? extends CtElement> klass);

/**
* Create a wildcard reference to a type member, used in a static import
*/
CtTypeReference createWildcardStaticTypeMemberReference();
}
12 changes: 12 additions & 0 deletions src/main/java/spoon/reflect/factory/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.declaration.CtImport;
import spoon.reflect.reference.CtIntersectionTypeReference;
import spoon.reflect.reference.CtLocalVariableReference;
import spoon.reflect.reference.CtPackageReference;
import spoon.reflect.reference.CtParameterReference;
import spoon.reflect.reference.CtReference;
import spoon.reflect.reference.CtTypeParameterReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.reference.CtUnboundVariableReference;
Expand Down Expand Up @@ -920,4 +922,14 @@ public interface Factory {
* @see QueryFactory#createQuery(Object...)
*/
CtQuery createQuery(Object... input);

/**
* @see TypeFactory#createImport(CtReference)
*/
CtImport createImport(CtReference reference);

/**
* @see TypeFactory#createWildcardStaticTypeMemberReference(CtTypeReference)
*/
CtTypeReference createWildcardStaticTypeMemberReference(CtTypeReference typeReference);
}
12 changes: 12 additions & 0 deletions src/main/java/spoon/reflect/factory/FactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@
import spoon.reflect.reference.CtCatchVariableReference;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.declaration.CtImport;
import spoon.reflect.reference.CtIntersectionTypeReference;
import spoon.reflect.reference.CtLocalVariableReference;
import spoon.reflect.reference.CtPackageReference;
import spoon.reflect.reference.CtParameterReference;
import spoon.reflect.reference.CtReference;
import spoon.reflect.reference.CtTypeParameterReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.reference.CtUnboundVariableReference;
Expand Down Expand Up @@ -1172,4 +1174,14 @@ public CtElement createElement(Class<? extends CtElement> klass) {
public CtQuery createQuery(Object... input) {
return Query().createQuery(input);
}

@Override
public CtImport createImport(CtReference reference) {
return Type().createImport(reference);
}

@Override
public CtTypeReference createWildcardStaticTypeMemberReference(CtTypeReference typeReference) {
return Type().createWildcardStaticTypeMemberReference(typeReference);
}
}
26 changes: 26 additions & 0 deletions src/main/java/spoon/reflect/factory/TypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.declaration.CtImport;
import spoon.reflect.reference.CtIntersectionTypeReference;
import spoon.reflect.reference.CtReference;
import spoon.reflect.reference.CtTypeParameterReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.CtAbstractVisitor;
Expand Down Expand Up @@ -333,6 +335,22 @@ public <T> CtTypeReference<T> createReference(CtType<T> type) {
return createReference(type, false);
}

/**
* Create a wildcard reference to a simple type
*/
public CtTypeReference createWildcardStaticTypeMemberReference(CtTypeReference typeReference) {
CtTypeReference ref = factory.Core().createWildcardStaticTypeMemberReference();
ref.setFactory(this.factory);
if (typeReference.getDeclaringType() != null) {
ref.setDeclaringType(typeReference.getDeclaringType().clone());
}
if (typeReference.getPackage() != null) {
ref.setPackage(typeReference.getPackage().clone());
}
ref.setSimpleName(typeReference.getSimpleName());
return ref;
}

/**
* @param includingFormalTypeParameter if true then references to formal type parameters
* are added as actual type arguments of returned {@link CtTypeReference}
Expand Down Expand Up @@ -662,4 +680,12 @@ public CtTypeReference getDefaultBoundingType() {
return OBJECT;
}

/**
* Creates an import declaration.
*/
public CtImport createImport(CtReference reference) {
CtImport ctImport = factory.Core().createImport();
return ctImport.setReference(reference.clone());
}

}
20 changes: 19 additions & 1 deletion src/main/java/spoon/reflect/meta/impl/ModelRoleHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtFormalTypeDeclarer;
import spoon.reflect.declaration.CtImport;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtModifiable;
import spoon.reflect.declaration.CtMultiTypedElement;
Expand Down Expand Up @@ -111,7 +112,7 @@
* Contains implementations of {@link RoleHandler}s for all {@link CtRole}s of all model elements
*/
class ModelRoleHandlers {
static final RoleHandler[] roleHandlers = new RoleHandler[]{ new CtTypeAccess_ACCESSED_TYPE_RoleHandler(), new CtClass_ANNONYMOUS_EXECUTABLE_RoleHandler(), new CtElement_ANNOTATION_RoleHandler(), new CtAnnotation_ANNOTATION_TYPE_RoleHandler(), new CtAbstractInvocation_ARGUMENT_RoleHandler(), new CtExecutableReference_ARGUMENT_TYPE_RoleHandler(), new CtAssignment_ASSIGNED_RoleHandler(), new CtRHSReceiver_ASSIGNMENT_RoleHandler(), new CtBodyHolder_BODY_RoleHandler(), new CtSynchronized_BODY_RoleHandler(), new CtIntersectionTypeReference_BOUND_RoleHandler(), new CtTypeParameterReference_BOUNDING_TYPE_RoleHandler(), new CtSwitch_CASE_RoleHandler(), new CtExpression_CAST_RoleHandler(), new CtTry_CATCH_RoleHandler(), new CtElement_COMMENT_RoleHandler(), new CtComment_COMMENT_CONTENT_RoleHandler(), new CtJavaDocTag_COMMENT_CONTENT_RoleHandler(), new CtJavaDoc_COMMENT_TAG_RoleHandler(), new CtComment_COMMENT_TYPE_RoleHandler(), new CtAssert_CONDITION_RoleHandler(), new CtConditional_CONDITION_RoleHandler(), new CtIf_CONDITION_RoleHandler(), new CtClass_CONSTRUCTOR_RoleHandler(), new CtPackage_CONTAINED_TYPE_RoleHandler(), new CtExecutableReference_DECLARING_TYPE_RoleHandler(), new CtFieldReference_DECLARING_TYPE_RoleHandler(), new CtTypeReference_DECLARING_TYPE_RoleHandler(), new CtAnnotationMethod_DEFAULT_EXPRESSION_RoleHandler(), new CtVariable_DEFAULT_EXPRESSION_RoleHandler(), new CtNewArray_DIMENSION_RoleHandler(), new CtJavaDocTag_DOCUMENTATION_TYPE_RoleHandler(), new CtConditional_ELSE_RoleHandler(), new CtIf_ELSE_RoleHandler(), new CtAbstractInvocation_EXECUTABLE_REF_RoleHandler(), new CtExecutableReferenceExpression_EXECUTABLE_REF_RoleHandler(), new CtParameterReference_EXECUTABLE_REF_RoleHandler(), new CtArrayAccess_EXPRESSION_RoleHandler(), new CtAssert_EXPRESSION_RoleHandler(), new CtCase_EXPRESSION_RoleHandler(), new CtDo_EXPRESSION_RoleHandler(), new CtFor_EXPRESSION_RoleHandler(), new CtForEach_EXPRESSION_RoleHandler(), new CtLambda_EXPRESSION_RoleHandler(), new CtNewArray_EXPRESSION_RoleHandler(), new CtReturn_EXPRESSION_RoleHandler(), new CtSwitch_EXPRESSION_RoleHandler(), new CtSynchronized_EXPRESSION_RoleHandler(), new CtThrow_EXPRESSION_RoleHandler(), new CtUnaryOperator_EXPRESSION_RoleHandler(), new CtWhile_EXPRESSION_RoleHandler(), new CtType_FIELD_RoleHandler(), new CtTry_FINALIZER_RoleHandler(), new CtForEach_FOREACH_VARIABLE_RoleHandler(), new CtFor_FOR_INIT_RoleHandler(), new CtFor_FOR_UPDATE_RoleHandler(), new CtTypeInformation_INTERFACE_RoleHandler(), new CtMethod_IS_DEFAULT_RoleHandler(), new CtFieldReference_IS_FINAL_RoleHandler(), new CtElement_IS_IMPLICIT_RoleHandler(), new CtShadowable_IS_SHADOW_RoleHandler(), new CtExecutableReference_IS_STATIC_RoleHandler(), new CtFieldReference_IS_STATIC_RoleHandler(), new CtTypeParameterReference_IS_UPPER_RoleHandler(), new CtParameter_IS_VARARGS_RoleHandler(), new CtJavaDocTag_JAVADOC_TAG_VALUE_RoleHandler(), new CtStatement_LABEL_RoleHandler(), new CtBinaryOperator_LEFT_OPERAND_RoleHandler(), new CtType_METHOD_RoleHandler(), new CtModifiable_MODIFIER_RoleHandler(), new CtTypeInformation_MODIFIER_RoleHandler(), new CtNamedElement_NAME_RoleHandler(), new CtReference_NAME_RoleHandler(), new CtNewClass_NESTED_TYPE_RoleHandler(), new CtType_NESTED_TYPE_RoleHandler(), new CtBinaryOperator_OPERATOR_KIND_RoleHandler(), new CtOperatorAssignment_OPERATOR_KIND_RoleHandler(), new CtUnaryOperator_OPERATOR_KIND_RoleHandler(), new CtTypeReference_PACKAGE_REF_RoleHandler(), new CtCatch_PARAMETER_RoleHandler(), new CtExecutable_PARAMETER_RoleHandler(), new CtElement_POSITION_RoleHandler(), new CtBinaryOperator_RIGHT_OPERAND_RoleHandler(), new CtCodeSnippet_SNIPPET_RoleHandler(), new CtStatementList_STATEMENT_RoleHandler(), new CtPackage_SUB_PACKAGE_RoleHandler(), new CtTypeInformation_SUPER_TYPE_RoleHandler(), new CtTargetedExpression_TARGET_RoleHandler(), new CtLabelledFlowBreak_TARGET_LABEL_RoleHandler(), new CtConditional_THEN_RoleHandler(), new CtIf_THEN_RoleHandler(), new CtExecutable_THROWN_RoleHandler(), new CtTryWithResource_TRY_RESOURCE_RoleHandler(), new CtArrayTypeReference_TYPE_RoleHandler(), new CtExecutableReference_TYPE_RoleHandler(), new CtMultiTypedElement_TYPE_RoleHandler(), new CtTypedElement_TYPE_RoleHandler(), new CtVariableReference_TYPE_RoleHandler(), new CtActualTypeContainer_TYPE_ARGUMENT_RoleHandler(), new CtType_TYPE_MEMBER_RoleHandler(), new CtFormalTypeDeclarer_TYPE_PARAMETER_RoleHandler(), new CtAnnotation_VALUE_RoleHandler(), new CtEnum_VALUE_RoleHandler(), new CtLiteral_VALUE_RoleHandler(), new CtVariableAccess_VARIABLE_RoleHandler() };
static final RoleHandler[] roleHandlers = new RoleHandler[]{ new CtTypeAccess_ACCESSED_TYPE_RoleHandler(), new CtClass_ANNONYMOUS_EXECUTABLE_RoleHandler(), new CtElement_ANNOTATION_RoleHandler(), new CtAnnotation_ANNOTATION_TYPE_RoleHandler(), new CtAbstractInvocation_ARGUMENT_RoleHandler(), new CtExecutableReference_ARGUMENT_TYPE_RoleHandler(), new CtAssignment_ASSIGNED_RoleHandler(), new CtRHSReceiver_ASSIGNMENT_RoleHandler(), new CtBodyHolder_BODY_RoleHandler(), new CtSynchronized_BODY_RoleHandler(), new CtIntersectionTypeReference_BOUND_RoleHandler(), new CtTypeParameterReference_BOUNDING_TYPE_RoleHandler(), new CtSwitch_CASE_RoleHandler(), new CtExpression_CAST_RoleHandler(), new CtTry_CATCH_RoleHandler(), new CtElement_COMMENT_RoleHandler(), new CtComment_COMMENT_CONTENT_RoleHandler(), new CtJavaDocTag_COMMENT_CONTENT_RoleHandler(), new CtJavaDoc_COMMENT_TAG_RoleHandler(), new CtComment_COMMENT_TYPE_RoleHandler(), new CtAssert_CONDITION_RoleHandler(), new CtConditional_CONDITION_RoleHandler(), new CtIf_CONDITION_RoleHandler(), new CtClass_CONSTRUCTOR_RoleHandler(), new CtPackage_CONTAINED_TYPE_RoleHandler(), new CtExecutableReference_DECLARING_TYPE_RoleHandler(), new CtFieldReference_DECLARING_TYPE_RoleHandler(), new CtTypeReference_DECLARING_TYPE_RoleHandler(), new CtAnnotationMethod_DEFAULT_EXPRESSION_RoleHandler(), new CtVariable_DEFAULT_EXPRESSION_RoleHandler(), new CtNewArray_DIMENSION_RoleHandler(), new CtJavaDocTag_DOCUMENTATION_TYPE_RoleHandler(), new CtConditional_ELSE_RoleHandler(), new CtIf_ELSE_RoleHandler(), new CtAbstractInvocation_EXECUTABLE_REF_RoleHandler(), new CtExecutableReferenceExpression_EXECUTABLE_REF_RoleHandler(), new CtParameterReference_EXECUTABLE_REF_RoleHandler(), new CtArrayAccess_EXPRESSION_RoleHandler(), new CtAssert_EXPRESSION_RoleHandler(), new CtCase_EXPRESSION_RoleHandler(), new CtDo_EXPRESSION_RoleHandler(), new CtFor_EXPRESSION_RoleHandler(), new CtForEach_EXPRESSION_RoleHandler(), new CtLambda_EXPRESSION_RoleHandler(), new CtNewArray_EXPRESSION_RoleHandler(), new CtReturn_EXPRESSION_RoleHandler(), new CtSwitch_EXPRESSION_RoleHandler(), new CtSynchronized_EXPRESSION_RoleHandler(), new CtThrow_EXPRESSION_RoleHandler(), new CtUnaryOperator_EXPRESSION_RoleHandler(), new CtWhile_EXPRESSION_RoleHandler(), new CtType_FIELD_RoleHandler(), new CtTry_FINALIZER_RoleHandler(), new CtForEach_FOREACH_VARIABLE_RoleHandler(), new CtFor_FOR_INIT_RoleHandler(), new CtFor_FOR_UPDATE_RoleHandler(), new CtImport_IMPORT_REFERENCE_RoleHandler(), new CtTypeInformation_INTERFACE_RoleHandler(), new CtMethod_IS_DEFAULT_RoleHandler(), new CtFieldReference_IS_FINAL_RoleHandler(), new CtElement_IS_IMPLICIT_RoleHandler(), new CtShadowable_IS_SHADOW_RoleHandler(), new CtExecutableReference_IS_STATIC_RoleHandler(), new CtFieldReference_IS_STATIC_RoleHandler(), new CtTypeParameterReference_IS_UPPER_RoleHandler(), new CtParameter_IS_VARARGS_RoleHandler(), new CtJavaDocTag_JAVADOC_TAG_VALUE_RoleHandler(), new CtStatement_LABEL_RoleHandler(), new CtBinaryOperator_LEFT_OPERAND_RoleHandler(), new CtType_METHOD_RoleHandler(), new CtModifiable_MODIFIER_RoleHandler(), new CtTypeInformation_MODIFIER_RoleHandler(), new CtNamedElement_NAME_RoleHandler(), new CtReference_NAME_RoleHandler(), new CtNewClass_NESTED_TYPE_RoleHandler(), new CtType_NESTED_TYPE_RoleHandler(), new CtBinaryOperator_OPERATOR_KIND_RoleHandler(), new CtOperatorAssignment_OPERATOR_KIND_RoleHandler(), new CtUnaryOperator_OPERATOR_KIND_RoleHandler(), new CtTypeReference_PACKAGE_REF_RoleHandler(), new CtCatch_PARAMETER_RoleHandler(), new CtExecutable_PARAMETER_RoleHandler(), new CtElement_POSITION_RoleHandler(), new CtBinaryOperator_RIGHT_OPERAND_RoleHandler(), new CtCodeSnippet_SNIPPET_RoleHandler(), new CtStatementList_STATEMENT_RoleHandler(), new CtPackage_SUB_PACKAGE_RoleHandler(), new CtTypeInformation_SUPER_TYPE_RoleHandler(), new CtTargetedExpression_TARGET_RoleHandler(), new CtLabelledFlowBreak_TARGET_LABEL_RoleHandler(), new CtConditional_THEN_RoleHandler(), new CtIf_THEN_RoleHandler(), new CtExecutable_THROWN_RoleHandler(), new CtTryWithResource_TRY_RESOURCE_RoleHandler(), new CtArrayTypeReference_TYPE_RoleHandler(), new CtExecutableReference_TYPE_RoleHandler(), new CtMultiTypedElement_TYPE_RoleHandler(), new CtTypedElement_TYPE_RoleHandler(), new CtVariableReference_TYPE_RoleHandler(), new CtActualTypeContainer_TYPE_ARGUMENT_RoleHandler(), new CtType_TYPE_MEMBER_RoleHandler(), new CtFormalTypeDeclarer_TYPE_PARAMETER_RoleHandler(), new CtAnnotation_VALUE_RoleHandler(), new CtEnum_VALUE_RoleHandler(), new CtLiteral_VALUE_RoleHandler(), new CtVariableAccess_VARIABLE_RoleHandler() };

private ModelRoleHandlers() {
}
Expand Down Expand Up @@ -1068,6 +1069,23 @@ public <T, U> void setValue(T element, U value) {
}
}

static class CtImport_IMPORT_REFERENCE_RoleHandler extends SingleHandler<CtImport, CtReference> {
private CtImport_IMPORT_REFERENCE_RoleHandler() {
super(CtRole.IMPORT_REFERENCE, CtImport.class, CtReference.class);
}

@SuppressWarnings("unchecked")
@Override
public <T, U> U getValue(T element) {
return ((U) ((Object) (castTarget(element).getReference())));
}

@Override
public <T, U> void setValue(T element, U value) {
castTarget(element).setReference(castValue(value));
}
}

static class CtTypeInformation_INTERFACE_RoleHandler extends SetHandler<CtTypeInformation, CtTypeReference<?>> {
private CtTypeInformation_INTERFACE_RoleHandler() {
super(CtRole.INTERFACE, CtTypeInformation.class, CtTypeReference.class);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/spoon/reflect/path/CtRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public enum CtRole {
JAVADOC_TAG_VALUE,
POSITION,
SNIPPET,
ACCESSED_TYPE;
ACCESSED_TYPE,
IMPORT_REFERENCE;

private final CtRole superRole;
private final List<CtRole> subRoles;
Expand Down
Loading

0 comments on commit ade0049

Please sign in to comment.