浏览代码

Removed Type System Registry - replaced by DomainRegistry

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

+ 0 - 8
plugins/org.yakindu.base.types/plugin.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.0"?>
 <plugin>
-   <extension-point id="typesystem" name="org.yakindu.base.types.typesystem" schema="schema/typesystem.exsd"/>
    <extension point="org.eclipse.emf.ecore.generated_package">
       <package
             uri="http://www.yakindu.org/base/types/2.0.0"
@@ -13,13 +12,6 @@
             uri="http://www.yakindu.org/base/base/2.0.0">
       </package>
    </extension>
-   <extension
-         point="org.yakindu.base.types.typesystem">
-      <contribution
-            domainID="org.yakindu.domain.default"
-            typesystem="org.yakindu.base.types.typesystem.DefaultTypeSystem">
-      </contribution>
-   </extension>
    <extension point="org.eclipse.emf.ecore.generated_package">
       <!-- @generated base -->
       <package

+ 0 - 109
plugins/org.yakindu.base.types/schema/typesystem.exsd

@@ -1,109 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.yakindu.base.types" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
-      <appInfo>
-         <meta.schema plugin="org.yakindu.base.types" id="typesystem" name="org.yakindu.base.types.typesystem"/>
-      </appInfo>
-      <documentation>
-         [Enter description of this extension point.]
-      </documentation>
-   </annotation>
-
-   <element name="extension">
-      <annotation>
-         <appInfo>
-            <meta.element />
-         </appInfo>
-      </annotation>
-      <complexType>
-         <sequence minOccurs="1" maxOccurs="unbounded">
-            <element ref="contribution"/>
-         </sequence>
-         <attribute name="point" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="id" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appInfo>
-                  <meta.attribute translatable="true"/>
-               </appInfo>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <element name="contribution">
-      <complexType>
-         <attribute name="typesystem" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appInfo>
-                  <meta.attribute kind="java" basedOn=":org.yakindu.base.types.ITypeSystem"/>
-               </appInfo>
-            </annotation>
-         </attribute>
-         <attribute name="domainID" type="string" use="required">
-            <annotation>
-               <documentation>
-                  The import uri scheme this type system is responsible for
-               </documentation>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="since"/>
-      </appInfo>
-      <documentation>
-         [Enter the first release in which this extension point appears.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="examples"/>
-      </appInfo>
-      <documentation>
-         [Enter extension point usage example here.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="apiinfo"/>
-      </appInfo>
-      <documentation>
-         [Enter API information here.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appInfo>
-         <meta.section type="implementation"/>
-      </appInfo>
-      <documentation>
-         [Enter information about supplied implementation of this extension point.]
-      </documentation>
-   </annotation>
-
-
-</schema>

+ 0 - 110
plugins/org.yakindu.base.types/src/org/yakindu/base/types/AbstractTypeSystemRegistry.java

@@ -1,110 +0,0 @@
-/**
- * Copyright (c) 2014 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.base.types;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.yakindu.base.types.typesystem.ITypeSystem;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public abstract class AbstractTypeSystemRegistry implements ITypeSystemRegistry {
-
-	private Multimap<String, ITypeSystem> typeSystemRegistry = ArrayListMultimap.create();
-
-	public Iterable<ITypeSystem> getTypeSystems(String typesystemID) {
-		return typeSystemRegistry.get(typesystemID);
-	}
-
-	protected void addTypeSystem(String uriScheme, ITypeSystem system) {
-		typeSystemRegistry.put(uriScheme, system);
-	}
-
-	@Override
-	public Iterable<ITypeSystem> getAllTypeSystems() {
-		return typeSystemRegistry.values();
-	}
-
-	@Override
-	public Collection<Type> getTypes(EObject context) {
-		List<Type> allTypes = Lists.newArrayList();
-		Iterable<ITypeSystem> allTypeSystems = getAllTypeSystems();
-		for (ITypeSystem iTypeSystem : allTypeSystems) {
-			allTypes.addAll(iTypeSystem.getTypes(context));
-		}
-		return allTypes;
-	}
-
-	@Override
-	public Type getType(String name) {
-		Iterable<ITypeSystem> allTypeSystems = getAllTypeSystems();
-		for (ITypeSystem iTypeSystem : allTypeSystems) {
-			if (iTypeSystem.getType(name) != null) {
-				return iTypeSystem.getType(name);
-			}
-		}
-		throw new IllegalArgumentException(String.format("Type %s not found ", name));
-	}
-
-	protected ITypeSystem getDelegate(Type type) {
-		Iterable<ITypeSystem> allTypeSystems = getAllTypeSystems();
-		for (ITypeSystem iTypeSystem : allTypeSystems) {
-			if (iTypeSystem.isTypeSystemFor(type))
-				return iTypeSystem;
-		}
-		throw new IllegalStateException(String.format("No Type System for type %s found!", type));
-	}
-
-	@Override
-	public boolean isSame(Type type1, Type type2) {
-		return getDelegate(type1).isSame(type1, type2);
-	}
-
-	@Override
-	public Type getCommonType(Type type1, Type type2) {
-		return getDelegate(type1).getCommonType(type1, type2);
-	}
-
-	@Override
-	public boolean haveCommonType(Type type1, Type type2) {
-		return getDelegate(type1).haveCommonType(type1, type2);
-	}
-
-	@Override
-	public Type getSuperType(Type type) {
-		return getDelegate(type).getSuperType(type);
-	}
-
-	@Override
-	public boolean isSuperType(Type subtype, Type supertype) {
-		return getDelegate(subtype).isSuperType(subtype, supertype);
-	}
-
-	@Override
-	public boolean isTypeSystemFor(Type type) {
-		return getDelegate(type) != null;
-	}
-
-	@Override
-	public Object defaultValue(Type type) {
-		return getDelegate(type).defaultValue(type);
-	}
-
-}

+ 0 - 61
plugins/org.yakindu.base.types/src/org/yakindu/base/types/DefaultTypeSystemRegistry.java

@@ -1,61 +0,0 @@
-/**
- * Copyright (c) 2014 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.base.types;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.yakindu.base.types.typesystem.ITypeSystem;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Singleton;
-
-/**
- * The default implementation of {@link ITypeSystemRegistry}. Loads all type
- * systems contributed via extension point org.yakindu.base.types.typesystem
- * This class is not intended to be subclassed.
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-@Singleton
-public class DefaultTypeSystemRegistry extends AbstractTypeSystemRegistry implements ITypeSystemRegistry {
-
-	private static final String EXTENSION_POINT_ID = "org.yakindu.base.types.typesystem";
-	private static final String ITYPESYSTEM_CLASS = "typesystem";
-	private static final String DOMAIN_ID = "domainID";
-
-	public DefaultTypeSystemRegistry() {
-		loadFromExtension();
-	}
-
-	protected synchronized void loadFromExtension() {
-		IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(
-				EXTENSION_POINT_ID);
-		for (IConfigurationElement element : configurationElements) {
-			try {
-				ITypeSystem typeSystem = (ITypeSystem) element.createExecutableExtension(ITYPESYSTEM_CLASS);
-				Guice.createInjector(new AbstractModule() {
-					@Override
-					protected void configure() {
-						bind(ITypeSystemRegistry.class).toInstance(DefaultTypeSystemRegistry.this);
-					}
-				}).injectMembers(typeSystem);
-				String attribute = element.getAttribute(DOMAIN_ID);
-				Assert.isNotNull(attribute);
-				addTypeSystem(attribute, typeSystem);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-		}
-	}
-}

+ 0 - 29
plugins/org.yakindu.base.types/src/org/yakindu/base/types/ITypeSystemRegistry.java

@@ -1,29 +0,0 @@
-/**
- * Copyright (c) 2014 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.base.types;
-
-import org.yakindu.base.types.typesystem.ITypeSystem;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-@ImplementedBy(DefaultTypeSystemRegistry.class)
-public interface ITypeSystemRegistry extends ITypeSystem {
-
-	public Iterable<ITypeSystem> getAllTypeSystems();
-	
-	public Iterable<ITypeSystem> getTypeSystems(String uriScheme);
-	
-}

+ 2 - 2
plugins/org.yakindu.base.types/src/org/yakindu/base/types/inferrer/AbstractTypeSystemInferrer.java

@@ -16,8 +16,8 @@ import java.util.Collections;
 
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.util.PolymorphicDispatcher;
-import org.yakindu.base.types.ITypeSystemRegistry;
 import org.yakindu.base.types.Type;
+import org.yakindu.base.types.typesystem.ITypeSystem;
 import org.yakindu.base.types.validation.IValidationIssueAcceptor;
 import org.yakindu.base.types.validation.IValidationIssueAcceptor.ListBasedValidationIssueAcceptor;
 import org.yakindu.base.types.validation.IValidationIssueAcceptor.ValidationIssue;
@@ -43,7 +43,7 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
 	private static final String METHOD_NAME = "infer";
 
 	@Inject
-	private ITypeSystemRegistry registry;
+	private ITypeSystem registry;
 
 	private IValidationIssueAcceptor acceptor;
 

+ 0 - 9
plugins/org.yakindu.base.types/src/org/yakindu/base/types/interpreter/DefaultTypeSystemInterpreter.java

@@ -11,12 +11,6 @@
 package org.yakindu.base.types.interpreter;
 
 import org.eclipse.emf.ecore.EObject;
-import org.yakindu.base.types.ITypeSystemRegistry;
-import org.yakindu.base.types.Type;
-import org.yakindu.base.types.typesystem.DefaultTypeSystem;
-import org.yakindu.base.types.typesystem.ITypeSystem;
-
-import com.google.inject.Inject;
 
 /**
  * @author andreas muelder - Initial contribution and API
@@ -24,9 +18,6 @@ import com.google.inject.Inject;
  */
 public class DefaultTypeSystemInterpreter extends AbstractTypeSystemInterpreter {
 
-	@Inject
-	private ITypeSystemRegistry typeSystem;
-
 	@Override
 	public Object interpret(EObject object) {
 		throw new IllegalArgumentException("not yet implemented");

+ 0 - 10
plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/AbstractTypeSystem.java

@@ -24,13 +24,10 @@ import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
 import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.yakindu.base.types.ITypeSystemRegistry;
 import org.yakindu.base.types.PrimitiveType;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.TypesFactory;
 
-import com.google.inject.Inject;
-
 /**
  * Abstract base implementation if {@link ITypeSystem}. Provides convenience
  * methods to determine type compatibility.
@@ -47,8 +44,6 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 	protected abstract void initStaticTypes();
 
 	private Resource resource;
-	@Inject
-	private ITypeSystemRegistry registry;
 
 	public AbstractTypeSystem() {
 		resource = new ResourceImpl(URI.createURI("types"));
@@ -181,9 +176,4 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 		}
 		return false;
 	}
-
-	public ITypeSystemRegistry getTypeSystemRegistry() {
-		return registry;
-	}
-
 }