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

Merge pull request #530 from Yakindu/issue_162

open APIs and decoupling from EFS
jdicks пре 10 година
родитељ
комит
0673ab5039

+ 0 - 36
plugins/org.yakindu.base.expressions/.launch/Launch Runtime Eclipse.launch

@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
-<booleanAttribute key="append.args" value="true"/>
-<booleanAttribute key="askclear" value="true"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<stringAttribute key="bad_container_name" value="/org.yakindu.base.expressions/.launch/"/>
-<stringAttribute key="bootstrap" value=""/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="clearConfig" value="false"/>
-<booleanAttribute key="clearws" value="false"/>
-<booleanAttribute key="clearwslog" value="false"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Eclipse"/>
-<booleanAttribute key="default" value="true"/>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="location" value="${workspace_loc}/../runtime-EclipseXtext"/>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
-</listAttribute>
-<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m -XX:MaxPermSize=256m &#13;&#10;-Dorg.eclipse.epp.internal.mpc.core.service.DefaultCatalogService.url=http://localhost:8080"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<stringAttribute key="product" value="org.eclipse.platform.ide"/>
-<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
-<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useCustomFeatures" value="false"/>
-<booleanAttribute key="useDefaultConfig" value="true"/>
-<booleanAttribute key="useDefaultConfigArea" value="true"/>
-<booleanAttribute key="useProduct" value="true"/>
-<booleanAttribute key="usefeatures" value="false"/>
-</launchConfiguration>

+ 0 - 174
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/filesystem/HeadlessFileSystemAccess.java

