Преглед изворни кода

removed contextPredicateProvider from STextProposalProvider (#1166)

* removed contextPredicateProvider from STextProposalProvider
Used GlobalURIScopeProvider

* removed sysout

* Updated tests

*  - Tranaitive Imports and DynamicClusteringPolicy for builder

* Disabled transitive imports
Andreas Mülder пре 9 година
родитељ
комит
176189d2a3

+ 7 - 0
plugins/org.yakindu.sct.model.stext.ui/plugin.xml

@@ -84,4 +84,11 @@
             </attribute>
         </markerResolutionGenerator>
     </extension>
+    
+     <extension
+        point="org.eclipse.xtext.ui.shared.overridingGuiceModule">
+     <module
+           class="org.yakindu.sct.model.stext.ui.OverridingGuiceModule">
+     </module>
+  </extension>
 </plugin>

+ 346 - 346
plugins/org.yakindu.sct.model.stext.ui/plugin.xml_gen

@@ -1,346 +1,346 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-
-<plugin>
-
-    <extension
-            point="org.eclipse.ui.editors">
-        <editor
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
-            contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
-            default="true"
-            extensions="stext"
-            id="org.yakindu.sct.model.stext.SText"
-            name="SText Editor">
-        </editor>
-    </extension>
-    <extension
-        point="org.eclipse.ui.handlers">
-        <handler
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
-            commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
-            <activeWhen>
-                <reference
-                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-                </reference>
-            </activeWhen>
-        </handler>
-        <handler
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
-            commandId="org.yakindu.sct.model.stext.SText.validate">
-         <activeWhen>
-            <reference
-                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-            </reference>
-         </activeWhen>
-      	</handler>
-      	<!-- copy qualified name -->
-        <handler
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
-            commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
-            <activeWhen>
-				<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened" />
-            </activeWhen>
-        </handler>
-        <handler
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
-            commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
-            <activeWhen>
-            	<and>
-            		<reference definitionId="org.yakindu.sct.model.stext.SText.XtextEditor.opened" />
-	                <iterate>
-						<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
-					</iterate>
-				</and>
-            </activeWhen>
-        </handler>
-    </extension>
-    <extension point="org.eclipse.core.expressions.definitions">
-        <definition id="org.yakindu.sct.model.stext.SText.Editor.opened">
-            <and>
-                <reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
-                <with variable="activeEditor">
-                    <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName" 
-                        value="org.yakindu.sct.model.stext.SText" 
-                        forcePluginActivation="true"/>
-                </with>        
-            </and>
-        </definition>
-        <definition id="org.yakindu.sct.model.stext.SText.XtextEditor.opened">
-            <and>
-                <reference definitionId="isXtextEditorActive"/>
-                <with variable="activeEditor">
-                    <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName" 
-                        value="org.yakindu.sct.model.stext.SText" 
-                        forcePluginActivation="true"/>
-                </with>        
-            </and>
-        </definition>
-    </extension>
-    <extension
-            point="org.eclipse.ui.preferencePages">
-        <page
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
-            id="org.yakindu.sct.model.stext.SText"
-            name="SText">
-            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
-        </page>
-        <page
-            category="org.yakindu.sct.model.stext.SText"
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
-            id="org.yakindu.sct.model.stext.SText.coloring"
-            name="Syntax Coloring">
-            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
-        </page>
-        <page
-            category="org.yakindu.sct.model.stext.SText"
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
-            id="org.yakindu.sct.model.stext.SText.templates"
-            name="Templates">
-            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
-        </page>
-    </extension>
-    <extension
-            point="org.eclipse.ui.propertyPages">
-        <page
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
-            id="org.yakindu.sct.model.stext.SText"
-            name="SText">
-            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
-            <enabledWhen>
-	            <adapt type="org.eclipse.core.resources.IProject"/>
-			</enabledWhen>
-	        <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
-        </page>
-    </extension>
-    <extension
-        point="org.eclipse.ui.keywords">
-        <keyword
-            id="org.yakindu.sct.model.stext.ui.keyword_SText"
-            label="SText"/>
-    </extension>
-    <extension
-         point="org.eclipse.ui.commands">
-      <command
-            description="Trigger expensive validation"
-            id="org.yakindu.sct.model.stext.SText.validate"
-            name="Validate">
-      </command>
-      <!-- copy qualified name -->
-      <command
-            id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
-            categoryId="org.eclipse.ui.category.edit"
-            description="Copy the qualified name for the selected element"
-            name="Copy Qualified Name">
-      </command>
-      <command
-            id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
-            categoryId="org.eclipse.ui.category.edit"
-            description="Copy the qualified name for the selected element"
-            name="Copy Qualified Name">
-      </command>
-    </extension>
-    <extension point="org.eclipse.ui.menus">
-        <menuContribution
-            locationURI="popup:#TextEditorContext?after=group.edit">
-             <command
-                 commandId="org.yakindu.sct.model.stext.SText.validate"
-                 style="push"
-                 tooltip="Trigger expensive validation">
-            <visibleWhen checkEnabled="false">
-                <reference
-                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-                </reference>
-            </visibleWhen>
-         </command>  
-         </menuContribution>
-         <!-- copy qualified name -->
-         <menuContribution locationURI="popup:#TextEditorContext?after=copy">
-         	<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName" 
-         		style="push" tooltip="Copy Qualified Name">
-            	<visibleWhen checkEnabled="false">
-                	<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened" />
-            	</visibleWhen>
-         	</command>  
-         </menuContribution>
-         <menuContribution locationURI="menu:edit?after=copy">
-         	<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
-            	style="push" tooltip="Copy Qualified Name">
-            	<visibleWhen checkEnabled="false">
-                	<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened" />
-            	</visibleWhen>
-         	</command>  
-         </menuContribution>
-         <menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
-			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName" 
-				style="push" tooltip="Copy Qualified Name">
-         		<visibleWhen checkEnabled="false">
-	            	<and>
-	            		<reference definitionId="org.yakindu.sct.model.stext.SText.XtextEditor.opened" />
-						<iterate>
-							<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
-						</iterate>
-					</and>
-				</visibleWhen>
-			</command>
-         </menuContribution>
-    </extension>
-    <extension point="org.eclipse.ui.menus">
-		<menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
-			<command commandId="org.eclipse.xtext.ui.editor.FindReferences">
-				<visibleWhen checkEnabled="false">
-                	<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-                	</reference>
-            	</visibleWhen>
-			</command>
-		</menuContribution>
-	</extension>
-	<extension point="org.eclipse.ui.handlers">
-	    <handler
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
-            commandId="org.eclipse.xtext.ui.editor.FindReferences">
-            <activeWhen>
-                <reference
-                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-                </reference>
-            </activeWhen>
-        </handler>
-    </extension>   
-
-<!-- adding resource factories -->
-
-	<extension
-		point="org.eclipse.emf.ecore.extension_parser">
-		<parser
-			class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
-			type="stext">
-		</parser>
-	</extension>
-	<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
-        <resourceServiceProvider
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
-            uriExtension="stext">
-        </resourceServiceProvider>
-    </extension>
-
-
-    <!-- marker definitions for org.yakindu.sct.model.stext.SText -->
-    <extension
-            id="stext.check.fast"
-            name="SText Problem"
-            point="org.eclipse.core.resources.markers">
-        <super type="org.eclipse.xtext.ui.check.fast"/>
-        <persistent value="true"/>
-    </extension>
-    <extension
-            id="stext.check.normal"
-            name="SText Problem"
-            point="org.eclipse.core.resources.markers">
-        <super type="org.eclipse.xtext.ui.check.normal"/>
-        <persistent value="true"/>
-    </extension>
-    <extension
-            id="stext.check.expensive"
-            name="SText Problem"
-            point="org.eclipse.core.resources.markers">
-        <super type="org.eclipse.xtext.ui.check.expensive"/>
-        <persistent value="true"/>
-    </extension>
-
-	<!-- Quick Outline -->
-	<extension
-		point="org.eclipse.ui.handlers">
-		<handler 
-			class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
-			commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
-			<activeWhen>
-				<reference
-					definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-				</reference>
-			</activeWhen>
-		</handler>
-	</extension>
-	<extension
-		point="org.eclipse.ui.commands">
-		<command
-			description="Open the quick outline."
-			id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
-			name="Quick Outline">
-		</command>
-	</extension>
-	<extension point="org.eclipse.ui.menus">
-		<menuContribution
-			locationURI="popup:#TextEditorContext?after=group.open">
-			<command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
-				style="push"
-				tooltip="Open Quick Outline">
-				<visibleWhen checkEnabled="false">
-					<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened"/>
-				</visibleWhen>
-			</command>
-		</menuContribution>
-	</extension>
-    <!-- quickfix marker resolution generator for org.yakindu.sct.model.stext.SText -->
-    <extension
-            point="org.eclipse.ui.ide.markerResolution">
-        <markerResolutionGenerator
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
-            markerType="org.yakindu.sct.model.stext.ui.stext.check.fast">
-            <attribute
-                name="FIXABLE_KEY"
-                value="true">
-            </attribute>
-        </markerResolutionGenerator>
-        <markerResolutionGenerator
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
-            markerType="org.yakindu.sct.model.stext.ui.stext.check.normal">
-            <attribute
-                name="FIXABLE_KEY"
-                value="true">
-            </attribute>
-        </markerResolutionGenerator>
-        <markerResolutionGenerator
-            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
-            markerType="org.yakindu.sct.model.stext.ui.stext.check.expensive">
-            <attribute
-                name="FIXABLE_KEY"
-                value="true">
-            </attribute>
-        </markerResolutionGenerator>
-    </extension>
-   	<!-- Rename Refactoring -->
-	<extension point="org.eclipse.ui.handlers">
-		<handler 
-			class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
-			commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
-			<activeWhen>
-				<reference
-					definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-				</reference>
-			</activeWhen>
-		</handler>
-	</extension>
-    <extension point="org.eclipse.ui.menus">
-         <menuContribution
-            locationURI="popup:#TextEditorContext?after=group.edit">
-         <command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
-               style="push">
-            <visibleWhen checkEnabled="false">
-               <reference
-                     definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
-               </reference>
-            </visibleWhen>
-         </command>
-      </menuContribution>
-   </extension>
-   <extension point="org.eclipse.ui.preferencePages">
-	    <page
-	        category="org.yakindu.sct.model.stext.SText"
-	        class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
-	        id="org.yakindu.sct.model.stext.SText.refactoring"
-	        name="Refactoring">
-	        <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
-	    </page>
-	</extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+
+    <extension
+            point="org.eclipse.ui.editors">
+        <editor
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
+            contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
+            default="true"
+            extensions="stext"
+            id="org.yakindu.sct.model.stext.SText"
+            name="SText Editor">
+        </editor>
+    </extension>
+    <extension
+        point="org.eclipse.ui.handlers">
+        <handler
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
+            commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
+            <activeWhen>
+                <reference
+                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+                </reference>
+            </activeWhen>
+        </handler>
+        <handler
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
+            commandId="org.yakindu.sct.model.stext.SText.validate">
+         <activeWhen>
+            <reference
+                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+            </reference>
+         </activeWhen>
+      	</handler>
+      	<!-- copy qualified name -->
+        <handler
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
+            commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
+            <activeWhen>
+				<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened" />
+            </activeWhen>
+        </handler>
+        <handler
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
+            commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
+            <activeWhen>
+            	<and>
+            		<reference definitionId="org.yakindu.sct.model.stext.SText.XtextEditor.opened" />
+	                <iterate>
+						<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
+					</iterate>
+				</and>
+            </activeWhen>
+        </handler>
+    </extension>
+    <extension point="org.eclipse.core.expressions.definitions">
+        <definition id="org.yakindu.sct.model.stext.SText.Editor.opened">
+            <and>
+                <reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
+                <with variable="activeEditor">
+                    <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName" 
+                        value="org.yakindu.sct.model.stext.SText" 
+                        forcePluginActivation="true"/>
+                </with>        
+            </and>
+        </definition>
+        <definition id="org.yakindu.sct.model.stext.SText.XtextEditor.opened">
+            <and>
+                <reference definitionId="isXtextEditorActive"/>
+                <with variable="activeEditor">
+                    <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName" 
+                        value="org.yakindu.sct.model.stext.SText" 
+                        forcePluginActivation="true"/>
+                </with>        
+            </and>
+        </definition>
+    </extension>
+    <extension
+            point="org.eclipse.ui.preferencePages">
+        <page
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
+            id="org.yakindu.sct.model.stext.SText"
+            name="SText">
+            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
+        </page>
+        <page
+            category="org.yakindu.sct.model.stext.SText"
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
+            id="org.yakindu.sct.model.stext.SText.coloring"
+            name="Syntax Coloring">
+            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
+        </page>
+        <page
+            category="org.yakindu.sct.model.stext.SText"
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
+            id="org.yakindu.sct.model.stext.SText.templates"
+            name="Templates">
+            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
+        </page>
+    </extension>
+    <extension
+            point="org.eclipse.ui.propertyPages">
+        <page
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
+            id="org.yakindu.sct.model.stext.SText"
+            name="SText">
+            <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
+            <enabledWhen>
+	            <adapt type="org.eclipse.core.resources.IProject"/>
+			</enabledWhen>
+	        <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
+        </page>
+    </extension>
+    <extension
+        point="org.eclipse.ui.keywords">
+        <keyword
+            id="org.yakindu.sct.model.stext.ui.keyword_SText"
+            label="SText"/>
+    </extension>
+    <extension
+         point="org.eclipse.ui.commands">
+      <command
+            description="Trigger expensive validation"
+            id="org.yakindu.sct.model.stext.SText.validate"
+            name="Validate">
+      </command>
+      <!-- copy qualified name -->
+      <command
+            id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+            categoryId="org.eclipse.ui.category.edit"
+            description="Copy the qualified name for the selected element"
+            name="Copy Qualified Name">
+      </command>
+      <command
+            id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
+            categoryId="org.eclipse.ui.category.edit"
+            description="Copy the qualified name for the selected element"
+            name="Copy Qualified Name">
+      </command>
+    </extension>
+    <extension point="org.eclipse.ui.menus">
+        <menuContribution
+            locationURI="popup:#TextEditorContext?after=group.edit">
+             <command
+                 commandId="org.yakindu.sct.model.stext.SText.validate"
+                 style="push"
+                 tooltip="Trigger expensive validation">
+            <visibleWhen checkEnabled="false">
+                <reference
+                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+                </reference>
+            </visibleWhen>
+         </command>  
+         </menuContribution>
+         <!-- copy qualified name -->
+         <menuContribution locationURI="popup:#TextEditorContext?after=copy">
+         	<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName" 
+         		style="push" tooltip="Copy Qualified Name">
+            	<visibleWhen checkEnabled="false">
+                	<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened" />
+            	</visibleWhen>
+         	</command>  
+         </menuContribution>
+         <menuContribution locationURI="menu:edit?after=copy">
+         	<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+            	style="push" tooltip="Copy Qualified Name">
+            	<visibleWhen checkEnabled="false">
+                	<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened" />
+            	</visibleWhen>
+         	</command>  
+         </menuContribution>
+         <menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
+			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName" 
+				style="push" tooltip="Copy Qualified Name">
+         		<visibleWhen checkEnabled="false">
+	            	<and>
+	            		<reference definitionId="org.yakindu.sct.model.stext.SText.XtextEditor.opened" />
+						<iterate>
+							<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
+						</iterate>
+					</and>
+				</visibleWhen>
+			</command>
+         </menuContribution>
+    </extension>
+    <extension point="org.eclipse.ui.menus">
+		<menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
+			<command commandId="org.eclipse.xtext.ui.editor.FindReferences">
+				<visibleWhen checkEnabled="false">
+                	<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+                	</reference>
+            	</visibleWhen>
+			</command>
+		</menuContribution>
+	</extension>
+	<extension point="org.eclipse.ui.handlers">
+	    <handler
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
+            commandId="org.eclipse.xtext.ui.editor.FindReferences">
+            <activeWhen>
+                <reference
+                    definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+                </reference>
+            </activeWhen>
+        </handler>
+    </extension>   
+
+<!-- adding resource factories -->
+
+	<extension
+		point="org.eclipse.emf.ecore.extension_parser">
+		<parser
+			class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
+			type="stext">
+		</parser>
+	</extension>
+	<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
+        <resourceServiceProvider
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
+            uriExtension="stext">
+        </resourceServiceProvider>
+    </extension>
+
+
+    <!-- marker definitions for org.yakindu.sct.model.stext.SText -->
+    <extension
+            id="stext.check.fast"
+            name="SText Problem"
+            point="org.eclipse.core.resources.markers">
+        <super type="org.eclipse.xtext.ui.check.fast"/>
+        <persistent value="true"/>
+    </extension>
+    <extension
+            id="stext.check.normal"
+            name="SText Problem"
+            point="org.eclipse.core.resources.markers">
+        <super type="org.eclipse.xtext.ui.check.normal"/>
+        <persistent value="true"/>
+    </extension>
+    <extension
+            id="stext.check.expensive"
+            name="SText Problem"
+            point="org.eclipse.core.resources.markers">
+        <super type="org.eclipse.xtext.ui.check.expensive"/>
+        <persistent value="true"/>
+    </extension>
+
+	<!-- Quick Outline -->
+	<extension
+		point="org.eclipse.ui.handlers">
+		<handler 
+			class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
+			commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
+			<activeWhen>
+				<reference
+					definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+				</reference>
+			</activeWhen>
+		</handler>
+	</extension>
+	<extension
+		point="org.eclipse.ui.commands">
+		<command
+			description="Open the quick outline."
+			id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
+			name="Quick Outline">
+		</command>
+	</extension>
+	<extension point="org.eclipse.ui.menus">
+		<menuContribution
+			locationURI="popup:#TextEditorContext?after=group.open">
+			<command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
+				style="push"
+				tooltip="Open Quick Outline">
+				<visibleWhen checkEnabled="false">
+					<reference definitionId="org.yakindu.sct.model.stext.SText.Editor.opened"/>
+				</visibleWhen>
+			</command>
+		</menuContribution>
+	</extension>
+    <!-- quickfix marker resolution generator for org.yakindu.sct.model.stext.SText -->
+    <extension
+            point="org.eclipse.ui.ide.markerResolution">
+        <markerResolutionGenerator
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+            markerType="org.yakindu.sct.model.stext.ui.stext.check.fast">
+            <attribute
+                name="FIXABLE_KEY"
+                value="true">
+            </attribute>
+        </markerResolutionGenerator>
+        <markerResolutionGenerator
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+            markerType="org.yakindu.sct.model.stext.ui.stext.check.normal">
+            <attribute
+                name="FIXABLE_KEY"
+                value="true">
+            </attribute>
+        </markerResolutionGenerator>
+        <markerResolutionGenerator
+            class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+            markerType="org.yakindu.sct.model.stext.ui.stext.check.expensive">
+            <attribute
+                name="FIXABLE_KEY"
+                value="true">
+            </attribute>
+        </markerResolutionGenerator>
+    </extension>
+   	<!-- Rename Refactoring -->
+	<extension point="org.eclipse.ui.handlers">
+		<handler 
+			class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
+			commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
+			<activeWhen>
+				<reference
+					definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+				</reference>
+			</activeWhen>
+		</handler>
+	</extension>
+    <extension point="org.eclipse.ui.menus">
+         <menuContribution
+            locationURI="popup:#TextEditorContext?after=group.edit">
+         <command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
+               style="push">
+            <visibleWhen checkEnabled="false">
+               <reference
+                     definitionId="org.yakindu.sct.model.stext.SText.Editor.opened">
+               </reference>
+            </visibleWhen>
+         </command>
+      </menuContribution>
+   </extension>
+   <extension point="org.eclipse.ui.preferencePages">
+	    <page
+	        category="org.yakindu.sct.model.stext.SText"
+	        class="org.yakindu.sct.model.stext.ui.STextExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
+	        id="org.yakindu.sct.model.stext.SText.refactoring"
+	        name="Refactoring">
+	        <keywordReference id="org.yakindu.sct.model.stext.ui.keyword_SText"/>
+	    </page>
+	</extension>
+
+</plugin>

+ 25 - 0
plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/OverridingGuiceModule.java

@@ -0,0 +1,25 @@
+/** 
+ * 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;
+
+import org.eclipse.xtext.resource.clustering.DynamicResourceClusteringPolicy;
+import org.eclipse.xtext.resource.clustering.IResourceClusteringPolicy;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+
+@SuppressWarnings("restriction")
+public class OverridingGuiceModule implements Module {
+	@Override
+	public void configure(Binder binder) {
+		binder.bind(IResourceClusteringPolicy.class).to(DynamicResourceClusteringPolicy.class);
+	}
+}

+ 6 - 0
plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/STextUiModule.java

@@ -12,6 +12,8 @@ package org.yakindu.sct.model.stext.ui;
 
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
+import org.eclipse.xtext.resource.clustering.DynamicResourceClusteringPolicy;
+import org.eclipse.xtext.resource.clustering.IResourceClusteringPolicy;
 import org.eclipse.xtext.tasks.ITaskFinder;
 import org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory.StatefulFactory;
 import org.eclipse.xtext.ui.editor.hover.DispatchingEObjectTextHover;
@@ -111,5 +113,9 @@ 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;
+	}
 
 }

+ 8 - 21
plugins/org.yakindu.sct.model.stext.ui/src/org/yakindu/sct/model/stext/ui/contentassist/STextProposalProvider.java

@@ -33,11 +33,9 @@ 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;
-import org.yakindu.base.types.TypesPackage;
 import org.yakindu.sct.model.stext.services.STextGrammarAccess;
 import org.yakindu.sct.model.stext.stext.InterfaceScope;
 import org.yakindu.sct.model.stext.stext.InternalScope;
@@ -45,10 +43,8 @@ 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;
 
 /**
@@ -192,31 +188,22 @@ public class STextProposalProvider extends AbstractSTextProposalProvider {
 		};
 	}
 
-	@Inject
-	protected ContextPredicateProvider contextProvider;
-
 	@Override
 	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);
+		lookupCrossReference(((CrossReference) assignment.getTerminal()), context, acceptor);
 	}
-	
+
 	@Override
 	public void completeSimpleElementReferenceExpression_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);
+		lookupCrossReference(((CrossReference) assignment.getTerminal()), context, acceptor);
 	}
-		
-	@Override	
-	public void completeTypeSpecifier_Type(EObject model, Assignment assignment,
-			ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
-		Predicate<IEObjectDescription> predicate = contextProvider.calculateFilterPredicate(context.getCurrentModel(),
-				TypesPackage.Literals.TYPE_SPECIFIER__TYPE);
-		lookupCrossReference(((CrossReference) assignment.getTerminal()), context, acceptor, predicate);
+
+	@Override
+	public void completeTypeSpecifier_Type(EObject model, Assignment assignment, ContentAssistContext context,
+			ICompletionProposalAcceptor acceptor) {
+		lookupCrossReference(((CrossReference) assignment.getTerminal()), context, acceptor);
 	}
 
 	@Override

+ 232 - 237
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/ContextPredicateProvider.java

@@ -1,237 +1,232 @@
-/**
- * Copyright (c) 2011 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.validation;
-
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION__EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.BITWISE_AND_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.BITWISE_OR_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.BITWISE_XOR_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.CONDITIONAL_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_AND_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_NOT_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_OR_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_RELATION_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.NUMERICAL_ADD_SUBTRACT_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.NUMERICAL_MULTIPLY_DIVIDE_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.NUMERICAL_UNARY_EXPRESSION;
-import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.SHIFT_EXPRESSION;
-import static org.yakindu.base.types.TypesPackage.Literals.TYPE_SPECIFIER__TYPE;
-import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.EVENT_RAISING_EXPRESSION;
-import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.EVENT_RAISING_EXPRESSION__VALUE;
-import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION;
-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 java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-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.Type;
-import org.yakindu.base.types.TypesPackage;
-import org.yakindu.base.types.resource.TypedResourceDescriptionStrategy;
-import org.yakindu.base.types.typesystem.GenericTypeValueProvider;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.stext.stext.StextPackage;
-import org.yakindu.sct.model.stext.stext.VariableDefinition;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-
-/**
- * @author andreas muelder - Initial contribution and API
- * @author axel terfloth - extensions to predicates
- * 
- */
-public class ContextPredicateProvider {
-
-	public static class TypePredicate implements Predicate<IEObjectDescription> {
-		public boolean apply(IEObjectDescription input) {
-			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) {
-			EClass eClass = input.getEClass();
-			
-			return (SGraphPackage.Literals.SCOPE.isSuperTypeOf(eClass)); 
-//					|| (TypesPackage.Literals.DECLARATION.isSuperTypeOf(eClass));
-		}
-	}
-
-	protected static EClass getVariableType(IEObjectDescription ieod) {
-		 EObject eObj = ieod.getEObjectOrProxy();
-		 if (eObj != null && (! eObj.eIsProxy()) ) {
-			 EObject eTS = (EObject) eObj.eGet(TypesPackage.Literals.TYPED_ELEMENT__TYPE_SPECIFIER, false);
-			 if (eTS != null && (! eTS.eIsProxy())) {
-				 EObject eT = (EObject) eObj.eGet(TypesPackage.Literals.TYPE_SPECIFIER__TYPE, false);
-				 if (eT != null) {
-					 return eT.eClass();
-				 }
-			 }
-		 }
-		 return TypesPackage.Literals.TYPE;
-	}
-	
-	
-	public static class EventPredicate extends FeaturedTypePredicate {
-		@Override
-		public boolean apply(IEObjectDescription input) {
-			if (super.apply(input))
-				return true;
-			return TypesPackage.Literals.EVENT.isSuperTypeOf(input.getEClass())	 || (TypesPackage.Literals.DECLARATION.isSuperTypeOf(input.getEClass()));
-		}
-	}
-
-	public static class VariablePredicate extends FeaturedTypePredicate {
-		@Override
-		public boolean apply(IEObjectDescription input) {
-			if (super.apply(input))
-				return true;
-			return TypesPackage.Literals.PROPERTY.isSuperTypeOf(input.getEClass());
-		}
-
-	};
-
-	public static class VariableOperationPredicate extends FeaturedTypePredicate {
-		@Override
-		public boolean apply(IEObjectDescription input) {
-			if (super.apply(input))
-				return true;
-			EClass eClass = input.getEClass();
-			return (TypesPackage.Literals.PROPERTY.isSuperTypeOf(eClass)
-					|| TypesPackage.Literals.OPERATION.isSuperTypeOf(eClass));
-		}
-	}
-
-	public static class VariableOperationEventEnumeratorPredicate extends FeaturedTypePredicate {
-		@Override
-		public boolean apply(IEObjectDescription input) {
-			if (super.apply(input))
-				return true;
-			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));
-		}
-	}
-
-	public static class EmptyPredicate implements Predicate<IEObjectDescription> {
-
-		public boolean apply(IEObjectDescription input) {
-			return true;
-		}
-
-	}
-
-	private static final EmptyPredicate EMPTY_PREDICATE = new EmptyPredicate();
-	private static final VariablePredicate VARIABLES = new VariablePredicate();
-	private static final EventPredicate EVENTS = new EventPredicate();
-	private static final VariableOperationPredicate VARIABLES_AND_OPERATIONS = new VariableOperationPredicate();
-	private static final VariableOperationEventEnumeratorPredicate VARIABLES_OPERATIONS_EVENTS_ENUMERATORS = new VariableOperationEventEnumeratorPredicate();
-	private static final TypePredicate TYPES = new TypePredicate();
-	private static final Predicate<IEObjectDescription> ALL = Predicates.<IEObjectDescription> alwaysTrue();
-
-	protected final Map<Pair<EClass, EReference>, Predicate<IEObjectDescription>> filter;
-
-	public ContextPredicateProvider() {
-		filter = new HashMap<Pair<EClass, EReference>, Predicate<IEObjectDescription>>();
-		initMap();
-	}
-
-	protected Pair<EClass, EReference> key(EClass eClass) {
-		return Tuples.create(eClass, null);
-	}
-
-	protected Pair<EClass, EReference> key(EClass eClass, EReference ref) {
-		return Tuples.create(eClass, ref);
-	}
-
-	protected void initMap() {
-		filter.put(key(ASSIGNMENT_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
-		filter.put(key(ASSIGNMENT_EXPRESSION, ASSIGNMENT_EXPRESSION__EXPRESSION), ALL);
-		filter.put(key(CONDITIONAL_EXPRESSION), VARIABLES_AND_OPERATIONS);
-		filter.put(key(LOGICAL_OR_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
-		filter.put(key(LOGICAL_AND_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
-		filter.put(key(LOGICAL_NOT_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
-		filter.put(key(BITWISE_XOR_EXPRESSION), VARIABLES);
-		filter.put(key(BITWISE_OR_EXPRESSION), VARIABLES);
-		filter.put(key(BITWISE_AND_EXPRESSION), VARIABLES);
-		filter.put(key(SHIFT_EXPRESSION), VARIABLES);
-		filter.put(key(LOGICAL_RELATION_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
-		filter.put(key(NUMERICAL_ADD_SUBTRACT_EXPRESSION), VARIABLES_AND_OPERATIONS);
-		filter.put(key(NUMERICAL_MULTIPLY_DIVIDE_EXPRESSION), VARIABLES_AND_OPERATIONS);
-		filter.put(key(NUMERICAL_UNARY_EXPRESSION), VARIABLES_AND_OPERATIONS);
-		filter.put(key(EVENT_RAISING_EXPRESSION), EVENTS);
-		filter.put(key(EVENT_RAISING_EXPRESSION, EVENT_RAISING_EXPRESSION__VALUE),
-				VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
-		filter.put(key(REGULAR_EVENT_SPEC), EVENTS);
-		filter.put(key(EVENT_VALUE_REFERENCE_EXPRESSION), EVENTS);
-		filter.put(key(REACTION_EFFECT), VARIABLES_AND_OPERATIONS);
-		filter.put(key(TRANSITION_SPECIFICATION), EVENTS);
-		filter.put(key(LOCAL_REACTION), VARIABLES_AND_OPERATIONS);
-		filter.put(key(TRANSITION_REACTION), VARIABLES_AND_OPERATIONS);
-		filter.put(key(VARIABLE_DEFINITION, TYPE_SPECIFIER__TYPE), TYPES);
-		filter.put(key(VARIABLE_DEFINITION, ELEMENT_REFERENCE_EXPRESSION__REFERENCE),
-				VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
-		filter.put(key(STATE_SPECIFICATION), EVENTS);
-	}
-
-	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));
-			if (predicate == null) {
-				return EMPTY_PREDICATE;
-			}
-		}
-		return predicate;
-	}
-
-	public Predicate<IEObjectDescription> calculateFilterPredicate(final EObject context, final EReference reference) {
-		Predicate<IEObjectDescription> predicate = Predicates.alwaysTrue();
-		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;
-	}
-	
-	
-	protected static boolean hasComplexType(IEObjectDescription input) {
-		String hasComplexType = input.getUserData(TypedResourceDescriptionStrategy.HAS_COMPLEX_TYPE);
-		return hasComplexType != null && Boolean.valueOf(hasComplexType);
-	}
-
-}
+/**
+ * Copyright (c) 2011 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 static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION__EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.BITWISE_AND_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.BITWISE_OR_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.BITWISE_XOR_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.CONDITIONAL_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_AND_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_NOT_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_OR_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.LOGICAL_RELATION_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.NUMERICAL_ADD_SUBTRACT_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.NUMERICAL_MULTIPLY_DIVIDE_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.NUMERICAL_UNARY_EXPRESSION;
+import static org.yakindu.base.expressions.expressions.ExpressionsPackage.Literals.SHIFT_EXPRESSION;
+import static org.yakindu.base.types.TypesPackage.Literals.TYPE_SPECIFIER__TYPE;
+import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.EVENT_RAISING_EXPRESSION;
+import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.EVENT_RAISING_EXPRESSION__VALUE;
+import static org.yakindu.sct.model.stext.stext.StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION;
+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 java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+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.TypesPackage;
+import org.yakindu.base.types.resource.TypedResourceDescriptionStrategy;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * @author axel terfloth - extensions to predicates
+ * 
+ */
+public class ContextPredicateProvider {
+
+	public static class TypePredicate implements Predicate<IEObjectDescription> {
+		public boolean apply(IEObjectDescription input) {
+			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) {
+			EClass eClass = input.getEClass();
+			
+			return (SGraphPackage.Literals.SCOPE.isSuperTypeOf(eClass)); 
+//					|| (TypesPackage.Literals.DECLARATION.isSuperTypeOf(eClass));
+		}
+	}
+
+	protected static EClass getVariableType(IEObjectDescription ieod) {
+		 EObject eObj = ieod.getEObjectOrProxy();
+		 if (eObj != null && (! eObj.eIsProxy()) ) {
+			 EObject eTS = (EObject) eObj.eGet(TypesPackage.Literals.TYPED_ELEMENT__TYPE_SPECIFIER, false);
+			 if (eTS != null && (! eTS.eIsProxy())) {
+				 EObject eT = (EObject) eObj.eGet(TypesPackage.Literals.TYPE_SPECIFIER__TYPE, false);
+				 if (eT != null) {
+					 return eT.eClass();
+				 }
+			 }
+		 }
+		 return TypesPackage.Literals.TYPE;
+	}
+	
+	
+	public static class EventPredicate extends FeaturedTypePredicate {
+		@Override
+		public boolean apply(IEObjectDescription input) {
+			if (super.apply(input))
+				return true;
+			return TypesPackage.Literals.EVENT.isSuperTypeOf(input.getEClass())	 || (TypesPackage.Literals.DECLARATION.isSuperTypeOf(input.getEClass()));
+		}
+	}
+
+	public static class VariablePredicate extends FeaturedTypePredicate {
+		@Override
+		public boolean apply(IEObjectDescription input) {
+			if (super.apply(input))
+				return true;
+			return TypesPackage.Literals.PROPERTY.isSuperTypeOf(input.getEClass());
+		}
+
+	};
+
+	public static class VariableOperationPredicate extends FeaturedTypePredicate {
+		@Override
+		public boolean apply(IEObjectDescription input) {
+			if (super.apply(input))
+				return true;
+			EClass eClass = input.getEClass();
+			return (TypesPackage.Literals.PROPERTY.isSuperTypeOf(eClass)
+					|| TypesPackage.Literals.OPERATION.isSuperTypeOf(eClass));
+		}
+	}
+
+	public static class VariableOperationEventEnumeratorPredicate extends FeaturedTypePredicate {
+		@Override
+		public boolean apply(IEObjectDescription input) {
+			if (super.apply(input))
+				return true;
+			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));
+		}
+	}
+
+	public static class EmptyPredicate implements Predicate<IEObjectDescription> {
+
+		public boolean apply(IEObjectDescription input) {
+			return true;
+		}
+
+	}
+
+	private static final EmptyPredicate EMPTY_PREDICATE = new EmptyPredicate();
+	private static final VariablePredicate VARIABLES = new VariablePredicate();
+	private static final EventPredicate EVENTS = new EventPredicate();
+	private static final VariableOperationPredicate VARIABLES_AND_OPERATIONS = new VariableOperationPredicate();
+	private static final VariableOperationEventEnumeratorPredicate VARIABLES_OPERATIONS_EVENTS_ENUMERATORS = new VariableOperationEventEnumeratorPredicate();
+	private static final TypePredicate TYPES = new TypePredicate();
+	private static final Predicate<IEObjectDescription> ALL = Predicates.<IEObjectDescription> alwaysTrue();
+
+	protected final Map<Pair<EClass, EReference>, Predicate<IEObjectDescription>> filter;
+
+	public ContextPredicateProvider() {
+		filter = new HashMap<Pair<EClass, EReference>, Predicate<IEObjectDescription>>();
+		initMap();
+	}
+
+	protected Pair<EClass, EReference> key(EClass eClass) {
+		return Tuples.create(eClass, null);
+	}
+
+	protected Pair<EClass, EReference> key(EClass eClass, EReference ref) {
+		return Tuples.create(eClass, ref);
+	}
+
+	protected void initMap() {
+		filter.put(key(ASSIGNMENT_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(ASSIGNMENT_EXPRESSION, ASSIGNMENT_EXPRESSION__EXPRESSION), ALL);
+		filter.put(key(CONDITIONAL_EXPRESSION), VARIABLES_AND_OPERATIONS);
+		filter.put(key(LOGICAL_OR_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(LOGICAL_AND_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(LOGICAL_NOT_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(BITWISE_XOR_EXPRESSION), VARIABLES);
+		filter.put(key(BITWISE_OR_EXPRESSION), VARIABLES);
+		filter.put(key(BITWISE_AND_EXPRESSION), VARIABLES);
+		filter.put(key(SHIFT_EXPRESSION), VARIABLES);
+		filter.put(key(LOGICAL_RELATION_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(NUMERICAL_ADD_SUBTRACT_EXPRESSION), VARIABLES_AND_OPERATIONS);
+		filter.put(key(NUMERICAL_MULTIPLY_DIVIDE_EXPRESSION), VARIABLES_AND_OPERATIONS);
+		filter.put(key(NUMERICAL_UNARY_EXPRESSION), VARIABLES_AND_OPERATIONS);
+		filter.put(key(EVENT_RAISING_EXPRESSION), EVENTS);
+		filter.put(key(EVENT_RAISING_EXPRESSION, EVENT_RAISING_EXPRESSION__VALUE),
+				VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(REGULAR_EVENT_SPEC), EVENTS);
+		filter.put(key(EVENT_VALUE_REFERENCE_EXPRESSION), EVENTS);
+		filter.put(key(REACTION_EFFECT), VARIABLES_AND_OPERATIONS);
+		filter.put(key(TRANSITION_SPECIFICATION), EVENTS);
+		filter.put(key(LOCAL_REACTION), VARIABLES_AND_OPERATIONS);
+		filter.put(key(TRANSITION_REACTION), VARIABLES_AND_OPERATIONS);
+		filter.put(key(VARIABLE_DEFINITION, TYPE_SPECIFIER__TYPE), TYPES);
+		filter.put(key(VARIABLE_DEFINITION, ELEMENT_REFERENCE_EXPRESSION__REFERENCE),
+				VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(STATE_SPECIFICATION), EVENTS);
+	}
+
+	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));
+			if (predicate == null) {
+				return EMPTY_PREDICATE;
+			}
+		}
+		return predicate;
+	}
+
+	public Predicate<IEObjectDescription> calculateFilterPredicate(final EObject context, final EReference reference) {
+		Predicate<IEObjectDescription> predicate = Predicates.alwaysTrue();
+		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;
+	}
+	
+	
+	protected static boolean hasComplexType(IEObjectDescription input) {
+		String hasComplexType = input.getUserData(TypedResourceDescriptionStrategy.HAS_COMPLEX_TYPE);
+		return hasComplexType != null && Boolean.valueOf(hasComplexType);
+	}
+
+}

+ 78 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

@@ -10,6 +10,11 @@
  */
 package org.yakindu.sct.model.stext.scoping;
 
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+
+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;
@@ -20,29 +25,49 @@ import org.eclipse.xtext.resource.IEObjectDescription;
 import org.eclipse.xtext.scoping.IScope;
 import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider;
 import org.eclipse.xtext.scoping.impl.FilteringScope;
+import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
+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.stext.ImportScope;
+import org.yakindu.sct.model.stext.stext.StatechartSpecification;
+import org.yakindu.sct.model.stext.stext.StextPackage;
 
 import com.google.common.base.Predicate;
 import com.google.inject.Inject;
+import com.google.inject.Provider;
 
 /**
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class STextGlobalScopeProvider extends DefaultGlobalScopeProvider {
+public class STextGlobalScopeProvider extends ImportUriGlobalScopeProvider {
 
 	@Inject
 	private ITypeSystem typeSystem;
 	@Inject
 	private IQualifiedNameProvider qualifiedNameProvider;
+	@Inject
+	private IResourceScopeCache cache;
+	@Inject
+	private DefaultGlobalScopeProvider delegate;
+
+	public void setCache(IResourceScopeCache cache) {
+		this.cache = cache;
+	}
 
 	public static final String FILE_EXTENSION = "sct";
 
 	public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
+		if (reference.getEReferenceType() == TypesPackage.Literals.PACKAGE) {
+			return delegate.getScope(context, reference, filter);
+		}
 		IScope parentScope = super.getScope(context, reference, filter);
 		parentScope = filterExternalDeclarations(context, parentScope);
 		final Statechart statechart = getStatechart(context);
@@ -54,15 +79,66 @@ public class STextGlobalScopeProvider extends DefaultGlobalScopeProvider {
 				String userData = input.getUserData(DomainRegistry.DOMAIN_ID);
 				if (userData == null)
 					return true;
+
 				return statechart.getDomainID().equals(userData);
 			}
 		});
 	}
 
+	@Override
+	public IScope getScope(Resource resource, EReference reference) {
+		if (reference.getEReferenceType() == TypesPackage.Literals.PACKAGE) {
+			return delegate.getScope(resource, reference);
+		}
+		return super.getScope(resource, reference);
+	}
+
+	protected LinkedHashSet<URI> getImportedUris(final Resource resource) {
+		return cache.get(ImportUriGlobalScopeProvider.class.getName(), resource, new Provider<LinkedHashSet<URI>>() {
+			@Override
+			public LinkedHashSet<URI> get() {
+				final LinkedHashSet<URI> uniqueImportURIs = new LinkedHashSet<URI>(5);
+				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);
+					}
+				}
+				Iterator<URI> uriIter = uniqueImportURIs.iterator();
+				while (uriIter.hasNext()) {
+					if (!EcoreUtil2.isValidUri(resource, uriIter.next()))
+						uriIter.remove();
+				}
+				return uniqueImportURIs;
+			}
+
+			private Collection<ImportScope> getImportScopes(final Resource resource) {
+				StatechartSpecification specification = (StatechartSpecification) EcoreUtil
+						.getObjectByType(resource.getContents(), StextPackage.Literals.STATECHART_SPECIFICATION);
+				if (specification != null) {
+					return EcoreUtil.getObjectsByType(specification.getScopes(), StextPackage.Literals.IMPORT_SCOPE);
+				} else {
+					Statechart statechart = getStatechart(resource);
+					return EcoreUtil.getObjectsByType(statechart.getScopes(), StextPackage.Literals.IMPORT_SCOPE);
+				}
+			}
+		});
+	}
+
+	protected void collectPackageImports(Package package1, IAcceptor<String> acceptor,
+			LinkedHashSet<URI> uniqueImportURIs) {
+		EcoreUtil.resolveAll(package1);
+		if (package1.eIsProxy())
+			return;
+		String uri = EcoreUtil.getURI(package1).trimFragment().toString();
+		acceptor.accept(uri);
+	}
+
 	private Statechart getStatechart(Resource context) {
 		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(context,
 				ContextElementAdapter.class);
-
 		if (provider == null) {
 			return (Statechart) EcoreUtil2.getObjectByType(context.getContents(), SGraphPackage.Literals.STATECHART);
 		} else {

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

@@ -20,9 +20,12 @@ 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;
@@ -37,9 +40,12 @@ 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;
 
@@ -54,9 +60,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;
@@ -77,7 +83,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		}
 
 	}
-
+	
 	@Override
 	public IScope getScope(EObject context, EReference reference) {
 		try {
@@ -92,17 +98,31 @@ 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) {
-		return getDelegate().getScope(context, reference);
+		IScope scope = getDelegate().getScope(context, reference);
+		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
+		return new FilteringScope(scope, predicate);
 	}
 
 	public IScope scope_ElementReferenceExpression_reference(final EObject context, EReference reference) {
-		IScope scope = getUnnamedTopLevelScope(context, reference);
-		scope = getNamedTopLevelScope(context, reference, scope);
-		return scope;
+		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()));
 	}
 
 	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) {
@@ -118,30 +138,53 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		Type ownerType = result != null ? result.getType() : null;
 
 		if (element instanceof Scope) {
-			return Scopes.scopeFor(((Scope) element).getDeclarations());
-		} else if (ownerType != null) {
+			scope = Scopes.scopeFor(((Scope) element).getDeclarations());
+			return new FilteringScope(scope, predicate);
+		}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);
+			return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
 		}
 		if (ownerType instanceof EnumerationType) {
-			return addScopeForEnumType((EnumerationType) ownerType, scope);
+			return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
 		}
 		return scope;
 	}
 
-	protected IScope addScopeForEnumType(EnumerationType element, IScope scope) {
-		return Scopes.scopeFor((element).getEnumerator(), 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 addScopeForComplexType(final ComplexType type, IScope scope) {
-		return Scopes.scopeFor(type.getAllFeatures(), 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 getNamedTopLevelScope(final EObject context, EReference reference, IScope outer) {
+	/**
+	 * Returns the toplevel scope
+	 */
+	protected IScope getNamedTopLevelScope(final EObject context, EReference reference) {
 		List<EObject> scopeCandidates = Lists.newArrayList();
 		Statechart statechart = getStatechart(context);
 		if (statechart == null)
@@ -155,9 +198,12 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 				}
 			}
 		}
-		return Scopes.scopeFor(scopeCandidates, outer);
+		return Scopes.scopeFor(scopeCandidates);
 	}
 
+	/**
+	 * 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);
@@ -180,6 +226,9 @@ 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);

+ 17 - 64
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

@@ -33,12 +33,7 @@ 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.IDefaultResourceDescriptionStrategy;
-import org.eclipse.xtext.resource.IEObjectDescription;
-import org.eclipse.xtext.resource.IResourceDescriptions;
 import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions;
-import org.eclipse.xtext.util.IAcceptor;
 import org.eclipse.xtext.validation.Check;
 import org.eclipse.xtext.validation.CheckType;
 import org.eclipse.xtext.validation.ComposedChecks;
@@ -130,43 +125,6 @@ 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;
-	@Inject
-	private IResourceDescriptions index;
-	@Inject
-	private IDefaultResourceDescriptionStrategy strategy;
-
-	@Check(CheckType.FAST)
-	public void checkContextElement(final ElementReferenceExpression expression) {
-		Iterable<IEObjectDescription> description = null;
-		QualifiedName fqn = nameProvider.getFullyQualifiedName(expression.getReference());
-		if (index instanceof ResourceSetBasedResourceDescriptions) {
-			//This is the fallback for headless execution
-			description = createEObjectDescription(expression);
-		} else {
-			description = index.getExportedObjects(expression.getReference().eClass(), fqn, false);
-		}
-		final Predicate<IEObjectDescription> predicate = contextPredicateProvider.calculateFilterPredicate(expression,
-				ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE);
-		for (IEObjectDescription desc : description) {
-			if (!predicate.apply(desc)) {
-				String name = expression.getReference().eClass().getName();
-				error(String.format(ERROR_WRONG_CONTEXT_ELEMENT_MSG, name), null, -1, ERROR_WRONG_CONTEXT_ELEMENT_CODE);
-			}
-		}
-	}
-
-	protected List<IEObjectDescription> createEObjectDescription(final ElementReferenceExpression expression) {
-		final List<IEObjectDescription> result = Lists.newArrayList();
-		strategy.createEObjectDescriptions(expression.getReference(),new IAcceptor<IEObjectDescription>() {
-			@Override
-			public void accept(IEObjectDescription t) {
-				result.add(t);
-			}
-		} );
-		return result;
-	}
 
 	@Check(CheckType.FAST)
 	public void checkExpression(VariableDefinition expression) {
@@ -366,31 +324,28 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 
 	}
 
-	
 	@Check(CheckType.FAST)
-	public void checkValueOfNoEvent(EventValueReferenceExpression exp){
-		
+	public void checkValueOfNoEvent(EventValueReferenceExpression exp) {
+
 		Expression eventExpr = exp.getValue();
-		
+
 		EObject element = null;
 		if (eventExpr instanceof ElementReferenceExpression) {
-			element =  ((ElementReferenceExpression) eventExpr).getReference();
+			element = ((ElementReferenceExpression) eventExpr).getReference();
 		} else if (eventExpr instanceof FeatureCall) {
 			element = ((FeatureCall) eventExpr).getFeature();
 		}
-		
-		if (element != null && (! (element instanceof Event))) {
+
+		if (element != null && (!(element instanceof Event))) {
 			String elementName = "";
-			if ( element instanceof NamedElement ) {
-				elementName = "'" + ((NamedElement) element).getName() +"' ";
+			if (element instanceof NamedElement) {
+				elementName = "'" + ((NamedElement) element).getName() + "' ";
 			}
-			error( elementName + "is no event.",
-					StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION__VALUE, 0,
+			error(elementName + "is no event.", StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION__VALUE, 0,
 					VALUE_OF_REQUIRES_EVENT);
 		}
 	}
 
-	
 	@Check(CheckType.NORMAL)
 	public void checkValueReferenedBeforeDefined(Scope scope) {
 		EList<Declaration> declarations = scope.getDeclarations();
@@ -668,32 +623,30 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 
 	@Check(CheckType.FAST)
 	public void checkReactionTriggerRegularEvent(ReactionTrigger reactionTrigger) {
-		for (int i=0; i<reactionTrigger.getTriggers().size(); i++) {
+		for (int i = 0; i < reactionTrigger.getTriggers().size(); i++) {
 			EventSpec eventSpec = reactionTrigger.getTriggers().get(i);
 			if (eventSpec instanceof RegularEventSpec) {
 
 				Expression eventExpression = ((RegularEventSpec) eventSpec).getEvent();
 				EObject element = null;
 				if (eventExpression instanceof ElementReferenceExpression) {
-					element =  ((ElementReferenceExpression) eventExpression).getReference();
+					element = ((ElementReferenceExpression) eventExpression).getReference();
 				} else if (eventExpression instanceof FeatureCall) {
 					element = ((FeatureCall) eventExpression).getFeature();
 				}
-				
-				if (element != null && (! (element instanceof Event))) {
+
+				if (element != null && (!(element instanceof Event))) {
 					String elementName = "";
-					if ( element instanceof NamedElement ) {
-						elementName = "'" + ((NamedElement) element).getName() +"' ";
+					if (element instanceof NamedElement) {
+						elementName = "'" + ((NamedElement) element).getName() + "' ";
 					}
-					error("Trigger " + elementName + "is no event.",
-							StextPackage.Literals.REACTION_TRIGGER__TRIGGERS, i,
-							TRIGGER_IS_NO_EVENT);
+					error("Trigger " + elementName + "is no event.", StextPackage.Literals.REACTION_TRIGGER__TRIGGERS,
+							i, TRIGGER_IS_NO_EVENT);
 				}
 			}
 		}
 	}
 
-	
 	/**
 	 * Only Expressions that produce an effect should be used as actions.
 	 * 

+ 0 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java

@@ -54,8 +54,6 @@ public interface STextValidationMessages {
 	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 ";
-	public static final String ERROR_WRONG_CONTEXT_ELEMENT_MSG = "Element of type '%s' is not allowed in this context.";
-	public static final String ERROR_WRONG_CONTEXT_ELEMENT_CODE = "ElementNotAllowedInContext";
 	
 	public static final String VALUE_OF_REQUIRES_EVENT = "valueof() expression requires event as argument.";
 

+ 1 - 1
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/AllTests.java

@@ -24,7 +24,7 @@ import org.yakindu.sct.model.stext.test.validation.TransitionsWithNoTriggerTest;
 @RunWith(value = Suite.class)
 @SuiteClasses(value = { TypeInferrerTest.class, StextParserRuleTest.class, TestModelsContainErrorsTest.class,
 		SCTUnitClassifierTest.class, STextJavaValidatorTest.class, TransitionsWithNoTriggerTest.class,
-		ContextPredicateProviderTest.class })
+		STextScopeProviderTest.class })
 
 public class AllTests {
 }

+ 20 - 17
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/ContextPredicateProviderTest.java

@@ -10,30 +10,30 @@
 */
 package org.yakindu.sct.model.stext.test;
 
+import static org.junit.Assert.fail;
+
 import java.util.Arrays;
 
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.junit4.validation.AssertableDiagnostics;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 import org.yakindu.base.expressions.expressions.Expression;
+import org.yakindu.sct.model.stext.expressions.STextExpressionParser.LinkingException;
+import org.yakindu.sct.model.stext.scoping.ContextPredicateProvider;
 import org.yakindu.sct.model.stext.stext.LocalReaction;
 import org.yakindu.sct.model.stext.stext.ReactionEffect;
 import org.yakindu.sct.model.stext.stext.ReactionTrigger;
 import org.yakindu.sct.model.stext.stext.VariableDefinition;
+import org.yakindu.sct.model.stext.test.util.AbstractSTextTest;
 import org.yakindu.sct.model.stext.test.util.STextInjectorProvider;
-import org.yakindu.sct.model.stext.test.validation.AbstractSTextValidationTest;
-import org.yakindu.sct.model.stext.validation.ContextPredicateProvider;
-import org.yakindu.sct.model.stext.validation.STextValidationMessages;
 
 /**
  * @author andreas muelder - Initial contribution and API
  * @author Johannes Dicks - Add tests covering {@link ContextPredicateProvider}
  */
 @RunWith(Parameterized.class)
-public class ContextPredicateProviderTest extends AbstractSTextValidationTest {
+public class STextScopeProviderTest extends AbstractSTextTest {
 
 	public static final String INTERNAL_SCOPE = "" + //
 			"internal: " + //
@@ -59,13 +59,13 @@ public class ContextPredicateProviderTest extends AbstractSTextValidationTest {
 	private String statement;
 	private String ruleName;
 	private String scopes;
-	private boolean valid;
-
-	public ContextPredicateProviderTest(String statement, String ruleName, String scopes, Boolean isLinkable) {
+	private boolean isLinkable;
+	
+	public STextScopeProviderTest(String statement, String ruleName, String scopes, Boolean isLinkable) {
 		this.statement = statement;
 		this.ruleName = ruleName;
 		this.scopes = scopes;
-		this.valid = isLinkable;
+		this.isLinkable = isLinkable;
 
 		STextInjectorProvider provider = new STextInjectorProvider();
 		provider.getInjector().injectMembers(this);
@@ -73,12 +73,15 @@ public class ContextPredicateProviderTest extends AbstractSTextValidationTest {
 
 	@Test
 	public void test() {
-		EObject expression = parseExpression(statement, ruleName, scopes);
-		AssertableDiagnostics validationResult = tester.validate(expression);
-		if (!valid) {
-			validationResult.assertAny(AssertableDiagnostics.errorCode(STextValidationMessages.ERROR_WRONG_CONTEXT_ELEMENT_CODE));
-		} else {
-			validationResult.assertOK();
+		try {
+			parseExpression(statement, ruleName, scopes);
+			if (!isLinkable)
+				fail(String.format(
+						"Expected not to be linkable [parse '%s' in rule '%s' for scope '%s' expected linkable = '%s']",
+						statement, ruleName, scopes, isLinkable));
+		} catch (LinkingException e) {
+			if (isLinkable)
+				throw new RuntimeException("Expected linkable but : "+e.getMessage(),e);
 		}
 	}
 
@@ -242,4 +245,4 @@ public class ContextPredicateProviderTest extends AbstractSTextValidationTest {
 				//{ "myInt / myInt = 10", LocalReaction.class.getSimpleName(), INTERNAL_SCOPE, true }, // context predicates can't validate this expression. This will be done in the SText validation instead.
 		});
 	}
-}
+}