FocusRascal is a Rascal project used to mine Java projects (in source code or binary JAR form) to extract method invocations and declarations information used by the FOCUS recommender system. FocusRascal extracts so-called M3 models from source code and JARs, which are then turned into FOCUS- and PAM-compatible models.
In order to install FocusRascal, please follow these steps:
- Install an appropriate version of Eclipse RCP and RAP according to your platform/distribution from this link: Eclipse RCP and RAP.
- In Eclipse, navigate to
Help -> Install New Software...
and use the update site URL https://update.rascal-mpl.org/unstable/ to install Rascal. - Restart Eclipse to complete the installation.
- Clone locally the
rascal-java-build-manager
project which is a required dependency of FocusRascal:- e.g.
$ git clone https://github.com/cwi-swat/rascal-java-build-manager
- e.g.
- In Eclipse, import the two projects
FocusRascal
andrascal-java-build-manager
by navigating toFile -> Import -> Existing Projects into Workspace
and pointing the root directory to, respectively,FocusRascal
andrascal-java-build-manager
. Both projects should compile without any issue.
Make sure to edit the file FocusRascal/src/focus/corpus/Configuration.rsc
.
The mavenLocation
should point to your local mvn
executable (which, on Linux, can be found with the command which mvn
). The datasetLocation
should be updated with an absolute path to the dataset
directory in the FocusRascal
project (e.g. |file:///path/to/FOCUS/tools/FocusRascal/dataset/|;
, note the mandatory |
around the path). The other relative paths can be left as is.
// Pointer to mvn executable, used to build the classpath of Maven projects
public loc mavenLocation = |file:///usr/bin/mvn|;
// Where the GitHub repositories are stored and/or cloned
public loc datasetLocation = |file:///FOCUS_ROOT/tools/FocusRascal/dataset/|;
// Where the M3, PAM, and FOCUS models are stored
public loc javaM3sLocation = |project://FocusRascal/data/m3/java-projects|;
// Where the FOCUS models built from JARs are stored
public loc jarsM3sLocation = |project://FocusRascal/data/m3/jar-projects|;
// Where information about the GitHub projects to analyze is stored
public loc githubConfigFile = |project://FocusRascal/config/github-repos.properties|;
All manipulations must be done in Eclipse:
- First, open the Rascal perspective:
Window -> Perspective -> Open Perspective -> Rascal
- Right-click on the
FocusRascal
project and selectRascal Console
, this opens a new Rascal console in the lower part of the IDE - In the console, import the ExtractMetadata module by typing
import focus::corpus::ExtractMetadata;
From here, the two main functions to invoke from the console are:
processGithubRepos()
, which reads the GitHub repositories stored inFocusRascal/config/github-repos.properties
, clone all repositories, build their M3 models, and write the output PAM and FOCUS files inFocusRascal/data/m3/java-projects/
. By default, thegithub-repos.properties
file points to the 17 libraries depicted in Table 1 of the ICSE'19 paper. Please bear in mind that it takes a long time to complete.- To use it, simply type
processGithubRepos();
in the Rascal console.
- To use it, simply type
processJARs(loc directory)
which takes as input the path to a directory containing a list of JARs, and writes as output the FOCUS models of those JARs inFocusRascal/data/m3/jar-projects/
. For instance, to parse, analyse, and compute the M3 and FOCUS models of the 3,600 JARs extracted from Maven Central (dataset MVL in the ICSE'19 paper), type the following in the Rascal console (replacing/path/to/FOCUS
with the path to your clone of the FOCUS repository):processJARs(|file:///path/to/FOCUS/dataset/jars|);