Buggy code:
public abstract class Openable extends JavaElement implements IBufferChangedListener , IOpenable { protected Openable ( int type , IJavaElement parent , String name ) { } public void bufferChanged ( BufferChangedEvent event ) { } protected void buildStructure ( OpenableElementInfo info , IProblemRequestor problemRequestor , IProgressMonitor pm ) throws JavaModelException { } protected void closeBuffer ( OpenableElementInfo info ) { } protected void closing ( Object info ) throws JavaModelException { } protected void codeComplete ( ICompilationUnit cu , ICompilationUnit unitToSkip , int position , ICompletionRequestor requestor ) throws JavaModelException { if ( requestor == null ) { throw new IllegalArgumentException ( Util . bind ( "codeAssist.nullRequestor" ) ) ; } IBuffer buffer = getBuffer ( ) ; if ( buffer == null ) { return ; } if ( ( position < ( - 1 ) ) || ( position > ( buffer . getLength ( ) ) ) ) { throw new JavaModelException ( new JavaModelStatus ( IJavaModelStatusConstants . INDEX_OUT_OF_BOUNDS ) ) ; } SearchableEnvironment environment = ( ( SearchableEnvironment ) ( ( ( JavaProject ) ( getJavaProject ( ) ) ) . getSearchableNameEnvironment ( ) ) ) ; NameLookup nameLookup = ( ( JavaProject ) ( getJavaProject ( ) ) ) . getNameLookup ( ) ; environment . unitToSkip = unitToSkip ; CompletionEngine engine = new CompletionEngine ( environment , new CompletionRequestorWrapper ( requestor , nameLookup ) , JavaCore . getOptions ( ) ) ; <START_BUG> engine . complete ( cu , position ) ; <END_BUG> environment . unitToSkip = null ; } protected IJavaElement [ ] codeSelect ( ICompilationUnit cu , int offset , int length ) throws JavaModelException { } protected void codeSelect ( ICompilationUnit cu , int offset , int length , ISelectionRequestor requestor ) throws JavaModelException { } protected OpenableElementInfo createElementInfo ( ) { } protected abstract boolean generateInfos ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource , IProblemRequestor problemRequestor ) throws JavaModelException { } public IBuffer getBuffer ( ) throws JavaModelException { } protected BufferManager getBufferManager ( ) { } public IResource getCorrespondingResource ( ) throws JavaModelException { } public IPath getPath ( ) { } public IResource getUnderlyingResource ( ) throws JavaModelException { } public boolean exists ( ) { } protected boolean hasBuffer ( ) { } public boolean hasChildren ( ) throws JavaModelException { } public boolean hasUnsavedChanges ( ) throws JavaModelException { } public boolean isConsistent ( ) throws JavaModelException { } public boolean isOpen ( ) { } protected boolean isSourceElement ( ) { } public void makeConsistent ( IProgressMonitor pm ) throws JavaModelException { } public void makeConsistent ( IProblemRequestor problemRequestor , IProgressMonitor pm ) throws JavaModelException { } public void open ( IProgressMonitor pm ) throws JavaModelException { } protected void open ( IProgressMonitor pm , IBuffer buffer ) throws JavaModelException { } protected IBuffer openBuffer ( IProgressMonitor pm ) throws JavaModelException { } protected void openParent ( IProgressMonitor pm ) throws JavaModelException { } protected void openWhenClosed ( IProgressMonitor pm , IBuffer buffer ) throws JavaModelException { } protected boolean parentExists ( ) { } protected boolean resourceExists ( ) { } public void save ( IProgressMonitor pm , boolean force ) throws JavaModelException { } public PackageFragmentRoot getPackageFragmentRoot ( ) { } protected void codeComplete ( ICompilationUnit cu , ICompilationUnit unitToSkip , int position , final ICodeCompletionRequestor requestor ) throws JavaModelException { } }

Fix:
engine . complete ( cu , position , 0 ) ;