From 554491fcdd0a8b59886883f937a54adbf27e8a59 Mon Sep 17 00:00:00 2001 From: Simon Barner <barner@fortiss.org> Date: Fri, 17 Nov 2017 08:47:12 +0000 Subject: [PATCH] YELLOW Use static imports. refs 2983 --- .../tooling/kernel/utils/ResourceUtils.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ResourceUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ResourceUtils.java index edd80d3e5..09be6ed71 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ResourceUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/ResourceUtils.java @@ -17,6 +17,11 @@ $Id$ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.kernel.utils; +import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace; +import static org.eclipse.emf.common.util.URI.createFileURI; +import static org.eclipse.emf.common.util.URI.createURI; +import static org.eclipse.emf.ecore.util.EcoreUtil.resolveAll; +import static org.fortiss.tooling.kernel.utils.EcoreUtils.getEClassForClass; import static org.fortiss.tooling.kernel.utils.LoggingUtils.error; import java.io.BufferedReader; @@ -37,7 +42,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.common.util.URI; @@ -48,7 +52,6 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.xmi.PackageNotFoundException; import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; @@ -64,7 +67,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService; * @author mou * @author $Author$ * @version $Rev$ - * @ConQAT.Rating YELLOW Hash: E6CBD4C9FC74A32B1386D76FC50D4CD1 + * @ConQAT.Rating YELLOW Hash: C96015AD0EA5339198679C8B703B1210 */ public final class ResourceUtils { @@ -111,7 +114,6 @@ public final class ResourceUtils { @Override public Map<EObject, String> getEObjectToIDMap() { if(eObjectToIDMap == null) { - /* * {@link IdentityHashMap} is used to implement alternative {@link EObject} -> * ID maps. @@ -241,8 +243,7 @@ public final class ResourceUtils { */ @SuppressWarnings("unchecked") public static <T extends EObject> T getModel(ResourceSet resourceSet, Class<T> clazz) { - // TODO (FH): use import static - EcoreUtil.resolveAll(resourceSet); + resolveAll(resourceSet); for(Resource resource : resourceSet.getResources()) { for(EObject obj : resource.getContents()) { if(clazz.isAssignableFrom(obj.getClass())) { @@ -311,7 +312,7 @@ public final class ResourceUtils { if(factory != null && fileExtension != null && uri != null && obj != null) { uri = uri.trimFileExtension().appendFileExtension(fileExtension); Resource resource = resourceSet.createResource(uri); - final T newModel = (T)factory.create(EcoreUtils.getEClassForClass(clazz)); + final T newModel = (T)factory.create(getEClassForClass(clazz)); ITopLevelElement modelContext = IPersistencyService.getInstance().getTopLevelElementFor(obj); @@ -339,8 +340,7 @@ public final class ResourceUtils { public static IFile getIFile(Resource resource) { final URI uri = resource.getURI(); String resourcePath = uri.toPlatformString(true); - // TODO (FH): use import static - final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + final IWorkspaceRoot workspaceRoot = getWorkspace().getRoot(); final IResource member = workspaceRoot.findMember(resourcePath); @@ -357,10 +357,10 @@ public final class ResourceUtils { */ public static URI getAbsoluteResourceURI(Resource resource) { IFile file = getIFile(resource); - final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + final IWorkspaceRoot workspaceRoot = getWorkspace().getRoot(); String absoluteResourcePath = workspaceRoot.getLocation().append(file.getFullPath()).toFile().toURI().toString(); - final URI resourceUri = URI.createURI(absoluteResourcePath, true); + final URI resourceUri = createURI(absoluteResourcePath, true); return resourceUri; } @@ -404,10 +404,9 @@ public final class ResourceUtils { ResourceSet resourceSet = new ResourceSetImpl(); try { - URI siblingUri = URI.createFileURI(member.getLocation().toString()); + URI siblingUri = createFileURI(member.getLocation().toString()); Resource siblingResource = resourceSet.getResource(siblingUri, true); - // TODO (FH): use import static - EcoreUtil.resolveAll(resourceSet); + resolveAll(resourceSet); for(Resource currentResource : resourceSet.getResources()) { final URI currentUri = currentResource.getURI(); -- GitLab