atom-apex-snippets
A collection of Apex commands for optimizing modern Salesforce/force.com development productivity.
Atom Apex Snippets
A collection of Apex commands for optimizing modern Salesforce/force.com development productivity.
Install
For this package to function properly, please don't forget to install mavensmate-atom which will add the language grammars for these snippets.
apm install atom-apex-snippets
Contributing/Suggestions
Feel free to let me know (link) what else can be improved/added or you can also submit a PR.
Snippets Overview
Snippets are optimized to be short and easy to remember. Some snippets are "chainable" and render differently when preceded by a ".".
- [Apex Doc Comments](#Apex Doc Comments Snippets)
- [Control Flow](#Control Flow Snippets)
- [Classes](#Class Related Snippets)
- Miscellaneous
- [Return Values](#Returning Values Snippets)
- [Testing](#Testing Snippets)
Apex Doc Comments Snippets
commentMethod⇥
java doc method comment
/**
* @description your_method_description
* @param param_name your_param_description
* @return return_type your_return_description
**/$1
commentModule⇥
java doc module comment
/**
* The ____ program implements/is used for.....
*
* @author
*/
Control Flow Snippets
if⇥
if statement
if(${1:condition}) {
${2}
}$3
else⇥
else statement
else {
${1}
}$2
ifelse⇥
else statement
if(${1:condition}) {
${2}
} else {
${3}
}$4
elseif⇥
else if statement
else if (${1:condition}) {
${2}
}${3}
for⇥
for loop
for (Integer ${1:i} = 0; ${1:i} < ${2:iterable}${3:.length}; ${1:i}++) {
${4}
}${5}
fore⇥
iterator based for each loop
for(${1:object_type} ${2:var_name}: ${3:collection_name}) {
${4:var_name}
}$5
while⇥
while loop
while (${1:condition}) {
${2}
}$3
trycatch⇥
try/catch statement
try {
${1}
} catch(Exception ${2:exception_name}) {
${2:exception_name}
}$4
tryfinally⇥
try/finally statement
try {
${2}
} finally {
${2}
}$3
trycatchfinally⇥
try/catch/finally statement
try {
${1}
} catch(Exception ${2:exception_name}) {
${2:exception_name}
} finally {
${3}
}${4}
Class Related Snippets
class⇥
class
${1:pub_or_priv} class ${2:ClassName} {
${3}
}$4
constructorPublic⇥
public class constructor
${1:public} ${2:ClassName} (${3:Parameters}) {
${4}
}$5
constructorPrivate⇥
private class constructor
${1:private} ${2:ClassName} (${3:Parameters}) {
${4}
}$5
methodPublic⇥
public method
${1:public} ${2:ClassName} (${3:Parameters}) {
${4}
}$5
methodPrivate⇥
private method
${1:private} ${2:ClassName} (${3:Parameters}) {
${4}
}$5
methodStatic⇥
static method
${1:pub_or_private} static ${2:ClassName} (${3:Parameters}) {
${4}
}$5
Miscellaneous
debug⇥
System.debug
System.debug('*** ${1:object}: ' + ${1:object});$2
assertEquals⇥
System.assertEquals
System.assertEquals(${1:expected}, ${2:actual});$3
assertNotEquals⇥
System.assertNotEquals
System.assertNotEquals(${1:expected}, ${2:actual});$3
soql⇥
soql query
[SELECT ${2:field} FROM ${1:sObject}]$3
Returning Values Snippets
r⇥
return
return ${1};${2}
rt⇥
return true
return true;
rf⇥
return false
return false;
rth⇥
return this
return this;
rn⇥
return null
return null;
r0⇥
return 0
return 0;
r1⇥
return 1
return -1;
r-1⇥
return -1
return -1;
Testing
testMethod⇥
Test Method
@isTest
${1:pub_or_private} static void ${2:MethodName}Test() {
${3}
}$4
testSetup⇥
Test Setup
@TestSetup
static void setup() {
${1}
}
insert⇥
insert
insert ${1:sObject};${2}