1

I encountered several specify java files when extracting the ASTs of the all java files of AspectJ. One example is as follows:

package aspects;

public aspect Logging {
    
    pointcut methods () :
        execution(* *..*(..)) && !within(Logging);
    
    before () : methods () {
        System.err.println("> " + thisJoinPoint.getSignature().toLongString());
    }
    
    after () : methods () {
        System.err.println("< " + thisJoinPoint.getSignature().toLongString());
    }
}

The file is "public aspect" and can not be parsed by JavaParser. How can I extract the AST of such files? Or is there any other tools I can use instead of JavaParser?

kriegaex
  • 63,017
  • 15
  • 111
  • 202
Vallxy
  • 13
  • 3
  • 1
    Native AspectJ syntax is a superset of Java. You forgot to explain your objective, though. An AST is not an end in itself. When you have it, what are you going to do with it? My answer shall depend on yours. From a byte code perspective, a compiled aspect is a Java class file, so if for example you want to use the AST in order to generate or transform byte code, maybe you want to start from there. For now, your question ins an instance of the [XY problem](https://meta.stackexchange.com/a/66378/309898), explaining **how** you want to do something without explaining **what** the goal is. – kriegaex Jun 06 '21 at 10:21

0 Answers0