@Test public void testFail2() throws Exception { IAstFactory f = getASTFactory(); EObject add = f.create(ComplexrewritetestPackage.Literals.ADD); // one operand INVALID EObject atom1 = f.create(ComplexrewritetestPackage.Literals.ATOM); f.set(atom1, "name", "x", null, null); f.add(add, "addOperands", atom1, null, null); failsWith(add); // two operands VALID EObject atom2 = f.create(ComplexrewritetestPackage.Literals.ATOM); f.set(atom2, "name", "x", null, null); f.add(add, "addOperands", atom2, null, null); assertNotNull(serialize(add)); // three operands INVALID EObject atom3 = f.create(ComplexrewritetestPackage.Literals.ATOM); f.set(atom3, "name", "x", null, null); f.add(add, "addOperands", atom3, null, null); failsWith(add); }
@Override public Class<? extends IAstFactory> bindIAstFactory() { return CustomDefaultEcoreElementFactory.class; }
protected IAstFactory getASTFactory() { return getInjector().getInstance(IAstFactory.class); }
public void setFactory(IAstFactory factory) { this.factory = factory; }
public IAstFactory getFactory() { return factory; }
public IAstFactory getElementFactory() { return elementFactory; }
public void setElementFactory(IAstFactory elementFactory) { this.elementFactory = elementFactory; }
public void setSemanticModelBuilder(IAstFactory semanticModelBuilder) { this.semanticModelBuilder = semanticModelBuilder; }
public IAstFactory getSemanticModelBuilder() { return semanticModelBuilder; }
@Test public void testFail1() throws Exception { IAstFactory f = getASTFactory(); failsWith(f.create(ComplexrewritetestPackage.Literals.ADD)); }
/** * customized AST element factory, that sets the PropertyAssignment kind depending if the element is a * name-value-pair, a getter or setter and the feature is a name. * * @return Class<{@link PropertyNameAwareElementFactory}> */ @Override public Class<? extends IAstFactory> bindIAstFactory() { return PropertyNameAwareElementFactory.class; }