Last active
April 26, 2018 20:34
-
-
Save fracarma/fe68498a778ebdf0620538d691e7f500 to your computer and use it in GitHub Desktop.
Visual Studio Code Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Class Comment (ApexDoc)": { | |
"prefix": "Class Comment (ApexDoc)", | |
"body": "/**\n* @author ${1:FraCarma}\n* @date ${2:the date the class was first implemented}\n*\n* @group ${3:a group to display this class under, in the menu hierarchy}\n* @group-content ${4:a relative path to a static html file that provides content about the group}\n*\n* @description ${5:one or more lines that provide an overview of the class}\n*/", | |
"description": "", | |
}, | |
"FraCarmaComment": { | |
"prefix": "FraCarmaComment", | |
"body": "/* FraCarma: $1 */", | |
"description": "", | |
}, | |
"Method Comment (ApexDoc)": { | |
"prefix": "Method Comment (ApexDoc)", | |
"body": "/*******************************************************************************************************\n * @description ${1:one or more lines that provide an overview of the method}\n * @param ${2:paramName} ${3:a description of what the parameter does} \n * @return ${4:a description of the return value from the method}\n * @example\n * ${5: Example code usage. This will be wrapped in tags to preserve whitespace}\n */", | |
"description": "", | |
}, | |
"Property Comment (ApexDoc)": { | |
"prefix": "Property Comment (ApexDoc)", | |
"body": "/*******************************************************************************************************\n * @description ${1:one or more lines that describe the property}\n */", | |
"description": "", | |
}, | |
"sysdebug": { | |
"prefix": "sysdebug", | |
"body": "system.debug('@@${1:String} '${2});", | |
"description": "", | |
}, | |
"foreach": { | |
"prefix": "foreach", | |
"body": "for(${1:sObject} ${2:cursor}: ${2:cursor}List){\n\t${4}\n}", | |
"description": "", | |
}, | |
"getSetSimple": { | |
"prefix": "getSetSimple", | |
"body": "${1:permission} ${2:varType} ${3:varName}\t\t\t\t\t\t{ get; set;}", | |
"description": "declaration with {get;set;}", | |
}, | |
"new": { | |
"prefix": "new", | |
"body": "${1:SObject} ${2:name} = new ${1:SObject}();", | |
"description": "", | |
}, | |
"newStaticMethod": { | |
"prefix": "newStaticMethod", | |
"body": "/**\n * @description A description of the function\n * @param Param data type Param description\n * @param Param data type Param description\n * @return Return data type Return description\n **/\n\npublic static ${1:returnType} ${2:methodName} (${3:parameters}){\n ${1:returnType} res = new ${1:returnType}();\n ${4}\n return res;\n}", | |
"description": "new static method", | |
}, | |
"SELECT": { | |
"prefix": "SELECT", | |
"body": "${1: sObject}[] ${2: name} = [SELECT ${3: Fields} FROM ${1: sObject} ${4}];", | |
"description": "", | |
}, | |
"SELECT single": { | |
"prefix": "SELECT single", | |
"body": "${1: sObject}[] ${2: name}List = [SELECT ${3: Fields} FROM ${1: sObject} ${4} LIMIT 1];\n${1: sObject} ${2: name} = (${2: name}List.size() > 0)? ${2: name}List[0] : null;", | |
"description": "", | |
}, | |
"tryCatch": { | |
"prefix": "tryCatch", | |
"body": "try {\n\t${2}\n} catch (Exception e) {\n\tsystem.debug('@@Exception on '+e.getStackTraceString()+' : '+e.getMessage());\n}", | |
"description": "try catch with system debug", | |
}, | |
"addMess": { | |
"prefix": "addMess", | |
"body": "ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.${1:ERROR}, ${2:result.getErrors()[0].getMessage()}));", | |
"description": "Add Apex Page Message from Errors", | |
}, | |
"asse": { | |
"prefix": "asse", | |
"body": "System.assertEquals(${1:expected}, ${2:actual});", | |
"description": "Assert Equals", | |
}, | |
"assne": { | |
"prefix": "assne", | |
"body": "System.assertNotEquals(${1:expected}, ${2:actual});", | |
"description": "Assert Not Equals", | |
}, | |
"class": { | |
"prefix": "class", | |
"body": "${1:public} class ${2:ClassName} {\n\t${0}\n}", | |
"description": "New Class Signature", | |
}, | |
"classHeader": { | |
"prefix": "classHeader", | |
"body": "/**\n* @author ${1:Your Name} (${2:Your email address})\n* @version ${3:1.0}\n* @description ${4:Description of the class}\n*\n* 201${5:Y}-${6:MM}-${7:DD} : ${1:Your Name} - Original\n**/\n", | |
"description": "Class Header for Java Docs", | |
}, | |
"const": { | |
"prefix": "const", | |
"body": "${1:private} static final ${2:String} ${3:NAME} = ${4:VALUE};", | |
"description": "Private Static Variable", | |
}, | |
"ctror": { | |
"prefix": "ctror", | |
"body": "${1:public} ${2:ClassName} (${3:Parameters}) {\n\t${0}\n}", | |
"description": "Class Construstor", | |
}, | |
"datasave": { | |
"prefix": "datasave", | |
"body": "Database.SaveResult[] srList = Database.${1:insert/update}(${2:listToUpdate}, false);\n\n// Iterate through each returned result\nfor (Database.SaveResult sr : srList) {\n\tif (sr.isSuccess()) {\n\t\t// Operation was successful, so get the ID of the record that was processed\n\t\tSystem.debug('Successfully inserted ${3:object}. ${4:object} Id: ' + sr.getId());\n\t}\n\telse {\n\t\t// Operation failed, so get all errors\n\t\tfor(Database.Error err : sr.getErrors()) {\n\t\t\tSystem.debug('The following error has occurred.');\n\t\t\tSystem.debug(err.getStatusCode() + ': ' + err.getMessage());\n\t\t\tSystem.debug('${5:object} fields that affected this error: ' + err.getFields());\n\t\t}\n\t}\n}", | |
"description": "Save Result with iteration", | |
}, | |
"debug": { | |
"prefix": "debug", | |
"body": "System.debug(loggingLevel.Error, '*** ${1:object}: ' + ${1:object});", | |
"description": "System debug with log level Error", | |
}, | |
"dynSoql": { | |
"prefix": "dynSoql", | |
"body": "String ${1:soql} = 'SELECT ';\nfor(String fieldName : Schema.getGlobalDescribe().get(${2:sObjectName}).getDescribe().fields.getMap().keySet()) {\n\t${1:soql} += fieldName + ', ';\n}\n${1:soql} = ${1:soql}.left(${1:soql}.lastIndexOf(','));\n${1:soql} += ' FROM ' + ${2:sObjectName} + ' WHERE Id = \\'' + ${3:sObjId} + '\\'' + ' LIMIT 1000';\nList<${4:sObjectName}> ${5:sObjectList} = (List<${4:sObjectName}>) Database.query(${1:soql});", | |
"description": "Dynamic Query with all the Fields", | |
}, | |
"else": { | |
"prefix": "else", | |
"body": "else {\n\t${0}\n}", | |
"description": "Else clause", | |
}, | |
"elseif": { | |
"prefix": "elseif", | |
"body": "else if (${1:Condition}) {\n\t${0}\n}", | |
"description": "Else If clause", | |
}, | |
"for": { | |
"prefix": "for", | |
"body": "for(Integer i = 0; i < ${1:sObjectList}.size(); i++) {\n\t${1:sObjectList}[i]\n}", | |
"description": "Traditional FOR loop", | |
}, | |
"forBlock": { | |
"prefix": "forBlock", | |
"body": "for (Integer i = 0; i < ${1:sObjectList}.size(); i++) {\n\t$SELECTION\n}", | |
"description": "Trad FOR loop around selection", | |
}, | |
"fore": { | |
"prefix": "fore", | |
"body": "for(${1:sObject} ${2:sObj}: ${3:sObjList}) {\n\t${2:sObj}\n}", | |
"description": "Iterator-based FOR loop", | |
}, | |
"foreBlock": { | |
"prefix": "foreBlock", | |
"body": "for(${1:sObject} ${2:sObj}: ${3:sObjList}) {\n\t$SELECTION\n}", | |
"description": "Iter FOR loop around selection", | |
}, | |
"getParameter": { | |
"prefix": "getParameter", | |
"body": "String ${1:sObjId} = ApexPages.currentPage().getParameters().get('${2:Id}');", | |
"description": "Get Paramater from Current Page", | |
}, | |
"if": { | |
"prefix": "if", | |
"body": "if(${1:true}) {\n\t${2}\n}", | |
"description": "Simple IF Condition", | |
}, | |
"ifblock": { | |
"prefix": "ifblock", | |
"body": "if ($1) {\n\t$SELECTION\n}\n\t", | |
"description": "Adds if block around selection", | |
}, | |
"ifStrIsBlank": { | |
"prefix": "ifStrIsBlank", | |
"body": "if(String.isBlank(${1:Id})) {\n\t${2}\n}", | |
"description": "IF Condition with String isBlank", | |
}, | |
"ifIsNotBlank": { | |
"prefix": "ifIsNotBlank", | |
"body": "if(String.isNotBlank(${1:Id})) {\n\t${2}\n}", | |
"description": "IF Condition with String isNotBlank", | |
}, | |
"ife": { | |
"prefix": "ife", | |
"body": "if(${1}) {\n\t${2}\n} else {\n\t${3}\n}", | |
"description": "Simple IF ELSE Condition", | |
}, | |
"interface": { | |
"prefix": "interface", | |
"body": "interface I${1:InterfaceName} {\n\t${0}\n}", | |
"description": "Interface", | |
}, | |
"isBlank": { | |
"prefix": "isBlank", | |
"body": " String.isBlank(${1:Id})", | |
"description": "String isBlank", | |
}, | |
"isNotBlank": { | |
"prefix": "isNotBlank", | |
"body": "String.isNotBlank(${1:Id})", | |
"description": "String isNotBlank", | |
}, | |
"methodHeader": { | |
"prefix": "methodHeader", | |
"body": "/**\n * @description ${1:A description of the function}\n * @param ${2:Param data type} ${3:Param description}\n * @param ${4:Param data type} ${5:Param description}\n * @return ${6:Return data type} ${7:Return description}\n **/\n", | |
"description": "Method Header for Java Docs", | |
}, | |
"newArr": { | |
"prefix": "newArr", | |
"body": "${1:SObject}[] ${2:sObjects} = new ${1:SObject}[]{};", | |
"description": "Instantiate a new Array", | |
}, | |
"newList": { | |
"prefix": "newList", | |
"body": "List<${1:SObject}> ${2:sObjectList}List = new List<${1:SObject}>();", | |
"description": "Instantiate a new List", | |
}, | |
"newMap": { | |
"prefix": "newMap", | |
"body": "Map<${1:Id}, ${2:SObject}> ${3:sObjectMap}Map = new Map<${1:Id}, ${2:SObject}>();", | |
"description": "Instantiate a new Map", | |
}, | |
"newSet": { | |
"prefix": "newSet", | |
"body": "Set<${1:SObject}> ${2:sObjectSet}Set = new Set<${1:SObject}>();", | |
"description": "Instantiate a new Set", | |
}, | |
"pm": { | |
"prefix": "pm", | |
"body": "${1:private} ${2:ReturnType} ${3:MethodName}(${4:Parameters}) {\n\t${0}\n}", | |
"description": "Method", | |
}, | |
"prop": { | |
"prefix": "prop", | |
"body": "${1:public} ${2:String} ${3:variable} {get; set;}", | |
"description": "Property", | |
}, | |
"psm": { | |
"prefix": "psm", | |
"body": "${1:private} static ${2:ReturnType} ${3:MethodName}(${4:Parameters}) {\n\t${0}\n}", | |
"description": "Static Method", | |
}, | |
"soql": { | |
"prefix": "soql", | |
"body": "[\n\tSELECT Id, Name, ${4} \n\tFROM ${1:sObject} \n\tWHERE ${2:Id} =:${3:sObjId}\n]", | |
"description": "SOQL query", | |
}, | |
"sp": { | |
"prefix": "sp", | |
"body": "Savepoint sp = Database.setSavepoint();", | |
"description": "Database Set Savepoint", | |
}, | |
"testMeth": { | |
"prefix": "testMeth", | |
"body": "@isTest\nprivate static void ${1:MethodName}Test() {\n\t${2}\n}", | |
"description": "Test Method", | |
}, | |
"throw": { | |
"prefix": "throw", | |
"body": "throw new ${1:Exception}();", | |
"description": "Throw New Exception", | |
}, | |
"tryc": { | |
"prefix": "tryc", | |
"body": "try {\n\t${3}\n} catch(${1:Exception e}) {\n\t${2:System.debug(e.getMessage());}\n}", | |
"description": "Simple TRY CATCH Condition", | |
}, | |
"while": { | |
"prefix": "while", | |
"body": "while (${1:Condition}) {\n\t${0}\n}", | |
"description": "While Loop", | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment