[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Clone CDT project
|
I'm doing research on refactoring/modernising C++projects and for safety, I'd
like to clone the project and carry out any actual work on the clone.
Here is the code that I use for cloning a project:
/**
* Clone the given project into the workspace under the newProject name
*/
public static IProject cloneProject(IProject project, String newProject)
throws CoreException {
try{
IProgressMonitor monitor = new NullProgressMonitor();
IWorkspaceRoot workspaceRoot =
ResourcesPlugin.getWorkspace().getRoot();
IProjectDescription projectDescription = project.getDescription();
// create clone project in workspace
IProjectDescription cloneDescription =
workspaceRoot.getWorkspace().newProjectDescription(newProject);
// copy project files
project. copy(cloneDescription, true, monitor);
IProject clone = workspaceRoot.getProject(newProject);
// copy the project properties
cloneDescription.setNatureIds(projectDescription.getNatureIds());
cloneDescription.setReferencedProjects(projectDescription.getReferencedProjects());
cloneDescription.setDynamicReferences(projectDescription.getDynamicReferences());
cloneDescription.setBuildSpec(projectDescription.getBuildSpec());
cloneDescription.setReferencedProjects(projectDescription.getReferencedProjects());
clone.setDescription(cloneDescription, null);
return clone;
}
catch (CoreException e){
e.printStackTrace();
MessageUtility.writeToConsole("console", e.getMessage());
return null;
}
}
This code works fine, but when I try to analyse cloned project I receive
the exception:
java.lang.Exception: Unsafe method call. Instantiation of dependent
expressions may not work.
on the following function calls:
- ICPPClassType.getBases()
- ICPPClassType.getConstructors()
An old thread <https://www.eclipse.org/forums/index.php/t/72925/>
provides a code snippet for creating a new CDT project (also provided in the
ResourceHelper
<https://github.com/eclipse/cdt/blob/master/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java>
class).
I'm currently exploring how to use this code to achieve my task. Any help is
appreciated.
--
View this message in context: http://eclipse.1072660.n5.nabble.com/Clone-CDT-project-tp187628.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.