GithubHelp home page GithubHelp logo

summit-ast's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

summit-ast's Issues

Failed to build AST

Expected Behavior

Unknown / shouldn't say "Found 0 Apex source files" nor "Failed to build AST for 0 files"

Actual Behavior

❯ bazel run :SummitTool './AccountController.cls'
INFO: Analyzed target //:SummitTool (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //src/main/java/com/google/summit:SummitTool up-to-date:
  bazel-bin/src/main/java/com/google/summit/SummitTool.jar
  bazel-bin/src/main/java/com/google/summit/SummitTool.jdeps
INFO: Elapsed time: 0.085s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/src/main/java/com/google/summit/SummitTool ./AccountController.cls
Feb 24, 2024 5:54:03 PM com.google.summit.SummitTool main
INFO: Summit AST Tool
Feb 24, 2024 5:54:03 PM com.google.summit.SummitTool main
INFO: Usage: SummitTool <Apex files or search directories>
Feb 24, 2024 5:54:03 PM com.google.summit.SummitTool main
INFO: Searching for Apex source at: ./AccountController.cls
Feb 24, 2024 5:54:03 PM com.google.summit.SummitTool main
WARNING: Invalid path ./AccountController.cls
java.nio.file.NoSuchFileException: ./AccountController.cls
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:149)
        at java.base/java.nio.file.Files.readAttributes(Files.java:1764)
        at java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
        at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
        at java.base/java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
        at java.base/java.nio.file.FileTreeIterator.<init>(FileTreeIterator.java:71)
        at java.base/java.nio.file.Files.find(Files.java:3942)
        at com.google.summit.SummitTool.main(SummitTool.kt:52)

Feb 24, 2024 5:54:03 PM com.google.summit.SummitTool main
INFO: Found 0 Apex source files
Feb 24, 2024 5:54:03 PM com.google.summit.SummitTool main
INFO: Failed to build AST for 0 files

Steps to Reproduce the Problem

  1. git clone https://github.com/google/summit-ast google/summit-ast
  2. cd google/summit-ast
  3. export JAVA_HOME="$(dirname $(dirname $(realpath $(which javac))))"
  4. Create file AccountController.cls in project using this content:
public class AccountController {
    public static Account getAccount() {
        return new Account();
    }
}
  1. Run bazel run :SummitTool './AccountController.cls' or bazel run :SummitTool 'AccountController.cls'

Specifications

  • Version: Latest commit, see 1f75111
  • Platform: Mac OS

Fail to parses SOSL with WITH USER_MODE or WITH SYSTEM_MODE

Expected Behavior

Correctly parse SOSL using USER_MODE

It does seem Salesforce SOSL documentation doesn't list this... https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_syntax.htm

Actual Behavior

Warning: PMD failed to evaluate against file 'C:\Users\xx\repos\xx\force-app\main\default\classes\class.cls'. Message: ParseException: Parse exception: com.google.summit.SummitAST$ParseException: Failed to parse C:\Users\xx\repos\xx\force-app\main\default\classes\xx.cls: Syntax error at 29:13: no viable alternative at input 'WITH USER_MODE'
Syntax error at 30:6: extraneous input ']' expecting ';'

Steps to Reproduce the Problem

  1. Attempt to parse the below class
public inherited sharing class soqlExample {

  public static String example(){
    String SecondarySearchList = 'test';

    List<List<SObject>> accountList = [
      FIND :SecondarySearchList
      IN NAME FIELDS
      RETURNING Account(Id, Account.Name WHERE ID = '' LIMIT 100)
      WITH USER_MODE
    ];
  }

}

Specifications

  • Version: 2.2.0
  • Platform: Linux / Windows -- Salesforce Code Analyser -> PMD -> Summit AST

Support bazel 6.0.0

The io_bazel_rules_kotlin plug-in fails with:

Error in repository_rule: invalid user-provided repo name '': valid names may contain only A-Z, a-z, 0-9, '-', '_', '.', and must start with a letter          

Unable to use SummitAST in Separate Application

Expected Behavior

I should be able to use Bazel to build an application which uses Summit-AST as a dependency and use the files internally within my custom application.

Actual Behavior

I encounter a runtime error when trying to call SummitAST.parseAndTranslate in a separate program.

Now, this could just be my lack of Kotlin knowledge showing, so I will keep trying to figure this one out, but I figured it best to at least create the issue to track my efforts here.

Is there a better or more canonical way to produce the AST for a .cls or .trigger file from a given file path?

Steps to Reproduce the Problem

.
├── BUILD
├── MODULE.bazel
├── MODULE.bazel.lock
├── WORKSPACE
└── src
    └── main
        └── java
            └── com
                └── app
                    ├── ASTParser.java
                    ├── BUILD
                    └── Runner.java

BUILD

java_binary(
    name = "astparser",
    runtime_deps = ["//src/main/java/com/app:apexparser-runner"],
    main_class = "com.app.Runner",
)

src/main/java/com/app/BUILD

java_library(
    name = "maven_deps",
    exports = [
        "@maven//:com_google_summit_summit_ast"
    ],
    visibility = ["//visibility:public"],
)

java_library(
    name = "apexparser-runner",
    srcs = [
        "ASTParser.java",
        "Runner.java",
    ],
    deps = [
        ":maven_deps",
    ],
    visibility = ["//visibility:public"],
)

Runner.java

public static void main(String[] args) {
  new ASTParser().parse(args[0]);
}

ASTParser.java

package com.app;

import java.nio.file.Paths;
import com.google.summit.SummitAST;
import com.google.summit.ast.CompilationUnit;

public class ASTParser {
    public void parse(String path) {
        CompilationUnit result = SummitAST.parseAndTranslate(Paths.get(path)); // this errors out
    }
}
bazel run :astparser foo/bar.cls

Error Message:

error: non-static method parseAndTranslate(Path) cannot be referenced from a static context
CompilationUnit result = SummitAST.parseAndTranslate(Paths.get(path));

Then if I update the code to instantiate an object

CompilationUnit result = new SummitAST().parseAndTranslate(Paths.get(path));

I get this:

error: SummitAST() has private access in SummitAST
CompilationUnit result = new SummitAST().parseAndTranslate(Paths.get(path));

Specifications

  • Version: Bazel v 7.0.0
  • Platform: Mac OS 13.3.1 (a)

Running SummitTool throws "%1 is not a valid Win32 application" error

Expected Behavior

Running bazel run :SummitTool './Lead_Utility.cls will output some basic information and provide an in-memory AST.

Actual Behavior

Running the command produces the following error:
FATAL: ExecuteProgram(C:\users\michael\_bazel_michael\k757sjdo\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\src\main\java\com\google\summit\SummitTool) failed: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\users\michael\_bazel_michael\k757sjdo\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\src\main\java\com\google\summit\SummitTool" C:\Users\Michael\Desktop\repos\summit-ast\Lead_Utility.cls): %1 is not a valid Win32 application. (error: 193)

Steps to Reproduce the Problem

  1. run git clone https://github.com/google/summit-ast.git
  2. run bazel build
  3. run bazel run :SummitTool './Lead_Utility.cls'

I've tried several variations for the path with forward/backward slashes, with/without single quotes, and the full path.

Specifications

  • OS: Windows 10 Home 10.0.19045 (64 bit)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.