当前位置: 首页>>代码示例>>Java>>正文


Java XUnaryOperation类代码示例

本文整理汇总了Java中org.eclipse.xtext.xbase.XUnaryOperation的典型用法代码示例。如果您正苦于以下问题:Java XUnaryOperation类的具体用法?Java XUnaryOperation怎么用?Java XUnaryOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XUnaryOperation类属于org.eclipse.xtext.xbase包,在下文中一共展示了XUnaryOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSyntacticReceiver

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
public XExpression getSyntacticReceiver(XExpression expression) {
	if (expression instanceof XAbstractFeatureCall) {
		if (expression instanceof XFeatureCall) {
			return null;
		}
		if (expression instanceof XMemberFeatureCall) {
			return ((XMemberFeatureCall) expression).getMemberCallTarget();
		}
		if (expression instanceof XAssignment) {
			return ((XAssignment) expression).getAssignable();
		}
		if (expression instanceof XBinaryOperation) {
			return ((XBinaryOperation) expression).getLeftOperand();
		}
		if (expression instanceof XUnaryOperation) {
			return ((XUnaryOperation) expression).getOperand();
		}
		if (expression instanceof XPostfixOperation) {
			return ((XPostfixOperation) expression).getOperand();
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:FeatureLinkHelper.java

示例2: getSyntacticArguments

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
public List<XExpression> getSyntacticArguments(XAbstractFeatureCall expression) {
	if (expression instanceof XFeatureCall) {
		return ((XFeatureCall) expression).getFeatureCallArguments();
	}
	if (expression instanceof XMemberFeatureCall) {
		return ((XMemberFeatureCall) expression).getMemberCallArguments();
	}
	if (expression instanceof XAssignment) {
		return Collections.singletonList(((XAssignment) expression).getValue());
	}
	if (expression instanceof XBinaryOperation) {
		return Collections.singletonList(((XBinaryOperation) expression).getRightOperand());
	}
	// explicit condition to make sure we thought about it
	if (expression instanceof XUnaryOperation) {
		return Collections.emptyList();
	}
	if (expression instanceof XPostfixOperation) {
		return Collections.emptyList();
	}
	return Collections.emptyList();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:FeatureLinkHelper.java

示例3: internalEvaluate

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
public Object internalEvaluate(final XExpression it, final Context ctx) {
  if (it instanceof XBinaryOperation) {
    return _internalEvaluate((XBinaryOperation)it, ctx);
  } else if (it instanceof XUnaryOperation) {
    return _internalEvaluate((XUnaryOperation)it, ctx);
  } else if (it instanceof XBooleanLiteral) {
    return _internalEvaluate((XBooleanLiteral)it, ctx);
  } else if (it instanceof XCastedExpression) {
    return _internalEvaluate((XCastedExpression)it, ctx);
  } else if (it instanceof XStringLiteral) {
    return _internalEvaluate((XStringLiteral)it, ctx);
  } else if (it instanceof XTypeLiteral) {
    return _internalEvaluate((XTypeLiteral)it, ctx);
  } else if (it instanceof XAnnotation) {
    return _internalEvaluate((XAnnotation)it, ctx);
  } else if (it != null) {
    return _internalEvaluate(it, ctx);
  } else if (it == null) {
    return _internalEvaluate((Void)null, ctx);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, ctx).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:AbstractConstantExpressionsInterpreter.java

示例4: checkRightHandSideHasOnlyIntegralNumbers

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
/**
 * Validates that all XNumberLiterals in this expression, which occurs on the right-hand side of a formal parameter
 * declaration/definition, have indeed integral values.
 * 
 * @param value
 *          to check
 * @param issueCode
 *          to issue if the validation fails
 */
protected void checkRightHandSideHasOnlyIntegralNumbers(final XExpression value, final String issueCode) {
  if (value != null) {
    List<XExpression> exprs = (value instanceof XListLiteral) ? ((XListLiteral) value).getElements() : Collections.singletonList(value);
    for (XExpression expr : exprs) {
      XExpression e = expr;
      while (e instanceof XUnaryOperation) {
        e = ((XUnaryOperation) e).getOperand();
      }
      if (e instanceof XNumberLiteral) {
        try {
          Integer.decode(((XNumberLiteral) e).getValue());
        } catch (NumberFormatException ex) {
          error("Only integral values as numbers are allowed in check parameters", expr, null, issueCode); // TODO: NLS
        }
      }
    }
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:28,代码来源:FormalParameterCheckBase.java

示例5: getSyntaxDescriptions

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
@Override
protected String getSyntaxDescriptions() {
	XExpression expression = getExpression();
	if (expression instanceof XBinaryOperation) {
		return "binary operation";
	} else if (expression instanceof XUnaryOperation) {
		return "unary operation";
	} else if (expression instanceof XPostfixOperation) {
		return "postfix operation";
	} else {
		return "feature call";
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:AmbiguousFeatureLinkingCandidate.java

示例6: startsWithUnaryOperator

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
protected boolean startsWithUnaryOperator(EObject obj) {
	if(obj instanceof XUnaryOperation)
		return true;
	if(obj instanceof XBinaryOperation)
		return startsWithUnaryOperator(((XBinaryOperation)obj).getLeftOperand());
	if(obj instanceof XPostfixOperation) {
		return startsWithUnaryOperator(((XPostfixOperation)obj).getOperand());
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseSyntacticSequencer.java

示例7: internalEvaluate

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
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());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:ConstantConditionsInterpreter.java

示例8: internalEvaluate

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
public Object internalEvaluate(final XExpression it, final Context ctx) {
  if (it instanceof XBinaryOperation) {
    return _internalEvaluate((XBinaryOperation)it, ctx);
  } else if (it instanceof XUnaryOperation) {
    return _internalEvaluate((XUnaryOperation)it, ctx);
  } else if (it instanceof XAbstractFeatureCall) {
    return _internalEvaluate((XAbstractFeatureCall)it, ctx);
  } else if (it instanceof XBooleanLiteral) {
    return _internalEvaluate((XBooleanLiteral)it, ctx);
  } else if (it instanceof XCastedExpression) {
    return _internalEvaluate((XCastedExpression)it, ctx);
  } else if (it instanceof XNumberLiteral) {
    return _internalEvaluate((XNumberLiteral)it, ctx);
  } else if (it instanceof XStringLiteral) {
    return _internalEvaluate((XStringLiteral)it, ctx);
  } else if (it instanceof XTypeLiteral) {
    return _internalEvaluate((XTypeLiteral)it, ctx);
  } else if (it instanceof XAnnotation) {
    return _internalEvaluate((XAnnotation)it, ctx);
  } else if (it != null) {
    return _internalEvaluate(it, ctx);
  } else if (it == null) {
    return _internalEvaluate((Void)null, ctx);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, ctx).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:SwitchConstantExpressionsInterpreter.java

示例9: _internalEvaluate

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
protected Object _internalEvaluate(final XUnaryOperation it, final Context ctx) {
  Object _xblockexpression = null;
  {
    final Object value = this.evaluate(it.getOperand(), ctx);
    final String op = this.getOperator(it);
    Object _switchResult = null;
    boolean _matched = false;
    if (Objects.equal(op, "-")) {
      _matched=true;
      _switchResult = this.constantOperators.minus(value);
    }
    if (!_matched) {
      if ((Objects.equal(op, "!") && (value instanceof Boolean))) {
        _matched=true;
        _switchResult = Boolean.valueOf((!(((Boolean) value)).booleanValue()));
      }
    }
    if (!_matched) {
      if ((Objects.equal(op, "+") && (value instanceof Number))) {
        _matched=true;
        _switchResult = value;
      }
    }
    if (!_matched) {
      throw new ConstantExpressionEvaluationException(((("Couldn\'t evaluate unary operator \'" + op) + "\' on value ") + value));
    }
    _xblockexpression = _switchResult;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:31,代码来源:AbstractConstantExpressionsInterpreter.java

示例10: testUnaryOperation_3

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
@Test public void testUnaryOperation_3() throws Exception {
	XBinaryOperation call = (XBinaryOperation) expression("foo+-bar");
	assertEquals("+",call.getConcreteSyntaxFeatureName());
	assertEquals(2,call.getExplicitArguments().size());
	XUnaryOperation unary = (XUnaryOperation) call.getExplicitArguments().get(1);
	assertEquals("-", unary.getConcreteSyntaxFeatureName());
	assertEquals("bar", ((XFeatureCall)unary.getExplicitArguments().get(0)).getConcreteSyntaxFeatureName());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:XbaseParserTest.java

示例11: sequence_XUnaryOperation

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
@Deprecated
protected void sequence_XUnaryOperation(EObject context, XUnaryOperation semanticObject) {
	sequence_XUnaryOperation(createContext(context, semanticObject), semanticObject);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:5,代码来源:AbstractXbaseSemanticSequencer.java

示例12: _internalEvaluate

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
protected EvaluationResult _internalEvaluate(final XUnaryOperation it, final EvaluationContext context) {
  EvaluationResult _xifexpression = null;
  boolean _isFromXbaseLibrary = this.isFromXbaseLibrary(it, context);
  if (_isFromXbaseLibrary) {
    EvaluationResult _xblockexpression = null;
    {
      final EvaluationResult arg = this.doEvaluate(it.getOperand(), context);
      final String op = it.getConcreteSyntaxFeatureName();
      EvaluationResult _switchResult = null;
      boolean _matched = false;
      if (Objects.equal(op, "-")) {
        _matched=true;
        try {
          final Object result = this.constantOperators.minus(arg.getRawValue());
          boolean _isCompileTimeConstant = arg.isCompileTimeConstant();
          return new EvaluationResult(result, _isCompileTimeConstant);
        } catch (final Throwable _t) {
          if (_t instanceof ConstantExpressionEvaluationException) {
            return EvaluationResult.NOT_A_CONSTANT;
          } else {
            throw Exceptions.sneakyThrow(_t);
          }
        }
      }
      if (!_matched) {
        if ((Objects.equal(op, "!") && (arg.getRawValue() instanceof Boolean))) {
          _matched=true;
          Object _rawValue = arg.getRawValue();
          boolean _not = (!(((Boolean) _rawValue)).booleanValue());
          boolean _isCompileTimeConstant_1 = arg.isCompileTimeConstant();
          _switchResult = new EvaluationResult(Boolean.valueOf(_not), _isCompileTimeConstant_1);
        }
      }
      if (!_matched) {
        if ((Objects.equal(op, "+") && (arg.getRawValue() instanceof Number))) {
          _matched=true;
          _switchResult = arg;
        }
      }
      if (!_matched) {
        _switchResult = EvaluationResult.NOT_A_CONSTANT;
      }
      _xblockexpression = _switchResult;
    }
    _xifexpression = _xblockexpression;
  } else {
    return EvaluationResult.NOT_A_CONSTANT;
  }
  return _xifexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:51,代码来源:ConstantConditionsInterpreter.java

示例13: testUnaryOperation

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
@Test public void testUnaryOperation() throws Exception {
	XUnaryOperation call = (XUnaryOperation) expression("-(Foo)");
	assertNotNull(call);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:5,代码来源:XbaseParserTest.java

示例14: testUnaryOperation_2

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
@Test public void testUnaryOperation_2() throws Exception {
	XUnaryOperation call = (XUnaryOperation) expression("-foo");
	assertNotNull(call);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:5,代码来源:XbaseParserTest.java

示例15: testUnaryOperation

import org.eclipse.xtext.xbase.XUnaryOperation; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test public void testUnaryOperation() throws Exception {
	assertEquals(1, ((XUnaryOperation) expression("- bar")).getExplicitArguments().size());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:5,代码来源:AbstractFeatureCallCustomImplTest.java


注:本文中的org.eclipse.xtext.xbase.XUnaryOperation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。