use of org.whole.lang.java.model.ClassDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithTwoNestedSelectQueries.
@Test
public void testSelectTemplateWithTwoNestedSelectQueries() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithTwoNestedSelectQueries");
for (ClassDeclaration t : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, m)) {
assertEquals(JavaEntityDescriptorEnum.ClassDeclaration, t.wGetEntityDescriptor());
BodyDeclarations bodyDeclarations = t.getBodyDeclarations();
MethodDeclaration md = (MethodDeclaration) bodyDeclarations.wGet(bodyDeclarations.wSize() - 1);
assertEquals(bodyDeclarations.wSize() - 1, md.getBody().wSize());
}
}
use of org.whole.lang.java.model.ClassDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithNestedEmptyQuery.
@Test
public void testSelectTemplateWithNestedEmptyQuery() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithNestedEmptyQuery");
for (ClassDeclaration t : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, m)) {
assertEquals(JavaEntityDescriptorEnum.ClassDeclaration, t.wGetEntityDescriptor());
assertEquals(2, t.getBodyDeclarations().wSize());
}
}
use of org.whole.lang.java.model.ClassDeclaration 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;
}
use of org.whole.lang.java.model.ClassDeclaration in project whole by wholeplatform.
the class MatcherTest method testMultipleTypesSubstitute.
@Test
public void testMultipleTypesSubstitute() {
ClassDeclaration functionPattern = new FunctionPattern().create();
IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
bindings.wDefValue("factName", "factorial");
bindings.wDefValue("factArg", 5);
Matcher.substitute(functionPattern, bindings, false);
IEntity var1 = functionPattern.getBodyDeclarations().wGet(0).wGet(JavaFeatureDescriptorEnum.name);
MethodInvocation methodInvocation = (MethodInvocation) functionPattern.getBodyDeclarations().wGet(1).wGet(JavaFeatureDescriptorEnum.body).wGet(0).wGet(JavaFeatureDescriptorEnum.expression).wGet(JavaFeatureDescriptorEnum.arguments).wGet(0);
IEntity var2 = methodInvocation.getName();
IEntity var3 = methodInvocation.getArguments().wGet(0);
assertEquals("factorial", var1.wStringValue());
assertEquals("factorial", var2.wStringValue());
assertEquals(5, var3.wByteValue());
}
use of org.whole.lang.java.model.ClassDeclaration in project whole by wholeplatform.
the class ClassDeclarationPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
ClassDeclaration classDeclaration = getModelEntity();
((ClassDeclarationFigure) getFigure()).hideTypeParameters(EntityUtils.isResolver(classDeclaration.getTypeParameters()));
((ClassDeclarationFigure) getFigure()).hideSuperclassType(EntityUtils.isResolver(classDeclaration.getSuperclassType()));
((ClassDeclarationFigure) getFigure()).hideSuperInterfaceTypes(EntityUtils.isResolver(classDeclaration.getSuperInterfaceTypes()));
List<IEntity> list = new ArrayList<IEntity>(7);
list.add(classDeclaration.getJavadoc());
list.add(classDeclaration.getModifiers());
list.add(classDeclaration.getName());
list.add(classDeclaration.getTypeParameters());
list.add(classDeclaration.getSuperclassType());
list.add(classDeclaration.getSuperInterfaceTypes());
list.add(classDeclaration.getBodyDeclarations());
return list;
}
Aggregations