-
-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
review: feat: Spoon CtRole based attributes access #1582
Conversation
return typeName + "_" + role.name() + "_RoleHandler"; | ||
} | ||
|
||
private <K, V> V getOrCreatte(Map<K, V> map, K key, Supplier<V> valueCreator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: Creatte -> Create
@evreybody, if you have suggestions concerning class names, please give me new names soon. I am using these names on many places and later change will need more effort. I will do it later too, but sooner is better ;-) |
About names, I like set/getValueByRole. |
Is CtRoleHandler meant to be a public API abstraction or an implementation abstraction? How would client use it? |
|
69dfc97
to
bb30a47
Compare
f1e0309
to
ee857cf
Compare
There will be following CtRoleHandler implementations.
At the beginning it will support only get and set method. Later we might add, addFirst, addLast, addOn, remove, ... Note: I expected that CtRole.Xxx has some meaning in the model, but now it looks like the meaning highly depends on target element. Is it correct? Some of them seems strange to me: e.g. CtPackage CtRole.TYPE, which does not return type of package (like other TYPE roles), but returns set of all types which belongs to this package. Is there some logic/semantic behind decision when to use same type name and when another type name would be better? |
Some of them seems strange to me: e.g. CtPackage CtRole.TYPE, which
does not return type of package (like other TYPE roles), but returns
set of all types which belongs to this package.
This is clearly a bug. The same CtRole should refer to the same role.
This should be eg CONTAINED_TYPES
I expected that CtRole.Xxx has some meaning in the model, but now it
looks like the meaning highly depends on target element. Is it correct?
No, the meaning of CtRole.XXX should not depend on the target element.
We should be able to come up with a checkable contract for this.
…On 10/14/17 7:23 PM, Pavel Vojtechovsky wrote:
There will be following CtRoleHandler implementations.
|CtNamedElement CtRole.NAME ItemType: java.lang.String get:
getSimpleName() : java.lang.String set:
setSimpleName(java.lang.String)
---------------------------------------------------------- CtReference
CtRole.NAME ItemType: java.lang.String get: getSimpleName() :
java.lang.String set: setSimpleName(java.lang.String)
----------------------------------------------------------
CtArrayTypeReference CtRole.TYPE ItemType:
spoon.reflect.reference.CtTypeReference<?> get: getComponentType() :
spoon.reflect.reference.CtTypeReference<?> set:
setComponentType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtExecutableReference CtRole.TYPE ItemType:
spoon.reflect.reference.CtTypeReference<T> get: getType() :
spoon.reflect.reference.CtTypeReference<T> set:
setType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtJavaDocTag CtRole.TYPE ItemType:
spoon.reflect.code.CtJavaDocTag.TagType get: getType() :
spoon.reflect.code.CtJavaDocTag.TagType set:
setType(spoon.reflect.code.CtJavaDocTag$TagType)
----------------------------------------------------------
CtMultiTypedElement CtRole.TYPE ItemType:
java.util.List<spoon.reflect.reference.CtTypeReference<?>> get:
getMultiTypes() :
java.util.List<spoon.reflect.reference.CtTypeReference<?>> set:
setMultiTypes(java.util.List) add:
addMultiType(spoon.reflect.reference.CtTypeReference) remove:
removeMultiType(spoon.reflect.reference.CtTypeReference)
---------------------------------------------------------- CtPackage
CtRole.TYPE ItemType:
java.util.Set<spoon.reflect.declaration.CtType<?>> get: getTypes() :
java.util.Set<spoon.reflect.declaration.CtType<?>> set:
setTypes(java.util.Set) add: addType(spoon.reflect.declaration.CtType)
remove: removeType(spoon.reflect.declaration.CtType)
----------------------------------------------------------
CtTypedElement CtRole.TYPE ItemType:
spoon.reflect.reference.CtTypeReference<T> get: getType() :
spoon.reflect.reference.CtTypeReference<T> set:
setType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtVariableReference CtRole.TYPE ItemType:
spoon.reflect.reference.CtTypeReference<T> get: getType() :
spoon.reflect.reference.CtTypeReference<T> set:
setType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtExecutableReference CtRole.DECLARING_TYPE ItemType:
spoon.reflect.reference.CtTypeReference<?> get: getDeclaringType() :
spoon.reflect.reference.CtTypeReference<?> set:
setDeclaringType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtFieldReference CtRole.DECLARING_TYPE ItemType:
spoon.reflect.reference.CtTypeReference<?> get: getDeclaringType() :
spoon.reflect.reference.CtTypeReference<?> set:
setDeclaringType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtTypeReference CtRole.DECLARING_TYPE ItemType:
spoon.reflect.reference.CtTypeReference<?> get: getDeclaringType() :
spoon.reflect.reference.CtTypeReference<?> set:
setDeclaringType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtBodyHolder CtRole.BODY ItemType: spoon.reflect.code.CtStatement get:
getBody() : spoon.reflect.code.CtStatement set:
setBody(spoon.reflect.code.CtStatement)
----------------------------------------------------------
CtSynchronized CtRole.BODY ItemType: spoon.reflect.code.CtBlock<?>
get: getBlock() : spoon.reflect.code.CtBlock<?> set:
setBlock(spoon.reflect.code.CtBlock)
----------------------------------------------------------
CtShadowable CtRole.IS_SHADOW ItemType: boolean get: isShadow() :
boolean set: setShadow(boolean)
----------------------------------------------------------
CtIntersectionTypeReference CtRole.BOUND ItemType:
java.util.List<spoon.reflect.reference.CtTypeReference<?>> get:
getBounds() :
java.util.List<spoon.reflect.reference.CtTypeReference<?>> set:
setBounds(java.util.List) add:
addBound(spoon.reflect.reference.CtTypeReference) remove:
removeBound(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtTypeParameterReference CtRole.BOUNDING_TYPE ItemType:
spoon.reflect.reference.CtTypeReference<?> get: getBoundingType() :
spoon.reflect.reference.CtTypeReference<?> set:
setBoundingType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtFieldReference CtRole.IS_FINAL ItemType: boolean get: isFinal() :
boolean set: setFinal(boolean)
----------------------------------------------------------
CtExecutableReference CtRole.IS_STATIC ItemType: boolean get:
isStatic() : boolean set: setStatic(boolean)
----------------------------------------------------------
CtFieldReference CtRole.IS_STATIC ItemType: boolean get: isStatic() :
boolean set: setStatic(boolean)
----------------------------------------------------------
CtTypeParameterReference CtRole.IS_UPPER ItemType: boolean get:
isUpper() : boolean set: setUpper(boolean)
---------------------------------------------------------- CtElement
CtRole.IS_IMPLICIT ItemType: boolean get: isImplicit() : boolean set:
setImplicit(boolean)
---------------------------------------------------------- CtMethod
CtRole.IS_DEFAULT ItemType: boolean get: isDefaultMethod() : boolean
set: setDefaultMethod(boolean)
---------------------------------------------------------- CtParameter
CtRole.IS_VARARGS ItemType: boolean get: isVarArgs() : boolean set:
setVarArgs(boolean)
----------------------------------------------------------
CtAnnotationMethod CtRole.DEFAULT_EXPRESSION ItemType:
spoon.reflect.code.CtExpression<T> get: getDefaultExpression() :
spoon.reflect.code.CtExpression<T> set:
setDefaultExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtVariable
CtRole.DEFAULT_EXPRESSION ItemType: spoon.reflect.code.CtExpression<T>
get: getDefaultExpression() : spoon.reflect.code.CtExpression<T> set:
setDefaultExpression(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtConditional CtRole.THEN ItemType: spoon.reflect.code.CtExpression<T>
get: getThenExpression() : spoon.reflect.code.CtExpression<T> set:
setThenExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtIf
CtRole.THEN ItemType: S get: getThenStatement() : S set:
setThenStatement(spoon.reflect.code.CtStatement)
----------------------------------------------------------
CtConditional CtRole.ELSE ItemType: spoon.reflect.code.CtExpression<T>
get: getElseExpression() : spoon.reflect.code.CtExpression<T> set:
setElseExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtIf
CtRole.ELSE ItemType: S get: getElseStatement() : S set:
setElseStatement(spoon.reflect.code.CtStatement)
----------------------------------------------------------
CtTypeReference CtRole.PACKAGE_REF ItemType:
spoon.reflect.reference.CtPackageReference get: getPackage() :
spoon.reflect.reference.CtPackageReference set:
setPackage(spoon.reflect.reference.CtPackageReference)
---------------------------------------------------------- CtPackage
CtRole.SUB_PACKAGE ItemType:
java.util.Set<spoon.reflect.declaration.CtPackage> get: getPackages()
: java.util.Set<spoon.reflect.declaration.CtPackage> set:
setPackages(java.util.Set) add:
addPackage(spoon.reflect.declaration.CtPackage) remove:
removePackage(spoon.reflect.declaration.CtPackage)
---------------------------------------------------------- CtAssert
CtRole.CONDITION ItemType:
spoon.reflect.code.CtExpression<java.lang.Boolean> get:
getAssertExpression() :
spoon.reflect.code.CtExpression<java.lang.Boolean> set:
setAssertExpression(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtConditional CtRole.CONDITION ItemType:
spoon.reflect.code.CtExpression<java.lang.Boolean> get: getCondition()
: spoon.reflect.code.CtExpression<java.lang.Boolean> set:
setCondition(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtIf
CtRole.CONDITION ItemType:
spoon.reflect.code.CtExpression<java.lang.Boolean> get: getCondition()
: spoon.reflect.code.CtExpression<java.lang.Boolean> set:
setCondition(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtBinaryOperator CtRole.RIGHT_OPERAND ItemType:
spoon.reflect.code.CtExpression<?> get: getRightHandOperand() :
spoon.reflect.code.CtExpression<?> set:
setRightHandOperand(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtBinaryOperator CtRole.LEFT_OPERAND ItemType:
spoon.reflect.code.CtExpression<?> get: getLeftHandOperand() :
spoon.reflect.code.CtExpression<?> set:
setLeftHandOperand(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtStatement
CtRole.LABEL ItemType: java.lang.String get: getLabel() :
java.lang.String set: setLabel(java.lang.String)
---------------------------------------------------------- CtSwitch
CtRole.CASE ItemType: java.util.List<spoon.reflect.code.CtCase<? super
S>> get: getCases() : java.util.List<spoon.reflect.code.CtCase<? super
S>> set: setCases(java.util.List) add:
addCase(spoon.reflect.code.CtCase) remove:
removeCase(spoon.reflect.code.CtCase)
----------------------------------------------------------
CtBinaryOperator CtRole.OPERATOR_KIND ItemType:
spoon.reflect.code.BinaryOperatorKind get: getKind() :
spoon.reflect.code.BinaryOperatorKind set:
setKind(spoon.reflect.code.BinaryOperatorKind)
----------------------------------------------------------
CtOperatorAssignment CtRole.OPERATOR_KIND ItemType:
spoon.reflect.code.BinaryOperatorKind get: getKind() :
spoon.reflect.code.BinaryOperatorKind set:
setKind(spoon.reflect.code.BinaryOperatorKind)
----------------------------------------------------------
CtUnaryOperator CtRole.OPERATOR_KIND ItemType:
spoon.reflect.code.UnaryOperatorKind get: getKind() :
spoon.reflect.code.UnaryOperatorKind set:
setKind(spoon.reflect.code.UnaryOperatorKind)
---------------------------------------------------------- CtCatch
CtRole.PARAMETER ItemType: spoon.reflect.code.CtCatchVariable<?
extends java.lang.Throwable> get: getParameter() :
spoon.reflect.code.CtCatchVariable<? extends java.lang.Throwable> set:
setParameter(spoon.reflect.code.CtCatchVariable)
----------------------------------------------------------
CtExecutable CtRole.PARAMETER ItemType:
java.util.List<spoon.reflect.declaration.CtParameter<?>> get:
getParameters() :
java.util.List<spoon.reflect.declaration.CtParameter<?>> set:
setParameters(java.util.List) add:
addParameter(spoon.reflect.declaration.CtParameter)
----------------------------------------------------------
CtExecutableReference CtRole.PARAMETER ItemType:
java.util.List<spoon.reflect.reference.CtTypeReference<?>> get:
getParameters() :
java.util.List<spoon.reflect.reference.CtTypeReference<?>> set:
setParameters(java.util.List)
----------------------------------------------------------
CtJavaDocTag CtRole.PARAMETER ItemType: java.lang.String get:
getParam() : java.lang.String set: setParam(java.lang.String)
----------------------------------------------------------
CtArrayAccess CtRole.EXPRESSION ItemType:
spoon.reflect.code.CtExpression<java.lang.Integer> get:
getIndexExpression() :
spoon.reflect.code.CtExpression<java.lang.Integer> set:
setIndexExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtAssert
CtRole.EXPRESSION ItemType: spoon.reflect.code.CtExpression<T> get:
getExpression() : spoon.reflect.code.CtExpression<T> set:
setExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtCase
CtRole.EXPRESSION ItemType: spoon.reflect.code.CtExpression<S> get:
getCaseExpression() : spoon.reflect.code.CtExpression<S> set:
setCaseExpression(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtCodeSnippet CtRole.EXPRESSION ItemType: java.lang.String get:
getValue() : java.lang.String set: setValue(java.lang.String)
---------------------------------------------------------- CtDo
CtRole.EXPRESSION ItemType:
spoon.reflect.code.CtExpression<java.lang.Boolean> get:
getLoopingExpression() :
spoon.reflect.code.CtExpression<java.lang.Boolean> set:
setLoopingExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtFor
CtRole.EXPRESSION ItemType:
spoon.reflect.code.CtExpression<java.lang.Boolean> get:
getExpression() : spoon.reflect.code.CtExpression<java.lang.Boolean>
set: setExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtForEach
CtRole.EXPRESSION ItemType: spoon.reflect.code.CtExpression<?> get:
getExpression() : spoon.reflect.code.CtExpression<?> set:
setExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtLambda
CtRole.EXPRESSION ItemType: spoon.reflect.code.CtExpression<T> get:
getExpression() : spoon.reflect.code.CtExpression<T> set:
setExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtNewArray
CtRole.EXPRESSION ItemType:
java.util.List<spoon.reflect.code.CtExpression<?>> get: getElements()
: java.util.List<spoon.reflect.code.CtExpression<?>> set:
setElements(java.util.List) add:
addElement(spoon.reflect.code.CtExpression) remove:
removeElement(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtReturn
CtRole.EXPRESSION ItemType: spoon.reflect.code.CtExpression<R> get:
getReturnedExpression() : spoon.reflect.code.CtExpression<R> set:
setReturnedExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtSwitch
CtRole.EXPRESSION ItemType: spoon.reflect.code.CtExpression<S> get:
getSelector() : spoon.reflect.code.CtExpression<S> set:
setSelector(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtSynchronized CtRole.EXPRESSION ItemType:
spoon.reflect.code.CtExpression<?> get: getExpression() :
spoon.reflect.code.CtExpression<?> set:
setExpression(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtUnaryOperator CtRole.EXPRESSION ItemType:
spoon.reflect.code.CtExpression<T> get: getOperand() :
spoon.reflect.code.CtExpression<T> set:
setOperand(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtWhile
CtRole.EXPRESSION ItemType:
spoon.reflect.code.CtExpression<java.lang.Boolean> get:
getLoopingExpression() :
spoon.reflect.code.CtExpression<java.lang.Boolean> set:
setLoopingExpression(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtTargetedExpression CtRole.TARGET ItemType: E get: getTarget() : E
set: setTarget(E extends spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtAnnotationFieldAccess CtRole.VARIABLE ItemType:
spoon.reflect.reference.CtFieldReference<T> get: getVariable() :
spoon.reflect.reference.CtFieldReference<T> set:
setVariable(spoon.reflect.reference.CtVariableReference)
----------------------------------------------------------
CtFieldAccess CtRole.VARIABLE ItemType:
spoon.reflect.reference.CtFieldReference<T> get: getVariable() :
spoon.reflect.reference.CtFieldReference<T> set:
setVariable(spoon.reflect.reference.CtVariableReference)
---------------------------------------------------------- CtForEach
CtRole.VARIABLE ItemType: spoon.reflect.code.CtLocalVariable<?> get:
getVariable() : spoon.reflect.code.CtLocalVariable<?> set:
setVariable(spoon.reflect.code.CtLocalVariable)
----------------------------------------------------------
CtVariableAccess CtRole.VARIABLE ItemType:
spoon.reflect.reference.CtVariableReference<T> get: getVariable() :
spoon.reflect.reference.CtVariableReference<T> set:
setVariable(spoon.reflect.reference.CtVariableReference)
---------------------------------------------------------- CtTry
CtRole.FINALIZER ItemType: spoon.reflect.code.CtBlock<?> get:
getFinalizer() : spoon.reflect.code.CtBlock<?> set:
setFinalizer(spoon.reflect.code.CtBlock)
----------------------------------------------------------
CtExecutable CtRole.THROWN ItemType:
java.util.Set<spoon.reflect.reference.CtTypeReference<? extends
java.lang.Throwable>> get: getThrownTypes() :
java.util.Set<spoon.reflect.reference.CtTypeReference<? extends
java.lang.Throwable>> set: setThrownTypes(java.util.Set) add:
addThrownType(spoon.reflect.reference.CtTypeReference)
---------------------------------------------------------- CtThrow
CtRole.THROWN ItemType: spoon.reflect.code.CtExpression<? extends
java.lang.Throwable> get: getThrownExpression() :
spoon.reflect.code.CtExpression<? extends java.lang.Throwable> set:
setThrownExpression(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtRHSReceiver CtRole.ASSIGNMENT ItemType:
spoon.reflect.code.CtExpression<A> get: getAssignment() :
spoon.reflect.code.CtExpression<A> set:
setAssignment(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtAssignment CtRole.ASSIGNED ItemType:
spoon.reflect.code.CtExpression<T> get: getAssigned() :
spoon.reflect.code.CtExpression<T> set:
setAssigned(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtModifiable CtRole.MODIFIER ItemType:
java.util.Set<spoon.reflect.declaration.ModifierKind> get:
getModifiers() : java.util.Set<spoon.reflect.declaration.ModifierKind>
set: setModifiers(java.util.Set) add:
addModifier(spoon.reflect.declaration.ModifierKind) remove:
removeModifier(spoon.reflect.declaration.ModifierKind)
----------------------------------------------------------
CtTypeInformation CtRole.MODIFIER ItemType:
java.util.Set<spoon.reflect.declaration.ModifierKind> get:
getModifiers() : java.util.Set<spoon.reflect.declaration.ModifierKind>
---------------------------------------------------------- CtElement
CtRole.COMMENT ItemType: java.util.List<spoon.reflect.code.CtComment>
get: getComments() : java.util.List<spoon.reflect.code.CtComment> set:
setComments(java.util.List) add:
addComment(spoon.reflect.code.CtComment) remove:
removeComment(spoon.reflect.code.CtComment)
----------------------------------------------------------
CtAnnotation CtRole.ANNOTATION_TYPE ItemType:
spoon.reflect.reference.CtTypeReference<A> get: getAnnotationType() :
spoon.reflect.reference.CtTypeReference<A> set:
setAnnotationType(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtTypeInformation CtRole.INTERFACE ItemType:
java.util.Set<spoon.reflect.reference.CtTypeReference<?>> get:
getSuperInterfaces() :
java.util.Set<spoon.reflect.reference.CtTypeReference<?>>
---------------------------------------------------------- CtElement
CtRole.ANNOTATION ItemType:
java.util.List<spoon.reflect.declaration.CtAnnotation<? extends
java.lang.annotation.Annotation>> get: getAnnotations() :
java.util.List<spoon.reflect.declaration.CtAnnotation<? extends
java.lang.annotation.Annotation>> set: setAnnotations(java.util.List)
add: addAnnotation(spoon.reflect.declaration.CtAnnotation) remove:
removeAnnotation(spoon.reflect.declaration.CtAnnotation)
----------------------------------------------------------
CtStatementList CtRole.STATEMENT ItemType:
java.util.List<spoon.reflect.code.CtStatement> get: getStatements() :
java.util.List<spoon.reflect.code.CtStatement> set:
setStatements(java.util.List) add:
addStatement(spoon.reflect.code.CtStatement) addFirst:
insertBegin(spoon.reflect.code.CtStatement) addLast:
insertEnd(spoon.reflect.code.CtStatement) addOn:
addStatement(int,spoon.reflect.code.CtStatement) remove:
removeStatement(spoon.reflect.code.CtStatement)
----------------------------------------------------------
CtAbstractInvocation CtRole.ARGUMENT ItemType:
java.util.List<spoon.reflect.code.CtExpression<?>> get: getArguments()
: java.util.List<spoon.reflect.code.CtExpression<?>> set:
setArguments(java.util.List) add:
addArgument(spoon.reflect.code.CtExpression) remove:
removeArgument(spoon.reflect.code.CtExpression)
----------------------------------------------------------
CtTypeInformation CtRole.SUPER_TYPE ItemType:
spoon.reflect.reference.CtTypeReference<?> get: getSuperclass() :
spoon.reflect.reference.CtTypeReference<?>
---------------------------------------------------------- CtNewClass
CtRole.NESTED_TYPE ItemType: spoon.reflect.declaration.CtClass<?> get:
getAnonymousClass() : spoon.reflect.declaration.CtClass<?> set:
setAnonymousClass(spoon.reflect.declaration.CtClass)
---------------------------------------------------------- CtType
CtRole.NESTED_TYPE ItemType:
java.util.Set<spoon.reflect.declaration.CtType<?>> get:
getNestedTypes() : java.util.Set<spoon.reflect.declaration.CtType<?>>
set: setNestedTypes(java.util.Set) add:
addNestedType(spoon.reflect.declaration.CtType) remove:
removeNestedType(spoon.reflect.declaration.CtType)
---------------------------------------------------------- CtClass
CtRole.CONSTRUCTOR ItemType:
java.util.Set<spoon.reflect.declaration.CtConstructor<T>> get:
getConstructors() :
java.util.Set<spoon.reflect.declaration.CtConstructor<T>> set:
setConstructors(java.util.Set) add:
addConstructor(spoon.reflect.declaration.CtConstructor) remove:
removeConstructor(spoon.reflect.declaration.CtConstructor)
----------------------------------------------------------
CtAbstractInvocation CtRole.EXECUTABLE ItemType:
spoon.reflect.reference.CtExecutableReference<T> get: getExecutable()
: spoon.reflect.reference.CtExecutableReference<T> set:
setExecutable(spoon.reflect.reference.CtExecutableReference)
----------------------------------------------------------
CtExecutableReferenceExpression CtRole.EXECUTABLE ItemType:
spoon.reflect.reference.CtExecutableReference<T> get: getExecutable()
: spoon.reflect.reference.CtExecutableReference<T> set:
setExecutable(spoon.reflect.reference.CtExecutableReference)
----------------------------------------------------------
CtParameterReference CtRole.EXECUTABLE ItemType:
spoon.reflect.reference.CtExecutableReference<?> get:
getDeclaringExecutable() :
spoon.reflect.reference.CtExecutableReference<?> set:
setDeclaringExecutable(spoon.reflect.reference.CtExecutableReference)
---------------------------------------------------------- CtType
CtRole.EXECUTABLE ItemType:
java.util.Set<spoon.reflect.declaration.CtMethod<?>> get: getMethods()
: java.util.Set<spoon.reflect.declaration.CtMethod<?>> set:
setMethods(java.util.Set) add:
addMethod(spoon.reflect.declaration.CtMethod) remove:
removeMethod(spoon.reflect.declaration.CtMethod)
---------------------------------------------------------- CtType
CtRole.FIELD ItemType:
java.util.List<spoon.reflect.declaration.CtField<?>> get: getFields()
: java.util.List<spoon.reflect.declaration.CtField<?>> set:
setFields(java.util.List) add:
addField(spoon.reflect.declaration.CtField) addFirst:
addFieldAtTop(spoon.reflect.declaration.CtField) addOn:
addField(int,spoon.reflect.declaration.CtField) remove:
removeField(spoon.reflect.declaration.CtField)
----------------------------------------------------------
CtExpression CtRole.CAST ItemType:
java.util.List<spoon.reflect.reference.CtTypeReference<?>> get:
getTypeCasts() :
java.util.List<spoon.reflect.reference.CtTypeReference<?>> set:
setTypeCasts(java.util.List) add:
addTypeCast(spoon.reflect.reference.CtTypeReference)
----------------------------------------------------------
CtAnnotation CtRole.VALUE ItemType: java.util.Map<java.lang.String,
spoon.reflect.code.CtExpression> get: getValues() :
java.util.Map<java.lang.String, spoon.reflect.code.CtExpression> set:
setValues(java.util.Map)
---------------------------------------------------------- CtEnum
CtRole.VALUE ItemType:
java.util.List<spoon.reflect.declaration.CtEnumValue<?>> get:
getEnumValues() :
java.util.List<spoon.reflect.declaration.CtEnumValue<?>> set:
setEnumValues(java.util.List) add:
addEnumValue(spoon.reflect.declaration.CtEnumValue) remove:
removeEnumValue(spoon.reflect.declaration.CtEnumValue)
---------------------------------------------------------- CtLiteral
CtRole.VALUE ItemType: T get: getValue() : T set: setValue(T)
---------------------------------------------------------- CtFor
CtRole.FOR_UPDATE ItemType:
java.util.List<spoon.reflect.code.CtStatement> get: getForUpdate() :
java.util.List<spoon.reflect.code.CtStatement> set:
setForUpdate(java.util.List) add:
addForUpdate(spoon.reflect.code.CtStatement) remove:
removeForUpdate(spoon.reflect.code.CtStatement)
---------------------------------------------------------- CtFor
CtRole.FOR_INIT ItemType:
java.util.List<spoon.reflect.code.CtStatement> get: getForInit() :
java.util.List<spoon.reflect.code.CtStatement> set:
setForInit(java.util.List) add:
addForInit(spoon.reflect.code.CtStatement) remove:
removeForInit(spoon.reflect.code.CtStatement)
----------------------------------------------------------
CtTryWithResource CtRole.TRY_RESOURCE ItemType:
java.util.List<spoon.reflect.code.CtLocalVariable<?>> get:
getResources() : java.util.List<spoon.reflect.code.CtLocalVariable<?>>
set: setResources(java.util.List) add:
addResource(spoon.reflect.code.CtLocalVariable) remove:
removeResource(spoon.reflect.code.CtLocalVariable)
---------------------------------------------------------- CtNewArray
CtRole.DIMENSION ItemType:
java.util.List<spoon.reflect.code.CtExpression<java.lang.Integer>>
get: getDimensionExpressions() :
java.util.List<spoon.reflect.code.CtExpression<java.lang.Integer>>
set: setDimensionExpressions(java.util.List) add:
addDimensionExpression(spoon.reflect.code.CtExpression) remove:
removeDimensionExpression(spoon.reflect.code.CtExpression)
---------------------------------------------------------- CtTry
CtRole.CATCH ItemType: java.util.List<spoon.reflect.code.CtCatch> get:
getCatchers() : java.util.List<spoon.reflect.code.CtCatch> set:
setCatchers(java.util.List) add:
addCatcher(spoon.reflect.code.CtCatch) remove:
removeCatcher(spoon.reflect.code.CtCatch)
----------------------------------------------------------
CtLabelledFlowBreak CtRole.TARGET_LABEL ItemType: java.lang.String
get: getTargetLabel() : java.lang.String set:
setTargetLabel(java.lang.String)
----------------------------------------------------------
CtActualTypeContainer CtRole.TYPE_PARAMETER ItemType:
java.util.List<spoon.reflect.reference.CtTypeReference<?>> get:
getActualTypeArguments() :
java.util.List<spoon.reflect.reference.CtTypeReference<?>> set:
setActualTypeArguments(java.util.List)
----------------------------------------------------------
CtFormalTypeDeclarer CtRole.TYPE_PARAMETER ItemType:
java.util.List<spoon.reflect.declaration.CtTypeParameter> get:
getFormalCtTypeParameters() :
java.util.List<spoon.reflect.declaration.CtTypeParameter> set:
setFormalCtTypeParameters(java.util.List) add:
addFormalCtTypeParameter(spoon.reflect.declaration.CtTypeParameter)
remove:
removeFormalCtTypeParameter(spoon.reflect.declaration.CtTypeParameter)
---------------------------------------------------------- CtJavaDoc
CtRole.COMMENT_TAG ItemType:
java.util.List<spoon.reflect.code.CtJavaDocTag> get: getTags() :
java.util.List<spoon.reflect.code.CtJavaDocTag> set:
setTags(java.util.List) add: addTag(spoon.reflect.code.CtJavaDocTag)
addOn: addTag(int,spoon.reflect.code.CtJavaDocTag) remove:
removeTag(spoon.reflect.code.CtJavaDocTag)
---------------------------------------------------------- CtComment
CtRole.COMMENT_CONTENT ItemType: java.lang.String get: getContent() :
java.lang.String set: setContent(java.lang.String)
----------------------------------------------------------
CtJavaDocTag CtRole.COMMENT_CONTENT ItemType: java.lang.String get:
getContent() : java.lang.String set: setContent(java.lang.String)
---------------------------------------------------------- CtComment
CtRole.COMMENT_TYPE ItemType: spoon.reflect.code.CtComment.CommentType
get: getCommentType() : spoon.reflect.code.CtComment.CommentType set:
setCommentType(spoon.reflect.code.CtComment$CommentType)
---------------------------------------------------------- CtElement
CtRole.POSITION ItemType: spoon.reflect.cu.SourcePosition get:
getPosition() : spoon.reflect.cu.SourcePosition set:
setPosition(spoon.reflect.cu.SourcePosition) |
At the beginning it will support only get and set method. Later we
might add, addFirst, addLast, addOn, remove, ...
Note: I expected that CtRole.Xxx has some meaning in the model, but
now it looks like the meaning highly depends on target element. Is it
correct?
Some of them seems strange to me: e.g. CtPackage CtRole.TYPE, which
does not return type of package (like other TYPE roles), but returns
set of all types which belongs to this package.
Is there some logic/semantic behind decision when to use same type
name and when another type name would be better?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1582 (comment)>, or
mute the thread
<https://github.com/notifications/unsubscribe-auth/AAxDUphfAxQjR_vYNVrhxh7v19iHtQeWks5ssO4FgaJpZM4Px2Gm>.
|
0f97e12
to
6bece32
Compare
I am glad that you see it same ;-) @monperrus Any idea how to test this PR? |
ab208f5
to
eefb15a
Compare
|Super interesting list. Here are important changes IMHO: CtJavaDocTag
CtRole.TYPE -> ||CtJavaDocTag CtRole.DOCUMENTATION_TYPE ||CtExecutableReference CtRole.PARAMETER -> ||CtExecutableReference CtRole.REF_PARAMETERS|
|CtJavaDocTag CtRole.PARAMETER -> |||CtJavaDocTag CtRole.JAVADOC_TAG_VALUE (actually the methods should be
renamed as well) |||CtExecutable CtRole.THROWN -> ||CtExecutable CtRole.THROWN||||_TYPES ||CtParameterReference CtRole.EXECUTABLE -> ||CtParameterReference CtRole.EXECUTABLE_REF|
|
What about this alternative?
These should be change too:
WDYT? I agree with other suggestions. |
|
eefb15a
to
04706a9
Compare
Note there are other places where suffix REF would be then needed too.
I agree
|
What about this alternative?
* CtExecutableReference CtRole.PARAMETER -> CtExecutableReference CtRole.PARAMETER_TYPES
CtParameterReference CtRole.EXECUTABLE -> CtParameterReference CtRole.EXECUTABLE_REF
These should be change too:
* CtExecutableReferenceExpression CtRole.EXECUTABLE - > CtExecutableReferenceExpression
CtRole.EXECUTABLE_REF
* CtAbstractInvocation CtRole.EXECUTABLE -> CtAbstractInvocation CtRole.EXECUTABLE_REF
WDYT?
OK for me.
|
@monperrus so please look at #1606 which contains most of these changes. Because this PR is about different topic |
95b5afa
to
5b14fa2
Compare
Here is latest overview of Type to role mappings, which fits to #1622, #1623, #1624, #1625 |
it is not true. RoleHandler instances are singletons and are bound to Classes of spoon types only.
OK, I will do it now |
On 11/8/17 9:58 PM, Pavel Vojtechovsky wrote:
However, it seems bound to a given element, would it make sense to
add a method CtElement getElement()?
it is not true. RoleHandler instances are singletons and are bound to
Classes of spoon types only.
Yes, I understand now.
Do the asCollection / etc methods of RoleHandler return the special wrapper?
(if yes, then clients can use this special feature through
RoleHandlerHelper, and not through CtElement)
|
yes, they do. The code, which is same like List listWrapper = element.getValueByRoleAsList(role) looks like this List listWrapper = RoleHandlerHelper.getRoleHandler(element.getClass(), role).asList(element); If you like this idea, then delete |
I am finished with changes for today - until tomorrow evening, so branch is yours - you can commit there ;-) |
reformulated javadoc, removed the methods from CtElement.
|
/** | ||
* @param role defines, which attribute has to be returned | ||
* @param value to be assigned value | ||
* Sets a field according to a role. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we should mention this here too:
single value (eg a CtElement), List, Set or Map depending on this
element
androle
*/ | ||
public interface RoleHandler { | ||
// the main methods, responsible to get and set the field corresponding to this role | ||
/** | ||
* @param element a element whose value will be get | ||
* @param element a element from which the value will be get for this role |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
single value (eg a CtElement), List, Set or Map depending on this
element
androle
* @return a value of the element on the role defined by {@link #getRole()} | ||
*/ | ||
<T, U> U getValue(T element); | ||
/** | ||
* @param element a element whose value will be set | ||
* @param element a element whose value will be set for this role |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
single value (eg a CtElement), List, Set or Map depending on this
element
androle
Detected changes by Revapi: 2. Old API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-20171109.180511-154 New API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-SNAPSHOT
|
c9476dd
to
1498392
Compare
Detected changes by Revapi: 2. Old API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-20171109.180511-154 New API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-SNAPSHOT
|
2 similar comments
Detected changes by Revapi: 2. Old API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-20171109.180511-154 New API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-SNAPSHOT
|
Detected changes by Revapi: 2. Old API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-20171109.180511-154 New API: fr.inria.gforge.spoon:spoon-core:jar:6.0.0-SNAPSHOT
|
Early implementation of spoon model CtRole based access to element attributes. See discussion in #1581