Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dschach committed Oct 24, 2023
1 parent 7c4948e commit ce2f572
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 132 deletions.
3 changes: 3 additions & 0 deletions demo/testcode.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
AND Date__kav NOT IN LAST_N_DAYS:80
ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
LIMIT 10];

List<Opportunity> opps = [SELECT Id FROM Opportunity WHERE Id NOT IN :newRecordsMap.keySet()];
</code></pre>
<p>-------NEW LANGUAGE----------</p>
<pre><code>
Expand Down Expand Up @@ -89,6 +91,7 @@
* @return `PageReference` Page to go to after deleting `ActionPlan__c`
*/
public PageReference deletePlan() {
this(DEFAULT_SIZE);
//delete ap, which will also delete apts via master-detail relationship
try {
delete actionPlan;
Expand Down
196 changes: 64 additions & 132 deletions src/languages/apex.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,18 @@ export default function (hljs) {
];

const LANGUAGE_VARS = [
'abstract',
'global',
'interface',
//'new',
'private',
'protected',
'public',
'static',
'virtual',
'final',
'instanceof',
'new',
'super',
'this',
'transient'
'this'
];

// keyword
const STORAGE_MODIFIER_LIST = [
'abstract',
'final',
'global',
'new',
'interface',
'override',
'private',
'protected',
Expand Down Expand Up @@ -519,7 +509,6 @@ export default function (hljs) {
// Type 3: annotation on one line and parentheses on next
// @IsTest
// (Seealldata=true)

{
begin: [regex.concat(ANNOTATION_RE, /\b/), /\s*\(/],
beginScope: { 1: 'meta annotations', 2: 'punctuation' },
Expand Down Expand Up @@ -615,53 +604,33 @@ export default function (hljs) {
OPERATORS,
COLLECTION_DECLARATION,
{
//contains: [NUMBERS, hljs.APOS_STRING_MODE],
illegal: ':',
endsWithParent: true,
relevance: 0,
variants: [
{
match: regex.concat(/\b/, regex.either(...LITERALS), /\b/),
scope: 'literal'
},
{
// mymethod(c.Id, c.Name); highlights each part of each parameter
// must be followed by comma or paren
match: [APEX_IDENT_RE, /\./, APEX_IDENT_RE, /\s*(?=[,)])/],
scope: { 1: 'variable', 3: 'property' }
},
{
// mymethod(Date myDate, Date yourDate); highlights each part of each parameter
// must be followed by comma or paren
match: [APEX_IDENT_RE, /\s+/, APEX_IDENT_RE, /\s*(?=[,)])/],
scope: { 1: 'type', 3: 'variable' }
},
{
// Parameter type, when declaring a method.
// This is a word, with/without a period, followed by a space and then NOT by a comma or paren
match: [
regex.either(
APEX_IDENT_RE,
regex.concat(APEX_IDENT_RE, /\./, APEX_IDENT_RE)
),
/\s+(?![,)])/
],
scope: { 1: 'variable' }
},
{
// Second part of the parameter, followed by comma or paren
match: [APEX_IDENT_RE, /\s*(?=[,)])/],
scope: { 1: 'variable' }
}
]
match: regex.concat(/\b/, regex.either(...LITERALS), /\b\s*(?=[,)])/),
scope: 'literal'
},
{
// mymethod(c.Id, c.Name); highlights each part of each parameter
// must be followed by comma or paren
match: [/(?<=[,\(])\s*(${APEX_IDENT_RE})/, /\./, APEX_IDENT_RE, /\s*(?=[,)])/],
scope: { 1: 'variable', 3: 'property' }
},
{
// mymethod(Date myDate, Date yourDate); highlights each part of each parameter
// must be followed by comma or paren
match: [/(?<=[,\(])\s*(${APEX_IDENT_RE})/, /\s+/, APEX_IDENT_RE, /\s*(?=[,)])/],
scope: { 1: 'type', 3: 'variable' }
},
{
// Second part of the parameter, followed by comma or paren
match: [APEX_IDENT_RE, /\s*(?=[,)])/],
scope: { 1: 'variable' }
}
]
};

