org.eclipse.xtext.RuleCall Java Examples

The following examples show how to use org.eclipse.xtext.RuleCall. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParseTreeUtil.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the source text assigned to the given feature of the given object. Does not work for multi-valued features. Optionally also converts the source
 * text using the corresponding value converter. Conversion is only performed for keywords, rule call or cross reference grammar rules.
 * <p>
 * This method does not perform a check to make sure the feature matches the given object.
 *
 * @param object
 *          the semantic object
 * @param feature
 *          the feature to be considered when parsing the parse tree model
 * @param convert
 *          {@code true} if the parsed string needs conversion using its value converter
 * @return the parsed string from the node model
 */
public static String getParsedStringUnchecked(final EObject object, final EStructuralFeature feature, final boolean convert) {
  INode node = Iterables.getFirst(NodeModelUtils.findNodesForFeature(object, feature), null);
  if (node != null) {
    if (convert) {
      final LazyLinkingResource res = (LazyLinkingResource) object.eResource();
      EObject grammarElement = node.getGrammarElement();
      if (res != null && (grammarElement instanceof Keyword || grammarElement instanceof RuleCall || grammarElement instanceof CrossReference)) {
        final DefaultLinkingService linkingService = (DefaultLinkingService) res.getLinkingService();
        return linkingService.getCrossRefNodeAsString(node);
      }
    }
    // result may contain escape sequences or quotes
    return NodeModelUtils.getTokenText(node);
  }
  return null;
}
 
Example #2
Source File: SuperCallScope.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
	IEObjectDescription result = doGetSingleElement(name);
	if (result != null && context instanceof RuleCall) {
		return new ExplicitCallDescription(result, (RuleCall) context);
	}
	return result;
}
 
Example #3
Source File: ParserBasedContentAssistContextFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected int computeParamStackOffset(List<AbstractElement> currentState, List<Integer> paramStack) {
	int paramIndex = paramStack.size() - 1;
	if (!paramStack.isEmpty()) {
		for(AbstractElement abstractElement: currentState) {
			if (abstractElement instanceof RuleCall) {
				RuleCall call = (RuleCall) abstractElement;
				if (!call.getArguments().isEmpty()) {
					paramIndex--;
				}
			}
		}
	}
	return paramIndex;
}
 
Example #4
Source File: AbstractSyntacticSequencerTestLanguageSyntacticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
	if (ruleCall.getRule() == grammarAccess.getBOOLEAN_TERMINAL_IDRule())
		return getBOOLEAN_TERMINAL_IDToken(semanticObject, ruleCall, node);
	else if (ruleCall.getRule() == grammarAccess.getBooleanDatatypeIDRule())
		return getBooleanDatatypeIDToken(semanticObject, ruleCall, node);
	else if (ruleCall.getRule() == grammarAccess.getC_COMMENT_ENDRule())
		return getC_COMMENT_ENDToken(semanticObject, ruleCall, node);
	else if (ruleCall.getRule() == grammarAccess.getIDRule())
		return getIDToken(semanticObject, ruleCall, node);
	else if (ruleCall.getRule() == grammarAccess.getKW1Rule())
		return getKW1Token(semanticObject, ruleCall, node);
	return "";
}
 
Example #5
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void complete_AnnotatedExpression(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #6
Source File: AbstractContentAssistTestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeModel_ReferenceHolder(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #7
Source File: AssertNodeModelAcceptor.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
@Deprecated
public void leaveUnssignedParserRuleCall(RuleCall rc) {
	super.leaveUnssignedParserRuleCall(rc);
}
 
Example #8
Source File: AbstractEcore2XtextTestProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_INT0(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #9
Source File: AbstractRegularExpressionProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completeAbstractLookAhead_Pattern(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #10
Source File: AssertStructureAcceptor.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void acceptAssignedCrossRefDatatype(RuleCall datatypeRC, String token, EObject value, int index,
		ICompositeNode node) {
	assertElement(datatypeRC);
	super.acceptAssignedCrossRefDatatype(datatypeRC, token, value, index, node);
}
 
Example #11
Source File: AbstractBacktrackingContentAssistTestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_SimpleOperationRef(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #12
Source File: AbstractBeeLangTestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeFeatureOfThis_FeatureName(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #13
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completeAssignmentExpression_Op(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #14
Source File: AbstractXtypeProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_QualifiedNameInStaticImport(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #15
Source File: AbstractBromiumProposalProvider.java    From bromium with MIT License 4 votes vote down vote up
public void complete_RowIndex(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #16
Source File: AbstractTypeExpressionsProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completeUnionTypeExpressionOLD_TypeRefs(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #17
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completeN4GetterDeclaration_DeclaredModifiers(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #18
Source File: AbstractXtendProposalProvider.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void completeMember_Implements(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #19
Source File: AbstractGamlProposalProvider.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public void completeTypeInfo_First(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #20
Source File: AbstractXtendProposalProvider.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void completeXtendEnumLiteral_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #21
Source File: AbstractBug304681TestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeObject_LongDescription(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #22
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completePropertyGetterDeclaration_Body(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #23
Source File: AbstractBug348427TestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_Scenario1_3(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #24
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void complete_MemberExpression(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #25
Source File: AbstractXbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_XAndExpression(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #26
Source File: AbstractGamlProposalProvider.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public void completeS_Species_Facets(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #27
Source File: AbstractGamlProposalProvider.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public void completeBinary_Right(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #28
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completeBindingElementFragment_Initializer(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #29
Source File: AbstractBeeLangTestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeFunction_Documentation(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #30
Source File: AbstractSARLProposalProvider.java    From sarl with Apache License 2.0 4 votes vote down vote up
public void completeSarlScript_Package(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}