Search in sources :

Example 1 with Type

use of org.whole.lang.java.model.Type in project whole by wholeplatform.

the class JDTTransformerVisitor method visit.

public boolean visit(AnnotationTypeDeclaration node) {
    // FIXME workaround for type nesting
    org.whole.lang.java.model.Type type = this.type;
    org.whole.lang.java.model.Name name = this.name;
    org.whole.lang.java.model.TypeParameter typeParameter = this.typeParameter;
    org.whole.lang.java.model.Parameters params = this.params;
    org.whole.lang.java.model.Types thrownExceptions = this.thrownExceptions;
    org.whole.lang.java.model.SingleVariableDeclaration varDecl = this.varDecl;
    org.whole.lang.java.model.Block block = this.block;
    org.whole.lang.java.model.Statement stm = this.stm;
    org.whole.lang.java.model.Expression exp = this.exp;
    org.whole.lang.java.model.VariableDeclarationFragment varFrag = this.varFrag;
    org.whole.lang.java.model.CatchClauses catchClauses = this.catchClauses;
    env().wEnterScope();
    org.whole.lang.java.model.AnnotationTypeDeclaration annotationTypeDeclaration;
    appendBodyDeclaration(annotationTypeDeclaration = lf.create(JavaEntityDescriptorEnum.AnnotationTypeDeclaration));
    if (acceptChild(node.getJavadoc()))
        annotationTypeDeclaration.setJavadoc(this.javadoc);
    List<?> modifiers = node.modifiers();
    if (!modifiers.isEmpty()) {
        annotationTypeDeclaration.setModifiers(lf.create(JavaEntityDescriptorEnum.ExtendedModifiers));
        setExtendedModifiers(annotationTypeDeclaration.getModifiers(), modifiers);
    }
    if (acceptChild(node.getName()))
        annotationTypeDeclaration.setName((org.whole.lang.java.model.SimpleName) this.name);
    org.whole.lang.java.model.BodyDeclarations bodyDecl = lf.createBodyDeclarations();
    annotationTypeDeclaration.setBodyDeclarations(bodyDecl);
    env().wDef("typeDeclarationsContainer", bodyDecl);
    acceptChildren(node.bodyDeclarations());
    env().wExitScope();
    // FIXME workaround for type nesting
    this.type = type;
    this.name = name;
    this.typeParameter = typeParameter;
    this.params = params;
    this.thrownExceptions = thrownExceptions;
    this.varDecl = varDecl;
    this.block = block;
    this.stm = stm;
    this.exp = exp;
    this.varFrag = varFrag;
    this.catchClauses = catchClauses;
    return false;
}
Also used : SimpleName(org.eclipse.jdt.core.dom.SimpleName) Type(org.whole.lang.java.model.Type)

Example 2 with Type

use of org.whole.lang.java.model.Type in project whole by wholeplatform.

the class JDTTransformerVisitor method visit.

public boolean visit(AnonymousClassDeclaration node) {
    // FIXME workaround for type nesting
    org.whole.lang.java.model.Type type = this.type;
    org.whole.lang.java.model.Name name = this.name;
    org.whole.lang.java.model.TypeParameter typeParameter = this.typeParameter;
    org.whole.lang.java.model.Parameters params = this.params;
    org.whole.lang.java.model.Types thrownExceptions = this.thrownExceptions;
    org.whole.lang.java.model.SingleVariableDeclaration varDecl = this.varDecl;
    org.whole.lang.java.model.Block block = this.block;
    org.whole.lang.java.model.Statement stm = this.stm;
    org.whole.lang.java.model.Expression exp = this.exp;
    org.whole.lang.java.model.VariableDeclarationFragment varFrag = this.varFrag;
    org.whole.lang.java.model.CatchClauses catchClauses = this.catchClauses;
    org.whole.lang.java.model.AnonymousClassDeclaration anonymousClassDeclaration = lf.create(JavaEntityDescriptorEnum.AnonymousClassDeclaration);
    env().wEnterScope();
    env().wDef("typeDeclarationsContainer", anonymousClassDeclaration);
    acceptChildren(node.bodyDeclarations());
    env().wExitScope();
    // FIXME workaround for type nesting
    this.type = type;
    this.name = name;
    this.typeParameter = typeParameter;
    this.params = params;
    this.thrownExceptions = thrownExceptions;
    this.varDecl = varDecl;
    this.block = block;
    this.stm = stm;
    this.exp = exp;
    this.varFrag = varFrag;
    this.catchClauses = catchClauses;
    this.anonymousClassDeclaration = anonymousClassDeclaration;
    return false;
}
Also used : Type(org.whole.lang.java.model.Type)

Example 3 with Type

use of org.whole.lang.java.model.Type in project whole by wholeplatform.

the class JDTTransformerVisitor method setTypeArguments.

