GrammaTech
Repo on GitLab

Using CRAM inside VS Code

Please follow the instructions below for downloading and running CRAM. Some familiarity with VS Code is beneficial. You are welcome to contact the current CRAM developers for assistance, using the contact information provided on the main page.

  1. Pull the CRAM docker image (this may take a while):

    docker pull grammatech/cram

You can do docker images -a to confirm the image has been downloaded to your machine.

  1. Install the Mnemosyne VS Code extension:

    (a) Download the .vsix file for the latest release of the Mnemosyne extension from its releases page.

    (b) Install the .vsix file in the usual way.

In order to use CRAM to refactor and migrate your code project, you need to create a directory that contains all source and header files (possibly in sub-directories). We will call this directory Project here. Ideally, Project should not contain anything else, as CRAM will interpret everything in Project as belonging to your project, and try to analyze it.

  1. Start CRAM inside a docker container, with Project as mounted volume: enter the Project directory, then:

    docker run -d --rm --name cram -v $(pwd):$(pwd) --net=host grammatech/cram cram-docker.sh --allow-local

  2. Inside Project, start VS Code, and make sure that the Mnemosyne extension is installed and enabled.

  3. In VS Code, open Project: go to File -> Open Folder, navigate to Project, select it (don't enter it) and press Open.

  4. In VS Code, call Mnemosyne: Connect to Argot Server from View -> Command Palette. Wait for the informational server messages to clear, indicating that the server is initialized (this may take a couple of seconds).

  5. From the File Explorer on the left, select a C++ file (not a header file) inside Project to process. Click somewhere inside the code in that file. You should see a yellow light bulb pop up, clicking on which shows you the list of currently enabled refactoring or migration commands. You can also decide to "Apply refactorings to compilation unit".

  6. To stop CRAM:

    docker stop cram

    Note: The --rm flag used when starting the container (Step 3) should cause the container to be removed automatically after being stopped. When switching between projects, it is a good idea to stop (and remove) the CRAM container and start a new one. That is, repeat steps 3--8 for each new project.