const INSTANTIATE = [
{
// Account a = new Account(Name = 'test account);
begin: [/\bnew\b/, /\s+/, APEX_IDENT_RE, /\s*/, /(?=\()/],
begin: [/\bnew\b/, /\s+/, APEX_IDENT_RE, /\s*(?=\()/],
beginScope: {
1: 'keyword',
3: 'title.function.invoke'
Expand All @@ -675,37 +644,37 @@ export default function (hljs) {
}
];

const PARAMS_CALL = {

};

const METHOD_CALL = {
end: /(?=\)\s*[^{])/,
returnEnd: true,
scope: 'method call',
variants: [
{
begin: [/\./, APEX_IDENT_RE, /(?=\s*\(\))/],
beginScope: { 2: 'title.function.invoke' }
begin: regex.concat(APEX_IDENT_RE, /(?=\s*\()/),
beginScope: 'title.function.invoke',
},
{
begin: [APEX_IDENT_RE, /\./, /(${APEX_IDENT_RE})(?=\s*\()/],
beginScope: {1: 'class.title', 3: 'title.function.invoke'},
}
/* {
begin: [
/\./,
regex.concat('(?:' + APEX_IDENT_RE + ')'),
/(?=\s*\([^\)])/
],
beginScope: { 2: 'title.function.invoke' }
}, */
/* {
begin: [
/(?<=\s)/,
regex.concat('(?:' + APEX_IDENT_RE + ')'),
/(?=\s*\()/
],
beginScope: { 2: 'title.function' }
} */
],
end: /(?=\))/,
returnEnd: true,
contains: [
contains: [
COMMENT_LINE,
COMMENT_BLOCK,
hljs.APOS_STRING_MODE,
PARAMS,
INSTANTIATE
INSTANTIATE,
/* {
begin: [/\bthis/,/\(/],
returnBegin: true,
end: /\)/,
returnEnd: true,
contains: [PARAMS]
} */
],
relevance: 0
};
Expand Down Expand Up @@ -838,7 +807,7 @@ export default function (hljs) {
scope: 'keyword'
};

const CONSTRUCTOR_DECLARATION = [
/* const CONSTRUCTOR_DECLARATION = [
{
// Constructor
// Matches public/private, methodname, then parens and a curly bracket
Expand All @@ -850,58 +819,16 @@ export default function (hljs) {
end: /\)\s*{/,
contains: [PARAMS]
}
];

const METHOD_DECLARATION = [
{
match: /method/,
scope: 'substr'

// Method declarations
/* begin: [
'(?:' + APEX_IDENT_RE + '\\s+)',
'(?:' + APEX_IDENT_RE + '\\s+)',
hljs.UNDERSCORE_IDENT_RE,
/(?=\s*\()/
],
scope: { 2: 'type', 3: 'title.function' }, */
/* {
begin: [
/((?:public|private|protected|global))?\s* /,
/((?:static|override))?\s* /,
/((?:static|override))?\s* /,
'(?:' + APEX_FULL_TYPE_RE + ')\\s+',
APEX_IDENT_RE,
/(?=\s* \()/
],
scope: {
1: 'keyword',
2: 'keyword',
3: 'keyword',
//4: 'type',
5: 'title.function'
},
keywords: KEYWORDS,
]; */

contains: [
COMMENT_LINE,
COMMENT_BLOCK,
hljs.APOS_STRING_MODE,
COLLECTION_DECLARATION
],
relevance: 0,
illegal: [/\b_/, /_\b/]
}, */
}
];


const DECLARATIONS = [
TRIGGER_DECLARATION,
CLASS_SHARING,
TRIGGER_CONTEXT_DECLARATION,
ENUM_DECLARATION
//CONSTRUCTOR_DECLARATION,
//METHOD_DECLARATION
].concat(CLASS_DECLARATION);

const ASSIGNMENTS = [
Expand Down Expand Up @@ -940,21 +867,28 @@ export default function (hljs) {
];

const RETURNS = [
{
match: [/(?<=\breturn\b)\s+/, regex.either(LITERALS), /(?=\s*;)/],
scope: {
2: 'literal'
}
},
{
match: [/(?<=return)/, /\s+/, APEX_IDENT_RE, /(?=\s*;)/],
scope: {
3: 'variable'
}
},
{
begin: [/(?<=return)/, /\s+/, APEX_IDENT_RE, /\(/],
end: /\)/,
beginScope: {
3: 'title.function.invoke'
}
//contains: [PARAMS]
// * RETURN NEW OBJECT - NO PARAMS BY DEFAULT
match: [/(?<=return)/, /\s+/, /(?=(${APEX_IDENT_RE})\()/],
//returnBegin: true,
//end: /(?=\))/,
scope: {
2: 'title.function.invoke'
},
//contains: [METHOD_CALL, PARAMS]
}
// * RETURN NEW OBJECT - NO PARAMS BY DEFAULT
];

const SALESFORCE_ID = {
Expand Down Expand Up @@ -1076,7 +1010,7 @@ export default function (hljs) {
begin: [/\[/, /\s*/, /\b(SELECT|FIND)\b/],
beginScope: { 1: 'punctuation', 3: 'keyword for soql' },
//returnBegin: true,
end: /\]|\;/,
end: /\]/,
endScope: 'punctuation outer',
//returnEnd: true,
scope: 'soql',
Expand Down Expand Up @@ -1106,7 +1040,7 @@ export default function (hljs) {
endsParent: true
},
{
match: /=\s*:/,
match: /IN|=\s*:/,
scope: 'operator'
},
{
Expand Down Expand Up @@ -1205,9 +1139,7 @@ export default function (hljs) {
{
begin: regex.concat(/\b/, regex.either(...DMLS), /\b/),
//returnBegin: true,
//returnBegin: true,
beginScope: 'built_in',

scope: 'DML',
contains: [
INSTANTIATE,
Expand Down

0 comments on commit ce2f572

Please sign in to comment.