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 Project: dsl-devkit   Author: dsldevkit   File: ParseTreeUtil.java    License: 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 Project: xtext-core   Author: eclipse   File: SuperCallScope.java    License: 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 Project: xtext-eclipse   Author: eclipse   File: ParserBasedContentAssistContextFactory.java    License: 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
@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 Project: xtext-eclipse   Author: eclipse   File: AbstractEcore2XtextTestProposalProvider.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public void complete_Root(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #6
Source Project: xtext-xtend   Author: eclipse   File: AbstractXtendProposalProvider.java    License: 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 #7
public void completeEnumRule_Alternatives(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #8
Source Project: xtext-eclipse   Author: eclipse   File: AbstractXbaseProposalProvider.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public void complete_XCasePart(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #9
Source Project: xtext-eclipse   Author: eclipse   File: AbstractEcore2XtextTestProposalProvider.java    License: 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 #10
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
	return "";
}
 
Example #11
Source Project: xtext-eclipse   Author: eclipse   File: AssertStructureAcceptor.java    License: 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 #12
public void completeModel_ReferenceHolder(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #13
Source Project: n4js   Author: eclipse   File: AbstractRegularExpressionProposalProvider.java    License: 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 #14
Source Project: xtext-core   Author: eclipse   File: AssertNodeModelAcceptor.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Override
@Deprecated
public void leaveUnssignedParserRuleCall(RuleCall rc) {
	super.leaveUnssignedParserRuleCall(rc);
}
 
Example #15
public void complete_SimpleOperationRef(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #16
public void completeFeatureOfThis_FeatureName(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #17
Source Project: n4js   Author: eclipse   File: AbstractN4JSProposalProvider.java    License: 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 #18
Source Project: xtext-eclipse   Author: eclipse   File: AbstractXtypeProposalProvider.java    License: 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 #19
Source Project: bromium   Author: hristo-vrigazov   File: AbstractBromiumProposalProvider.java    License: MIT License 4 votes vote down vote up
public void complete_RowIndex(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #20
Source Project: n4js   Author: eclipse   File: AbstractTypeExpressionsProposalProvider.java    License: 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 #21
Source Project: n4js   Author: eclipse   File: AbstractN4JSProposalProvider.java    License: 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 #22
Source Project: n4js   Author: eclipse   File: AbstractN4JSProposalProvider.java    License: 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 #23
Source Project: gama   Author: gama-platform   File: AbstractGamlProposalProvider.java    License: 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 #24
Source Project: xtext-xtend   Author: eclipse   File: AbstractXtendProposalProvider.java    License: 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 #25
public void completeObject_LongDescription(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #26
Source Project: n4js   Author: eclipse   File: AbstractN4JSProposalProvider.java    License: 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 #27
public void complete_Scenario1_3(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #28
Source Project: n4js   Author: eclipse   File: AbstractN4JSProposalProvider.java    License: 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 #29
Source Project: xtext-eclipse   Author: eclipse   File: AbstractXbaseProposalProvider.java    License: 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 #30
Source Project: gama   Author: gama-platform   File: AbstractGamlProposalProvider.java    License: 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);
}