Bug 164311 - Code completion unavailable for static methods
Summary: Code completion unavailable for static methods
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.3 M4   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-13 07:53 EST by Lars Gråmark CLA
Modified: 2006-12-11 14:23 EST (History)
0 users

See Also:


Attachments
Proposed fix (3.31 KB, patch)
2006-11-16 12:51 EST, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Gråmark CLA 2006-11-13 07:53:54 EST
Code completion doesn't work as expected in some cases. In the class below, 
content assistance is unavailable for the AnyClass methods. I've placed the AnyClass as an inner static class to simplify but it might as well be created as a separate class.

Code completion however succeeds when I make any of the following changes:
1. When replacing the comparison operator ">" to a "<" in the if-statement.
2. Removing the paranthesis in the if-statement, ie changing "if (0 > (10))" to if "(0 > 10)"
3. or removing the LOOP_WHILE label.

public class Test
{
    public static class AnyClass
    {
        public static void callMe()
        {
            System.out.println("whatever");
        }
    }

    public void method1()
    {
        LOOP_WHILE:
        while (true)
        {
            if (0 > (10))
            {
                break LOOP_WHILE;
            }
        }
        AnyClass.callMe(); //code completion fails here
    }
}
Comment 1 David Audel CLA 2006-11-15 10:08:53 EST
An exception occurs during code completion

java.lang.ArrayIndexOutOfBoundsException: -1
	at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.buildMoreCompletionContext(CompletionParser.java:617)
	at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.attachOrphanCompletionNode(CompletionParser.java:446)
	at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.updateRecoveryState(CompletionParser.java:3869)
	at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError(Parser.java:10062)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:8902)
	at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:1314)
	at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:1167)
	at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:292)
	at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:255)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1930)
	at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:123)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:316)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:309)
Comment 2 David Audel CLA 2006-11-16 12:51:42 EST
Created attachment 54002 [details]
Proposed fix
Comment 3 David Audel CLA 2006-11-16 12:59:14 EST
Released for 3.3 M4.

Test added
  CompletionTests#testBug164311()

Thanks for the test case which is the simplest test case to reproduce the bug. The labeled control statement and the '>' followed by a '(' are necessary to reproduce it.
Comment 4 Olivier Thomann CLA 2006-12-11 14:23:34 EST
Verified for 3.3M4 with I20061211-1119