Skip to content

Commit

Permalink
refactor: soql keywords cleanup (#32)
Browse files Browse the repository at this point in the history
test: add page to view expected markup test code
test: add sample soql file
fix: remove unnecessary system interfaces
  • Loading branch information
dschach committed Nov 7, 2023
1 parent 4483ee6 commit c8e9b25
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 218 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
!dist/**/*
!package.json
!src/**/*
!test/**/*
!test/**/*
!assets/*
78 changes: 78 additions & 0 deletions demo/markupcheck.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!doctype html>
<html lang="en">
<head>
<title>Apex Markup Check</title>
<meta charset="UTF-8" />
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.js"></script>
<script charset="UTF-8" src="../dist/apex.min.js"></script>
<link rel="stylesheet" href="./testcode.css" />
<!-- <link rel="stylesheet" href="../src/styles/monokai-sublime-apex.css" /> -->
<link rel="stylesheet" href="vs.css" />
<script>
hljs.debugMode();
hljs.highlightAll();
</script>
<style>
pre code {
white-space: pre-wrap;
font-size: 120%;
}
</style>
</head>

<body>
<pre><code class="language-apex">
/**
* @author John Smith
*/
@IsTest(Seealldata=true)
public with sharing class L2Char implements Database.batchable {
public static final String ERROR = 0x0001;

@InvocableMethod(label='my invocable')
public static void moveTo(
Integer x,
Integer y,
Integer z
) {


Account a = new Account();
a.Custom__c = 'stringvalue';
insert a;
Boolean ai = (Boolean) false;
System.debug('Should not be called');
if (1 &gt; 5 && !Test.isRunningTest()) { // wtf!?
Database.insert(myAccounts, false);
}
}

@TestSetup
private static void makeData(Boolean a){
Custom__c c = new Custom__c();

for(Account a : acctLis ){
ConnectApi.insert a;
}
}

@isTest
private static void testme(){
System.assert(true);
}

@testVisible
private List&lt;SelectOption&gt; recordTypes { get; private set; }

for(Account a : [SELECT Id FROM Account WHERE LastModifiedDate = LAST_N_DAYS:3]){
Assert.fail();
}
}

trigger CTrig on Custom__c (before insert){
System.debug('inserting a record');
upsert myRecord__c;
}
</code></pre>
</body>
</html>
60 changes: 60 additions & 0 deletions demo/soqlsamples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[SELECT
Account.Name,
(SELECT FIELDS(ALL) FROM Account.Contacts LIMIT 200)
FROM Account]

[SELECT Id, FIELDS(ALL) FROM User LIMIT 200]
[SELECT
TYPEOF What
WHEN Account THEN Phone
ELSE Name
END
FROM Event
WHERE CreatedById IN
(
SELECT CreatedById
FROM Case
)]
[SELECT
TYPEOF What
WHEN Account THEN Id, LastModifiedDate
WHEN Opportunity THEN Id
END
FROM Task]
[SELECT
TYPEOF What
WHEN Account THEN Phone, NumberOfEmployees
WHEN Opportunity THEN Amount, CloseDate
ELSE Name, Email
END
FROM Event]
[SELECT Id, (SELECT Id from OpportunityLineItems)
FROM Opportunity
WHERE Id IN
(
SELECT OpportunityId
FROM OpportunityLineItem
WHERE totalPrice > 10000
)]
[SELECT Id FROM Account WHERE CreatedDate = NEXT_N_FISCAL_QUARTERS:6]
[SELECT Id FROM Opportunity WHERE CloseDate = N_WEEKS_AGO:3]
[SELECT Id FROM Account WHERE CreatedDate = YESTERDAY]
[SELECT Id, MSP1__c from CustObj__c WHERE MSP1__c includes ('AAA;BBB','CCC')]
[SELECT Id
FROM Case
WHERE Contact.LastName = null]
[SELECT Title FROM Question WHERE LastReplyDate > 2005-10-08T01:02:03Z WITH DATA CATEGORY Geography__c AT (usa__c, uk__c)]
[SELECT LeadSource, COUNT(Name) cnt
FROM Lead
GROUP BY ROLLUP(LeadSource)]
[SELECT LeadSource, COUNT(Name) cnt
FROM Lead
GROUP BY ROLLUP(LeadSource)]
[SELECT Name, MAX(Amount), MIN(Amount) min, SUM(Amount)
FROM Opportunity
GROUP BY Name]
[SELECT LeadSource, Rating,
GROUPING(LeadSource) grpLS, GROUPING(Rating) grpRating,
COUNT(Name) cnt
FROM Lead
GROUP BY ROLLUP(LeadSource, Rating)]
Loading

0 comments on commit c8e9b25

Please sign in to comment.