Example usage for org.eclipse.jdt.internal.core.util Messages file_notFound

List of usage examples for org.eclipse.jdt.internal.core.util Messages file_notFound

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Messages file_notFound.

Prototype

String file_notFound

To view the source code for org.eclipse.jdt.internal.core.util Messages file_notFound.

Click Source Link

Usage

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()
 *///  w  ww  .j  a  v  a  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
        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.che.jdt.internal.core.JavaModelManager.java

License:Open Source License

/**
 * Returns the open ZipFile at the given path. If the ZipFile
 * does not yet exist, it is created, opened, and added to the cache
 * of open ZipFiles.//from   w  w w . ja v a  2s  . com
 * <p/>
 * The path must be a file system path if representing an external
 * zip/jar, or it must be an absolute workspace relative path if
 * representing a zip/jar inside the workspace.
 *
 * @throws org.eclipse.core.runtime.CoreException
 *         If unable to create/open the ZipFile
 */
public ZipFile getZipFile(IPath path) throws CoreException {

    if (isInvalidArchive(path))
        throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException,
                new ZipException()));

    ZipCache zipCache;
    ZipFile zipFile;
    if ((zipCache = this.zipFiles.get()) != null && (zipFile = zipCache.getCache(path)) != null) {
        return zipFile;
    }
    File localFile = null;
    //        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    //        IResource file = root.findMember(path);
    //        if (file != null) {
    //            // internal resource
    //            URI location;
    //            if (file.getType() != IResource.FILE || (location = file.getLocationURI()) == null) {
    //                throw new CoreException(
    //                        new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.bind(Messages.file_notFound, path.toString()), null));
    //            }
    //            localFile = Util.toLocalFile(location, null*//*no progress availaible*//*);
    //            if (localFile == null)
    //                throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.bind(Messages.file_notFound,
    // path.toString()), null));
    //        } else {
    //            // external resource -> it is ok to use toFile()
    localFile = path.toFile();
    //        }
    if (!localFile.exists()) {
        throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1,
                Messages.bind(Messages.file_notFound, path.toString()), null));
    }

    try {
        if (ZIP_ACCESS_VERBOSE) {
            System.out.println("(" + Thread.currentThread()
                    + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + localFile); //$NON-NLS-1$ //$NON-NLS-2$
        }
        zipFile = new ZipFile(localFile);
        if (zipCache != null) {
            zipCache.setCache(path, zipFile);
        }
        return zipFile;
    } catch (IOException e) {
        addInvalidArchive(path);
        throw new CoreException(
                new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, e));
    }
}

From source file:org.eclipse.jdt.internal.core.CompilationUnit.java

License:Open Source License

/**
 * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents()
 *//* w ww. ja  v a  2s. co  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.jdt.internal.core.JavaModelManager.java

License:Open Source License

/**
 * Returns the open ZipFile at the given path. If the ZipFile
 * does not yet exist, it is created, opened, and added to the cache
 * of open ZipFiles.//from  w w w.  ja v a2  s . c o m
 *
 * The path must be a file system path if representing an external
 * zip/jar, or it must be an absolute workspace relative path if
 * representing a zip/jar inside the workspace.
 *
 * @exception CoreException If unable to create/open the ZipFile
 */
public ZipFile getZipFile(IPath path) throws CoreException {

    if (isInvalidArchive(path))
        throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException,
                new ZipException()));

    ZipCache zipCache;
    ZipFile zipFile;
    if ((zipCache = (ZipCache) this.zipFiles.get()) != null && (zipFile = zipCache.getCache(path)) != null) {
        return zipFile;
    }
    File localFile = null;
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IResource file = root.findMember(path);
    if (file != null) {
        // internal resource
        URI location;
        if (file.getType() != IResource.FILE || (location = file.getLocationURI()) == null) {
            throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1,
                    Messages.bind(Messages.file_notFound, path.toString()), null));
        }
        localFile = Util.toLocalFile(location, null/*no progress availaible*/);
        if (localFile == null)
            throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1,
                    Messages.bind(Messages.file_notFound, path.toString()), null));
    } else {
        // external resource -> it is ok to use toFile()
        localFile = path.toFile();
    }

    try {
        if (ZIP_ACCESS_VERBOSE) {
            System.out.println("(" + Thread.currentThread() //$NON-NLS-1$
                    + ") [JavaModelManager.getZipFile(IPath)] Creating ZipFile on " + localFile); //$NON-NLS-1$
        }
        zipFile = new ZipFile(localFile);
        if (zipCache != null) {
            zipCache.setCache(path, zipFile);
        }
        return zipFile;
    } catch (IOException e) {
        addInvalidArchive(path);
        throw new CoreException(
                new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, e));
    }
}

From source file:org.jboss.tools.maven.conversion.ui.dialog.xpl.ConversionUtils.java

License:Open Source License

public static File getFile(IPath path) throws CoreException {
    Assert.isNotNull(path, "path can not be null");
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IResource file = root.findMember(path);
    File localFile = null;/*ww  w.j  a v a 2 s  .c  o m*/
    if (file != null) {
        // internal resource
        URI location;
        if (file.getType() != IResource.FILE || (location = file.getLocationURI()) == null) {
            throw new CoreException(new Status(IStatus.ERROR, MavenDependencyConversionActivator.PLUGIN_ID, -1,
                    Messages.bind(Messages.file_notFound, path.toString()), null));
        }
        localFile = Util.toLocalFile(location, null/*no progress availaible*/);
        if (localFile == null)
            throw new CoreException(new Status(IStatus.ERROR, MavenDependencyConversionActivator.PLUGIN_ID, -1,
                    Messages.bind(Messages.file_notFound, path.toString()), null));
    } else {
        // external resource -> it is ok to use toFile()
        localFile = path.toFile();
    }
    return localFile;
}