Просмотр исходного кода

Removed contextPredicateProvider from scope, added it to validation

Andreas Muelder 9 лет назад
Родитель
Сommit
5eca81cd1a

+ 30 - 12
plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/contentassist/STextProposalProvider.java

@@ -13,7 +13,6 @@ package org.yakindu.sct.model.stext.ui.contentassist;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.regex.Pattern;
 
 import org.eclipse.emf.common.util.BasicEList;
 import org.eclipse.emf.common.util.EList;
@@ -22,6 +21,8 @@ import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
 import org.eclipse.emf.edit.provider.IItemLabelProvider;
 import org.eclipse.jface.text.contentassist.ICompletionProposal;
 import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.xtext.Assignment;
+import org.eclipse.xtext.CrossReference;
 import org.eclipse.xtext.EnumLiteralDeclaration;
 import org.eclipse.xtext.Keyword;
 import org.eclipse.xtext.RuleCall;
@@ -32,6 +33,7 @@ import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
 import org.eclipse.xtext.ui.editor.contentassist.ContentProposalLabelProvider;
 import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
 import org.yakindu.base.expressions.expressions.ElementReferenceExpression;
+import org.yakindu.base.expressions.expressions.ExpressionsPackage;
 import org.yakindu.base.expressions.expressions.FeatureCall;
 import org.yakindu.base.types.Operation;
 import org.yakindu.base.types.Type;
@@ -42,8 +44,10 @@ import org.yakindu.sct.model.stext.stext.SimpleScope;
 import org.yakindu.sct.model.stext.stext.StatechartSpecification;
 import org.yakindu.sct.model.stext.stext.TransitionSpecification;
 import org.yakindu.sct.model.stext.stext.VariableDefinition;
+import org.yakindu.sct.model.stext.validation.ContextPredicateProvider;
 
 import com.google.common.base.Function;
+import com.google.common.base.Predicate;
 import com.google.inject.Inject;
 
 /**
@@ -53,10 +57,6 @@ import com.google.inject.Inject;
  */
 public class STextProposalProvider extends AbstractSTextProposalProvider {
 
-	private static final int OPERATION_PATTERN_OP_PARAMS = 1;
-
-	private static final Pattern OPERATION_PATTERN = Pattern.compile(".*\\((.*)\\).*");
-
 	@Inject
 	protected STextGrammarAccess grammarAccess;
 	private ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory(
@@ -138,7 +138,8 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 
 	protected void suppressKeywords(List<Keyword> suppressKeywords, FeatureCall featureCall) {
 		if (!(featureCall.getFeature() instanceof Operation)) {
-			suppressKeywords.add(grammarAccess.getFeatureCallAccess().getOperationCallLeftParenthesisKeyword_1_3_0_0_0());
+			suppressKeywords
+					.add(grammarAccess.getFeatureCallAccess().getOperationCallLeftParenthesisKeyword_1_3_0_0_0());
 		}
 	}
 
@@ -190,6 +191,16 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		};
 	}
 
