Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grammar for Apex #6198

Merged
merged 10 commits into from
May 30, 2023
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
[submodule "vendor/grammars/apache.tmbundle"]
path = vendor/grammars/apache.tmbundle
url = https://github.com/textmate/apache.tmbundle
[submodule "vendor/grammars/apex-tmLanguage"]
path = vendor/grammars/apex-tmLanguage
url = https://github.com/forcedotcom/apex-tmLanguage.git
[submodule "vendor/grammars/api-blueprint-sublime-plugin"]
path = vendor/grammars/api-blueprint-sublime-plugin
url = https://github.com/apiaryio/api-blueprint-sublime-plugin
Expand Down
4 changes: 3 additions & 1 deletion grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ vendor/grammars/antlr.tmbundle:
vendor/grammars/apache.tmbundle:
- source.apache-config
- source.apache-config.mod_perl
vendor/grammars/apex-tmLanguage:
- source.apex
vendor/grammars/api-blueprint-sublime-plugin:
- text.html.markdown.source.gfm.apib
- text.html.markdown.source.gfm.mson
Expand Down Expand Up @@ -1168,4 +1170,4 @@ vendor/grammars/xml.tmbundle:
vendor/grammars/zeek-sublime:
- source.zeek
vendor/grammars/zephir-sublime:
- source.php.zephir
- source.php.zephir
4 changes: 3 additions & 1 deletion lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ Apex:
type: programming
color: "#1797c0"
extensions:
- ".apex"
lildude marked this conversation as resolved.
Show resolved Hide resolved
- ".cls"
tm_scope: source.java
- ".trigger"
muenzpraeger marked this conversation as resolved.
Show resolved Hide resolved
tm_scope: source.apex
ace_mode: java
codemirror_mode: clike
codemirror_mime_type: text/x-java
Expand Down
45 changes: 45 additions & 0 deletions samples/Apex/LogTriggerHandler.trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @description Trigger handler for persisting Platform Event based
* log messages.
*
* @group Trigger Recipes
* @see Log
*/
public with sharing class LogTriggerHandler extends TriggerHandler {
List<Log__e> incomingRecords = new List<Log__e>();

/**
* @description constructor accepting a list of log__e records
*/
public LogTriggerHandler() {
this.incomingRecords = (List<Log__e>) Trigger.new;
}

/**
* @description code to be executed in the afterInsert context
*/
override public void afterInsert() {
List<LogEvent__c> events = new List<LogEvent__c>();

for (Log__e event : this.incomingRecords) {
events.add(
new LogEvent__c(
Log_Data__c = event.Log_Message__c,
Quiddity__c = event.Quiddity__c,
Request_Id__c = event.Request_Id__c,
Severity__c = event.Severity__c
)
);
}

List<Database.SaveResult> res = Database.insert(events, false);
for (Database.SaveResult saveRes : res) {
if (!saveRes.isSuccess()) {
System.debug(
LoggingLevel.ERROR,
'Failed to save log message: ' + saveRes
);
}
}
}
}
2 changes: 1 addition & 1 deletion vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Ant Build System:** [textmate/ant.tmbundle](https://github.com/textmate/ant.tmbundle)
- **Antlers:** [Stillat/vscode-antlers-language-server](https://github.com/Stillat/vscode-antlers-language-server)
- **ApacheConf:** [textmate/apache.tmbundle](https://github.com/textmate/apache.tmbundle)
- **Apex:** [textmate/java.tmbundle](https://github.com/textmate/java.tmbundle)
- **Apex:** [forcedotcom/apex-tmLanguage](https://github.com/forcedotcom/apex-tmLanguage)
- **Apollo Guidance Computer:** [Alhadis/language-agc](https://github.com/Alhadis/language-agc)
- **AppleScript:** [textmate/applescript.tmbundle](https://github.com/textmate/applescript.tmbundle)
- **AsciiDoc:** [zuckschwerdt/asciidoc.tmbundle](https://github.com/zuckschwerdt/asciidoc.tmbundle)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/apex-tmLanguage
Submodule apex-tmLanguage added at b9fc1a