title: Eclipse Jdt type bindings not resolved in lambda expressions
body: <p>I am running into a similar issue from <a href="https://stackoverflow.com/questions/39452906/eclipse-jdt-ast-parser-does-not-resolve-type-in-java-lambda-expression">here</a> where type bindings within lambda expressions are not being resolved properly for <code>MethodInvocation</code> types.</p>
  
  <p>Currently using version '3.13.50' and tried with '3.13.100' which is what Eclipse 4.7.3 seems to use.  Happy to try any debugging; currently stumped because other type bindings resolve correctly (for <code>ImportDeclaration</code> statements and for expressions not enclosed in lambda expressions).</p>
  
  <hr>
  
  <p>Parser setup code (<code>parserClasspath</code> contains paths to root of all third party library classes (including domain objects whose type bindings need to be resolved), <code>parserSourcepath</code> contains the root of the project source files):</p>
  
  <pre><code>    char[] sourceInput = source.get().toCharArray();
  
      ASTParser parser = ASTParser.newParser(AST.JLS9);
      parser.setEnvironment(parserClasspath, parserSourcepath, null, false);
      parser.setResolveBindings(true);
      parser.setBindingsRecovery(true);
      parser.setSource(sourceInput);
      parser.setUnitName(projFilepath);
  
      return parser.createAST(null);
  </code></pre>
  
  <p>Parser transformer snippet (using ASTVisitor):</p>
  
  <pre><code>@Override
  public boolean visit(MethodInvocation mi) {
      if (mi.getExpression() != null) {
  
          // resolves to null when 'mi' is within lambda functions
          ITypeBinding typeBinding = mi.getExpression().resolveTypeBinding();
  
          if (typeBinding != null) {
              // do stuff
          }
      }
      return true;
  }
  </code></pre>
  
  <p>Example to parse:</p>
  
  <pre><code>private DomainType getMockDomainType() {
      DomainType mock = mock(DomainType.class);
      Supplier&lt;DomainType&gt; domainTypeSupplier = () -&gt; {
          DomainType domainType = mock(DomainType.class);
          when(domainType.method()).thenReturn("VALUE");
          ...
          return domainType;
      };
  
      DomainType domainType = domainTypeSupplier.get();
  
      when(mock.method()).thenReturn(domainType)
      ...
      return mock;
  }
  </code></pre>
  
  <p>Expected output (<code>method()</code> will be transformed to <code>NEW_METHOD()</code>):</p>
  
  <pre><code>private DomainType getMockDomainType() {
      DomainType mock = mock(DomainType.class);
      Supplier&lt;DomainType&gt; domainTypeSupplier = () -&gt; {
          DomainType domainType = mock(DomainType.class);
          when(domainType.NEW_METHOD()).thenReturn("VALUE");
          ...
          return domainType;
      };
  
      DomainType domainType = domainTypeSupplier.get();
  
      when(mock.NEW_METHOD()).thenReturn(domainType)
      ...
      return mock;
  }
  </code></pre>
  
  <p>Actual output:</p>
  
  <pre><code>private DomainType getMockDomainType() {
      DomainType mock = mock(DomainType.class);
      Supplier&lt;DomainType&gt; domainTypeSupplier = () -&gt; {
          DomainType domainType = mock(DomainType.class);
          when(domainType.method()).thenReturn("VALUE");
          ...
          return domainType;
      };
  
      DomainType domainType = domainTypeSupplier.get();
  
      when(mock.NEW_METHOD()).thenReturn(domainType)
      ...
      return mock;
  }
  </code></pre>
  
  <p>In the <code>visit(MethodDeclaration mi)</code> method within the lambda expression for <code>domainType.method()</code>, <code>mi.getExpression().resolveTypeBinding()</code> is <code>null</code> when it should be a binding for <code>DomainType</code>.</p>