Class QualifiedNameResolver

    • Constructor Detail

      • QualifiedNameResolver

        public QualifiedNameResolver()
    • Method Detail

      • initializeWith

        public void initializeWith​(java.lang.ClassLoader classLoader,
                                   ASTCompilationUnit rootNode)
        Initialises the visitor and starts it.
        Parameters:
        classLoader - The classloader that will be used by type qualified names to load their type.
        rootNode - The root hierarchy
      • visit

        public java.lang.Object visit​(ASTLambdaExpression node,
                                      java.lang.Object data)
        Populates the qualified name of a lambda expression. The qualified name of a lambda is made up:
        • Of the qualified name of the innermost enclosing type (considering anonymous classes too);
        • The operation string is composed of the following segments, separated with a dollar ($) symbol:
          • The lambda keyword;
          • A keyword identifying the scope the lambda was declared in. It can be:
            • new, if the lambda is declared in an instance initializer, or a constructor, or in the initializer of an instance field of an outer or nested class
            • static, if the lambda is declared in a static initializer, or in the initializer of a static field (including interface constants),
            • null, if the lambda is declared inside another lambda,
            • The innermost enclosing type's simple name, if the lambda is declared in the field initializer of a local class,
            • The innermost enclosing method's name, if the lambda is declared inside a method,
            • Nothing (empty string), if the lambda is declared in the initializer of the field of an anonymous class;
          • A numeric index, unique for each lambda declared within the same type declaration.

        The operation string of a lambda does not contain any formal parameters.

        This specification was worked out from stack traces. The precise order in which the numeric index is assigned does not conform to the way javac assigns them. Doing that could allow us to retrieve the Method instance associated with the lambda. TODO

        See this stackoverflow answer for more info about how lambdas are compiled.

        Specified by:
        visit in interface JavaParserVisitor
        Overrides:
        visit in class JavaParserVisitorReducedAdapter
        Parameters:
        node - Lambda expression node