+	@Inject
+	private ContextPredicateProvider contextProvider;
+
+	public void completeElementReferenceExpression_Reference(EObject model, Assignment assignment,
+			ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
+		Predicate<IEObjectDescription> predicate = contextProvider.calculateFilterPredicate(context.getCurrentModel(),
+				ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE);
+		lookupCrossReference(((CrossReference) assignment.getTerminal()), context, acceptor, predicate);
+	}
+
 	@Override
 	public void complete_BOOL(EObject model, RuleCall ruleCall, ContentAssistContext context,
 			ICompletionProposalAcceptor acceptor) {
@@ -226,8 +237,8 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		if (element instanceof Type) {
 			return super.getDisplayString(element, qualifiedNameAsString, shortName);
 		}
-		
-		if(element == null || element.eIsProxy()){
+
+		if (element == null || element.eIsProxy()) {
 			return qualifiedNameAsString;
 		}
 		IItemLabelProvider adapter = (IItemLabelProvider) composedAdapterFactory.adapt(element,
@@ -238,6 +249,13 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		return super.getDisplayString(element, qualifiedNameAsString, shortName);
 	}
 
+	@Override
+	public void complete_ElementReferenceExpression(EObject model, RuleCall ruleCall, ContentAssistContext context,
+			ICompletionProposalAcceptor acceptor) {
+		// TODO Auto-generated method stub
+		super.complete_ElementReferenceExpression(model, ruleCall, context, acceptor);
+	}
+
 	@Override
 	public void complete_STRING(EObject model, RuleCall ruleCall, ContentAssistContext context,
 			ICompletionProposalAcceptor acceptor) {
@@ -262,8 +280,8 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		ICompletionProposalAcceptor priorityOptimizer = getCustomAcceptor(model, "integer", acceptor);
 
 		String proposalText = "0x1";
-		ICompletionProposal proposal = createCompletionProposal(proposalText, proposalText + " - "
-				+ ruleCall.getRule().getName(), null, context);
+		ICompletionProposal proposal = createCompletionProposal(proposalText,
+				proposalText + " - " + ruleCall.getRule().getName(), null, context);
 
 		if (proposal instanceof ConfigurableCompletionProposal) {
 			ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal;
@@ -282,8 +300,8 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		ICompletionProposalAcceptor priorityOptimizer = getCustomAcceptor(model, "real", acceptor);
 
 		String proposalText = "0.1";
-		ICompletionProposal proposal = createCompletionProposal(proposalText, proposalText + " - "
-				+ ruleCall.getRule().getName(), null, context);
+		ICompletionProposal proposal = createCompletionProposal(proposalText,
+				proposalText + " - " + ruleCall.getRule().getName(), null, context);
 		priorityOptimizer.accept(proposal);
 	}
 

+ 19 - 68
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -20,12 +20,9 @@ import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.xtext.EcoreUtil2;
-import org.eclipse.xtext.resource.IEObjectDescription;
 import org.eclipse.xtext.scoping.IScope;
 import org.eclipse.xtext.scoping.Scopes;
 import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
-import org.eclipse.xtext.scoping.impl.FilteringScope;
-import org.eclipse.xtext.scoping.impl.SimpleScope;
 import org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler;
 import org.yakindu.base.expressions.expressions.ElementReferenceExpression;
 import org.yakindu.base.expressions.expressions.Expression;
@@ -40,12 +37,9 @@ import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Scope;
 import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.model.sgraph.util.ContextElementAdapter;
-import org.yakindu.sct.model.stext.scoping.ContextPredicateProvider.EmptyPredicate;
 import org.yakindu.sct.model.stext.stext.InterfaceScope;
 import org.yakindu.sct.model.stext.stext.InternalScope;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.inject.Inject;
 
@@ -60,9 +54,9 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 
 	@Inject
 	private ITypeSystemInferrer typeInferrer;
-	@Inject 
+	@Inject
 	private ITypeSystem typeSystem;
-	
+
 	private static class ErrorHandlerDelegate<T> implements ErrorHandler<T> {
 
 		private ErrorHandler<T> delegate;
@@ -83,7 +77,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		}
 
 	}
-	
+
 	@Override
 	public IScope getScope(EObject context, EReference reference) {
 		try {
@@ -98,31 +92,17 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		}
 	}
 
-	@Inject
-	private ContextPredicateProvider predicateProvider;
-
-	/**
-	 * Scoping for types and taking imported namespaces into account e.g. in
-	 * variable declarations.
-	 */
 	public IScope scope_TypeSpecifier_type(final EObject context, EReference reference) {
-		IScope scope = getDelegate().getScope(context, reference);
-		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
-		return new FilteringScope(scope, predicate);
+		return getDelegate().getScope(context, reference);
 	}
 
 	public IScope scope_ElementReferenceExpression_reference(final EObject context, EReference reference) {
-		IScope namdScope = getNamedTopLevelScope(context, reference);
-		IScope unnamedScope = getUnnamedTopLevelScope(context, reference);
-		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
-		unnamedScope = new FilteringScope(unnamedScope, predicate);
-		return new SimpleScope(Iterables.concat(namdScope.getAllElements(), unnamedScope.getAllElements()));
+		IScope scope = getUnnamedTopLevelScope(context, reference);
+		scope = getNamedTopLevelScope(context, reference, scope);
+		return scope;
 	}
 
 	public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
-
-		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
-
 		Expression owner = context.getOwner();
 		EObject element = null;
 		if (owner instanceof ElementReferenceExpression) {
@@ -138,53 +118,30 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		Type ownerType = result != null ? result.getType() : null;
 
 		if (element instanceof Scope) {
-			scope = Scopes.scopeFor(((Scope) element).getDeclarations());
-			return new FilteringScope(scope, predicate);
-		}else if(ownerType != null){
+			return Scopes.scopeFor(((Scope) element).getDeclarations());
+		} else if (ownerType != null) {
 			scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
-			scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType),scope);
+			scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType), scope);
 		}
