Neo4j github resources

Style guides

Reformatting guidelines

In general it should be regarded as bad form to reformat code which is not strictly part of a code change. This is not a strict rule as such, but using auto-reformatting of entire files leads to more problems than it solves. Sometimes it is however good to sneak in some obvious cleanup together with other changes.

Luckily IntelliJ has support for reformatting only code you have touched. The option is called "Only VCS changed text" and it is available in the reformatting dialogue. It is by default accessed by pressing shift-alt-cmd-L and it is recommended that you exclusively use this mode if you want to make use of auto-reformatting. There is also a way of doing the same when checking in code using IntelliJ.

If you use another editor then try to find similar functionality.

Code style guidelines

Code styles are nice and we should try to keep generally aligned. However if you feel that some code should be justifiable formatted a bit differently then feel free. Likewise if you stumble upon code that is justifiably formatted in a different way then try to keep it like that.

You can also adjust your local copy of the code style with changes that make sense for you but which do not generally affect others. Some examples are whether or not you want your code to wrap automatically when you go outside the margin as you type. Another example could be whether or not you want to keep the formatting of line breaks when you do an automatic reformatting. IntelliJ is to some extent mixing policy with mechanism here.

End of file

For some reason dating back to who knows when new lines are required at the end of files. This is not part of the code style in IntelliJ so it is recommended to enable this manually. In the Preferences>Editor>General tab there is an "On Save" section with an option "Ensure every saved file ends with a line break".

build-resources Maven Plugin

Some Neo4j Maven tasks require a Neo4j-specific maven plugin. The code for the plugin is included in the main repository. The plugin can be installed manually by running: mvn install -pl org.neo4j.build:build-resources Alternatively IntelliJ can be configured to install the plugin before a build or rebuild operation using the Maven tool window.

Javacc Cypher Compiler

Cypher uses JavaCC (Java Compiler Compiler) to generate Java code. The generated code is necessary to build Neo4j and it is not cheked in to source control. To build Neo4j you have to generate the code locally. IntelliJ IDEA does not do this automatically out of the box. There are three main ways to run javacc:

  1. Maven command line: mvn compile -am -pl public/community/cypher/front-end/javacc-parser
  2. Run the IntelliJ Maven menu command "Generate Sources and Update Folders"
  3. Configure IntelliJ to run the ph-javacc Maven plugin before each build or rebuild operation using the Maven tool window

Fork me on GitHub