IntelliJ Java Code Templates Configuration: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * IntelliJ") |
|||
(12 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [[IntelliJ#Configuration|IntelliJ]] | * [[IntelliJ#Configuration|IntelliJ]] | ||
=Overview= | |||
=Class Template= | |||
Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab | |||
<pre> | |||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end | |||
#parse("File Header.java") | |||
public class ${NAME} { | |||
// Constants ------------------------------------------------------------------------------------------------------- | |||
// Static ---------------------------------------------------------------------------------------------------------- | |||
// Attributes ------------------------------------------------------------------------------------------------------ | |||
// Constructors ---------------------------------------------------------------------------------------------------- | |||
// Public ---------------------------------------------------------------------------------------------------------- | |||
#if (${NAME.endsWith("Test")}) | |||
// Test Overrides -------------------------------------------------------------------------------------------------- | |||
// Tests ----------------------------------------------------------------------------------------------------------- | |||
#end | |||
// Package protected ----------------------------------------------------------------------------------------------- | |||
// Protected ------------------------------------------------------------------------------------------------------- | |||
// Private --------------------------------------------------------------------------------------------------------- | |||
// Inner classes --------------------------------------------------------------------------------------------------- | |||
} | |||
</pre> | |||
=Interface Template= | |||
Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab | |||
<pre> | |||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end | |||
#parse("File Header.java") | |||
public interface ${NAME} { | |||
// Constants ------------------------------------------------------------------------------------------------------- | |||
// Static ---------------------------------------------------------------------------------------------------------- | |||
// Public ---------------------------------------------------------------------------------------------------------- | |||
} | |||
</pre> | |||
=Enum= | |||
Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab | |||
<pre> | |||
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end | |||
#parse("File Header.java") | |||
public enum ${NAME} { | |||
// Constants ------------------------------------------------------------------------------------------------------- | |||
// Static ---------------------------------------------------------------------------------------------------------- | |||
// Public ---------------------------------------------------------------------------------------------------------- | |||
} | |||
</pre> | |||
=File Header= | |||
Settings -> Editor -> Code Style -> File and Code Templates -> "Includes" tab | |||
Edit File Header: | |||
<pre> | |||
/** | |||
* @author Ovidiu Feodorov <ovidiu@novaordis.com> | |||
* @since ${DATE} | |||
*/ | |||
</pre> | |||
=Method Template= | |||
Preferences -> Editor -> File and Code Templates -> Code tab -> Implemented Method Body | |||
Replace the content with | |||
<pre> | |||
throw new NotYetImplementedException("${METHOD_NAME}() NOT YET IMPLEMENTED"); | |||
</pre> |
Latest revision as of 22:31, 23 May 2018
Internal
Overview
Class Template
Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end #parse("File Header.java") public class ${NAME} { // Constants ------------------------------------------------------------------------------------------------------- // Static ---------------------------------------------------------------------------------------------------------- // Attributes ------------------------------------------------------------------------------------------------------ // Constructors ---------------------------------------------------------------------------------------------------- // Public ---------------------------------------------------------------------------------------------------------- #if (${NAME.endsWith("Test")}) // Test Overrides -------------------------------------------------------------------------------------------------- // Tests ----------------------------------------------------------------------------------------------------------- #end // Package protected ----------------------------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------------------------- // Private --------------------------------------------------------------------------------------------------------- // Inner classes --------------------------------------------------------------------------------------------------- }
Interface Template
Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end #parse("File Header.java") public interface ${NAME} { // Constants ------------------------------------------------------------------------------------------------------- // Static ---------------------------------------------------------------------------------------------------------- // Public ---------------------------------------------------------------------------------------------------------- }
Enum
Settings -> Editor -> Code & Style -> File and Code Templates -> Templates tab
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end #parse("File Header.java") public enum ${NAME} { // Constants ------------------------------------------------------------------------------------------------------- // Static ---------------------------------------------------------------------------------------------------------- // Public ---------------------------------------------------------------------------------------------------------- }
File Header
Settings -> Editor -> Code Style -> File and Code Templates -> "Includes" tab
Edit File Header:
/** * @author Ovidiu Feodorov <ovidiu@novaordis.com> * @since ${DATE} */
Method Template
Preferences -> Editor -> File and Code Templates -> Code tab -> Implemented Method Body
Replace the content with
throw new NotYetImplementedException("${METHOD_NAME}() NOT YET IMPLEMENTED");