@salesforce/apex-tmlanguage
Advanced tools
Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "@salesforce/apex-tmlanguage", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Textmate grammar for Apex with outputs for VSCode, Atom and TextMate.", | ||
@@ -5,0 +5,0 @@ "displayName": "apex-tmLanguage", |
@@ -318,94 +318,2 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Switch', () => { | ||
it('switch statement', () => { | ||
const input = Input.InMethod(` | ||
switch (i) { | ||
case 0: | ||
goto case 1; | ||
case 1: | ||
goto default; | ||
default: | ||
break; | ||
}`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.Switch, | ||
Token.Punctuation.OpenParen, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Case, | ||
Token.Literals.Numeric.Decimal('0'), | ||
Token.Punctuation.Colon, | ||
Token.Keywords.Control.Goto, | ||
Token.Keywords.Control.Case, | ||
Token.Literals.Numeric.Decimal('1'), | ||
Token.Punctuation.Semicolon, | ||
Token.Keywords.Control.Case, | ||
Token.Literals.Numeric.Decimal('1'), | ||
Token.Punctuation.Colon, | ||
Token.Keywords.Control.Goto, | ||
Token.Keywords.Control.Default, | ||
Token.Punctuation.Semicolon, | ||
Token.Keywords.Control.Default, | ||
Token.Punctuation.Colon, | ||
Token.Keywords.Control.Break, | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace | ||
]); | ||
}); | ||
it('switch statement with blocks', () => { | ||
const input = Input.InMethod(` | ||
switch (i) { | ||
case 0: | ||
{ | ||
goto case 1; | ||
} | ||
case 1: | ||
{ | ||
goto default; | ||
} | ||
default: | ||
{ | ||
break; | ||
} | ||
}`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.Switch, | ||
Token.Punctuation.OpenParen, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Case, | ||
Token.Literals.Numeric.Decimal('0'), | ||
Token.Punctuation.Colon, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Goto, | ||
Token.Keywords.Control.Case, | ||
Token.Literals.Numeric.Decimal('1'), | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace, | ||
Token.Keywords.Control.Case, | ||
Token.Literals.Numeric.Decimal('1'), | ||
Token.Punctuation.Colon, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Goto, | ||
Token.Keywords.Control.Default, | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace, | ||
Token.Keywords.Control.Default, | ||
Token.Punctuation.Colon, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Break, | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace, | ||
Token.Punctuation.CloseBrace | ||
]); | ||
}); | ||
}); | ||
describe('Try', () => { | ||
@@ -525,60 +433,2 @@ it('try-finally', () => { | ||
it('try-catch with exception filter', () => { | ||
const input = Input.InMethod(` | ||
try | ||
{ | ||
throw new Exception(); | ||
} | ||
catch when (true) | ||
{ | ||
}`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.Try, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Throw, | ||
Token.Keywords.Control.New, | ||
Token.Support.Class.Text('Exception'), | ||
Token.Punctuation.OpenParen, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace, | ||
Token.Keywords.Control.Catch, | ||
Token.Keywords.Control.When, | ||
Token.Punctuation.OpenParen, | ||
Token.Literals.Boolean.True, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Punctuation.CloseBrace | ||
]); | ||
}); | ||
it('try-catch with exception type and filter', () => { | ||
const input = Input.InMethod(` | ||
try | ||
{ | ||
} | ||
catch (Exception) when (true) | ||
{ | ||
}`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.Try, | ||
Token.Punctuation.OpenBrace, | ||
Token.Punctuation.CloseBrace, | ||
Token.Keywords.Control.Catch, | ||
Token.Punctuation.OpenParen, | ||
Token.Support.Class.Text('Exception'), | ||
Token.Punctuation.CloseParen, | ||
Token.Keywords.Control.When, | ||
Token.Punctuation.OpenParen, | ||
Token.Literals.Boolean.True, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Punctuation.CloseBrace | ||
]); | ||
}); | ||
it('try-finally followed by statement', () => { | ||
@@ -585,0 +435,0 @@ const input = Input.InMethod(` |
@@ -400,3 +400,3 @@ import { should } from 'chai'; | ||
it('upsert a new list of objects', () => { | ||
const input = Input.InMethod(`upsert new List<User>{User1, User2});`); | ||
const input = Input.InMethod(`upsert new List<User>{User1, User2};`); | ||
const tokens = tokenize(input); | ||
@@ -419,3 +419,64 @@ | ||
}); | ||
it('merge method usage in method', () => { | ||
const input = Input.InMethod(`merge masterAcct mergeAcct;`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Support.Class.FunctionText('merge'), | ||
Token.Variables.ReadWrite('masterAcct'), | ||
Token.Variables.ReadWrite('mergeAcct'), | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
it('merge using new object statement', () => { | ||
const input = Input.InMethod(`merge masterAcct new Account(name='Master');`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Support.Class.FunctionText('merge'), | ||
Token.Variables.ReadWrite('masterAcct'), | ||
Token.Keywords.Control.New, | ||
Token.Type('Account'), | ||
Token.Punctuation.OpenParen, | ||
Token.Variables.ReadWrite('name'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('Master'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
it('merge using only new statements', () => { | ||
const input = Input.InMethod(`merge new Account(name='Master') new List<Account>{acc1, acc2};`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Support.Class.FunctionText('merge'), | ||
Token.Keywords.Control.New, | ||
Token.Type('Account'), | ||
Token.Punctuation.OpenParen, | ||
Token.Variables.ReadWrite('name'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('Master'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen, | ||
Token.Keywords.Control.New, | ||
Token.Type('List'), | ||
Token.Punctuation.TypeParameters.Begin, | ||
Token.Type('Account'), | ||
Token.Punctuation.TypeParameters.End, | ||
Token.Punctuation.OpenBrace, | ||
Token.Variables.ReadWrite('acc1'), | ||
Token.Punctuation.Comma, | ||
Token.Variables.ReadWrite('acc2'), | ||
Token.Punctuation.CloseBrace, | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
}); | ||
}); |
@@ -296,6 +296,2 @@ /*--------------------------------------------------------------------------------------------- | ||
); | ||
export const Switch = createToken( | ||
'switch', | ||
'keyword.control.switch.apex' | ||
); | ||
export const Throw = createToken( | ||
@@ -340,2 +336,18 @@ 'throw', | ||
export namespace Switch { | ||
export const Switch = createToken( | ||
'switch', | ||
'keyword.control.switch.apex' | ||
); | ||
export const On = createToken('on', 'keyword.control.switch.on.apex'); | ||
export const When = createToken( | ||
'when', | ||
'keyword.control.switch.when.apex' | ||
); | ||
export const Else = createToken( | ||
'else', | ||
'keyword.control.switch.else.apex' | ||
); | ||
} | ||
export namespace Queries { | ||
@@ -342,0 +354,0 @@ export const Ascending = createToken( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
510007
37
6733