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

项目:xtext-extras    文件:LiteralsCompiler.java   
@Override
protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) {
    if (obj instanceof XStringLiteral) {
        _toJavaExpression((XStringLiteral) obj, appendable);
    } else if (obj instanceof XNumberLiteral) {
        _toJavaExpression((XNumberLiteral) obj, appendable);
    } else if (obj instanceof XNullLiteral) {
        _toJavaExpression((XNullLiteral) obj, appendable);
    } else if (obj instanceof XBooleanLiteral) {
        _toJavaExpression((XBooleanLiteral) obj, appendable);
    } else if (obj instanceof XTypeLiteral) {
        _toJavaExpression((XTypeLiteral) obj, appendable);
    } else {
        super.internalToConvertedExpression(obj, appendable);
    }
}
项目:xtext-extras    文件:LiteralsCompiler.java   
@Override
protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) {
    if (obj instanceof XStringLiteral) {
        _toJavaStatement((XStringLiteral) obj, appendable, isReferenced);
    } else if (obj instanceof XNumberLiteral) {
        _toJavaStatement((XNumberLiteral) obj, appendable, isReferenced);
    } else if (obj instanceof XNullLiteral) {
        _toJavaStatement((XNullLiteral) obj, appendable, isReferenced);
    } else if (obj instanceof XBooleanLiteral) {
        _toJavaStatement((XBooleanLiteral) obj, appendable, isReferenced);
    } else if (obj instanceof XTypeLiteral) {
        _toJavaStatement((XTypeLiteral) obj, appendable, isReferenced);
    } else {
        super.doInternalToJavaStatement(obj, appendable, isReferenced);
    }
}
项目:xtext-extras    文件:XbaseCompiler.java   
protected void appendImmutableCollectionExpression(XCollectionLiteral literal,
        ITreeAppendable b, String collectionsMethod, Class<?> guavaHelper, String guavaHelperMethod) {
    LightweightTypeReference collectionElementType = getCollectionElementType(literal);
    b.append(Collections.class);
    b.append(".<").append(collectionElementType).append(">").append(collectionsMethod).append("(");
    b.append(guavaHelper).append(".<").append(collectionElementType).append(">").append(guavaHelperMethod).append("(");
    boolean isFirst = true;
    for(XExpression element: literal.getElements())  {
        if(!isFirst)
            b.append(", ");
        isFirst = false;
        if(element instanceof XNullLiteral) {
            b.append("(").append(collectionElementType).append(")");
        }
        internalToJavaExpression(element, b);
    }
    b.append("))");
    return;
}
项目:xtext-extras    文件:TypeComputationStateTest.java   
@Test
public void testChildrenAddEntryForParent() {
  try {
    this.resolver.setTypeComputer(this);
    final XExpression expression = this.expression("{ null }");
    this.resolver.initializeFrom(expression);
    final PublicResolvedTypes resolution = new PublicResolvedTypes(this.resolver);
    final AnyTypeReference any = resolution.getReferenceOwner().newAnyTypeReference();
    IFeatureScopeSession _newSession = this.resolver.getBatchScopeProvider().newSession(expression.eResource());
    new ExpressionBasedRootTypeComputationState(resolution, _newSession, expression, any).computeTypes();
    Assert.assertEquals(any.toString(), resolution.getActualType(expression).toString());
    EObject _head = IterableExtensions.<EObject>head(expression.eContents());
    Assert.assertEquals(any.toString(), resolution.getActualType(((XNullLiteral) _head)).toString());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-extras    文件:XExpressionHelper.java   
/**
 * @return whether the expression itself (not its children) possibly causes a side-effect
 */
public boolean hasSideEffects(XExpression expr) {
    if (expr instanceof XClosure
        || expr instanceof XStringLiteral
        || expr instanceof XTypeLiteral
        || expr instanceof XBooleanLiteral
        || expr instanceof XNumberLiteral
        || expr instanceof XNullLiteral
        || expr instanceof XAnnotation
        )
        return false;
    if(expr instanceof XCollectionLiteral) {
        for(XExpression element: ((XCollectionLiteral)expr).getElements()) {
            if(hasSideEffects(element))
                return true;
        }
        return false;
    }
    if (expr instanceof XAbstractFeatureCall) {
        XAbstractFeatureCall featureCall = (XAbstractFeatureCall) expr;
        return hasSideEffects(featureCall, true);
    }
    if (expr instanceof XConstructorCall) {
        XConstructorCall constrCall = (XConstructorCall) expr;
        return findPureAnnotation(constrCall.getConstructor()) == null;
    }
    return true;
}
项目:xtext-extras    文件:LiteralsCompiler.java   
@Override
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) {
    if (expr instanceof XBooleanLiteral
        || expr instanceof XStringLiteral
        || expr instanceof XNumberLiteral
        || expr instanceof XTypeLiteral
        || expr instanceof XClosure
        || expr instanceof XNullLiteral)
        return false;
    return super.isVariableDeclarationRequired(expr,b, recursive);
}
项目:xtext-extras    文件:ConstantConditionsInterpreter.java   
public EvaluationResult internalEvaluate(final XExpression it, final EvaluationContext context) {
  if (it instanceof XBinaryOperation) {
    return _internalEvaluate((XBinaryOperation)it, context);
  } else if (it instanceof XUnaryOperation) {
    return _internalEvaluate((XUnaryOperation)it, context);
  } else if (it instanceof XAbstractFeatureCall) {
    return _internalEvaluate((XAbstractFeatureCall)it, context);
  } else if (it instanceof XBooleanLiteral) {
    return _internalEvaluate((XBooleanLiteral)it, context);
  } else if (it instanceof XCastedExpression) {
    return _internalEvaluate((XCastedExpression)it, context);
  } else if (it instanceof XNullLiteral) {
    return _internalEvaluate((XNullLiteral)it, context);
  } else if (it instanceof XNumberLiteral) {
    return _internalEvaluate((XNumberLiteral)it, context);
  } else if (it instanceof XStringLiteral) {
    return _internalEvaluate((XStringLiteral)it, context);
  } else if (it instanceof XTypeLiteral) {
    return _internalEvaluate((XTypeLiteral)it, context);
  } else if (it != null) {
    return _internalEvaluate(it, context);
  } else if (it == null) {
    return _internalEvaluate((Void)null, context);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, context).toString());
  }
}
项目:xtext-extras    文件:TypeComputationStateTest.java   
@Override
public void computeTypes(final XExpression expression, final ITypeComputationState state) {
  try {
    Assert.assertTrue("state is instanceof ExpressionTypeComputationState", (state instanceof ExpressionTypeComputationState));
    final LightweightTypeReference expectedType = IterableExtensions.head(state.getExpectations()).getExpectedType();
    if ((expression instanceof XNullLiteral)) {
      final ExpressionTypeComputationState casted = ((ExpressionTypeComputationState) state);
      final ResolvedTypes resolution = this._reflectExtensions.<ResolvedTypes>get(casted, "resolvedTypes");
      final ResolvedTypes parentResolution = this._reflectExtensions.<ResolvedTypes>get(this._reflectExtensions.<ExpressionTypeComputationState>get(casted, "parent"), "resolvedTypes");
      EObject _eContainer = ((XNullLiteral)expression).eContainer();
      Assert.assertNull(parentResolution.getActualType(((XExpression) _eContainer)));
      state.acceptActualType(expectedType);
      Assert.assertNull(parentResolution.getActualType(expression));
      Assert.assertEquals(expectedType.getIdentifier(), resolution.getActualType(expression).getIdentifier());
      EObject _eContainer_1 = ((XNullLiteral)expression).eContainer();
      Assert.assertNull(parentResolution.getActualType(((XExpression) _eContainer_1)));
    } else {
      Assert.assertTrue((expression instanceof XBlockExpression));
      EObject _head = IterableExtensions.<EObject>head(expression.eContents());
      final XNullLiteral nullLiteral = ((XNullLiteral) _head);
      state.computeTypes(nullLiteral);
      final ResolvedTypes resolution_1 = this._reflectExtensions.<ResolvedTypes>get(state, "resolvedTypes");
      Assert.assertEquals(expectedType.getIdentifier(), resolution_1.getActualType(nullLiteral).getIdentifier());
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目: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    文件:AbstractXbaseSemanticSequencer.java   
@Deprecated
protected void sequence_XNullLiteral(EObject context, XNullLiteral semanticObject) {
    sequence_XNullLiteral(createContext(context, semanticObject), semanticObject);
}
项目:xtext-extras    文件:XbaseTypeComputer.java   
@Override
public void computeTypes(XExpression expression, ITypeComputationState state) {
    if (expression instanceof XAssignment) {
        _computeTypes((XAssignment)expression, state);
    } else if (expression instanceof XAbstractFeatureCall) {
        _computeTypes((XAbstractFeatureCall)expression, state);
    } else if (expression instanceof XDoWhileExpression) {
        _computeTypes((XDoWhileExpression)expression, state);
    } else if (expression instanceof XWhileExpression) {
        _computeTypes((XWhileExpression)expression, state);
    } else if (expression instanceof XBlockExpression) {
        _computeTypes((XBlockExpression)expression, state);
    } else if (expression instanceof XBooleanLiteral) {
        _computeTypes((XBooleanLiteral)expression, state);
    } else if (expression instanceof XCastedExpression) {
        _computeTypes((XCastedExpression)expression, state);
    } else if (expression instanceof XClosure) {
        _computeTypes((XClosure)expression, state);
    } else if (expression instanceof XConstructorCall) {
        _computeTypes((XConstructorCall)expression, state);
    } else if (expression instanceof XForLoopExpression) {
        _computeTypes((XForLoopExpression)expression, state);
    } else if (expression instanceof XBasicForLoopExpression) {
        _computeTypes((XBasicForLoopExpression)expression, state);
    } else if (expression instanceof XIfExpression) {
        _computeTypes((XIfExpression)expression, state);
    } else if (expression instanceof XInstanceOfExpression) {
        _computeTypes((XInstanceOfExpression)expression, state);
    } else if (expression instanceof XNumberLiteral) {
        _computeTypes((XNumberLiteral)expression, state);
    } else if (expression instanceof XNullLiteral) {
        _computeTypes((XNullLiteral)expression, state);
    } else if (expression instanceof XReturnExpression) {
        _computeTypes((XReturnExpression)expression, state);
    } else if (expression instanceof XStringLiteral) {
        _computeTypes((XStringLiteral)expression, state);
    } else if (expression instanceof XSwitchExpression) {
        _computeTypes((XSwitchExpression)expression, state);
    } else if (expression instanceof XThrowExpression) {
        _computeTypes((XThrowExpression)expression, state);
    } else if (expression instanceof XTryCatchFinallyExpression) {
        _computeTypes((XTryCatchFinallyExpression)expression, state);
    } else if (expression instanceof XTypeLiteral) {
        _computeTypes((XTypeLiteral)expression, state);
    } else if (expression instanceof XVariableDeclaration) {
        _computeTypes((XVariableDeclaration)expression, state);
    } else if (expression instanceof XListLiteral) {
        _computeTypes((XListLiteral)expression, state);
    } else if (expression instanceof XSetLiteral) {
        _computeTypes((XSetLiteral)expression, state);
    } else if (expression instanceof XSynchronizedExpression) {
        _computeTypes((XSynchronizedExpression)expression, state);
    } else {
        throw new UnsupportedOperationException("Missing type computation for expression type: " + expression.eClass().getName() + " / " + state);
    }
}
项目:xtext-extras    文件:XbaseTypeComputer.java   
/**
 * @param object used for dispatching
 */
protected void _computeTypes(XNullLiteral object, ITypeComputationState state) {
    state.acceptActualType(state.getReferenceOwner().newAnyTypeReference());
}
项目:xtext-extras    文件:XbaseSemanticSequencer.java   
/**
 * This is for backwards compatibility < 2.3RC2 due to change in the naming strategy for sequencer methods
 */
@Deprecated
protected void sequence_XExpression(EObject context, XNullLiteral semanticObject) {
    super.sequence_XNullLiteral(context, semanticObject);
}
项目:xtext-extras    文件:LiteralsCompiler.java   
/**
 * @param expr the expression. Used by the dispatch strategy.
 */
public void _toJavaExpression(XNullLiteral expr, ITreeAppendable b) {
    b.append("null");
}
项目:xtext-extras    文件:LiteralsCompiler.java   
public void _toJavaStatement(XNullLiteral expr, ITreeAppendable b, boolean isReferenced) {
    generateComment(expr, b, isReferenced);
}
项目:xtext-extras    文件:XbaseInterpreter.java   
/**
 * don't call this directly. Always call evaluate() internalEvaluate()
 */
protected Object doEvaluate(XExpression expression, IEvaluationContext context, CancelIndicator indicator) {
    if (expression instanceof XAssignment) {
      return _doEvaluate((XAssignment)expression, context, indicator);
    } else if (expression instanceof XDoWhileExpression) {
      return _doEvaluate((XDoWhileExpression)expression, context, indicator);
    } else if (expression instanceof XMemberFeatureCall) {
      return _doEvaluate((XMemberFeatureCall)expression, context, indicator);
    } else if (expression instanceof XWhileExpression) {
      return _doEvaluate((XWhileExpression)expression, context, indicator);
    } else if (expression instanceof XFeatureCall) {
        return _doEvaluate((XFeatureCall)expression, context, indicator);
    } else if (expression instanceof XAbstractFeatureCall) {
        return _doEvaluate((XAbstractFeatureCall)expression, context, indicator);
    } else if (expression instanceof XBlockExpression) {
      return _doEvaluate((XBlockExpression)expression, context, indicator);
    } else if (expression instanceof XSynchronizedExpression) {
      return _doEvaluate((XSynchronizedExpression)expression, context, indicator);
    } else if (expression instanceof XBooleanLiteral) {
      return _doEvaluate((XBooleanLiteral)expression, context, indicator);
    } else if (expression instanceof XCastedExpression) {
      return _doEvaluate((XCastedExpression)expression, context, indicator);
    } else if (expression instanceof XClosure) {
      return _doEvaluate((XClosure)expression, context, indicator);
    } else if (expression instanceof XConstructorCall) {
      return _doEvaluate((XConstructorCall)expression, context, indicator);
    } else if (expression instanceof XForLoopExpression) {
      return _doEvaluate((XForLoopExpression)expression, context, indicator);
    } else if (expression instanceof XBasicForLoopExpression) {
      return _doEvaluate((XBasicForLoopExpression)expression, context, indicator);
    } else if (expression instanceof XIfExpression) {
      return _doEvaluate((XIfExpression)expression, context, indicator);
    } else if (expression instanceof XInstanceOfExpression) {
      return _doEvaluate((XInstanceOfExpression)expression, context, indicator);
    } else if (expression instanceof XNullLiteral) {
      return _doEvaluate((XNullLiteral)expression, context, indicator);
    } else if (expression instanceof XNumberLiteral) {
      return _doEvaluate((XNumberLiteral)expression, context, indicator);
    } else if (expression instanceof XReturnExpression) {
      return _doEvaluate((XReturnExpression)expression, context, indicator);
    } else if (expression instanceof XStringLiteral) {
      return _doEvaluate((XStringLiteral)expression, context, indicator);
    } else if (expression instanceof XSwitchExpression) {
      return _doEvaluate((XSwitchExpression)expression, context, indicator);
    } else if (expression instanceof XThrowExpression) {
      return _doEvaluate((XThrowExpression)expression, context, indicator);
    } else if (expression instanceof XTryCatchFinallyExpression) {
      return _doEvaluate((XTryCatchFinallyExpression)expression, context, indicator);
    } else if (expression instanceof XTypeLiteral) {
      return _doEvaluate((XTypeLiteral)expression, context, indicator);
    } else if (expression instanceof XVariableDeclaration) {
          return _doEvaluate((XVariableDeclaration)expression, context, indicator);
    } else if (expression instanceof XListLiteral) {
          return _doEvaluate((XListLiteral)expression, context, indicator);
    } else if (expression instanceof XSetLiteral) {
          return _doEvaluate((XSetLiteral)expression, context, indicator);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.<Object>asList(expression, context, indicator).toString());
    }
}
项目:xtext-extras    文件:XbaseImplicitReturnFinder.java   
protected void _findImplicitReturns(final XNullLiteral expression, final ImplicitReturnFinder.Acceptor acceptor) {
  acceptor.accept(expression);
}
项目:xtext-extras    文件:XbaseImplicitReturnFinder.java   
public void findImplicitReturns(final XExpression expression, final ImplicitReturnFinder.Acceptor acceptor) {
  if (expression instanceof XAbstractFeatureCall) {
    _findImplicitReturns((XAbstractFeatureCall)expression, acceptor);
    return;
  } else if (expression instanceof XBlockExpression) {
    _findImplicitReturns((XBlockExpression)expression, acceptor);
    return;
  } else if (expression instanceof XBooleanLiteral) {
    _findImplicitReturns((XBooleanLiteral)expression, acceptor);
    return;
  } else if (expression instanceof XCastedExpression) {
    _findImplicitReturns((XCastedExpression)expression, acceptor);
    return;
  } else if (expression instanceof XClosure) {
    _findImplicitReturns((XClosure)expression, acceptor);
    return;
  } else if (expression instanceof XCollectionLiteral) {
    _findImplicitReturns((XCollectionLiteral)expression, acceptor);
    return;
  } else if (expression instanceof XConstructorCall) {
    _findImplicitReturns((XConstructorCall)expression, acceptor);
    return;
  } else if (expression instanceof XIfExpression) {
    _findImplicitReturns((XIfExpression)expression, acceptor);
    return;
  } else if (expression instanceof XInstanceOfExpression) {
    _findImplicitReturns((XInstanceOfExpression)expression, acceptor);
    return;
  } else if (expression instanceof XNullLiteral) {
    _findImplicitReturns((XNullLiteral)expression, acceptor);
    return;
  } else if (expression instanceof XNumberLiteral) {
    _findImplicitReturns((XNumberLiteral)expression, acceptor);
    return;
  } else if (expression instanceof XStringLiteral) {
    _findImplicitReturns((XStringLiteral)expression, acceptor);
    return;
  } else if (expression instanceof XSwitchExpression) {
    _findImplicitReturns((XSwitchExpression)expression, acceptor);
    return;
  } else if (expression instanceof XSynchronizedExpression) {
    _findImplicitReturns((XSynchronizedExpression)expression, acceptor);
    return;
  } else if (expression instanceof XTryCatchFinallyExpression) {
    _findImplicitReturns((XTryCatchFinallyExpression)expression, acceptor);
    return;
  } else if (expression instanceof XTypeLiteral) {
    _findImplicitReturns((XTypeLiteral)expression, acceptor);
    return;
  } else if (expression != null) {
    _findImplicitReturns(expression, acceptor);
    return;
  } else if (expression == null) {
    _findImplicitReturns((Void)null, acceptor);
    return;
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(expression, acceptor).toString());
  }
}
项目:xtext-extras    文件:ConstantConditionsInterpreter.java   
protected EvaluationResult _internalEvaluate(final XNullLiteral it, final EvaluationContext context) {
  return new EvaluationResult(null, true);
}
项目:xtext-extras    文件:AbstractXbaseSemanticSequencer.java   
/**
 * Contexts:
 *     XExpression returns XNullLiteral
 *     XAssignment returns XNullLiteral
 *     XAssignment.XBinaryOperation_1_1_0_0_0 returns XNullLiteral
 *     XOrExpression returns XNullLiteral
 *     XOrExpression.XBinaryOperation_1_0_0_0 returns XNullLiteral
 *     XAndExpression returns XNullLiteral
 *     XAndExpression.XBinaryOperation_1_0_0_0 returns XNullLiteral
 *     XEqualityExpression returns XNullLiteral
 *     XEqualityExpression.XBinaryOperation_1_0_0_0 returns XNullLiteral
 *     XRelationalExpression returns XNullLiteral
 *     XRelationalExpression.XInstanceOfExpression_1_0_0_0_0 returns XNullLiteral
 *     XRelationalExpression.XBinaryOperation_1_1_0_0_0 returns XNullLiteral
 *     XOtherOperatorExpression returns XNullLiteral
 *     XOtherOperatorExpression.XBinaryOperation_1_0_0_0 returns XNullLiteral
 *     XAdditiveExpression returns XNullLiteral
 *     XAdditiveExpression.XBinaryOperation_1_0_0_0 returns XNullLiteral
 *     XMultiplicativeExpression returns XNullLiteral
 *     XMultiplicativeExpression.XBinaryOperation_1_0_0_0 returns XNullLiteral
 *     XUnaryOperation returns XNullLiteral
 *     XCastedExpression returns XNullLiteral
 *     XCastedExpression.XCastedExpression_1_0_0_0 returns XNullLiteral
 *     XPostfixOperation returns XNullLiteral
 *     XPostfixOperation.XPostfixOperation_1_0_0 returns XNullLiteral
 *     XMemberFeatureCall returns XNullLiteral
 *     XMemberFeatureCall.XAssignment_1_0_0_0_0 returns XNullLiteral
 *     XMemberFeatureCall.XMemberFeatureCall_1_1_0_0_0 returns XNullLiteral
 *     XPrimaryExpression returns XNullLiteral
 *     XLiteral returns XNullLiteral
 *     XParenthesizedExpression returns XNullLiteral
 *     XExpressionOrVarDeclaration returns XNullLiteral
 *     XNullLiteral returns XNullLiteral
 *
 * Constraint:
 *     {XNullLiteral}
 */
protected void sequence_XNullLiteral(ISerializationContext context, XNullLiteral semanticObject) {
    genericSequencer.createSequence(context, semanticObject);
}
项目:xtext-extras    文件:XbaseInterpreter.java   
/**
 * @param literal unused in this context but required for dispatching 
 * @param context unused in this context but required for dispatching
 * @param indicator unused in this context but required for dispatching
 */
protected Object _doEvaluate(XNullLiteral literal, IEvaluationContext context, CancelIndicator indicator) {
    return null;
}
项目:dsl-devkit    文件:AbstractCheckSemanticSequencer.java   
/**
 * Constraint:
 *     {XNullLiteral}
 */
protected void sequence_XNullLiteral(EObject context, XNullLiteral semanticObject) {
    genericSequencer.createSequence(context, semanticObject);
}
项目:dsl-devkit    文件:AbstractCheckCfgSemanticSequencer.java   
/**
 * Constraint:
 *     {XNullLiteral}
 */
protected void sequence_XNullLiteral(EObject context, XNullLiteral semanticObject) {
    genericSequencer.createSequence(context, semanticObject);
}