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

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

Introduction

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

Prototype

String build_missingSourceFile

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

Click Source Link

Usage

From source file:net.sf.j2s.core.builder.JavaBuilder.java

License:Open Source License

protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) throws CoreException {
    this.currentProject = getProject();
    if (this.currentProject == null || !this.currentProject.isAccessible())
        return new IProject[0];

    if (DEBUG)/*  w ww.j av  a2  s .c  o  m*/
        System.out.println("\nJavaBuilder: Starting build of " + this.currentProject.getName() //$NON-NLS-1$
                + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$
    this.notifier = new BuildNotifier(monitor, this.currentProject);
    this.notifier.begin();
    boolean ok = false;
    try {
        this.notifier.checkCancel();
        kind = initializeBuilder(kind, true);

        if (isWorthBuilding()) {
            if (kind == FULL_BUILD) {
                if (DEBUG)
                    System.out.println("JavaBuilder: Performing full build as requested"); //$NON-NLS-1$
                buildAll();
            } else {
                if ((this.lastState = getLastState(this.currentProject)) == null) {
                    if (DEBUG)
                        System.out.println(
                                "JavaBuilder: Performing full build since last saved state was not found"); //$NON-NLS-1$
                    buildAll();
                } else if (hasClasspathChanged()) {
                    // if the output location changes, do not delete the binary files from old location
                    // the user may be trying something
                    if (DEBUG)
                        System.out.println("JavaBuilder: Performing full build since classpath has changed"); //$NON-NLS-1$
                    buildAll();
                } else if (this.nameEnvironment.sourceLocations.length > 0) {
                    // if there is no source to compile & no classpath changes then we are done
                    SimpleLookupTable deltas = findDeltas();
                    if (deltas == null) {
                        if (DEBUG)
                            System.out.println(
                                    "JavaBuilder: Performing full build since deltas are missing after incremental request"); //$NON-NLS-1$
                        buildAll();
                    } else if (deltas.elementSize > 0) {
                        buildDeltas(deltas);
                    } else if (DEBUG) {
                        System.out.println("JavaBuilder: Nothing to build since deltas were empty"); //$NON-NLS-1$
                    }
                } else {
                    if (hasStructuralDelta()) { // double check that a jar file didn't get replaced in a binary project
                        if (DEBUG)
                            System.out.println(
                                    "JavaBuilder: Performing full build since there are structural deltas"); //$NON-NLS-1$
                        buildAll();
                    } else {
                        if (DEBUG)
                            System.out.println(
                                    "JavaBuilder: Nothing to build since there are no source folders and no deltas"); //$NON-NLS-1$
                        this.lastState.tagAsNoopBuild();
                    }
                }
            }
            ok = true;
        }
    } catch (CoreException e) {
        Util.log(e, "JavaBuilder handling CoreException while building: " + this.currentProject.getName()); //$NON-NLS-1$
        createInconsistentBuildMarker(e);
    } catch (ImageBuilderInternalException e) {
        Util.log(e.getThrowable(), "JavaBuilder handling ImageBuilderInternalException while building: " //$NON-NLS-1$
                + this.currentProject.getName());
        createInconsistentBuildMarker(e.coreException);
    } catch (MissingSourceFileException e) {
        // do not log this exception since its thrown to handle aborted compiles because of missing source files
        if (DEBUG)
            System.out.println(Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile));
        removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
        IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
        marker.setAttributes(new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IMarker.SOURCE_ID },
                new Object[] { Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile),
                        new Integer(IMarker.SEVERITY_ERROR), JavaBuilder.SOURCE_ID });
    } finally {
        for (int i = 0, l = this.participants == null ? 0 : this.participants.length; i < l; i++)
            this.participants[i].buildFinished(this.javaProject);
        if (!ok)
            // If the build failed, clear the previously built state, forcing a full build next time.
            clearLastState();
        this.notifier.done();
        cleanup();
    }
    IProject[] requiredProjects = getRequiredProjects(true);
    if (DEBUG)
        System.out.println("JavaBuilder: Finished build of " + this.currentProject.getName() //$NON-NLS-1$
                + " @ " + new Date(System.currentTimeMillis()) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
    return requiredProjects;
}