use of org.yakindu.sct.model.stext.stext.StatechartSpecification in project statecharts by Yakindu.
the class STextProposalProvider method completeKeyword.
/**
* Validates if a keyword should be viewed by the proposal view.
*
* Builds dependent on the ContentAssistContext a list with keywords which
* shouldn't be displayed by the proposal view.
*/
@Override
public void completeKeyword(Keyword keyword, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) {
List<Keyword> suppressKeywords = new ArrayList<Keyword>();
EObject rootModel = contentAssistContext.getRootModel();
if (rootModel instanceof TransitionSpecification) {
suppressKeywords(suppressKeywords, (TransitionSpecification) rootModel);
} else if (rootModel instanceof SimpleScope) {
suppressKeywords(suppressKeywords, (SimpleScope) rootModel);
} else if (rootModel instanceof StatechartSpecification) {
suppressKeywords(suppressKeywords, (StatechartSpecification) rootModel);
}
EObject currentModel = contentAssistContext.getCurrentModel();
if (currentModel instanceof InterfaceScope) {
suppressKeywords(suppressKeywords, (InterfaceScope) currentModel);
}
if (currentModel instanceof FeatureCall) {
suppressKeywords(suppressKeywords, (FeatureCall) currentModel);
}
if (currentModel instanceof ElementReferenceExpression) {
suppressKeywords(suppressKeywords, (ElementReferenceExpression) currentModel);
}
if (currentModel instanceof InternalScope) {
suppressKeywords(suppressKeywords, (InternalScope) currentModel);
}
if (!suppressKeywords.contains(keyword)) {
super.completeKeyword(keyword, contentAssistContext, new AcceptorDelegate(acceptor));
}
}
use of org.yakindu.sct.model.stext.stext.StatechartSpecification in project statecharts by Yakindu.
the class StextResource method parseStatechart.
protected void parseStatechart(Statechart statechart) {
IParseResult parseResult = parse(statechart, StatechartSpecification.class.getSimpleName());
StatechartSpecification rootASTElement = (StatechartSpecification) parseResult.getRootASTElement();
statechart.setNamespace(rootASTElement.getNamespace());
statechart.getScopes().clear();
EList<Scope> definitionScopes = rootASTElement.getScopes();
if (definitionScopes != null) {
statechart.getScopes().addAll(definitionScopes);
}
statechart.getAnnotations().clear();
EList<ArgumentedAnnotation> annotations = rootASTElement.getAnnotations();
if (annotations != null) {
statechart.getAnnotations().addAll(annotations);
}
}
use of org.yakindu.sct.model.stext.stext.StatechartSpecification in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkAnnotations.
@Test
public void checkAnnotations() {
String scope;
StatechartSpecification model;
AssertableDiagnostics validationResult;
statechart.setName("Annotated");
scope = "@EventDriven";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@CycleBased(200)";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@CycleBased(200)\n" + "@EventDriven";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertErrorContains(CONTRADICTORY_ANNOTATIONS.split("%s")[0]);
scope = "@ParentFirstExecution";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@ChildFirstExecution";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertOK();
scope = "@ParentFirstExecution\n" + "@ChildFirstExecution";
model = (StatechartSpecification) super.parseExpression(scope, StatechartSpecification.class.getSimpleName());
statechart.getAnnotations().clear();
statechart.getAnnotations().addAll(model.getAnnotations());
validationResult = tester.validate(statechart);
validationResult.assertErrorContains(CONTRADICTORY_ANNOTATIONS.split("%s")[0]);
}
use of org.yakindu.sct.model.stext.stext.StatechartSpecification in project statecharts by Yakindu.
the class StatechartRootImpl method basicSetDef.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetDef(StatechartSpecification newDef, NotificationChain msgs) {
StatechartSpecification oldDef = def;
def = newDef;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StextPackage.STATECHART_ROOT__DEF, oldDef, newDef);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations