org.eclipse.xtext.Action Java Examples

The following examples show how to use org.eclipse.xtext.Action. 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: Bug381381TestLanguageSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 == Bug381381TestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Bug381381TestLanguagePackage.COPY_FIELD_NAME_TO_VARIABLE_STMT:
			sequence_CopyFieldNameToVariableStmt(context, (CopyFieldNameToVariableStmt) semanticObject); 
			return; 
		case Bug381381TestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #2
Source File: GH341TestLanguageSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 == Gh341TestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Gh341TestLanguagePackage.BROKEN:
			sequence_Broken_Fragment(context, (Broken) semanticObject); 
			return; 
		case Gh341TestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case Gh341TestLanguagePackage.THIRD:
			sequence_Third(context, (Third) semanticObject); 
			return; 
		case Gh341TestLanguagePackage.WORKS:
			sequence_Works(context, (Works) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #3
Source File: TestLanguageSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 == FooPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case FooPackage.FILE:
			sequence_File(context, (File) semanticObject); 
			return; 
		case FooPackage.STUFF:
			sequence_Stuff(context, (Stuff) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #4
Source File: Ecore2XtextTestSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 == Ecore2xtextPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Ecore2xtextPackage.CONCRETE0:
			sequence_Concrete0_Impl(context, (Concrete0) semanticObject); 
			return; 
		case Ecore2xtextPackage.CONCRETE1:
			sequence_Concrete1_Impl(context, (Concrete1) semanticObject); 
			return; 
		case Ecore2xtextPackage.DIAMOND_INHERITANCE:
			sequence_DiamondInheritance(context, (DiamondInheritance) semanticObject); 
			return; 
		case Ecore2xtextPackage.ROOT:
			sequence_Root(context, (Root) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #5
Source File: ContentAssistTestLanguageSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@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 == ContentAssistTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case ContentAssistTestLanguagePackage.GENERATE_DIRECTIVE:
			sequence_GenerateDirective(context, (GenerateDirective) semanticObject); 
			return; 
		case ContentAssistTestLanguagePackage.IMPORT:
			sequence_Import(context, (Import) semanticObject); 
			return; 
		case ContentAssistTestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case ContentAssistTestLanguagePackage.REFERENCE_HOLDER:
			sequence_ReferenceHolder(context, (ReferenceHolder) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #6
Source File: DatatypeRuleTestLanguageSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 == DatatypeRuleTestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case DatatypeRuleTestPackage.COMPOSITE_TYPE:
			sequence_CompositeType(context, (CompositeType) semanticObject); 
			return; 
		case DatatypeRuleTestPackage.COMPOSITE_TYPE_ENTRY:
			sequence_CompositeTypeEntry(context, (CompositeTypeEntry) semanticObject); 
			return; 
		case DatatypeRuleTestPackage.SIMPLE_TYPE:
			sequence_SimpleType(context, (SimpleType) semanticObject); 
			return; 
		case DatatypeRuleTestPackage.TYPES:
			sequence_Types(context, (Types) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #7
Source File: ContentAssistTestLanguageSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 == ContentAssistTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case ContentAssistTestLanguagePackage.ABSTRACT_RULE_CALL:
			sequence_AbstractRuleCall(context, (AbstractRuleCall) semanticObject); 
			return; 
		case ContentAssistTestLanguagePackage.FIRST_ABSTRACT_RULE_CHILD:
			sequence_FirstAbstractRuleChild(context, (FirstAbstractRuleChild) semanticObject); 
			return; 
		case ContentAssistTestLanguagePackage.SECOND_ABSTRACT_RULE_CHILD:
			sequence_SecondAbstractRuleChild(context, (SecondAbstractRuleChild) semanticObject); 
			return; 
		case ContentAssistTestLanguagePackage.START:
			sequence_Start(context, (Start) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #8
Source File: GrammarAccessTestLanguageSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@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 == AsubpackagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case AsubpackagePackage.AMODEL:
			sequence_Root(context, (AModel) semanticObject); 
			return; 
		case AsubpackagePackage.ATYPE:
			sequence_AType(context, (AType) semanticObject); 
			return; 
		}
	else if (epackage == SubsubpackagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case SubsubpackagePackage.ANOTHER_TYPE:
			sequence_AnotherType(context, (AnotherType) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #9
Source File: AbstractAntlrGrammarWithActionsGenerator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected String assignmentEbnf(final AbstractElement it, final Assignment assignment, final AntlrOptions options, final boolean supportActions) {
  if (it instanceof Alternatives) {
    return _assignmentEbnf((Alternatives)it, assignment, options, supportActions);
  } else if (it instanceof Group) {
    return _assignmentEbnf((Group)it, assignment, options, supportActions);
  } else if (it instanceof Action) {
    return _assignmentEbnf((Action)it, assignment, options, supportActions);
  } else if (it instanceof Assignment) {
    return _assignmentEbnf((Assignment)it, assignment, options, supportActions);
  } else if (it instanceof CrossReference) {
    return _assignmentEbnf((CrossReference)it, assignment, options, supportActions);
  } else if (it instanceof RuleCall) {
    return _assignmentEbnf((RuleCall)it, assignment, options, supportActions);
  } else if (it != null) {
    return _assignmentEbnf(it, assignment, options, supportActions);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, assignment, options, supportActions).toString());
  }
}
 
Example #10
Source File: XtextValidationTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testActionAllowed_01() throws Exception {
	String grammarAsText =
		"grammar test with org.eclipse.xtext.common.Terminals\n" +
		"generate test 'http://test'\n" +
		"Model: name=ID Fragment;\n" +
		"fragment Fragment: {Model};\n";

	Grammar grammar = (Grammar) getModel(grammarAsText);
	ParserRule rule = (ParserRule) grammar.getRules().get(1);
	Action action = (Action) rule.getAlternatives();
	XtextValidator validator = get(XtextValidator.class);
	ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(action, true, false);
	validator.setMessageAcceptor(messageAcceptor);
	try {
		validator.checkUnassignedActionAfterAssignment(action);
		fail();
	} catch(RuntimeException e) {
		assertEquals("org.eclipse.xtext.validation.GuardException", e.getClass().getName());
	}
	messageAcceptor.validate();
}
 
Example #11
Source File: TreeTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 == TreeTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case TreeTestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case TreeTestLanguagePackage.NODE:
			sequence_Node(context, (Node) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #12
Source File: UnorderedGroupsTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 == UnorderedGroupsTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case UnorderedGroupsTestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case UnorderedGroupsTestLanguagePackage.NESTED_MODEL:
			sequence_NestedModel(context, (NestedModel) semanticObject); 
			return; 
		case UnorderedGroupsTestLanguagePackage.UNORDERED_SERIALIZATION:
			sequence_UnorderedSerialization(context, (UnorderedSerialization) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #13
Source File: Bug307519TestLanguageSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 == Bug307519TestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Bug307519TestLanguagePackage.ELEM1:
			sequence_Elem1(context, (Elem1) semanticObject); 
			return; 
		case Bug307519TestLanguagePackage.ELEM2:
			sequence_Elem2(context, (Elem2) semanticObject); 
			return; 
		case Bug307519TestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #14
Source File: Bug317840TestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 == Bug317840TestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Bug317840TestLanguagePackage.ELEMENT:
			sequence_Element(context, (Element) semanticObject); 
			return; 
		case Bug317840TestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case Bug317840TestLanguagePackage.NAMED:
			sequence_Named(context, (Named) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #15
Source File: BaseContentAssistParser.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: UnicodeTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 == UnicodePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case UnicodePackage.GSTRING:
			sequence_GString(context, (GString) semanticObject); 
			return; 
		case UnicodePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case UnicodePackage.QUOTED_STRING:
			sequence_QuotedString(context, (QuotedString) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #17
Source File: ImportUriTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 == ImportedURIPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case ImportedURIPackage.IMPORT:
			sequence_Import(context, (Import) semanticObject); 
			return; 
		case ImportedURIPackage.MAIN:
			sequence_Main(context, (Main) semanticObject); 
			return; 
		case ImportedURIPackage.TYPE:
			sequence_Type(context, (Type) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #18
Source File: AbstractInternalAntlrParser.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected EObject forceCreateModelElementAndAdd(Action action, EObject value) {
	EObject result = semanticModelBuilder.create(action.getType().getClassifier());
	semanticModelBuilder.add(result, action.getFeature(), value, null /* ParserRule */, currentNode);
	insertCompositeNode(action);
	associateNodeWithAstElement(currentNode, result);
	return result;
}
 
Example #19
Source File: TokenUtil.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public EObject getTokenOwner(INode node) {
	if (node.hasDirectSemanticElement())
		return node.getSemanticElement();
	if (node.getParent() != null) {
		if (node.getParent().hasDirectSemanticElement())
			return node.getParent().getSemanticElement();
		EObject parentGrammarElement = node.getParent().getGrammarElement();
		boolean isParser = GrammarUtil.isEObjectRule(parentGrammarElement) || GrammarUtil.isEObjectRuleCall(parentGrammarElement);
		for (INode sibling : node.getParent().getChildren())
			if (sibling.hasDirectSemanticElement() && (isParser || sibling.getGrammarElement() instanceof Action))
				return sibling.getSemanticElement();
	}
	return node.getSemanticElement();
}
 
Example #20
Source File: OverriddenValueInspector.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Boolean caseAction(Action object) {
	if (!fragmentStack.isEmpty()) {
		return Boolean.TRUE;
	}
	assignedFeatures = newMultimap();
	if (GrammarUtil.isMultipleAssignment(object))
		return null;
	if (object.getFeature() == null)
		return Boolean.FALSE;
	checkAssignment(object, object.getFeature());
	return Boolean.FALSE;
}
 
Example #21
Source File: DebugConsumerUtility.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void consumeAction(Action action, boolean isMany) {
	if (log.isDebugEnabled()) {
		log.debug("consumeAction(type = " + action.getType().getClassifier().getName() + ", feature = " + action.getFeature() + ", isMany = " + isMany + ")");
	}
	delegate.consumeAction(action, isMany);
}
 
Example #22
Source File: MultiValueFeatureTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 == MultiValueFeatureTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case MultiValueFeatureTestLanguagePackage.START:
			sequence_Start(context, (Start) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #23
Source File: FixedPartialParsingHelper.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean isInvalidRootNode(final ICompositeNode rootNode, final ICompositeNode candidate) {
  int endOffset = candidate.getTotalEndOffset();
  if (candidate instanceof SyntheticCompositeNode) {
    return true;
  }
  if (candidate.getGrammarElement() instanceof RuleCall) {
    AbstractRule rule = ((RuleCall) candidate.getGrammarElement()).getRule();
    if (!(rule instanceof ParserRule) || GrammarUtil.isDatatypeRule((ParserRule) rule)) {
      return true;
    } else if (isInvalidDueToPredicates((AbstractElement) candidate.getGrammarElement())) {
      return true;
    }
  }
  if (candidate.getGrammarElement() instanceof Action) {
    return true;
  }
  if (endOffset == rootNode.getTotalEndOffset()) {
    INode lastChild = getLastChild(candidate);
    if (lastChild instanceof ICompositeNode) {
      INode lastLeaf = getLastLeaf(candidate);
      if (isInvalidLastChildNode(candidate, lastLeaf)) {
        return true;
      }
    }
    if (isInvalidLastChildNode(candidate, lastChild)) {
      return true;
    }
  }
  return false;
}
 
Example #24
Source File: Bug406914TestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 == Bug406914TestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Bug406914TestPackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #25
Source File: AbstractBug301935TestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 == Bug301935TestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Bug301935TestPackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #26
Source File: BaseInheritanceTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 == BaseInheritanceTestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case BaseInheritanceTestPackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #27
Source File: KeywordsTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 == KeywordsTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case KeywordsTestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #28
Source File: FormatterTestLanguage2SemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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 == Formattertestlanguage2Package.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Formattertestlanguage2Package.ROOT:
			sequence_Root(context, (Root) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #29
Source File: SerializationContext.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public static ISerializationContext forChild(ISerializationContext container, Action assignedAction, EObject sem) {
	EClass type = sem == null ? null : sem.eClass();
	//		RuleContext ruleContext = new RuleContext(null, container.getParserRule());
	ISerializationContext context = new TypeContext(new ActionContext(/*ruleContext*/null, assignedAction), type);
	if (container != null) {
		Set<Parameter> params = container.getEnabledBooleanParameters();
		if (!params.isEmpty())
			context = new ParameterValueContext(context, params);
	}
	return context;
}
 
Example #30
Source File: XtextProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void createClassifierProposals(AbstractMetamodelDeclaration declaration, EObject model,
		ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	String alias = declaration.getAlias();
	QualifiedName prefix = (!Strings.isEmpty(alias)) ? QualifiedName.create(getValueConverter().toString(alias,
			grammarAccess.getValidIDRule().getName())) : null;
	boolean createDatatypeProposals = !(model instanceof AbstractElement)
			&& modelOrContainerIs(model, AbstractRule.class);
	boolean createEnumProposals = !(model instanceof AbstractElement) && modelOrContainerIs(model, EnumRule.class);
	boolean createClassProposals = modelOrContainerIs(model, ParserRule.class, CrossReference.class, Action.class);
	Function<IEObjectDescription, ICompletionProposal> factory = new DefaultProposalCreator(context, null, classifierQualifiedNameConverter);
	for (EClassifier classifier : declaration.getEPackage().getEClassifiers()) {
		if (classifier instanceof EDataType && createDatatypeProposals || classifier instanceof EEnum
				&& createEnumProposals || classifier instanceof EClass && createClassProposals) {
			String classifierName = getValueConverter().toString(classifier.getName(), grammarAccess.getValidIDRule().getName());
			QualifiedName proposalQualifiedName = (prefix != null) ? prefix.append(classifierName) : QualifiedName
					.create(classifierName);
			IEObjectDescription description = EObjectDescription.create(proposalQualifiedName, classifier);
			ConfigurableCompletionProposal proposal = (ConfigurableCompletionProposal) factory.apply(description);
			if (proposal != null) {
				if (prefix != null)
					proposal.setDisplayString(classifier.getName() + " - " + alias);
				proposal.setPriority(proposal.getPriority() * 2);
			}
			acceptor.accept(proposal);
		}
	}
}