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.
-
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.
-
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.
-
Start CRAM inside a docker container, with
Project
as mounted volume: enter theProject
directory, then:docker run -d --rm --name cram -v $(pwd):$(pwd) --net=host grammatech/cram cram-docker.sh --allow-local
-
Inside
Project
, start VS Code, and make sure that the Mnemosyne extension is installed and enabled. -
In VS Code, open
Project
: go toFile -> Open Folder
, navigate toProject
, select it (don't enter it) and pressOpen
. -
In VS Code, call
Mnemosyne: Connect to Argot Server
fromView -> Command Palette
. Wait for the informational server messages to clear, indicating that the server is initialized (this may take a couple of seconds). -
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". -
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.