/* * #%~ * org.overture.ide.debug * %% * Copyright (C) 2008 - 2014 Overture * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #~% */ package org.overture.ide.debug.core.launching; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate; import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer; import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer; import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer; import org.overture.ide.debug.core.IDebugConstants; public class VdmSourcePathComputerDelegate implements ISourcePathComputerDelegate { public ISourceContainer[] computeSourceContainers( ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { IProject project = null; // IVdmProject vdmProject = null; project = ResourcesPlugin.getWorkspace().getRoot().getProject(configuration.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_PROJECT, "")); // if (project != null) // { // vdmProject = (IVdmProject) project.getAdapter(IVdmProject.class); // } String path = project.getFullPath().toOSString(); ISourceContainer sourceContainer = null; if (path != null) { IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(project.getFullPath()); if (resource != null) { IContainer container = (IContainer) resource; if (container.getType() == IResource.PROJECT) { sourceContainer = new ProjectSourceContainer((IProject) container, false); } else if (container.getType() == IResource.FOLDER) { sourceContainer = new FolderSourceContainer(container, false); } } } if (sourceContainer == null) { sourceContainer = new WorkspaceSourceContainer(); } return new ISourceContainer[] { sourceContainer }; } }