本文整理汇总了Java中org.eclipse.xtext.xbase.XStringLiteral类的典型用法代码示例。如果您正苦于以下问题:Java XStringLiteral类的具体用法?Java XStringLiteral怎么用?Java XStringLiteral使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XStringLiteral类属于org.eclipse.xtext.xbase包,在下文中一共展示了XStringLiteral类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: internalToConvertedExpression
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@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);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:LiteralsCompiler.java
示例2: doInternalToJavaStatement
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@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);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:LiteralsCompiler.java
示例3: isConstant
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
public boolean isConstant(final XExpression expression) {
if (expression instanceof XAbstractFeatureCall) {
return _isConstant((XAbstractFeatureCall)expression);
} else if (expression instanceof XBooleanLiteral) {
return _isConstant((XBooleanLiteral)expression);
} else if (expression instanceof XCastedExpression) {
return _isConstant((XCastedExpression)expression);
} else if (expression instanceof XNumberLiteral) {
return _isConstant((XNumberLiteral)expression);
} else if (expression instanceof XStringLiteral) {
return _isConstant((XStringLiteral)expression);
} else if (expression instanceof XTypeLiteral) {
return _isConstant((XTypeLiteral)expression);
} else if (expression != null) {
return _isConstant(expression);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(expression).toString());
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:ConstantExpressionValidator.java
示例4: internalEvaluate
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的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
示例5: testSerialize_01
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@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));
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:SerializerTest.java
示例6: testSerialize_02
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@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));
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:SerializerTest.java
示例7: testStringAnnotation
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test
public void testStringAnnotation() {
try {
final XAnnotationsFactory f = XAnnotationsFactory.eINSTANCE;
final XExpression e = this.expression("\'Foo\'");
final XAnnotation anno = f.createXAnnotation();
JvmType _findDeclaredType = this.references.findDeclaredType(Inject.class, e);
anno.setAnnotationType(((JvmAnnotationType) _findDeclaredType));
anno.setValue(e);
final JvmGenericType type = this.typesFactory.createJvmGenericType();
this._jvmTypesBuilder.addAnnotation(type, anno);
Assert.assertEquals(anno.getAnnotationType(), IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getAnnotation());
JvmAnnotationValue _head = IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues());
EObject _head_1 = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue) _head).getValues());
Assert.assertTrue((_head_1 instanceof XStringLiteral));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:JvmTypesBuilderTest.java
示例8: testAnnotationDefaultValue
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test
public void testAnnotationDefaultValue() {
try {
final XAnnotationsFactory f = XAnnotationsFactory.eINSTANCE;
final XExpression e = this.expression("\'Foo\'");
final XAnnotation anno = f.createXAnnotation();
JvmType _findDeclaredType = this.references.findDeclaredType(Named.class, e);
anno.setAnnotationType(((JvmAnnotationType) _findDeclaredType));
anno.setValue(e);
final JvmGenericType type = this.typesFactory.createJvmGenericType();
this._jvmTypesBuilder.addAnnotation(type, anno);
Assert.assertEquals(anno.getAnnotationType(), IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getAnnotation());
JvmAnnotationValue _head = IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues());
EObject _head_1 = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue) _head).getValues());
Assert.assertTrue((_head_1 instanceof XStringLiteral));
Assert.assertNull(IterableExtensions.<JvmAnnotationValue>head(IterableExtensions.<JvmAnnotationReference>head(type.getAnnotations()).getValues()).getOperation());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:JvmTypesBuilderTest.java
示例9: hasSideEffects
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
/**
* @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;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:31,代码来源:XExpressionHelper.java
示例10: toJavaStatement
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
/**
* @since 2.4
*/
protected void toJavaStatement(final XStringLiteral expr, ITreeAppendable b, boolean isReferenced, final boolean useUnicodeEscapes) {
generateComment(new Later() {
@Override
public void exec(ITreeAppendable appendable) {
// we have to escape closing comments in string literals
String escapedClosingComments = expr.getValue().replace("*/", "* /");
String javaString = Strings.convertToJavaString(escapedClosingComments, useUnicodeEscapes);
appendable.append("\"").append(javaString).append("\"");
}
}, b, isReferenced);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:LiteralsCompiler.java
示例11: isVariableDeclarationRequired
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@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);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:LiteralsCompiler.java
示例12: _doEvaluate
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
/**
* @param context unused in this context but required for dispatching
* @param indicator unused in this context but required for dispatching
*/
protected Object _doEvaluate(XStringLiteral literal, IEvaluationContext context, CancelIndicator indicator) {
LightweightTypeReference type = typeResolver.resolveTypes(literal).getActualType(literal);
if (type != null && (type.isType(Character.TYPE) || type.isType(Character.class))) {
return literal.getValue().charAt(0);
}
return literal.getValue();
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:XbaseInterpreter.java
示例13: internalEvaluate
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的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
示例14: internalEvaluate
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的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
示例15: testClosure_2
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test public void testClosure_2() throws Exception {
XClosure closure = (XClosure) expression("[bar|'foo']");
assertEquals("foo", ((XStringLiteral) ((XBlockExpression)closure.getExpression()).getExpressions().get(0))
.getValue());
assertEquals("bar", closure.getFormalParameters().get(0).getName());
assertNull(closure.getFormalParameters().get(0).getParameterType());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseParserTest.java
示例16: testClosure_3
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test public void testClosure_3() throws Exception {
XClosure closure = (XClosure) expression("[String bar|'foo']");
assertEquals("foo", ((XStringLiteral) ((XBlockExpression)closure.getExpression()).getExpressions().get(0))
.getValue());
assertEquals("bar", closure.getFormalParameters().get(0).getName());
assertEquals(1, closure.getFormalParameters().size());
assertNotNull(closure.getFormalParameters().get(0).getParameterType());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:XbaseParserTest.java
示例17: testClosure_4
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test public void testClosure_4() throws Exception {
XClosure closure = (XClosure) expression("[foo, String bar|'foo']");
assertEquals("foo", ((XStringLiteral) ((XBlockExpression)closure.getExpression()).getExpressions().get(0))
.getValue());
assertEquals("foo", closure.getFormalParameters().get(0).getName());
assertEquals("bar", closure.getFormalParameters().get(1).getName());
assertEquals(2, closure.getFormalParameters().size());
assertNull(closure.getFormalParameters().get(0).getParameterType());
assertNotNull(closure.getFormalParameters().get(1).getParameterType());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseParserTest.java
示例18: testFeatureCall_3
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test public void testFeatureCall_3() throws Exception {
XMemberFeatureCall call = (XMemberFeatureCall) expression("'holla'.bar(4)");
assertNotNull(call);
assertEquals(2, call.getExplicitArguments().size());
assertEquals("4", ((XNumberLiteral) call.getExplicitArguments().get(1)).getValue());
assertTrue(call.getExplicitArguments().get(0) instanceof XStringLiteral);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseParserTest.java
示例19: testSwitch_0
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test public void testSwitch_0() throws Exception {
XSwitchExpression se = (XSwitchExpression) expression("switch true { case 1==0 : '1' }");
assertNull(se.getDefault());
assertEquals(1, se.getCases().size());
assertNotNull(se.getSwitch());
XCasePart casePart = se.getCases().get(0);
assertTrue(casePart.getCase() instanceof XBinaryOperation);
assertTrue(casePart.getThen() instanceof XStringLiteral);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:XbaseParserTest.java
示例20: testSwitch_1
import org.eclipse.xtext.xbase.XStringLiteral; //导入依赖的package包/类
@Test public void testSwitch_1() throws Exception {
XSwitchExpression se = (XSwitchExpression) expression("switch number{case 1:'1' case 2:'2' default:'3'}");
assertTrue(se.getDefault() instanceof XStringLiteral);
assertEquals(2, se.getCases().size());
assertTrue(se.getSwitch() instanceof XFeatureCall);
XCasePart case1 = se.getCases().get(0);
assertEquals("1", ((XNumberLiteral) case1.getCase()).getValue());
assertTrue(case1.getThen() instanceof XStringLiteral);
XCasePart case2 = se.getCases().get(1);
assertEquals("2", ((XNumberLiteral) case2.getCase()).getValue());
assertTrue(case2.getThen() instanceof XStringLiteral);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:XbaseParserTest.java
注:本文中的org.eclipse.xtext.xbase.XStringLiteral类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论