-		
+
 		if (ownerType instanceof ComplexType) {
-			return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
+			return addScopeForComplexType((ComplexType) ownerType, scope);
 		}
 		if (ownerType instanceof EnumerationType) {
-			return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
+			return addScopeForEnumType((EnumerationType) ownerType, scope);
 		}
 		return scope;
 	}
 
-	protected IScope addScopeForEnumType(EnumerationType element, IScope scope, final Predicate<IEObjectDescription> predicate) {
-		scope = Scopes.scopeFor((element).getEnumerator(), scope);
-		scope = new FilteringScope(scope, predicate);
-		return scope;
-	}
-
-	protected IScope addScopeForComplexType(final ComplexType type, IScope scope, final Predicate<IEObjectDescription> predicate) {
-		scope = Scopes.scopeFor(type.getAllFeatures(), scope);
-		scope = new FilteringScope(scope, predicate);
-		return scope;
+	protected IScope addScopeForEnumType(EnumerationType element, IScope scope) {
+		return Scopes.scopeFor((element).getEnumerator(), scope);
 	}
 
-	private Predicate<IEObjectDescription> calculateFilterPredicate(final EObject context, final EReference reference) {
-		Predicate<IEObjectDescription> predicate = null;
-		EObject container = context;
-		EReference ref = reference;
-		while (container != null) {
-			predicate = predicateProvider.getPredicate(container.eClass(), ref);
-			if (!(predicate instanceof EmptyPredicate)) {
-				break;
-			}
-			ref = (EReference) container.eContainingFeature();
-			container = container.eContainer();
-		}
-		return predicate;
+	protected IScope addScopeForComplexType(final ComplexType type, IScope scope) {
+		return Scopes.scopeFor(type.getAllFeatures(), scope);
 	}
 
-	/**
-	 * Returns the toplevel scope
-	 */
-	protected IScope getNamedTopLevelScope(final EObject context, EReference reference) {
+	protected IScope getNamedTopLevelScope(final EObject context, EReference reference, IScope outer) {
 		List<EObject> scopeCandidates = Lists.newArrayList();
 		Statechart statechart = getStatechart(context);
 		if (statechart == null)
@@ -198,12 +155,9 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 				}
 			}
 		}
-		return Scopes.scopeFor(scopeCandidates);
+		return Scopes.scopeFor(scopeCandidates, outer);
 	}
 
-	/**
-	 * Returns a scope with all toplevel declarations of unnamed scope
-	 */
 	protected IScope getUnnamedTopLevelScope(final EObject context, EReference reference) {
 		List<EObject> scopeCandidates = Lists.newArrayList();
 		Statechart statechart = getStatechart(context);
@@ -226,9 +180,6 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		return Scopes.scopeFor(scopeCandidates, scope);
 	}
 
-	/**
-	 * Returns the {@link Statechart} for a context element
-	 */
 	protected Statechart getStatechart(EObject context) {
 		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context.eResource(),
 				ContextElementAdapter.class);

+ 36 - 27
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/ContextPredicateProvider.java

@@ -8,7 +8,7 @@
  * Contributors:
  *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.model.stext.scoping;
+package org.yakindu.sct.model.stext.validation;
 
 import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION;
 import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION__EXPRESSION;
