@salesforce/apex-tmlanguage
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -50,9 +50,17 @@ const gulp = require('gulp'); | ||
gulp.task('test', gulp.series(['compile'], () => { | ||
return gulp | ||
.src(jsOut + 'test/**/*.tests.js') | ||
.pipe(mocha()) | ||
.on('error', handleError); | ||
})); | ||
gulp.task( | ||
'test', | ||
gulp.series(['compile'], () => { | ||
return gulp | ||
.src(jsOut + 'test/**/*.tests.js') | ||
.pipe(mocha()) | ||
.on('error', handleError); | ||
}) | ||
); | ||
gulp.task('default', gulp.series(['buildAtom', 'buildTmLanguage'], function(done) { done() })); | ||
gulp.task( | ||
'default', | ||
gulp.series(['buildAtom', 'buildTmLanguage'], function(done) { | ||
done(); | ||
}) | ||
); |
{ | ||
"name": "@salesforce/apex-tmlanguage", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Textmate grammar for Apex with outputs for VSCode, Atom and TextMate.", | ||
@@ -15,2 +15,6 @@ "displayName": "apex-tmLanguage", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/forcedotcom/apex-tmLanguage.git" | ||
}, | ||
"contributors": [ | ||
@@ -34,3 +38,3 @@ { | ||
"test": "gulp test", | ||
"prepublish": "gulp", | ||
"prepare": "gulp", | ||
"build:default": "gulp default", | ||
@@ -37,0 +41,0 @@ "format": "prettier --config .prettierrc.json --write './**/*.{ts,js,json,md}'" |
@@ -17,4 +17,4 @@ # Salesforce Apex Language Grammar | ||
* Run `npm install` to install any dependencies. | ||
* Run `gulp` to build and run tests. | ||
- Run `npm install` to install any dependencies. | ||
- Run `gulp` to build and run tests. | ||
@@ -29,4 +29,4 @@ Output grammars are output in the `grammars\` dirctory. | ||
* `grammars\apex.tmLanguage.cson` - for Atom | ||
* `grammars\apex.tmLanguage` - TextMate grammar (XML plist) | ||
- `grammars\apex.tmLanguage.cson` - for Atom | ||
- `grammars\apex.tmLanguage` - TextMate grammar (XML plist) | ||
@@ -33,0 +33,0 @@ ## Releasing |
@@ -5,4 +5,4 @@ ## Important regular expressions: | ||
* Expression: `[_[:alpha:]][_[:alnum:]]*` | ||
* Matches: `_`, `Ident42` | ||
- Expression: `[_[:alpha:]][_[:alnum:]]*` | ||
- Matches: `_`, `Ident42` | ||
@@ -9,0 +9,0 @@ #### Type name |
@@ -10,3 +10,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -13,0 +15,0 @@ describe('Annotation', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Apex Class', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Comments', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Constructors', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Enums', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Expressions', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Field', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Incomplete code', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Interfaces', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Literals', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Locals', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Methods', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Operators', () => { |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Property', () => { |
@@ -10,3 +10,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -243,5 +245,5 @@ describe('Queries', () => { | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.In, | ||
Token.Keywords.Queries.OperatorName('IN'), | ||
Token.Operators.Conditional.Colon, | ||
Token.Keywords.Queries.FieldName('variable'), | ||
Token.Identifiers.LocalName('variable'), | ||
Token.Punctuation.CloseBracket, | ||
@@ -251,3 +253,302 @@ Token.Punctuation.Semicolon | ||
}); | ||
it('where clause with parameter grouping', () => { | ||
const input = Input.InMethod( | ||
`SELECT Id FROM Subscription__c WHERE (Contract__c IN :contractIds OR Contract__c = 'Name')` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Subscription__c'), | ||
Token.Keywords.Queries.Where, | ||
Token.Punctuation.OpenParen, | ||
Token.Keywords.Queries.FieldName('Contract__c'), | ||
Token.Keywords.Queries.OperatorName('IN'), | ||
Token.Operators.Conditional.Colon, | ||
Token.Identifiers.LocalName('contractIds'), | ||
Token.Keywords.Queries.OperatorName('OR'), | ||
Token.Keywords.Queries.FieldName('Contract__c'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('Name'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen | ||
]); | ||
}); | ||
it('query with multiple operators after where clause', () => { | ||
const input = Input.InMethod( | ||
`SELECT Id FROM Contact WHERE Name LIKE 'A%' AND MailingState='California'` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Contact'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('Name'), | ||
Token.Keywords.Queries.OperatorName('LIKE'), | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('A%'), | ||
Token.Punctuation.String.End, | ||
Token.Keywords.Queries.OperatorName('AND'), | ||
Token.Keywords.Queries.FieldName('MailingState'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('California'), | ||
Token.Punctuation.String.End | ||
]); | ||
}); | ||
it('query with datetime constant usage', () => { | ||
const input = Input.InMethod( | ||
`SELECT Name FROM Account WHERE CreatedDate > 2011-04-26T10:00:00-08:00` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Name'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Account'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('CreatedDate'), | ||
Token.Operators.Relational.GreaterThan, | ||
Token.Literals.Numeric.DateTimeUTC('2011-04-26T10:00:00-08:00') | ||
]); | ||
}); | ||
it('query using soql methods on conditional syntax', () => { | ||
const input = Input.InMethod( | ||
`SELECT Amount FROM Opportunity WHERE CALENDAR_YEAR(CreatedDate) = 2011` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Amount'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Opportunity'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.QueryMethod('CALENDAR_YEAR'), | ||
Token.Punctuation.OpenParen, | ||
Token.Keywords.Queries.FieldName('CreatedDate'), | ||
Token.Punctuation.CloseParen, | ||
Token.Operators.Assignment, | ||
Token.Literals.Numeric.Decimal('2011') | ||
]); | ||
}); | ||
it('query using soql methods for translation', () => { | ||
const input = Input.InMethod( | ||
`SELECT Company, toLabel(Recordtype.Name) FROM Lead` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Company'), | ||
Token.Punctuation.Comma, | ||
Token.Keywords.Queries.QueryMethod('toLabel'), | ||
Token.Punctuation.OpenParen, | ||
Token.Keywords.Queries.FieldName('Recordtype.Name'), | ||
Token.Punctuation.CloseParen, | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Lead') | ||
]); | ||
}); | ||
it('query using soql methods for translation', () => { | ||
const input = Input.InMethod( | ||
`SELECT Id, MSP1__c FROM CustObj__c WHERE MSP1__c INCLUDES ('AAA;BBB','CCC')` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Punctuation.Comma, | ||
Token.Keywords.Queries.FieldName('MSP1__c'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('CustObj__c'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('MSP1__c'), | ||
Token.Keywords.Queries.QueryMethod('INCLUDES'), | ||
Token.Punctuation.OpenParen, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('AAA;BBB'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.Comma, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('CCC'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen | ||
]); | ||
}); | ||
it('Filtering on Polymorphic Relationship Fields', () => { | ||
const input = Input.InMethod( | ||
`SELECT Id FROM Event WHERE What.Type NOT IN ('Account', 'Opportunity')` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Event'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('What.Type'), | ||
Token.Keywords.Queries.OperatorName('NOT IN'), | ||
Token.Punctuation.OpenParen, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('Account'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.Comma, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('Opportunity'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen | ||
]); | ||
}); | ||
it('Filtering using date literals', () => { | ||
const input = Input.InMethod( | ||
`SELECT Id FROM Account WHERE CreatedDate = LAST_90_DAYS` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Account'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('CreatedDate'), | ||
Token.Operators.Assignment, | ||
Token.Keywords.Queries.DateLiteral('LAST_90_DAYS') | ||
]); | ||
}); | ||
it('Filtering using date literals', () => { | ||
const input = Input.InMethod( | ||
`SELECT Id FROM Opportunity WHERE CloseDate > LAST_N_FISCAL_YEARS:3` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Opportunity'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('CloseDate'), | ||
Token.Operators.Relational.GreaterThan, | ||
Token.Keywords.Queries.DateLiteral('LAST_N_FISCAL_YEARS:3') | ||
]); | ||
}); | ||
it('USING SCOPE: Get all account that belong to you', () => { | ||
const input = Input.InMethod(`SELECT Id FROM Account USING SCOPE Mine`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Account'), | ||
Token.Keywords.Queries.UsingScope('USING SCOPE Mine') | ||
]); | ||
}); | ||
it('filter using LIMIT & OFFSET', () => { | ||
const input = Input.InMethod( | ||
`SELECT Id FROM Discontinued_Merchandise__c LIMIT 100 OFFSET 20` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Discontinued_Merchandise__c'), | ||
Token.Keywords.Queries.OperatorName('LIMIT'), | ||
Token.Literals.Numeric.Decimal('100'), | ||
Token.Keywords.Queries.OperatorName('OFFSET'), | ||
Token.Literals.Numeric.Decimal('20') | ||
]); | ||
}); | ||
it('group by rollup', () => { | ||
const input = Input.InMethod( | ||
`SELECT Status, LeadSource, COUNT(Name) cnt FROM Lead GROUP BY ROLLUP(Status, LeadSource)` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Status'), | ||
Token.Punctuation.Comma, | ||
Token.Keywords.Queries.FieldName('LeadSource'), | ||
Token.Punctuation.Comma, | ||
Token.Keywords.Queries.QueryMethod('COUNT'), | ||
Token.Punctuation.OpenParen, | ||
Token.Keywords.Queries.FieldName('Name'), | ||
Token.Punctuation.CloseParen, | ||
Token.Keywords.Queries.FieldName('cnt'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Lead'), | ||
Token.Keywords.Queries.QueryMethod('GROUP BY ROLLUP'), | ||
Token.Punctuation.OpenParen, | ||
Token.Keywords.Queries.FieldName('Status'), | ||
Token.Punctuation.Comma, | ||
Token.Keywords.Queries.FieldName('LeadSource'), | ||
Token.Punctuation.CloseParen | ||
]); | ||
}); | ||
it('soql function has another soql function as parameter', () => { | ||
const input = Input.InMethod( | ||
`SELECT CreatedDate FROM Opportunity GROUP BY HOUR_IN_DAY(convertTimezone(CreatedDate))` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('CreatedDate'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Opportunity'), | ||
Token.Keywords.Queries.OperatorName('GROUP BY'), | ||
Token.Keywords.Queries.QueryMethod('HOUR_IN_DAY'), | ||
Token.Punctuation.OpenParen, | ||
Token.Keywords.Queries.QueryMethod('convertTimezone'), | ||
Token.Punctuation.OpenParen, | ||
Token.Keywords.Queries.FieldName('CreatedDate'), | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.CloseParen | ||
]); | ||
}); | ||
it('simple query inside of brackets with where & in clause', () => { | ||
const input = Input.InMethod(`SELECT Id FROM User WHERE Id IN :variable`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('User'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('Id'), | ||
Token.Keywords.Queries.OperatorName('IN'), | ||
Token.Operators.Conditional.Colon, | ||
Token.Identifiers.LocalName('variable') | ||
]); | ||
}); | ||
}); | ||
}); |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -33,111 +35,2 @@ describe('Statements', () => { | ||
describe('For', () => { | ||
it('single-line for loop', () => { | ||
const input = Input.InMethod(`for (Integer i = 0; i < 42; i++) { }`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.For, | ||
Token.Punctuation.OpenParen, | ||
Token.PrimitiveType.Integer, | ||
Token.Identifiers.LocalName('i'), | ||
Token.Operators.Assignment, | ||
Token.Literals.Numeric.Decimal('0'), | ||
Token.Punctuation.Semicolon, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Operators.Relational.LessThan, | ||
Token.Literals.Numeric.Decimal('42'), | ||
Token.Punctuation.Semicolon, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Operators.Increment, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Punctuation.CloseBrace | ||
]); | ||
}); | ||
it('for loop with break', () => { | ||
const input = Input.InMethod(` | ||
for (Integer i = 0; i < 42; i++) | ||
{ | ||
break; | ||
}`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.For, | ||
Token.Punctuation.OpenParen, | ||
Token.PrimitiveType.Integer, | ||
Token.Identifiers.LocalName('i'), | ||
Token.Operators.Assignment, | ||
Token.Literals.Numeric.Decimal('0'), | ||
Token.Punctuation.Semicolon, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Operators.Relational.LessThan, | ||
Token.Literals.Numeric.Decimal('42'), | ||
Token.Punctuation.Semicolon, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Operators.Increment, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Break, | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace | ||
]); | ||
}); | ||
it('for loop with continue', () => { | ||
const input = Input.InMethod(` | ||
for (Integer i = 0; i < 42; i++) | ||
{ | ||
continue; | ||
}`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.For, | ||
Token.Punctuation.OpenParen, | ||
Token.PrimitiveType.Integer, | ||
Token.Identifiers.LocalName('i'), | ||
Token.Operators.Assignment, | ||
Token.Literals.Numeric.Decimal('0'), | ||
Token.Punctuation.Semicolon, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Operators.Relational.LessThan, | ||
Token.Literals.Numeric.Decimal('42'), | ||
Token.Punctuation.Semicolon, | ||
Token.Variables.ReadWrite('i'), | ||
Token.Operators.Increment, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Continue, | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace | ||
]); | ||
}); | ||
/* @TODO: fix test | ||
it("for loop on collection", () => { | ||
const input = Input.InMethod(` | ||
for (Integer i : listOfIntegers) | ||
{ | ||
continue; | ||
}`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Keywords.Control.For, | ||
Token.Punctuation.OpenParen, | ||
Token.PrimitiveType.Integer, | ||
Token.Variables.ReadWrite("i"), | ||
Token.Operators.Conditional.Colon, | ||
Token.Variables.ReadWrite("listOfIntegers"), | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.OpenBrace, | ||
Token.Keywords.Control.Continue, | ||
Token.Punctuation.Semicolon, | ||
Token.Punctuation.CloseBrace, | ||
]); | ||
}); */ | ||
}); | ||
describe('While', () => { | ||
@@ -144,0 +37,0 @@ it('single-line while loop', () => { |
@@ -5,3 +5,5 @@ import { should } from 'chai'; | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -356,3 +358,64 @@ describe('Apex System Class', () => { | ||
}); | ||
it('insert a new object with parameters', () => { | ||
const input = Input.InMethod( | ||
`insert new MyObject__c(Name='Test', Meaning__c='Bad');` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Support.Class.FunctionText('insert'), | ||
Token.Keywords.Control.New, | ||
Token.Type('MyObject__c'), | ||
Token.Punctuation.OpenParen, | ||
Token.Variables.ReadWrite('Name'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('Test'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.Comma, | ||
Token.Variables.ReadWrite('Meaning__c'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.String.Begin, | ||
Token.Literals.String('Bad'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
it('delete a new object with no parameters', () => { | ||
const input = Input.InMethod(`delete new MyObjectWrapper());`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Support.Class.FunctionText('delete'), | ||
Token.Keywords.Control.New, | ||
Token.Type('MyObjectWrapper'), | ||
Token.Punctuation.OpenParen, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
it('upsert a new list of objects', () => { | ||
const input = Input.InMethod(`upsert new List<User>{User1, User2});`); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Support.Class.FunctionText('upsert'), | ||
Token.Keywords.Control.New, | ||
Token.Type('List'), | ||
Token.Punctuation.TypeParameters.Begin, | ||
Token.Type('User'), | ||
Token.Punctuation.TypeParameters.End, | ||
Token.Punctuation.OpenBrace, | ||
Token.Variables.ReadWrite('User1'), | ||
Token.Punctuation.Comma, | ||
Token.Variables.ReadWrite('User2'), | ||
Token.Punctuation.CloseBrace, | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
}); | ||
}); |
@@ -10,3 +10,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -154,3 +156,3 @@ describe('Apex Trigger', () => { | ||
Token.Keywords.Queries.FieldName('AccountId'), | ||
Token.Keywords.Queries.In, | ||
Token.Keywords.Queries.OperatorName('IN'), | ||
Token.Operators.Conditional.Colon, | ||
@@ -164,3 +166,69 @@ Token.Support.Class.Trigger, | ||
}); | ||
it('SOQL in triggers using methods in clauses', () => { | ||
const input = Input.InTrigger( | ||
`Contact[] cons = [SELECT LastName FROM Contact WHERE AccountId IN :keys('w')];` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Type('Contact'), | ||
Token.Punctuation.OpenBracket, | ||
Token.Punctuation.CloseBracket, | ||
Token.Identifiers.LocalName('cons'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.OpenBracket, | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('LastName'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Contact'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('AccountId'), | ||
Token.Keywords.Queries.OperatorName('IN'), | ||
Token.Operators.Conditional.Colon, | ||
Token.Identifiers.MethodName('keys'), | ||
Token.Punctuation.OpenParen, | ||
Token.Punctuation.String.Begin, | ||
Token.XmlDocComments.String.SingleQuoted.Text('w'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.CloseBracket, | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
it('SOQL in triggers using objects in clauses', () => { | ||
const input = Input.InTrigger( | ||
`Contact[] cons = [SELECT LastName FROM Contact WHERE AccountId IN :myObject.keys('w')];` | ||
); | ||
const tokens = tokenize(input); | ||
tokens.should.deep.equal([ | ||
Token.Type('Contact'), | ||
Token.Punctuation.OpenBracket, | ||
Token.Punctuation.CloseBracket, | ||
Token.Identifiers.LocalName('cons'), | ||
Token.Operators.Assignment, | ||
Token.Punctuation.OpenBracket, | ||
Token.Keywords.Queries.Select, | ||
Token.Keywords.Queries.FieldName('LastName'), | ||
Token.Keywords.Queries.From, | ||
Token.Keywords.Queries.TypeName('Contact'), | ||
Token.Keywords.Queries.Where, | ||
Token.Keywords.Queries.FieldName('AccountId'), | ||
Token.Keywords.Queries.OperatorName('IN'), | ||
Token.Operators.Conditional.Colon, | ||
Token.Variables.Object('myObject'), | ||
Token.Punctuation.Accessor, | ||
Token.Identifiers.MethodName('keys'), | ||
Token.Punctuation.OpenParen, | ||
Token.Punctuation.String.Begin, | ||
Token.XmlDocComments.String.SingleQuoted.Text('w'), | ||
Token.Punctuation.String.End, | ||
Token.Punctuation.CloseParen, | ||
Token.Punctuation.CloseBracket, | ||
Token.Punctuation.Semicolon | ||
]); | ||
}); | ||
}); | ||
}); |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('Type names', () => { |
@@ -267,2 +267,6 @@ /*--------------------------------------------------------------------------------------------- | ||
); | ||
export const ColonIterator = createToken( | ||
':', | ||
'keyword.operator.iterator.colon.apex' | ||
); | ||
export const Default = createToken( | ||
@@ -342,2 +346,4 @@ 'default', | ||
export const By = createToken('by', 'keyword.operator.query.by.apex'); | ||
export const DateLiteral = (text: string) => | ||
createToken(text, 'keyword.operator.query.date.apex'); | ||
export const Descending = createToken( | ||
@@ -359,3 +365,2 @@ 'DESC', | ||
); | ||
export const In = createToken('IN', 'keyword.operator.query.in.apex'); | ||
export const Into = createToken( | ||
@@ -379,2 +384,4 @@ 'into', | ||
export const On = createToken('on', 'keyword.operator.query.on.apex'); | ||
export const OperatorName = (text: string) => | ||
createToken(text, 'keyword.operator.query.apex'); | ||
export const OrderBy = createToken( | ||
@@ -392,2 +399,4 @@ 'ORDER BY', | ||
createToken(text, 'storage.type.apex'); | ||
export const UsingScope = (text: string) => | ||
createToken(text, 'keyword.operator.query.using.apex'); | ||
export const Where = createToken( | ||
@@ -397,2 +406,4 @@ 'WHERE', | ||
); | ||
export const QueryMethod = (text: string) => | ||
createToken(text, 'support.function.query.apex'); | ||
} | ||
@@ -456,2 +467,4 @@ | ||
createToken(text, 'constant.numeric.binary.apex'); | ||
export const DateTimeUTC = (text: string) => | ||
createToken(text, 'constant.numeric.datetime.apex'); | ||
export const Decimal = (text: string) => | ||
@@ -458,0 +471,0 @@ createToken(text, 'constant.numeric.decimal.apex'); |
@@ -11,3 +11,5 @@ /*--------------------------------------------------------------------------------------------- | ||
describe('Grammar', () => { | ||
before(() => { should(); }); | ||
before(() => { | ||
should(); | ||
}); | ||
@@ -14,0 +16,0 @@ describe('XML Doc Comments', () => { |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
488896
6315
1