0

We want to use Rascal to find all unused public methods in a collection of Java projects in an Eclipse workspace. I have just learned how to create a model of a Java project in Eclipse using createM3FromEclipseProject and navigate that. But this takes only one project into account. How do I perform this analysis across all Java projects in my workspace?

  • Without knowing more about your project you could simply perform the analysis for each project and calculate the intersection of the results. – Hannes Jun 27 '14 at 16:08

2 Answers2

0

Excellent question. You extract the models from each project, given the right Eclipse compiler settings and everything, then you can merge the models to get an overarching model:

import lang::java::m3::Core;

M3 composeJavaM3(loc id, set[M3] models) // the function to call

This will allow you to do a cross project analysis on the resulting M3 model.

There are some caveats, namely if the same qualified class name exists in both projects but they are in fact different classes then the compose function will map them onto each other. To fix such issues you would first have to do some preprocessing (see the link function), but we have yet to get experience in that.

Jurgen Vinju
  • 6,393
  • 1
  • 15
  • 26
0

If you are comfortable programming in Rascal, you could do the following:

  1. Create a java function in rascal that gets the set of projects in the workspace as a set of locations. The locations need to be in the |project://project_name| format and the projects need to be accessible.
  2. Create a rascal function that iterates over the set, creating the models using createM3FromEclipseProject and then composing them using composeJavaM3 into a single model to perform the analysis on.

If not, you can create an issue here and we could add it to an unstable build. This hasn't been added because of the caveats mentioned below.

AShahi
  • 156
  • 4