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;
}
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;
}
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;
}
Aggregations