Search in sources :

Example 1 with TemplateVisitor

use of sharpen.xobotos.api.TemplateVisitor in project XobotOS by xamarin.

the class CompilationUnitTemplate method findTypeTemplate.

@Override
public TypeTemplate findTypeTemplate(final TypeDeclaration node) {
    if (!(node.getParent() instanceof CompilationUnit))
        return null;
    final CompilationUnit parent = (CompilationUnit) node.getParent();
    final ByRef<TypeTemplate> result = new ByRef<TypeTemplate>();
    TemplateVisitor visitor = new TemplateVisitor() {

        @Override
        public void accept(TypeTemplate type) {
            result.value = type;
        }
    };
    if (!visit(visitor, parent, node))
        return null;
    return result.value != null ? result.value : TypeTemplate.DEFAULT;
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) TemplateVisitor(sharpen.xobotos.api.TemplateVisitor) ByRef(sharpen.core.framework.ByRef)

Example 2 with TemplateVisitor

use of sharpen.xobotos.api.TemplateVisitor in project XobotOS by xamarin.

the class CompilationUnitTemplate method findEnumTemplate.

@Override
public EnumTemplate findEnumTemplate(final EnumDeclaration node) {
    if (!(node.getParent() instanceof CompilationUnit))
        return null;
    final CompilationUnit parent = (CompilationUnit) node.getParent();
    final ByRef<EnumTemplate> result = new ByRef<EnumTemplate>();
    TemplateVisitor visitor = new TemplateVisitor() {

        @Override
        public void accept(EnumTemplate type) {
            result.value = type;
        }
    };
    if (!visit(visitor, parent, node))
        return null;
    return result.value != null ? result.value : EnumTemplate.DEFAULT;
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) TemplateVisitor(sharpen.xobotos.api.TemplateVisitor) ByRef(sharpen.core.framework.ByRef)

Example 3 with TemplateVisitor

use of sharpen.xobotos.api.TemplateVisitor in project XobotOS by xamarin.

the class TypeTemplate method findMemberTemplate.

public <T extends ASTNode, U extends CSNode, V extends AbstractMemberTemplate<T, U>> V findMemberTemplate(final T node, final V defaultValue, final Class<V> klass) {
    if (node instanceof AnonymousClassDeclaration) {
        ;
    } else if (node.getParent() instanceof AnonymousClassDeclaration) {
        ;
    } else if (!(node.getParent() instanceof TypeDeclaration))
        return null;
    final ByRef<V> result = new ByRef<V>();
    TemplateVisitor visitor = new TemplateVisitor() {

        @Override
        public void accept(AbstractTemplate template) {
            result.value = klass.cast(template);
        }
    };
    if (!visit(visitor, node, klass))
        return null;
    return result.value != null ? result.value : defaultValue;
}
Also used : TemplateVisitor(sharpen.xobotos.api.TemplateVisitor) ByRef(sharpen.core.framework.ByRef) CSTypeDeclaration(sharpen.core.csharp.ast.CSTypeDeclaration)

Aggregations

ByRef (sharpen.core.framework.ByRef)3 TemplateVisitor (sharpen.xobotos.api.TemplateVisitor)3 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)2 CSTypeDeclaration (sharpen.core.csharp.ast.CSTypeDeclaration)1