nawforce / apex-parser Goto Github PK
View Code? Open in Web Editor NEWSalesforce Apex language parser for Java and Javascript.
Salesforce Apex language parser for Java and Javascript.
The triggerUnit rule doesn't match member declarations within trigger blocks, e.g.
octoberswimmer/apexfmt@05fc8db#diff-b125d91c8378dd671838e33503a02c7e3cfd725c429e2f2432099fb4b90bc5fe
I'm sure I'm doing this wrong, please educate me as needed.
The Lexing pass appears to incorrectly identify name
identifiers as the NAME
token type from the SOSL section. Not sure how to isolate those token to limit to certain sections. I have a test that demonstrates this but didn't have an obvious fix. I'm not great with ANTLR syntax.
Let me know if I'm not understand that token type correctly. I haven't tested similar tokens but expect they might have the same problem.
test("Name handling", () => {
const lexer = new ApexLexer(
new CaseInsensitiveInputStream("test.cls", "record.name")
);
const tokens = new CommonTokenStream(lexer);
expect(tokens.getNumberOfOnChannelTokens()).toBe(4);
const tList = tokens.getTokens();
expect(tList[0].type).toBe(ApexLexer.Identifier);
expect(tList[2].type).toBe(ApexLexer.Identifier);
});
Throws the error, 164 in this case is NAME
Expected: 230
Received: 164
42 | expect(tList[0].type).toBe(ApexLexer.Identifier);
43 | expect(tList[1].type).toBe(ApexLexer.DOT);
> 44 | expect(tList[2].type).toBe(ApexLexer.Identifier);
| ^
45 | });
ApexLexer.ts:
public static readonly NAME = 164;
public static readonly Identifier = 230;
An example of where I'm experiencing this in genuine code, accessing the name
of a LoggingLevel enum:
public Log setLogLevel(LoggingLevel level) {
this.level = level;
lw.logLevel = level.name();
return this;
}
Hi @nawforce
The ParseTreeWalker
seems to be failing from version 2.9.1, where dependencies were updated. I think this could potentially be an issue with the new pre-release of antlr4ts 0.5.0-alpha.4
, but wondering if you have any ideas on the cause and how to fix it.
Cannot read property 'enterRule' of undefined
Thanks
Hi,
Can we please update the tsconfig to output declarations (i.e. declarations = true)? This would be super helpful in ides (vscode for example).
Cheers,
N_DAYS_AGO:N
and similar date formulas are missing from the lexer and parser:
Failing to parse System.runAs() and testMethod modifier.
There are no issues with the test classes in the developer console.
Error 1
SyntaxException { line: 36, column: 24, message: "missing ';' at '{'" }
System.runAs(u) {
...
}
Error 2
SyntaxException {
line: 5,
column: 19,
message: "no viable alternative at input 'testMethod void'"
}
static testMethod void testParse() {
...
}
Hello, I try to run the tests, and boot in Java and JS, unfortunately, the code doesn't contain the ApexLexer class.
Can you please help me and update the readme?
We have Linux build actions for Java 8 & 11 but could do with a Windows build as well
There a few changes available on the internal adt parser that are not yet reflected here. To avoid drift we need to re-sync against the adt version.
I'd love to get some of your latest changes into the Maven artifact that's being used by the experimental PMD branch. (Some of them will be required for the tests to pass.) Hopefully there is an opportune time to cut a release in the not-too-distant future. Thanks in advance!
We discovered that the grammar fails to parse the following PMD test code. It fails on FIND 'Foo'
. (This is generated by ApexSharingViolationsNestedClassTest.java
.)
public with sharing class Outer {
public void outerSOQL() {
[FIND 'Foo' IN ALL FIELDS RETURNING Account(Name)];
}
public with sharing class Inner {
public void innerSOQL() {
// ...
}
}
}
The lexer rule:
FindLiteral
: '[' WS? 'find' WS '{' FindCharacters? '}'
;
surrounds find clause with curly braces, but Apex is different according to here:
The syntax of the FIND clause in Apex differs from the syntax of the FIND clause in SOAP API and REST API:
In the API, the value of the FIND clause is demarcated with braces. For example:
FIND {map*} IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead
In Apex, the value of the FIND clause is demarcated with single quotes. For example:
FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead
I haven't confirmed on the platform.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.