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

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

Introduction

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

Prototype

String build_saveStateComplete

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

Click Source Link

Usage

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

License:Open Source License

/**
 * Saves the built state for the project.
 *//*ww w. j  a v a 2 s .  c  om*/
private void saveBuiltState(PerProjectInfo info) throws CoreException {
    if (JavaBuilder.DEBUG)
        System.out.println(Messages.bind(Messages.build_saveStateProgress, info.project.getName()));
    File file = getSerializationFile(info.project);
    if (file == null)
        return;
    long t = System.currentTimeMillis();
    try {
        DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
        try {
            out.writeUTF(JavaCore.PLUGIN_ID);
            out.writeUTF("STATE"); //$NON-NLS-1$
            if (info.savedState == null) {
                out.writeBoolean(false);
            } else {
                out.writeBoolean(true);
                JavaBuilder.writeState(info.savedState, out);
            }
        } finally {
            out.close();
        }
    } catch (RuntimeException e) {
        try {
            file.delete();
        } catch (SecurityException se) {
            // could not delete file: cannot do much more
        }
        throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
                Messages.bind(Messages.build_cannotSaveState, info.project.getName()), e));
    } catch (IOException e) {
        try {
            file.delete();
        } catch (SecurityException se) {
            // could not delete file: cannot do much more
        }
        throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
                Messages.bind(Messages.build_cannotSaveState, info.project.getName()), e));
    }
    if (JavaBuilder.DEBUG) {
        t = System.currentTimeMillis() - t;
        System.out.println(Messages.bind(Messages.build_saveStateComplete, String.valueOf(t)));
    }
}