Java 类org.eclipse.xtext.xbase.XbaseFactory 实例源码

项目:xtext-extras    文件:SerializerTest.java   
@Test public void testSerialize_01() throws Exception {
    Resource resource = newResource("'foo' as String");
    XCastedExpression casted = (XCastedExpression) resource.getContents().get(0);

    XbaseFactory factory = XbaseFactory.eINSTANCE;
    XClosure closure = factory.createXClosure();
    XStringLiteral stringLiteral = factory.createXStringLiteral();
    stringLiteral.setValue("value");
    XBlockExpression blockExpression = factory.createXBlockExpression();
    blockExpression.getExpressions().add(stringLiteral);
    closure.setExpression(blockExpression);
    closure.setExplicitSyntax(true);
    XInstanceOfExpression instanceOfExpression = factory.createXInstanceOfExpression();
    instanceOfExpression.setExpression(closure);
    instanceOfExpression.setType(EcoreUtil.copy(casted.getType()));
    resource.getContents().clear();
    resource.getContents().add(instanceOfExpression);
    ISerializer serializer = get(ISerializer.class);
    String string = serializer.serialize(instanceOfExpression);
    assertEquals("[|\"value\"] instanceof String", string);

    XInstanceOfExpression parsedExpression = parseHelper.parse(string);
    assertTrue(EcoreUtil.equals(instanceOfExpression, parsedExpression));
}
项目:xtext-extras    文件:SerializerTest.java   
@Test public void testSerialize_02() throws Exception {
    Resource resource = newResource("'foo' as String");
    XCastedExpression casted = (XCastedExpression) resource.getContents().get(0);

    XbaseFactory factory = XbaseFactory.eINSTANCE;
    XIfExpression ifExpression = factory.createXIfExpression();
    ifExpression.setIf(factory.createXBooleanLiteral());
    XStringLiteral stringLiteral = factory.createXStringLiteral();
    stringLiteral.setValue("value");
    ifExpression.setThen(stringLiteral);
    XInstanceOfExpression instanceOfExpression = factory.createXInstanceOfExpression();
    instanceOfExpression.setExpression(ifExpression);
    instanceOfExpression.setType(EcoreUtil.copy(casted.getType()));
    resource.getContents().clear();
    resource.getContents().add(instanceOfExpression);
    ISerializer serializer = get(ISerializer.class);
    String string = serializer.serialize(instanceOfExpression);
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=464846
    assertEquals("( if(false) \"value\" ) instanceof String", string);

    XInstanceOfExpression parsedExpression = parseHelper.parse(string);
    assertTrue(EcoreUtil.equals(instanceOfExpression, parsedExpression));
}
项目:xtext-extras    文件:StaticFeatureDescriptionWithImplicitReceiver.java   
public StaticFeatureDescriptionWithImplicitReceiver(QualifiedName qualifiedName, JvmFeature feature, 
        LightweightTypeReference receiverType,
        int bucketId, boolean visible) {
    super(qualifiedName, feature, bucketId, visible);
    this.implicitReceiverType = receiverType;
    this.implicitReceiver = XbaseFactory.eINSTANCE.createXFeatureCall();
}
项目:xtext-extras    文件:AbstractBatchTypeResolverTest.java   
@Test
public void testProxy() throws Exception {
  final XFeatureCall proxy = XbaseFactory.eINSTANCE.createXFeatureCall();
  ((InternalEObject) proxy).eSetProxyURI(URI.createURI("path#fragment"));
  final IResolvedTypes typeResolution = this.getTypeResolver().resolveTypes(proxy);
  Assert.assertNotNull(typeResolution);
  Assert.assertEquals(IResolvedTypes.NULL, typeResolution);
}
项目:xtext-extras    文件:AbstractBatchReturnTypeTest.java   
@Test
public void testProxy() throws Exception {
  final XFeatureCall proxy = XbaseFactory.eINSTANCE.createXFeatureCall();
  ((InternalEObject) proxy).eSetProxyURI(URI.createURI("path#fragment"));
  final IResolvedTypes typeResolution = this.getTypeResolver().resolveTypes(proxy);
  Assert.assertNotNull(typeResolution);
  Assert.assertEquals(IResolvedTypes.NULL, typeResolution);
}
项目:xtext-extras    文件:JvmTypesBuilderTest.java   
protected <T extends Object> void genericTestInitializeSafely(final Function3<? super EObject, ? super String, ? super Procedure1<? super T>, ? extends EObject> create) {
  final XNullLiteral expr = XbaseFactory.eINSTANCE.createXNullLiteral();
  final Wrapper<Boolean> initialized = new Wrapper<Boolean>(Boolean.valueOf(false));
  final Procedure1<T> _function = (T it) -> {
    initialized.set(Boolean.valueOf(true));
    throw new RuntimeException();
  };
  final EObject element = create.apply(expr, "foo", _function);
  Assert.assertTrue((initialized.get()).booleanValue());
  Assert.assertNotNull(element);
}
项目:xtext-extras    文件:DefaultReentrantTypeResolver.java   
protected XbaseFactory getXbaseFactory() {
    return xbaseFactory;
}
项目:xtext-extras    文件:FeatureScopes.java   
protected XbaseFactory getXbaseFactory() {
    return xbaseFactory;
}
项目:xtext-extras    文件:ClosureTypeComputerUnitTest.java   
protected UnboundTypeReference createUnboundTypeReference(JvmTypeParameter type) {
    PublicResolvedTypes resolvedTypes = getResolvedTypes();
    return resolvedTypes.createUnboundTypeReference(XbaseFactory.eINSTANCE.createXNullLiteral(), type);
}
项目:xtext-extras    文件:XbaseTypeProviderTest.java   
@Test public void testProxy() throws Exception {
    XFeatureCall proxy = XbaseFactory.eINSTANCE.createXFeatureCall();
    ((InternalEObject) proxy).eSetProxyURI(URI.createURI("path#fragment"));
    assertNull(getType(proxy));
}
项目:xtext-extras    文件:XbasePackageImpl.java   
/**
 * Creates an instance of the model <b>Package</b>, registered with
 * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
 * package URI value.
 * <p>Note: the correct way to create the package is via the static
 * factory method {@link #init init()}, which also performs
 * initialization of the package, or returns the registered package,
 * if one already exists.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see org.eclipse.emf.ecore.EPackage.Registry
 * @see org.eclipse.xtext.xbase.XbasePackage#eNS_URI
 * @see #init()
 * @generated
 */
private XbasePackageImpl()
{
    super(eNS_URI, XbaseFactory.eINSTANCE);
}
项目:xtext-extras    文件:XbasePackageImpl.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public XbaseFactory getXbaseFactory()
{
    return (XbaseFactory)getEFactoryInstance();
}