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

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

Introduction

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

Prototype

String build_analyzingSources

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

Click Source Link

Usage

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

License:Open Source License

public void build() {
    if (JavaBuilder.DEBUG)
        System.out.println("FULL build"); //$NON-NLS-1$

    try {/*from  w w w  . j a v  a2 s  . co  m*/
        this.notifier.subTask(
                Messages.bind(Messages.build_cleaningOutput, this.javaBuilder.currentProject.getName()));
        JavaBuilder.removeProblemsAndTasksFor(this.javaBuilder.currentProject);
        cleanOutputFolders(true);
        this.notifier.updateProgressDelta(0.05f);

        this.notifier.subTask(Messages.build_analyzingSources);
        ArrayList sourceFiles = new ArrayList(33);
        addAllSourceFiles(sourceFiles);
        this.notifier.updateProgressDelta(0.10f);

        if (sourceFiles.size() > 0) {
            SourceFile[] allSourceFiles = new SourceFile[sourceFiles.size()];
            sourceFiles.toArray(allSourceFiles);

            this.notifier.setProgressPerCompilationUnit(0.75f / allSourceFiles.length);
            this.workQueue.addAll(allSourceFiles);
            compile(allSourceFiles);

            if (this.typeLocatorsWithUndefinedTypes != null)
                if (this.secondaryTypes != null && !this.secondaryTypes.isEmpty())
                    rebuildTypesAffectedBySecondaryTypes();
            if (this.incrementalBuilder != null)
                this.incrementalBuilder.buildAfterBatchBuild();
        }

        if (this.javaBuilder.javaProject.hasCycleMarker())
            this.javaBuilder.mustPropagateStructuralChanges();
    } catch (CoreException e) {
        throw internalException(e);
    } finally {
        if (JavaBuilder.SHOW_STATS)
            printStats();
        cleanUp();
    }
}

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

License:Open Source License

public boolean build(SimpleLookupTable deltas) {
    // initialize builder
    // walk this project's deltas, find changed source files
    // walk prereq projects' deltas, find changed class files & add affected source files
    //   use the build state # to skip the deltas for certain prereq projects
    //   ignore changed zip/jar files since they caused a full build
    // compile the source files & acceptResult()
    // compare the produced class files against the existing ones on disk
    // recompile all dependent source files of any type with structural changes or new/removed secondary type
    // keep a loop counter to abort & perform a full build

    if (JavaBuilder.DEBUG)
        System.out.println("INCREMENTAL build"); //$NON-NLS-1$

    try {//from ww  w.j a v a  2s. com
        resetCollections();

        this.notifier.subTask(Messages.build_analyzingDeltas);
        if (this.javaBuilder.hasBuildpathErrors()) {
            // if a mssing class file was detected in the last build, a build state was saved since its no longer fatal
            // but we need to rebuild every source file since problems were not recorded
            // AND to avoid the infinite build scenario if this project is involved in a cycle, see bug 160550
            // we need to avoid unnecessary deltas caused by doing a full build in this case
            if (JavaBuilder.DEBUG)
                System.out.println("COMPILING all source files since the buildpath has errors "); //$NON-NLS-1$
            this.javaBuilder.currentProject.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false,
                    IResource.DEPTH_ZERO);
            addAllSourceFiles(this.sourceFiles);
            this.notifier.updateProgressDelta(0.25f);
        } else {
            IResourceDelta sourceDelta = (IResourceDelta) deltas.get(this.javaBuilder.currentProject);
            if (sourceDelta != null)
                if (!findSourceFiles(sourceDelta))
                    return false;
            this.notifier.updateProgressDelta(0.10f);

            Object[] keyTable = deltas.keyTable;
            Object[] valueTable = deltas.valueTable;
            for (int i = 0, l = valueTable.length; i < l; i++) {
                IResourceDelta delta = (IResourceDelta) valueTable[i];
                if (delta != null) {
                    IProject p = (IProject) keyTable[i];
                    ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) this.javaBuilder.binaryLocationsPerProject
                            .get(p);
                    if (classFoldersAndJars != null)
                        if (!findAffectedSourceFiles(delta, classFoldersAndJars, p))
                            return false;
                }
            }
            this.notifier.updateProgressDelta(0.10f);

            this.notifier.subTask(Messages.build_analyzingSources);
            addAffectedSourceFiles();
            this.notifier.updateProgressDelta(0.05f);
        }

        this.compileLoop = 0;
        float increment = 0.40f;
        while (this.sourceFiles.size() > 0) { // added to in acceptResult
            if (++this.compileLoop > MaxCompileLoop) {
                if (JavaBuilder.DEBUG)
                    System.out.println("ABORTING incremental build... exceeded loop count"); //$NON-NLS-1$
                return false;
            }
            this.notifier.checkCancel();

            SourceFile[] allSourceFiles = new SourceFile[this.sourceFiles.size()];
            this.sourceFiles.toArray(allSourceFiles);
            resetCollections();

            this.workQueue.addAll(allSourceFiles);
            this.notifier.setProgressPerCompilationUnit(increment / allSourceFiles.length);
            increment = increment / 2;
            compile(allSourceFiles);
            removeSecondaryTypes();
            addAffectedSourceFiles();
        }
        if (this.hasStructuralChanges && this.javaBuilder.javaProject.hasCycleMarker())
            this.javaBuilder.mustPropagateStructuralChanges();
    } catch (AbortIncrementalBuildException e) {
        // abort the incremental build and let the batch builder handle the problem
        if (JavaBuilder.DEBUG)
            System.out.println("ABORTING incremental build... problem with " + e.qualifiedTypeName + //$NON-NLS-1$
                    ". Likely renamed inside its existing source file."); //$NON-NLS-1$
        return false;
    } catch (CoreException e) {
        throw internalException(e);
    } finally {
        cleanUp();
    }
    return true;
}

