Search in sources :

Example 1 with GrAccessorMethodImpl

use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrAccessorMethodImpl in project intellij-community by JetBrains.

the class DefaultTransformationSupport method applyTransformation.

@Override
public void applyTransformation(@NotNull TransformationContext context) {
    for (GrField field : context.getFields()) {
        if (!field.isProperty())
            continue;
        final String fieldName = field.getName();
        String nameNonBoolean = getGetterNameNonBoolean(fieldName);
        if (!hasContradictingMethods(context, nameNonBoolean, false)) {
            context.addMethod(new GrAccessorMethodImpl(field, false, nameNonBoolean));
            if (PsiType.BOOLEAN.equals(field.getDeclaredType())) {
                String nameBoolean = getGetterNameBoolean(fieldName);
                if (!hasContradictingMethods(context, nameBoolean, false)) {
                    context.addMethod(new GrAccessorMethodImpl(field, false, nameBoolean));
                }
            }
        }
        if (!field.hasModifierProperty(PsiModifier.FINAL)) {
            String setterName = getSetterName(fieldName);
            if (!hasContradictingMethods(context, setterName, true)) {
                context.addMethod(new GrAccessorMethodImpl(field, true, setterName));
            }
        }
    }
}
Also used : GrField(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField) GrAccessorMethodImpl(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrAccessorMethodImpl)

Aggregations

GrField (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField)1 GrAccessorMethodImpl (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrAccessorMethodImpl)1