|
@@ -11,6 +11,7 @@
|
|
|
*/
|
|
|
package org.yakindu.sct.model.stext.validation;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -31,6 +32,7 @@ import org.eclipse.xtext.validation.Check;
|
|
|
import org.eclipse.xtext.validation.CheckType;
|
|
|
import org.eclipse.xtext.validation.ComposedChecks;
|
|
|
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
|
|
|
+import org.yakindu.base.base.NamedElement;
|
|
|
import org.yakindu.base.types.Event;
|
|
|
import org.yakindu.base.types.Feature;
|
|
|
import org.yakindu.base.types.ITypeSystem.InferenceIssue;
|
|
@@ -39,6 +41,9 @@ import org.yakindu.base.types.Operation;
|
|
|
import org.yakindu.base.types.Parameter;
|
|
|
import org.yakindu.base.types.Property;
|
|
|
import org.yakindu.sct.model.sgraph.Choice;
|
|
|
+import org.yakindu.sct.model.sgraph.Entry;
|
|
|
+import org.yakindu.sct.model.sgraph.ReactionProperty;
|
|
|
+import org.yakindu.sct.model.sgraph.Region;
|
|
|
import org.yakindu.sct.model.sgraph.SGraphPackage;
|
|
|
import org.yakindu.sct.model.sgraph.Scope;
|
|
|
import org.yakindu.sct.model.sgraph.ScopedElement;
|
|
@@ -53,6 +58,7 @@ import org.yakindu.sct.model.stext.stext.DefaultTrigger;
|
|
|
import org.yakindu.sct.model.stext.stext.Direction;
|
|
|
import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
|
|
|
import org.yakindu.sct.model.stext.stext.EntryEvent;
|
|
|
+import org.yakindu.sct.model.stext.stext.EntryPointSpec;
|
|
|
import org.yakindu.sct.model.stext.stext.EventDefinition;
|
|
|
import org.yakindu.sct.model.stext.stext.EventRaisingExpression;
|
|
|
import org.yakindu.sct.model.stext.stext.EventSpec;
|
|
@@ -82,7 +88,8 @@ import com.google.inject.name.Named;
|
|
|
* @auhor muelder
|
|
|
*
|
|
|
*/
|
|
|
-@ComposedChecks(validators = { SGraphJavaValidator.class, SCTResourceValidator.class })
|
|
|
+@ComposedChecks(validators = { SGraphJavaValidator.class,
|
|
|
+ SCTResourceValidator.class })
|
|
|
public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
|
|
|
public static final String CHOICE_ONE_OUTGOING_DEFAULT_TRANSITION = "A choice should have one outgoing default transition";
|
|
@@ -97,6 +104,9 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
public static final String GUARD_EXPRESSION = "The evaluation result of a guard expression must be of type boolean";
|
|
|
public static final String ASSIGNMENT_EXPRESSION = "No nested assignment of the same variable allowed (different behavior in various programming languages)";
|
|
|
public static final String VARIABLE_VOID_TYPE = "'void' is an invalid type for variables";
|
|
|
+ public static final String TRANSITION_ENTRY_SPEC_NOT_COMPOSITE = "Target state isn't composite";
|
|
|
+ public static final String TRANSITION_UNBOUND_ENTRY_POINT = "Target state has regions without 'default' entries.";
|
|
|
+ public static final String REGION_UNBOUND_ENTRY_POINT = "Region must have a 'default' entry.";
|
|
|
|
|
|
@Inject
|
|
|
private ISTextTypeInferrer typeInferrer;
|
|
@@ -110,11 +120,100 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
@Named(Constants.LANGUAGE_NAME)
|
|
|
private String languageName;
|
|
|
|
|
|
+ @Check(CheckType.FAST)
|
|
|
+ public void checkEntrySpecOnAtomicState(final Transition transition) {
|
|
|
+ for (ReactionProperty property : transition.getProperties()) {
|
|
|
+ if (property instanceof EntryPointSpec) {
|
|
|
+ if (transition.getTarget() instanceof org.yakindu.sct.model.sgraph.State) {
|
|
|
+ org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) transition
|
|
|
+ .getTarget();
|
|
|
+ if (!state.isComposite()) {
|
|
|
+ warning(TRANSITION_ENTRY_SPEC_NOT_COMPOSITE,
|
|
|
+ transition, null, -1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Check(CheckType.FAST)
|
|
|
+ public void checkUnboundEntryPoints(
|
|
|
+ final org.yakindu.sct.model.sgraph.State state) {
|
|
|
+
|
|
|
+ final List<Transition> transitions = getTransitionsWithoutEntrySpec(state
|
|
|
+ .getIncomingTransitions());
|
|
|
+
|
|
|
+ if (!transitions.isEmpty()) {
|
|
|
+ final List<Region> regions = getRegionsWithoutDefaultEntry(state
|
|
|
+ .getRegions());
|
|
|
+ if (!regions.isEmpty()) {
|
|
|
+ for (Transition transition : transitions) {
|
|
|
+ error(TRANSITION_UNBOUND_ENTRY_POINT, transition, null, -1);
|
|
|
+ }
|
|
|
+ for (Region region : regions) {
|
|
|
+ error(REGION_UNBOUND_ENTRY_POINT, region, null, -1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Transition> getTransitionsWithoutEntrySpec(
|
|
|
+ List<Transition> elements) {
|
|
|
+ final List<Transition> transitions = new ArrayList<Transition>();
|
|
|
+ for (Transition transition : elements) {
|
|
|
+ boolean hasEntrySpec = false;
|
|
|
+ for (ReactionProperty property : transition.getProperties()) {
|
|
|
+ if (property instanceof EntryPointSpec) {
|
|
|
+ hasEntrySpec = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!hasEntrySpec) {
|
|
|
+ transitions.add(transition);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return transitions;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Region> getRegionsWithoutDefaultEntry(List<Region> elements) {
|
|
|
+ List<Region> regions = new ArrayList<Region>();
|
|
|
+ for (Region region : elements) {
|
|
|
+ boolean hasDefaultEntry = false;
|
|
|
+ for (Entry entry : getEntries(region.eContents())) {
|
|
|
+ if (isDefault(entry)) {
|
|
|
+ hasDefaultEntry = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!hasDefaultEntry) {
|
|
|
+ regions.add(region);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return regions;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isDefault(final NamedElement element) {
|
|
|
+ return element.getName() == null
|
|
|
+ || (element.getName() != null && (element.getName().isEmpty() || element
|
|
|
+ .getName().equalsIgnoreCase("default")));
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Entry> getEntries(List<EObject> elements) {
|
|
|
+ List<Entry> entries = new ArrayList<Entry>();
|
|
|
+ for (EObject element : elements) {
|
|
|
+ if (element instanceof Entry) {
|
|
|
+ entries.add((Entry) element);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return entries;
|
|
|
+ }
|
|
|
+
|
|
|
@Check(CheckType.FAST)
|
|
|
public void checkVariableDefinition(final VariableDefinition definition) {
|
|
|
try {
|
|
|
InferenceResult result = typeInferrer.inferType(definition);
|
|
|
- if (result.getType() != null && typeSystem.isVoidType(result.getType())) {
|
|
|
+ if (result.getType() != null
|
|
|
+ && typeSystem.isVoidType(result.getType())) {
|
|
|
error(VARIABLE_VOID_TYPE, null);
|
|
|
} else {
|
|
|
report(result, null);
|
|
@@ -138,7 +237,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
}
|
|
|
|
|
|
@Check(CheckType.FAST)
|
|
|
- public void checkOperationArguments_TypedElementReferenceExpression(final ElementReferenceExpression call) {
|
|
|
+ public void checkOperationArguments_TypedElementReferenceExpression(
|
|
|
+ final ElementReferenceExpression call) {
|
|
|
if (call.getReference() instanceof Operation) {
|
|
|
Operation operation = (Operation) call.getReference();
|
|
|
EList<Parameter> parameters = operation.getParameters();
|
|
@@ -154,16 +254,18 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
|
|
|
final String name = getVariableName(exp);
|
|
|
|
|
|
- List<AssignmentExpression> contents = EcoreUtil2.eAllOfType(exp, AssignmentExpression.class);
|
|
|
+ List<AssignmentExpression> contents = EcoreUtil2.eAllOfType(exp,
|
|
|
+ AssignmentExpression.class);
|
|
|
contents.remove(exp);
|
|
|
|
|
|
- Iterable<AssignmentExpression> filter = Iterables.filter(contents, new Predicate<AssignmentExpression>() {
|
|
|
- public boolean apply(final AssignmentExpression ex) {
|
|
|
- String variableName = getVariableName(ex);
|
|
|
- return variableName.equals(name);
|
|
|
+ Iterable<AssignmentExpression> filter = Iterables.filter(contents,
|
|
|
+ new Predicate<AssignmentExpression>() {
|
|
|
+ public boolean apply(final AssignmentExpression ex) {
|
|
|
+ String variableName = getVariableName(ex);
|
|
|
+ return variableName.equals(name);
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
if (Iterables.size(filter) > 0) {
|
|
|
error(ASSIGNMENT_EXPRESSION, null);
|
|
|
}
|
|
@@ -173,9 +275,11 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
Expression varRef = exp.getVarRef();
|
|
|
if (varRef instanceof ElementReferenceExpression
|
|
|
&& ((ElementReferenceExpression) varRef).getReference() instanceof Property) {
|
|
|
- Property reference = (Property) ((ElementReferenceExpression) varRef).getReference();
|
|
|
+ Property reference = (Property) ((ElementReferenceExpression) varRef)
|
|
|
+ .getReference();
|
|
|
return reference.getName();
|
|
|
- } else if (varRef instanceof FeatureCall && ((FeatureCall) varRef).getFeature() instanceof Property) {
|
|
|
+ } else if (varRef instanceof FeatureCall
|
|
|
+ && ((FeatureCall) varRef).getFeature() instanceof Property) {
|
|
|
Property reference = (Property) ((FeatureCall) varRef).getFeature();
|
|
|
return reference.getName();
|
|
|
}
|
|
@@ -188,7 +292,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
return;
|
|
|
}
|
|
|
if (call.getFeature() instanceof Scope) {
|
|
|
- error("A variable, event or operation is required", StextPackage.Literals.FEATURE_CALL__FEATURE,
|
|
|
+ error("A variable, event or operation is required",
|
|
|
+ StextPackage.Literals.FEATURE_CALL__FEATURE,
|
|
|
INSIGNIFICANT_INDEX, FEATURE_CALL_TO_SCOPE);
|
|
|
}
|
|
|
}
|
|
@@ -200,8 +305,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
}
|
|
|
if (call.getReference() instanceof Scope) {
|
|
|
error("A variable, event or operation is required",
|
|
|
- StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE, INSIGNIFICANT_INDEX,
|
|
|
- FEATURE_CALL_TO_SCOPE);
|
|
|
+ StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE,
|
|
|
+ INSIGNIFICANT_INDEX, FEATURE_CALL_TO_SCOPE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -211,9 +316,12 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- InferenceResult result = typeInferrer.inferType(trigger.getGuardExpression());
|
|
|
- if (result.getType() == null || !typeSystem.isBooleanType(result.getType())) {
|
|
|
- error(GUARD_EXPRESSION, StextPackage.Literals.REACTION_TRIGGER__GUARD_EXPRESSION);
|
|
|
+ InferenceResult result = typeInferrer.inferType(trigger
|
|
|
+ .getGuardExpression());
|
|
|
+ if (result.getType() == null
|
|
|
+ || !typeSystem.isBooleanType(result.getType())) {
|
|
|
+ error(GUARD_EXPRESSION,
|
|
|
+ StextPackage.Literals.REACTION_TRIGGER__GUARD_EXPRESSION);
|
|
|
}
|
|
|
report(result, null);
|
|
|
} catch (IllegalArgumentException e) {
|
|
@@ -226,7 +334,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
public void checkTimeEventSpecValueExpression(TimeEventSpec spec) {
|
|
|
try {
|
|
|
InferenceResult result = typeInferrer.inferType(spec.getValue());
|
|
|
- if (result.getType() == null || !typeSystem.isIntegerType(result.getType())) {
|
|
|
+ if (result.getType() == null
|
|
|
+ || !typeSystem.isIntegerType(result.getType())) {
|
|
|
error(TIME_EXPRESSION, null);
|
|
|
}
|
|
|
report(result, StextPackage.Literals.TIME_EVENT_SPEC__VALUE);
|
|
@@ -242,8 +351,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
if (!(reactionTrigger.eContainer() instanceof LocalReaction)
|
|
|
&& (eventSpec instanceof EntryEvent || eventSpec instanceof ExitEvent)) {
|
|
|
error("entry and exit events are allowed as local reactions only.",
|
|
|
- StextPackage.Literals.REACTION_TRIGGER__TRIGGERS, INSIGNIFICANT_INDEX,
|
|
|
- LOCAL_REACTIONS_NOT_ALLOWED);
|
|
|
+ StextPackage.Literals.REACTION_TRIGGER__TRIGGERS,
|
|
|
+ INSIGNIFICANT_INDEX, LOCAL_REACTIONS_NOT_ALLOWED);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -270,15 +379,18 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
public void checkReactionEffectActions(ReactionEffect effect) {
|
|
|
for (Expression exp : effect.getActions()) {
|
|
|
|
|
|
- if (!(exp instanceof AssignmentExpression) && !(exp instanceof EventRaisingExpression)) {
|
|
|
+ if (!(exp instanceof AssignmentExpression)
|
|
|
+ && !(exp instanceof EventRaisingExpression)) {
|
|
|
|
|
|
if (exp instanceof FeatureCall) {
|
|
|
checkFeatureCallEffect((FeatureCall) exp);
|
|
|
} else if (exp instanceof ElementReferenceExpression) {
|
|
|
checkElementReferenceEffect((ElementReferenceExpression) exp);
|
|
|
} else {
|
|
|
- error("Action has no effect.", StextPackage.Literals.REACTION_EFFECT__ACTIONS, effect.getActions()
|
|
|
- .indexOf(exp), FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
+ error("Action has no effect.",
|
|
|
+ StextPackage.Literals.REACTION_EFFECT__ACTIONS,
|
|
|
+ effect.getActions().indexOf(exp),
|
|
|
+ FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -289,17 +401,23 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
if (call.getFeature() != null && call.getFeature() instanceof Feature
|
|
|
&& !(call.getFeature() instanceof Operation)) {
|
|
|
if (call.getFeature() instanceof Property) {
|
|
|
- error("Access to property '" + nameProvider.getFullyQualifiedName(call.getFeature())
|
|
|
- + "' has no effect.", call, StextPackage.Literals.FEATURE_CALL__FEATURE, INSIGNIFICANT_INDEX,
|
|
|
- FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
+ error("Access to property '"
|
|
|
+ + nameProvider.getFullyQualifiedName(call.getFeature())
|
|
|
+ + "' has no effect.", call,
|
|
|
+ StextPackage.Literals.FEATURE_CALL__FEATURE,
|
|
|
+ INSIGNIFICANT_INDEX, FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
} else if (call.getFeature() instanceof Event) {
|
|
|
- error("Access to event '" + nameProvider.getFullyQualifiedName(call.getFeature()) + "' has no effect.",
|
|
|
- call, StextPackage.Literals.FEATURE_CALL__FEATURE, INSIGNIFICANT_INDEX,
|
|
|
- FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
+ error("Access to event '"
|
|
|
+ + nameProvider.getFullyQualifiedName(call.getFeature())
|
|
|
+ + "' has no effect.", call,
|
|
|
+ StextPackage.Literals.FEATURE_CALL__FEATURE,
|
|
|
+ INSIGNIFICANT_INDEX, FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
} else {
|
|
|
- error("Access to feature '" + nameProvider.getFullyQualifiedName(call.getFeature())
|
|
|
- + "' has no effect.", call, StextPackage.Literals.FEATURE_CALL__FEATURE, INSIGNIFICANT_INDEX,
|
|
|
- FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
+ error("Access to feature '"
|
|
|
+ + nameProvider.getFullyQualifiedName(call.getFeature())
|
|
|
+ + "' has no effect.", call,
|
|
|
+ StextPackage.Literals.FEATURE_CALL__FEATURE,
|
|
|
+ INSIGNIFICANT_INDEX, FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -307,16 +425,25 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
protected void checkElementReferenceEffect(ElementReferenceExpression refExp) {
|
|
|
if (!(refExp.getReference() instanceof Operation)) {
|
|
|
if (refExp.getReference() instanceof Property) {
|
|
|
- error("Access to property '" + nameProvider.getFullyQualifiedName(refExp.getReference())
|
|
|
- + "' has no effect.", refExp, StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE,
|
|
|
+ error("Access to property '"
|
|
|
+ + nameProvider.getFullyQualifiedName(refExp
|
|
|
+ .getReference()) + "' has no effect.",
|
|
|
+ refExp,
|
|
|
+ StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE,
|
|
|
INSIGNIFICANT_INDEX, FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
} else if (refExp.getReference() instanceof Event) {
|
|
|
- error("Access to event '" + nameProvider.getFullyQualifiedName(refExp.getReference())
|
|
|
- + "' has no effect.", refExp, StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE,
|
|
|
+ error("Access to event '"
|
|
|
+ + nameProvider.getFullyQualifiedName(refExp
|
|
|
+ .getReference()) + "' has no effect.",
|
|
|
+ refExp,
|
|
|
+ StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE,
|
|
|
INSIGNIFICANT_INDEX, FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
} else {
|
|
|
- error("Access to feature '" + nameProvider.getFullyQualifiedName(refExp.getReference())
|
|
|
- + "' has no effect.", refExp, StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE,
|
|
|
+ error("Access to feature '"
|
|
|
+ + nameProvider.getFullyQualifiedName(refExp
|
|
|
+ .getReference()) + "' has no effect.",
|
|
|
+ refExp,
|
|
|
+ StextPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE,
|
|
|
INSIGNIFICANT_INDEX, FEATURE_CALL_HAS_NO_EFFECT);
|
|
|
}
|
|
|
}
|
|
@@ -324,11 +451,15 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
|
|
|
@Check(CheckType.FAST)
|
|
|
public void checkEventDefinition(EventDefinition event) {
|
|
|
- if (event.eContainer() instanceof InterfaceScope && event.getDirection() == Direction.LOCAL) {
|
|
|
- error(LOCAL_DECLARATIONS, StextPackage.Literals.EVENT_DEFINITION__DIRECTION);
|
|
|
+ if (event.eContainer() instanceof InterfaceScope
|
|
|
+ && event.getDirection() == Direction.LOCAL) {
|
|
|
+ error(LOCAL_DECLARATIONS,
|
|
|
+ StextPackage.Literals.EVENT_DEFINITION__DIRECTION);
|
|
|
}
|
|
|
- if (event.eContainer() instanceof InternalScope && event.getDirection() != Direction.LOCAL) {
|
|
|
- error(IN_OUT_DECLARATIONS, StextPackage.Literals.EVENT_DEFINITION__DIRECTION);
|
|
|
+ if (event.eContainer() instanceof InternalScope
|
|
|
+ && event.getDirection() != Direction.LOCAL) {
|
|
|
+ error(IN_OUT_DECLARATIONS,
|
|
|
+ StextPackage.Literals.EVENT_DEFINITION__DIRECTION);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -337,14 +468,17 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
List<InterfaceScope> defaultInterfaces = new LinkedList<InterfaceScope>();
|
|
|
|
|
|
for (Scope scope : statechart.getScopes()) {
|
|
|
- if (scope instanceof InterfaceScope && ((InterfaceScope) scope).getName() == null) {
|
|
|
+ if (scope instanceof InterfaceScope
|
|
|
+ && ((InterfaceScope) scope).getName() == null) {
|
|
|
defaultInterfaces.add((InterfaceScope) scope);
|
|
|
}
|
|
|
}
|
|
|
if (defaultInterfaces.size() > 1) {
|
|
|
for (InterfaceScope scope : defaultInterfaces) {
|
|
|
- error(ONLY_ONE_INTERFACE, scope, grammarAccess.getInterfaceScopeAccess().getInterfaceKeyword_1(),
|
|
|
- ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ONLY_ONE_INTERFACE);
|
|
|
+ error(ONLY_ONE_INTERFACE, scope, grammarAccess
|
|
|
+ .getInterfaceScopeAccess().getInterfaceKeyword_1(),
|
|
|
+ ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
|
|
|
+ ONLY_ONE_INTERFACE);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -359,19 +493,22 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
}
|
|
|
}
|
|
|
if (!found)
|
|
|
- warning(CHOICE_ONE_OUTGOING_DEFAULT_TRANSITION, SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS);
|
|
|
+ warning(CHOICE_ONE_OUTGOING_DEFAULT_TRANSITION,
|
|
|
+ SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS);
|
|
|
}
|
|
|
|
|
|
protected boolean isDefault(Trigger trigger) {
|
|
|
|
|
|
return trigger == null
|
|
|
|| trigger instanceof DefaultTrigger
|
|
|
- || ((trigger instanceof ReactionTrigger) && ((ReactionTrigger) trigger).getTriggers().size() == 0 && ((ReactionTrigger) trigger)
|
|
|
+ || ((trigger instanceof ReactionTrigger)
|
|
|
+ && ((ReactionTrigger) trigger).getTriggers().size() == 0 && ((ReactionTrigger) trigger)
|
|
|
.getGuardExpression() == null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected String getCurrentLanguage(Map<Object, Object> context, EObject eObject) {
|
|
|
+ protected String getCurrentLanguage(Map<Object, Object> context,
|
|
|
+ EObject eObject) {
|
|
|
Resource eResource = eObject.eResource();
|
|
|
if (eResource instanceof XtextResource) {
|
|
|
return super.getCurrentLanguage(context, eObject);
|
|
@@ -381,19 +518,23 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
- protected void error(String message, EObject source, Keyword keyword, int index, String code) {
|
|
|
+ protected void error(String message, EObject source, Keyword keyword,
|
|
|
+ int index, String code) {
|
|
|
final String[] issueData = null;
|
|
|
ICompositeNode rootNode = NodeModelUtils.findActualNodeFor(source);
|
|
|
if (rootNode != null) {
|
|
|
- INode child = findNode(source, false, rootNode, keyword, new int[] { index });
|
|
|
+ INode child = findNode(source, false, rootNode, keyword,
|
|
|
+ new int[] { index });
|
|
|
if (child != null) {
|
|
|
int offset = child.getTotalOffset();
|
|
|
int length = child.getTotalLength();
|
|
|
- getMessageAcceptor().acceptError(message, source, offset, length, code, issueData);
|
|
|
+ getMessageAcceptor().acceptError(message, source, offset,
|
|
|
+ length, code, issueData);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- error(message, source, (EStructuralFeature) null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, code);
|
|
|
+ error(message, source, (EStructuralFeature) null,
|
|
|
+ ValidationMessageAcceptor.INSIGNIFICANT_INDEX, code);
|
|
|
}
|
|
|
|
|
|
protected void report(InferenceResult result, EStructuralFeature feature) {
|
|
@@ -405,7 +546,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private INode findNode(EObject source, boolean sourceFound, INode root, Keyword keyword, int[] index) {
|
|
|
+ private INode findNode(EObject source, boolean sourceFound, INode root,
|
|
|
+ Keyword keyword, int[] index) {
|
|
|
if (sourceFound && root.getSemanticElement() != source) {
|
|
|
return null;
|
|
|
}
|
|
@@ -416,7 +558,9 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
// .equals or == does not work because sub grammars use their own
|
|
|
// Modules with custom
|
|
|
// grammarAccess instance and .equals is not overwritten.
|
|
|
- if (grammarElement instanceof Keyword && keyword.getValue().equals(((Keyword) grammarElement).getValue())) {
|
|
|
+ if (grammarElement instanceof Keyword
|
|
|
+ && keyword.getValue().equals(
|
|
|
+ ((Keyword) grammarElement).getValue())) {
|
|
|
if (index[0] != INSIGNIFICANT_INDEX) {
|
|
|
index[0]--;
|
|
|
}
|
|
@@ -427,7 +571,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
|
|
|
if (root instanceof ICompositeNode) {
|
|
|
ICompositeNode node = (ICompositeNode) root;
|
|
|
for (INode child : node.getChildren()) {
|
|
|
- INode result = findNode(source, sourceFound, child, keyword, index);
|
|
|
+ INode result = findNode(source, sourceFound, child, keyword,
|
|
|
+ index);
|
|
|
if (result != null) {
|
|
|
return result;
|
|
|
}
|