From source file:org.jboss.tools.arquillian.core.internal.compiler.ArquillianCompilationParticipant.java

License:Open Source License

@Override
public void buildFinished(IJavaProject project) {
    if (ArquillianCoreActivator.getDefault() == null) {
        return;// w ww.  j ava2  s .  c o  m
    }
    try {
        project.getProject().deleteMarkers(ArquillianConstants.MARKER_CLASS_ID, false,
                IResource.DEPTH_INFINITE);
        project.getProject().deleteMarkers(ArquillianConstants.MARKER_RESOURCE_ID, false,
                IResource.DEPTH_INFINITE);
    } catch (CoreException e) {
        ArquillianCoreActivator.log(e);
    }
    if (!ArquillianUtility.isValidatorEnabled(project.getProject())) {
        return;
    }
    try {
        IMarker[] markers = project.getProject().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        for (IMarker marker : markers) {
            Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
            if (severity != null && severity.intValue() == IMarker.SEVERITY_ERROR
                    && JavaBuilder.SOURCE_ID.equals(marker.getAttribute(IMarker.SOURCE_ID))) {
                return;
            }
        }
    } catch (CoreException e1) {
        // ignore
    }
    List<SourceFile> sourceFiles = new ArrayList(33);
    this.problemSourceFiles = new ArrayList(3);
    this.notifier = new BuildNotifier(new NullProgressMonitor(), project.getProject());
    this.notifier.begin();
    compiler = newCompiler(project);
    this.notifier.updateProgressDelta(0.05f);

    this.notifier.subTask(Messages.build_analyzingSources);
    sourceLocations = nameEnvironment.sourceLocations;
    try {
        addAllSourceFiles(sourceFiles, project);
    } catch (CoreException e) {
        ArquillianCoreActivator.log(e);
    }
    this.notifier.updateProgressDelta(0.10f);
    if (sourceFiles.size() <= 0) {
        return;
    }
    Iterator<SourceFile> iterator = sourceFiles.iterator();
    while (iterator.hasNext()) {
        SourceFile sourceFile = iterator.next();

        boolean remove = false;
        String preference = ArquillianUtility.getPreference(ArquillianConstants.MISSING_DEPLOYMENT_METHOD,
                project.getProject());

        if (!JavaCore.IGNORE.equals(preference)
                && !ArquillianSearchEngine.hasDeploymentMethod(sourceFile, project)) {
            try {
                Integer severity = ArquillianUtility.getSeverity(preference);
                storeProblem(sourceFile,
                        "Arquillian test requires at least one method annotated with @Deployment", severity);
            } catch (CoreException e) {
                ArquillianCoreActivator.log(e);
            }
            remove = true;
        }
        preference = ArquillianUtility.getPreference(ArquillianConstants.MISSING_TEST_METHOD,
                project.getProject());
        if (!JavaCore.IGNORE.equals(preference) && !ArquillianSearchEngine.hasTestMethod(sourceFile, project)) {
            try {
                Integer severity = ArquillianUtility.getSeverity(preference);
                storeProblem(sourceFile, "Arquillian test requires at least one method annotated with @Test",
                        severity);
            } catch (CoreException e) {
                ArquillianCoreActivator.log(e);
            }
            remove = true;
        }
        if (remove) {
            iterator.remove();
        }

    }
    for (SourceFile sourceFile : sourceFiles) {
        if (nameEnvironment.setEnvironment(sourceFile, project)) {
            compile(new SourceFile[] { sourceFile });
        }
    }

}