use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class PartialSerializationTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == EcorePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case EcorePackage.ECLASS:
sequence_EClassDecl(context, (EClass) semanticObject);
return;
}
else if (epackage == PartialSerializationTestLanguagePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case PartialSerializationTestLanguagePackage.ECLASS_REF:
sequence_EClassRef(context, (EClassRef) semanticObject);
return;
case PartialSerializationTestLanguagePackage.IMPORT:
sequence_Import(context, (Import) semanticObject);
return;
case PartialSerializationTestLanguagePackage.MANDATORY_CHILD:
sequence_MandatoryChild(context, (MandatoryChild) semanticObject);
return;
case PartialSerializationTestLanguagePackage.MANDATORY_CHILD_LIST:
sequence_MandatoryChildList(context, (MandatoryChildList) semanticObject);
return;
case PartialSerializationTestLanguagePackage.MANDATORY_VALUE:
sequence_MandatoryValue(context, (MandatoryValue) semanticObject);
return;
case PartialSerializationTestLanguagePackage.MANY_MANDATORY_VALUES:
sequence_ManyMandatoryValues(context, (ManyMandatoryValues) semanticObject);
return;
case PartialSerializationTestLanguagePackage.MANY_VALUES:
sequence_ManyOptionalValues(context, (ManyValues) semanticObject);
return;
case PartialSerializationTestLanguagePackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
case PartialSerializationTestLanguagePackage.NODE:
sequence_Node(context, (Node) semanticObject);
return;
case PartialSerializationTestLanguagePackage.OPTIONAL_CHILD:
sequence_OptionalChild(context, (OptionalChild) semanticObject);
return;
case PartialSerializationTestLanguagePackage.OPTIONAL_CHILD_LIST:
sequence_OptionalChildList(context, (OptionalChildList) semanticObject);
return;
case PartialSerializationTestLanguagePackage.OPTIONAL_VALUE:
sequence_OptionalValue(context, (OptionalValue) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class IndentationAwareCompletionPrefixProvider method getLastCompleteNodeByOffset.
protected INode getLastCompleteNodeByOffset(INode node, int offset) {
BidiTreeIterator<INode> iterator = node.getRootNode().getAsTreeIterable().iterator();
INode result = node;
ITextRegion candidateTextRegion = node.getTextRegion();
while (iterator.hasNext()) {
INode candidate = iterator.next();
ITextRegion textRegion = candidate.getTextRegion();
if (textRegion.getOffset() >= offset && !(textRegion.getOffset() == offset && textRegion.getLength() == 0)) {
if (!candidateTextRegion.equals(textRegion) && candidate instanceof ILeafNode && textRegion.getLength() + textRegion.getOffset() >= offset) {
break;
}
}
if ((candidate instanceof ILeafNode) && (candidate.getGrammarElement() == null || candidate.getGrammarElement() instanceof AbstractElement || candidate.getGrammarElement() instanceof ParserRule)) {
if (textRegion.getLength() == 0) {
if (candidateTextRegion.getOffset() + candidateTextRegion.getLength() < offset || candidateTextRegion.getLength() == 0 && candidateTextRegion.getOffset() <= offset) {
result = candidate;
candidateTextRegion = candidate.getTextRegion();
}
} else {
result = candidate;
candidateTextRegion = candidate.getTextRegion();
}
}
}
return result;
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class BaseContentAssistParser method getFollowElements.
protected Collection<FE> getFollowElements(InternalParser parser, AbstractElement entryPoint) {
String ruleName = getRuleName(entryPoint);
if (ruleName == null) {
if (entryPoint instanceof RuleCall) {
RuleCall call = (RuleCall) entryPoint;
AbstractRule rule = call.getRule();
if (rule instanceof ParserRule) {
ruleName = getRuleNames().getAntlrRuleName(rule);
}
}
}
if (ruleName == null) {
throw new IllegalStateException("entryPoint: " + entryPoint);
}
return getFollowElements(parser, ruleName);
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class Bug385636SemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Bug385636Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Bug385636Package.DEFINE_VARIABLE:
sequence_DefineVariable(context, (DefineVariable) semanticObject);
return;
case Bug385636Package.DEFINE_VARIABLES:
sequence_DefineVariables(context, (DefineVariables) semanticObject);
return;
case Bug385636Package.EXPRESSION_EQUAL:
sequence_Statement(context, (Expression_Equal) semanticObject);
return;
case Bug385636Package.EXPRESSION_LARGER_EQUAL:
sequence_Statement(context, (Expression_Larger_Equal) semanticObject);
return;
case Bug385636Package.EXPRESSION_NOT_EQUAL:
sequence_Statement(context, (Expression_Not_Equal) semanticObject);
return;
case Bug385636Package.EXPRESSION_NOT_GREATER:
sequence_Statement(context, (Expression_Not_Greater) semanticObject);
return;
case Bug385636Package.EXPRESSION_NOT_LESS:
sequence_Statement(context, (Expression_Not_Less) semanticObject);
return;
case Bug385636Package.EXPRESSION_SMALLER:
sequence_Statement(context, (Expression_Smaller) semanticObject);
return;
case Bug385636Package.EXPRESSION_SMALLER_EQUAL:
sequence_Statement(context, (Expression_Smaller_Equal) semanticObject);
return;
case Bug385636Package.EXPRESSION_VARIABLE_NAME:
sequence_Expression_VariableName(context, (Expression_VariableName) semanticObject);
return;
case Bug385636Package.NVARIABLE_ACCESS:
sequence_NVariableAccess(context, (NVariableAccess) semanticObject);
return;
case Bug385636Package.PROGRAM:
sequence_Program(context, (Program) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class LiveContainerTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == LiveContainerTestLanguagePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case LiveContainerTestLanguagePackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations