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


Java GrammarUtil.containingAssignment方法代码示例

本文整理汇总了Java中org.eclipse.xtext.GrammarUtil.containingAssignment方法的典型用法代码示例。如果您正苦于以下问题:Java GrammarUtil.containingAssignment方法的具体用法?Java GrammarUtil.containingAssignment怎么用?Java GrammarUtil.containingAssignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.GrammarUtil的用法示例。


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

示例1: shouldUseParent

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected boolean shouldUseParent(ICompositeNode result, int offset, ILeafNode leaf) {
	if (leaf.getTotalEndOffset() == offset) {
		return true;
	}
	if (result.getGrammarElement() instanceof RuleCall) {
		RuleCall rc = (RuleCall) result.getGrammarElement();
		if (!rc.getArguments().isEmpty()) {
			return true;
		}
		Assignment assignment = GrammarUtil.containingAssignment(rc);
		if (assignment != null
				&& (GrammarUtil.isMultipleCardinality(assignment) || (assignment.eContainer() instanceof AbstractElement && GrammarUtil
						.isMultipleCardinality((AbstractElement) assignment.eContainer())))) {
			return true;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:EntryPointFinder.java

示例2: getLocationOfDefault

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected ILocationData getLocationOfDefault(XSwitchExpression expression) {
	final ICompositeNode startNode = NodeModelUtils.getNode(expression);
	if (startNode != null) {
		List<INode> resultNodes = Lists.newArrayList();
		boolean defaultSeen = false;
		for (INode child : startNode.getChildren()) {
			if (defaultSeen) {
				resultNodes.add(child);
				if (GrammarUtil.containingAssignment(child.getGrammarElement()) != null) {
					break;
				}
			} else if (child.getGrammarElement() instanceof Keyword && "default".equals(child.getText())) {
				defaultSeen = true;
				resultNodes.add(child);
			}
		}
		return toLocationData(resultNodes);
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:XbaseCompiler.java

示例3: findNodeFor

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
 * Returns the smallest node that covers all assigned values of the given object. It handles the semantics of {@link Action
 * actions} and {@link RuleCall unassigned rule calls}.
 * 
 * @return the minimal node that covers all assigned values of the given object.
 * @since 2.3
 */
protected ICompositeNode findNodeFor(EObject semanticObject) {
	ICompositeNode result = NodeModelUtils.getNode(semanticObject);
	if (result != null) {
		ICompositeNode node = result;
		while (GrammarUtil.containingAssignment(node.getGrammarElement()) == null && node.getParent() != null && !node.getParent().hasDirectSemanticElement()) {
			ICompositeNode parent = node.getParent();
			if (node.hasSiblings()) {
				for(INode sibling: parent.getChildren()) {
					EObject grammarElement = sibling.getGrammarElement();
					if (grammarElement != null && GrammarUtil.containingAssignment(grammarElement) != null) {
						result = parent;
					}
				}
			}
			node = parent;
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:DefaultLocationInFileProvider.java

示例4: shouldCheckParentNode

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
 * @return true, if the parent node could contain cross references to the same semantic element as the given node.
 */
protected boolean shouldCheckParentNode(INode node) {
	EObject grammarElement = node.getGrammarElement();
	if (grammarElement instanceof AbstractElement) {
		ICompositeNode parent = node.getParent();
		if (parent != null) {
			if (!parent.hasDirectSemanticElement()) {
				if (isContainedInFragmentRule(grammarElement)) {
					return false;
				}
				Assignment assignment = GrammarUtil.containingAssignment(grammarElement);
				if (assignment == null) {
					return true;
				}
			}
			if (grammarElement instanceof Action) {
				if (isContainedInFragmentRule(grammarElement)) {
					return parent.getGrammarElement() instanceof RuleCall;
				}
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:AbstractCleaningLinker.java

示例5: getContainingFeature

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public EStructuralFeature getContainingFeature() {
	String feature = null;
	if (grammarElement instanceof Action) {
		feature = ((Action) grammarElement).getFeature();
	} else {
		Assignment assignment = GrammarUtil.containingAssignment(getGrammarElement());
		if (assignment != null) {
			feature = assignment.getFeature();
		}
	}
	if (feature == null) {
		return null;
	}
	return semanticElement.eClass().getEStructuralFeature(feature);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractEObjectRegion.java

示例6: getEntryGrammarElement

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected AbstractElement getEntryGrammarElement(ICompositeNode entryPoint) {
	EObject grammarElement = entryPoint.getGrammarElement();
	if (grammarElement instanceof RuleCall) {
		AbstractRule rule = ((RuleCall) grammarElement).getRule();
		if (rule instanceof ParserRule) {
			if (!GrammarUtil.isMultipleCardinality(rule.getAlternatives())) {
				grammarElement = rule.getAlternatives();
			}
		}
	} else if (grammarElement instanceof ParserRule) {
		grammarElement = ((ParserRule) grammarElement).getAlternatives();
	} else if (grammarElement instanceof CrossReference) {
		grammarElement = GrammarUtil.containingAssignment(grammarElement);
	}
	AbstractElement result = (AbstractElement) grammarElement;
	if (result instanceof Action) {
		return getEntryGrammarElement((ICompositeNode) entryPoint.getFirstChild());
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:BaseContentAssistParser.java

示例7: getAssignedFeature

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
 * Get the name assigned feature in an Assignment rule call.
 *
 * @param call
 *          a rule call
 * @return the assigned feature
 */
private String getAssignedFeature(final RuleCall call) {
  Assignment ass = GrammarUtil.containingAssignment(call);
  if (ass != null) {
    String result = ass.getFeature();
    if (result.equals(result.toLowerCase())) { // NOPMD
      result = Strings.toFirstUpper(result);
    }
    return result;
  }
  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:19,代码来源:CheckProposalProvider.java

示例8: collectReachableRules

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected void collectReachableRules(ParserRule pr, Set<ParserRule> rules, Set<ParserRule> visited) {
	if (!visited.add(pr))
		return;
	for (RuleCall rc : GrammarUtil.containedRuleCalls(pr))
		if (isParserRule(rc.getRule())) {
			if (GrammarUtil.containingAssignment(rc) != null)
				rules.add((ParserRule) rc.getRule());
			collectReachableRules((ParserRule) rc.getRule(), rules, visited);
		}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:ConcreteSyntaxConstraintProvider.java

示例9: checkUnassignedRuleCallAllowed

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Check
public void checkUnassignedRuleCallAllowed(final RuleCall call) {
	if (call.getRule() != null && !call.getRule().eIsProxy() && GrammarUtil.containingAssignment(call) == null) {
		AbstractRule container = GrammarUtil.containingRule(call);
		if (call.getRule() instanceof ParserRule) {
			if (container instanceof TerminalRule) {
				getMessageAcceptor().acceptError(
						"Cannot call parser rule from terminal rule.", 
						call, 
						XtextPackage.Literals.RULE_CALL__RULE,
						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
						null);
			} else {
				ParserRule parserRule = (ParserRule) call.getRule();
				if (!GrammarUtil.isDatatypeRule(parserRule) && !parserRule.isFragment()) {
					checkCurrentMustBeUnassigned(call);
				}
			}
		}
		if (call.getRule() instanceof EnumRule) {
			if (container instanceof TerminalRule) {
				getMessageAcceptor().acceptError(
						"Cannot call enum rule from terminal rule.", 
						call, 
						XtextPackage.Literals.RULE_CALL__RULE,
						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
						null);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:32,代码来源:XtextValidator.java

示例10: serializeInternal

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
protected String serializeInternal(INode node) {
	if (type == null)
		return null;
	switch (type) {
		case CROSS_REFERENCE:
			String ref = crossRefSerializer.serializeCrossRef(eObjectConsumer.getEObject(),
					(CrossReference) element, (EObject) value, node);
			if (ref == null) {
				Assignment ass = GrammarUtil.containingAssignment(element);
				throw new XtextSerializationException("Could not serialize cross reference from "
						+ EmfFormatter.objPath(eObjectConsumer.getEObject()) + "." + ass.getFeature() + " to "
						+ EmfFormatter.objPath((EObject) value));
			}
			return ref;
		case KEYWORD:
			return keywordSerializer.serializeAssignedKeyword(eObjectConsumer.getEObject(),
					((Keyword) element), value, node);
		case TERMINAL_RULE_CALL:
			return valueSerializer.serializeAssignedValue(eObjectConsumer.getEObject(), (RuleCall) element,
					value, node);
		case ENUM_RULE_CALL:
			return enumLitSerializer.serializeAssignedEnumLiteral(eObjectConsumer.getEObject(),
					(RuleCall) element, value, node);
		case PARSER_RULE_CALL:
			return null;
		case DATATYPE_RULE_CALL:
			return valueSerializer.serializeAssignedValue(eObjectConsumer.getEObject(), (RuleCall) element,
					value, node);
		default:
			return null;
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:34,代码来源:AbstractParseTreeConstructor.java

示例11: equalsOrReplacesNode

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public boolean equalsOrReplacesNode(EObject context, RuleCall ruleCall, Object value, INode node) {
	if (ruleCall != node.getGrammarElement())
		return false;
	Assignment ass = GrammarUtil.containingAssignment(ruleCall);
	if (GrammarUtil.isSingleAssignment(ass))
		return true;
	Object converted = converter.toValue(serialize(node), ruleCall.getRule().getName(), node);
	return converted != null && converted.equals(value);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:ValueSerializer.java

示例12: addAssignemnt

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected String addAssignemnt(String result, AbstractElement ele) {
	if (!showAssignment)
		return result;
	Assignment ass = GrammarUtil.containingAssignment(ele);
	result = ass != null ? ass.getFeature() + ass.getOperator() + result : result;
	return addQualified(result, ele);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:GrammarElementTitleSwitch.java

示例13: getConstructedType

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
 * @since 2.0
 */
protected EClass getConstructedType(AbstractElement ele) {
	if (ele instanceof Action)
		return (EClass) ((Action) ele).getType().getClassifier();
	if (GrammarUtil.containingAssignment(ele) != null)
		return (EClass) GrammarUtil.containingRule(ele).getType().getClassifier();
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:11,代码来源:AbstractPDAProvider.java

示例14: getToken

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected String getToken(RuleCall rc, Object value, INode node) {
	CrossReference crossRef = GrammarUtil.containingCrossReference(rc);
	Assignment assignment = GrammarUtil.containingAssignment(rc);
	if (crossRef != null)
		return provider.crossRefSerializer.serializeCrossRef(semanticObject, crossRef, (EObject) value, node,
				errorAcceptor);
	else if (GrammarUtil.isEObjectRuleCall(rc) || GrammarUtil.isBooleanAssignment(assignment))
		return null;
	else if (GrammarUtil.isEnumRuleCall(rc))
		return provider.enumLiteralSerializer.serializeAssignedEnumLiteral(semanticObject, rc, value, node,
				errorAcceptor);
	else
		return provider.valueSerializer.serializeAssignedValue(semanticObject, rc, value, node, errorAcceptor);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:15,代码来源:SequenceFeeder.java

示例15: isBooleanAssignment

import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public boolean isBooleanAssignment() {
	if (booleanAssignment == null) {
		Assignment assignment = GrammarUtil.containingAssignment(assignedGrammarElement);
		booleanAssignment = assignment != null && GrammarUtil.isBooleanAssignment(assignment);
	}
	return booleanAssignment;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:9,代码来源:SemanticSequencerNfaProvider.java


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