private void setTypeArguments(IEntity typeArguments, List<?> jdtTypeArguments) {
    IEntity parent = typeArguments.wGetParent();
    FeatureDescriptor fd = parent.wGetFeatureDescriptor(typeArguments);
    for (Iterator<?> i = jdtTypeArguments.iterator(); i.hasNext(); ) {
        org.eclipse.jdt.core.dom.Type type = (org.eclipse.jdt.core.dom.Type) i.next();
        acceptChild((org.eclipse.jdt.core.dom.Type) type);
        parent.wGet(fd).wAdd(this.type);
    }
}
Also used : UnionType(org.eclipse.jdt.core.dom.UnionType) ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) IntersectionType(org.eclipse.jdt.core.dom.IntersectionType) WildcardType(org.eclipse.jdt.core.dom.WildcardType) Type(org.whole.lang.java.model.Type) PrimitiveType(org.eclipse.jdt.core.dom.PrimitiveType) NameQualifiedType(org.eclipse.jdt.core.dom.NameQualifiedType) ArrayType(org.eclipse.jdt.core.dom.ArrayType) SimpleType(org.eclipse.jdt.core.dom.SimpleType) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Example 4 with Type

use of org.whole.lang.java.model.Type in project whole by wholeplatform.

the class JDTTransformerVisitor method visit.

public boolean visit(TypeDeclaration node) {
    // FIXME workaround for type nesting
    org.whole.lang.java.model.Type type = this.type;
    org.whole.lang.java.model.Name name = this.name;
    org.whole.lang.java.model.TypeParameter typeParameter = this.typeParameter;
    org.whole.lang.java.model.Parameters params = this.params;
    org.whole.lang.java.model.Types thrownExceptions = this.thrownExceptions;
    org.whole.lang.java.model.SingleVariableDeclaration varDecl = this.varDecl;
    org.whole.lang.java.model.Block block = this.block;
    org.whole.lang.java.model.Statement stm = this.stm;
    org.whole.lang.java.model.Expression exp = this.exp;
    org.whole.lang.java.model.VariableDeclarationFragment varFrag = this.varFrag;
    org.whole.lang.java.model.CatchClauses catchClauses = this.catchClauses;
    org.whole.lang.java.model.AnonymousClassDeclaration anonymousClassDeclaration = this.anonymousClassDeclaration;
    env().wEnterScope();
    if (node.isInterface()) {
        InterfaceDeclaration interfaceDecl;
        appendBodyDeclaration(interfaceDecl = lf.create(JavaEntityDescriptorEnum.InterfaceDeclaration));
        if (acceptChild(node.getJavadoc()))
            interfaceDecl.setJavadoc(this.javadoc);
        Iterator<?> j = node.typeParameters().iterator();
        while (j.hasNext()) {
            ((ASTNode) j.next()).accept(this);
            interfaceDecl.getTypeParameters().wAdd(this.typeParameter);
        }
        List<?> modifiers = node.modifiers();
        if (!modifiers.isEmpty()) {
            interfaceDecl.setModifiers(lf.create(JavaEntityDescriptorEnum.ExtendedModifiers));
            setExtendedModifiers(interfaceDecl.getModifiers(), modifiers);
        }
        if (acceptChild(node.getName()))
            interfaceDecl.setName((org.whole.lang.java.model.SimpleName) this.name);
        Iterator<?> i = node.superInterfaceTypes().iterator();
        while (i.hasNext()) {
            ((ASTNode) i.next()).accept(this);
            interfaceDecl.getSuperInterfaceTypes().wAdd(this.type);
        }
        org.whole.lang.java.model.BodyDeclarations bodyDecl = lf.createBodyDeclarations();
        interfaceDecl.setBodyDeclarations(bodyDecl);
        env().wDef("typeDeclarationsContainer", bodyDecl);
        acceptChildren(node.bodyDeclarations());
    } else {
        ClassDeclaration classDecl;
        appendBodyDeclaration(classDecl = lf.create(JavaEntityDescriptorEnum.ClassDeclaration));
        if (acceptChild(node.getJavadoc()))
            classDecl.setJavadoc(this.javadoc);
        Iterator<?> j = node.typeParameters().iterator();
        while (j.hasNext()) {
            ((ASTNode) j.next()).accept(this);
            classDecl.getTypeParameters().wAdd(this.typeParameter);
        }
        List<?> modifiers = node.modifiers();
        if (!modifiers.isEmpty()) {
            classDecl.setModifiers(lf.create(JavaEntityDescriptorEnum.ExtendedModifiers));
            setExtendedModifiers(classDecl.getModifiers(), modifiers);
        }
        if (acceptChild(node.getName()))
            classDecl.setName((org.whole.lang.java.model.SimpleName) this.name);
        if (acceptChild(node.getSuperclassType()))
            classDecl.setSuperclassType(this.type);
        Iterator<?> i = node.superInterfaceTypes().iterator();
        while (i.hasNext()) {
            ((ASTNode) i.next()).accept(this);
            classDecl.getSuperInterfaceTypes().wAdd(this.type);
        }
        org.whole.lang.java.model.BodyDeclarations bodyDecl = lf.createBodyDeclarations();
        classDecl.setBodyDeclarations(bodyDecl);
        env().wDef("typeDeclarationsContainer", bodyDecl);
        acceptChildren(node.bodyDeclarations());
    }
    env().wExitScope();
    // FIXME workaround for type nesting
    this.anonymousClassDeclaration = anonymousClassDeclaration;
    this.type = type;
    this.name = name;
    this.typeParameter = typeParameter;
    this.params = params;
    this.thrownExceptions = thrownExceptions;
    this.varDecl = varDecl;
    this.block = block;
    this.stm = stm;
    this.exp = exp;
    this.varFrag = varFrag;
    this.catchClauses = catchClauses;
    return false;
}
Also used : SimpleName(org.eclipse.jdt.core.dom.SimpleName) InterfaceDeclaration(org.whole.lang.java.model.InterfaceDeclaration) AnonymousClassDeclaration(org.eclipse.jdt.core.dom.AnonymousClassDeclaration) ClassDeclaration(org.whole.lang.java.model.ClassDeclaration) ASTNode(org.eclipse.jdt.core.dom.ASTNode) Type(org.whole.lang.java.model.Type)