@@ -1,174 +0,0 @@
-package org.yakindu.sct.generator.core.filesystem;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.xtext.generator.AbstractFileSystemAccess;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.OutputConfiguration;
-import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
-
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-
-public class HeadlessFileSystemAccess extends AbstractFileSystemAccess implements ISCTFileSystemAccess {
-	public static final String BASE_DIR = "filesystemAccess.absolute.baseDir";
-	public static final String ENCODING = "filesystemAccess.encoding";
-
-	@Inject
-	@Named(ENCODING)
-	protected String ENCODING_UTF_8;
-	@Inject
-	@Named(BASE_DIR)
-	protected String absoluteBaseDir;
-
-	@Override
-	public void generateFile(String fileName, String outputConfigurationName, CharSequence contents) {
-		// validate setup
-		validateFileSystemAccess();
-
-		OutputConfiguration outputConfig = getOutputConfig(outputConfigurationName);
-
-		File outputDir = getOutputDir(outputConfig);
-
-		String contentsAsString = doPostProcesses(fileName, outputConfigurationName, contents);
-
-		File outputFile = new File(outputDir, fileName);
-		if (outputFile.exists()) {
-			if (outputConfig.isOverrideExistingResources()) {
-				tryOverride(contentsAsString, outputFile);
-			}
-		} else {
-			outputFile.getParentFile().mkdirs();
-			try {
-				outputFile.createNewFile();
-			} catch (IOException e) {
-				throw new RuntimeException(e);
-			}
-			writeContent(contentsAsString, outputFile, ENCODING_UTF_8);
-		}
-	}
-
-	protected void validateFileSystemAccess() {
-		if (this.absoluteBaseDir == null || this.absoluteBaseDir.isEmpty())
-			throw new IllegalStateException("the base dir must have been set");
-	}
-
-	protected void tryOverride(String contentsAsString, File outputFile) {
-		String currentContent = getCurrentContent(outputFile);
-		if (isSame(contentsAsString, currentContent)) {
-			writeContent(contentsAsString, outputFile, ENCODING_UTF_8);
-		} else {
-			// ignore same content...
-		}
-	}
-
-	/**
-	 * Respects 'Pigeonhole_principle'.
-	 * 
-	 * @param newContent
-	 * @param currentContent
-	 * @return
-	 */
-	protected boolean isSame(String newContent, String currentContent) {
-		return currentContent.hashCode() != newContent.hashCode() &&
-				/* Pigeonhole_principle */currentContent.equals(newContent);
-	}
-
-	protected String getCurrentContent(File outputFile) {
-		String currentContent = null;
-		BufferedReader reader = null;
-		try {
-			reader = new BufferedReader(new FileReader(outputFile));
-			String line = null;
-			StringBuilder stringBuilder = new StringBuilder();
-			String ls = System.getProperty("line.separator");
-			while ((line = reader.readLine()) != null) {
-				stringBuilder.append(line);
-				stringBuilder.append(ls);
-			}
-			currentContent = stringBuilder.toString();
-		} catch (FileNotFoundException e1) {
-			throw new RuntimeException("Error during load of current file", e1);
-		} catch (IOException e) {
-			throw new RuntimeException("Error during load of current file", e);
-		} finally {
-			try {
-				reader.close();
-			} catch (IOException e) {
-				// ignore
-			}
-		}
-		return currentContent;
-	}
-
-	protected String doPostProcesses(String fileName, String outputConfigurationName, CharSequence contents) {
-		CharSequence postProcessedContent = postProcess(fileName, outputConfigurationName, contents);
-		String contentsAsString = postProcessedContent.toString();
-		return contentsAsString;
-	}
-
-	protected File getOutputDir(OutputConfiguration outputConfig) {
-		String fullPath = getFullPath(outputConfig);
-		File outputDir = new File(fullPath);
-		if (!outputDir.exists()) {
-			if (outputConfig.isCreateOutputDirectory()) {
-				outputDir.mkdirs();
-			} else {
-				outputDir = null;
-			}
-		}
-		return outputDir;
-	}
-
-	protected String getFullPath(OutputConfiguration outputConfig) {
-		String outputDirectory = outputConfig.getOutputDirectory();
-		String fullPath = absoluteBaseDir + File.separator
-				+ getOutputConfig(ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT).getOutputDirectory()
-				+ File.separator + outputDirectory;
-		return fullPath;
-	}
-
-	protected void writeContent(String contentsAsString, File outputFile, String encoding) {
-		Writer out = null;
-		try {
-			out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), encoding));
-			out.write(contentsAsString);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		} finally {
-			try {
-				if (out != null)
-					out.close();
-			} catch (IOException e) {
-				// ignore
-			}
-
-		}
-	}
-
-	@Override
-	public URI getURI(String path, String outputConfiguration) {
-		OutputConfiguration outputConfig = getOutputConfig(outputConfiguration);
-		return URI.createFileURI(getFullPath(outputConfig) + File.separator + path);
-	}
-
-	@Override
-	public IFileSystemAccess getIFileSystemAccess() {
-		return this;
-	}
-
-	@Override
-	public void afterGeneration() {
-		// currently nothing
-	}
-
-}

+ 136 - 136
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/util/ImportResolver.java

