-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Coding Guidelines
- indent with four spaces
- wrap lines at 120 characters
- type and method annotations go on a separate line
- wrapped arguments are aligned to opening parenthesis
Newly added files must contain the correct Copyright and License header comment:
/*
* Copyright (C) 2011, 2013-2023 The JavaParser Team.
*
* This file is part of JavaParser.
*
* JavaParser can be used either under the terms of
* a) the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* b) the terms of the Apache License
*
* You should have received a copy of both licenses in LICENCE.LGPL and
* LICENCE.APACHE. Please refer to those files for details.
*
* JavaParser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
WARNING: Notice that there is an empty line between the Copyright and License comment and the package declaration.
To configure your IDE to automatically add the header see the IDE Settings section below.
Copy dev-files/JavaParser-idea.xml
to .IdeaIC14/config/codestyles/
and select it in 'Settings > Editor > Code Style'.
In 'Settings > Editor > Code Style' select item as follows:
- [y] Wrap when typing reaches right margin
In 'Settings > Editor > General':
- Other
- Strip trailing spaces on Save: 'Modified Lines'
- [y] Ensure line feed at file end on Save
- Strip trailing spaces on Save: 'Modified Lines'
Go to 'Settings > Editor > Copyright > Copyright Profiles'. Click the '+' button to add a 'JavaParser' profile with the following text:
Copyright (C) 2011, 2013-2023 The JavaParser Team.
This file is part of JavaParser.
JavaParser can be used either under the terms of
a) the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
b) the terms of the Apache License
You should have received a copy of both licenses in LICENCE.LGPL and
LICENCE.APACHE. Please refer to those files for details.
JavaParser is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
Then go up to 'Settings > Editor > Copyright' and select 'JavaParser' as the 'Default project copyright' (this applies to the current project).
Import formatter settings dev-files/JavaParser-eclipse.xml
Go to 'Window > Preferences > Java > Code Style > Formatter and select JavaParser-eclipse.xml.
In 'Preferences > Java> Editor > Save Actions' select items as follows:
- [y] Perform the selected actions on save
- [y] Format source code
- [n] Format all lines
- [y] Format edited lines
- [y] Format source code
Go to 'Window > Preferences > Java > Code Style > Code Templates ', expands Code and select “New Java Files”, click 'Edit' to add the following text:
/*
* Copyright (C) 2011, 2013-2023 The JavaParser Team.
*
* This file is part of JavaParser.
*
* JavaParser can be used either under the terms of
* a) the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* b) the terms of the Apache License
*
* You should have received a copy of both licenses in LICENCE.LGPL and
* LICENCE.APACHE. Please refer to those files for details.
*
* JavaParser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
${filecomment}
${package_declaration}
${typecomment}
${type_declaration}
Website: JavaParser.org Chat: Gitter.im/JavaParser/JavaParser Free eBook: leanpub.com/JavaParserVisited
- Home
- Migration Guide (2.5.1 to 3.0.0)
- Migration Guide (3.25.10 to 3.26.0)
- Inspecting an AST
JavaParser
vsStaticJavaParser
Pro* jectRoot
vsSourceRoot
(Analysing a Whole Project)- Parsing Java Comments
- Getting started with JavaParser: analyzing Java Code programmatically
- Observers for AST nodes in JavaParser
- Implementing Lexical Preservation for JavaParser
- JavaParser’s logging framework in one file
- Making strings in JavaParser
- The quick and the full API of JavaParser
- Less Casting in JavaParser
- Parse error recovery
- Inverting ifs in JavaParser
- Code generation and Maven in JavaParser
- Semantic validations in JavaParser
- Setting Java 8, 9, 10, etc
- Analysing an entire project in one go
- Pragmatic Versioning
- Testing JavaParser Code
- Functional Tree Traversal
- Coding Guidelines
- Eclipse Project Setup Guide
- Code Style / Architecture
- Build Process
- Release Process
- A Detailed Guide to Adding New Nodes and Fields
Visit the JavaParser blog
Download the JavaParserVisited book (free!).
Join the chatroom on Gitter!