本文整理汇总了Java中org.eclipse.xtext.xbase.XFeatureCall类的典型用法代码示例。如果您正苦于以下问题:Java XFeatureCall类的具体用法?Java XFeatureCall怎么用?Java XFeatureCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XFeatureCall类属于org.eclipse.xtext.xbase包,在下文中一共展示了XFeatureCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasConstructorCallWithThis
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected boolean hasConstructorCallWithThis(JvmConstructor constr) {
XExpression associatedExpression = logicalContainerProvider.getAssociatedExpression(constr);
if (associatedExpression == null) {
return false;
}
TreeIterator<EObject> contents = associatedExpression.eAllContents();
while (contents.hasNext()) {
EObject next = contents.next();
if (next instanceof XFeatureCall) {
XFeatureCall featureCall = (XFeatureCall) next;
if (featureCall.getFeature() instanceof JvmConstructor && featureCall.getConcreteSyntaxFeatureName().equals(IFeatureNames.THIS.toString())) {
return true;
}
}
}
return false;
}
示例2: checkDelegateConstructorIsFirst
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的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);
}
}
}
}
示例3: checkIsValidConstructorArgument
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected void checkIsValidConstructorArgument(XExpression argument, JvmType containerType) {
TreeIterator<EObject> iterator = EcoreUtil2.eAll(argument);
while(iterator.hasNext()) {
EObject partOfArgumentExpression = iterator.next();
if (partOfArgumentExpression instanceof XFeatureCall || partOfArgumentExpression instanceof XMemberFeatureCall) {
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) partOfArgumentExpression;
XExpression actualReceiver = featureCall.getActualReceiver();
if(actualReceiver instanceof XFeatureCall && ((XFeatureCall)actualReceiver).getFeature() == containerType) {
JvmIdentifiableElement feature = featureCall.getFeature();
if (feature != null && !feature.eIsProxy()) {
if (feature instanceof JvmField) {
if (!((JvmField) feature).isStatic())
error("Cannot refer to an instance field " + feature.getSimpleName() + " while explicitly invoking a constructor",
partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT);
} else if (feature instanceof JvmOperation) {
if (!((JvmOperation) feature).isStatic())
error("Cannot refer to an instance method while explicitly invoking a constructor",
partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT);
}
}
}
} else if(isLocalClassSemantics(partOfArgumentExpression)) {
iterator.prune();
}
}
}
示例4: checkNoJavaStyleTypeCasting
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected void checkNoJavaStyleTypeCasting(INode node) {
BidiTreeIterator<INode> iterator = node.getAsTreeIterable().reverse().iterator();
ILeafNode child = getFirstLeafNode(iterator);
if (child != null && child.getGrammarElement() == grammarAccess.getXParenthesizedExpressionAccess().getRightParenthesisKeyword_2()) {
INode expressionNode = getNode(iterator, grammarAccess.getXParenthesizedExpressionAccess().getXExpressionParserRuleCall_1());
EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(expressionNode);
if (semanticObject instanceof XFeatureCall || semanticObject instanceof XMemberFeatureCall) {
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) semanticObject;
if (featureCall.isTypeLiteral()) {
ICompositeNode parenthesizedNode = child.getParent();
ITextRegion parenthesizedRegion = parenthesizedNode.getTextRegion();
addIssue("Use 'as' keyword for type casting.", featureCall, parenthesizedRegion.getOffset(), parenthesizedRegion.getLength(), JAVA_STYLE_TYPE_CAST);
}
}
}
}
示例5: addExtensionsToCurrentScope
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
@Override
public void addExtensionsToCurrentScope(List<? extends JvmIdentifiableElement> extensionProviders) {
if (extensionProviders.isEmpty())
return;
if (extensionProviders.size() == 1) {
addExtensionToCurrentScope(extensionProviders.get(0));
return;
}
Map<XExpression, LightweightTypeReference> prototypeToType = Maps2.newLinkedHashMapWithExpectedSize(extensionProviders.size());
for(JvmIdentifiableElement extensionProvider: extensionProviders) {
LightweightTypeReference knownType = getResolvedTypes().getActualType(extensionProvider);
if (knownType != null && !knownType.isAny() && !knownType.isUnknown()) {
XFeatureCall prototype = getResolver().getXbaseFactory().createXFeatureCall();
prototype.setFeature(extensionProvider);
prototypeToType.put(prototype, knownType);
}
}
if (!prototypeToType.isEmpty())
featureScopeSession = featureScopeSession.addToExtensionScope(prototypeToType);
}
示例6: getErrorNode
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
/**
* Returns the node that best describes the error, e.g. if there is an expression
* <code>com::foo::DoesNotExist::method()</code> the error will be rooted at <code>com</code>, but
* the real problem is <code>com::foo::DoesNotExist</code>.
*/
private INode getErrorNode(XExpression expression, INode node) {
if (expression instanceof XFeatureCall) {
XFeatureCall featureCall = (XFeatureCall) expression;
if (!canBeTypeLiteral(featureCall)) {
return node;
}
if (featureCall.eContainingFeature() == XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET) {
XMemberFeatureCall container = (XMemberFeatureCall) featureCall.eContainer();
if (canBeTypeLiteral(container)) {
boolean explicitStatic = container.isExplicitStatic();
XMemberFeatureCall outerMost = getLongestTypeLiteralCandidate(container, explicitStatic);
if (outerMost != null)
return NodeModelUtils.getNode(outerMost);
}
}
}
return node;
}
示例7: createSimpleFeatureCallScope
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
/**
* This method serves as an entry point for the content assist scoping for simple feature calls.
* @param context the context e.g. a for loop expression, a block or a catch clause
*/
public IScope createSimpleFeatureCallScope(EObject context, IFeatureScopeSession session, IResolvedTypes resolvedTypes) {
IScope root = IScope.NULLSCOPE;
if (context instanceof XFeatureCall) {
XFeatureCall featureCall = (XFeatureCall) context;
if (!featureCall.isExplicitOperationCallOrBuilderSyntax()) {
root = createTypeLiteralScope(context, QualifiedName.EMPTY, root, session, resolvedTypes);
if (isDefiniteTypeLiteral(featureCall)) {
return root;
}
}
}
IScope staticImports = createStaticFeaturesScope(context, root, session);
IScope staticMembers = createStaticScope(asAbstractFeatureCall(context), null, null, staticImports, session, resolvedTypes);
IScope staticExtensions = createStaticExtensionsScope(null, null, context, staticMembers, session, resolvedTypes);
// we don't want to use captured instances of 'IT' as dynamic extension implicit argument
// thus the dynamic extension scope only works for the *real* local variables
IScope dynamicExtensions = createDynamicExtensionsScope(null, null, context, staticExtensions, session, resolvedTypes);
IScope localVariables = createImplicitFeatureCallAndLocalVariableScope(context, dynamicExtensions, session, resolvedTypes);
return localVariables;
}
示例8: createImplicitFeatureCallScope
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected IScope createImplicitFeatureCallScope(QualifiedName implicitName, EObject featureCall,
IFeatureScopeSession session, IResolvedTypes resolvedTypes, IScope parent) {
IEObjectDescription thisDescription = session.getLocalElement(implicitName);
if (thisDescription != null) {
JvmIdentifiableElement thisElement = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy();
boolean validStaticScope = true;
if (thisElement instanceof JvmType && THIS.equals(implicitName) && !session.isInstanceContext()) {
validStaticScope = false;
}
LightweightTypeReference type = resolvedTypes.getActualType(thisElement);
if (type !=null && !type.isUnknown()) {
XFeatureCall implicitReceiver = xbaseFactory.createXFeatureCall();
implicitReceiver.setFeature(thisElement);
return createFeatureScopeForTypeRef(implicitReceiver, type, true, featureCall, session, thisElement, parent, validStaticScope);
}
}
return parent;
}
示例9: getRootTypeLiteral
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
public XAbstractFeatureCall getRootTypeLiteral(XAbstractFeatureCall featureCall) {
if (featureCall.isTypeLiteral()) {
return featureCall;
}
if (featureCall.isPackageFragment()) {
return getRootTypeLiteral((XAbstractFeatureCall) featureCall.eContainer());
}
if (featureCall.getFeature() == null || featureCall.getFeature().eIsProxy()) {
// syntactic check
if (featureCall instanceof XFeatureCall || featureCall instanceof XMemberFeatureCall) {
if (!isPotentialTypeLiteral(featureCall, null)) {
return null;
}
if (featureCall instanceof XMemberFeatureCall) {
return doGetRootTypeLiteral((XMemberFeatureCall) featureCall);
}
if (featureCall instanceof XFeatureCall) {
if (featureCall.eContainingFeature() == XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET) {
return doGetRootTypeLiteral((XMemberFeatureCall) featureCall.eContainer());
}
}
}
}
return null;
}
示例10: _toJavaExpression
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected void _toJavaExpression(XAbstractFeatureCall call, ITreeAppendable b) {
if (call.isTypeLiteral()) {
b.append((JvmType) call.getFeature()).append(".class");
} else if (isPrimitiveVoid(call)) {
throw new IllegalArgumentException("feature yields 'void'");
} else {
final String referenceName = getReferenceName(call, b);
if (referenceName != null) {
if (call instanceof XFeatureCall || call instanceof XMemberFeatureCall) {
b.trace(call, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, 0).append(referenceName);
} else {
b.trace(call, false).append(referenceName);
}
} else {
featureCalltoJavaExpression(call, b, true);
}
}
}
示例11: getLocationWithoutTypeArguments
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected ILocationData getLocationWithoutTypeArguments(XAbstractFeatureCall call) {
final ICompositeNode startNode = NodeModelUtils.getNode(call);
if (startNode != null) {
List<INode> resultNodes = Lists.newArrayList();
if (call instanceof XFeatureCall || call instanceof XMemberFeatureCall) {
boolean featureReferenceSeen = false;
for (INode child : startNode.getChildren()) {
if (featureReferenceSeen) {
resultNodes.add(child);
} else {
EObject grammarElement = child.getGrammarElement();
if (grammarElement instanceof CrossReference) {
Assignment assignment = GrammarUtil.containingAssignment(grammarElement);
if (assignment != null && "feature".equals(assignment.getFeature())) {
featureReferenceSeen = true;
resultNodes.add(child);
}
}
}
}
}
return toLocationData(resultNodes);
}
return null;
}
示例12: getSwitchLocalVariableName
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected String getSwitchLocalVariableName(XSwitchExpression expr, ITreeAppendable b) {
JvmFormalParameter declaredParam = expr.getDeclaredParam();
if (declaredParam != null) {
if (b.hasName(declaredParam)) {
return b.getName(declaredParam);
}
return null;
}
XExpression switchExpression = expr.getSwitch();
if (b.hasName(switchExpression)) {
return b.getName(switchExpression);
}
if (switchExpression instanceof XFeatureCall) {
XFeatureCall featureCall = (XFeatureCall) switchExpression;
JvmIdentifiableElement feature = featureCall.getFeature();
if (b.hasName(feature)) {
return b.getName(feature);
}
}
return null;
}
示例13: canCompileToJavaLambda
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected boolean canCompileToJavaLambda(XClosure closure, LightweightTypeReference typeRef, JvmOperation operation) {
if (!typeRef.isInterfaceType())
return false;
if (!operation.getTypeParameters().isEmpty())
return false;
TreeIterator<EObject> iterator = closure.eAllContents();
JvmType jvmType = typeRef.getType();
while (iterator.hasNext()) {
EObject obj = iterator.next();
if (obj instanceof XClosure) {
iterator.prune();
} else if (obj instanceof XFeatureCall && isReferenceToSelf((XFeatureCall) obj, jvmType)) {
return false;
}
}
return true;
}
示例14: hasJvmConstructorCall
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected boolean hasJvmConstructorCall(XExpression obj) {
if (!(obj instanceof XBlockExpression)) {
return false;
}
XBlockExpression blockExpression = (XBlockExpression) obj;
EList<XExpression> expressions = blockExpression.getExpressions();
if (expressions.isEmpty()) {
return false;
}
XExpression expr = expressions.get(0);
if (!(expr instanceof XFeatureCall)) {
return false;
}
XFeatureCall featureCall = (XFeatureCall) expr;
return featureCall.getFeature() instanceof JvmConstructor;
}
示例15: collectStaticImportsFrom
import org.eclipse.xtext.xbase.XFeatureCall; //导入依赖的package包/类
protected void collectStaticImportsFrom(XExpression expression, JvmIdentifiableElement feature) {
if (expression instanceof XAbstractFeatureCall) {
if (feature instanceof JvmEnumerationLiteral && expression instanceof XFeatureCall) {
if (isEnumLiteralImplicitelyImported(expression, (JvmEnumerationLiteral) feature)) {
return;
}
}
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) expression;
if ((feature instanceof JvmOperation || feature instanceof JvmField) && featureCall.isStatic()) {
if (featureCall.isExtension()) {
acceptStaticExtensionImport((JvmMember) feature);
} else {
acceptStaticImport((JvmMember) feature);
}
}
}
}