List of usage examples for org.eclipse.jdt.core JavaModelException getException
public Throwable getException()
Throwable
that caused the failure. From source file:com.codenvy.ide.ext.java.server.internal.core.CompilationUnit.java
License:Open Source License
/** * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents() *//*from w w w. ja va2s . com*/ public char[] getContents() { IBuffer buffer = getBufferManager().getBuffer(this); if (buffer == null) { // no need to force opening of CU to get the content // also this cannot be a working copy, as its buffer is never closed while the working copy is alive File file = resource(); // Get encoding from file String encoding; encoding = "UTF-8"; //file.getCharset(); try { return Util.getResourceContentsAsCharArray(file, encoding); } catch (JavaModelException e) { if (manager.abortOnMissingSource.get() == Boolean.TRUE) { IOException ioException = e.getJavaModelStatus() .getCode() == IJavaModelStatusConstants.IO_EXCEPTION ? (IOException) e.getException() : new IOException(e.getMessage()); throw new AbortCompilationUnit(null, ioException, encoding); } else { Util.log(e, Messages.bind(Messages.file_notFound, file.getAbsolutePath())); } return CharOperation.NO_CHAR; } } char[] contents = buffer.getCharacters(); if (contents == null) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=129814 if (manager.abortOnMissingSource.get() == Boolean.TRUE) { IOException ioException = new IOException(Messages.buffer_closed); IFile file = (IFile) getResource(); // Get encoding from file String encoding; try { encoding = file.getCharset(); } catch (CoreException ce) { // do not use any encoding encoding = null; } throw new AbortCompilationUnit(null, ioException, encoding); } return CharOperation.NO_CHAR; } return contents; }
From source file:org.eclipse.jdt.internal.core.CompilationUnit.java
License:Open Source License
/** * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents() *//*from www. j a va 2 s.c o m*/ public char[] getContents() { IBuffer buffer = getBufferManager().getBuffer(this); if (buffer == null) { // no need to force opening of CU to get the content // also this cannot be a working copy, as its buffer is never closed while the working copy is alive IFile file = (IFile) getResource(); // Get encoding from file String encoding; try { encoding = file.getCharset(); } catch (CoreException ce) { // do not use any encoding encoding = null; } try { return Util.getResourceContentsAsCharArray(file, encoding); } catch (JavaModelException e) { if (JavaModelManager.getJavaModelManager().abortOnMissingSource.get() == Boolean.TRUE) { IOException ioException = e.getJavaModelStatus() .getCode() == IJavaModelStatusConstants.IO_EXCEPTION ? (IOException) e.getException() : new IOException(e.getMessage()); throw new AbortCompilationUnit(null, ioException, encoding); } else { Util.log(e, Messages.bind(Messages.file_notFound, file.getFullPath().toString())); } return CharOperation.NO_CHAR; } } char[] contents = buffer.getCharacters(); if (contents == null) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=129814 if (JavaModelManager.getJavaModelManager().abortOnMissingSource.get() == Boolean.TRUE) { IOException ioException = new IOException(Messages.buffer_closed); IFile file = (IFile) getResource(); // Get encoding from file String encoding; try { encoding = file.getCharset(); } catch (CoreException ce) { // do not use any encoding encoding = null; } throw new AbortCompilationUnit(null, ioException, encoding); } return CharOperation.NO_CHAR; } return contents; }
From source file:org.eclipse.modisco.java.discoverer.internal.io.library.binding.JavaModelDelegateBindingFactory.java
License:Open Source License
/** * Returns the MoDisco {@link Binding} corresponding to the Java entity * represented by the Java Model element. * //w w w . j av a2s . c o m * @param element * the Java Model element * @param visitor * the {@code ClassFileParser} * @return the MoDisco {@code Binding} */ public Binding getBindingForElement(final IJavaElement element, final ClassFileParser visitor) { Binding result = null; try { result = getBinding(element, visitor); } catch (JavaModelException e) { IStatus status = new Status(IStatus.WARNING, JavaActivator.PLUGIN_ID, e.getException().getMessage(), e); JavaActivator.getDefault().getLog().log(status); } if (result == null) { result = new UnresolvedBinding(element.getElementName()); } return result; }
From source file:org.eclipse.wazaabi.ide.ui.editparts.commands.jdt.InsertNewCompilationUnitCommand.java
License:Open Source License
@Override public void redo() { try {//from www . ja va 2 s.c o m compilationUnit = getPackageFRagment().createCompilationUnit(getCompilationUnitDescriptor().getName(), getCompilationUnitDescriptor().getContents(), true, new NullProgressMonitor()); makeSourceBeautiful(compilationUnit); } catch (JavaModelException e) { logger.error("Unable to create CompilationUnit {} {} {}", new Object[] { compilationUnitDescriptor.getName(), e.getException(), e.getCause() }); } }
From source file:org.eclipse.wazaabi.ide.ui.editparts.commands.jdt.InsertNewCompilationUnitCommand.java
License:Open Source License
@Override public void undo() { try {/*from www .j a v a 2 s . co m*/ if (compilationUnit.exists()) compilationUnit.delete(true, new NullProgressMonitor()); compilationUnit = null; } catch (JavaModelException e) { logger.error("Unable to destroy CompilationUnit {} {} {}", new Object[] { compilationUnitDescriptor.getName(), e.getException(), e.getCause() }); } }