Developer Documentation
The ApCoCoA 2.0 project is divided into two sub projects: The CoCoA Plugin and the CoCoA IDE based on IntelliJ.
The CoCoA IDE
The IDE is based on IntelliJ Community Edition. The source code of the IntelliJ Community Edition is available on Github. We cloned the original repository and modified some files in the python branch to make our own customized IDE (ApCoCoA). However the repository on which we are working now is available on Bitbucket: https://bitbucket.org/klausnguets/cocoa_ide/src/master/. We modified the following files in the IDE:
- In the folder
python/resources
we replaced the IDE logos with our own logo. - In
python/python-community-ide-resources/resources/tips
you can find the files to modify the product name, the help page etc. - In the same folder
python/python-community-ide-resources/resources
you can find the file/idea/PyCharmCoreApplicationInfo.xml
to edit the IDE information.
There is more one can customize. Please refer to the Github page or to the IntelliJ Platform SDK DevGuide.
Building the IDE
After the the IDE is customized as wanted, the last step is to build the sources in order to obtain the IDE for Windows, Linux and Mac as follows:
- Install Ant, the Java Development Kit and JavaFX.
- Increase the Java Heap size for ant:
export _JAVA_OPTIONS=-Xmx5000m
to set a maximum heap size of for example 5G. To make those changes permanent, you have to add this command in your/etc/profile
.
You can use the commandjava -XshowSettings:vm
to check whether the heap size has changed.
- Change to the folder
python
in the source and run the commandant -f build.xml
. You might get aBUILD FAILED
Error Message. You can ignore this message but need to make sure that in the directorypython/out/pycharm-ce
the three foldersdist.mac
,dist.unix
anddist.win
where created.
- To obtain the IDE for a given platform, for example unix, copy the contents of
dist.unix/run
into the folderdist.all/run
.
- Make the files
pycharm.sh
,fsnotifier
andfsnotifier64
executable:chmod +x ./fsnotifier ./fsnotifier64 ./pycharm.sh
.
- Now you should be able to start the IDE using
./pycharm.sh
.
The CoCoA Plugin
The CoCoA plugin is the part of the project which addresses everything that is specific to the CoCoA language such as the syntax highlighting, the interpreter, the interactive window, the CoCoA files recognition... The plugin is developed as a normal IntelliJ Platform plugin, meaning it can be used in other IntelliJ IDEs to make them recognize and interpret a CoCoA file. IntelliJ platforms provides interesting tutorials on plugin creation: Getting Started, Creating a Plugin Project. Our plugin project is located in a Bitbucket repository at https://bitbucket.org/klausnguets/apcocoa_plugin/src/master/
Plugin Implementation
The plugin implementation has 3 packages: com.cocoaplugin.ide, com.cocoaplugin.psi, com.cocoaplugin.run.
com.cocoaplugin.psi
In this package you will find the logic about the CoCoA Parser for syntax highlighting, and all other logic related to the CoCoA language itself. For more information on this topic please refer to the IntelliJ Platform SDK DevGuide.
com.cocoaplugin.run
This package contains the logic to create a run configuration for CoCoA. It is not very important for the plugin to work but with a run configuration someone can send a CoCoA file to the interpreter without using the interactive windows or the CoCoA window. IMPORTANT: if you are building the plugin for windows or another OS please make sure the INTERPRETER_PATH in the class CocoaRunConfigurationProducer of this package is correct for that OS.
com.cocoaplugin.ide
This package is the most important package of the project as here you have the logic for the interactive Window, the events “send to Cocoa”, “refresh cocoa” , as well as the multithreading used to separate the interpreter threads from the IDE thread in order to avoid blocking everything when cocoa is calculating. Let’s choose some important classes in this package and give a brief description of them:
- CocoaProcessManager
This class is the class where we manage the cocoa interpreter process running in the background. Again make sure the right interpreter path for the targeted OS is given(line 32). - InterpreterThread
This class represents the thread which reads the results produced by CoCoA. It listens to the standard output of the CoCoA interpreter process and whenever there is a result available, it prints it back to the user in the CoCoA output window. - SendToCocoa
This class is an IntelliJ Action When the user starts the action “send to cocoa” we get the text selection and write it to the input of the cocoa interpreter process, and later the result will be read by the InterpreterThread as explained above. - CocoaInteractiveWindow
This is the cocoa interactive window. It interacsts with the two other classes TerminalFilter and TerminalNavigationFilter. - CocoaToolWindow
This class is the window for the CoCoA Outputs. For more about IntelliJ ToolWindows, please refer again to the IntelliJ Platform SDK DevGuide
Deployment
ApCoCoA can be distributed using the files generated during the building process. But the plugin also has to be integrated in the final
distribution file. For that, you need to build the plugin. In IntelliJ open the plugin project and go to “Build > Prepare module
apcocoa_plugin for Deployment”. A jar file (apcocoa_plugin.jar
) will be generated in the project directory.
Then move that plugin file to the dist.[os]/plugins/apcocoa/lib/
you want to distribute.
When ApCoCoA starts, we always check whether the user has a CoCoA interpreter in his or her system already. Otherwise we copy the CoCoA
interpreter to the users home directory. How this is done can be found in the file bin/start.sh
or bin/start.bat
(Windows) of the current ApCoCoA.