@@ -1,136 +1,136 @@
-/**
- * Copyright (c) 2014 itemis AG 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:
- * 	itemis AG - initial API and implementation
- *  
- */
-package org.yakindu.sct.model.stext.util;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.xtext.resource.IContainer;
-import org.eclipse.xtext.resource.IEObjectDescription;
-import org.eclipse.xtext.resource.IResourceDescription;
-import org.eclipse.xtext.resource.IResourceDescriptions;
-import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions;
-import org.yakindu.base.types.Package;
-import org.yakindu.base.types.TypesPackage;
-import org.yakindu.sct.model.stext.stext.Import;
-
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-
-/**
- * Convenience class for retrieving imported elements in the statechart's import scope.
- * 
- * @author Thomas Kutz
- *
- */
-public class ImportResolver {
-
-	@Inject
-	private IContainer.Manager containerManager;
-	@Inject
-	private IResourceDescriptions resourceDescriptions;
-
-	/**
-	 * Returns for a given {@link Import} declaration all elements of given type that are defined in the imported {@link Package}.
-	 * 
-	 * @param importDeclaration the import declaration within an import scope
-	 * @param type type of imported elements to be returned
-	 * @return imported elements of given type
-	 */
-	public <T extends EObject> List<T> getImportedElementsOfType(Import importDeclaration, Class<T> type) {
-		List<T> varDefs = Lists.newArrayList();
-		Package importedPackage = getPackageForNamespace(importDeclaration.eResource(), importDeclaration.getImportedNamespace());
-		if (importedPackage != null) {
-			TreeIterator<EObject> iter = importedPackage.eAllContents();
-			while (iter.hasNext()) {
-				EObject next = iter.next();
-				if (type.isInstance(next)) {
-					varDefs.add(type.cast(next));
-				}
-			}
-		}
-		return varDefs;
-	}
-
-	/**
-	 * Returns for a given namespace the {@link Package}.
-	 * 
-	 * @param contextResource the resource used to decide which packages are visible
-	 * @param namespace name of the package to be returned; ending wildcards (.*) will be trimmed
-	 * @return first found package with name as defined in namespace
-	 */
-	public Package getPackageForNamespace(Resource contextResource, String namespace) {
-		initResourceDescriptions(contextResource);
-		// remove wildcard
-		if (namespace.endsWith(".*")) {
-			namespace = namespace.substring(0, namespace.length() - 2);
-		}
-		URI uri = contextResource.getURI();
-		IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(uri);
-		if (resourceDescription == null) {
-			// no resource description could be found, so package cannot be resolved anyway
-			return null;
-		}
-		for (IContainer container : containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
-			final Iterable<IResourceDescription> currentDescriptions = container.getResourceDescriptions();
-			for (IResourceDescription resDesc : currentDescriptions) {
-				Iterable<IEObjectDescription> visiblePackages = resDesc
-						.getExportedObjectsByType(TypesPackage.Literals.PACKAGE);
-				for (IEObjectDescription pkgDesc : visiblePackages) {
-					if (pkgDesc.getName().toString().equals(namespace)) {
-						return (Package) pkgDesc.getEObjectOrProxy();
-					}
-				}
-			}
-		}
-		return null;
-	}
-
-	private void initResourceDescriptions(Resource contextResource) {
-		if (resourceDescriptions instanceof ResourceSetBasedResourceDescriptions) {
-			ResourceSet rset = buildResourceSet(contextResource);
-			((ResourceSetBasedResourceDescriptions) resourceDescriptions).setContext(rset);
-		}
-	}
-
-	private ResourceSet buildResourceSet(Resource contextResource) {
-		final ResourceSet rset = new ResourceSetImpl();
-		IProject project = WorkspaceSynchronizer.getFile(contextResource).getProject();
-		try {
-			project.accept(new IResourceVisitor() {
-				public boolean visit(IResource resource) throws CoreException {
-					if ("types".equals(resource.getFileExtension())) {
-						String filePath = resource.getFullPath().toString();
-						rset.createResource(URI.createPlatformResourceURI(filePath, true));
-					}
-					return true;
-				}
-			});
-
-		} catch (CoreException e) {
-			e.printStackTrace();
-		}
-		rset.getResources().add(contextResource);
-
-		return rset;
-	}
-}
+/**
+ * Copyright (c) 2014 itemis AG 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:
+ * 	itemis AG - initial API and implementation
+ *  
+ */
+package org.yakindu.sct.model.stext.util;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.xtext.resource.IContainer;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.resource.IResourceDescription;
+import org.eclipse.xtext.resource.IResourceDescriptions;
+import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions;
+import org.yakindu.base.types.Package;
+import org.yakindu.base.types.TypesPackage;
+import org.yakindu.sct.model.stext.stext.Import;
+
+import com.google.common.collect.Lists;
+import com.google.inject.Inject;
+
+/**
+ * Convenience class for retrieving imported elements in the statechart's import scope.
+ * 
+ * @author Thomas Kutz
+ *
+ */
+public class ImportResolver {
+
+	@Inject
+	private IContainer.Manager containerManager;
+	@Inject
+	private IResourceDescriptions resourceDescriptions;
+
+	/**
+	 * Returns for a given {@link Import} declaration all elements of given type that are defined in the imported {@link Package}.
+	 * 
+	 * @param importDeclaration the import declaration within an import scope
+	 * @param type type of imported elements to be returned
+	 * @return imported elements of given type
+	 */
+	public <T extends EObject> List<T> getImportedElementsOfType(Import importDeclaration, Class<T> type) {
+		List<T> varDefs = Lists.newArrayList();
+		Package importedPackage = getPackageForNamespace(importDeclaration.eResource(), importDeclaration.getImportedNamespace());
+		if (importedPackage != null) {
+			TreeIterator<EObject> iter = importedPackage.eAllContents();
+			while (iter.hasNext()) {
+				EObject next = iter.next();
+				if (type.isInstance(next)) {
+					varDefs.add(type.cast(next));
+				}
+			}
+		}
+		return varDefs;
+	}
+
+	/**
+	 * Returns for a given namespace the {@link Package}.
+	 * 
+	 * @param contextResource the resource used to decide which packages are visible
+	 * @param namespace name of the package to be returned; ending wildcards (.*) will be trimmed
+	 * @return first found package with name as defined in namespace
+	 */
+	public Package getPackageForNamespace(Resource contextResource, String namespace) {
+		initResourceDescriptions(contextResource);
+		// remove wildcard
+		if (namespace.endsWith(".*")) {
+			namespace = namespace.substring(0, namespace.length() - 2);
+		}
+		URI uri = contextResource.getURI();
+		IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(uri);
+		if (resourceDescription == null) {
+			// no resource description could be found, so package cannot be resolved anyway
+			return null;
+		}
+		for (IContainer container : containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
+			final Iterable<IResourceDescription> currentDescriptions = container.getResourceDescriptions();
+			for (IResourceDescription resDesc : currentDescriptions) {
+				Iterable<IEObjectDescription> visiblePackages = resDesc
+						.getExportedObjectsByType(TypesPackage.Literals.PACKAGE);
+				for (IEObjectDescription pkgDesc : visiblePackages) {
+					if (pkgDesc.getName().toString().equals(namespace)) {
+						return (Package) pkgDesc.getEObjectOrProxy();
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	private void initResourceDescriptions(Resource contextResource) {
+		if (resourceDescriptions instanceof ResourceSetBasedResourceDescriptions) {
+			ResourceSet rset = buildResourceSet(contextResource);
+			((ResourceSetBasedResourceDescriptions) resourceDescriptions).setContext(rset);
+		}
+	}
+
+	protected ResourceSet buildResourceSet(Resource contextResource) {
+		final ResourceSet rset = new ResourceSetImpl();
+		IProject project = WorkspaceSynchronizer.getFile(contextResource).getProject();
+		try {
+			project.accept(new IResourceVisitor() {
+				public boolean visit(IResource resource) throws CoreException {
+					if ("types".equals(resource.getFileExtension())) {
+						String filePath = resource.getFullPath().toString();
+						rset.createResource(URI.createPlatformResourceURI(filePath, true));
+					}
+					return true;
+				}
+			});
+
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+		rset.getResources().add(contextResource);
+
+		return rset;
+	}
+}

+ 95 - 0
test-plugins/org.yakindu.sct.generator.c.test/src/org/yakindu/sct/generator/c/gtest/GCCCommandExecutor.java

@@ -0,0 +1,95 @@
+package org.yakindu.sct.generator.c.gtest;
+
+import java.io.File;
+/****************************************************************************
+ * Copyright (c) 2008, 2012 Andreas Unger 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:
+ *    Andreas Unger - initial API and implementation 
+ ****************************************************************************/
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+
+public class GCCCommandExecutor {
+
+	public void execute(List<String> command, File workingDirectory) {
+		execute(command, workingDirectory, true);
+	}
+	
+	public void execute(List<String> command, File workingDirectory, boolean refreshWorkspace) {
+		try {
+			// System.out.println("compile: " + command);
+
+			ProcessBuilder processBuilder = new ProcessBuilder(command).directory(workingDirectory);
+			Process process = processBuilder.redirectErrorStream(true).start();
+			String message = readProcessInputStream(process);
+
+			boolean wait = true;
+			int exitCode = 0;
+
+			do {
+				wait = false;
+
+				// waiting for the processes termination
+				try {
+					process.waitFor();
+				} catch (InterruptedException e) { /*
+													 * we ignore if waiting was
+													 * interrupted ...
+													 */
+				}
+
+				// if we get an exit code then we know that the process is
+				// finished
+				try {
+					exitCode = process.exitValue();
+				} catch (IllegalThreadStateException e) {
+					wait = true; // if we get an exception then the process has
+									// not finished ...
+				}
+			} while (wait);
+
+			if (exitCode != 0) {
+				throw new RuntimeException("Compilation failed (exit status " + process.exitValue() + "):\n" + message);
+			}
+		} catch (Error e) {
+			throw e;
+		} catch (RuntimeException e) {
+			throw e;
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		} finally {
+			try {
+				if (refreshWorkspace) {
+					ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,
+							new NullProgressMonitor());
+				}
+			} catch (CoreException e) {
+				throw new RuntimeException(e);
+			}
+		}
+	}
+
+	private String readProcessInputStream(Process process) throws IOException {
+		Reader reader = new InputStreamReader(process.getInputStream());
+		char[] buffer = new char[4096];
+		int count;
+		StringBuilder message = new StringBuilder();
+		while ((count = reader.read(buffer)) != -1) {
+			message.append(buffer, 0, count);
+		}
+		return message.toString();
+	}
+}

+ 5 - 67
test-plugins/org.yakindu.sct.generator.c.test/src/org/yakindu/sct/generator/c/gtest/GTestHelper.java

@@ -14,8 +14,6 @@ package org.yakindu.sct.generator.c.gtest;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -61,66 +59,13 @@ public class GTestHelper {
 	}
 
 	public void compile() {
-		try {
 			copyFilesFromBundleToFolder();
 			IResource resource = ResourcesPlugin.getWorkspace().getRoot()
 					.findMember(getTargetPath());
 			File directory = resource.getLocation().toFile();
 			List<String> command = createCommand();
 
-			// System.out.println("compile: " + command);
-
-			ProcessBuilder processBuilder = new ProcessBuilder(command)
-					.directory(directory);
-			Process process = processBuilder.redirectErrorStream(true).start();
-			String message = readProcessInputStream(process);
-
-			boolean wait = true;
-			int exitCode = 0;
-
-			do {
-				wait = false;
-
-				// waiting for the processes termination
-				try {
-					process.waitFor();
-				} catch (InterruptedException e) { /*
-													 * we ignore if waiting was
-													 * interrupted ...
-													 */
-				}
-
-				// if we get an exit code then we know that the process is
-				// finished
-				try {
-					exitCode = process.exitValue();
-				} catch (IllegalThreadStateException e) {
-					wait = true; // if we get an exception then the process has
-									// not finished ...
-				}
-			} while (wait);
-
-			if (exitCode != 0) {
-				throw new RuntimeException("Compilation failed (exit status "
-						+ process.exitValue() + "):\n" + message);
-			}
-		} catch (Error e) {
-			throw e;
-		} catch (RuntimeException e) {
-			throw e;
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		} finally {
-			try {
-				ResourcesPlugin
-						.getWorkspace()
-						.getRoot()
-						.refreshLocal(IResource.DEPTH_INFINITE,
-								new NullProgressMonitor());
-			} catch (CoreException e) {
-				throw new RuntimeException(e);
-			}
-		}
+			getCommandExecutor().execute(command, directory);
 	}
 
 	public void generate() {
@@ -144,6 +89,10 @@ public class GTestHelper {
 		new GeneratorExecutor().executeGenerator(model);
 	}
 	
+	protected GCCCommandExecutor getCommandExecutor() {
+		return new GCCCommandExecutor();
+	}
+	
 	protected void performFullBuild() {
 		try {
 			ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
@@ -187,17 +136,6 @@ public class GTestHelper {
 		}
 	}
 
-	private String readProcessInputStream(Process process) throws IOException {
-		Reader reader = new InputStreamReader(process.getInputStream());
-		char[] buffer = new char[4096];
-		int count;
-		StringBuilder message = new StringBuilder();
-		while ((count = reader.read(buffer)) != -1) {
-			message.append(buffer, 0, count);
-		}
-		return message.toString();
-	}
-
 	protected List<String> createCommand() {
 		String gTestDirectory = getGTestDirectory();