public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else { switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException((IJavaModelStatus) status); } } } /**
public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else { switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException((IJavaModelStatus) status); } } } /**
public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else { switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException((IJavaModelStatus) status); } } } /**
protected IStatus validateExistence(IResource underlyingResource) { // check whether the class file can be opened IStatus status = validateClassFile(); if (!status.isOK()) return status; if (underlyingResource != null) { if (!underlyingResource.isAccessible()) return newDoesNotExistStatus(); PackageFragmentRoot root; if ((underlyingResource instanceof IFolder) && (root = getPackageFragmentRoot()).isArchive()) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652 return root.newDoesNotExistStatus(); } } return JavaModelStatus.VERIFIED_OK; } public ISourceRange getNameRange() {
protected IStatus validateExistence(IResource underlyingResource) { // check whether the class file can be opened IStatus status = validateClassFile(); if (!status.isOK()) return status; if (underlyingResource != null) { if (!underlyingResource.isAccessible()) return newDoesNotExistStatus(); PackageFragmentRoot root; if ((underlyingResource instanceof IFolder) && (root = getPackageFragmentRoot()).isArchive()) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652 return root.newDoesNotExistStatus(); } } return JavaModelStatus.VERIFIED_OK; } public ISourceRange getNameRange() {
protected IStatus validateExistence(IResource underlyingResource) { // check whether the class file can be opened IStatus status = validateClassFile(); if (!status.isOK()) return status; if (underlyingResource != null) { if (!underlyingResource.isAccessible()) return newDoesNotExistStatus(); PackageFragmentRoot root; if ((underlyingResource instanceof IFolder) && (root = getPackageFragmentRoot()).isArchive()) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652 return root.newDoesNotExistStatus(); } } return JavaModelStatus.VERIFIED_OK; } public ISourceRange getNameRange() {
protected IStatus validateExistence(IResource underlyingResource) { // check whether the class file can be opened IStatus status = validateClassFile(); if (!status.isOK()) return status; if (underlyingResource != null) { if (!underlyingResource.isAccessible()) return newDoesNotExistStatus(); PackageFragmentRoot root; if ((underlyingResource instanceof IFolder) && (root = getPackageFragmentRoot()).isArchive()) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652 return root.newDoesNotExistStatus(); } } return JavaModelStatus.VERIFIED_OK; } public ISourceRange getNameRange() {
public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else { // .class file not on classpath, create a new buffer to be nice (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=41444) Object info = ((ClassFile) getClassFile()).getBinaryTypeInfo((IFile) resource()); IBuffer buffer = openBuffer(null, info); if (buffer != null && !(buffer instanceof NullBuffer)) return buffer; switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException((IJavaModelStatus) status); } } } /**