@@ -32,10 +32,10 @@ import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.EVENT_VALU
 import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.LOCAL_REACTION;
 import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.REACTION_EFFECT;
 import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.REGULAR_EVENT_SPEC;
+import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.STATE_SPECIFICATION;
 import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.TRANSITION_REACTION;
 import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.TRANSITION_SPECIFICATION;
 import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.VARIABLE_DEFINITION;
-import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.STATE_SPECIFICATION;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -46,10 +46,8 @@ import org.eclipse.emf.ecore.EReference;
 import org.eclipse.xtext.resource.IEObjectDescription;
 import org.eclipse.xtext.util.Pair;
 import org.eclipse.xtext.util.Tuples;
-import org.yakindu.base.types.ComplexType;
-import org.yakindu.base.types.TypedElement;
 import org.yakindu.base.types.TypesPackage;
-import org.yakindu.sct.model.stext.stext.StextPackage;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -63,15 +61,18 @@ public class ContextPredicateProvider {
 
 	public static class TypePredicate implements Predicate<IEObjectDescription> {
 		public boolean apply(IEObjectDescription input) {
-			return TypesPackage.Literals.TYPE.isSuperTypeOf(input.getEClass())
-					&& !TypesPackage.Literals.TYPE_PARAMETER.isSuperTypeOf(input.getEClass());
+			EClass eClass = input.getEClass();
+			return TypesPackage.Literals.TYPE.isSuperTypeOf(eClass)
+					&& !TypesPackage.Literals.TYPE_PARAMETER.isSuperTypeOf(eClass);
 		}
 	}
 
 	public static class FeaturedTypePredicate implements Predicate<IEObjectDescription> {
 		public boolean apply(IEObjectDescription input) {
-			return TypesPackage.Literals.TYPE.isSuperTypeOf(input.getEClass())
-					&& TypesPackage.Literals.DECLARATION.isSuperTypeOf(input.getEClass());
+			EClass eClass = input.getEClass();
+			return SGraphPackage.Literals.SCOPE.isSuperTypeOf(eClass)
+					|| (TypesPackage.Literals.TYPE.isSuperTypeOf(eClass)
+							&& TypesPackage.Literals.DECLARATION.isSuperTypeOf(eClass));
 		}
 	}
 
@@ -80,16 +81,7 @@ public class ContextPredicateProvider {
 		public boolean apply(IEObjectDescription input) {
 			if (super.apply(input))
 				return true;
-			return TypesPackage.Literals.EVENT.isSuperTypeOf(input.getEClass()) || isComplexTypeVariable(input);
-		}
-
-		protected boolean isComplexTypeVariable(IEObjectDescription input) {
-			if (StextPackage.Literals.VARIABLE_DEFINITION.isSuperTypeOf(input.getEClass())) {
-				TypedElement definition = (TypedElement) input.getEObjectOrProxy();
-				EObject element = (EObject) definition.eGet(TypesPackage.Literals.TYPED_ELEMENT__TYPE, false);
-				return (element != null && !element.eIsProxy() && definition.getType() instanceof ComplexType);
-			}
-			return false;
+			return TypesPackage.Literals.EVENT.isSuperTypeOf(input.getEClass());
 		}
 	}
 
@@ -108,8 +100,9 @@ public class ContextPredicateProvider {
 		public boolean apply(IEObjectDescription input) {
 			if (super.apply(input))
 				return true;
-			return (TypesPackage.Literals.PROPERTY.isSuperTypeOf(input.getEClass()) || TypesPackage.Literals.OPERATION
-					.isSuperTypeOf(input.getEClass()));
+			EClass eClass = input.getEClass();
+			return (TypesPackage.Literals.PROPERTY.isSuperTypeOf(eClass)
+					|| TypesPackage.Literals.OPERATION.isSuperTypeOf(eClass));
 		}
 	}
 
@@ -118,11 +111,12 @@ public class ContextPredicateProvider {
 		public boolean apply(IEObjectDescription input) {
 			if (super.apply(input))
 				return true;
-			return (TypesPackage.Literals.PROPERTY.isSuperTypeOf(input.getEClass()) //
-					|| TypesPackage.Literals.OPERATION.isSuperTypeOf(input.getEClass()) //
-					|| TypesPackage.Literals.EVENT.isSuperTypeOf(input.getEClass()) //
-					|| TypesPackage.Literals.ENUMERATOR.isSuperTypeOf(input.getEClass()) //
-					|| TypesPackage.Literals.ENUMERATION_TYPE.isSuperTypeOf(input.getEClass()));
+			EClass eClass = input.getEClass();
+			return (TypesPackage.Literals.PROPERTY.isSuperTypeOf(eClass)
+					|| TypesPackage.Literals.OPERATION.isSuperTypeOf(eClass)
+					|| TypesPackage.Literals.EVENT.isSuperTypeOf(eClass)
+					|| TypesPackage.Literals.ENUMERATOR.isSuperTypeOf(eClass)
+					|| TypesPackage.Literals.ENUMERATION_TYPE.isSuperTypeOf(eClass));
 		}
 	}
 
@@ -187,7 +181,7 @@ public class ContextPredicateProvider {
 		filter.put(key(STATE_SPECIFICATION), EVENTS);
 	}
 
-	public Predicate<IEObjectDescription> getPredicate(EClass clazz, EReference reference) {
+	protected Predicate<IEObjectDescription> getPredicate(EClass clazz, EReference reference) {
 		Predicate<IEObjectDescription> predicate = filter.get(key(clazz, reference));
 		if (predicate == null) {
 			predicate = filter.get(key(clazz, null));
@@ -197,4 +191,19 @@ public class ContextPredicateProvider {
 		}
 		return predicate;
 	}
+
+	public Predicate<IEObjectDescription> calculateFilterPredicate(final EObject context, final EReference reference) {
+		Predicate<IEObjectDescription> predicate = null;
+		EObject container = context;
+		EReference ref = reference;
+		while (container != null) {
+			predicate = getPredicate(container.eClass(), ref);
+			if (!(predicate instanceof EmptyPredicate)) {
+				break;
+			}
+			ref = (EReference) container.eContainingFeature();
+			container = container.eContainer();
+		}
+		return predicate;
+	}
 }

+ 40 - 21
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

@@ -33,6 +33,8 @@ import org.eclipse.xtext.naming.QualifiedName;
 import org.eclipse.xtext.nodemodel.ICompositeNode;
 import org.eclipse.xtext.nodemodel.INode;
 import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.resource.EObjectDescription;
+import org.eclipse.xtext.resource.IEObjectDescription;
 import org.eclipse.xtext.resource.XtextResource;
 import org.eclipse.xtext.validation.Check;
 import org.eclipse.xtext.validation.CheckType;
@@ -54,7 +56,6 @@ import org.yakindu.base.types.Operation;
 import org.yakindu.base.types.Parameter;
 import org.yakindu.base.types.Property;
 import org.yakindu.base.types.TypesPackage;
-import org.yakindu.base.types.annotations.TypeAnnotations;
 import org.yakindu.base.types.inferrer.ITypeSystemInferrer;
 import org.yakindu.sct.domain.extension.DomainRegistry;
 import org.yakindu.sct.model.sgraph.Choice;
@@ -127,6 +128,21 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 	@Inject(optional = true)
 	@Named(DomainRegistry.DOMAIN_ID)
 	private String domainID = BasePackage.Literals.DOMAIN_ELEMENT__DOMAIN_ID.getDefaultValueLiteral();
+	@Inject
+	private ContextPredicateProvider contextPredicateProvider;
+
+	@Check
+	public void checkContextElement(ElementReferenceExpression expression) {
+		Predicate<IEObjectDescription> predicate = contextPredicateProvider.calculateFilterPredicate(expression,
+				ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE);
+
+		IEObjectDescription desc = EObjectDescription
+				.create(nameProvider.getFullyQualifiedName(expression.getReference()), expression.getReference());
+		if (!predicate.apply(desc)) {
+			error("Element of type " + expression.getReference().eClass().getName()
+					+ " is not allowed in this context.", null);
+		}
+	}
 
 	@Check
 	public void checkExpression(VariableDefinition expression) {
@@ -144,27 +160,27 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 	public void checkExpression(Guard expression) {
 		typeInferrer.infer(expression, this);
 	}
-	
+
 	@Check
 	public void checkNoAssignmentInGuard(Guard guard) {
 		TreeIterator<EObject> eAllContents = guard.eAllContents();
-		while(eAllContents.hasNext()) {
+		while (eAllContents.hasNext()) {
 			EObject e = eAllContents.next();
-			if(e instanceof AssignmentExpression) {
+			if (e instanceof AssignmentExpression) {
 				error(GUARD_CONTAINS_ASSIGNMENT, guard, null);
 			}
 		}
 	}
-	
+
 	@Check(CheckType.FAST)
 	public void transitionsWithNoTrigger(Transition trans) {
 
-		if (trans.getSource() instanceof Entry 
-			|| trans.getSource() instanceof Choice
-			|| trans.getSource() instanceof Synchronization
-			|| (trans.getTarget() instanceof Synchronization && (trans.getTarget().getIncomingTransitions().size() > 1))
-			) { return; }
-		
+		if (trans.getSource() instanceof Entry || trans.getSource() instanceof Choice
+				|| trans.getSource() instanceof Synchronization || (trans.getTarget() instanceof Synchronization
+						&& (trans.getTarget().getIncomingTransitions().size() > 1))) {
+			return;
+		}
+
 		if (trans.getSource() instanceof org.yakindu.sct.model.sgraph.State) {
 			org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) trans.getSource();
 			if (state.isComposite()) {
@@ -217,7 +233,7 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 		Expression varRef = expression.getVarRef();
 		if (varRef instanceof FeatureCall) {
 			EObject referencedObject = ((FeatureCall) varRef).getFeature();
-		 if (!(referencedObject instanceof Property)) {
+			if (!(referencedObject instanceof Property)) {
 				error(LEFT_HAND_ASSIGNMENT, ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION__VAR_REF);
 			}
 		} else if (varRef instanceof ElementReferenceExpression) {
@@ -496,26 +512,28 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 			}
 		}
 	}
+
 	@Check(CheckType.FAST)
 	public void checkTopLeveEntryIsDefaultEntry(final Entry entry) {
 		Region parentRegion = entry.getParentRegion();
 		EObject eContainer = parentRegion.eContainer();
-	
+
 		boolean isTopLevelRegionEntry = eContainer instanceof Statechart;
 
-		//1. check if is toplevel
+		// 1. check if is toplevel
 		if (isTopLevelRegionEntry) {
 			boolean isDefaultEntry = STextValidationModelUtils.isDefault(entry);
-			//2. check if is default entry
+			// 2. check if is default entry
 			if (!isDefaultEntry) {
-				Map<Region, List<Entry>> regionsWithoutDefaultEntry = STextValidationModelUtils.getRegionsWithoutDefaultEntry(Lists.newArrayList(parentRegion));
+				Map<Region, List<Entry>> regionsWithoutDefaultEntry = STextValidationModelUtils
+						.getRegionsWithoutDefaultEntry(Lists.newArrayList(parentRegion));
 				List<Entry> list = regionsWithoutDefaultEntry.get(parentRegion);
-				if(list!=null)
-					error(TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY, entry,
-							SGraphPackage.Literals.ENTRY__KIND,-1);
+				if (list != null)
+					error(TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY, entry, SGraphPackage.Literals.ENTRY__KIND,
+							-1);
 				else
 					warning(TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY, entry,
-							SGraphPackage.Literals.ENTRY__KIND,-1);
+							SGraphPackage.Literals.ENTRY__KIND, -1);
 			}
 		}
 	}
@@ -723,7 +741,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 		if (!found)
 			warning(CHOICE_ONE_OUTGOING_DEFAULT_TRANSITION, SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS);
 	}
-	//TODO Extract TypesValidator
+
+	// TODO Extract TypesValidator
 	@Check
 	public void checkAnnotationTarget(final AnnotatableElement element) {
 		EList<Annotation> annotations = element.getAnnotations();