Example 5 with Type

use of org.whole.lang.java.model.Type in project whole by wholeplatform.

the class JDTTransformerVisitor method visit.

@Override
public boolean visit(LambdaExpression node) {
    // FIXME workaround for type nesting
    org.whole.lang.java.model.Type type = this.type;
    org.whole.lang.java.model.Name name = this.name;
    org.whole.lang.java.model.TypeParameter typeParameter = this.typeParameter;
    org.whole.lang.java.model.Parameters params = this.params;
    org.whole.lang.java.model.Types thrownExceptions = this.thrownExceptions;
    org.whole.lang.java.model.SingleVariableDeclaration varDecl = this.varDecl;
    org.whole.lang.java.model.Block block = this.block;
    org.whole.lang.java.model.Statement stm = this.stm;
    org.whole.lang.java.model.VariableDeclarationFragment varFrag = this.varFrag;
    org.whole.lang.java.model.CatchClauses catchClauses = this.catchClauses;
    org.whole.lang.java.model.AnonymousClassDeclaration anonymousClassDeclaration = lf.create(JavaEntityDescriptorEnum.AnonymousClassDeclaration);
    org.whole.lang.java.model.LambdaExpression lambdaExpression = lf.createLambdaExpression();
    this.params = null;
    if (node.hasParentheses()) {
        Iterator<?> iterator = node.parameters().iterator();
        while (iterator.hasNext()) {
            this.varDecl = null;
            this.varFrag = null;
            acceptChild((ASTNode) iterator.next());
            lambdaExpression.getParameters().wAdd(this.varDecl != null ? this.varDecl : this.varFrag);
        }
        if (EntityUtils.isResolver(lambdaExpression.getParameters()))
            lambdaExpression.setParameters(lf.createParameters(0));
    } else {
        acceptChild((ASTNode) node.parameters().get(0));
        lambdaExpression.setParameters(this.varFrag);
    }
    this.exp = null;
    this.stm = null;
    acceptChild(node.getBody());
    lambdaExpression.setBody(this.stm != null ? this.stm : this.exp);
    exp = lambdaExpression;
    // FIXME workaround for type nesting
    this.type = type;
    this.name = name;
    this.typeParameter = typeParameter;
    this.params = params;
    this.thrownExceptions = thrownExceptions;
    this.varDecl = varDecl;
    this.block = block;
    this.stm = stm;
    this.varFrag = varFrag;
    this.catchClauses = catchClauses;
    this.anonymousClassDeclaration = anonymousClassDeclaration;
    return false;
}
Also used : Type(org.whole.lang.java.model.Type)

Aggregations

Type (org.whole.lang.java.model.Type)8 SimpleName (org.eclipse.jdt.core.dom.SimpleName)3 ASTNode (org.eclipse.jdt.core.dom.ASTNode)2 AnonymousClassDeclaration (org.eclipse.jdt.core.dom.AnonymousClassDeclaration)1 ArrayType (org.eclipse.jdt.core.dom.ArrayType)1 IntersectionType (org.eclipse.jdt.core.dom.IntersectionType)1 NameQualifiedType (org.eclipse.jdt.core.dom.NameQualifiedType)1 ParameterizedType (org.eclipse.jdt.core.dom.ParameterizedType)1 PrimitiveType (org.eclipse.jdt.core.dom.PrimitiveType)1 SimpleType (org.eclipse.jdt.core.dom.SimpleType)1 UnionType (org.eclipse.jdt.core.dom.UnionType)1 WildcardType (org.eclipse.jdt.core.dom.WildcardType)1 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)1 InterfaceDeclaration (org.whole.lang.java.model.InterfaceDeclaration)1 IEntity (org.whole.lang.model.IEntity)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1