本文整理汇总了Java中org.eclipse.xtext.xbase.XBlockExpression类的典型用法代码示例。如果您正苦于以下问题:Java XBlockExpression类的具体用法?Java XBlockExpression怎么用?Java XBlockExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XBlockExpression类属于org.eclipse.xtext.xbase包,在下文中一共展示了XBlockExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkDelegateConstructorIsFirst
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Check
public void checkDelegateConstructorIsFirst(XFeatureCall featureCall) {
JvmIdentifiableElement feature = featureCall.getFeature();
if (feature != null && !feature.eIsProxy() && feature instanceof JvmConstructor) {
JvmIdentifiableElement container = logicalContainerProvider.getNearestLogicalContainer(featureCall);
if (container != null) {
if (container instanceof JvmConstructor) {
XExpression body = logicalContainerProvider.getAssociatedExpression(container);
if (body == featureCall)
return;
if (body instanceof XBlockExpression) {
List<XExpression> expressions = ((XBlockExpression) body).getExpressions();
if (expressions.isEmpty() || expressions.get(0) != featureCall) {
error("Constructor call must be the first expression in a constructor", null, INVALID_CONSTRUCTOR_INVOCATION);
}
}
} else {
error("Constructor call must be the first expression in a constructor", null, INVALID_CONSTRUCTOR_INVOCATION);
}
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:XbaseValidator.java
示例2: checkNoJavaStyleTypeCasting
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Check
public void checkNoJavaStyleTypeCasting(XBlockExpression blockExpression) {
if(isIgnored(JAVA_STYLE_TYPE_CAST)) {
return;
}
if (blockExpression.getExpressions().size() <= 1) {
return;
}
ICompositeNode node = NodeModelUtils.getNode(blockExpression);
if (node == null) {
return;
}
INode expressionNode = null;
for (INode child : node.getChildren()) {
if (isSemicolon(child)) {
expressionNode = null;
} else if (isXExpressionInsideBlock(child)) {
if (expressionNode != null) {
checkNoJavaStyleTypeCasting(expressionNode);
}
expressionNode = child;
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:XbaseValidator.java
示例3: emit_XParenthesizedExpression_LeftParenthesisKeyword_0_a
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
/**
* Syntax: '('*
*/
@Override
protected void emit_XParenthesizedExpression_LeftParenthesisKeyword_0_a(EObject semanticObject,
ISynNavigable transition, List<INode> nodes) {
Keyword kw = grammarAccess.getXParenthesizedExpressionAccess().getLeftParenthesisKeyword_0();
if (nodes == null) {
if (semanticObject instanceof XIfExpression || semanticObject instanceof XTryCatchFinallyExpression) {
EObject cnt = semanticObject.eContainer();
if (cnt instanceof XExpression && !(cnt instanceof XBlockExpression)
&& !(cnt instanceof XForLoopExpression))
acceptUnassignedKeyword(kw, kw.getValue(), null);
}
if (semanticObject instanceof XConstructorCall) {
XConstructorCall call = (XConstructorCall) semanticObject;
if (!call.isExplicitConstructorCall() && call.getArguments().isEmpty()) {
acceptUnassignedKeyword(kw, kw.getValue(), null);
}
}
}
acceptNodes(transition, nodes);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:XbaseSyntacticSequencer.java
示例4: isToBeCastedAnyType
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
/**
* On Java-level the any-type is represented as java.lang.Object as there is no subtype of everything (i.e. type for null).
* So, when the values are used we need to manually cast them to whatever is expected.
*
* This method tells us whether such a cast is needed.
*/
private boolean isToBeCastedAnyType(LightweightTypeReference actualType, XExpression obj, ITreeAppendable appendable) {
if (actualType instanceof AnyTypeReference) {
if (getReferenceName(obj, appendable) != null)
return true;
else if (obj instanceof XBlockExpression) {
XBlockExpression blockExpression = (XBlockExpression) obj;
EList<XExpression> expressions = blockExpression.getExpressions();
if (expressions.isEmpty())
return false;
if (expressions.size() > 1)
return true;
XExpression last = expressions.get(0);
return isToBeCastedAnyType(actualType, last, appendable);
}
}
return false;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:TypeConvertingCompiler.java
示例5: testXVariableDeclarationCall
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test
public void testXVariableDeclarationCall() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("val foo = 1");
_builder.newLine();
_builder.append("\t");
_builder.append("val bar = foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XExpression _expression = this.expression(_builder);
final XBlockExpression blockExpression = ((XBlockExpression) _expression);
XExpression _get = blockExpression.getExpressions().get(1);
final XVariableDeclaration variableDeclaration = ((XVariableDeclaration) _get);
this.evaluatesTo(variableDeclaration, Integer.valueOf(1));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:SwitchConstantExpressionsInterpreterTest.java
示例6: compileWithJvmConstructorCall
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
protected void compileWithJvmConstructorCall(XBlockExpression obj, ITreeAppendable apendable) {
EList<XExpression> expressions = obj.getExpressions();
internalToJavaStatement(expressions.get(0), apendable.trace(obj, false), false);
if (expressions.size() == 1) {
return;
}
apendable.newLine().append("try {").increaseIndentation();
ITreeAppendable b = apendable.trace(obj, false);
for (int i = 1; i < expressions.size(); i++) {
XExpression ex = expressions.get(i);
internalToJavaStatement(ex, b, false);
}
generateCheckedExceptionHandling(apendable);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:AbstractXbaseCompiler.java
示例7: isMultilineLambda
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
/**
* checks whether the given lambda should be formatted as a block.
* That includes newlines after and before the brackets, and a fresh line for each expression.
*/
protected boolean isMultilineLambda(final XClosure closure) {
final ILeafNode closingBracket = this._nodeModelAccess.nodeForKeyword(closure, "]");
HiddenLeafs _hiddenLeafsBefore = null;
if (closingBracket!=null) {
_hiddenLeafsBefore=this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket);
}
boolean _tripleNotEquals = (_hiddenLeafsBefore != null);
if (_tripleNotEquals) {
int _newLines = this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket).getNewLines();
return (_newLines > 0);
}
boolean _switchResult = false;
XExpression _expression = closure.getExpression();
final XExpression block = _expression;
boolean _matched = false;
if (block instanceof XBlockExpression) {
_matched=true;
_switchResult = ((((XBlockExpression)block).getExpressions().size() > 1) && this.isEachExpressionInOwnLine(((XBlockExpression)block).getExpressions()));
}
if (!_matched) {
_switchResult = false;
}
return _switchResult;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:29,代码来源:XbaseFormatter2.java
示例8: testReassignedType_01
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test
public void testReassignedType_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{ var it = new Object() if (it instanceof String) {} }");
XExpression _expression = this.expression(_builder, false);
XExpression _last = IterableExtensions.<XExpression>last(((XBlockExpression) _expression).getExpressions());
final XIfExpression ifExpr = ((XIfExpression) _last);
XExpression _then = ifExpr.getThen();
final XBlockExpression block = ((XBlockExpression) _then);
final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(block).getExpressionScope(block, IExpressionScope.Anchor.BEFORE);
this.contains(expressionScope, "charAt");
this.contains(expressionScope, "it");
this.contains(expressionScope, "operator_lessThan");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:ExpressionScopeTest.java
示例9: createEObjectDescriptions
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean createEObjectDescriptions(final EObject eObject, final IAcceptor<IEObjectDescription> acceptor) {
if (eObject instanceof XBlockExpression || isXbaseLocalVariableName(eObject)) {
return false;
}
boolean indexObject = false;
boolean indexDefault = false;
String objectFingerprint = null;
if (fingerprintComputer != null && eObject.eContainer() instanceof FormatConfiguration && NodeModelUtils.getNode(eObject) != null) {
objectFingerprint = fingerprintComputer.computeFingerprint(eObject);
}
if (objectFingerprint != null && !"".equals(objectFingerprint) && eObject.eContainer() instanceof FormatConfiguration) {
acceptor.accept(EObjectDescription.create(objectFingerprint, eObject));
indexObject = true;
}
indexDefault = createDescriptionsForNonXbaseFormalParameters(eObject, acceptor);
return indexDefault || indexObject;
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:27,代码来源:FormatResourceDescriptionStrategy.java
示例10: testReassignedType_02
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test
public void testReassignedType_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{ var it = new Object() if (it instanceof String) { it = new Object() } }");
XExpression _expression = this.expression(_builder, false);
XExpression _last = IterableExtensions.<XExpression>last(((XBlockExpression) _expression).getExpressions());
final XIfExpression ifExpr = ((XIfExpression) _last);
XExpression _then = ifExpr.getThen();
final XBlockExpression block = ((XBlockExpression) _then);
final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(block).getExpressionScope(block, IExpressionScope.Anchor.BEFORE);
this.contains(expressionScope, "charAt");
this.contains(expressionScope, "it");
this.contains(expressionScope, "operator_lessThan");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:ExpressionScopeTest.java
示例11: testMemberOnIt_05
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test
public void testMemberOnIt_05() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{ var (int)=>int it = null }");
XExpression _expression = this.expression(_builder, false);
XExpression _head = IterableExtensions.<XExpression>head(((XBlockExpression) _expression).getExpressions());
final XExpression varInit = ((XVariableDeclaration) _head).getRight();
final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(varInit).getExpressionScope(varInit, IExpressionScope.Anchor.BEFORE);
this.containsNot(expressionScope, "it");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:ExpressionScopeTest.java
示例12: testFeatureCall_2
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test public void testFeatureCall_2() throws Exception {
XBlockExpression block = (XBlockExpression) expression("{" +
" val this = new testdata.FieldAccessSub();" +
" privateField;" +
" privateField();" +
"}");
XFeatureCall call1 = (XFeatureCall) block.getExpressions().get(1);
XFeatureCall call2 = (XFeatureCall) block.getExpressions().get(2);
assertEquals("testdata.FieldAccessSub.privateField()",((JvmOperation)call1.getFeature()).getIdentifier());
assertSame(call1.getFeature(), call2.getFeature());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:AbstractXbaseLinkingTest.java
示例13: basicSetBlock
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBlock(XBlockExpression newBlock, NotificationChain msgs)
{
XBlockExpression oldBlock = block;
block = newBlock;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PureXbasePackage.MODEL__BLOCK, oldBlock, newBlock);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:ModelImpl.java
示例14: testSynchronized
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test
public void testSynchronized() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("synchronized (this) {1}");
XExpression _expression = this.expression(_builder);
final XSynchronizedExpression block = ((XSynchronizedExpression) _expression);
XExpression _expression_1 = block.getExpression();
this.hasImplicitReturns(block, IterableExtensions.<XExpression>head(((XBlockExpression) _expression_1).getExpressions()));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:ImplicitReturnFinderTest.java
示例15: eSet
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case PureXbasePackage.MODEL__IMPORT_SECTION:
setImportSection((XImportSection)newValue);
return;
case PureXbasePackage.MODEL__BLOCK:
setBlock((XBlockExpression)newValue);
return;
}
super.eSet(featureID, newValue);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:ModelImpl.java
示例16: testAppendForEachSafely_3
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test
public void testAppendForEachSafely_3() {
XExpression _validatedExpression = this.validatedExpression("{ error }");
final XBlockExpression e = ((XBlockExpression) _validatedExpression);
final TreeAppendable app = this.createTreeAppendable(e);
Assert.assertTrue(this._errorSafeExtensions.hasErrors(e.getExpressions().get(0)));
final Procedure2<XExpression, ITreeAppendable> _function = (XExpression it, ITreeAppendable app2) -> {
app2.append(this.getText(it));
};
this._errorSafeExtensions.<XExpression>forEachSafely(app, e.getExpressions(), this.getLoopInitializer(), _function);
Assert.assertEquals("/* (error) */", app.getContent());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:ErrorSafeExtensionsTest.java
示例17: testLocalVarAssignment_1
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test public void testLocalVarAssignment_1() throws Exception {
XBlockExpression block = (XBlockExpression) expression("{ var x = ''; x = '' }");
XAssignment assignment = (XAssignment) block.getExpressions().get(1);
assertNull(assignment.getAssignable());
assertTrue(String.valueOf(assignment.getFeature()), assignment.getFeature() instanceof XVariableDeclaration);
assertSame(block.getExpressions().get(0), assignment.getFeature());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:AbstractXbaseLinkingTest.java
示例18: testOverloadedMethods_03
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test public void testOverloadedMethods_03() throws Exception {
XBlockExpression block = (XBlockExpression) expression(
"{\n" +
" var java.util.List<String> strings = null\n" +
" var testdata.OverloadedMethods<Object> receiver = null\n" +
" receiver.overloaded(strings, strings)\n" +
"}");
XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(2);
JvmIdentifiableElement overloaded = featureCall.getFeature();
assertNotNull(overloaded);
assertFalse(overloaded.eIsProxy());
assertEquals("testdata.OverloadedMethods.overloaded(java.util.List,java.util.List)", overloaded.getIdentifier());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:AbstractXbaseLinkingTest.java
示例19: testShadowing_4
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Test public void testShadowing_4() throws Exception {
XBlockExpression bop = (XBlockExpression) expression(
"{" +
" val size = 23;" +
" {" +
" val this = new java.util.ArrayList<String>(); " +
" size();" +
" };" +
"}");
XBlockExpression innerBlock = (XBlockExpression)bop.getExpressions().get(1);
assertEquals("java.util.ArrayList.size()",((XFeatureCall)innerBlock.getExpressions().get(1)).getFeature().getIdentifier());
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:AbstractXbaseLinkingTest.java
示例20: checkDeadCode
import org.eclipse.xtext.xbase.XBlockExpression; //导入依赖的package包/类
@Check
public void checkDeadCode(XBlockExpression block) {
List<XExpression> expressions = block.getExpressions();
for(int i = 0, size = expressions.size(); i < size - 1; i++) {
XExpression expression = expressions.get(i);
if (earlyExitComputer.isEarlyExit(expression)) {
if (!(expression instanceof XAbstractFeatureCall)) {
// XAbstractFeatureCall does already a decent job for its argument lists
// no additional error necessary
markAsDeadCode(expressions.get(i + 1));
}
return;
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:EarlyExitValidator.java
注:本文中的org.eclipse.xtext.xbase.XBlockExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论