• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java XListLiteral类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: computeType

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected void computeType(XListLiteral literal, JvmGenericType listType, ITypeExpectation expectation,
		ITypeComputationState state) {
	LightweightTypeReference elementTypeExpectation = null;
	final LightweightTypeReference expectedType = expectation.getExpectedType();
	if(expectedType != null) {
		if(expectedType.isArray()) {
			computeArrayLiteralType(literal, expectedType, expectation, state);
			return; 
		} 
		elementTypeExpectation = getElementOrComponentType(expectedType, state);
	}
	List<LightweightTypeReference> listTypeCandidates = computeCollectionTypeCandidates(literal, listType, elementTypeExpectation, state);
	LightweightTypeReference commonListType = getCommonSuperType(listTypeCandidates, state);
	if (commonListType != null) {
		LightweightTypeReference commonElementType = getElementOrComponentType(commonListType, state);
		ITypeReferenceOwner owner = state.getReferenceOwner();
		commonElementType = normalizeElementType(commonElementType, expectedType, owner);
		if (expectedType != null) {
			commonListType = createCollectionTypeReference(listType, commonElementType, expectedType, owner);
		}
		expectation.acceptActualType(commonListType, ConformanceFlags.UNCHECKED);
		refineElementTypeExpectation(literal, commonElementType, state);
	} else {
		setUnboundCollectionType(literal, listType, expectation, elementTypeExpectation, state);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:CollectionLiteralsTypeComputer.java


示例2: computeArrayLiteralType

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected void computeArrayLiteralType(XListLiteral literal, LightweightTypeReference expectedArrayType, ITypeExpectation expectation,
		ITypeComputationState state) {
	LightweightTypeReference elementTypeExpectation = getElementOrComponentType(expectedArrayType, state);
	int allFlags = 0;
	for(XExpression element: literal.getElements()) {
		ITypeComputationResult elementTypeResult = computeTypes(element, elementTypeExpectation, state);
		deferredBindTypeArgument(elementTypeExpectation, elementTypeResult.getActualExpressionType(), state);
		allFlags |= elementTypeResult.getCheckedConformanceFlags();
	}
	if ((allFlags & ConformanceFlags.INCOMPATIBLE) != 0) {
		allFlags &= (~ConformanceFlags.SUCCESS);
		allFlags |= ConformanceFlags.SEALED | ConformanceFlags.CHECKED | ConformanceFlags.PROPAGATED_TYPE;
		expectation.acceptActualType(expectedArrayType, allFlags);
	} else if ((allFlags & ConformanceFlags.SUCCESS) != 0) {
		allFlags |= ConformanceFlags.SEALED | ConformanceFlags.CHECKED;
		expectation.acceptActualType(expectedArrayType, allFlags);
	} else {
		expectation.acceptActualType(expectedArrayType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.SEALED);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:CollectionLiteralsTypeComputer.java


示例3: _doEvaluate

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected Object _doEvaluate(XListLiteral literal, IEvaluationContext context, CancelIndicator indicator) {
	IResolvedTypes resolveTypes = typeResolver.resolveTypes(literal);
	LightweightTypeReference type = resolveTypes.getActualType(literal);
	List<Object> list = newArrayList();
	for(XExpression element: literal.getElements()) {
		if (indicator.isCanceled())
			throw new InterpreterCanceledException();
		list.add(internalEvaluate(element, context, indicator));
	}
	if(type != null && type.isArray()) {
		try {
			LightweightTypeReference componentType = type.getComponentType();
			return Conversions.unwrapArray(list, getJavaType(componentType.getType()));
		} catch (ClassNotFoundException e) {
		}
	}
	return Collections.unmodifiableList(list);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:XbaseInterpreter.java


示例4: isValidAnnotationValue

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected boolean isValidAnnotationValue(final XExpression expression) {
  if (expression instanceof XListLiteral) {
    return _isValidAnnotationValue((XListLiteral)expression);
  } else if (expression instanceof XAbstractFeatureCall) {
    return _isValidAnnotationValue((XAbstractFeatureCall)expression);
  } else if (expression instanceof XAnnotation) {
    return _isValidAnnotationValue((XAnnotation)expression);
  } else if (expression != null) {
    return _isValidAnnotationValue(expression);
  } else if (expression == null) {
    return _isValidAnnotationValue((Void)null);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(expression).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:AnnotationValueValidator.java


示例5: appendImmutableCollectionExpression

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
@Override
protected void appendImmutableCollectionExpression(final XCollectionLiteral literal, final ITreeAppendable b, final String collectionsMethod, final Class<?> guavaHelper, final String guavaHelperMethod) {
  // This is a work-around for a bug in the xbase compiler, which always constructs empty list literals #[] as List<Object>,
  // which then cannot be assigned (without cast) to any typed list. Note that this is not a problem in check; it also occurs
  // in plain xtend.
  if (literal.getElements().isEmpty()) {
    JvmType collectionsClass = findKnownTopLevelType(Collections.class, literal);
    if (collectionsClass != null) {
      if (literal instanceof XListLiteral) {
        b.append(collectionsClass).append(".emptyList()");
        return;
      } else if (literal instanceof XSetLiteral) {
        b.append(collectionsClass).append(".emptySet()");
        return;
      }
    }
  }
  super.appendImmutableCollectionExpression(literal, b, collectionsMethod, guavaHelper, guavaHelperMethod);
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:20,代码来源:CheckCompiler.java


示例6: checkRightHandSideHasOnlyIntegralNumbers

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的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


示例7: evaluateParameterValue

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
/**
 * Evaluate an expression (value of a ConfiguredParameter).
 *
 * @param newValue
 *          the new value
 * @return the string
 */
private String evaluateParameterValue(final XExpression newValue) {
  if (newValue instanceof XListLiteral) {
    return evaluateList((XListLiteral) newValue);
  } else {
    Object evaluationResult = interpreter.evaluate(newValue).getResult();
    if (evaluationResult instanceof Boolean) {
      return ((Boolean) evaluationResult).toString();
    } else if (evaluationResult instanceof Integer) {
      return ((Integer) evaluationResult).toString();
    } else if (evaluationResult instanceof String) {
      // Note: control characters are no problem; java.util.Properties is smart enough to encode/decode those.
      return (String) evaluationResult;
    }
  }
  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:24,代码来源:CheckConfigurationPropertiesGenerator.java


示例8: evaluateList

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
/**
 * Evaluates a list.
 *
 * @param list
 *          to evaluate
 * @return the evaluated list.
 */
private String evaluateList(final XListLiteral list) {
  Iterable<Object> evaluated = Iterables.transform(list.getElements(), new Function<XExpression, Object>() {
    @Override
    public Object apply(final XExpression expr) {
      return interpreter.evaluate(expr).getResult();
    }
  });
  Object first = Iterables.getFirst(evaluated, null);
  if (first != null) {
    if (first instanceof Boolean) {
      return CheckPreferencesHelper.marshalBooleans(Iterables.filter(evaluated, Boolean.class));
    } else if (first instanceof Integer) {
      return CheckPreferencesHelper.marshalIntegers(Iterables.filter(evaluated, Integer.class));
    } else if (first instanceof String) {
      return CheckPreferencesHelper.marshalStrings(Iterables.filter(evaluated, String.class));
    }
  }
  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:27,代码来源:CheckConfigurationPropertiesGenerator.java


示例9: canUseArrayInitializer

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected boolean canUseArrayInitializer(XListLiteral literal, ITreeAppendable appendable) {
	if (literal.eContainingFeature() == XbasePackage.Literals.XVARIABLE_DECLARATION__RIGHT
		|| literal.eContainingFeature() == XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__VALUE
		|| literal.eContainingFeature() == XAnnotationsPackage.Literals.XANNOTATION__VALUE
		) {
		return canUseArrayInitializerImpl(literal, appendable);
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:XbaseCompiler.java


示例10: canUseArrayInitializerImpl

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected boolean canUseArrayInitializerImpl(XListLiteral literal, ITreeAppendable appendable) {
	for(XExpression element: literal.getElements()) {
		if (isVariableDeclarationRequired(element, appendable, true))
			return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseCompiler.java


示例11: internalToConvertedExpression

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
@Override
protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) {
	if (obj instanceof XBlockExpression) {
		_toJavaExpression((XBlockExpression) obj, appendable);
	} else if (obj instanceof XCastedExpression) {
		_toJavaExpression((XCastedExpression) obj, appendable);
	} else if (obj instanceof XClosure) {
		_toJavaExpression((XClosure) obj, appendable);
	} else if (obj instanceof XAnnotation) {
		_toJavaExpression((XAnnotation) obj, appendable);
	} else if (obj instanceof XConstructorCall) {
		_toJavaExpression((XConstructorCall) obj, appendable);
	} else if (obj instanceof XIfExpression) {
		_toJavaExpression((XIfExpression) obj, appendable);
	} else if (obj instanceof XInstanceOfExpression) {
		_toJavaExpression((XInstanceOfExpression) obj, appendable);
	} else if (obj instanceof XSwitchExpression) {
		_toJavaExpression((XSwitchExpression) obj, appendable);
	} else if (obj instanceof XTryCatchFinallyExpression) {
		_toJavaExpression((XTryCatchFinallyExpression) obj, appendable);
	} else if (obj instanceof XListLiteral) {
		_toJavaExpression((XListLiteral) obj, appendable);
	} else if (obj instanceof XSetLiteral) {
		_toJavaExpression((XSetLiteral) obj, appendable);
	} else if (obj instanceof XSynchronizedExpression) {
		_toJavaExpression((XSynchronizedExpression) obj, appendable);
	} else if (obj instanceof XReturnExpression) {
		_toJavaExpression((XReturnExpression) obj, appendable);
	} else if (obj instanceof XThrowExpression) {
		_toJavaExpression((XThrowExpression) obj, appendable);
	} else {
		super.internalToConvertedExpression(obj, appendable);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:35,代码来源:XbaseCompiler.java


示例12: sequence_XListLiteral

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


示例13: sequence_XAnnotationElementValueOrCommaList_XListLiteral

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


示例14: sequence_XAnnotationElementValue_XListLiteral

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


示例15: computeTypes

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


示例16: _computeTypes

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected void _computeTypes(XListLiteral literal, ITypeComputationState state) {
	collectionLiterals.computeType(literal, state);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:XbaseTypeComputer.java


示例17: _toJavaStatement

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
/**
 * @param isReferenced unused in this context but necessary for dispatch signature 
 */
protected void _toJavaStatement(XListLiteral literal, ITreeAppendable b, boolean isReferenced) {
	for(XExpression element: literal.getElements()) 
		internalToJavaStatement(element, b, true);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseCompiler.java


示例18: _toJavaExpression

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
protected void _toJavaExpression(XListLiteral literal, ITreeAppendable b) {
	LightweightTypeReference literalType = batchTypeResolver.resolveTypes(literal).getActualType(literal);
	if (literalType == null) {
		b.append("error - couldn't compute type for literal : "+literal);
		return;
	} 
	if (literalType.isArray()) {
		LightweightTypeReference expectedType = batchTypeResolver.resolveTypes(literal).getExpectedType(literal);
		boolean skipTypeName = false;
		if (expectedType != null && expectedType.isArray()) {
			if (canUseArrayInitializer(literal, b)) {
				skipTypeName = true;
			}
		}
		if (!skipTypeName) {
			if (literalType instanceof CompoundTypeReference) {
				for (LightweightTypeReference c : literalType.getMultiTypeComponents()) {
					if (c.isArray()) {
						b.append("new ")
						.append(c.getType()) // append raw type since we cannot create generic arrays
						.append(" ");
						break;
					}
				}
			} else {
				b.append("new ")
					.append(literalType.getType()) // append raw type since we cannot create generic arrays
					.append(" ");
			}
		}
		if (literal.getElements().isEmpty()) {
			b.append("{}");
		} else {
			b.append("{ ");
			boolean isFirst = true;
			for(XExpression element: literal.getElements())  {
				if(!isFirst)
					b.append(", ");
				isFirst = false;
				internalToJavaExpression(element, b);
			}
			b.append(" }");
		}
		return;
	} else {
		appendImmutableCollectionExpression(literal, b, "unmodifiableList", CollectionLiterals.class, "newArrayList");
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:49,代码来源:XbaseCompiler.java


示例19: doInternalToJavaStatement

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
@Override
protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) {
	if (obj instanceof XBlockExpression) {
		_toJavaStatement((XBlockExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XCastedExpression) {
		_toJavaStatement((XCastedExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XClosure) {
		_toJavaStatement((XClosure) obj, appendable, isReferenced);
	} else if (obj instanceof XConstructorCall) {
		_toJavaStatement((XConstructorCall) obj, appendable, isReferenced);
	} else if (obj instanceof XDoWhileExpression) {
		_toJavaStatement((XDoWhileExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XForLoopExpression) {
		_toJavaStatement((XForLoopExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XBasicForLoopExpression) {
		_toJavaStatement((XBasicForLoopExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XIfExpression) {
		_toJavaStatement((XIfExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XInstanceOfExpression) {
		_toJavaStatement((XInstanceOfExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XReturnExpression) {
		_toJavaStatement((XReturnExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XSwitchExpression) {
		_toJavaStatement((XSwitchExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XThrowExpression) {
		_toJavaStatement((XThrowExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XTryCatchFinallyExpression) {
		_toJavaStatement((XTryCatchFinallyExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XVariableDeclaration) {
		_toJavaStatement((XVariableDeclaration) obj, appendable, isReferenced);
	} else if (obj instanceof XWhileExpression) {
		_toJavaStatement((XWhileExpression) obj, appendable, isReferenced);
	} else if (obj instanceof XListLiteral) {
		_toJavaStatement((XListLiteral) obj, appendable, isReferenced);
	} else if (obj instanceof XSetLiteral) {
		_toJavaStatement((XSetLiteral) obj, appendable, isReferenced);
	} else if (obj instanceof XSynchronizedExpression) {
		_toJavaStatement((XSynchronizedExpression) obj, appendable, isReferenced);
	} else {
		super.doInternalToJavaStatement(obj, appendable, isReferenced);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:43,代码来源:XbaseCompiler.java


示例20: isVariableDeclarationRequired

import org.eclipse.xtext.xbase.XListLiteral; //导入依赖的package包/类
@Override
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) {
	if (expr instanceof XAnnotation) {
		return false;
	}
	if (expr instanceof XListLiteral) {
		return false;
	}
	if (expr instanceof XSetLiteral) {
		return false;
	}
	if (expr instanceof XCastedExpression) {
		return false;
	}
	if (expr instanceof XInstanceOfExpression) {
		return false;
	}
	if (expr instanceof XMemberFeatureCall && isVariableDeclarationRequired((XMemberFeatureCall) expr, b))
		return true;
	EObject container = expr.eContainer();
	if ((container instanceof XVariableDeclaration)
		|| (container instanceof XReturnExpression) 
		|| (container instanceof XThrowExpression)) {
		return false;
	}
	if (container instanceof XIfExpression) {
		XIfExpression ifExpression = (XIfExpression) container;
		if (ifExpression.getThen() == expr || ifExpression.getElse() == expr) {
			return false;
		}
	}
	if (container instanceof XCasePart) {
		XCasePart casePart = (XCasePart) container;
		if (casePart.getThen() == expr) {
			return false;
		}
	}
	if (container instanceof XSwitchExpression) {
		XSwitchExpression switchExpression = (XSwitchExpression) container;
		if (switchExpression.getDefault() == expr) {
			return false;
		}
	}
	if (container instanceof XBlockExpression) {
		List<XExpression> siblings = ((XBlockExpression) container).getExpressions();
		if (siblings.get(siblings.size() - 1) == expr) {
			return isVariableDeclarationRequired(getFeatureCall(expr), expr, b);
		}
	}
	if (container instanceof XClosure) {
		if (((XClosure) container).getExpression() == expr) {
			return false;
		}
	}
	if (expr instanceof XAssignment) {
		XAssignment a = (XAssignment) expr;
		for (XExpression arg : getActualArguments(a)) {
			if (isVariableDeclarationRequired(arg, b, recursive)) {
				return true;
			}
		}
	}
	return super.isVariableDeclarationRequired(expr, b, recursive);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:65,代码来源:XbaseCompiler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServiceHealth类代码示例发布时间:2022-05-22
下一篇:
Java SM3Digest类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap