浏览代码

Moved typescope to stext

Andreas Mülder 10 年之前
父节点
当前提交
555c3affa9

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

@@ -20,7 +20,6 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport,
  de.itemis.xtext.utils.gmf,
  org.eclipse.gmf.runtime.emf.core;bundle-version="1.4.1",
  org.yakindu.base.types;bundle-version="1.0.0",
- org.yakindu.base.types.scope;bundle-version="1.0.0",
  de.itemis.xtext.utils.jface;bundle-version="1.0.0",
  org.yakindu.base.expressions;bundle-version="1.0.0";visibility:=reexport,
  org.yakindu.sct.commons;bundle-version="2.1.2"

+ 0 - 1
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

@@ -20,7 +20,6 @@ import org.eclipse.xtext.scoping.IScope;
 import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider;
 import org.eclipse.xtext.scoping.impl.FilteringScope;
 import org.yakindu.base.types.ITypeSystemRegistry;
-import org.yakindu.base.types.scope.TypeSystemAwareScope;
 import org.yakindu.base.types.typesystem.ITypeSystem;
 
 import com.google.common.base.Predicate;

+ 56 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/TypeSystemAwareScope.java

@@ -0,0 +1,56 @@
+/**
+ * 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:
+ *     Alexander Nyssen (itemis AG) - initial API and implementation
+ */
+package org.yakindu.sct.model.stext.scoping;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.scoping.IScope;
+import org.eclipse.xtext.scoping.Scopes;
+import org.eclipse.xtext.scoping.impl.AbstractScope;
+import org.yakindu.base.types.ITypeSystemRegistry;
+import org.yakindu.base.types.typesystem.ITypeSystem;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class TypeSystemAwareScope extends AbstractScope {
+
+	private final ITypeSystemRegistry typeSystemAccess;
+
+	private final IQualifiedNameProvider qualifiedNameProvider;
+
+	private EClass eClass;
+
+	public TypeSystemAwareScope(IScope parent, ITypeSystemRegistry typeSystemAccess,
+			IQualifiedNameProvider qualifiedNameProvider, EClass eClass) {
+		super(parent, false);
+		this.typeSystemAccess = typeSystemAccess;
+		this.qualifiedNameProvider = qualifiedNameProvider;
+		this.eClass = eClass;
+	}
+
+	@Override
+	protected Iterable<IEObjectDescription> getAllLocalElements() {
+		List<IEObjectDescription> result = Lists.newArrayList();
+		Iterable<ITypeSystem> allTypeSystems = typeSystemAccess.getAllTypeSystems();
+		for (ITypeSystem iTypeSystem : allTypeSystems) {
+			Iterable<IEObjectDescription> iterable = Scopes.scopedElementsFor(
+					EcoreUtil2.<EObject> getObjectsByType(iTypeSystem.getTypes(), eClass), qualifiedNameProvider);
+			Iterables.addAll(result, iterable);
+		}
+		return result;
+	}
+}