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

Provide string based imports (#1382)

* Yakindu/sctpro#694 : changed cross referencing import to string import

* Yakindu/sctpro#694: navigate to imported 'string' header

* Yakindu/sctpro#694 : fixed import scope mapping

* #694 : fix code quality issues

* https://www.codacy.com/app/a.muelder/statecharts/pullRequest?prid=675461

* #694 : fix code quality issues

* https://www.codacy.com/app/a.muelder/statecharts/pullRequest?prid=675461

* #694 : fix code quality issues

* https://www.codacy.com/app/a.muelder/statecharts/pullRequest?prid=675461

* Yakindu/sctpro#694 : remove ImportResolver, replace by
IPackageImport2URIMapper

* #694 : dispatch import decl creation properly

* #694 : add import EObject

* #694 : fix execution slot resolving

* #694 : handle element ref expressions without reference

* will be the case for e.g. stdio.h imports in c domain where some
expressions are used from other system headers.

* inferring is not necessary for now because we just loose type safety
at some points

* Yakindu/sctpro#694 : moved into CStext

* Yakindu/sctpro#694 : fix codacy issues

* https://www.codacy.com/app/a.muelder/statecharts/pullRequest?prid=675461

* Yakindu/sctpro#694 : enable possibility to open external resources
Johannes Dicks 8 лет назад
Родитель
Сommit
6a31814d1b
22 измененных файлов с 7872 добавлено и 7773 удалено
  1. 1 1
      plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/inferrer/ExpressionsTypeInferrer.java
  2. 28 15
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/StructureMapping.xtend
  3. 7 1
      plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/STextUiModule.java
  4. 67 0
      plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/hyperlink/PackageImportHyperlinkHelper.java
  5. 0 1
      plugins/org.yakindu.sct.model.stext/META-INF/MANIFEST.MF
  6. 40 40
      plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/ImportScope.java
  7. 2744 2744
      plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/StextPackage.java
  8. 144 128
      plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/ImportScopeImpl.java
  9. 592 591
      plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/StextFactoryImpl.java
  10. 1250 1250
      plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/StextPackageImpl.java
  11. 1164 1163
      plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/util/StextAdapterFactory.java
  12. 1261 1260
      plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/util/StextSwitch.java
  13. 111 111
      plugins/org.yakindu.sct.model.stext/model/SText.ecore
  14. 182 182
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/SText.xtext
  15. 127 0
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/IPackageImport2URIMapper.java
  16. 12 10
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java
  17. 137 135
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/StextImportAwareScopeProvider.java
  18. 0 128
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/util/ImportResolver.java
  19. 3 0
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java
  20. 1 3
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java
  21. 0 1
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/DefaultExecutionContextInitializer.xtend
  22. 1 9
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/DefaultExecutionSlotResolver.xtend

+ 1 - 1
plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/inferrer/ExpressionsTypeInferrer.java

@@ -234,7 +234,7 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
 
 	public InferenceResult doInfer(ElementReferenceExpression e) {
 		if (e.isOperationCall()) {
-			if (!e.getReference().eIsProxy()) {
+			if (e.getReference() != null && !e.getReference().eIsProxy()) {
 				return inferOperation(e, (Operation) e.getReference(),
 						Maps.<TypeParameter, InferenceResult> newHashMap());
 			} else {

+ 28 - 15
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/StructureMapping.xtend

@@ -12,6 +12,7 @@ package org.yakindu.sct.model.sexec.transformation
 
 import com.google.inject.Inject
 import java.util.ArrayList
+import org.eclipse.emf.ecore.resource.URIConverter
 import org.eclipse.xtext.EcoreUtil2
 import org.eclipse.xtext.naming.IQualifiedNameProvider
 import org.yakindu.base.types.Declaration
@@ -31,18 +32,20 @@ import org.yakindu.sct.model.sgraph.Scope
 import org.yakindu.sct.model.sgraph.State
 import org.yakindu.sct.model.sgraph.Statechart
 import org.yakindu.sct.model.sgraph.Vertex
+import org.yakindu.sct.model.stext.scoping.IPackageImport2URIMapper
 import org.yakindu.sct.model.stext.stext.EventDefinition
 import org.yakindu.sct.model.stext.stext.ImportScope
 import org.yakindu.sct.model.stext.stext.OperationDefinition
 import org.yakindu.sct.model.stext.stext.VariableDefinition
-import org.yakindu.sct.model.stext.util.ImportResolver
+import org.eclipse.emf.ecore.EObject
 
 class StructureMapping {
 	 
 	@Inject extension SexecElementMapping mapping
 	@Inject extension StatechartExtensions sct
 	@Inject extension IQualifiedNameProvider
-	@Inject ImportResolver resolver
+	@Inject
+	private IPackageImport2URIMapper mapper;
 	
 	
 	//==========================================================================
@@ -73,27 +76,37 @@ class StructureMapping {
 	 */
 	def dispatch Scope mapScope(ImportScope scope) {
 		val _scope = scope.createScope
-		for (Package imp : scope.imports) {
-			val props = resolver.getImportedElementsOfType(imp, Property)
-			for (Declaration decl : props) {
-				_scope.declarations.add(decl.createImportDeclaration)
-			}
-			val operations = resolver.getImportedElementsOfType(imp, Operation) 
-			for (Declaration decl : operations) {
-				_scope.declarations.add(decl.createImportDeclaration)
+		for (String importString : scope.imports){
+			val pkgImport = mapper.findPackageImport(scope.eResource,importString)
+			
+			if (pkgImport !== null && URIConverter.INSTANCE.exists(pkgImport.getUri(), null)) {
+				val packageForNamespace = scope.eResource.resourceSet.getResource(pkgImport.uri, true).contents.
+					head as Package
+				packageForNamespace.eAllContents.filter(Declaration).toList.forEach[createImportDeclaration(_scope)]
 			}
 		}
 		return _scope
 	}
 	
-	protected def createImportDeclaration(Declaration decl) {
-		val importDecl = SGraphFactory.eINSTANCE.createImportDeclaration
-		importDecl.name = decl.name
-		importDecl.declaration = decl
-		importDecl
+	protected dispatch def createImportDeclaration(Property decl, Scope scope) {
+		decl.doCreateAndAddImportDecl(scope)
+	}
+
+	protected dispatch def createImportDeclaration(Operation decl, Scope scope) {
+		decl.doCreateAndAddImportDecl(scope)
 	}
 	
+	protected def doCreateAndAddImportDecl(Declaration decl, Scope scope){
+		scope.declarations += SGraphFactory.eINSTANCE.createImportDeclaration => [
+			name = decl.name
+			declaration = decl
+		]
+	}
 	
+	protected dispatch def createImportDeclaration(EObject decl, Scope scope) {
+		// Nothing to do
+	}
+
 	def dispatch Declaration map(Declaration decl) {
 	}
 	

+ 7 - 1
plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/STextUiModule.java

@@ -20,6 +20,7 @@ import org.eclipse.xtext.ui.editor.hover.DispatchingEObjectTextHover;
 import org.eclipse.xtext.ui.editor.hover.IEObjectHover;
 import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider;
 import org.eclipse.xtext.ui.editor.hover.ProblemAnnotationHover;
+import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkHelper;
 import org.eclipse.xtext.ui.editor.model.IResourceForEditorInputFactory;
 import org.eclipse.xtext.ui.editor.model.JavaClassPathResourceForIEditorInputFactory;
 import org.eclipse.xtext.ui.editor.model.ResourceForIEditorInputFactory;
@@ -33,6 +34,7 @@ import org.yakindu.sct.model.stext.ui.contentassist.STextStatefulFactory;
 import org.yakindu.sct.model.stext.ui.help.CustomCSSHelpHoverProvider;
 import org.yakindu.sct.model.stext.ui.help.STextUserHelpDocumentationProvider;
 import org.yakindu.sct.model.stext.ui.highlighting.SCTHighlightingConfiguration;
+import org.yakindu.sct.model.stext.ui.hyperlink.PackageImportHyperlinkHelper;
 import org.yakindu.sct.model.stext.ui.tasks.STextTaskFinder;
 
 import com.google.inject.Binder;
@@ -113,9 +115,13 @@ public class STextUiModule extends org.yakindu.sct.model.stext.ui.AbstractSTextU
 	public Class<? extends ITaskFinder> bindITaskFinder() {
 		return STextTaskFinder.class;
 	}
-	
+
 	public Class<? extends IResourceClusteringPolicy> bindIResourceClusteringPolicy() {
 		return DynamicResourceClusteringPolicy.class;
 	}
 
+	public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() {
+		return PackageImportHyperlinkHelper.class;
+	}
+
 }

+ 67 - 0
plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/hyperlink/PackageImportHyperlinkHelper.java

@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.model.stext.ui.hyperlink;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.text.Region;
+import org.eclipse.xtext.RuleCall;
+import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.ui.editor.hyperlinking.HyperlinkHelper;
+import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkAcceptor;
+import org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink;
+import org.yakindu.base.types.TypesPackage;
+import org.yakindu.sct.model.stext.scoping.IPackageImport2URIMapper;
+import org.yakindu.sct.model.stext.scoping.IPackageImport2URIMapper.PackageImport;
+import org.yakindu.sct.model.stext.stext.ImportScope;
+
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class PackageImportHyperlinkHelper extends HyperlinkHelper {
+
+	@Inject
+	private IPackageImport2URIMapper mapper;
+
+	public void createHyperlinksByOffset(XtextResource resource, int offset, IHyperlinkAcceptor acceptor) {
+		createPackageImportHyperlinksByOffset(resource, offset, acceptor);
+		super.createHyperlinksByOffset(resource, offset, acceptor);
+	}
+
+	protected void createPackageImportHyperlinksByOffset(XtextResource resource, int offset,
+			IHyperlinkAcceptor acceptor) {
+		INode node = NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
+		if (node != null && node.getGrammarElement() instanceof RuleCall
+				&& node.getSemanticElement() instanceof ImportScope) {
+			NodeModelUtils.findNodesForFeature(node.getSemanticElement(), TypesPackage.Literals.PACKAGE__IMPORT);
+			ImportScope importScope = (ImportScope) node.getSemanticElement();
+			EList<String> imports = importScope.getImports();
+			for (String pkgImport : imports) {
+				PackageImport mappedImport = mapper.findPackageImport(resource, pkgImport);
+				final URI targetURI = mappedImport.getUri();
+				XtextHyperlink result = getHyperlinkProvider().get();
+				result.setURI(targetURI);
+				Region region = new Region(node.getOffset(), node.getLength());
+				result.setHyperlinkRegion(region);
+				result.setHyperlinkText(targetURI.toString());
+				acceptor.accept(result);
+			}
+
+		}
+
+	}
+}

+ 0 - 1
plugins/org.yakindu.sct.model.stext/META-INF/MANIFEST.MF

@@ -39,6 +39,5 @@ Export-Package: org.yakindu.sct.model.stext,
  org.yakindu.sct.model.stext.stext,
  org.yakindu.sct.model.stext.stext.impl,
  org.yakindu.sct.model.stext.stext.util,
- org.yakindu.sct.model.stext.util,
  org.yakindu.sct.model.stext.validation
 Bundle-ClassPath: .

+ 40 - 40
plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/ImportScope.java

@@ -1,40 +1,40 @@
-/**
- */
-package org.yakindu.sct.model.stext.stext;
-
-import org.eclipse.emf.common.util.EList;
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>Import Scope</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * </p>
- * <ul>
- *   <li>{@link org.yakindu.sct.model.stext.stext.ImportScope#getImports <em>Imports</em>}</li>
- * </ul>
- *
- * @see org.yakindu.sct.model.stext.stext.StextPackage#getImportScope()
- * @model
- * @generated
- */
-public interface ImportScope extends StatechartScope {
-	/**
-	 * Returns the value of the '<em><b>Imports</b></em>' reference list.
-	 * The list contents are of type {@link org.yakindu.base.types.Package}.
-	 * <!-- begin-user-doc -->
-	 * <p>
-	 * If the meaning of the '<em>Imports</em>' containment reference list isn't clear,
-	 * there really should be more of a description here...
-	 * </p>
-	 * <!-- end-user-doc -->
-	 * @return the value of the '<em>Imports</em>' reference list.
-	 * @see org.yakindu.sct.model.stext.stext.StextPackage#getImportScope_Imports()
-	 * @model
-	 * @generated
-	 */
-	EList<org.yakindu.base.types.Package> getImports();
-
-} // ImportScope
+/**
+ */
+package org.yakindu.sct.model.stext.stext;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Import Scope</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * </p>
+ * <ul>
+ *   <li>{@link org.yakindu.sct.model.stext.stext.ImportScope#getImports <em>Imports</em>}</li>
+ * </ul>
+ *
+ * @see org.yakindu.sct.model.stext.stext.StextPackage#getImportScope()
+ * @model
+ * @generated
+ */
+public interface ImportScope extends StatechartScope {
+	/**
+	 * Returns the value of the '<em><b>Imports</b></em>' attribute list.
+	 * The list contents are of type {@link java.lang.String}.
+	 * <!-- begin-user-doc -->
+	 * <p>
+	 * If the meaning of the '<em>Imports</em>' containment reference list isn't clear,
+	 * there really should be more of a description here...
+	 * </p>
+	 * <!-- end-user-doc -->
+	 * @return the value of the '<em>Imports</em>' attribute list.
+	 * @see org.yakindu.sct.model.stext.stext.StextPackage#getImportScope_Imports()
+	 * @model
+	 * @generated
+	 */
+	EList<String> getImports();
+
+} // ImportScope

Разница между файлами не показана из-за своего большого размера
+ 2744 - 2744
plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/StextPackage.java


+ 144 - 128
plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/ImportScopeImpl.java

@@ -1,128 +1,144 @@
-/**
- */
-package org.yakindu.sct.model.stext.stext.impl;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.util.EObjectResolvingEList;
-import org.yakindu.sct.model.stext.stext.ImportScope;
-import org.yakindu.sct.model.stext.stext.StextPackage;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>Import Scope</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * </p>
- * <ul>
- *   <li>{@link org.yakindu.sct.model.stext.stext.impl.ImportScopeImpl#getImports <em>Imports</em>}</li>
- * </ul>
- *
- * @generated
- */
-public class ImportScopeImpl extends StatechartScopeImpl implements ImportScope {
-	/**
-	 * The cached value of the '{@link #getImports() <em>Imports</em>}' reference list.
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @see #getImports()
-	 * @generated
-	 * @ordered
-	 */
-	protected EList<org.yakindu.base.types.Package> imports;
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
-	protected ImportScopeImpl() {
-		super();
-	}
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
-	@Override
-	protected EClass eStaticClass() {
-		return StextPackage.Literals.IMPORT_SCOPE;
-	}
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
-	public EList<org.yakindu.base.types.Package> getImports() {
-		if (imports == null) {
-			imports = new EObjectResolvingEList<org.yakindu.base.types.Package>(org.yakindu.base.types.Package.class, this, StextPackage.IMPORT_SCOPE__IMPORTS);
-		}
-		return imports;
-	}
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
-	@Override
-	public Object eGet(int featureID, boolean resolve, boolean coreType) {
-		switch (featureID) {
-			case StextPackage.IMPORT_SCOPE__IMPORTS:
-				return getImports();
-		}
-		return super.eGet(featureID, resolve, coreType);
-	}
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
-	@SuppressWarnings("unchecked")
-	@Override
-	public void eSet(int featureID, Object newValue) {
-		switch (featureID) {
-			case StextPackage.IMPORT_SCOPE__IMPORTS:
-				getImports().clear();
-				getImports().addAll((Collection<? extends org.yakindu.base.types.Package>)newValue);
-				return;
-		}
-		super.eSet(featureID, newValue);
-	}
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
-	@Override
-	public void eUnset(int featureID) {
-		switch (featureID) {
-			case StextPackage.IMPORT_SCOPE__IMPORTS:
-				getImports().clear();
-				return;
-		}
-		super.eUnset(featureID);
-	}
-
-	/**
-	 * <!-- begin-user-doc -->
-	 * <!-- end-user-doc -->
-	 * @generated
-	 */
-	@Override
-	public boolean eIsSet(int featureID) {
-		switch (featureID) {
-			case StextPackage.IMPORT_SCOPE__IMPORTS:
-				return imports != null && !imports.isEmpty();
-		}
-		return super.eIsSet(featureID);
-	}
-
-} //ImportScopeImpl
+/**
+ */
+package org.yakindu.sct.model.stext.stext.impl;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
+import org.yakindu.sct.model.stext.stext.ImportScope;
+import org.yakindu.sct.model.stext.stext.StextPackage;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Import Scope</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * </p>
+ * <ul>
+ *   <li>{@link org.yakindu.sct.model.stext.stext.impl.ImportScopeImpl#getImports <em>Imports</em>}</li>
+ * </ul>
+ *
+ * @generated
+ */
+public class ImportScopeImpl extends StatechartScopeImpl implements ImportScope {
+	/**
+	 * The cached value of the '{@link #getImports() <em>Imports</em>}' attribute list.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getImports()
+	 * @generated
+	 * @ordered
+	 */
+	protected EList<String> imports;
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	protected ImportScopeImpl() {
+		super();
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	protected EClass eStaticClass() {
+		return StextPackage.Literals.IMPORT_SCOPE;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	public EList<String> getImports() {
+		if (imports == null) {
+			imports = new EDataTypeUniqueEList<String>(String.class, this, StextPackage.IMPORT_SCOPE__IMPORTS);
+		}
+		return imports;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public Object eGet(int featureID, boolean resolve, boolean coreType) {
+		switch (featureID) {
+			case StextPackage.IMPORT_SCOPE__IMPORTS:
+				return getImports();
+		}
+		return super.eGet(featureID, resolve, coreType);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@SuppressWarnings("unchecked")
+	@Override
+	public void eSet(int featureID, Object newValue) {
+		switch (featureID) {
+			case StextPackage.IMPORT_SCOPE__IMPORTS:
+				getImports().clear();
+				getImports().addAll((Collection<? extends String>)newValue);
+				return;
+		}
+		super.eSet(featureID, newValue);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public void eUnset(int featureID) {
+		switch (featureID) {
+			case StextPackage.IMPORT_SCOPE__IMPORTS:
+				getImports().clear();
+				return;
+		}
+		super.eUnset(featureID);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public boolean eIsSet(int featureID) {
+		switch (featureID) {
+			case StextPackage.IMPORT_SCOPE__IMPORTS:
+				return imports != null && !imports.isEmpty();
+		}
+		return super.eIsSet(featureID);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public String toString() {
+		if (eIsProxy()) return super.toString();
+
+		StringBuffer result = new StringBuffer(super.toString());
+		result.append(" (imports: ");
+		result.append(imports);
+		result.append(')');
+		return result.toString();
+	}
+
+} //ImportScopeImpl

Разница между файлами не показана из-за своего большого размера
+ 592 - 591
plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/StextFactoryImpl.java


Разница между файлами не показана из-за своего большого размера
+ 1250 - 1250
plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/impl/StextPackageImpl.java


Разница между файлами не показана из-за своего большого размера
+ 1164 - 1163
plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/util/StextAdapterFactory.java


Разница между файлами не показана из-за своего большого размера
+ 1261 - 1260
plugins/org.yakindu.sct.model.stext/emf-gen/org/yakindu/sct/model/stext/stext/util/StextSwitch.java


+ 111 - 111
plugins/org.yakindu.sct.model.stext/model/SText.ecore

@@ -1,111 +1,111 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="stext" nsURI="http://www.yakindu.org/sct/statechart/SText" nsPrefix="stext">
-  <eClassifiers xsi:type="ecore:EClass" name="Root">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="roots" upperBound="-1"
-        eType="#//DefRoot" containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="DefRoot"/>
-  <eClassifiers xsi:type="ecore:EClass" name="StatechartRoot" eSuperTypes="#//DefRoot">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="def" eType="#//StatechartSpecification"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="StateRoot" eSuperTypes="#//DefRoot">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="def" eType="#//StateSpecification"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="TransitionRoot" eSuperTypes="#//DefRoot">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="def" eType="#//TransitionSpecification"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="StatechartSpecification" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ScopedElement">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="annotations" upperBound="-1"
-        eType="#//ArgumentedAnnotation" containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="StateSpecification">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="scope" eType="ecore:EClass ../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Scope"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="TransitionSpecification">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="reaction" eType="#//TransitionReaction"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="StatechartScope" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Scope"/>
-  <eClassifiers xsi:type="ecore:EClass" name="InterfaceScope" eSuperTypes="#//StatechartScope ../../org.yakindu.base.types/model/base.ecore#//NamedElement"/>
-  <eClassifiers xsi:type="ecore:EClass" name="InternalScope" eSuperTypes="#//StatechartScope"/>
-  <eClassifiers xsi:type="ecore:EClass" name="ImportScope" eSuperTypes="#//StatechartScope">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="imports" upperBound="-1"
-        eType="ecore:EClass ../../org.yakindu.base.types/model/types.ecore#//Package"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="EventDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Event"/>
-  <eClassifiers xsi:type="ecore:EClass" name="VariableDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Property">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="initialValue" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="OperationDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Operation"/>
-  <eClassifiers xsi:type="ecore:EClass" name="TypeAliasDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//TypeAlias ../../org.yakindu.base.types/model/types.ecore#//Declaration"/>
-  <eClassifiers xsi:type="ecore:EClass" name="LocalReaction" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Reaction"/>
-  <eClassifiers xsi:type="ecore:EClass" name="TransitionReaction" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Reaction"/>
-  <eClassifiers xsi:type="ecore:EClass" name="Guard">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="expression" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="EntryPointSpec" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ReactionProperty">
-    <eStructuralFeatures xsi:type="ecore:EAttribute" name="entrypoint" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="ExitPointSpec" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ReactionProperty">
-    <eStructuralFeatures xsi:type="ecore:EAttribute" name="exitpoint" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="EventSpec"/>
-  <eClassifiers xsi:type="ecore:EClass" name="RegularEventSpec" eSuperTypes="#//EventSpec">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="event" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="TimeEventSpec" eSuperTypes="#//EventSpec">
-    <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//TimeEventType"/>
-    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-    <eStructuralFeatures xsi:type="ecore:EAttribute" name="unit" eType="#//TimeUnit"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EEnum" name="TimeEventType">
-    <eLiterals name="after" literal="after"/>
-    <eLiterals name="every" value="1" literal="every"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="BuiltinEventSpec" eSuperTypes="#//EventSpec"/>
-  <eClassifiers xsi:type="ecore:EClass" name="EntryEvent" eSuperTypes="#//BuiltinEventSpec"/>
-  <eClassifiers xsi:type="ecore:EClass" name="ExitEvent" eSuperTypes="#//BuiltinEventSpec"/>
-  <eClassifiers xsi:type="ecore:EClass" name="AlwaysEvent" eSuperTypes="#//BuiltinEventSpec"/>
-  <eClassifiers xsi:type="ecore:EEnum" name="TimeUnit">
-    <eLiterals name="second" literal="s"/>
-    <eLiterals name="millisecond" value="1" literal="ms"/>
-    <eLiterals name="microsecond" value="2" literal="us"/>
-    <eLiterals name="nanosecond" value="3" literal="ns"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="SimpleScope" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Scope"/>
-  <eClassifiers xsi:type="ecore:EClass" name="ReactionTrigger" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Trigger">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="triggers" upperBound="-1"
-        eType="#//EventSpec" containment="true"/>
-    <eStructuralFeatures xsi:type="ecore:EReference" name="guard" eType="#//Guard"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="DefaultTrigger" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Trigger"/>
-  <eClassifiers xsi:type="ecore:EClass" name="ReactionEffect" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Effect">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="actions" upperBound="-1"
-        eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="EventRaisingExpression" eSuperTypes="../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="event" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="EventValueReferenceExpression" eSuperTypes="../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
-        containment="true"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="ActiveStateReferenceExpression" eSuperTypes="../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression">
-    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//State"/>
-  </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="ArgumentedAnnotation" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Annotation ../../org.yakindu.base.expressions/model/Expressions.ecore#//ArgumentExpression"/>
-</ecore:EPackage>
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="stext" nsURI="http://www.yakindu.org/sct/statechart/SText" nsPrefix="stext">
+  <eClassifiers xsi:type="ecore:EClass" name="Root">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="roots" upperBound="-1"
+        eType="#//DefRoot" containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="DefRoot"/>
+  <eClassifiers xsi:type="ecore:EClass" name="StatechartRoot" eSuperTypes="#//DefRoot">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="def" eType="#//StatechartSpecification"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="StateRoot" eSuperTypes="#//DefRoot">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="def" eType="#//StateSpecification"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="TransitionRoot" eSuperTypes="#//DefRoot">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="def" eType="#//TransitionSpecification"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="StatechartSpecification" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ScopedElement">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="annotations" upperBound="-1"
+        eType="#//ArgumentedAnnotation" containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="StateSpecification">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="scope" eType="ecore:EClass ../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Scope"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="TransitionSpecification">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="reaction" eType="#//TransitionReaction"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="StatechartScope" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Scope"/>
+  <eClassifiers xsi:type="ecore:EClass" name="InterfaceScope" eSuperTypes="#//StatechartScope ../../org.yakindu.base.types/model/base.ecore#//NamedElement"/>
+  <eClassifiers xsi:type="ecore:EClass" name="InternalScope" eSuperTypes="#//StatechartScope"/>
+  <eClassifiers xsi:type="ecore:EClass" name="ImportScope" eSuperTypes="#//StatechartScope">
+  	<eStructuralFeatures xsi:type="ecore:EAttribute" name="imports" upperBound="-1"
+		eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="EventDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Event"/>
+  <eClassifiers xsi:type="ecore:EClass" name="VariableDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Property">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="initialValue" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="OperationDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Operation"/>
+  <eClassifiers xsi:type="ecore:EClass" name="TypeAliasDefinition" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//TypeAlias ../../org.yakindu.base.types/model/types.ecore#//Declaration"/>
+  <eClassifiers xsi:type="ecore:EClass" name="LocalReaction" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Reaction"/>
+  <eClassifiers xsi:type="ecore:EClass" name="TransitionReaction" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Reaction"/>
+  <eClassifiers xsi:type="ecore:EClass" name="Guard">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="expression" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="EntryPointSpec" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ReactionProperty">
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="entrypoint" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="ExitPointSpec" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ReactionProperty">
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="exitpoint" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="EventSpec"/>
+  <eClassifiers xsi:type="ecore:EClass" name="RegularEventSpec" eSuperTypes="#//EventSpec">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="event" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="TimeEventSpec" eSuperTypes="#//EventSpec">
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//TimeEventType"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="unit" eType="#//TimeUnit"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EEnum" name="TimeEventType">
+    <eLiterals name="after" literal="after"/>
+    <eLiterals name="every" value="1" literal="every"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="BuiltinEventSpec" eSuperTypes="#//EventSpec"/>
+  <eClassifiers xsi:type="ecore:EClass" name="EntryEvent" eSuperTypes="#//BuiltinEventSpec"/>
+  <eClassifiers xsi:type="ecore:EClass" name="ExitEvent" eSuperTypes="#//BuiltinEventSpec"/>
+  <eClassifiers xsi:type="ecore:EClass" name="AlwaysEvent" eSuperTypes="#//BuiltinEventSpec"/>
+  <eClassifiers xsi:type="ecore:EEnum" name="TimeUnit">
+    <eLiterals name="second" literal="s"/>
+    <eLiterals name="millisecond" value="1" literal="ms"/>
+    <eLiterals name="microsecond" value="2" literal="us"/>
+    <eLiterals name="nanosecond" value="3" literal="ns"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="SimpleScope" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Scope"/>
+  <eClassifiers xsi:type="ecore:EClass" name="ReactionTrigger" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Trigger">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="triggers" upperBound="-1"
+        eType="#//EventSpec" containment="true"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="guard" eType="#//Guard"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="DefaultTrigger" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Trigger"/>
+  <eClassifiers xsi:type="ecore:EClass" name="ReactionEffect" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Effect">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="actions" upperBound="-1"
+        eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="EventRaisingExpression" eSuperTypes="../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="event" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="EventValueReferenceExpression" eSuperTypes="../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression"
+        containment="true"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="ActiveStateReferenceExpression" eSuperTypes="../../org.yakindu.base.expressions/model/Expressions.ecore#//Expression">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="ecore:EClass ../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//State"/>
+  </eClassifiers>
+  <eClassifiers xsi:type="ecore:EClass" name="ArgumentedAnnotation" eSuperTypes="../../org.yakindu.base.types/model/types.ecore#//Annotation ../../org.yakindu.base.expressions/model/Expressions.ecore#//ArgumentExpression"/>
+</ecore:EPackage>

+ 182 - 182
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/SText.xtext

@@ -1,188 +1,188 @@
-grammar org.yakindu.sct.model.stext.SText with org.yakindu.base.expressions.Expressions
-
-import "http://www.yakindu.org/sct/statechart/SText"
-import "http://www.eclipse.org/emf/2002/Ecore" as ecore
-import "http://www.yakindu.org/sct/sgraph/2.0.0" as sgraph
-import "http://www.yakindu.org/base/types/2.0.0" as types
-import "http://www.yakindu.org/base/base/2.0.0" as base
-import "http://www.yakindu.org/base/expressions/Expressions" as exp
+grammar org.yakindu.sct.model.stext.SText with org.yakindu.base.expressions.Expressions
+
+import "http://www.yakindu.org/sct/statechart/SText"
+import "http://www.eclipse.org/emf/2002/Ecore" as ecore
+import "http://www.yakindu.org/sct/sgraph/2.0.0" as sgraph
+import "http://www.yakindu.org/base/types/2.0.0" as types
+import "http://www.yakindu.org/base/base/2.0.0" as base
+import "http://www.yakindu.org/base/expressions/Expressions" as exp
 /* ---- root rules ----
 These root rules are not relevant for the grammar integration in the statechart. They just integrate the different start rules consistently 
 into a single grammar. 
-*/
-Root:
-	(roots+=DefRoot)*;
-
-DefRoot:
-	StatechartRoot | StateRoot | TransitionRoot;
-
-StatechartRoot:
-	'@@statechart@@' def=StatechartSpecification;
-
-StateRoot:
-	'@@state@@' def=StateSpecification;
-
-TransitionRoot:
-	'@@transition@@' def=TransitionSpecification;
+*/
+Root:
+	(roots+=DefRoot)*;
+
+DefRoot:
+	StatechartRoot | StateRoot | TransitionRoot;
+
+StatechartRoot:
+	'@@statechart@@' def=StatechartSpecification;
+
+StateRoot:
+	'@@state@@' def=StateSpecification;
+
+TransitionRoot:
+	'@@transition@@' def=TransitionSpecification;
 /* ---- start rules ----
 Define the starting points used by the statechart integration. These rules hook in the concrete rules of the specific grammar.
-*/
-
-StatechartSpecification:
-	{StatechartSpecification} ('namespace' namespace=FQN)?
-	(annotations+=ArgumentedAnnotation)*
-	(scopes+=StatechartScope)*;
-
-StateSpecification:
-	scope=StateScope;
-
-TransitionSpecification:
-	reaction=TransitionReaction;
-
-StateScope returns sgraph::Scope:
-	{SimpleScope} (reactions+=(LocalReaction))*;
-
-StatechartScope:
-	InterfaceScope | InternalScope | ImportScope;
-
-InterfaceScope:
-	{InterfaceScope} 'interface' (name=XID)? ':' (declarations+=InterfaceScopeDeclaration)*;
-
-InterfaceScopeDeclaration returns types::Declaration:
-	EventDefinition | VariableDefinition | TypeAliasDefinition | OperationDefinition;
-
-InternalScope:
-	{InternalScope} 'internal' ':' ((declarations+=InternalScopeDeclaration) | (reactions +=LocalReaction))*
-;
-InternalScopeDeclaration returns types::Declaration:
-	EventDefinition | VariableDefinition | OperationDefinition | TypeAliasDefinition
-;
-ImportScope:
-	 {ImportScope} 'import' ':' (imports+=[types::Package|QID])*;
-
-QID:
-	ID ('.' ID)*;
-
-EventDefinition:
-	(direction=Direction)? 'event' name=XID (':' typeSpecifier=TypeSpecifier)?;
-
-enum Direction returns types::Direction:
-	LOCAL='local' | IN='in' | OUT='out';
-
-VariableDefinition:
-	{VariableDefinition} (const?='const'|'var') ((readonly?='readonly')? & (external?='external')?) name=XID ':' typeSpecifier=TypeSpecifier
-	('=' initialValue=Expression)?; /* ---- operation definition ---- */ 
-	
-TypeAliasDefinition:
-	{TypeAliasDefinition} 'alias' name=XID ':' typeSpecifier=TypeSpecifier;
-
-OperationDefinition:
-	{OperationDefinition} 
-	'operation' name=XID '(' (parameters+=Parameter (',' parameters+=Parameter)*)? ')' (':'
-	typeSpecifier=TypeSpecifier)?;
-	
-ArgumentedAnnotation:
-	'@' type=[types::AnnotationType|QID] ('('(arguments+=SimpleArgument (',' arguments+=SimpleArgument)*)? ')')?
-;
-
-SimpleArgument returns exp::Argument:
-	{exp::Argument} value=ConditionalExpression
-;
-
-TypeSpecifier returns types::TypeSpecifier:
-	type=[types::Type|FQN] ('<' (typeArguments+=TypeSpecifier (',' typeArguments+=TypeSpecifier)*'>'))?;
-
-Parameter returns types::Parameter:
-	 name=XID (varArgs?='...')? ':' typeSpecifier=TypeSpecifier;
-
-LocalReaction:
-	(trigger=ReactionTrigger) => ('/' effect=ReactionEffect);
-
-TransitionReaction:
-	{TransitionReaction} (trigger=StextTrigger)? ('/' effect=ReactionEffect)? ('#' (properties+=TransitionProperty)*)?;
-
-StextTrigger returns sgraph::Trigger:
-	ReactionTrigger | DefaultTrigger;
-
-ReactionTrigger returns sgraph::Trigger:
-	{ReactionTrigger} ((triggers+=EventSpec ("," triggers+=EventSpec)* (=> '[' guard=Guard ']')?) | ('[' guard=Guard
-	']'));
-
-DefaultTrigger returns sgraph::Trigger:
-	{DefaultTrigger} ('default' | 'else');
-
-Guard:
-	{Guard} expression=Expression;
-
-ReactionEffect returns sgraph::Effect:
-	{ReactionEffect} actions+=(Expression | EventRaisingExpression) (=> ';' actions+=(Expression |
-	EventRaisingExpression))*;
-
-TransitionProperty returns sgraph::ReactionProperty:
-	EntryPointSpec | ExitPointSpec;
-
-EntryPointSpec:
-	'>' entrypoint=ID;
-
-ExitPointSpec:
-	exitpoint=ID '>';
-
-EventSpec:
-	RegularEventSpec | TimeEventSpec | BuiltinEventSpec;
-
-// Use SimpleFeatureCall for eventSpec to avoid guard ambiguity with array access
-RegularEventSpec:
-	event=SimpleFeatureCall;
-
-SimpleFeatureCall returns exp::Expression:
-	SimpleElementReferenceExpression ({exp::FeatureCall.owner=current} '.' feature=[ecore::EObject]
-	(=> operationCall?='('
-	(arguments+=Argument(',' arguments+=Argument)*)?
-	')')?)*;
-
-SimpleElementReferenceExpression returns exp::ElementReferenceExpression:
-	reference=[ecore::EObject|ID]
-	(=> operationCall?='('
-	(arguments+=Argument (',' arguments+=Argument)*)?
-	')')?;
-
-TimeEventSpec:
-	type=TimeEventType value=ConditionalExpression unit=TimeUnit;
-
-enum TimeEventType:
-	after | every;
-
-BuiltinEventSpec:
-	EntryEvent | ExitEvent | AlwaysEvent;
-
-EntryEvent:
-	{EntryEvent} 'entry';
-
-ExitEvent:
-	{ExitEvent} 'exit';
-
-AlwaysEvent:
-	{AlwaysEvent} ('always' | 'oncycle');
-
-EventRaisingExpression returns exp::Expression:
-	{EventRaisingExpression} 'raise' event=FeatureCall (':' value=Expression)?;
-
-EventValueReferenceExpression returns exp::Expression:
-	{EventValueReferenceExpression} 'valueof' '(' value=FeatureCall ')';
-
-ActiveStateReferenceExpression returns exp::Expression:
-	{ActiveStateReferenceExpression} 'active' '(' value=[sgraph::State|FQN] ')';
-
-PrimaryExpression returns exp::Expression:
-	PrimitiveValueExpression | FeatureCall | ActiveStateReferenceExpression | EventValueReferenceExpression |
-	ParenthesizedExpression;
-
-enum TimeUnit:
-	second='s' | millisecond='ms' | microsecond='us' | nanosecond='ns';
-
-XID:
-	ID | 'namespace' | 'interface' | 'internal' | 'event' | 'local' | 'in' | 'out' | 'var' | 'readonly' | 'external' |
-	'operation' | 'default' | 'else' | 'entry' | 'exit' | 'always' | 'oncycle' | 'raise' | 'valueof' | 'active';
-
-FQN:
+*/
+
+StatechartSpecification:
+	{StatechartSpecification} ('namespace' namespace=FQN)?
+	(annotations+=ArgumentedAnnotation)*
+	(scopes+=StatechartScope)*;
+
+StateSpecification:
+	scope=StateScope;
+
+TransitionSpecification:
+	reaction=TransitionReaction;
+
+StateScope returns sgraph::Scope:
+	{SimpleScope} (reactions+=(LocalReaction))*;
+
+StatechartScope:
+	InterfaceScope | InternalScope | ImportScope;
+
+InterfaceScope:
+	{InterfaceScope} 'interface' (name=XID)? ':' (declarations+=InterfaceScopeDeclaration)*;
+
+InterfaceScopeDeclaration returns types::Declaration:
+	EventDefinition | VariableDefinition | TypeAliasDefinition | OperationDefinition;
+
+InternalScope:
+	{InternalScope} 'internal' ':' ((declarations+=InternalScopeDeclaration) | (reactions +=LocalReaction))*
+;
+InternalScopeDeclaration returns types::Declaration:
+	EventDefinition | VariableDefinition | OperationDefinition | TypeAliasDefinition
+;
+ImportScope:
+	 {ImportScope} 'import' ':' (imports+=QID | imports+=STRING)*;
+
+QID:
+	ID ('.' ID)*;
+
+EventDefinition:
+	(direction=Direction)? 'event' name=XID (':' typeSpecifier=TypeSpecifier)?;
+
+enum Direction returns types::Direction:
+	LOCAL='local' | IN='in' | OUT='out';
+
+VariableDefinition:
+	{VariableDefinition} (const?='const'|'var') ((readonly?='readonly')? & (external?='external')?) name=XID ':' typeSpecifier=TypeSpecifier
+	('=' initialValue=Expression)?; /* ---- operation definition ---- */ 
+	
+TypeAliasDefinition:
+	{TypeAliasDefinition} 'alias' name=XID ':' typeSpecifier=TypeSpecifier;
+
+OperationDefinition:
+	{OperationDefinition} 
+	'operation' name=XID '(' (parameters+=Parameter (',' parameters+=Parameter)*)? ')' (':'
+	typeSpecifier=TypeSpecifier)?;
+	
+ArgumentedAnnotation:
+	'@' type=[types::AnnotationType|QID] ('('(arguments+=SimpleArgument (',' arguments+=SimpleArgument)*)? ')')?
+;
+
+SimpleArgument returns exp::Argument:
+	{exp::Argument} value=ConditionalExpression
+;
+
+TypeSpecifier returns types::TypeSpecifier:
+	type=[types::Type|FQN] ('<' (typeArguments+=TypeSpecifier (',' typeArguments+=TypeSpecifier)*'>'))?;
+
+Parameter returns types::Parameter:
+	 name=XID (varArgs?='...')? ':' typeSpecifier=TypeSpecifier;
+
+LocalReaction:
+	(trigger=ReactionTrigger) => ('/' effect=ReactionEffect);
+
+TransitionReaction:
+	{TransitionReaction} (trigger=StextTrigger)? ('/' effect=ReactionEffect)? ('#' (properties+=TransitionProperty)*)?;
+
+StextTrigger returns sgraph::Trigger:
+	ReactionTrigger | DefaultTrigger;
+
+ReactionTrigger returns sgraph::Trigger:
+	{ReactionTrigger} ((triggers+=EventSpec ("," triggers+=EventSpec)* (=> '[' guard=Guard ']')?) | ('[' guard=Guard
+	']'));
+
+DefaultTrigger returns sgraph::Trigger:
+	{DefaultTrigger} ('default' | 'else');
+
+Guard:
+	{Guard} expression=Expression;
+
+ReactionEffect returns sgraph::Effect:
+	{ReactionEffect} actions+=(Expression | EventRaisingExpression) (=> ';' actions+=(Expression |
+	EventRaisingExpression))*;
+
+TransitionProperty returns sgraph::ReactionProperty:
+	EntryPointSpec | ExitPointSpec;
+
+EntryPointSpec:
+	'>' entrypoint=ID;
+
+ExitPointSpec:
+	exitpoint=ID '>';
+
+EventSpec:
+	RegularEventSpec | TimeEventSpec | BuiltinEventSpec;
+
+// Use SimpleFeatureCall for eventSpec to avoid guard ambiguity with array access
+RegularEventSpec:
+	event=SimpleFeatureCall;
+
+SimpleFeatureCall returns exp::Expression:
+	SimpleElementReferenceExpression ({exp::FeatureCall.owner=current} '.' feature=[ecore::EObject]
+	(=> operationCall?='('
+	(arguments+=Argument(',' arguments+=Argument)*)?
+	')')?)*;
+
+SimpleElementReferenceExpression returns exp::ElementReferenceExpression:
+	reference=[ecore::EObject|ID]
+	(=> operationCall?='('
+	(arguments+=Argument (',' arguments+=Argument)*)?
+	')')?;
+
+TimeEventSpec:
+	type=TimeEventType value=ConditionalExpression unit=TimeUnit;
+
+enum TimeEventType:
+	after | every;
+
+BuiltinEventSpec:
+	EntryEvent | ExitEvent | AlwaysEvent;
+
+EntryEvent:
+	{EntryEvent} 'entry';
+
+ExitEvent:
+	{ExitEvent} 'exit';
+
+AlwaysEvent:
+	{AlwaysEvent} ('always' | 'oncycle');
+
+EventRaisingExpression returns exp::Expression:
+	{EventRaisingExpression} 'raise' event=FeatureCall (':' value=Expression)?;
+
+EventValueReferenceExpression returns exp::Expression:
+	{EventValueReferenceExpression} 'valueof' '(' value=FeatureCall ')';
+
+ActiveStateReferenceExpression returns exp::Expression:
+	{ActiveStateReferenceExpression} 'active' '(' value=[sgraph::State|FQN] ')';
+
+PrimaryExpression returns exp::Expression:
+	PrimitiveValueExpression | FeatureCall | ActiveStateReferenceExpression | EventValueReferenceExpression |
+	ParenthesizedExpression;
+
+enum TimeUnit:
+	second='s' | millisecond='ms' | microsecond='us' | nanosecond='ns';
+
+XID:
+	ID | 'namespace' | 'interface' | 'internal' | 'event' | 'local' | 'in' | 'out' | 'var' | 'readonly' | 'external' |
+	'operation' | 'default' | 'else' | 'entry' | 'exit' | 'always' | 'oncycle' | 'raise' | 'valueof' | 'active';
+
+FQN:
 	XID ('.' XID)*;

+ 127 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/IPackageImport2URIMapper.java

@@ -0,0 +1,127 @@
+/**
+ * Copyright (c) 2017 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.model.stext.scoping;
+
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.yakindu.sct.model.stext.scoping.IPackageImport2URIMapper.NullImpl;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * 
+ * @author Andreas Mülder - Initial contribution and API
+ *
+ */
+@ImplementedBy(NullImpl.class)
+public interface IPackageImport2URIMapper {
+
+	public PackageImport findPackageImport(Resource context, String packageImport);
+
+	public Set<PackageImport> getAllImports(Resource context);
+
+	public static class PackageImport {
+
+		private String namespace;
+
+		private String name;
+
+		private URI uri;
+
+		public PackageImport(String name, URI uri, String namespace) {
+			this.name = name;
+			this.uri = uri;
+			this.namespace = namespace;
+		}
+
+		public String getName() {
+			return name;
+		}
+
+		public URI getUri() {
+			return uri;
+		}
+
+		public String getNamespace() {
+			return namespace;
+		}
+
+		@Override
+		public int hashCode() {
+			final int prime = 31;
+			int result = 1;
+			result = prime * result + ((name == null) ? 0 : name.hashCode());
+			result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
+			result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+			return result;
+		}
+
+		@Override
+		public boolean equals(Object obj) {
+			if (this == obj)
+				return true;
+			if (obj == null)
+				return false;
+			if (getClass() != obj.getClass())
+				return false;
+			PackageImport other = (PackageImport) obj;
+			return attributesEqual(other);
+		}
+
+		private boolean attributesEqual(PackageImport other) {
+			return nameEquals(other) && namespaceEquals(other) && uriEquals(other);
+		}
+
+		private boolean uriEquals(PackageImport other) {
+			if (uri == null) {
+				if (other.uri != null)
+					return false;
+			} else if (!uri.equals(other.uri))
+				return false;
+			return true;
+		}
+
+		private boolean namespaceEquals(PackageImport other) {
+			if (namespace == null) {
+				if (other.namespace != null)
+					return false;
+			} else if (!namespace.equals(other.namespace))
+				return false;
+			return true;
+		}
+
+		private boolean nameEquals(PackageImport other) {
+			if (name == null) {
+				if (other.name != null)
+					return false;
+			} else if (!name.equals(other.name))
+				return false;
+			return true;
+		}
+
+	}
+
+	public static class NullImpl implements IPackageImport2URIMapper {
+
+		@Override
+		public PackageImport findPackageImport(Resource context, String packageImport) {
+			return null;
+		}
+
+		@Override
+		public Set<PackageImport> getAllImports(Resource context) {
+			return null;
+		}
+	}
+
+}

+ 12 - 10
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

@@ -18,6 +18,7 @@ import org.eclipse.emf.common.util.EList;
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.URIConverter;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.xtext.EcoreUtil2;
 import org.eclipse.xtext.naming.IQualifiedNameProvider;
@@ -29,13 +30,13 @@ import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
 import org.eclipse.xtext.scoping.impl.SimpleScope;
 import org.eclipse.xtext.util.IAcceptor;
 import org.eclipse.xtext.util.IResourceScopeCache;
-import org.yakindu.base.types.Package;
 import org.yakindu.base.types.TypesPackage;
 import org.yakindu.base.types.typesystem.ITypeSystem;
 import org.yakindu.sct.domain.extension.DomainRegistry;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Statechart;
 import org.yakindu.sct.model.sgraph.util.ContextElementAdapter;
+import org.yakindu.sct.model.stext.scoping.IPackageImport2URIMapper.PackageImport;
 import org.yakindu.sct.model.stext.stext.ImportScope;
 import org.yakindu.sct.model.stext.stext.StatechartSpecification;
 import org.yakindu.sct.model.stext.stext.StextPackage;
@@ -63,6 +64,8 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 	private DefaultGlobalScopeProvider delegate;
 	@Inject
 	private STextLibraryGlobalScopeProvider libraryScope;
+	@Inject
+	private IPackageImport2URIMapper mapper;
 
 	public void setCache(IResourceScopeCache cache) {
 		this.cache = cache;
@@ -109,9 +112,9 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 				IAcceptor<String> collector = createURICollector(resource, uniqueImportURIs);
 				Collection<ImportScope> importScopes = getImportScopes(resource);
 				for (ImportScope object : importScopes) {
-					EList<Package> imports = object.getImports();
-					for (Package package1 : imports) {
-						collectPackageImports(package1, collector, uniqueImportURIs);
+					EList<String> imports = object.getImports();
+					for (String packageImport : imports) {
+						collectPackageImports(resource, packageImport, collector, uniqueImportURIs);
 					}
 				}
 				Iterator<URI> uriIter = uniqueImportURIs.iterator();
@@ -135,13 +138,12 @@ public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 		});
 	}
 
-	protected void collectPackageImports(Package package1, IAcceptor<String> acceptor,
+	protected void collectPackageImports(Resource resource, String packageImport, IAcceptor<String> acceptor,
 			LinkedHashSet<URI> uniqueImportURIs) {
-		EcoreUtil.resolveAll(package1);
-		if (package1.eIsProxy())
-			return;
-		String uri = EcoreUtil.getURI(package1).trimFragment().toString();
-		acceptor.accept(uri);
+		PackageImport pkgImport = mapper.findPackageImport(resource, packageImport);
+		if (pkgImport != null && pkgImport.getUri() != null && URIConverter.INSTANCE.exists(pkgImport.getUri(), null)) {
+			acceptor.accept(pkgImport.getUri().toString());
+		}
 	}
 
 	protected Statechart getStatechart(Resource context) {

+ 137 - 135
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/StextImportAwareScopeProvider.java

@@ -1,135 +1,137 @@
-/**
-* Copyright (c) 2016 itemis AG - All rights Reserved
-* Unauthorized copying of this file, via any medium is strictly prohibited
-* 
-* Contributors:
-*	Andreas Muelder - itemis AG	
-*	Thomas Kutz - itemis AG
-*
-*/
-package org.yakindu.sct.model.stext.scoping;
-
-import static java.util.Collections.singletonList;
-
-import java.util.List;
-
-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.naming.QualifiedName;
-import org.eclipse.xtext.resource.ISelectable;
-import org.eclipse.xtext.scoping.IScope;
-import org.eclipse.xtext.scoping.impl.ImportNormalizer;
-import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider;
-import org.yakindu.base.types.Package;
-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.stext.ImportScope;
-import org.yakindu.sct.model.stext.stext.StateSpecification;
-import org.yakindu.sct.model.stext.stext.TransitionSpecification;
-
-import com.google.common.collect.Lists;
-
-/**
- * 
- * @author thomas kutz
- *
- */
-public class StextImportAwareScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {
-
-	@Override
-	public IScope getScope(EObject context, EReference reference) {
-		if (context == null)
-			throw new NullPointerException("context");
-		IScope result = null;
-		if (context instanceof ImportScope) {
-			result = getResourceScope(context.eResource(), reference);
-		} else if (context.eContainer() != null) {
-			result = getScope(context.eContainer(), reference);
-		} else {
-			result = getResourceScope(context.eResource(), reference);
-		}
-		return getLocalElementsScope(result, context, reference);
-	}
-
-	@Override
-	protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) {
-		List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
-		List<ImportScope> importScopes = null;
-		if (context instanceof StateSpecification || context instanceof TransitionSpecification) {
-			importScopes = EcoreUtil2.getAllContentsOfType(getStatechart(context), ImportScope.class);
-		} else {
-			importScopes = EcoreUtil2.getAllContentsOfType(context, ImportScope.class);
-		}
-		for (ImportScope scope : importScopes) {
-			importedNamespaceResolvers.addAll(createNamespaceResolver(scope, ignoreCase));
-		}
-		return importedNamespaceResolvers;
-	}
-
-	@Override
-	protected ImportNormalizer doCreateImportNormalizer(QualifiedName importedNamespace, boolean wildcard,
-			boolean ignoreCase) {
-		// all imports should be treated as if they had a wild card
-		return new ImportNormalizer(importedNamespace, true, ignoreCase);
-	}
-
-	protected List<ImportNormalizer> createNamespaceResolver(Scope scope, boolean ignoreCase) {
-		List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
-		ImportScope importScope = (ImportScope) scope;
-		for (org.yakindu.base.types.Package child : importScope.getImports()) {
-			String value = getImportedNamespace(child);
-			ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase);
-			if (resolver != null)
-				importedNamespaceResolvers.add(resolver);
-		}
-		return importedNamespaceResolvers;
-	}
-
-	protected IScope getLocalElementsScope(IScope parent, final EObject context, final EReference reference) {
-		IScope result = parent;
-		ISelectable allDescriptions = getAllDescriptions(context.eResource());
-		QualifiedName name = getQualifiedNameOfLocalElement(context);
-		boolean ignoreCase = isIgnoreCase(reference);
-		final List<ImportNormalizer> namespaceResolvers = getImportedNamespaceResolvers(context, ignoreCase);
-		if (!namespaceResolvers.isEmpty()) {
-			if (isRelativeImport() && name != null && !name.isEmpty()) {
-				ImportNormalizer localNormalizer = doCreateImportNormalizer(name, true, ignoreCase);
-				result = createImportScope(result, singletonList(localNormalizer), allDescriptions,
-						reference.getEReferenceType(), isIgnoreCase(reference));
-			}
-			result = createImportScope(result, namespaceResolvers, null, reference.getEReferenceType(),
-					isIgnoreCase(reference));
-		}
-		if (name != null) {
-			ImportNormalizer localNormalizer = doCreateImportNormalizer(name, true, ignoreCase);
-			result = createImportScope(result, singletonList(localNormalizer), allDescriptions,
-					reference.getEReferenceType(), isIgnoreCase(reference));
-		}
-		return result;
-	}
-
-	@Override
-	protected String getImportedNamespace(EObject object) {
-		if (object instanceof Package)
-			return ((Package) object).getName();
-		return super.getImportedNamespace(object);
-	}
-
-	protected Statechart getStatechart(EObject context) {
-
-		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context.eResource(),
-				ContextElementAdapter.class);
-
-		if (provider == null) {
-			return EcoreUtil2.getContainerOfType(context, Statechart.class);
-		} else {
-			return (Statechart) EcoreUtil.getObjectByType(provider.getElement().eResource().getContents(),
-					SGraphPackage.Literals.STATECHART);
-		}
-	}
-
-}
+/**
+* Copyright (c) 2016 itemis AG - All rights Reserved
+* Unauthorized copying of this file, via any medium is strictly prohibited
+* 
+* Contributors:
+*	Andreas Muelder - itemis AG	
+*	Thomas Kutz - itemis AG
+*
+*/
+package org.yakindu.sct.model.stext.scoping;
+
+import java.util.Collections;
+import java.util.List;
+
+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.naming.QualifiedName;
+import org.eclipse.xtext.resource.ISelectable;
+import org.eclipse.xtext.scoping.IScope;
+import org.eclipse.xtext.scoping.impl.ImportNormalizer;
+import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider;
+import org.yakindu.base.types.Package;
+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.IPackageImport2URIMapper.PackageImport;
+import org.yakindu.sct.model.stext.stext.ImportScope;
+import org.yakindu.sct.model.stext.stext.StateSpecification;
+import org.yakindu.sct.model.stext.stext.TransitionSpecification;
+
+import com.google.common.collect.Lists;
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author thomas kutz
+ *
+ */
+public class StextImportAwareScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {
+
+	@Inject
+	private IPackageImport2URIMapper mapper;
+
+	@Override
+	public IScope getScope(EObject context, EReference reference) {
+		if (context == null)
+			throw new NullPointerException("context");
+		IScope result = null;
+		if (context instanceof ImportScope) {
+			result = getResourceScope(context.eResource(), reference);
+		} else if (context.eContainer() != null) {
+			result = getScope(context.eContainer(), reference);
+		} else {
+			result = getResourceScope(context.eResource(), reference);
+		}
+		return getLocalElementsScope(result, context, reference);
+	}
+
+	@Override
+	protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) {
+		List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
+		List<ImportScope> importScopes = null;
+		if (context instanceof StateSpecification || context instanceof TransitionSpecification) {
+			importScopes = EcoreUtil2.getAllContentsOfType(getStatechart(context), ImportScope.class);
+		} else {
+			importScopes = EcoreUtil2.getAllContentsOfType(context, ImportScope.class);
+		}
+		for (ImportScope scope : importScopes) {
+			importedNamespaceResolvers.addAll(createNamespaceResolver(scope, ignoreCase));
+		}
+		return importedNamespaceResolvers;
+	}
+
+	@Override
+	protected ImportNormalizer doCreateImportNormalizer(QualifiedName importedNamespace, boolean wildcard,
+			boolean ignoreCase) {
+		// all imports should be treated as if they had a wild card
+		return new ImportNormalizer(importedNamespace, true, ignoreCase);
+	}
+
+	protected List<ImportNormalizer> createNamespaceResolver(Scope scope, boolean ignoreCase) {
+		List<ImportNormalizer> importedNamespaceResolvers = Lists.newArrayList();
+		ImportScope importScope = (ImportScope) scope;
+		for (String child : importScope.getImports()) {
+			PackageImport pkgImport = mapper.findPackageImport(scope.eResource(), child);
+			if (pkgImport != null) {
+				ImportNormalizer resolver = createImportedNamespaceResolver(pkgImport.getNamespace(), ignoreCase);
+				if (resolver != null)
+					importedNamespaceResolvers.add(resolver);
+			}
+		}
+		return importedNamespaceResolvers;
+	}
+
+	protected IScope getLocalElementsScope(IScope parent, final EObject context, final EReference reference) {
+		IScope result = parent;
+		ISelectable allDescriptions = getAllDescriptions(context.eResource());
+		QualifiedName name = getQualifiedNameOfLocalElement(context);
+		boolean ignoreCase = isIgnoreCase(reference);
+		final List<ImportNormalizer> namespaceResolvers = getImportedNamespaceResolvers(context, ignoreCase);
+		if (!namespaceResolvers.isEmpty()) {
+			if (isRelativeImport() && name != null && !name.isEmpty()) {
+				ImportNormalizer localNormalizer = doCreateImportNormalizer(name, true, ignoreCase);
+				result = createImportScope(result, Collections.singletonList(localNormalizer), allDescriptions,
+						reference.getEReferenceType(), isIgnoreCase(reference));
+			}
+			result = createImportScope(result, namespaceResolvers, null, reference.getEReferenceType(),
+					isIgnoreCase(reference));
+		}
+		// We don't want to add an implicit local ImportNormalizer here...
+		return result;
+	}
+
+	@Override
+	protected String getImportedNamespace(EObject object) {
+		if (object instanceof Package)
+			return ((Package) object).getName();
+		return super.getImportedNamespace(object);
+	}
+
+	protected Statechart getStatechart(EObject context) {
+
+		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context.eResource(),
+				ContextElementAdapter.class);
+
+		if (provider == null) {
+			return EcoreUtil2.getContainerOfType(context, Statechart.class);
+		} else {
+			return (Statechart) EcoreUtil.getObjectByType(provider.getElement().eResource().getContents(),
+					SGraphPackage.Literals.STATECHART);
+		}
+	}
+
+}

+ 0 - 128
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/util/ImportResolver.java

@@ -1,128 +0,0 @@
-/**
- * Copyright (c) 2014 itemis AG and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- * 	itemis AG - initial API and implementation
- *  
- */
-package org.yakindu.sct.model.stext.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.mwe2.language.mwe2.Import;
-import org.eclipse.xtext.resource.IContainer;
-import org.eclipse.xtext.resource.IEObjectDescription;
-import org.eclipse.xtext.resource.IResourceDescription;
-import org.eclipse.xtext.resource.IResourceDescriptions;
-import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions;
-import org.yakindu.base.types.Package;
-import org.yakindu.base.types.TypesPackage;
-
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-
-/**
- * Convenience class for retrieving imported elements in the statechart's import
- * scope.
- * 
- * @author Thomas Kutz
- *
- */
-public class ImportResolver {
-
-	@Inject
-	private IContainer.Manager containerManager;
-	@Inject
-	private IResourceDescriptions resourceDescriptions;
-
-	/**
-	 * Returns for a given {@link Import} declaration all elements of given type
-	 * that are defined in the imported {@link Package}.
-	 * 
-	 * @param importDeclaration
-	 *            the import declaration within an import scope
-	 * @param type
-	 *            type of imported elements to be returned
-	 * @return imported elements of given type
-	 */
-	public <T extends EObject> List<T> getImportedElementsOfType(Package importedPackage, Class<T> type) {
-		List<T> elements = Lists.newArrayList();
-		if (importedPackage != null) {
-			for (EObject content : importedPackage.eContents()) {
-				if (type.isInstance(content)) {
-					elements.add(type.cast(content));
-				}
-			}
-		}
-		return elements;
-	}
-
-	/**
-	 * Returns for a given namespace the {@link Package}.
-	 * 
-	 * @param contextResource
-	 *            the resource used to decide which packages are visible
-	 * @param namespace
-	 *            name of the package to be returned; ending wildcards (.*) will
-	 *            be trimmed
-	 * @return first found package with name as defined in namespace
-	 */
-	public Package getPackageForNamespace(Resource contextResource, String namespace) {
-		initResourceDescriptions(contextResource);
-		List<IEObjectDescription> allVisiblePackages = getAllVisiblePackagesDescriptions(contextResource.getURI());
-		for (IEObjectDescription pkgDesc : allVisiblePackages) {
-			if (pkgDesc.getName().toString().equals(namespace)) {
-				return (Package) pkgDesc.getEObjectOrProxy();
-			}
-		}
-		return null;
-	}
-
-	public List<IEObjectDescription> getAllVisiblePackagesDescriptions(URI contextURI) {
-		List<IEObjectDescription> result = new ArrayList<>();
-
-		IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(contextURI);
-		if (resourceDescription == null) {
-			// no resource description could be found, so package cannot be
-			// resolved anyway
-			return result;
-		}
-		for (IContainer container : containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
-			final Iterable<IResourceDescription> currentDescriptions = container.getResourceDescriptions();
-			for (IResourceDescription resDesc : currentDescriptions) {
-				Iterable<IEObjectDescription> visiblePackages = resDesc
-						.getExportedObjectsByType(TypesPackage.Literals.PACKAGE);
-				for (IEObjectDescription pkgDesc : visiblePackages) {
-					result.add(pkgDesc);
-				}
-			}
-		}
-		return result;
-	}
-
-	protected void initResourceDescriptions(Resource contextResource) {
-		if (resourceDescriptions instanceof ResourceSetBasedResourceDescriptions) {
-			ResourceSet rset = buildResourceSet(contextResource);
-			((ResourceSetBasedResourceDescriptions) resourceDescriptions).setContext(rset);
-		}
-	}
-
-	protected ResourceSet buildResourceSet(Resource contextResource) {
-		if (contextResource.getResourceSet() == null) {
-			final ResourceSet rset = new ResourceSetImpl();
-			rset.getResources().add(contextResource);
-			return rset;
-		}
-		return contextResource.getResourceSet();
-	}
-}

+ 3 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

@@ -114,6 +114,9 @@ import com.google.inject.name.Named;
 @ComposedChecks(validators = { SGraphJavaValidator.class, SCTResourceValidator.class, ExpressionsJavaValidator.class })
 public class STextJavaValidator extends AbstractSTextJavaValidator implements STextValidationMessages {
 
+	public static final String IMPORT_NOT_RESOLVED_MSG = "Import '%s' cannot be resolved.";
+	public static final String IMPORT_NOT_RESOLVED_CODE = "ImportNotResolved";
+
 	@Inject
 	private ITypeSystemInferrer typeInferrer;
 	@Inject

+ 1 - 3
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java

@@ -46,13 +46,12 @@ public interface STextValidationMessages {
 	public static final String TRANSITION_EXIT_SPEC_ON_MULTIPLE_SIBLINGS = "ExitPointSpec can't be used on transition siblings.";
 	public static final String LEFT_HAND_ASSIGNMENT = "The left-hand side of an assignment must be a variable.";
 	public static final String ISSUE_TRANSITION_WITHOUT_TRIGGER = "Missing trigger. Transition is never taken. Use 'oncycle' or 'always' instead.";
-	public static final String IMPORT_NOT_RESOLVED = "Import cannot be resolved.";
 	public static final String EXITPOINTSPEC_WITH_TRIGGER = "Transitions with an exit point spec does not have a trigger or guard.";
 	public static final String ASSIGNMENT_TO_VALUE = "Assignment constant not allowed.";
 	public static final String REFERENCE_TO_VARIABLE = "Cannot reference a variable in a constant initialization.";
 	public static final String CONST_MUST_HAVE_VALUE_MSG = "A constant definition must specify an initial value";
 	public static final String CONST_MUST_HAVE_VALUE_CODE = "ConstMustHaveAValue";
-	public static final String REFERENCE_CONSTANT_BEFORE_DEFINED = "Cannot reference a constant from different scope or before it is defined.";	
+	public static final String REFERENCE_CONSTANT_BEFORE_DEFINED = "Cannot reference a constant from different scope or before it is defined.";
 	public static final String INTERNAL_DECLARATION_UNUSED = "Internal declaration is not used in statechart.";
 	public static final String ERROR_WRONG_ANNOTATION_TARGET_CODE = "WrongAnnotationTarget";
 	public static final String ERROR_WRONG_ANNOTATION_TARGET_MSG = "Annotation '%s' can not be applied on %s ";
@@ -62,5 +61,4 @@ public interface STextValidationMessages {
 	public static final String WRONG_NUMBER_OF_ARGUMENTS_MSG = "Wrong number of arguments, expected %s .";
 	public static final String WRONG_NUMBER_OF_ARGUMENTS_CODE = "WrongNrOfArgs";
 
-
 }

+ 0 - 1
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/DefaultExecutionContextInitializer.xtend

@@ -34,7 +34,6 @@ import org.yakindu.sct.simulation.core.sruntime.EventDirection
 import org.yakindu.sct.simulation.core.sruntime.ExecutionContext
 import org.yakindu.sct.simulation.core.sruntime.ExecutionSlot
 import org.yakindu.sct.simulation.core.sruntime.SRuntimeFactory
-import org.yakindu.sct.simulation.core.sruntime.impl.CompositeSlotImpl
 
 /**
  * 

+ 1 - 9
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/interpreter/DefaultExecutionSlotResolver.xtend

@@ -13,7 +13,6 @@ package org.yakindu.sct.simulation.core.sexec.interpreter
 import com.google.inject.Inject
 import java.util.Stack
 import org.eclipse.emf.ecore.EObject
-import org.eclipse.xtext.EcoreUtil2
 import org.eclipse.xtext.naming.IQualifiedNameProvider
 import org.eclipse.xtext.util.SimpleAttributeResolver
 import org.yakindu.base.base.NamedElement
@@ -21,13 +20,12 @@ import org.yakindu.base.expressions.expressions.AssignmentExpression
 import org.yakindu.base.expressions.expressions.ElementReferenceExpression
 import org.yakindu.base.expressions.expressions.FeatureCall
 import org.yakindu.base.types.Event
-import org.yakindu.base.types.Package
+import org.yakindu.base.types.Operation
 import org.yakindu.base.types.Property
 import org.yakindu.sct.model.stext.stext.InterfaceScope
 import org.yakindu.sct.simulation.core.sruntime.CompositeSlot
 import org.yakindu.sct.simulation.core.sruntime.ExecutionContext
 import org.yakindu.sct.simulation.core.sruntime.ExecutionSlot
-import org.yakindu.base.types.Operation
 
 /**
  * Default implementation for resolving execution slots based on expressions.
@@ -129,13 +127,7 @@ class DefaultExecutionSlotResolver implements IExecutionSlotResolver {
 	}
 	
 	def protected ExecutionSlot packageNamespaceAwareResolve(ExecutionContext context, EObject element) {
-		val pkg = EcoreUtil2.getContainerOfType(element, Package)
-		if (pkg != null && pkg.name != null) {
-			context.getSlot(pkg.name + "." + element.fullyQualifiedName.toString)
-		}
-		else {
 			context.getSlot(element.fullyQualifiedName.toString)
-		}
 	}
 
 	def protected name(EObject e) {