Search in sources :

Example 1 with MethodInvocation

use of org.whole.lang.java.model.MethodInvocation 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());
}
Also used : ClassDeclaration(org.whole.lang.java.model.ClassDeclaration) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) MethodInvocation(org.whole.lang.java.model.MethodInvocation) Test(org.junit.Test)

Example 2 with MethodInvocation

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

the class MethodInvocationPart method getModelSpecificChildren.

protected List<IEntity> getModelSpecificChildren() {
    MethodInvocation entity = getModelEntity();
    ((MethodInvocationFigure) getFigure()).hideExpression(EntityUtils.isResolver(entity.getExpression()));
    ((MethodInvocationFigure) getFigure()).hideTypeParameters(EntityUtils.isResolver(entity.getTypeArguments()));
    List<IEntity> list = new ArrayList<IEntity>(4);
    list.add(entity.getExpression());
    list.add(entity.getTypeArguments());
    list.add(entity.getName());
    list.add(entity.getArguments());
    return list;
}
Also used : MethodInvocationFigure(org.whole.lang.java.ui.figures.MethodInvocationFigure) IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) MethodInvocation(org.whole.lang.java.model.MethodInvocation)

Aggregations

MethodInvocation (org.whole.lang.java.model.MethodInvocation)2 IEntity (org.whole.lang.model.IEntity)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 IBindingManager (org.whole.lang.bindings.IBindingManager)1 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)1 MethodInvocationFigure (org.whole.lang.java.ui.figures.MethodInvocationFigure)1