Path expression to select all Java constructors
ddgenome opened this issue · comments
From @ElderMael in atomist-community:
I have several classes that expose two constructors (default and one with all the fields they have). I am unable to create a expression that selects both constructors. It is selecting only the default constructor. So far I only have this: //JavaConstructor()
public edit(project: Project) {
const eng: PathExpressionEngine = project.context.pathExpressionEngine;
let superTypesToExclude = this.excludingSuperTypes ? this.excludingSuperTypes.split("-") : [];
eng.with<JavaSource>(project,
`//JavaSource()`,
javaSourceCode => {
eng.with<JavaType>(javaSourceCode,
`//JavaType()[.pkg()='${ this.packageOfTypesToAnnotate }']`,
javaType => {
let isTheSuperType = superTypesToExclude.some((superType) => {
let isSameType = superType === javaType.name;
return isSameType;
});
if (isTheSuperType) {
return;
}
eng.with<JavaConstructor>(javaType, '//JavaConstructor()', javaConstructor => {
javaConstructor.addAnnotation(this.annotationPackage, this.annotationName);
});
});
});
}
Reference: https://atomist-community.slack.com/files/U2RL76AMS/F78FVA5K7/Edit_Method.js
@ElderMael we will need to discuss in the community how to best move this forward in the new world.