title: Eclipse Java content assist not working for files with lambda expressions
body: <p><strong>My question:</strong></p>
  
  <p>What can I do to prevent content assist from breaking when I write <s>larger</s> files that contain lambda expressions?</p>
  
  <p><strong>The issue (description):</strong></p>
  
  <p>For some time now, Eclipse's content assist for Java has stopped working properly for <s>larger</s> files in my IDE when I use lambda expressions. <s>I never encounter the issue when writing smaller files, but when I write files at 1500~2000+ lines of code it is like the content assist suddenly gives in and it becomes unstable.</s> When I activate content assist near the top of the file there are no issues:</p>
  
  <p><a href="https://i.stack.imgur.com/X1QKM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X1QKM.png" alt="content-assist working"></a></p>
  
  <p>In the above picture, content assist performs exactly as I expect it to. However, when I activate content assist closer to the bottom, it becomes unresponsive (does not activate when I type <code>.</code>) and activating it manually with <code>ctrl + space</code> brings up an empty list:</p>
  
  <p><a href="https://i.stack.imgur.com/cUOCI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cUOCI.png" alt="content-assist not working"></a></p>
  
  <p>For this particular file, content assist stops working in any part of the file after line 1540, which is right after a lambda expression. Removing the lambda expression does not solve the issue, but instead propagates it further down the file, to the next lambda expression.</p>
  
  <p>The following message is also displayed in the toolbar when this happens:</p>
  
  <p><a href="https://i.stack.imgur.com/lxa9s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lxa9s.png" alt="toolbar message"></a></p>
  
  <p><strong>Things I have tried:</strong></p>
  
  <ul>
  <li>Using a clean Eclipse IDE with the existing workspace as well as a new workspace.</li>
  <li>Clearing the index cache in <code>workspace/.metadata/.plugins/org.eclipse.jdt.core</code>.</li>
  <li>Enabling all proposal kinds in <code>Preferences &gt; Java &gt; Editor &gt; Content Assist &gt; Advanced</code>.</li>
  <li>Restoring defaults on the settings page just mentioned above.</li>
  <li>Increasing the amount of memory allocated to the Eclipse IDE in <code>eclipse.ini</code> to 2 gigabytes as well as increasing the amount of memory allocated initially to 1 gigabyte.</li>
  <li>Adding <code>-vmargs -Dorg.eclipse.jdt.ui.codeAssistTimeout=60000</code> to <code>eclipse.ini</code></li>
  </ul>
  
  <p><strong>Edit #1</strong></p>
  
  <p><s>As mentioned the issue only occurs for larger Java files. Below is a picture of a smaller Java file with 3 different lambda expressions and content assist works as expected:</s> See Edit #2</p>
  
  <p><strong>Edit #2</strong></p>
  
  <p>Below is a Java SCF to reproduce the issue. I've tried my best to make it as small as possible. In this case, the issue occurs when using a lambda expression in conjunction with a for-loop, but I imagine it might be possible to reproduce the issue with other control statements as well. </p>
  
  <pre><code>import java.util.ArrayList;
  public class Foo {
      public Foo() {
          foo(() -&gt; {
              final ArrayList&lt;Object&gt; list = new ArrayList&lt;&gt;();
              for (final Object o : list)
                  ;
              /* works until here */ } /* no longer working */
          );
      } // &lt;--- content assist works again after end bracket of constructor/method
      void foo(final Runnable r) { r.run(); }
  }
  </code></pre>
  
  <p>Notes:</p>
  
  <ul>
  <li>Enclosing the body of the for loop with curly brackets fixes the issue.</li>
  <li>The issue only occurs with the <code>for-each</code> variant of the for loop; using the <code>for(;;)</code> variant fixes the issue.</li>
  </ul>