Search in sources :

Example 6 with IProperty

use of dyvilx.tools.compiler.ast.field.IProperty in project Dyvil by Dyvil.

the class CaseClassMetadata method resolveTypesPre.

@Override
public void resolveTypesPre(MarkerList markers, IContext context) {
    super.resolveTypesPre(markers, context);
    for (IParameter param : this.theClass.getParameters()) {
        final ClassParameter classParameter = (ClassParameter) param;
        if (classParameter.isOverride() || classParameter.getProperty() != null) {
            // Ignore override class parameters and class parameters that already have a property
            continue;
        }
        // Create a property with getter
        final IProperty property = classParameter.createProperty();
        property.getAttributes().addFlag(Modifiers.GENERATED);
        property.initGetter();
        if (!classParameter.hasModifier(Modifiers.FINAL)) {
            // and setter, for non-final class parameters
            property.initSetter();
        }
    }
}
Also used : IParameter(dyvilx.tools.compiler.ast.parameter.IParameter) IProperty(dyvilx.tools.compiler.ast.field.IProperty) ClassParameter(dyvilx.tools.compiler.ast.parameter.ClassParameter)

Example 7 with IProperty

use of dyvilx.tools.compiler.ast.field.IProperty in project Dyvil by Dyvil.

the class ClassMetadata method checkMembers.

private void checkMembers(ClassBody body) {
    for (int i = 0, count = body.methodCount(); i < count; i++) {
        this.checkMethod(body.getMethod(i));
    }
    for (int i = 0, count = body.propertyCount(); i < count; i++) {
        final IMethod getter = body.getProperty(i).getGetter();
        if (getter != null) {
            this.checkMethod(getter);
        }
    // only check the getter
    }
    for (int i = 0, count = body.fieldCount(); i < count; i++) {
        final IField field = body.getField(i);
        this.checkField(field);
        final IProperty property = field.getProperty();
        final IMethod getter;
        if (property != null && (getter = property.getGetter()) != null) {
            this.checkMethod(getter);
        }
    // only check the getter
    }
}
Also used : IProperty(dyvilx.tools.compiler.ast.field.IProperty) IMethod(dyvilx.tools.compiler.ast.method.IMethod) IField(dyvilx.tools.compiler.ast.field.IField)

Example 8 with IProperty

use of dyvilx.tools.compiler.ast.field.IProperty in project Dyvil by Dyvil.

the class CompleteCommand method printCompletions.

private void printCompletions(DyvilREPL repl, String memberStart, IValue value) {
    final IType type = value.getType();
    final boolean statics = value.isClassAccess();
    final IContext context = repl.getContext().getContext();
    final Set<IField> fields = new TreeSet<>(MemberSorter.MEMBER_COMPARATOR);
    final Set<IProperty> properties = new TreeSet<>(MemberSorter.MEMBER_COMPARATOR);
    final Set<IMethod> methods = new TreeSet<>(MemberSorter.METHOD_COMPARATOR);
    final Set<IMethod> extensionMethods = new TreeSet<>(MemberSorter.METHOD_COMPARATOR);
    final Set<IMethod> conversionMethods = new TreeSet<>(MemberSorter.METHOD_COMPARATOR);
    final PrintStream output = repl.getOutput();
    if (statics) {
        output.println(I18n.get("command.complete.type", type));
        findMembers(type, fields, properties, methods, memberStart, true);
        findExtensions(context, type, value, extensionMethods, memberStart, true);
    } else {
        output.println(I18n.get("command.complete.expression", value, type));
        findInstanceMembers(type, fields, properties, methods, memberStart, new IdentityHashSet<>());
        findExtensions(context, type, value, extensionMethods, memberStart, false);
        findConversions(context, type, value, conversionMethods);
    }
    boolean hasOutput = false;
    if (!fields.isEmpty()) {
        hasOutput = true;
        output.println(I18n.get("command.complete.fields"));
        printMembers(output, fields, type);
    }
    if (!properties.isEmpty()) {
        hasOutput = true;
        output.println(I18n.get("command.complete.properties"));
        printMembers(output, properties, type);
    }
    if (!methods.isEmpty()) {
        hasOutput = true;
        output.println(I18n.get("command.complete.methods"));
        printMethods(output, methods, type);
    }
    if (!extensionMethods.isEmpty()) {
        hasOutput = true;
        output.println(I18n.get("command.complete.extensions"));
        printMethods(output, extensionMethods, type);
    }
    if (!conversionMethods.isEmpty()) {
        hasOutput = true;
        output.println(I18n.get("command.complete.conversions"));
        printMethods(output, conversionMethods, type);
    }
    if (!hasOutput) {
        output.println(I18n.get("command.complete.none"));
    }
}
Also used : PrintStream(java.io.PrintStream) IContext(dyvilx.tools.compiler.ast.context.IContext) IProperty(dyvilx.tools.compiler.ast.field.IProperty) TreeSet(dyvil.collection.mutable.TreeSet) IMethod(dyvilx.tools.compiler.ast.method.IMethod) IField(dyvilx.tools.compiler.ast.field.IField) IType(dyvilx.tools.compiler.ast.type.IType)

Example 9 with IProperty

use of dyvilx.tools.compiler.ast.field.IProperty in project Dyvil by Dyvil.

the class REPLContext method getMethodMatches.

@Override
public void getMethodMatches(MatchList<IMethod> list, IValue receiver, Name name, ArgumentList arguments) {
    for (IMethod method : this.methods) {
        method.checkMatch(list, receiver, name, arguments);
    }
    if (name == null) {
        return;
    }
    final Name removeEq = Util.removeEq(name);
    IProperty property = this.properties.get(removeEq);
    if (property != null) {
        property.checkMatch(list, receiver, name, arguments);
    }
    final IField field = this.fields.get(removeEq);
    if (field != null) {
        property = field.getProperty();
        if (property != null) {
            property.checkMatch(list, receiver, name, arguments);
        }
    }
}
Also used : IProperty(dyvilx.tools.compiler.ast.field.IProperty) IMethod(dyvilx.tools.compiler.ast.method.IMethod) IField(dyvilx.tools.compiler.ast.field.IField) Name(dyvil.lang.Name)

Aggregations

IProperty (dyvilx.tools.compiler.ast.field.IProperty)9 IField (dyvilx.tools.compiler.ast.field.IField)4 IMethod (dyvilx.tools.compiler.ast.method.IMethod)4 Name (dyvil.lang.Name)2 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)2 IType (dyvilx.tools.compiler.ast.type.IType)2 ArrayList (dyvil.collection.immutable.ArrayList)1 TreeSet (dyvil.collection.mutable.TreeSet)1 Modifiers (dyvil.reflect.Modifiers)1 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)1 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)1 CodeAnnotation (dyvilx.tools.compiler.ast.attribute.annotation.CodeAnnotation)1 Modifier (dyvilx.tools.compiler.ast.attribute.modifiers.Modifier)1 ITypeConsumer (dyvilx.tools.compiler.ast.consumer.ITypeConsumer)1 IContext (dyvilx.tools.compiler.ast.context.IContext)1 EnumConstant (dyvilx.tools.compiler.ast.field.EnumConstant)1 ClassParameter (dyvilx.tools.compiler.ast.parameter.ClassParameter)1 IParametric (dyvilx.tools.compiler.ast.parameter.IParametric)1 Types (dyvilx.tools.compiler.ast.type.builtin.Types)1 ArrayType (dyvilx.tools.compiler.ast.type.compound.ArrayType)1