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 , IProgressMonitor monitor ) 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 ) ) ; } JavaProject project = ( ( JavaProject ) ( getJavaProject ( ) ) ) ; SearchableEnvironment environment = ( ( SearchableEnvironment ) ( project . getSearchableNameEnvironment ( ) ) ) ; NameLookup nameLookup = project . getNameLookup ( ) ; environment . unitToSkip = unitToSkip ; <START_BUG> CompletionEngine engine = new CompletionEngine ( environment , new CompletionRequestorWrapper ( requestor , nameLookup ) , project . getOptions ( true ) ) ; <END_BUG> engine . complete ( cu , position , 0 ) ; 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 ) throws JavaModelException { } public IBuffer getBuffer ( ) throws JavaModelException { } public IBufferFactory getBufferFactory ( ) { } protected BufferManager getBufferManager ( ) { } public IResource getCorrespondingResource ( ) throws JavaModelException { } public IOpenable getOpenable ( ) { } 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 open ( IProgressMonitor pm ) throws JavaModelException { } protected IBuffer openBuffer ( IProgressMonitor pm ) throws JavaModelException { } protected void openParent ( IProgressMonitor pm ) throws JavaModelException { } protected void openWhenClosed ( IProgressMonitor pm ) 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:
CompletionEngine engine = new CompletionEngine ( environment , new CompletionRequestorWrapper ( requestor , nameLookup ) , project . getOptions ( true ) , project ) ;