Skip to content
Snippets Groups Projects
Commit fef07932 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

cleanup: Class<? extends Object> -> Class<?>

refs 153
parent ef7169a1
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 59 deletions
...@@ -165,7 +165,7 @@ public class MarkerService implements IMarkerService, ...@@ -165,7 +165,7 @@ public class MarkerService implements IMarkerService,
List<IConstraintViolation<? extends EObject>> checkResult = IConstraintCheckerService.INSTANCE List<IConstraintViolation<? extends EObject>> checkResult = IConstraintCheckerService.INSTANCE
.performAllConstraintChecksRecursively(element .performAllConstraintChecksRecursively(element
.getTopLevelElement()); .getRootModelElement());
synchronized (violationCache) { synchronized (violationCache) {
CacheEntry entry = getCacheEntry(element); CacheEntry entry = getCacheEntry(element);
entry.updateCacheEntries(checkResult); entry.updateCacheEntries(checkResult);
...@@ -305,7 +305,7 @@ public class MarkerService implements IMarkerService, ...@@ -305,7 +305,7 @@ public class MarkerService implements IMarkerService,
} }
} }
// project severity to parent // project severity to parent
computeHighestSeverity(topElement.getTopLevelElement()); computeHighestSeverity(topElement.getRootModelElement());
} }
/** Recursively projects highest severity from children to parents. */ /** Recursively projects highest severity from children to parents. */
......
...@@ -47,7 +47,7 @@ public class NavigatorTreeContentProvider implements ITreeContentProvider { ...@@ -47,7 +47,7 @@ public class NavigatorTreeContentProvider implements ITreeContentProvider {
for (ITopLevelElement context : IPersistencyService.INSTANCE for (ITopLevelElement context : IPersistencyService.INSTANCE
.getTopLevelElements()) { .getTopLevelElements()) {
result.add(context.getTopLevelElement()); result.add(context.getRootModelElement());
} }
return result.toArray(); return result.toArray();
} }
......
...@@ -24,24 +24,21 @@ import org.fortiss.tooling.kernel.service.ITransformationService; ...@@ -24,24 +24,21 @@ import org.fortiss.tooling.kernel.service.ITransformationService;
import org.fortiss.tooling.kernel.service.base.IObjectAware2; import org.fortiss.tooling.kernel.service.base.IObjectAware2;
/** /**
* TODO: why do you mean with "extends the {@link ITransformationService}"? * A transformation provider represents a concrete transformation from a source
* where is the extension? * element into a target element and is registered with the
* * {@link ITransformationService}'s extension point. Since transformations may
* A transformation provider extends the {@link ITransformationService} with a * also produce intermediary data, which is not intended to be persisted, this
* concrete transformation from a source element into a target element. Since * class uses {@link Object} instead of {@link EObject}s only.
* transformations may also produce intermediary data, which is not intended to
* be persisted, this class uses {@link Object} instead of {@link EObject}s
* only.
* *
* @author hoelzl * @author hoelzl
* @author $Author$ * @author $Author$
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating RED Hash: 85C9BC59354ADFA207E0852126747DC3 * @ConQAT.Rating YELLOW Hash: D798E691812994DC6321748E8CAC1C20
*/ */
public interface ITransformationProvider extends IObjectAware2<Object, Object> { public interface ITransformationProvider extends IObjectAware2<Object, Object> {
/** Returns the target class this provider can provide. */ /** Returns the target class this provider can provide. */
Class<? extends Object> getTargetClass(); Class<?> getTargetClass();
/** /**
* Returns whether this provider is able to become part of a chain, * Returns whether this provider is able to become part of a chain,
...@@ -51,7 +48,7 @@ public interface ITransformationProvider extends IObjectAware2<Object, Object> { ...@@ -51,7 +48,7 @@ public interface ITransformationProvider extends IObjectAware2<Object, Object> {
* {@link #canTransform(Object, ITransformationContext)} is called and the * {@link #canTransform(Object, ITransformationContext)} is called and the
* concrete source object to be transformed cannot be handled. * concrete source object to be transformed cannot be handled.
*/ */
boolean canHandleChainTransformation(Class<? extends Object> sourceClass, boolean canHandleChainTransformation(Class<?> sourceClass,
ITransformationContext context); ITransformationContext context);
/** /**
......
...@@ -27,9 +27,9 @@ import org.fortiss.tooling.kernel.extension.IStorageProvider; ...@@ -27,9 +27,9 @@ import org.fortiss.tooling.kernel.extension.IStorageProvider;
/** /**
* Interface for accessing top-level elements provided by * Interface for accessing top-level elements provided by
* {@link IStorageProvider}s. The context supports the typical methods like * {@link IStorageProvider}s. This interface supports the typical methods like
* running commands, listening to the command stack, undo and redo, a dirty * running commands, listening to the command stack, undo and redo, a dirty
* state and a save mechanism. * state and a save mechanism as well as accessing the root model element.
* *
* <P> * <P>
* Once an instance of this interface is provided to the kernel, the underlying * Once an instance of this interface is provided to the kernel, the underlying
...@@ -40,18 +40,12 @@ import org.fortiss.tooling.kernel.extension.IStorageProvider; ...@@ -40,18 +40,12 @@ import org.fortiss.tooling.kernel.extension.IStorageProvider;
* @author hoelzl * @author hoelzl
* @author $Author$ * @author $Author$
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating RED Hash: 9226FD21C183EB5EBC673EE375282AA2 * @ConQAT.Rating YELLOW Hash: DE8A819268F75497B61A48B6E32A648F
*/ */
public interface ITopLevelElement { public interface ITopLevelElement {
// TODO: Why does the interface ITopLevelElement have the method /** Returns the root model element represented by this top-level element. */
// getTopLevelElement ? Shouldn't we rename this interface in e.g. EObject getRootModelElement();
// IModelContext?
// in ProjectRootElementUtils we have
// IPersistencyService.INSTANCE.getTopLevelElementFor(element).getTopLevelElement().eContents()
// ----- so, a topLevelElement has another toplevelElement
/** Returns the top-level model element represented by this context. */
EObject getTopLevelElement();
/** Executes the given {@link Runnable} as model changing command. */ /** Executes the given {@link Runnable} as model changing command. */
void runAsCommand(Runnable runner); void runAsCommand(Runnable runner);
......
...@@ -26,7 +26,7 @@ import org.fortiss.tooling.kernel.extension.base.TransformationContextChainBase; ...@@ -26,7 +26,7 @@ import org.fortiss.tooling.kernel.extension.base.TransformationContextChainBase;
* @author hoelzl * @author hoelzl
* @author $Author$ * @author $Author$
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating YELLOW Hash: 86FBA7A228E86492FB4A54CDD086CFCC * @ConQAT.Rating YELLOW Hash: 0E04AF20E122C47C6545809D144811E0
*/ */
public class ModelElementTransformationContext extends public class ModelElementTransformationContext extends
TransformationContextChainBase { TransformationContextChainBase {
......
...@@ -87,7 +87,7 @@ public class PersistencyService implements IPersistencyService { ...@@ -87,7 +87,7 @@ public class PersistencyService implements IPersistencyService {
@Override @Override
public synchronized boolean isTopLevelElement(EObject element) { public synchronized boolean isTopLevelElement(EObject element) {
for (ITopLevelElement context : contextCache) { for (ITopLevelElement context : contextCache) {
if (context.getTopLevelElement() == element) { if (context.getRootModelElement() == element) {
return true; return true;
} }
} }
...@@ -206,7 +206,7 @@ public class PersistencyService implements IPersistencyService { ...@@ -206,7 +206,7 @@ public class PersistencyService implements IPersistencyService {
EObject modelElement) { EObject modelElement) {
while (modelElement != null) { while (modelElement != null) {
for (ITopLevelElement context : contextCache) { for (ITopLevelElement context : contextCache) {
if (context.getTopLevelElement() == modelElement) { if (context.getRootModelElement() == modelElement) {
return context; return context;
} }
} }
......
...@@ -57,8 +57,7 @@ public class TransformationService extends ...@@ -57,8 +57,7 @@ public class TransformationService extends
* given elements (or <code>null</code>n if no such connector exists). * given elements (or <code>null</code>n if no such connector exists).
*/ */
private ITransformationProvider findWorkingTransformationProvider( private ITransformationProvider findWorkingTransformationProvider(
Object source, Class<? extends Object> targetClass, Object source, Class<?> targetClass, ITransformationContext context) {
ITransformationContext context) {
List<ITransformationProvider> list = getRegisteredHandlers( List<ITransformationProvider> list = getRegisteredHandlers(
source.getClass(), targetClass); source.getClass(), targetClass);
if (list == null) { if (list == null) {
...@@ -92,14 +91,14 @@ public class TransformationService extends ...@@ -92,14 +91,14 @@ public class TransformationService extends
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean canTransform(Object source, public boolean canTransform(Object source, Class<?> targetClass,
Class<? extends Object> targetClass, ITransformationContext context) { ITransformationContext context) {
return findWorkingTransformationProvider(source, targetClass, context) != null; return findWorkingTransformationProvider(source, targetClass, context) != null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Object transform(Object source, Class<? extends Object> targetClass, public Object transform(Object source, Class<?> targetClass,
ITransformationContext context) ITransformationContext context)
throws TransformationFailedException { throws TransformationFailedException {
return findWorkingTransformationProvider(source, targetClass, context) return findWorkingTransformationProvider(source, targetClass, context)
...@@ -109,11 +108,11 @@ public class TransformationService extends ...@@ -109,11 +108,11 @@ public class TransformationService extends
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public List<TransformationProviderChain> getTransformationProviderChain( public List<TransformationProviderChain> getTransformationProviderChain(
Class<? extends Object> sourceClass, Class<?> sourceClass, Class<?> targetClass,
Class<? extends Object> targetClass, ITransformationContext context) { ITransformationContext context) {
List<TransformationProviderChain> results = new LinkedList<TransformationProviderChain>(); List<TransformationProviderChain> results = new LinkedList<TransformationProviderChain>();
List<ITransformationProvider> currentChain = new LinkedList<ITransformationProvider>(); List<ITransformationProvider> currentChain = new LinkedList<ITransformationProvider>();
Set<Class<? extends Object>> seenTargets = new HashSet<Class<? extends Object>>(); Set<Class<?>> seenTargets = new HashSet<Class<?>>();
seenTargets.add(sourceClass); seenTargets.add(sourceClass);
findTransformationChains(sourceClass, targetClass, results, findTransformationChains(sourceClass, targetClass, results,
currentChain, seenTargets, context); currentChain, seenTargets, context);
...@@ -125,12 +124,10 @@ public class TransformationService extends ...@@ -125,12 +124,10 @@ public class TransformationService extends
* is shielded against infinite loops within the transformation provider * is shielded against infinite loops within the transformation provider
* graph. * graph.
*/ */
private void findTransformationChains(Class<? extends Object> sourceClass, private void findTransformationChains(Class<?> sourceClass,
Class<? extends Object> targetClass, Class<?> targetClass, List<TransformationProviderChain> results,
List<TransformationProviderChain> results,
List<ITransformationProvider> currentChain, List<ITransformationProvider> currentChain,
Set<Class<? extends Object>> seenTargets, Set<Class<?>> seenTargets, ITransformationContext context) {
ITransformationContext context) {
if (!currentChain.isEmpty() if (!currentChain.isEmpty()
&& currentChain.get(currentChain.size() - 1).getTargetClass() == targetClass) { && currentChain.get(currentChain.size() - 1).getTargetClass() == targetClass) {
// found a complete chain => add to result and backtrack // found a complete chain => add to result and backtrack
...@@ -147,7 +144,7 @@ public class TransformationService extends ...@@ -147,7 +144,7 @@ public class TransformationService extends
// dead end reached // dead end reached
return; return;
} }
for (Class<? extends Object> key : providerMap.keySet()) { for (Class<?> key : providerMap.keySet()) {
List<ITransformationProvider> providerList = providerMap.get(key); List<ITransformationProvider> providerList = providerMap.get(key);
for (ITransformationProvider provider : providerList) { for (ITransformationProvider provider : providerList) {
if (provider.canHandleChainTransformation(sourceClass, context)) { if (provider.canHandleChainTransformation(sourceClass, context)) {
......
...@@ -214,7 +214,7 @@ public class EclipseResourceStorageProvider implements ...@@ -214,7 +214,7 @@ public class EclipseResourceStorageProvider implements
private ModelContext loadContext(IFile file) throws IOException { private ModelContext loadContext(IFile file) throws IOException {
ModelContext mc = new ModelContext(file); ModelContext mc = new ModelContext(file);
loadedContexts.put(file, mc); loadedContexts.put(file, mc);
rootElementContexts.put(mc.getTopLevelElement(), mc); rootElementContexts.put(mc.getRootModelElement(), mc);
return mc; return mc;
} }
...@@ -222,7 +222,7 @@ public class EclipseResourceStorageProvider implements ...@@ -222,7 +222,7 @@ public class EclipseResourceStorageProvider implements
private void unloadContext(IFile file) { private void unloadContext(IFile file) {
ModelContext context = loadedContexts.remove(file); ModelContext context = loadedContexts.remove(file);
if (context != null) { if (context != null) {
rootElementContexts.remove(context.getTopLevelElement()); rootElementContexts.remove(context.getRootModelElement());
context.destroy(); context.destroy();
} }
} }
......
...@@ -96,7 +96,7 @@ class ModelContext implements ITopLevelElement { ...@@ -96,7 +96,7 @@ class ModelContext implements ITopLevelElement {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public EObject getTopLevelElement() { public EObject getRootModelElement() {
return r.getContents().get(0); return r.getContents().get(0);
} }
...@@ -115,7 +115,7 @@ class ModelContext implements ITopLevelElement { ...@@ -115,7 +115,7 @@ class ModelContext implements ITopLevelElement {
/** Checks whether all IDs are present and updates {@link #maxId}. */ /** Checks whether all IDs are present and updates {@link #maxId}. */
private void checkIDs() { private void checkIDs() {
boolean hadMissing = false; boolean hadMissing = false;
for (Iterator<EObject> i = getTopLevelElement().eAllContents(); i for (Iterator<EObject> i = getRootModelElement().eAllContents(); i
.hasNext();) { .hasNext();) {
EObject eo = i.next(); EObject eo = i.next();
if (eo instanceof IIdLabeled) { if (eo instanceof IIdLabeled) {
...@@ -138,7 +138,7 @@ class ModelContext implements ITopLevelElement { ...@@ -138,7 +138,7 @@ class ModelContext implements ITopLevelElement {
/** Generates missing IDs. Must be called within transaction. */ /** Generates missing IDs. Must be called within transaction. */
private void generateMissingIDs() { private void generateMissingIDs() {
for (Iterator<EObject> i = getTopLevelElement().eAllContents(); i for (Iterator<EObject> i = getRootModelElement().eAllContents(); i
.hasNext();) { .hasNext();) {
EObject eo = i.next(); EObject eo = i.next();
if (eo instanceof IIdLabeled) { if (eo instanceof IIdLabeled) {
...@@ -178,7 +178,7 @@ class ModelContext implements ITopLevelElement { ...@@ -178,7 +178,7 @@ class ModelContext implements ITopLevelElement {
if (needSmart) { if (needSmart) {
Set<Integer> usedIDs = new HashSet<Integer>(); Set<Integer> usedIDs = new HashSet<Integer>();
for (Iterator<EObject> i = getTopLevelElement().eAllContents(); i for (Iterator<EObject> i = getRootModelElement().eAllContents(); i
.hasNext();) { .hasNext();) {
EObject eo = i.next(); EObject eo = i.next();
if (eo instanceof IIdLabeled) { if (eo instanceof IIdLabeled) {
......
...@@ -47,9 +47,7 @@ public interface ITransformationService { ...@@ -47,9 +47,7 @@ public interface ITransformationService {
* Determines if there is a transformation provider, which can perform the * Determines if there is a transformation provider, which can perform the
* transformation of the given source element into the given target element. * transformation of the given source element into the given target element.
*/ */
// TODO: replace everywhere Class<? extends Object> with Class<?> boolean canTransform(Object source, Class<?> targetClass,
// http://stackoverflow.com/questions/370601/is-it-good-practice-to-replace-class-with-class-extends-object-to-avoid-warnin
boolean canTransform(Object source, Class<? extends Object> targetClass,
ITransformationContext context); ITransformationContext context);
/** /**
...@@ -59,7 +57,7 @@ public interface ITransformationService { ...@@ -59,7 +57,7 @@ public interface ITransformationService {
* @throws TransformationFailedException * @throws TransformationFailedException
* if something goes wrong during the transformation. * if something goes wrong during the transformation.
*/ */
Object transform(Object source, Class<? extends Object> targetClass, Object transform(Object source, Class<?> targetClass,
ITransformationContext context) ITransformationContext context)
throws TransformationFailedException; throws TransformationFailedException;
...@@ -69,6 +67,6 @@ public interface ITransformationService { ...@@ -69,6 +67,6 @@ public interface ITransformationService {
* empty list. * empty list.
*/ */
List<TransformationProviderChain> getTransformationProviderChain( List<TransformationProviderChain> getTransformationProviderChain(
Class<? extends Object> sourceClass, Class<?> sourceClass, Class<?> targetClass,
Class<? extends Object> targetClass, ITransformationContext context); ITransformationContext context);
} }
...@@ -193,8 +193,7 @@ public abstract class ObjectAware2ServiceBase<T extends IObjectAware2<? extends ...@@ -193,8 +193,7 @@ public abstract class ObjectAware2ServiceBase<T extends IObjectAware2<? extends
/** Adds all registered classes to the given list. */ /** Adds all registered classes to the given list. */
private void addRegisteredClasses(IConfigurationElement element, private void addRegisteredClasses(IConfigurationElement element,
List<Class<? extends Object>> list, Bundle bundle) List<Class<?>> list, Bundle bundle) throws ClassNotFoundException {
throws ClassNotFoundException {
for (IConfigurationElement ce : element for (IConfigurationElement ce : element
.getChildren(getClassConfigurationElement())) { .getChildren(getClassConfigurationElement())) {
Class<?> modelElementClass = ExtensionPointUtils.loadClass( Class<?> modelElementClass = ExtensionPointUtils.loadClass(
......
...@@ -46,7 +46,7 @@ public final class ProjectRootElementUtils { ...@@ -46,7 +46,7 @@ public final class ProjectRootElementUtils {
EObject element, Class<T> clazz) { EObject element, Class<T> clazz) {
return ReflectionUtils.pickInstanceOf(clazz, return ReflectionUtils.pickInstanceOf(clazz,
IPersistencyService.INSTANCE.getTopLevelElementFor(element) IPersistencyService.INSTANCE.getTopLevelElementFor(element)
.getTopLevelElement().eContents()); .getRootModelElement().eContents());
} }
/** /**
...@@ -58,7 +58,7 @@ public final class ProjectRootElementUtils { ...@@ -58,7 +58,7 @@ public final class ProjectRootElementUtils {
EObject parent) { EObject parent) {
StringTokenizer tizer = new StringTokenizer(qualifiedName, "/"); StringTokenizer tizer = new StringTokenizer(qualifiedName, "/");
EObject current = IPersistencyService.INSTANCE.getTopLevelElementFor( EObject current = IPersistencyService.INSTANCE.getTopLevelElementFor(
parent).getTopLevelElement(); parent).getRootModelElement();
boolean found = true; boolean found = true;
while (found && tizer.hasMoreElements()) { while (found && tizer.hasMoreElements()) {
String name = tizer.nextToken(); String name = tizer.nextToken();
...@@ -85,7 +85,7 @@ public final class ProjectRootElementUtils { ...@@ -85,7 +85,7 @@ public final class ProjectRootElementUtils {
*/ */
public static EObject findElementById(IIdLabeledReference reference) { public static EObject findElementById(IIdLabeledReference reference) {
EObject root = IPersistencyService.INSTANCE.getTopLevelElementFor( EObject root = IPersistencyService.INSTANCE.getTopLevelElementFor(
reference).getTopLevelElement(); reference).getRootModelElement();
for (Iterator<EObject> iter = root.eAllContents(); iter.hasNext();) { for (Iterator<EObject> iter = root.eAllContents(); iter.hasNext();) {
EObject eo = iter.next(); EObject eo = iter.next();
if (eo instanceof IIdLabeled if (eo instanceof IIdLabeled
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment