Search in sources :

Example 6 with Type

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

the class JDTTransformerVisitor method visit.

public boolean visit(EnumDeclaration 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.EnumDeclaration enumDeclaration;
    appendBodyDeclaration(enumDeclaration = lf.create(JavaEntityDescriptorEnum.EnumDeclaration));
    if (acceptChild(node.getJavadoc()))
        enumDeclaration.setJavadoc(this.javadoc);
    List<?> modifiers = node.modifiers();
    if (!modifiers.isEmpty()) {
        enumDeclaration.setModifiers(lf.create(JavaEntityDescriptorEnum.ExtendedModifiers));
        setExtendedModifiers(enumDeclaration.getModifiers(), modifiers);
    }
    if (acceptChild(node.getName()))
        enumDeclaration.setName((org.whole.lang.java.model.SimpleName) this.name);
    Iterator<?> i = node.superInterfaceTypes().iterator();
    while (i.hasNext()) {
        ((ASTNode) i.next()).accept(this);
        enumDeclaration.getSuperInterfaceTypes().wAdd(this.type);
    }
    org.whole.lang.java.model.EnumConstants enumConstants = lf.create(JavaEntityDescriptorEnum.EnumConstants);
    enumDeclaration.setEnumConstants(enumConstants);
    env().wDef("typeDeclarationsContainer", enumConstants);
    acceptChildren(node.enumConstants());
    org.whole.lang.java.model.BodyDeclarations bodyDecl = lf.createBodyDeclarations();
    enumDeclaration.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) ASTNode(org.eclipse.jdt.core.dom.ASTNode) Type(org.whole.lang.java.model.Type)

Example 7 with Type

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

the class JDTTransformerVisitor method visit.

public boolean visit(CastExpression node) {
    acceptChild(node.getType());
    org.whole.lang.java.model.Type type1 = type;
    acceptChild(node.getExpression());
    exp = lf.createCastExpression(type1, exp);
    return false;
}
Also used : Type(org.whole.lang.java.model.Type)

Example 8 with Type

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

the class Helpers method isFactoryMethod.

public static boolean isFactoryMethod(MethodDeclaration entity) {
    if (!Matcher.matchImpl(JavaEntityDescriptorEnum.SimpleName, entity.getName().wGetAdaptee(false)))
        return false;
    String methodName = entity.getName().getValue();
    Type returnType = entity.getReturnType();
    return (methodName.startsWith("create") || methodName.startsWith("new")) && !returnType.wGetEntityDescriptor().equals(JavaEntityDescriptorEnum.PrimitiveType);
}
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