/** @see ICodeAssist#codeSelect(int, int, WorkingCopyOwner) */ public IJavaElement[] codeSelect(int offset, int length, WorkingCopyOwner owner) throws JavaModelException { IBuffer buffer = getBuffer(); char[] contents; if (buffer != null && (contents = buffer.getCharacters()) != null) { BinaryType type = (BinaryType) getType(); // GROOVY start /*old{ BasicCompilationUnit cu = new BasicCompilationUnit(contents, null, type.sourceFileName((IBinaryType) type.getElementInfo())); }new*/ // handle code select for Groovy files differently IBinaryType typeInfo = (IBinaryType) type.getElementInfo(); if (LanguageSupportFactory.isInterestingBinary(type, typeInfo)) { return LanguageSupportFactory.binaryCodeSelect(this, offset, length, owner); } BasicCompilationUnit cu = new BasicCompilationUnit(contents, null, type.sourceFileName(typeInfo)); // GROOVY end return super.codeSelect(cu, offset, length, owner); } else { // has no associated souce return new IJavaElement[] {}; } }
/* (non-Javadoc) * @see org.eclipse.jdt.core.ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor, org.eclipse.jdt.core.WorkingCopyOwner, org.eclipse.core.runtime.IProgressMonitor) */ public void codeComplete( int offset, CompletionRequestor requestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { String source = getSource(); if (source != null) { BinaryType type = (BinaryType) getType(); BasicCompilationUnit cu = new BasicCompilationUnit( getSource().toCharArray(), null, type.sourceFileName((IBinaryType) type.getElementInfo()), getJavaProject()); // use project to retrieve corresponding .java IFile codeComplete( cu, cu, offset, requestor, owner, null /*extended context isn't computed*/, monitor); } }