Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder')
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbortIncrementalBuildException.java26
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbstractImageBuilder.java664
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AdditionalTypeCollection.java22
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BatchImageBuilder.java137
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BuildNotifier.java278
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathDirectory.java127
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLibrary.java138
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLocation.java56
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathMultiDirectory.java61
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ICompilationUnitLocator.java25
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ImageBuilderInternalException.java52
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/IncrementalImageBuilder.java787
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/JavaBuilder.java778
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/MissingSourceFileException.java24
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameEnvironment.java484
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameSet.java66
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ProblemFactory.java32
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/QualifiedNameSet.java69
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ReferenceCollection.java244
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/SourceFile.java132
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/State.java728
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/StringSet.java81
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ValidationParticipantResult.java44
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/WorkQueue.java55
24 files changed, 0 insertions, 5110 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbortIncrementalBuildException.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbortIncrementalBuildException.java
deleted file mode 100644
index 0a9481ae..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbortIncrementalBuildException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-/**
- * Exception thrown when an incremental builder cannot find a .class file.
- * Its possible the type can no longer be found because it was renamed inside its existing
- * source file.
- */
-public class AbortIncrementalBuildException extends RuntimeException {
-
-protected String qualifiedTypeName;
-private static final long serialVersionUID = -8874662133883858502L; // backward compatible
-
-public AbortIncrementalBuildException(String qualifiedTypeName) {
- this.qualifiedTypeName = qualifiedTypeName;
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbstractImageBuilder.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbstractImageBuilder.java
deleted file mode 100644
index b9533c56..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AbstractImageBuilder.java
+++ /dev/null
@@ -1,664 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Map;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.jsdt.core.IJavaScriptModelMarker;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.compiler.BuildContext;
-import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.internal.compiler.CompilationResult;
-import org.eclipse.wst.jsdt.internal.compiler.Compiler;
-import org.eclipse.wst.jsdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.wst.jsdt.internal.compiler.ICompilerRequestor;
-import org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.wst.jsdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleSet;
-import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
-import org.eclipse.wst.jsdt.internal.core.util.Messages;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-/**
- * The abstract superclass of Java builders.
- * Provides the building and compilation mechanism
- * in common with the batch and incremental builders.
- */
-public abstract class AbstractImageBuilder implements ICompilerRequestor, ICompilationUnitLocator {
-
-protected JavaBuilder javaBuilder;
-protected State newState;
-
-// local copies
-protected NameEnvironment nameEnvironment;
-protected ClasspathMultiDirectory[] sourceLocations;
-protected BuildNotifier notifier;
-
-protected Compiler compiler;
-protected WorkQueue workQueue;
-protected ArrayList problemSourceFiles;
-protected boolean compiledAllAtOnce;
-
-private boolean inCompiler;
-protected boolean keepStoringProblemMarkers;
-
-public static int MAX_AT_ONCE = 2000; // best compromise between space used and speed
-public final static String[] JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES = {
- IMarker.MESSAGE,
- IMarker.SEVERITY,
- IJavaScriptModelMarker.ID,
- IMarker.CHAR_START,
- IMarker.CHAR_END,
- IMarker.LINE_NUMBER,
- IJavaScriptModelMarker.ARGUMENTS,
- IJavaScriptModelMarker.CATEGORY_ID,
-};
-public final static String[] JAVA_TASK_MARKER_ATTRIBUTE_NAMES = {
- IMarker.MESSAGE,
- IMarker.PRIORITY,
- IJavaScriptModelMarker.ID,
- IMarker.CHAR_START,
- IMarker.CHAR_END,
- IMarker.LINE_NUMBER,
- IMarker.USER_EDITABLE,
- IMarker.SOURCE_ID,
-};
-public final static Integer S_ERROR = new Integer(IMarker.SEVERITY_ERROR);
-public final static Integer S_WARNING = new Integer(IMarker.SEVERITY_WARNING);
-public final static Integer P_HIGH = new Integer(IMarker.PRIORITY_HIGH);
-public final static Integer P_NORMAL = new Integer(IMarker.PRIORITY_NORMAL);
-public final static Integer P_LOW = new Integer(IMarker.PRIORITY_LOW);
-
-protected AbstractImageBuilder(JavaBuilder javaBuilder, boolean buildStarting, State newState) {
- // local copies
- this.javaBuilder = javaBuilder;
- this.nameEnvironment = javaBuilder.nameEnvironment;
- this.sourceLocations = this.nameEnvironment.sourceLocations;
- this.notifier = javaBuilder.notifier;
- this.keepStoringProblemMarkers = true; // may get disabled when missing classfiles are encountered
-
- if (buildStarting) {
- this.newState = newState == null ? new State(javaBuilder) : newState;
- this.compiler = newCompiler();
- this.workQueue = new WorkQueue();
- this.problemSourceFiles = new ArrayList(3);
- }
-}
-
-public void acceptResult(CompilationResult result) {
- // In Batch mode, we write out the class files, hold onto the dependency info
- // & additional types and report problems.
-
- // In Incremental mode, when writing out a class file we need to compare it
- // against the previous file, remembering if structural changes occured.
- // Before reporting the new problems, we need to update the problem count &
- // remove the old problems. Plus delete additional class files that no longer exist.
-
- SourceFile compilationUnit = (SourceFile) result.getCompilationUnit(); // go directly back to the sourceFile
- if (!workQueue.isCompiled(compilationUnit)) {
- workQueue.finished(compilationUnit);
-
- try {
- updateProblemsFor(compilationUnit, result); // record compilation problems before potentially adding duplicate errors
- updateTasksFor(compilationUnit, result); // record tasks
- } catch (CoreException e) {
- throw internalException(e);
- }
-
- if (result.hasInconsistentToplevelHierarchies)
- // ensure that this file is always retrieved from source for the rest of the build
- if (!problemSourceFiles.contains(compilationUnit))
- problemSourceFiles.add(compilationUnit);
-
- String typeLocator = compilationUnit.typeLocator();
-
- finishedWith(typeLocator, result, compilationUnit.getMainTypeName(), new ArrayList(), new ArrayList());
- notifier.compiled(compilationUnit);
- }
-}
-
-
-protected void addAllSourceFiles(final ArrayList sourceFiles) throws CoreException {
- for (int i = 0, l = sourceLocations.length; i < l; i++) {
- final ClasspathMultiDirectory sourceLocation = sourceLocations[i];
- final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
- final char[][] inclusionPatterns = sourceLocation.inclusionPatterns;
- final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject);
- final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
- final IContainer outputFolder = sourceLocation.binaryFolder;
- final boolean isOutputFolder = sourceLocation.sourceFolder.equals(outputFolder);
- sourceLocation.sourceFolder.accept(
- new IResourceProxyVisitor() {
- public boolean visit(IResourceProxy proxy) throws CoreException {
- switch(proxy.getType()) {
- case IResource.FILE :
- if (org.eclipse.wst.jsdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
- IResource resource = proxy.requestResource();
- if (exclusionPatterns != null || inclusionPatterns != null)
- if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false))
- return false;
- sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
- }
- return false;
- case IResource.FOLDER :
- IPath folderPath = null;
- if (isAlsoProject)
- if (isExcludedFromProject(folderPath = proxy.requestFullPath()))
- return false;
- if (JavaScriptCore.isReadOnly(proxy.requestResource()))
- return false;
- if (exclusionPatterns != null) {
- if (folderPath == null)
- folderPath = proxy.requestFullPath();
- if (Util.isExcluded(folderPath, inclusionPatterns, exclusionPatterns, true)) {
- // must walk children if inclusionPatterns != null, can skip them if == null
- // but folder is excluded so do not create it in the output folder
- return inclusionPatterns != null;
- }
- }
- }
- return true;
- }
- },
- IResource.NONE
- );
- notifier.checkCancel();
- }
-}
-
-protected void cleanUp() {
- this.nameEnvironment.cleanup();
-
- this.javaBuilder = null;
- this.nameEnvironment = null;
- this.sourceLocations = null;
- this.notifier = null;
- this.compiler = null;
- this.workQueue = null;
- this.problemSourceFiles = null;
-}
-
-/* Compile the given elements, adding more elements to the work queue
-* if they are affected by the changes.
-*/
-protected void compile(SourceFile[] units) {
- // notify validationParticipants which source files are about to be compiled
- BuildContext[] participantResults = this.javaBuilder.participants == null ? null : notifyParticipants(units);
- if (participantResults != null && participantResults.length > units.length) {
- units = new SourceFile[participantResults.length];
- for (int i = participantResults.length; --i >= 0;)
- units[i] = participantResults[i].sourceFile;
- }
-
- int unitsLength = units.length;
- this.compiledAllAtOnce = unitsLength <= MAX_AT_ONCE;
- if (this.compiledAllAtOnce) {
- // do them all now
- if (JavaBuilder.DEBUG)
- for (int i = 0; i < unitsLength; i++)
- System.out.println("About to compile " + units[i].typeLocator()); //$NON-NLS-1$
- compile(units, null, true);
- } else {
- SourceFile[] remainingUnits = new SourceFile[unitsLength]; // copy of units, removing units when about to compile
- System.arraycopy(units, 0, remainingUnits, 0, unitsLength);
- int doNow = unitsLength < MAX_AT_ONCE ? unitsLength : MAX_AT_ONCE;
- SourceFile[] toCompile = new SourceFile[doNow];
- int remainingIndex = 0;
- boolean compilingFirstGroup = true;
- while (remainingIndex < unitsLength) {
- int count = 0;
- while (remainingIndex < unitsLength && count < doNow) {
- // Although it needed compiling when this method was called, it may have
- // already been compiled when it was referenced by another unit.
- SourceFile unit = remainingUnits[remainingIndex];
- if (unit != null && (compilingFirstGroup || this.workQueue.isWaiting(unit))) {
- if (JavaBuilder.DEBUG)
- System.out.println("About to compile #" + remainingIndex + " : "+ unit.typeLocator()); //$NON-NLS-1$ //$NON-NLS-2$
- toCompile[count++] = unit;
- }
- remainingUnits[remainingIndex++] = null;
- }
- if (count < doNow)
- System.arraycopy(toCompile, 0, toCompile = new SourceFile[count], 0, count);
- if (!compilingFirstGroup)
- for (int a = remainingIndex; a < unitsLength; a++)
- if (remainingUnits[a] != null && this.workQueue.isCompiled(remainingUnits[a]))
- remainingUnits[a] = null; // use the class file for this source file since its been compiled
- compile(toCompile, remainingUnits, compilingFirstGroup);
- compilingFirstGroup = false;
- }
- }
-
- if (participantResults != null) {
- for (int i = participantResults.length; --i >= 0;)
- if (participantResults[i] != null)
- recordParticipantResult(participantResults[i]);
- }
-}
-
-protected void compile(SourceFile[] units, SourceFile[] additionalUnits, boolean compilingFirstGroup) {
- if (units.length == 0) return;
- notifier.aboutToCompile(units[0]); // just to change the message
-
- // extend additionalFilenames with all hierarchical problem types found during this entire build
- if (!problemSourceFiles.isEmpty()) {
- int toAdd = problemSourceFiles.size();
- int length = additionalUnits == null ? 0 : additionalUnits.length;
- if (length == 0)
- additionalUnits = new SourceFile[toAdd];
- else
- System.arraycopy(additionalUnits, 0, additionalUnits = new SourceFile[length + toAdd], 0, length);
- for (int i = 0; i < toAdd; i++)
- additionalUnits[length + i] = (SourceFile) problemSourceFiles.get(i);
- }
-// String[] initialTypeNames = new String[units.length];
-// for (int i = 0, l = units.length; i < l; i++)
-// initialTypeNames[i] = units[i].initialTypeName;
-// nameEnvironment.setNames(initialTypeNames, additionalUnits);
- notifier.checkCancel();
- try {
- inCompiler = true;
- compiler.compile(units);
- } catch (AbortCompilation ignored) {
- // ignore the AbortCompilcation coming from BuildNotifier.checkCancelWithinCompiler()
- // the Compiler failed after the user has chose to cancel... likely due to an OutOfMemory error
- } finally {
- inCompiler = false;
- }
- // Check for cancel immediately after a compile, because the compiler may
- // have been cancelled but without propagating the correct exception
- notifier.checkCancel();
-}
-
-protected void createProblemFor(IResource resource, IMember javaElement, String message, String problemSeverity) {
- try {
- IMarker marker = resource.createMarker(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER);
- int severity = problemSeverity.equals(JavaScriptCore.WARNING) ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR;
-
- ISourceRange range = javaElement == null ? null : javaElement.getNameRange();
- int start = range == null ? 0 : range.getOffset();
- int end = range == null ? 1 : start + range.getLength();
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.CHAR_START, IMarker.CHAR_END, IMarker.SOURCE_ID},
- new Object[] {message, new Integer(severity), new Integer(start), new Integer(end), JavaBuilder.SOURCE_ID});
- } catch (CoreException e) {
- throw internalException(e);
- }
-}
-
-protected void deleteGeneratedFiles(IFile[] deletedGeneratedFiles) {
- // no op by default
-}
-
-protected SourceFile findSourceFile(IFile file, boolean mustExist) {
- if (mustExist && !file.exists()) return null;
-
- // assumes the file exists in at least one of the source folders & is not excluded
- ClasspathMultiDirectory md = sourceLocations[0];
- if (sourceLocations.length > 1) {
- IPath sourceFileFullPath = file.getFullPath();
- for (int j = 0, m = sourceLocations.length; j < m; j++) {
- if (sourceLocations[j].sourceFolder.getFullPath().isPrefixOf(sourceFileFullPath)) {
- md = sourceLocations[j];
- if (md.exclusionPatterns == null && md.inclusionPatterns == null)
- break;
- if (!Util.isExcluded(file, md.inclusionPatterns, md.exclusionPatterns))
- break;
- }
- }
- }
- return new SourceFile(file, md);
-}
-
-protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames, ArrayList duplicateTypeNames) {
- if (duplicateTypeNames == null) {
- newState.record(sourceLocator, result.qualifiedReferences, result.simpleNameReferences, mainTypeName, definedTypeNames);
- return;
- }
-
- char[][][] qualifiedRefs = result.qualifiedReferences;
- char[][] simpleRefs = result.simpleNameReferences;
- // for each duplicate type p1.p2.A, add the type name A (package was already added)
- next : for (int i = 0, l = duplicateTypeNames.size(); i < l; i++) {
- char[][] compoundName = (char[][]) duplicateTypeNames.get(i);
- char[] typeName = compoundName[compoundName.length - 1];
- int sLength = simpleRefs.length;
- for (int j = 0; j < sLength; j++)
- if (CharOperation.equals(simpleRefs[j], typeName))
- continue next;
- System.arraycopy(simpleRefs, 0, simpleRefs = new char[sLength + 1][], 0, sLength);
- simpleRefs[sLength] = typeName;
- }
- newState.record(sourceLocator, qualifiedRefs, simpleRefs, mainTypeName, definedTypeNames);
-}
-
-
-
-
-
-/* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.core.builder.ICompilationUnitLocator#fromIFile(org.eclipse.core.resources.IFile)
- */
-public ICompilationUnit fromIFile(IFile file) {
- return findSourceFile(file, true);
-}
-
-protected RuntimeException internalException(CoreException t) {
- ImageBuilderInternalException imageBuilderException = new ImageBuilderInternalException(t);
- if (inCompiler)
- return new AbortCompilation(true, imageBuilderException);
- return imageBuilderException;
-}
-
-protected boolean isExcludedFromProject(IPath childPath) throws JavaScriptModelException {
- // answer whether the folder should be ignored when walking the project as a source folder
- if (childPath.segmentCount() > 2) return false; // is a subfolder of a package
-
- for (int j = 0, k = sourceLocations.length; j < k; j++) {
- if (childPath.equals(sourceLocations[j].binaryFolder.getFullPath())) return true;
- if (childPath.equals(sourceLocations[j].sourceFolder.getFullPath())) return true;
- }
- // skip default output folder which may not be used by any source folder
- return childPath.equals(javaBuilder.javaProject.getOutputLocation());
-}
-
-protected Compiler newCompiler() {
- // disable entire javadoc support if not interested in diagnostics
- Map projectOptions = javaBuilder.javaProject.getOptions(true);
- String option = (String) projectOptions.get(JavaScriptCore.COMPILER_PB_INVALID_JAVADOC);
- if (option == null || option.equals(JavaScriptCore.IGNORE)) { // TODO (frederic) see why option is null sometimes while running model tests!?
- option = (String) projectOptions.get(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_TAGS);
- if (option == null || option.equals(JavaScriptCore.IGNORE)) {
- option = (String) projectOptions.get(JavaScriptCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS);
- if (option == null || option.equals(JavaScriptCore.IGNORE)) {
- option = (String) projectOptions.get(JavaScriptCore.COMPILER_PB_UNUSED_IMPORT);
- if (option == null || option.equals(JavaScriptCore.IGNORE)) { // Unused import need also to look inside javadoc comment
- projectOptions.put(JavaScriptCore.COMPILER_DOC_COMMENT_SUPPORT, JavaScriptCore.DISABLED);
- }
- }
- }
- }
-
- // called once when the builder is initialized... can override if needed
- CompilerOptions compilerOptions = new CompilerOptions(projectOptions);
- compilerOptions.performMethodsFullRecovery = true;
- compilerOptions.performStatementsRecovery = true;
- Compiler newCompiler = new Compiler(
- nameEnvironment,
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- compilerOptions,
- this,
- ProblemFactory.getProblemFactory(Locale.getDefault()));
- CompilerOptions options = newCompiler.options;
-
- // enable the compiler reference info support
- options.produceReferenceInfo = true;
-
- return newCompiler;
-}
-
-protected BuildContext[] notifyParticipants(SourceFile[] unitsAboutToCompile) {
- BuildContext[] results = new BuildContext[unitsAboutToCompile.length];
- for (int i = unitsAboutToCompile.length; --i >= 0;)
- results[i] = new BuildContext(unitsAboutToCompile[i]);
-
- // TODO (kent) do we expect to have more than one participant?
- // and if so should we pass the generated files from the each processor to the others to process?
- // and what happens if some participants do not expect to be called with only a few files, after seeing 'all' the files?
- for (int i = 0, l = this.javaBuilder.participants.length; i < l; i++)
- this.javaBuilder.participants[i].buildStarting(results, this instanceof BatchImageBuilder);
-
- SimpleSet uniqueFiles = null;
- ValidationParticipantResult[] toAdd = null;
- int added = 0;
- for (int i = results.length; --i >= 0;) {
- ValidationParticipantResult result = results[i];
- if (result == null) continue;
-
- IFile[] deletedGeneratedFiles = result.deletedFiles;
- if (deletedGeneratedFiles != null)
- deleteGeneratedFiles(deletedGeneratedFiles);
-
- IFile[] addedGeneratedFiles = result.addedFiles;
- if (addedGeneratedFiles != null) {
- for (int j = addedGeneratedFiles.length; --j >= 0;) {
- SourceFile sourceFile = findSourceFile(addedGeneratedFiles[j], true);
- if (sourceFile == null) continue;
- if (uniqueFiles == null) {
- uniqueFiles = new SimpleSet(unitsAboutToCompile.length + 3);
- for (int f = unitsAboutToCompile.length; --f >= 0;)
- uniqueFiles.add(unitsAboutToCompile[f]);
- }
- if (uniqueFiles.addIfNotIncluded(sourceFile) == sourceFile) {
- ValidationParticipantResult newResult = new BuildContext(sourceFile);
- // is there enough room to add all the addedGeneratedFiles.length ?
- if (toAdd == null) {
- toAdd = new ValidationParticipantResult[addedGeneratedFiles.length];
- } else {
- int length = toAdd.length;
- if (added == length)
- System.arraycopy(toAdd, 0, toAdd = new ValidationParticipantResult[length + addedGeneratedFiles.length], 0, length);
- }
- toAdd[added++] = newResult;
- }
- }
- }
- }
-
- if (added >0 ) {
- int length = results.length;
- System.arraycopy(results, 0, results = new BuildContext[length + added], 0 , length);
- System.arraycopy(toAdd, 0, results, length, added);
- }
- return results;
-}
-
-protected void recordParticipantResult(ValidationParticipantResult result) {
- // any added/changed/deleted generated files have already been taken care
- // just record the problems and dependencies - do not expect there to be many
- // must be called after we're finished with the compilation unit results but before incremental loop adds affected files
- CategorizedProblem[] problems = result.problems;
- if (problems != null && problems.length > 0) {
- // existing problems have already been removed so just add these as new problems
- this.notifier.updateProblemCounts(problems);
- try {
- storeProblemsFor(result.sourceFile, problems);
- } catch (CoreException e) {
- // must continue with compile loop so just log the CoreException
- e.printStackTrace();
- }
- }
-
- String[] dependencies = result.dependencies;
- if (dependencies != null) {
- ReferenceCollection refs = (ReferenceCollection) this.newState.references.get(result.sourceFile.typeLocator());
- if (refs != null)
- refs.addDependencies(dependencies);
- }
-}
-
-/**
- * Creates a marker from each problem and adds it to the resource.
- * The marker is as follows:
- * - its type is T_PROBLEM
- * - its plugin ID is the JavaBuilder's plugin ID
- * - its message is the problem's message
- * - its priority reflects the severity of the problem
- * - its range is the problem's range
- * - it has an extra attribute "ID" which holds the problem's id
- * - it's GENERATED_BY attribute is positioned to JavaBuilder.GENERATED_BY if
- * the problem was generated by JDT; else the GENERATED_BY attribute is
- * carried from the problem to the marker in extra attributes, if present.
- */
-protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
- if (sourceFile == null || problems == null || problems.length == 0) return;
- // once a classpath error is found, ignore all other problems for this project so the user can see the main error
- // but still try to compile as many source files as possible to help the case when the base libraries are in source
- if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
-
- IResource resource = sourceFile.resource;
- IResource container=(resource instanceof IFile)? resource.getParent():resource;
- if (JavaScriptCore.isReadOnly(container))
- return;
- HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().validationParticipants.managedMarkerTypes();
- for (int i = 0, l = problems.length; i < l; i++) {
- CategorizedProblem problem = problems[i];
- int id = problem.getID();
-
- // handle missing classfile situation
- if (id == IProblem.IsClassPathCorrect) {
- String missingClassfileName = problem.getArguments()[0];
- if (JavaBuilder.DEBUG)
- System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName));
- boolean isInvalidClasspathError = JavaScriptCore.ERROR.equals(javaBuilder.javaProject.getOption(JavaScriptCore.CORE_INCOMPLETE_CLASSPATH, true));
- // insert extra classpath problem, and make it the only problem for this project (optional)
- if (isInvalidClasspathError && JavaScriptCore.ABORT.equals(javaBuilder.javaProject.getOption(JavaScriptCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) {
- JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
- this.keepStoringProblemMarkers = false;
- }
- IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaScriptModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_incompleteClassPath, missingClassfileName),
- new Integer(isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING),
- new Integer(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
- // even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending
- // IsClassPathCorrect problem gets recorded since it may help locate the offending reference
- }
-
- String markerType = problem.getMarkerType();
- boolean managedProblem = false;
- if (IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER.equals(markerType)
- || (managedProblem = managedMarkerTypes.contains(markerType))) {
- IMarker marker = resource.createMarker(markerType);
-
- String[] attributeNames = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES;
- int standardLength = attributeNames.length;
- String[] allNames = attributeNames;
- int managedLength = managedProblem ? 0 : 1;
- String[] extraAttributeNames = problem.getExtraMarkerAttributeNames();
- int extraLength = extraAttributeNames == null ? 0 : extraAttributeNames.length;
- if (managedLength > 0 || extraLength > 0) {
- allNames = new String[standardLength + managedLength + extraLength];
- System.arraycopy(attributeNames, 0, allNames, 0, standardLength);
- if (managedLength > 0)
- allNames[standardLength] = IMarker.SOURCE_ID;
- System.arraycopy(extraAttributeNames, 0, allNames, standardLength + managedLength, extraLength);
- }
-
- Object[] allValues = new Object[allNames.length];
- // standard attributes
- int index = 0;
- allValues[index++] = problem.getMessage(); // message
- allValues[index++] = problem.isError() ? S_ERROR : S_WARNING; // severity
- allValues[index++] = new Integer(id); // ID
- allValues[index++] = new Integer(problem.getSourceStart()); // start
- allValues[index++] = new Integer(problem.getSourceEnd() + 1); // end
- allValues[index++] = new Integer(problem.getSourceLineNumber()); // line
- allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments
- allValues[index++] = new Integer(problem.getCategoryID()); // category ID
- // GENERATED_BY attribute for JDT problems
- if (managedLength > 0)
- allValues[index++] = JavaBuilder.SOURCE_ID;
- // optional extra attributes
- if (extraLength > 0)
- System.arraycopy(problem.getExtraMarkerAttributeValues(), 0, allValues, index, extraLength);
-
- marker.setAttributes(allNames, allValues);
-
- if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file
- }
- }
-}
-
-protected void storeTasksFor(SourceFile sourceFile, CategorizedProblem[] tasks) throws CoreException {
- if (sourceFile == null || tasks == null || tasks.length == 0) return;
-
- IResource resource = sourceFile.resource;
- for (int i = 0, l = tasks.length; i < l; i++) {
- CategorizedProblem task = tasks[i];
- if (task.getID() == IProblem.Task) {
- IMarker marker = resource.createMarker(IJavaScriptModelMarker.TASK_MARKER);
- Integer priority = P_NORMAL;
- String compilerPriority = task.getArguments()[2];
- if (JavaScriptCore.COMPILER_TASK_PRIORITY_HIGH.equals(compilerPriority))
- priority = P_HIGH;
- else if (JavaScriptCore.COMPILER_TASK_PRIORITY_LOW.equals(compilerPriority))
- priority = P_LOW;
-
- String[] attributeNames = JAVA_TASK_MARKER_ATTRIBUTE_NAMES;
- int standardLength = attributeNames.length;
- String[] allNames = attributeNames;
- String[] extraAttributeNames = task.getExtraMarkerAttributeNames();
- int extraLength = extraAttributeNames == null ? 0 : extraAttributeNames.length;
- if (extraLength > 0) {
- allNames = new String[standardLength + extraLength];
- System.arraycopy(attributeNames, 0, allNames, 0, standardLength);
- System.arraycopy(extraAttributeNames, 0, allNames, standardLength, extraLength);
- }
-
- Object[] allValues = new Object[allNames.length];
- // standard attributes
- int index = 0;
- allValues[index++] = task.getMessage();
- allValues[index++] = priority;
- allValues[index++] = new Integer(task.getID());
- allValues[index++] = new Integer(task.getSourceStart());
- allValues[index++] = new Integer(task.getSourceEnd() + 1);
- allValues[index++] = new Integer(task.getSourceLineNumber());
- allValues[index++] = Boolean.FALSE;
- allValues[index++] = JavaBuilder.SOURCE_ID;
- // optional extra attributes
- if (extraLength > 0)
- System.arraycopy(task.getExtraMarkerAttributeValues(), 0, allValues, index, extraLength);
-
- marker.setAttributes(allNames, allValues);
- }
- }
-}
-
-protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
- CategorizedProblem[] problems = result.getProblems();
- if (problems == null || problems.length == 0) return;
-
- notifier.updateProblemCounts(problems);
- storeProblemsFor(sourceFile, problems);
-}
-
-protected void updateTasksFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
- CategorizedProblem[] tasks = result.getTasks();
- if (tasks == null || tasks.length == 0) return;
-
- storeTasksFor(sourceFile, tasks);
-}
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AdditionalTypeCollection.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AdditionalTypeCollection.java
deleted file mode 100644
index 9fca750d..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/AdditionalTypeCollection.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-public class AdditionalTypeCollection extends ReferenceCollection {
-
-char[][] definedTypeNames;
-
-protected AdditionalTypeCollection(char[][] definedTypeNames, char[][][] qualifiedReferences, char[][] simpleNameReferences) {
- super(qualifiedReferences, simpleNameReferences);
- this.definedTypeNames = definedTypeNames; // do not bother interning member type names (ie. 'A$M')
-}
-}
-
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BatchImageBuilder.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BatchImageBuilder.java
deleted file mode 100644
index f99af0c4..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BatchImageBuilder.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.internal.core.util.Messages;
-
-public class BatchImageBuilder extends AbstractImageBuilder {
-
- IncrementalImageBuilder incrementalBuilder; // if annotations or secondary types have to be processed after the compile loop
- ArrayList secondaryTypes; // qualified names for all secondary types found during batch compile
- StringSet typeLocatorsWithUndefinedTypes; // type locators for all source files with errors that may be caused by 'not found' secondary types
-
-protected BatchImageBuilder(JavaBuilder javaBuilder, boolean buildStarting) {
- super(javaBuilder, buildStarting, null);
- this.nameEnvironment.isIncrementalBuild = false;
- this.incrementalBuilder = null;
- this.secondaryTypes = null;
- this.typeLocatorsWithUndefinedTypes = null;
-}
-
-public void build() {
- if (JavaBuilder.DEBUG)
- System.out.println("FULL build"); //$NON-NLS-1$
-
- try {
-// notifier.subTask(Messages.bind(Messages.build_cleaningOutput, this.javaBuilder.currentProject.getName()));
- JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject);
-// cleanOutputFolders(true);
- notifier.updateProgressDelta(0.05f);
-
- notifier.subTask(Messages.build_analyzingSources);
- ArrayList sourceFiles = new ArrayList(33);
- addAllSourceFiles(sourceFiles);
- notifier.updateProgressDelta(0.10f);
-
- if (sourceFiles.size() > 0) {
- SourceFile[] allSourceFiles = new SourceFile[sourceFiles.size()];
- sourceFiles.toArray(allSourceFiles);
-
- notifier.setProgressPerCompilationUnit(0.75f / allSourceFiles.length);
- 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 (javaBuilder.javaProject.hasCycleMarker())
- javaBuilder.mustPropagateStructuralChanges();
- } catch (CoreException e) {
- throw internalException(e);
- } finally {
- cleanUp();
- }
-}
-
-protected void cleanUp() {
- this.incrementalBuilder = null;
- this.secondaryTypes = null;
- this.typeLocatorsWithUndefinedTypes = null;
- super.cleanUp();
-}
-
-protected void compile(SourceFile[] units, SourceFile[] additionalUnits, boolean compilingFirstGroup) {
- if (additionalUnits != null && this.secondaryTypes == null)
- this.secondaryTypes = new ArrayList(7);
- super.compile(units, additionalUnits, compilingFirstGroup);
-}
-
-protected IResource findOriginalResource(IPath partialPath) {
- for (int i = 0, l = sourceLocations.length; i < l; i++) {
- ClasspathMultiDirectory sourceLocation = sourceLocations[i];
- if (sourceLocation.hasIndependentOutputFolder) {
- IResource originalResource = sourceLocation.sourceFolder.getFile(partialPath);
- if (originalResource.exists()) return originalResource;
- }
- }
- return null;
-}
-
-protected void rebuildTypesAffectedBySecondaryTypes() {
- // to compile types that could not find 'missing' secondary types because of multiple
- // compile groups, we need to incrementally recompile all affected types as if the missing
- // secondary types have just been added, see bug 146324
- if (this.incrementalBuilder == null)
- this.incrementalBuilder = new IncrementalImageBuilder(this);
-
- for (int i = this.secondaryTypes.size(); --i >=0;) {
- char[] secondaryTypeName = (char[]) this.secondaryTypes.get(i);
- IPath path = new Path(null, new String(secondaryTypeName));
- this.incrementalBuilder.addDependentsOf(path, false);
- }
- this.incrementalBuilder.addAffectedSourceFiles(
- this.incrementalBuilder.qualifiedStrings,
- this.incrementalBuilder.simpleStrings,
- this.typeLocatorsWithUndefinedTypes);
-}
-
-protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException {
- if (sourceFile == null || problems == null || problems.length == 0) return;
-
- for (int i = problems.length; --i >= 0;) {
- CategorizedProblem problem = problems[i];
- if (problem != null && problem.getID() == IProblem.UndefinedType) {
- if (this.typeLocatorsWithUndefinedTypes == null)
- this.typeLocatorsWithUndefinedTypes = new StringSet(3);
- this.typeLocatorsWithUndefinedTypes.add(sourceFile.typeLocator());
- break;
- }
- }
-
- super.storeProblemsFor(sourceFile, problems);
-}
-
-public String toString() {
- return "batch image builder for:\n\tnew state: " + newState; //$NON-NLS-1$
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BuildNotifier.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BuildNotifier.java
deleted file mode 100644
index b5d5c3a6..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/BuildNotifier.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-import org.eclipse.wst.jsdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.wst.jsdt.internal.core.util.Messages;
-
-public class BuildNotifier {
-
-protected IProgressMonitor monitor;
-protected boolean cancelling;
-protected float percentComplete;
-protected float progressPerCompilationUnit;
-protected int newErrorCount;
-protected int fixedErrorCount;
-protected int newWarningCount;
-protected int fixedWarningCount;
-protected int workDone;
-protected int totalWork;
-protected String previousSubtask;
-
-public static int NewErrorCount = 0;
-public static int FixedErrorCount = 0;
-public static int NewWarningCount = 0;
-public static int FixedWarningCount = 0;
-
-public static void resetProblemCounters() {
- NewErrorCount = 0;
- FixedErrorCount = 0;
- NewWarningCount = 0;
- FixedWarningCount = 0;
-}
-
-public BuildNotifier(IProgressMonitor monitor, IProject project) {
- this.monitor = monitor;
- this.cancelling = false;
- this.newErrorCount = NewErrorCount;
- this.fixedErrorCount = FixedErrorCount;
- this.newWarningCount = NewWarningCount;
- this.fixedWarningCount = FixedWarningCount;
- this.workDone = 0;
- this.totalWork = 1000000;
-}
-
-/**
- * Notification before a compile that a unit is about to be compiled.
- */
-public void aboutToCompile(SourceFile unit) {
- String message = Messages.bind(Messages.build_compiling, unit.resource.getFullPath().removeLastSegments(1).makeRelative().toString());
- subTask(message);
-}
-
-public void begin() {
- if (monitor != null)
- monitor.beginTask("", totalWork); //$NON-NLS-1$
- this.previousSubtask = null;
-}
-
-/**
- * Check whether the build has been canceled.
- */
-public void checkCancel() {
- if (monitor != null && monitor.isCanceled())
- throw new OperationCanceledException();
-}
-
-/**
- * Check whether the build has been canceled.
- * Must use this call instead of checkCancel() when within the compiler.
- */
-public void checkCancelWithinCompiler() {
- if (monitor != null && monitor.isCanceled() && !cancelling) {
- // Once the compiler has been canceled, don't check again.
- setCancelling(true);
- // Only AbortCompilation can stop the compiler cleanly.
- // We check cancelation again following the call to compile.
- throw new AbortCompilation(true, null);
- }
-}
-
-/**
- * Notification while within a compile that a unit has finished being compiled.
- */
-public void compiled(SourceFile unit) {
- String message = Messages.bind(Messages.build_compiling, unit.resource.getFullPath().removeLastSegments(1).makeRelative().toString());
- subTask(message);
- updateProgressDelta(progressPerCompilationUnit);
- checkCancelWithinCompiler();
-}
-
-public void done() {
- NewErrorCount = this.newErrorCount;
- FixedErrorCount = this.fixedErrorCount;
- NewWarningCount = this.newWarningCount;
- FixedWarningCount = this.fixedWarningCount;
-
- updateProgress(1.0f);
- subTask(Messages.build_done);
- if (monitor != null)
- monitor.done();
- this.previousSubtask = null;
-}
-
-/**
- * Returns a string describing the problems.
- */
-protected String problemsMessage() {
- int numNew = newErrorCount + newWarningCount;
- int numFixed = fixedErrorCount + fixedWarningCount;
- if (numNew == 0 && numFixed == 0) return ""; //$NON-NLS-1$
-
- boolean displayBoth = numNew > 0 && numFixed > 0;
- StringBuffer buffer = new StringBuffer();
- buffer.append('(');
- if (numNew > 0) {
- // (Found x errors + y warnings)
- buffer.append(Messages.build_foundHeader);
- buffer.append(' ');
- if (displayBoth || newErrorCount > 0) {
- if (newErrorCount == 1)
- buffer.append(Messages.build_oneError);
- else
- buffer.append(Messages.bind(Messages.build_multipleErrors, String.valueOf(newErrorCount)));
- if (displayBoth || newWarningCount > 0)
- buffer.append(" + "); //$NON-NLS-1$
- }
- if (displayBoth || newWarningCount > 0) {
- if (newWarningCount == 1)
- buffer.append(Messages.build_oneWarning);
- else
- buffer.append(Messages.bind(Messages.build_multipleWarnings, String.valueOf(newWarningCount)));
- }
- if (numFixed > 0)
- buffer.append(", "); //$NON-NLS-1$
- }
- if (numFixed > 0) {
- // (Fixed x errors + y warnings) or (Found x errors + y warnings, Fixed x + y)
- buffer.append(Messages.build_fixedHeader);
- buffer.append(' ');
- if (displayBoth) {
- buffer.append(String.valueOf(fixedErrorCount));
- buffer.append(" + "); //$NON-NLS-1$
- buffer.append(String.valueOf(fixedWarningCount));
- } else {
- if (fixedErrorCount > 0) {
- if (fixedErrorCount == 1)
- buffer.append(Messages.build_oneError);
- else
- buffer.append(Messages.bind(Messages.build_multipleErrors, String.valueOf(fixedErrorCount)));
- if (fixedWarningCount > 0)
- buffer.append(" + "); //$NON-NLS-1$
- }
- if (fixedWarningCount > 0) {
- if (fixedWarningCount == 1)
- buffer.append(Messages.build_oneWarning);
- else
- buffer.append(Messages.bind(Messages.build_multipleWarnings, String.valueOf(fixedWarningCount)));
- }
- }
- }
- buffer.append(')');
- return buffer.toString();
-}
-
-/**
- * Sets the cancelling flag, which indicates we are in the middle
- * of being cancelled. Certain places (those callable indirectly from the compiler)
- * should not check cancel again while this is true, to avoid OperationCanceledException
- * being thrown at an inopportune time.
- */
-public void setCancelling(boolean cancelling) {
- this.cancelling = cancelling;
-}
-
-/**
- * Sets the amount of progress to report for compiling each compilation unit.
- */
-public void setProgressPerCompilationUnit(float progress) {
- this.progressPerCompilationUnit = progress;
-}
-
-public void subTask(String message) {
- String pm = problemsMessage();
- String msg = pm.length() == 0 ? message : pm + " " + message; //$NON-NLS-1$
-
- if (msg.equals(this.previousSubtask)) return; // avoid refreshing with same one
- //if (JavaBuilder.DEBUG) System.out.println(msg);
- if (monitor != null)
- monitor.subTask(msg);
-
- this.previousSubtask = msg;
-}
-
-protected void updateProblemCounts(CategorizedProblem[] newProblems) {
- for (int i = 0, l = newProblems.length; i < l; i++)
- if (newProblems[i].isError()) newErrorCount++; else newWarningCount++;
-}
-
-/**
- * Update the problem counts from one compilation result given the old and new problems,
- * either of which may be null.
- */
-protected void updateProblemCounts(IMarker[] oldProblems, CategorizedProblem[] newProblems) {
- if (newProblems != null) {
- next : for (int i = 0, l = newProblems.length; i < l; i++) {
- CategorizedProblem newProblem = newProblems[i];
- if (newProblem.getID() == IProblem.Task) continue; // skip task
- boolean isError = newProblem.isError();
- String message = newProblem.getMessage();
-
- if (oldProblems != null) {
- for (int j = 0, m = oldProblems.length; j < m; j++) {
- IMarker pb = oldProblems[j];
- if (pb == null) continue; // already matched up with a new problem
- boolean wasError = IMarker.SEVERITY_ERROR
- == pb.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- if (isError == wasError && message.equals(pb.getAttribute(IMarker.MESSAGE, ""))) { //$NON-NLS-1$
- oldProblems[j] = null;
- continue next;
- }
- }
- }
- if (isError) newErrorCount++; else newWarningCount++;
- }
- }
- if (oldProblems != null) {
- next : for (int i = 0, l = oldProblems.length; i < l; i++) {
- IMarker oldProblem = oldProblems[i];
- if (oldProblem == null) continue next; // already matched up with a new problem
- boolean wasError = IMarker.SEVERITY_ERROR
- == oldProblem.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- String message = oldProblem.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
-
- if (newProblems != null) {
- for (int j = 0, m = newProblems.length; j < m; j++) {
- CategorizedProblem pb = newProblems[j];
- if (pb.getID() == IProblem.Task) continue; // skip task
- if (wasError == pb.isError() && message.equals(pb.getMessage()))
- continue next;
- }
- }
- if (wasError) fixedErrorCount++; else fixedWarningCount++;
- }
- }
-}
-
-public void updateProgress(float newPercentComplete) {
- if (newPercentComplete > this.percentComplete) {
- this.percentComplete = Math.min(newPercentComplete, 1.0f);
- int work = Math.round(this.percentComplete * this.totalWork);
- if (work > this.workDone) {
- if (monitor != null)
- monitor.worked(work - this.workDone);
- //if (JavaBuilder.DEBUG)
- //System.out.println(java.text.NumberFormat.getPercentInstance().format(this.percentComplete));
- this.workDone = work;
- }
- }
-}
-
-public void updateProgressDelta(float percentWorked) {
- updateProgress(percentComplete + percentWorked);
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathDirectory.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathDirectory.java
deleted file mode 100644
index 812b242c..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathDirectory.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
-import org.eclipse.wst.jsdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleLookupTable;
-
-public class ClasspathDirectory extends ClasspathLocation {
-
-IContainer binaryFolder; // includes .class files for a single directory
-boolean isOutputFolder;
-SimpleLookupTable directoryCache;
-String[] missingPackageHolder = new String[1];
-AccessRuleSet accessRuleSet;
-
-ClasspathDirectory(IContainer binaryFolder, boolean isOutputFolder, AccessRuleSet accessRuleSet) {
- this.binaryFolder = binaryFolder;
- this.isOutputFolder = isOutputFolder;
- this.directoryCache = new SimpleLookupTable(5);
- this.accessRuleSet = accessRuleSet;
-}
-
-public void cleanup() {
- this.directoryCache = null;
-}
-
-String[] directoryList(String qualifiedPackageName) {
- String[] dirList = (String[]) directoryCache.get(qualifiedPackageName);
- if (dirList == missingPackageHolder) return null; // package exists in another classpath directory or jar
- if (dirList != null) return dirList;
-
- try {
- IResource container = binaryFolder.findMember(qualifiedPackageName); // this is a case-sensitive check
- if (container instanceof IContainer) {
- IResource[] members = ((IContainer) container).members();
- dirList = new String[members.length];
- int index = 0;
- for (int i = 0, l = members.length; i < l; i++) {
- IResource m = members[i];
- if (m.getType() == IResource.FILE && org.eclipse.wst.jsdt.internal.compiler.util.Util.isClassFileName(m.getName()))
- // add exclusion pattern check here if we want to hide .class files
- dirList[index++] = m.getName();
- }
- if (index < dirList.length)
- System.arraycopy(dirList, 0, dirList = new String[index], 0, index);
- directoryCache.put(qualifiedPackageName, dirList);
- return dirList;
- }
- } catch(CoreException ignored) {
- // ignore
- }
- directoryCache.put(qualifiedPackageName, missingPackageHolder);
- return null;
-}
-
-boolean doesFileExist(String fileName, String qualifiedPackageName, String qualifiedFullName) {
- String[] dirList = directoryList(qualifiedPackageName);
- if (dirList == null) return false; // most common case
-
- for (int i = dirList.length; --i >= 0;)
- if (fileName.equals(dirList[i]))
- return true;
- return false;
-}
-
-public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ClasspathDirectory)) return false;
-
- ClasspathDirectory dir = (ClasspathDirectory) o;
- if (this.accessRuleSet != dir.accessRuleSet)
- if (this.accessRuleSet == null || !this.accessRuleSet.equals(dir.accessRuleSet))
- return false;
- return this.binaryFolder.equals(dir.binaryFolder);
-}
-
-public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
-
- return null;
-}
-
-public IPath getProjectRelativePath() {
- return binaryFolder.getProjectRelativePath();
-}
-
-protected boolean isExcluded(IResource resource) {
- return false;
-}
-
-public boolean isOutputFolder() {
- return isOutputFolder;
-}
-
-public boolean isPackage(String qualifiedPackageName) {
- return directoryList(qualifiedPackageName) != null;
-}
-
-public void reset() {
- this.directoryCache = new SimpleLookupTable(5);
-}
-
-public String toString() {
- String start = "Binary classpath directory " + this.binaryFolder.getFullPath().toString(); //$NON-NLS-1$
- if (this.accessRuleSet == null)
- return start;
- return start + " with " + this.accessRuleSet; //$NON-NLS-1$
-}
-
-public String debugPathString() {
- return this.binaryFolder.getFullPath().toString();
-}
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLibrary.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLibrary.java
deleted file mode 100644
index e17f263a..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLibrary.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Tal Lev-Ami - added package cache for zip files
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.io.File;
-import java.util.Date;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
-import org.eclipse.wst.jsdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleSet;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-public class ClasspathLibrary extends ClasspathLocation {
-
-
-
-String filename; // keep for equals
-IFile resource;
-long lastModified;
-boolean closeZipFileAtEnd;
-SimpleSet knownPackageNames;
-AccessRuleSet accessRuleSet;
-
-ClasspathLibrary(IFile resource, AccessRuleSet accessRuleSet) {
- this.resource = resource;
- try {
- java.net.URI location = resource.getLocationURI();
- if (location == null) {
- this.filename = ""; //$NON-NLS-1$
- } else {
- File localFile = Util.toLocalFile(location, null);
- this.filename = localFile.getPath();
- }
- } catch (CoreException e) {
- // ignore
- }
- this.knownPackageNames = null;
- this.accessRuleSet = accessRuleSet;
-}
-
-ClasspathLibrary(String filename, long lastModified, AccessRuleSet accessRuleSet) {
- this.filename = filename;
- this.lastModified = lastModified;
- this.knownPackageNames = null;
- this.accessRuleSet = accessRuleSet;
-}
-
-
-public void cleanup() {
- this.knownPackageNames = null;
-}
-
-public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ClasspathLibrary)) return false;
-
- ClasspathLibrary library = (ClasspathLibrary) o;
- if (this.accessRuleSet != library.accessRuleSet)
- if (this.accessRuleSet == null || !this.accessRuleSet.equals(library.accessRuleSet))
- return false;
- return this.filename.equals(library.filename) && this.lastModified() == library.lastModified();
-}
-
-public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
-// if (!isPackage(qualifiedPackageName)) return null; // most common case
-//
-// try {
-// ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
-// if (reader != null) {
-// if (this.accessRuleSet == null)
-// return new NameEnvironmentAnswer(reader, null);
-// String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
-// return new NameEnvironmentAnswer(reader, this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()));
-// }
-// } catch (Exception e) { // treat as if class file is missing
-// }
-// return null;
- //TODO: implement
- throw new org.eclipse.wst.jsdt.core.UnimplementedException();
-}
-
-public IPath getProjectRelativePath() {
- if (this.resource == null) return null;
- return this.resource.getProjectRelativePath();
-}
-
-public boolean isPackage(String qualifiedPackageName) {
- return this.filename.endsWith(qualifiedPackageName);
-// if (this.knownPackageNames != null)
-// return this.knownPackageNames.includes(qualifiedPackageName);
-//
-// try {
-// if (this.zipFile == null) {
-// if (org.eclipse.wst.jsdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) {
-// System.out.println("(" + Thread.currentThread() + ") [ClasspathJar.isPackage(String)] Creating ZipFile on " + zipFilename); //$NON-NLS-1$ //$NON-NLS-2$
-// }
-// this.zipFile = new ZipFile(zipFilename);
-// this.closeZipFileAtEnd = true;
-// }
-// this.knownPackageNames = findPackageSet(this);
-// } catch(Exception e) {
-// this.knownPackageNames = new SimpleSet(); // assume for this build the zipFile is empty
-// }
-// return this.knownPackageNames.includes(qualifiedPackageName);
-}
-
-public long lastModified() {
- if (this.lastModified == 0)
- this.lastModified = new File(this.filename).lastModified();
- return this.lastModified;
-}
-
-public String toString() {
- String start = "Classpath library file " + this.filename; //$NON-NLS-1$
- if (this.accessRuleSet == null)
- return start;
- return start + " with " + this.accessRuleSet; //$NON-NLS-1$
-}
-
-public String debugPathString() {
- if (this.lastModified == 0)
- return this.filename;
- return this.filename + '(' + (new Date(this.lastModified)) + " : " + this.lastModified + ')'; //$NON-NLS-1$
-}
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLocation.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLocation.java
deleted file mode 100644
index 3cfac9b6..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathLocation.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
-import org.eclipse.wst.jsdt.internal.compiler.env.NameEnvironmentAnswer;
-
-public abstract class ClasspathLocation {
-
-static ClasspathLocation forSourceFolder(IContainer sourceFolder, IContainer outputFolder, char[][] inclusionPatterns, char[][] exclusionPatterns) {
- return new ClasspathMultiDirectory(sourceFolder, outputFolder, inclusionPatterns, exclusionPatterns);
-}
-
-public static ClasspathLocation forBinaryFolder(IContainer binaryFolder, boolean isOutputFolder, AccessRuleSet accessRuleSet) {
- return new ClasspathDirectory(binaryFolder, isOutputFolder, accessRuleSet);
-}
-
-public static ClasspathLocation forLibrary(String libraryPathname, long lastModified, AccessRuleSet accessRuleSet) {
- return new ClasspathLibrary(libraryPathname, lastModified, accessRuleSet);
-}
-
-public static ClasspathLocation forLibrary(String libraryPathname, AccessRuleSet accessRuleSet) {
- return forLibrary(libraryPathname, 0, accessRuleSet);
-}
-
-
-public abstract NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName);
-
-public abstract IPath getProjectRelativePath();
-
-public boolean isOutputFolder() {
- return false;
-}
-
-public abstract boolean isPackage(String qualifiedPackageName);
-
-public void cleanup() {
- // free anything which is not required when the state is saved
-}
-public void reset() {
- // reset any internal caches before another compile loop starts
-}
-
-public abstract String debugPathString();
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathMultiDirectory.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathMultiDirectory.java
deleted file mode 100644
index ff692ae2..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ClasspathMultiDirectory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-class ClasspathMultiDirectory extends ClasspathDirectory {
-
-IContainer sourceFolder;
-char[][] inclusionPatterns; // used by builders when walking source folders
-char[][] exclusionPatterns; // used by builders when walking source folders
-boolean hasIndependentOutputFolder; // if output folder is not equal to any of the source folders
-
-ClasspathMultiDirectory(IContainer sourceFolder, IContainer binaryFolder, char[][] inclusionPatterns, char[][] exclusionPatterns) {
- super(binaryFolder, true, null);
-
- this.sourceFolder = sourceFolder;
- this.inclusionPatterns = inclusionPatterns;
- this.exclusionPatterns = exclusionPatterns;
- this.hasIndependentOutputFolder = false;
-
- // handle the case when a state rebuilds a source folder
- if (this.inclusionPatterns != null && this.inclusionPatterns.length == 0)
- this.inclusionPatterns = null;
- if (this.exclusionPatterns != null && this.exclusionPatterns.length == 0)
- this.exclusionPatterns = null;
-}
-
-public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ClasspathMultiDirectory)) return false;
-
- ClasspathMultiDirectory md = (ClasspathMultiDirectory) o;
- return sourceFolder.equals(md.sourceFolder) && binaryFolder.equals(md.binaryFolder)
- && CharOperation.equals(inclusionPatterns, md.inclusionPatterns)
- && CharOperation.equals(exclusionPatterns, md.exclusionPatterns);
-}
-
-protected boolean isExcluded(IResource resource) {
- if (this.exclusionPatterns != null || this.inclusionPatterns != null)
- if (this.sourceFolder.equals(this.binaryFolder))
- return Util.isExcluded(resource, this.inclusionPatterns, this.exclusionPatterns);
- return false;
-}
-
-public String toString() {
- return "Source classpath directory " + sourceFolder.getFullPath().toString() + //$NON-NLS-1$
- " with " + super.toString(); //$NON-NLS-1$
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ICompilationUnitLocator.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ICompilationUnitLocator.java
deleted file mode 100644
index 687ed952..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ICompilationUnitLocator.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 BEA Systems, Inc.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * wharley@bea.com - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit;
-
-/**
- * Used to convert an IFile into an IJavaScriptUnit,
- * for clients outside of this package.
- * @since 3.3
- */
-public interface ICompilationUnitLocator {
- public ICompilationUnit fromIFile(IFile file);
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ImageBuilderInternalException.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ImageBuilderInternalException.java
deleted file mode 100644
index 677a0e3c..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ImageBuilderInternalException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * Exception thrown when there is an internal error in the image builder.
- * May wrapper another exception.
- */
-public class ImageBuilderInternalException extends RuntimeException {
-
-private static final long serialVersionUID = 28252254530437336L; // backward compatible
-protected CoreException coreException;
-
-public ImageBuilderInternalException(CoreException e) {
- this.coreException = e;
-}
-
-public String getLocalizedMessage() {
- IStatus status = this.coreException.getStatus();
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- if (children != null && children.length > 0)
- return children[0].getMessage();
- }
- return this.coreException.getLocalizedMessage();
-}
-
-public CoreException getThrowable() {
- return coreException;
-}
-
-public void printStackTrace() {
- if (coreException != null) {
- System.err.println(this);
- System.err.println("Stack trace of embedded core exception:"); //$NON-NLS-1$
- coreException.printStackTrace();
- } else {
- super.printStackTrace();
- }
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/IncrementalImageBuilder.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/IncrementalImageBuilder.java
deleted file mode 100644
index 764ab3d8..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/IncrementalImageBuilder.java
+++ /dev/null
@@ -1,787 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.util.ArrayList;
-import java.util.Date;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.jsdt.core.IJavaScriptModelMarker;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.internal.compiler.CompilationResult;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleLookupTable;
-import org.eclipse.wst.jsdt.internal.core.util.Messages;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-/**
- * The incremental image builder
- */
-public class IncrementalImageBuilder extends AbstractImageBuilder {
-
-protected ArrayList sourceFiles;
-protected ArrayList previousSourceFiles;
-protected StringSet qualifiedStrings;
-protected StringSet simpleStrings;
-protected SimpleLookupTable secondaryTypesToRemove;
-protected boolean hasStructuralChanges;
-protected int compileLoop;
-protected boolean makeOutputFolderConsistent;
-
-public static int MaxCompileLoop = 5; // perform a full build if it takes more than ? incremental compile loops
-
-protected IncrementalImageBuilder(JavaBuilder javaBuilder, State buildState) {
- super(javaBuilder, true, buildState);
- this.nameEnvironment.isIncrementalBuild = true;
- this.makeOutputFolderConsistent = JavaScriptCore.ENABLED.equals(
- javaBuilder.javaProject.getOption(JavaScriptCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, true));
-}
-
-protected IncrementalImageBuilder(JavaBuilder javaBuilder) {
- this(javaBuilder, null);
- this.newState.copyFrom(javaBuilder.lastState);
-}
-
-protected IncrementalImageBuilder(BatchImageBuilder batchBuilder) {
- this(batchBuilder.javaBuilder, batchBuilder.newState);
- resetCollections();
-}
-
-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 {
- resetCollections();
-
- notifier.subTask(Messages.build_analyzingDeltas);
- if (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
- javaBuilder.currentProject.deleteMarkers(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
- addAllSourceFiles(sourceFiles);
- notifier.updateProgressDelta(0.25f);
- } else {
- IResourceDelta sourceDelta = (IResourceDelta) deltas.get(javaBuilder.currentProject);
- if (sourceDelta != null)
- if (!findSourceFiles(sourceDelta)) return false;
- 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[]) javaBuilder.binaryLocationsPerProject.get(p);
- if (classFoldersAndJars != null)
- if (!findAffectedSourceFiles(delta, classFoldersAndJars, p)) return false;
- }
- }
- notifier.updateProgressDelta(0.10f);
-
- notifier.subTask(Messages.build_analyzingSources);
- addAffectedSourceFiles();
- notifier.updateProgressDelta(0.05f);
- }
-
- this.compileLoop = 0;
- float increment = 0.40f;
- while (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;
- }
- notifier.checkCancel();
-
- SourceFile[] allSourceFiles = new SourceFile[sourceFiles.size()];
- sourceFiles.toArray(allSourceFiles);
- resetCollections();
-
- workQueue.addAll(allSourceFiles);
- notifier.setProgressPerCompilationUnit(increment / allSourceFiles.length);
- increment = increment / 2;
- compile(allSourceFiles);
- //removeSecondaryTypes();
- addAffectedSourceFiles();
- }
- if (this.hasStructuralChanges && javaBuilder.javaProject.hasCycleMarker())
- 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;
-}
-
-protected void buildAfterBatchBuild() {
- // called from a batch builder once all source files have been compiled AND some changes
- // need to be propagated incrementally (annotations, missing secondary types)
-
- if (JavaBuilder.DEBUG)
- System.out.println("INCREMENTAL build after batch build @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$
-
- // this is a copy of the incremental build loop
- try {
- addAffectedSourceFiles();
- while (this.sourceFiles.size() > 0) {
- notifier.checkCancel();
- SourceFile[] allSourceFiles = new SourceFile[this.sourceFiles.size()];
- this.sourceFiles.toArray(allSourceFiles);
- resetCollections();
- notifier.setProgressPerCompilationUnit(0.08f / allSourceFiles.length);
- this.workQueue.addAll(allSourceFiles);
- compile(allSourceFiles);
- //removeSecondaryTypes();
- addAffectedSourceFiles();
- }
-// } catch (Exception e) {
-// throw internalException(e);
- } finally {
- cleanUp();
- }
-}
-
-protected void addAffectedSourceFiles() {
- if (qualifiedStrings.elementSize == 0 && simpleStrings.elementSize == 0) return;
-
- addAffectedSourceFiles(qualifiedStrings, simpleStrings, null);
-}
-
-protected void addAffectedSourceFiles(StringSet qualifiedSet, StringSet simpleSet, StringSet affectedTypes) {
- // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are just 'X'
- char[][][] internedQualifiedNames = ReferenceCollection.internQualifiedNames(qualifiedSet);
- // if a well known qualified name was found then we can skip over these
- if (internedQualifiedNames.length < qualifiedSet.elementSize)
- internedQualifiedNames = null;
- char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(simpleSet);
- // if a well known name was found then we can skip over these
- if (internedSimpleNames.length < simpleSet.elementSize)
- internedSimpleNames = null;
-
- Object[] keyTable = newState.references.keyTable;
- Object[] valueTable = newState.references.valueTable;
- next : for (int i = 0, l = valueTable.length; i < l; i++) {
- String typeLocator = (String) keyTable[i];
- if (typeLocator != null) {
- if (affectedTypes != null && !affectedTypes.includes(typeLocator)) continue next;
- ReferenceCollection refs = (ReferenceCollection) valueTable[i];
- if (refs.includes(internedQualifiedNames, internedSimpleNames)) {
- IFile file = javaBuilder.currentProject.getFile(typeLocator);
- SourceFile sourceFile = findSourceFile(file, true);
- if (sourceFile == null) continue next;
- if (sourceFiles.contains(sourceFile)) continue next;
- if (compiledAllAtOnce && previousSourceFiles != null && previousSourceFiles.contains(sourceFile))
- continue next; // can skip previously compiled files since already saw hierarchy related problems
-
- if (JavaBuilder.DEBUG)
- System.out.println(" adding affected source file " + typeLocator); //$NON-NLS-1$
- sourceFiles.add(sourceFile);
- }
- }
- }
-}
-
-protected void addDependentsOf(IPath path, boolean isStructuralChange) {
- if (isStructuralChange && !this.hasStructuralChanges) {
- newState.tagAsStructurallyChanged();
- this.hasStructuralChanges = true;
- }
- // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are just 'X'
- path = path.setDevice(null);
- String packageName = path.removeLastSegments(1).toString();
- qualifiedStrings.add(packageName);
- String typeName = path.lastSegment();
- int memberIndex = typeName.indexOf('$');
- if (memberIndex > 0)
- typeName = typeName.substring(0, memberIndex);
- if (simpleStrings.add(typeName) && JavaBuilder.DEBUG)
- System.out.println(" will look for dependents of " //$NON-NLS-1$
- + typeName + " in " + packageName); //$NON-NLS-1$
-}
-
-protected boolean checkForClassFileChanges(IResourceDelta binaryDelta, ClasspathMultiDirectory md, int segmentCount) throws CoreException {
- IResource resource = binaryDelta.getResource();
- // remember that if inclusion & exclusion patterns change then a full build is done
- boolean isExcluded = (md.exclusionPatterns != null || md.inclusionPatterns != null)
- && Util.isExcluded(resource, md.inclusionPatterns, md.exclusionPatterns);
- switch(resource.getType()) {
- case IResource.FOLDER :
- if (isExcluded && md.inclusionPatterns == null)
- return true; // no need to go further with this delta since its children cannot be included
-
- IResourceDelta[] children = binaryDelta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- if (!checkForClassFileChanges(children[i], md, segmentCount))
- return false;
- return true;
- case IResource.FILE :
- if (!isExcluded && org.eclipse.wst.jsdt.internal.compiler.util.Util.isClassFileName(resource.getName())) {
- // perform full build if a managed class file has been changed
- IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
- if (newState.isKnownType(typePath.toString())) {
- if (JavaBuilder.DEBUG)
- System.out.println("MUST DO FULL BUILD. Found change to class file " + typePath); //$NON-NLS-1$
- return false;
- }
- return true;
- }
- }
- return true;
-}
-
-protected void cleanUp() {
- super.cleanUp();
-
- this.sourceFiles = null;
- this.previousSourceFiles = null;
- this.qualifiedStrings = null;
- this.simpleStrings = null;
- this.secondaryTypesToRemove = null;
- this.hasStructuralChanges = false;
- this.compileLoop = 0;
-}
-
-protected void compile(SourceFile[] units, SourceFile[] additionalUnits, boolean compilingFirstGroup) {
- if (compilingFirstGroup && additionalUnits != null) {
- // add any source file from additionalUnits to units if it defines secondary types
- // otherwise its possible during testing with MAX_AT_ONCE == 1 that a secondary type
- // can cause an infinite loop as it alternates between not found and defined, see bug 146324
- ArrayList extras = null;
- for (int i = 0, l = additionalUnits.length; i < l; i++) {
- SourceFile unit = additionalUnits[i];
- if (unit != null && newState.getDefinedTypeNamesFor(unit.typeLocator()) != null) {
- if (JavaBuilder.DEBUG)
- System.out.println("About to compile file with secondary types "+ unit.typeLocator()); //$NON-NLS-1$
- if (extras == null)
- extras = new ArrayList(3);
- extras.add(unit);
- }
- }
- if (extras != null) {
- int oldLength = units.length;
- int toAdd = extras.size();
- System.arraycopy(units, 0, units = new SourceFile[oldLength + toAdd], 0, oldLength);
- for (int i = 0; i < toAdd; i++)
- units[oldLength++] = (SourceFile) extras.get(i);
- }
- }
- super.compile(units, additionalUnits, compilingFirstGroup);
-}
-
-protected void deleteGeneratedFiles(IFile[] deletedGeneratedFiles) {
- // delete generated files and recompile any affected source files
-// try {
- for (int j = deletedGeneratedFiles.length; --j >= 0;) {
- IFile deletedFile = deletedGeneratedFiles[j];
- if (deletedFile.exists()) continue; // only delete .class files for source files that were actually deleted
-
- SourceFile sourceFile = findSourceFile(deletedFile, false);
- String typeLocator = sourceFile.typeLocator();
- int mdSegmentCount = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount();
- IPath typePath = sourceFile.resource.getFullPath().removeFirstSegments(mdSegmentCount).removeFileExtension();
- addDependentsOf(typePath, true); // add dependents of the source file since its now deleted
- previousSourceFiles = null; // existing source files did not see it as deleted since they were compiled before it was
- char[][] definedTypeNames = newState.getDefinedTypeNamesFor(typeLocator);
-// if (definedTypeNames == null) { // defined a single type matching typePath
-// removeClassFile(typePath, sourceFile.sourceLocation.binaryFolder);
-// } else {
-// if (definedTypeNames.length > 0) { // skip it if it failed to successfully define a type
-// IPath packagePath = typePath.removeLastSegments(1);
-// for (int d = 0, l = definedTypeNames.length; d < l; d++)
-// removeClassFile(packagePath.append(new String(definedTypeNames[d])), sourceFile.sourceLocation.binaryFolder);
-// }
-// }
- this.newState.removeLocator(typeLocator);
- }
-// } catch (CoreException e) {
-// // must continue with compile loop so just log the CoreException
-// e.printStackTrace();
-// }
-}
-
-protected boolean findAffectedSourceFiles(IResourceDelta delta, ClasspathLocation[] classFoldersAndJars, IProject prereqProject) {
- for (int i = 0, l = classFoldersAndJars.length; i < l; i++) {
- ClasspathLocation bLocation = classFoldersAndJars[i];
- // either a .class file folder or a zip/jar file
- if (bLocation != null) { // skip unchanged output folder
- IPath p = bLocation.getProjectRelativePath();
- if (p != null) {
- IResourceDelta binaryDelta = delta.findMember(p);
- if (binaryDelta != null) {
- if (binaryDelta.getKind() == IResourceDelta.ADDED || binaryDelta.getKind() == IResourceDelta.REMOVED) {
- if (JavaBuilder.DEBUG)
- System.out.println("ABORTING incremental build... found added/removed binary folder"); //$NON-NLS-1$
- return false; // added/removed binary folder should not make it here (classpath change), but handle anyways
- }
- int segmentCount = binaryDelta.getFullPath().segmentCount();
- IResourceDelta[] children = binaryDelta.getAffectedChildren(); // .class files from class folder
- StringSet structurallyChangedTypes = null;
- if (bLocation.isOutputFolder())
- structurallyChangedTypes = this.newState.getStructurallyChangedTypes(javaBuilder.getLastState(prereqProject));
- for (int j = 0, m = children.length; j < m; j++)
- findAffectedSourceFiles(children[j], segmentCount, structurallyChangedTypes);
- notifier.checkCancel();
- }
- }
- }
- }
- return true;
-}
-
-protected void findAffectedSourceFiles(IResourceDelta binaryDelta, int segmentCount, StringSet structurallyChangedTypes) {
- // When a package becomes a type or vice versa, expect 2 deltas,
- // one on the folder & one on the class file
- IResource resource = binaryDelta.getResource();
- switch(resource.getType()) {
- case IResource.FOLDER :
- switch (binaryDelta.getKind()) {
- case IResourceDelta.ADDED :
- case IResourceDelta.REMOVED :
- IPath packagePath = resource.getFullPath().removeFirstSegments(segmentCount);
- String packageName = packagePath.toString();
- if (binaryDelta.getKind() == IResourceDelta.ADDED) {
- // see if any known source file is from the same package... classpath already includes new package
- if (!newState.isKnownPackage(packageName)) {
- if (JavaBuilder.DEBUG)
- System.out.println("Found added package " + packageName); //$NON-NLS-1$
- addDependentsOf(packagePath, false);
- return;
- }
- if (JavaBuilder.DEBUG)
- System.out.println("Skipped dependents of added package " + packageName); //$NON-NLS-1$
- } else {
- // see if the package still exists on the classpath
- if (!nameEnvironment.isPackage(packageName)) {
- if (JavaBuilder.DEBUG)
- System.out.println("Found removed package " + packageName); //$NON-NLS-1$
- addDependentsOf(packagePath, false);
- return;
- }
- if (JavaBuilder.DEBUG)
- System.out.println("Skipped dependents of removed package " + packageName); //$NON-NLS-1$
- }
- // fall thru & traverse the sub-packages and .class files
- case IResourceDelta.CHANGED :
- IResourceDelta[] children = binaryDelta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- findAffectedSourceFiles(children[i], segmentCount, structurallyChangedTypes);
- }
- return;
- case IResource.FILE :
- if (org.eclipse.wst.jsdt.internal.compiler.util.Util.isClassFileName(resource.getName())) {
- IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
- switch (binaryDelta.getKind()) {
- case IResourceDelta.ADDED :
- case IResourceDelta.REMOVED :
- if (JavaBuilder.DEBUG)
- System.out.println("Found added/removed class file " + typePath); //$NON-NLS-1$
- addDependentsOf(typePath, false);
- return;
- case IResourceDelta.CHANGED :
- if ((binaryDelta.getFlags() & IResourceDelta.CONTENT) == 0)
- return; // skip it since it really isn't changed
- if (structurallyChangedTypes != null && !structurallyChangedTypes.includes(typePath.toString()))
- return; // skip since it wasn't a structural change
- if (JavaBuilder.DEBUG)
- System.out.println("Found changed class file " + typePath); //$NON-NLS-1$
- addDependentsOf(typePath, false);
- }
- return;
- }
- }
-}
-
-protected boolean findSourceFiles(IResourceDelta delta) throws CoreException {
- ArrayList visited = this.makeOutputFolderConsistent ? new ArrayList(sourceLocations.length) : null;
- for (int i = 0, l = sourceLocations.length; i < l; i++) {
- ClasspathMultiDirectory md = sourceLocations[i];
- if (this.makeOutputFolderConsistent && md.hasIndependentOutputFolder && !visited.contains(md.binaryFolder)) {
- // even a project which acts as its own source folder can have an independent/nested output folder
- visited.add(md.binaryFolder);
- IResourceDelta binaryDelta = delta.findMember(md.binaryFolder.getProjectRelativePath());
- if (binaryDelta != null) {
- int segmentCount = binaryDelta.getFullPath().segmentCount();
- IResourceDelta[] children = binaryDelta.getAffectedChildren();
- for (int j = 0, m = children.length; j < m; j++)
- if (!checkForClassFileChanges(children[j], md, segmentCount))
- return false;
- }
- }
- if (md.sourceFolder.equals(javaBuilder.currentProject)) {
- // skip nested source & output folders when the project is a source folder
- int segmentCount = delta.getFullPath().segmentCount();
- IResourceDelta[] children = delta.getAffectedChildren();
- for (int j = 0, m = children.length; j < m; j++)
- if (!isExcludedFromProject(children[j].getFullPath()))
- if (!findSourceFiles(children[j], md, segmentCount))
- return false;
- } else {
- IResourceDelta sourceDelta = delta.findMember(md.sourceFolder.getProjectRelativePath());
- if (sourceDelta != null) {
- if (sourceDelta.getKind() == IResourceDelta.REMOVED) {
- if (JavaBuilder.DEBUG)
- System.out.println("ABORTING incremental build... found removed source folder"); //$NON-NLS-1$
- return false; // removed source folder should not make it here, but handle anyways (ADDED is supported)
- }
- int segmentCount = sourceDelta.getFullPath().segmentCount();
- IResourceDelta[] children = sourceDelta.getAffectedChildren();
- try {
- for (int j = 0, m = children.length; j < m; j++)
- if (!findSourceFiles(children[j], md, segmentCount))
- return false;
- } catch (CoreException e) {
- // catch the case that a package has been renamed and collides on disk with an as-yet-to-be-deleted package
- if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
- if (JavaBuilder.DEBUG)
- System.out.println("ABORTING incremental build... found renamed package"); //$NON-NLS-1$
- return false;
- }
- throw e; // rethrow
- }
- }
- }
- notifier.checkCancel();
- }
- return true;
-}
-
-protected boolean findSourceFiles(IResourceDelta sourceDelta, ClasspathMultiDirectory md, int segmentCount) throws CoreException {
- // When a package becomes a type or vice versa, expect 2 deltas,
- // one on the folder & one on the source file
- IResource resource = sourceDelta.getResource();
- // remember that if inclusion & exclusion patterns change then a full build is done
- boolean isExcluded = (md.exclusionPatterns != null || md.inclusionPatterns != null)
- && Util.isExcluded(resource, md.inclusionPatterns, md.exclusionPatterns);
- switch(resource.getType()) {
- case IResource.FOLDER :
- if (isExcluded && md.inclusionPatterns == null)
- return true; // no need to go further with this delta since its children cannot be included
-
- switch (sourceDelta.getKind()) {
- case IResourceDelta.ADDED :
- if (!isExcluded) {
- IPath addedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
- // add dependents even when the package thinks it exists to be on the safe side
- if (JavaBuilder.DEBUG)
- System.out.println("Found added package " + addedPackagePath); //$NON-NLS-1$
- addDependentsOf(addedPackagePath, true);
- }
- // fall thru & collect all the source files
- case IResourceDelta.CHANGED :
- IResourceDelta[] children = sourceDelta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- if (!findSourceFiles(children[i], md, segmentCount))
- return false;
- return true;
- case IResourceDelta.REMOVED :
- if (isExcluded) {
- // since this folder is excluded then there is nothing to delete (from this md), but must walk any included subfolders
- children = sourceDelta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- if (!findSourceFiles(children[i], md, segmentCount))
- return false;
- return true;
- }
- IPath removedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
- if (sourceLocations.length > 1) {
- for (int i = 0, l = sourceLocations.length; i < l; i++) {
- if (sourceLocations[i].sourceFolder.getFolder(removedPackagePath).exists()) {
- // only a package fragment was removed, same as removing multiple source files
- IResourceDelta[] removedChildren = sourceDelta.getAffectedChildren();
- for (int j = 0, m = removedChildren.length; j < m; j++)
- if (!findSourceFiles(removedChildren[j], md, segmentCount))
- return false;
- return true;
- }
- }
- }
- IFolder removedPackageFolder = md.binaryFolder.getFolder(removedPackagePath);
- if (removedPackageFolder.exists())
- removedPackageFolder.delete(IResource.FORCE, null);
- // add dependents even when the package thinks it does not exist to be on the safe side
- if (JavaBuilder.DEBUG)
- System.out.println("Found removed package " + removedPackagePath); //$NON-NLS-1$
- addDependentsOf(removedPackagePath, true);
- newState.removePackage(sourceDelta);
- }
- return true;
- case IResource.FILE :
- if (isExcluded) return true;
-
- String resourceName = resource.getName();
- if (org.eclipse.wst.jsdt.internal.core.util.Util.isJavaLikeFileName(resourceName)) {
- IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
- String typeLocator = resource.getProjectRelativePath().toString();
- switch (sourceDelta.getKind()) {
- case IResourceDelta.ADDED :
- if (JavaBuilder.DEBUG)
- System.out.println("Compile this added source file " + typeLocator); //$NON-NLS-1$
- sourceFiles.add(new SourceFile((IFile) resource, md, true));
- String typeName = typePath.toString();
- if (!newState.isDuplicateLocator(typeName, typeLocator)) { // adding dependents results in 2 duplicate errors
- if (JavaBuilder.DEBUG)
- System.out.println("Found added source file " + typeName); //$NON-NLS-1$
- addDependentsOf(typePath, true);
- }
- return true;
- case IResourceDelta.REMOVED :
- char[][] definedTypeNames = newState.getDefinedTypeNamesFor(typeLocator);
- if (definedTypeNames == null) { // defined a single type matching typePath
-// removeClassFile(typePath, md.binaryFolder);
- if ((sourceDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
- // remove problems and tasks for a compilation unit that is being moved (to another package or renamed)
- // if the target file is a compilation unit, the new cu will be recompiled
- // if the target file is a non-java resource, then markers are removed
- // see bug 2857
- IResource movedFile = javaBuilder.workspaceRoot.getFile(sourceDelta.getMovedToPath());
- JavaBuilder.removeProblemsAndTasksFor(movedFile);
- }
- } else {
- if (JavaBuilder.DEBUG)
- System.out.println("Found removed source file " + typePath.toString()); //$NON-NLS-1$
- addDependentsOf(typePath, true); // add dependents of the source file since it may be involved in a name collision
-// if (definedTypeNames.length > 0) { // skip it if it failed to successfully define a type
-// IPath packagePath = typePath.removeLastSegments(1);
-// for (int i = 0, l = definedTypeNames.length; i < l; i++)
-// removeClassFile(packagePath.append(new String(definedTypeNames[i])), md.binaryFolder);
-// }
- }
- newState.removeLocator(typeLocator);
- return true;
- case IResourceDelta.CHANGED :
- if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0
- && (sourceDelta.getFlags() & IResourceDelta.ENCODING) == 0)
- return true; // skip it since it really isn't changed
- if (JavaBuilder.DEBUG)
- System.out.println("Compile this changed source file " + typeLocator); //$NON-NLS-1$
- sourceFiles.add(new SourceFile((IFile) resource, md, true));
- }
- return true;
- } else if (org.eclipse.wst.jsdt.internal.compiler.util.Util.isClassFileName(resourceName)) {
- // perform full build if a managed class file has been changed
- if (this.makeOutputFolderConsistent) {
- IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
- if (newState.isKnownType(typePath.toString())) {
- if (JavaBuilder.DEBUG)
- System.out.println("MUST DO FULL BUILD. Found change to class file " + typePath); //$NON-NLS-1$
- return false;
- }
- }
- return true;
- } else if (md.hasIndependentOutputFolder) {
- if (javaBuilder.filterExtraResource(resource)) return true;
-
- // copy all other resource deltas to the output folder
- IPath resourcePath = resource.getFullPath().removeFirstSegments(segmentCount);
- IResource outputFile = md.binaryFolder.getFile(resourcePath);
- switch (sourceDelta.getKind()) {
- case IResourceDelta.ADDED :
- if (outputFile.exists()) {
- if (JavaBuilder.DEBUG)
- System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$
- outputFile.delete(IResource.FORCE, null);
- }
- if (JavaBuilder.DEBUG)
- System.out.println("Copying added file " + resourcePath); //$NON-NLS-1$
- return true;
- case IResourceDelta.REMOVED :
- if (outputFile.exists()) {
- if (JavaBuilder.DEBUG)
- System.out.println("Deleting removed file " + resourcePath); //$NON-NLS-1$
- outputFile.delete(IResource.FORCE, null);
- }
- return true;
- case IResourceDelta.CHANGED :
- if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0
- && (sourceDelta.getFlags() & IResourceDelta.ENCODING) == 0)
- return true; // skip it since it really isn't changed
- if (outputFile.exists()) {
- if (JavaBuilder.DEBUG)
- System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$
- outputFile.delete(IResource.FORCE, null);
- }
- if (JavaBuilder.DEBUG)
- System.out.println("Copying changed file " + resourcePath); //$NON-NLS-1$
- //createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure package exists in the output folder
- //resource.copy(outputFile.getFullPath(), IResource.FORCE | IResource.DERIVED, null);
- // Util.setReadOnly(outputFile, false); // just in case the original was read only
- }
- return true;
- }
- }
- return true;
-}
-
-protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames, ArrayList duplicateTypeNames) {
- char[][] previousTypeNames = newState.getDefinedTypeNamesFor(sourceLocator);
- if (previousTypeNames == null)
- previousTypeNames = new char[][] {mainTypeName};
- IPath packagePath = null;
- next : for (int i = 0, l = previousTypeNames.length; i < l; i++) {
- char[] previous = previousTypeNames[i];
- for (int j = 0, m = definedTypeNames.size(); j < m; j++)
- if (CharOperation.equals(previous, (char[]) definedTypeNames.get(j)))
- continue next;
-
- SourceFile sourceFile = (SourceFile) result.getCompilationUnit();
- if (packagePath == null) {
- int count = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount();
- packagePath = sourceFile.resource.getFullPath().removeFirstSegments(count).removeLastSegments(1);
- }
- if (secondaryTypesToRemove == null)
- this.secondaryTypesToRemove = new SimpleLookupTable();
- ArrayList types = (ArrayList) secondaryTypesToRemove.get(sourceFile.sourceLocation.binaryFolder);
- if (types == null)
- types = new ArrayList(definedTypeNames.size());
- types.add(packagePath.append(new String(previous)));
- secondaryTypesToRemove.put(sourceFile.sourceLocation.binaryFolder, types);
- }
- super.finishedWith(sourceLocator, result, mainTypeName, definedTypeNames, duplicateTypeNames);
-}
-
-//protected void removeClassFile(IPath typePath, IContainer outputFolder) throws CoreException {
-// if (typePath.lastSegment().indexOf('$') == -1) { // is not a nested type
-// newState.removeQualifiedTypeName(typePath.toString());
-// // add dependents even when the type thinks it does not exist to be on the safe side
-// if (JavaBuilder.DEBUG)
-// System.out.println("Found removed type " + typePath); //$NON-NLS-1$
-// addDependentsOf(typePath, true); // when member types are removed, their enclosing type is structurally changed
-// }
-// IFile classFile = outputFolder.getFile(typePath.addFileExtension(SuffixConstants.EXTENSION_class));
-// if (classFile.exists()) {
-// if (JavaBuilder.DEBUG)
-// System.out.println("Deleting class file of removed type " + typePath); //$NON-NLS-1$
-// classFile.delete(IResource.FORCE, null);
-// }
-//}
-
-//protected void removeSecondaryTypes() throws CoreException {
-// if (secondaryTypesToRemove != null) { // delayed deleting secondary types until the end of the compile loop
-// Object[] keyTable = secondaryTypesToRemove.keyTable;
-// Object[] valueTable = secondaryTypesToRemove.valueTable;
-// for (int i = 0, l = keyTable.length; i < l; i++) {
-// IContainer outputFolder = (IContainer) keyTable[i];
-// if (outputFolder != null) {
-// ArrayList paths = (ArrayList) valueTable[i];
-// for (int j = 0, m = paths.size(); j < m; j++)
-// removeClassFile((IPath) paths.get(j), outputFolder);
-// }
-// }
-// this.secondaryTypesToRemove = null;
-// if (previousSourceFiles != null)
-// this.previousSourceFiles = null; // cannot optimize recompile case when a secondary type is deleted, see 181269
-// }
-//}
-
-protected void resetCollections() {
- if (this.sourceFiles == null) {
- this.sourceFiles = new ArrayList(33);
- this.previousSourceFiles = null;
- this.qualifiedStrings = new StringSet(3);
- this.simpleStrings = new StringSet(3);
- this.hasStructuralChanges = false;
- this.compileLoop = 0;
- } else {
- this.previousSourceFiles = this.sourceFiles.isEmpty() ? null : (ArrayList) this.sourceFiles.clone();
-
- this.sourceFiles.clear();
- this.qualifiedStrings.clear();
- this.simpleStrings.clear();
- this.workQueue.clear();
- }
-}
-
-protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
- IMarker[] markers = JavaBuilder.getProblemsFor(sourceFile.resource);
- CategorizedProblem[] problems = result.getProblems();
- if (problems == null && markers.length == 0) return;
-
- notifier.updateProblemCounts(markers, problems);
- JavaBuilder.removeProblemsFor(sourceFile.resource);
- storeProblemsFor(sourceFile, problems);
-}
-
-protected void updateTasksFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
- IMarker[] markers = JavaBuilder.getTasksFor(sourceFile.resource);
- CategorizedProblem[] tasks = result.getTasks();
- if (tasks == null && markers.length == 0) return;
-
- JavaBuilder.removeTasksFor(sourceFile.resource);
- storeTasksFor(sourceFile, tasks);
-}
-
-public String toString() {
- return "incremental image builder for:\n\tnew state: " + newState; //$NON-NLS-1$
-}
-
-
-/* Debug helper
-
-static void dump(IResourceDelta delta) {
- StringBuffer buffer = new StringBuffer();
- IPath path = delta.getFullPath();
- for (int i = path.segmentCount(); --i > 0;)
- buffer.append(" ");
- switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- buffer.append('+');
- break;
- case IResourceDelta.REMOVED:
- buffer.append('-');
- break;
- case IResourceDelta.CHANGED:
- buffer.append('*');
- break;
- case IResourceDelta.NO_CHANGE:
- buffer.append('=');
- break;
- default:
- buffer.append('?');
- break;
- }
- buffer.append(path);
- System.out.println(buffer.toString());
- IResourceDelta[] children = delta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- dump(children[i]);
-}
-*/
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/JavaBuilder.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/JavaBuilder.java
deleted file mode 100644
index 5daa39ce..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/JavaBuilder.java
+++ /dev/null
@@ -1,778 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptModelMarker;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.core.compiler.ValidationParticipant;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleLookupTable;
-import org.eclipse.wst.jsdt.internal.core.ClasspathEntry;
-import org.eclipse.wst.jsdt.internal.core.JavaModel;
-import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
-import org.eclipse.wst.jsdt.internal.core.JavaProject;
-import org.eclipse.wst.jsdt.internal.core.util.Messages;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-public class JavaBuilder extends IncrementalProjectBuilder {
-
-IProject currentProject;
-JavaProject javaProject;
-IWorkspaceRoot workspaceRoot;
-ValidationParticipant[] participants;
-NameEnvironment nameEnvironment;
-SimpleLookupTable binaryLocationsPerProject; // maps a project to its binary resources (output folders, class folders, zip/jar files)
-public State lastState;
-BuildNotifier notifier;
-char[][] extraResourceFileFilters;
-String[] extraResourceFolderFilters;
-public static final String SOURCE_ID = "JSDT"; //$NON-NLS-1$
-
-public static boolean DEBUG = false;
-
-/**
- * A list of project names that have been built.
- * This list is used to reset the JavaModel.existingExternalFiles cache when a build cycle begins
- * so that deleted external jars are discovered.
- */
-static ArrayList builtProjects = null;
-
-public static IMarker[] getProblemsFor(IResource resource) {
- try {
- if (resource != null && resource.exists()) {
- IMarker[] markers = resource.findMarkers(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
- Set markerTypes = JavaModelManager.getJavaModelManager().validationParticipants.managedMarkerTypes();
- if (markerTypes.isEmpty()) return markers;
- ArrayList markerList = new ArrayList(5);
- for (int i = 0, length = markers.length; i < length; i++) {
- markerList.add(markers[i]);
- }
- Iterator iterator = markerTypes.iterator();
- while (iterator.hasNext()) {
- markers = resource.findMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE);
- for (int i = 0, length = markers.length; i < length; i++) {
- markerList.add(markers[i]);
- }
- }
- IMarker[] result;
- markerList.toArray(result = new IMarker[markerList.size()]);
- return result;
- }
- } catch (CoreException e) {
- // assume there are no problems
- }
- return new IMarker[0];
-}
-
-public static IMarker[] getTasksFor(IResource resource) {
- try {
- if (resource != null && resource.exists())
- return resource.findMarkers(IJavaScriptModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- // assume there are no tasks
- }
- return new IMarker[0];
-}
-
-/**
- * Hook allowing to initialize some static state before a complete build iteration.
- * This hook is invoked during PRE_AUTO_BUILD notification
- */
-public static void buildStarting() {
- // build is about to start
-}
-
-/**
- * Hook allowing to reset some static state after a complete build iteration.
- * This hook is invoked during POST_AUTO_BUILD notification
- */
-public static void buildFinished() {
- BuildNotifier.resetProblemCounters();
-}
-
-public static void removeProblemsFor(IResource resource) {
- try {
- if (resource != null && resource.exists()) {
- resource.deleteMarkers(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
-
- // delete managed markers
- Set markerTypes = JavaModelManager.getJavaModelManager().validationParticipants.managedMarkerTypes();
- if (markerTypes.size() == 0) return;
- Iterator iterator = markerTypes.iterator();
- while (iterator.hasNext())
- resource.deleteMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE);
- }
- } catch (CoreException e) {
- // assume there were no problems
- }
-}
-
-public static void removeTasksFor(IResource resource) {
- try {
- if (resource != null && resource.exists())
- resource.deleteMarkers(IJavaScriptModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- // assume there were no problems
- }
-}
-
-public static void removeProblemsAndTasksFor(IResource resource) {
- try {
- if (resource != null && resource.exists()) {
- resource.deleteMarkers(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
- resource.deleteMarkers(IJavaScriptModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
-
- // delete managed markers
- Set markerTypes = JavaModelManager.getJavaModelManager().validationParticipants.managedMarkerTypes();
- if (markerTypes.size() == 0) return;
- Iterator iterator = markerTypes.iterator();
- while (iterator.hasNext())
- resource.deleteMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE);
- }
- } catch (CoreException e) {
- // assume there were no problems
- }
-}
-
-public static State readState(IProject project, DataInputStream in) throws IOException {
- return State.read(project, in);
-}
-
-public static void writeState(Object state, DataOutputStream out) throws IOException {
- ((State) state).write(out);
-}
-
-protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) throws CoreException {
- this.currentProject = getProject();
- if (currentProject == null || !currentProject.isAccessible()) return new IProject[0];
-
- if (DEBUG)
- System.out.println("\nStarting build of " + currentProject.getName() //$NON-NLS-1$
- + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$
- this.notifier = new BuildNotifier(monitor, currentProject);
- notifier.begin();
- boolean ok = false;
- try {
- notifier.checkCancel();
- kind = initializeBuilder(kind, true);
-
- if (isWorthBuilding()) {
- if (kind == FULL_BUILD) {
- if (DEBUG)
- System.out.println("Performing full build as requested by user"); //$NON-NLS-1$
- buildAll();
- } else {
- if ((this.lastState = getLastState(currentProject)) == null) {
- if (DEBUG)
- System.out.println("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("Performing full build since classpath has changed"); //$NON-NLS-1$
- buildAll();
- } else if (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("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("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("Performing full build since there are structural deltas"); //$NON-NLS-1$
- buildAll();
- } else {
- if (DEBUG)
- System.out.println("Nothing to build since there are no source folders and no deltas"); //$NON-NLS-1$
- lastState.tagAsNoopBuild();
- }
- }
- }
- ok = true;
- }
- } catch (CoreException e) {
- Util.log(e, "JavaBuilder handling CoreException while building: " + currentProject.getName()); //$NON-NLS-1$
- IMarker marker = currentProject.createMarker(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaScriptModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage()),
- new Integer(IMarker.SEVERITY_ERROR),
- new Integer(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
- } catch (ImageBuilderInternalException e) {
- Util.log(e.getThrowable(), "JavaBuilder handling ImageBuilderInternalException while building: " + currentProject.getName()); //$NON-NLS-1$
- IMarker marker = currentProject.createMarker(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaScriptModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage()),
- new Integer(IMarker.SEVERITY_ERROR),
- new Integer(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
- } 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(currentProject); // make this the only problem for this project
- IMarker marker = currentProject.createMarker(IJavaScriptModelMarker.JAVASCRIPT_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 {
- if (!ok)
- // If the build failed, clear the previously built state, forcing a full build next time.
- clearLastState();
- notifier.done();
- cleanup();
- }
- IProject[] requiredProjects = getRequiredProjects(true);
- if (DEBUG)
- System.out.println("Finished build of " + currentProject.getName() //$NON-NLS-1$
- + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$
- return requiredProjects;
-}
-
-private void buildAll() {
- notifier.checkCancel();
- notifier.subTask(Messages.bind(Messages.build_preparingBuild, this.currentProject.getName()));
- if (DEBUG && lastState != null)
- System.out.println("Clearing last state : " + lastState); //$NON-NLS-1$
- clearLastState();
- BatchImageBuilder imageBuilder = new BatchImageBuilder(this, true);
- imageBuilder.build();
- recordNewState(imageBuilder.newState);
-}
-
-private void buildDeltas(SimpleLookupTable deltas) {
- notifier.checkCancel();
- notifier.subTask(Messages.bind(Messages.build_preparingBuild, this.currentProject.getName()));
- if (DEBUG && lastState != null)
- System.out.println("Clearing last state : " + lastState); //$NON-NLS-1$
- clearLastState(); // clear the previously built state so if the build fails, a full build will occur next time
- IncrementalImageBuilder imageBuilder = new IncrementalImageBuilder(this);
- if (imageBuilder.build(deltas)) {
- recordNewState(imageBuilder.newState);
- } else {
- if (DEBUG)
- System.out.println("Performing full build since incremental build failed"); //$NON-NLS-1$
- buildAll();
- }
-}
-
-protected void clean(IProgressMonitor monitor) throws CoreException {
- this.currentProject = getProject();
- if (currentProject == null || !currentProject.isAccessible()) return;
-
- if (DEBUG)
- System.out.println("\nCleaning " + currentProject.getName() //$NON-NLS-1$
- + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$
- this.notifier = new BuildNotifier(monitor, currentProject);
- notifier.begin();
- try {
- notifier.checkCancel();
-
- initializeBuilder(CLEAN_BUILD, true);
- if (DEBUG)
- System.out.println("Clearing last state as part of clean : " + lastState); //$NON-NLS-1$
- clearLastState();
- removeProblemsAndTasksFor(currentProject);
-// new BatchImageBuilder(this, false).cleanOutputFolders(false);
- } catch (CoreException e) {
- Util.log(e, "JavaBuilder handling CoreException while cleaning: " + currentProject.getName()); //$NON-NLS-1$
- IMarker marker = currentProject.createMarker(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_inconsistentProject, e.getLocalizedMessage()),
- new Integer(IMarker.SEVERITY_ERROR),
- JavaBuilder.SOURCE_ID
- }
- );
- } finally {
- notifier.done();
- cleanup();
- }
- if (DEBUG)
- System.out.println("Finished cleaning " + currentProject.getName() //$NON-NLS-1$
- + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$
-}
-
-private void cleanup() {
- this.participants = null;
- this.nameEnvironment = null;
- this.binaryLocationsPerProject = null;
- this.lastState = null;
- this.notifier = null;
- this.extraResourceFileFilters = null;
- this.extraResourceFolderFilters = null;
-}
-
-private void clearLastState() {
- JavaModelManager.getJavaModelManager().setLastBuiltState(currentProject, null);
-}
-
-boolean filterExtraResource(IResource resource) {
- if (extraResourceFileFilters != null) {
- char[] name = resource.getName().toCharArray();
- for (int i = 0, l = extraResourceFileFilters.length; i < l; i++)
- if (CharOperation.match(extraResourceFileFilters[i], name, true))
- return true;
- }
- if (extraResourceFolderFilters != null) {
- IPath path = resource.getProjectRelativePath();
- String pathName = path.toString();
- int count = path.segmentCount();
- if (resource.getType() == IResource.FILE) count--;
- for (int i = 0, l = extraResourceFolderFilters.length; i < l; i++)
- if (pathName.indexOf(extraResourceFolderFilters[i]) != -1)
- for (int j = 0; j < count; j++)
- if (extraResourceFolderFilters[i].equals(path.segment(j)))
- return true;
- }
- return false;
-}
-
-private SimpleLookupTable findDeltas() {
- notifier.subTask(Messages.bind(Messages.build_readingDelta, currentProject.getName()));
- IResourceDelta delta = getDelta(currentProject);
- SimpleLookupTable deltas = new SimpleLookupTable(3);
- if (delta != null) {
- if (delta.getKind() != IResourceDelta.NO_CHANGE) {
- if (DEBUG)
- System.out.println("Found source delta for: " + currentProject.getName()); //$NON-NLS-1$
- deltas.put(currentProject, delta);
- }
- } else {
- if (DEBUG)
- System.out.println("Missing delta for: " + currentProject.getName()); //$NON-NLS-1$
- notifier.subTask(""); //$NON-NLS-1$
- return null;
- }
-
- Object[] keyTable = binaryLocationsPerProject.keyTable;
- Object[] valueTable = binaryLocationsPerProject.valueTable;
- nextProject : for (int i = 0, l = keyTable.length; i < l; i++) {
- IProject p = (IProject) keyTable[i];
- if (p != null && p != currentProject) {
- State s = getLastState(p);
- if (!lastState.wasStructurallyChanged(p, s)) { // see if we can skip its delta
- if (s.wasNoopBuild())
- continue nextProject; // project has no source folders and can be skipped
- ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) valueTable[i];
- boolean canSkip = true;
- for (int j = 0, m = classFoldersAndJars.length; j < m; j++) {
- if (classFoldersAndJars[j].isOutputFolder())
- classFoldersAndJars[j] = null; // can ignore output folder since project was not structurally changed
- else
- canSkip = false;
- }
- if (canSkip) continue nextProject; // project has no structural changes in its output folders
- }
-
- notifier.subTask(Messages.bind(Messages.build_readingDelta, p.getName()));
- delta = getDelta(p);
- if (delta != null) {
- if (delta.getKind() != IResourceDelta.NO_CHANGE) {
- if (DEBUG)
- System.out.println("Found binary delta for: " + p.getName()); //$NON-NLS-1$
- deltas.put(p, delta);
- }
- } else {
- if (DEBUG)
- System.out.println("Missing delta for: " + p.getName()); //$NON-NLS-1$
- notifier.subTask(""); //$NON-NLS-1$
- return null;
- }
- }
- }
- notifier.subTask(""); //$NON-NLS-1$
- return deltas;
-}
-
-public State getLastState(IProject project) {
- return (State) JavaModelManager.getJavaModelManager().getLastBuiltState(project, notifier.monitor);
-}
-
-/* Return the list of projects for which it requires a resource delta. This builder's project
-* is implicitly included and need not be specified. Builders must re-specify the list
-* of interesting projects every time they are run as this is not carried forward
-* beyond the next build. Missing projects should be specified but will be ignored until
-* they are added to the workspace.
-*/
-private IProject[] getRequiredProjects(boolean includeBinaryPrerequisites) {
- if (javaProject == null || workspaceRoot == null) return new IProject[0];
-
- ArrayList projects = new ArrayList();
- try {
- IIncludePathEntry[] entries = javaProject.getExpandedClasspath();
- for (int i = 0, l = entries.length; i < l; i++) {
- IIncludePathEntry entry = entries[i];
- IPath path = entry.getPath();
- IProject p = null;
- switch (entry.getEntryKind()) {
- case IIncludePathEntry.CPE_PROJECT :
- p = workspaceRoot.getProject(path.lastSegment()); // missing projects are considered too
- if (((ClasspathEntry) entry).isOptional() && !JavaProject.hasJavaNature(p)) // except if entry is optional
- p = null;
- break;
- case IIncludePathEntry.CPE_LIBRARY :
- if (includeBinaryPrerequisites && path.segmentCount() > 1) {
- // some binary resources on the class path can come from projects that are not included in the project references
- IResource resource = workspaceRoot.findMember(path.segment(0));
- if (resource instanceof IProject)
- p = (IProject) resource;
- }
- }
- if (p != null && !projects.contains(p))
- projects.add(p);
- }
- } catch(JavaScriptModelException e) {
- return new IProject[0];
- }
- IProject[] result = new IProject[projects.size()];
- projects.toArray(result);
- return result;
-}
-
-boolean hasBuildpathErrors() throws CoreException {
-// IMarker[] markers = this.currentProject.findMarkers(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
-// for (int i = 0, l = markers.length; i < l; i++)
-// if (markers[i].getAttribute(IJavaScriptModelMarker.CATEGORY_ID, -1) == CategorizedProblem.CAT_BUILDPATH)
-// return true;
- return false;
-}
-
-private boolean hasClasspathChanged() {
- ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
- ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
- int newLength = newSourceLocations.length;
- int oldLength = oldSourceLocations.length;
- int n, o;
- for (n = o = 0; n < newLength && o < oldLength; n++, o++) {
- if (newSourceLocations[n].equals(oldSourceLocations[o])) continue; // checks source & output folders
- try {
- if (newSourceLocations[n].sourceFolder.members().length == 0) { // added new empty source folder
- o--;
- continue;
- }
- } catch (CoreException ignore) { // skip it
- }
- if (DEBUG) {
- System.out.println("New location: " + newSourceLocations[n] + "\n!= old location: " + oldSourceLocations[o]); //$NON-NLS-1$ //$NON-NLS-2$
- printLocations(newSourceLocations, oldSourceLocations);
- }
- return true;
- }
- while (n < newLength) {
- try {
- if (newSourceLocations[n].sourceFolder.members().length == 0) { // added new empty source folder
- n++;
- continue;
- }
- } catch (CoreException ignore) { // skip it
- }
- if (DEBUG) {
- System.out.println("Added non-empty source folder"); //$NON-NLS-1$
- printLocations(newSourceLocations, oldSourceLocations);
- }
- return true;
- }
- if (o < oldLength) {
- if (DEBUG) {
- System.out.println("Removed source folder"); //$NON-NLS-1$
- printLocations(newSourceLocations, oldSourceLocations);
- }
- return true;
- }
-
- ClasspathLocation[] newBinaryLocations = nameEnvironment.binaryLocations;
- ClasspathLocation[] oldBinaryLocations = lastState.binaryLocations;
- newLength = newBinaryLocations.length;
- oldLength = oldBinaryLocations.length;
- for (n = o = 0; n < newLength && o < oldLength; n++, o++) {
- if (newBinaryLocations[n].equals(oldBinaryLocations[o])) continue;
- if (DEBUG) {
- System.out.println("New location: " + newBinaryLocations[n] + "\n!= old location: " + oldBinaryLocations[o]); //$NON-NLS-1$ //$NON-NLS-2$
- printLocations(newBinaryLocations, oldBinaryLocations);
- }
- return true;
- }
- if (n < newLength || o < oldLength) {
- if (DEBUG) {
- System.out.println("Number of binary folders/jar files has changed:"); //$NON-NLS-1$
- printLocations(newBinaryLocations, oldBinaryLocations);
- }
- return true;
- }
- return false;
-}
-
-private boolean hasJavaBuilder(IProject project) throws CoreException {
- ICommand[] buildCommands = project.getDescription().getBuildSpec();
- for (int i = 0, l = buildCommands.length; i < l; i++)
- if (buildCommands[i].getBuilderName().equals(JavaScriptCore.BUILDER_ID))
- return true;
- return false;
-}
-
-private boolean hasStructuralDelta() {
- // handle case when currentProject has only .class file folders and/or jar files... no source/output folders
- IResourceDelta delta = getDelta(currentProject);
- if (delta != null && delta.getKind() != IResourceDelta.NO_CHANGE) {
- ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) binaryLocationsPerProject.get(currentProject);
- if (classFoldersAndJars != null) {
- for (int i = 0, l = classFoldersAndJars.length; i < l; i++) {
- ClasspathLocation classFolderOrJar = classFoldersAndJars[i]; // either a .class file folder or a zip/jar file
- if (classFolderOrJar != null) {
- IPath p = classFolderOrJar.getProjectRelativePath();
- if (p != null) {
- IResourceDelta binaryDelta = delta.findMember(p);
- if (binaryDelta != null && binaryDelta.getKind() != IResourceDelta.NO_CHANGE)
- return true;
- }
- }
- }
- }
- }
- return false;
-}
-
-private int initializeBuilder(int kind, boolean forBuild) throws CoreException {
- // some calls just need the nameEnvironment initialized so skip the rest
- this.javaProject = (JavaProject) JavaScriptCore.create(currentProject);
- this.workspaceRoot = currentProject.getWorkspace().getRoot();
-
- if (forBuild) {
- // cache the known participants for this project
- this.participants = JavaModelManager.getJavaModelManager().validationParticipants.getvalidationParticipants(this.javaProject);
- if (this.participants != null)
- for (int i = 0, l = this.participants.length; i < l; i++)
- if (this.participants[i].aboutToBuild(this.javaProject) == ValidationParticipant.NEEDS_FULL_BUILD)
- kind = FULL_BUILD;
-
- // Flush the existing external files cache if this is the beginning of a build cycle
- String projectName = currentProject.getName();
- if (builtProjects == null || builtProjects.contains(projectName)) {
- JavaModel.flushExternalFileCache();
- builtProjects = new ArrayList();
- }
- builtProjects.add(projectName);
- }
-
- this.binaryLocationsPerProject = new SimpleLookupTable(3);
- this.nameEnvironment = new NameEnvironment(workspaceRoot, javaProject, binaryLocationsPerProject, notifier);
-
- if (forBuild) {
- String filterSequence = javaProject.getOption(JavaScriptCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true);
- char[][] filters = filterSequence != null && filterSequence.length() > 0
- ? CharOperation.splitAndTrimOn(',', filterSequence.toCharArray())
- : null;
- if (filters == null) {
- this.extraResourceFileFilters = null;
- this.extraResourceFolderFilters = null;
- } else {
- int fileCount = 0, folderCount = 0;
- for (int i = 0, l = filters.length; i < l; i++) {
- char[] f = filters[i];
- if (f.length == 0) continue;
- if (f[f.length - 1] == '/') folderCount++; else fileCount++;
- }
- this.extraResourceFileFilters = new char[fileCount][];
- this.extraResourceFolderFilters = new String[folderCount];
- for (int i = 0, l = filters.length; i < l; i++) {
- char[] f = filters[i];
- if (f.length == 0) continue;
- if (f[f.length - 1] == '/')
- extraResourceFolderFilters[--folderCount] = new String(f, 0, f.length - 1);
- else
- extraResourceFileFilters[--fileCount] = f;
- }
- }
- }
- return kind;
-}
-
-private boolean isClasspathBroken(IIncludePathEntry[] classpath, IProject p) throws CoreException {
- IMarker[] markers = p.findMarkers(IJavaScriptModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
- for (int i = 0, l = markers.length; i < l; i++)
- if (markers[i].getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR)
- return true;
- return false;
-}
-
-private boolean isWorthBuilding() throws CoreException {
- boolean abortBuilds =
- JavaScriptCore.ABORT.equals(javaProject.getOption(JavaScriptCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true));
- if (!abortBuilds) return true;
-
- // Abort build only if there are classpath errors
- if (isClasspathBroken(javaProject.getRawIncludepath(), currentProject)) {
- if (DEBUG)
- System.out.println("Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$
-
- removeProblemsAndTasksFor(currentProject); // remove all compilation problems
-
- IMarker marker = currentProject.createMarker(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaScriptModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- Messages.build_abortDueToClasspathProblems,
- new Integer(IMarker.SEVERITY_ERROR),
- new Integer(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
- return false;
- }
-
- if (JavaScriptCore.WARNING.equals(javaProject.getOption(JavaScriptCore.CORE_INCOMPLETE_CLASSPATH, true)))
- return true;
-
- // make sure all prereq projects have valid build states... only when aborting builds since projects in cycles do not have build states
- // except for projects involved in a 'warning' cycle (see below)
- IProject[] requiredProjects = getRequiredProjects(false);
- for (int i = 0, l = requiredProjects.length; i < l; i++) {
- IProject p = requiredProjects[i];
- if (getLastState(p) == null) {
- // The prereq project has no build state: if this prereq project has a 'warning' cycle marker then allow build (see bug id 23357)
- JavaProject prereq = (JavaProject) JavaScriptCore.create(p);
- if (prereq.hasCycleMarker() && JavaScriptCore.WARNING.equals(javaProject.getOption(JavaScriptCore.CORE_CIRCULAR_CLASSPATH, true))) {
- if (DEBUG)
- System.out.println("Continued to build even though prereq project " + p.getName() //$NON-NLS-1$
- + " was not built since its part of a cycle"); //$NON-NLS-1$
- continue;
- }
- if (!hasJavaBuilder(p)) {
- if (DEBUG)
- System.out.println("Continued to build even though prereq project " + p.getName() //$NON-NLS-1$
- + " is not built by JavaBuilder"); //$NON-NLS-1$
- continue;
- }
- if (DEBUG)
- System.out.println("Aborted build because prereq project " + p.getName() //$NON-NLS-1$
- + " was not built"); //$NON-NLS-1$
-
- removeProblemsAndTasksFor(currentProject); // make this the only problem for this project
- IMarker marker = currentProject.createMarker(IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaScriptModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- isClasspathBroken(prereq.getRawIncludepath(), p)
- ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems, p.getName())
- : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()),
- new Integer(IMarker.SEVERITY_ERROR),
- new Integer(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
- return false;
- }
- }
- return true;
-}
-
-/*
- * Instruct the build manager that this project is involved in a cycle and
- * needs to propagate structural changes to the other projects in the cycle.
- */
-void mustPropagateStructuralChanges() {
- HashSet cycleParticipants = new HashSet(3);
- javaProject.updateCycleParticipants(new ArrayList(), cycleParticipants, workspaceRoot, new HashSet(3), null);
- IPath currentPath = javaProject.getPath();
- Iterator i= cycleParticipants.iterator();
- while (i.hasNext()) {
- IPath participantPath = (IPath) i.next();
- if (participantPath != currentPath) {
- IProject project = workspaceRoot.getProject(participantPath.segment(0));
- if (hasBeenBuilt(project)) {
- if (DEBUG)
- System.out.println("Requesting another build iteration since cycle participant " + project.getName() //$NON-NLS-1$
- + " has not yet seen some structural changes"); //$NON-NLS-1$
- needRebuild();
- return;
- }
- }
- }
-}
-
-private void printLocations(ClasspathLocation[] newLocations, ClasspathLocation[] oldLocations) {
- System.out.println("New locations:"); //$NON-NLS-1$
- for (int i = 0, length = newLocations.length; i < length; i++)
- System.out.println(" " + newLocations[i].debugPathString()); //$NON-NLS-1$
- System.out.println("Old locations:"); //$NON-NLS-1$
- for (int i = 0, length = oldLocations.length; i < length; i++)
- System.out.println(" " + oldLocations[i].debugPathString()); //$NON-NLS-1$
-}
-
-private void recordNewState(State state) {
- Object[] keyTable = binaryLocationsPerProject.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- IProject prereqProject = (IProject) keyTable[i];
- if (prereqProject != null && prereqProject != currentProject)
- state.recordStructuralDependency(prereqProject, getLastState(prereqProject));
- }
-
- if (DEBUG)
- System.out.println("Recording new state : " + state); //$NON-NLS-1$
- // state.dump();
- JavaModelManager.getJavaModelManager().setLastBuiltState(currentProject, state);
-}
-
-/**
- * String representation for debugging purposes
- */
-public String toString() {
- return currentProject == null
- ? "JavaBuilder for unknown project" //$NON-NLS-1$
- : "JavaBuilder for " + currentProject.getName(); //$NON-NLS-1$
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/MissingSourceFileException.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/MissingSourceFileException.java
deleted file mode 100644
index a5aff47c..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/MissingSourceFileException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-/**
- * Exception thrown when the build should be aborted because a source file is missing/empty.
- */
-public class MissingSourceFileException extends RuntimeException {
-
- protected String missingSourceFile;
- private static final long serialVersionUID = -1416609004971115719L; // backward compatible
-
-public MissingSourceFileException(String missingSourceFile) {
- this.missingSourceFile = missingSourceFile;
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameEnvironment.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameEnvironment.java
deleted file mode 100644
index 5dc5264c..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameEnvironment.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
-import org.eclipse.wst.jsdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.wst.jsdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.wst.jsdt.internal.compiler.impl.ITypeRequestor;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleLookupTable;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleSet;
-import org.eclipse.wst.jsdt.internal.compiler.util.SuffixConstants;
-import org.eclipse.wst.jsdt.internal.core.ClasspathEntry;
-import org.eclipse.wst.jsdt.internal.core.CompilationUnit;
-import org.eclipse.wst.jsdt.internal.core.JavaModel;
-import org.eclipse.wst.jsdt.internal.core.JavaProject;
-import org.eclipse.wst.jsdt.internal.core.SearchableEnvironment;
-
-public class NameEnvironment implements INameEnvironment, SuffixConstants {
-
-boolean isIncrementalBuild;
-ClasspathMultiDirectory[] sourceLocations;
-ClasspathLocation[] binaryLocations;
-BuildNotifier notifier;
-
-SimpleSet initialTypeNames; // assumed that each name is of the form "a/b/ClassName"
-SimpleLookupTable additionalUnits;
-SearchableEnvironment searchableEnvironment;
-
-NameEnvironment(IWorkspaceRoot root, JavaProject javaProject, SimpleLookupTable binaryLocationsPerProject, BuildNotifier notifier) throws CoreException {
- this.isIncrementalBuild = false;
- this.notifier = notifier;
- computeClasspathLocations(root, javaProject, binaryLocationsPerProject);
-// setNames(null, null);
- this.searchableEnvironment=javaProject.newSearchableNameEnvironment(new IJavaScriptUnit[0]);
-}
-
-public NameEnvironment(IJavaScriptProject javaProject) {
- this.isIncrementalBuild = false;
- try {
- computeClasspathLocations(javaProject.getProject().getWorkspace().getRoot(), (JavaProject) javaProject, null);
- } catch(CoreException e) {
- this.sourceLocations = new ClasspathMultiDirectory[0];
- this.binaryLocations = new ClasspathLocation[0];
- }
-// setNames(null, null);
- try {
- this.searchableEnvironment=javaProject.newSearchableNameEnvironment(new IJavaScriptUnit[0]);
- } catch (JavaScriptModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-}
-
-/* Some examples of resolved class path entries.
-* Remember to search class path in the order that it was defined.
-*
-* 1a. typical project with no source folders:
-* /Test[CPE_SOURCE][K_SOURCE] -> D:/eclipse.test/Test
-* 1b. project with source folders:
-* /Test/src1[CPE_SOURCE][K_SOURCE] -> D:/eclipse.test/Test/src1
-* /Test/src2[CPE_SOURCE][K_SOURCE] -> D:/eclipse.test/Test/src2
-* NOTE: These can be in any order & separated by prereq projects or libraries
-* 1c. project external to workspace (only detectable using getLocation()):
-* /Test/src[CPE_SOURCE][K_SOURCE] -> d:/eclipse.zzz/src
-* Need to search source folder & output folder
-*
-* 2. zip files:
-* D:/j9/lib/jclMax/classes.zip[CPE_LIBRARY][K_BINARY][sourcePath:d:/j9/lib/jclMax/source/source.zip]
-* -> D:/j9/lib/jclMax/classes.zip
-* ALWAYS want to take the library path as is
-*
-* 3a. prereq project (regardless of whether it has a source or output folder):
-* /Test[CPE_PROJECT][K_SOURCE] -> D:/eclipse.test/Test
-* ALWAYS want to append the output folder & ONLY search for .class files
-*/
-private void computeClasspathLocations(
- IWorkspaceRoot root,
- JavaProject javaProject,
- SimpleLookupTable binaryLocationsPerProject) throws CoreException {
-
- /* Update cycle marker */
- IMarker cycleMarker = javaProject.getCycleMarker();
- if (cycleMarker != null) {
- int severity = JavaScriptCore.ERROR.equals(javaProject.getOption(JavaScriptCore.CORE_CIRCULAR_CLASSPATH, true))
- ? IMarker.SEVERITY_ERROR
- : IMarker.SEVERITY_WARNING;
- if (severity != cycleMarker.getAttribute(IMarker.SEVERITY, severity))
- cycleMarker.setAttribute(IMarker.SEVERITY, severity);
- }
-
- IIncludePathEntry[] classpathEntries = javaProject.getExpandedClasspath();
- ArrayList sLocations = new ArrayList(classpathEntries.length);
- ArrayList bLocations = new ArrayList(classpathEntries.length);
- nextEntry : for (int i = 0, l = classpathEntries.length; i < l; i++) {
- ClasspathEntry entry = (ClasspathEntry) classpathEntries[i];
- IPath path = entry.getPath();
- Object target = JavaModel.getTarget(root, path, true);
- if (target == null) continue nextEntry;
-
- IIncludePathAttribute[] attribs = entry.getExtraAttributes();
-
- for(int k=0;attribs!=null && k<attribs.length;k++) {
- if(attribs[k].getName().equalsIgnoreCase("validate") && attribs[k].getValue().equalsIgnoreCase("false")) continue nextEntry; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- switch(entry.getEntryKind()) {
- case IIncludePathEntry.CPE_SOURCE :
- if (!(target instanceof IContainer)) continue nextEntry;
-
- IPath outputPath = entry.getOutputLocation() != null
- ? entry.getOutputLocation()
- : javaProject.getOutputLocation();
- IContainer outputFolder;
- if (outputPath.segmentCount() == 1) {
- outputFolder = javaProject.getProject();
- } else {
- outputFolder = root.getFolder(outputPath);
- if (!outputFolder.exists())
- createOutputFolder(outputFolder);
- }
- sLocations.add(
- ClasspathLocation.forSourceFolder((IContainer) target, outputFolder, entry.fullInclusionPatternChars(), entry.fullExclusionPatternChars()));
- continue nextEntry;
-
- case IIncludePathEntry.CPE_PROJECT :
- if (!(target instanceof IProject)) continue nextEntry;
- IProject prereqProject = (IProject) target;
- if (!JavaProject.hasJavaNature(prereqProject)) continue nextEntry; // if project doesn't have java nature or is not accessible
-
- JavaProject prereqJavaProject = (JavaProject) JavaScriptCore.create(prereqProject);
- IIncludePathEntry[] prereqClasspathEntries = prereqJavaProject.getRawIncludepath();
- ArrayList seen = new ArrayList();
- nextPrereqEntry: for (int j = 0, m = prereqClasspathEntries.length; j < m; j++) {
- IIncludePathEntry prereqEntry = prereqClasspathEntries[j];
- if (prereqEntry.getEntryKind() == IIncludePathEntry.CPE_SOURCE) {
- Object prereqTarget = JavaModel.getTarget(root, prereqEntry.getPath(), true);
- if (!(prereqTarget instanceof IContainer)) continue nextPrereqEntry;
- IPath prereqOutputPath = prereqJavaProject.getOutputLocation();
- IContainer binaryFolder = prereqOutputPath.segmentCount() == 1
- ? (IContainer) prereqProject
- : (IContainer) root.getFolder(prereqOutputPath);
- if (binaryFolder.exists() && !seen.contains(binaryFolder)) {
- seen.add(binaryFolder);
- ClasspathLocation bLocation = ClasspathLocation.forBinaryFolder(binaryFolder, true, entry.getAccessRuleSet());
- bLocations.add(bLocation);
- if (binaryLocationsPerProject != null) { // normal builder mode
- ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject.get(prereqProject);
- if (existingLocations == null) {
- existingLocations = new ClasspathLocation[] {bLocation};
- } else {
- int size = existingLocations.length;
- System.arraycopy(existingLocations, 0, existingLocations = new ClasspathLocation[size + 1], 0, size);
- existingLocations[size] = bLocation;
- }
- binaryLocationsPerProject.put(prereqProject, existingLocations);
- }
- }
- }
- }
- continue nextEntry;
-
- case IIncludePathEntry.CPE_LIBRARY :
- if(true) continue nextEntry;
- if (target instanceof IResource) {
- IResource resource = (IResource) target;
- ClasspathLocation bLocation = null;
-// if (resource instanceof IFile) {
-// if (!(org.eclipse.wst.jsdt.internal.compiler.util.Util.isClassFileName(path.lastSegment())))
-// continue nextEntry;
-// AccessRuleSet accessRuleSet =
-// (JavaScriptCore.IGNORE.equals(javaProject.getOption(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, true))
-// && JavaScriptCore.IGNORE.equals(javaProject.getOption(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, true)))
-// ? null
-// : entry.getAccessRuleSet();
-// bLocation = ClasspathLocation.forLibrary((IFile) resource, accessRuleSet);
-// } else if (resource instanceof IContainer) {
-// AccessRuleSet accessRuleSet =
-// (JavaScriptCore.IGNORE.equals(javaProject.getOption(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, true))
-// && JavaScriptCore.IGNORE.equals(javaProject.getOption(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, true)))
-// ? null
-// : entry.getAccessRuleSet();
-// bLocation = ClasspathLocation.forBinaryFolder((IContainer) target, false, accessRuleSet); // is library folder not output folder
-// }
-// bLocations.add(bLocation);
- if (binaryLocationsPerProject != null) { // normal builder mode
- IProject p = resource.getProject(); // can be the project being built
- ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject.get(p);
- if (existingLocations == null) {
- existingLocations = new ClasspathLocation[] {bLocation};
- } else {
- int size = existingLocations.length;
- System.arraycopy(existingLocations, 0, existingLocations = new ClasspathLocation[size + 1], 0, size);
- existingLocations[size] = bLocation;
- }
- binaryLocationsPerProject.put(p, existingLocations);
- }
- } else if (target instanceof File) {
- if (!(org.eclipse.wst.jsdt.internal.compiler.util.Util.isClassFileName(path.lastSegment())))
- continue nextEntry;
- AccessRuleSet accessRuleSet =
- (JavaScriptCore.IGNORE.equals(javaProject.getOption(JavaScriptCore.COMPILER_PB_FORBIDDEN_REFERENCE, true))
- && JavaScriptCore.IGNORE.equals(javaProject.getOption(JavaScriptCore.COMPILER_PB_DISCOURAGED_REFERENCE, true)))
- ? null
- : entry.getAccessRuleSet();
- bLocations.add(ClasspathLocation.forLibrary(path.toString(), accessRuleSet));
- }
- continue nextEntry;
- }
- }
-
- // now split the classpath locations... place the output folders ahead of the other .class file folders & jars
- ArrayList outputFolders = new ArrayList(1);
- this.sourceLocations = new ClasspathMultiDirectory[sLocations.size()];
- if (!sLocations.isEmpty()) {
- sLocations.toArray(this.sourceLocations);
-
- // collect the output folders, skipping duplicates
- next : for (int i = 0, l = sourceLocations.length; i < l; i++) {
- ClasspathMultiDirectory md = sourceLocations[i];
- IPath outputPath = md.binaryFolder.getFullPath();
- for (int j = 0; j < i; j++) { // compare against previously walked source folders
- if (outputPath.equals(sourceLocations[j].binaryFolder.getFullPath())) {
- md.hasIndependentOutputFolder = sourceLocations[j].hasIndependentOutputFolder;
- continue next;
- }
- }
- outputFolders.add(md);
-
- // also tag each source folder whose output folder is an independent folder & is not also a source folder
- for (int j = 0, m = sourceLocations.length; j < m; j++)
- if (outputPath.equals(sourceLocations[j].sourceFolder.getFullPath()))
- continue next;
- md.hasIndependentOutputFolder = true;
- }
- }
-
- // combine the output folders with the binary folders & jars... place the output folders before other .class file folders & jars
- this.binaryLocations = new ClasspathLocation[outputFolders.size() + bLocations.size()];
- int index = 0;
- for (int i = 0, l = outputFolders.size(); i < l; i++)
- this.binaryLocations[index++] = (ClasspathLocation) outputFolders.get(i);
- for (int i = 0, l = bLocations.size(); i < l; i++)
- this.binaryLocations[index++] = (ClasspathLocation) bLocations.get(i);
-}
-
-public void cleanup() {
-// this.initialTypeNames = null;
-// this.additionalUnits = null;
-// for (int i = 0, l = sourceLocations.length; i < l; i++)
-// sourceLocations[i].cleanup();
-// for (int i = 0, l = binaryLocations.length; i < l; i++)
-// binaryLocations[i].cleanup();
- this.searchableEnvironment=null;
-}
-
-private void createOutputFolder(IContainer outputFolder) throws CoreException {
- createParentFolder(outputFolder.getParent());
- ((IFolder) outputFolder).create(IResource.FORCE | IResource.DERIVED, true, null);
-}
-
-private void createParentFolder(IContainer parent) throws CoreException {
- if (!parent.exists()) {
- createParentFolder(parent.getParent());
- ((IFolder) parent).create(true, true, null);
- }
-}
-
-//private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName) {
-// if (this.notifier != null)
-// this.notifier.checkCancelWithinCompiler();
-//
-// if (this.initialTypeNames != null && this.initialTypeNames.includes(qualifiedTypeName)) {
-// if (isIncrementalBuild)
-// // catch the case that a type inside a source file has been renamed but other class files are looking for it
-// throw new AbortCompilation(true, new AbortIncrementalBuildException(qualifiedTypeName));
-// return null; // looking for a file which we know was provided at the beginning of the compilation
-// }
-//
-// if (this.additionalUnits != null && this.sourceLocations.length > 0) {
-// // if an additional source file is waiting to be compiled, answer it BUT not if this is a secondary type search
-// // if we answer X.js & it no longer defines Y then the binary type looking for Y will think the class path is wrong
-// // let the recompile loop fix up dependents when the secondary type Y has been deleted from X.js
-// SourceFile unit = (SourceFile) this.additionalUnits.get(qualifiedTypeName); // doesn't have file extension
-// if (unit != null)
-// return new NameEnvironmentAnswer(unit, null /*no access restriction*/);
-// }
-//
-// String qBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class;
-// String binaryFileName = qBinaryFileName;
-// String qPackageName = ""; //$NON-NLS-1$
-// if (qualifiedTypeName.length() > typeName.length) {
-// int typeNameStart = qBinaryFileName.length() - typeName.length - 6; // size of ".class"
-// qPackageName = qBinaryFileName.substring(0, typeNameStart - 1);
-// binaryFileName = qBinaryFileName.substring(typeNameStart);
-// }
-//
-// // NOTE: the output folders are added at the beginning of the binaryLocations
-// NameEnvironmentAnswer suggestedAnswer = null;
-// for (int i = 0, l = binaryLocations.length; i < l; i++) {
-// NameEnvironmentAnswer answer = binaryLocations[i].findClass(binaryFileName, qPackageName, qBinaryFileName);
-// if (answer != null) {
-// if (!answer.ignoreIfBetter()) {
-// if (answer.isBetter(suggestedAnswer))
-// return answer;
-// } else if (answer.isBetter(suggestedAnswer))
-// // remember suggestion and keep looking
-// suggestedAnswer = answer;
-// }
-// }
-// if (suggestedAnswer != null)
-// // no better answer was found
-// return suggestedAnswer;
-// return null;
-//}
-
-public NameEnvironmentAnswer findType(char[][] compoundName, ITypeRequestor requestor) {
-// if (compoundName != null)
-// return findClass(
-// new String(CharOperation.concatWith(compoundName, '/')),
-// compoundName[compoundName.length - 1]);
-// return null;
- return this.searchableEnvironment.findType(compoundName, requestor);
-}
-
-private SourceFile convertToSourceFile(CompilationUnit compilationUnit)
-{
- IPath path = compilationUnit.getPath();
- for (int i = 0; i < this.sourceLocations.length; i++) {
- IContainer srcFolder=sourceLocations[i].sourceFolder;
- if (srcFolder.getFullPath().isPrefixOf(path))
- {
- SourceFile sourceFile=new SourceFile((IFile)compilationUnit.getResource(),sourceLocations[i]);
- return sourceFile;
- }
- }
- return null;
-}
-
-private NameEnvironmentAnswer convertToSourceFile(NameEnvironmentAnswer answer)
-{
- if (answer==null )
- return answer;
-
- if (answer.getCompilationUnit() instanceof CompilationUnit) {
- CompilationUnit compilationUnit = (CompilationUnit) answer.getCompilationUnit();
- SourceFile sourceFile=convertToSourceFile(compilationUnit);
- if (sourceFile!=null)
- return new NameEnvironmentAnswer(sourceFile,answer.getAccessRestriction());
- }
- else if (answer.getCompilationUnits()!=null)
- {
- org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit[] compilationUnits = answer.getCompilationUnits();
- org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit[] newcompilationUnits =
- new org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit[compilationUnits.length];
- boolean newAnswer=false;
- for (int i = 0; i < compilationUnits.length; i++) {
- newcompilationUnits[i]=compilationUnits[i];
- if (compilationUnits[i] instanceof CompilationUnit) {
- SourceFile sourceFile=convertToSourceFile((CompilationUnit)compilationUnits[i]);
- if (sourceFile!=null)
- {
- newcompilationUnits[i]=sourceFile;
- newAnswer=true;
- }
-
- }
- }
- if (newAnswer)
- return new NameEnvironmentAnswer(newcompilationUnits,answer.getAccessRestriction());
- }
- return answer;
-}
-
-
-public NameEnvironmentAnswer findBinding(char[] bindingName, char[][] packageName, int type, ITypeRequestor requestor, boolean returnMultiple, String excludePath) {
- if (this.notifier != null)
- this.notifier.checkCancelWithinCompiler();
- NameEnvironmentAnswer answer= this.searchableEnvironment.findBinding(bindingName, packageName,type, requestor, returnMultiple, excludePath);
- answer=convertToSourceFile(answer);
- return answer;
-
-// String qBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class;
-// String binaryFileName = qBinaryFileName;
-// String qPackageName = ""; //$NON-NLS-1$
-// if (qualifiedTypeName.length() > typeName.length) {
-// int typeNameStart = qBinaryFileName.length() - typeName.length - 6; // size of ".class"
-// qPackageName = qBinaryFileName.substring(0, typeNameStart - 1);
-// binaryFileName = qBinaryFileName.substring(typeNameStart);
-// }
-//
- // NOTE: the output folders are added at the beginning of the binaryLocations
-// NameEnvironmentAnswer suggestedAnswer = null;
-// for (int i = 0, l = binaryLocations.length; i < l; i++) {
-// NameEnvironmentAnswer answer = binaryLocations[i].findClass(binaryFileName, qPackageName, qBinaryFileName);
-// if (answer != null) {
-// if (!answer.ignoreIfBetter()) {
-// if (answer.isBetter(suggestedAnswer))
-// return answer;
-// } else if (answer.isBetter(suggestedAnswer))
-// // remember suggestion and keep looking
-// suggestedAnswer = answer;
-// }
-// }
-// if (suggestedAnswer != null)
-// // no better answer was found
-// return suggestedAnswer;
-// return null;
-}
-
-public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, ITypeRequestor requestor) {
- return searchableEnvironment.findType( typeName,packageName, requestor);
-// if (typeName != null)
-// return findClass(
-// new String(CharOperation.concatWith(packageName, typeName, '/')),
-// typeName);
-// return null;
-}
-
-public boolean isPackage(char[][] compoundName, char[] packageName) {
- return searchableEnvironment.isPackage(compoundName,packageName);
-// return isPackage(new String(CharOperation.concatWith(compoundName, packageName, '/')));
-}
-
-public boolean isPackage(String qualifiedPackageName) {
- // NOTE: the output folders are added at the beginning of the binaryLocations
- for (int i = 0, l = binaryLocations.length; i < l; i++)
- if (binaryLocations[i].isPackage(qualifiedPackageName))
- return true;
- return false;
-}
-
-void setNames(String[] typeNames, SourceFile[] additionalFiles) {
- // convert the initial typeNames to a set
- if (typeNames == null) {
- this.initialTypeNames = null;
- } else {
- this.initialTypeNames = new SimpleSet(typeNames.length);
- for (int i = 0, l = typeNames.length; i < l; i++)
- this.initialTypeNames.add(typeNames[i]);
- }
- // map the additional source files by qualified type name
- if (additionalFiles == null) {
- this.additionalUnits = null;
- } else {
- this.additionalUnits = new SimpleLookupTable(additionalFiles.length);
- for (int i = 0, l = additionalFiles.length; i < l; i++) {
- SourceFile additionalUnit = additionalFiles[i];
- if (additionalUnit != null)
- this.additionalUnits.put(additionalUnit.initialTypeName, additionalFiles[i]);
- }
- }
-
- for (int i = 0, l = sourceLocations.length; i < l; i++)
- sourceLocations[i].reset();
- for (int i = 0, l = binaryLocations.length; i < l; i++)
- binaryLocations[i].reset();
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameSet.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameSet.java
deleted file mode 100644
index b8eb752b..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/NameSet.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-
-public final class NameSet {
-
-// to avoid using Enumerations, walk the individual values skipping nulls
-public char[][] names;
-public int elementSize; // number of elements in the table
-public int threshold;
-
-public NameSet(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.5f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.names = new char[extraRoom][];
-}
-
-public char[] add(char[] name) {
- int length = names.length;
- int index = CharOperation.hashCode(name) % length;
- char[] current;
- while ((current = names[index]) != null) {
- if (CharOperation.equals(current, name)) return current;
- if (++index == length) index = 0;
- }
- names[index] = name;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold) rehash();
- return name;
-}
-
-private void rehash() {
- NameSet newSet = new NameSet(elementSize * 2); // double the number of expected elements
- char[] current;
- for (int i = names.length; --i >= 0;)
- if ((current = names[i]) != null)
- newSet.add(current);
-
- this.names = newSet.names;
- this.elementSize = newSet.elementSize;
- this.threshold = newSet.threshold;
-}
-
-public String toString() {
- String s = ""; //$NON-NLS-1$
- char[] name;
- for (int i = 0, l = names.length; i < l; i++)
- if ((name = names[i]) != null)
- s += new String(name) + "\n"; //$NON-NLS-1$
- return s;
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ProblemFactory.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ProblemFactory.java
deleted file mode 100644
index 80fbb629..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ProblemFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.util.Locale;
-
-import org.eclipse.wst.jsdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleLookupTable;
-
-public class ProblemFactory extends DefaultProblemFactory {
-
-static SimpleLookupTable factories = new SimpleLookupTable(5);
-
-private ProblemFactory(Locale locale) {
- super(locale);
-}
-
-public static ProblemFactory getProblemFactory(Locale locale) {
- ProblemFactory factory = (ProblemFactory) factories.get(locale);
- if (factory == null)
- factories.put(locale, factory = new ProblemFactory(locale));
- return factory;
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/QualifiedNameSet.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/QualifiedNameSet.java
deleted file mode 100644
index 56970f7f..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/QualifiedNameSet.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-
-public class QualifiedNameSet {
-
-// to avoid using Enumerations, walk the individual values skipping nulls
-public char[][][] qualifiedNames;
-public int elementSize; // number of elements in the table
-public int threshold;
-
-public QualifiedNameSet(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.5f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.qualifiedNames = new char[extraRoom][][];
-}
-
-public char[][] add(char[][] qualifiedName) {
- int qLength = qualifiedName.length;
- if (qLength == 0) return CharOperation.NO_CHAR_CHAR;
-
- int length = qualifiedNames.length;
- int index = CharOperation.hashCode(qualifiedName[qLength - 1]) % length;
- char[][] current;
- while ((current = qualifiedNames[index]) != null) {
- if (CharOperation.equals(current, qualifiedName)) return current;
- if (++index == length) index = 0;
- }
- qualifiedNames[index] = qualifiedName;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold) rehash();
- return qualifiedName;
-}
-
-private void rehash() {
- QualifiedNameSet newSet = new QualifiedNameSet(elementSize * 2); // double the number of expected elements
- char[][] current;
- for (int i = qualifiedNames.length; --i >= 0;)
- if ((current = qualifiedNames[i]) != null)
- newSet.add(current);
-
- this.qualifiedNames = newSet.qualifiedNames;
- this.elementSize = newSet.elementSize;
- this.threshold = newSet.threshold;
-}
-
-public String toString() {
- String s = ""; //$NON-NLS-1$
- char[][] qualifiedName;
- for (int i = 0, l = qualifiedNames.length; i < l; i++)
- if ((qualifiedName = qualifiedNames[i]) != null)
- s += CharOperation.toString(qualifiedName) + "\n"; //$NON-NLS-1$
- return s;
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ReferenceCollection.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ReferenceCollection.java
deleted file mode 100644
index 2fc3745d..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ReferenceCollection.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Tim Hanson <thanson@bea.com> - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=137634
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.internal.compiler.lookup.TypeConstants;
-
-public class ReferenceCollection {
-
-char[][][] qualifiedNameReferences; // contains no simple names as in just 'a' which is kept in simpleNameReferences instead
-char[][] simpleNameReferences;
-
-protected ReferenceCollection(char[][][] qualifiedNameReferences, char[][] simpleNameReferences) {
- this.qualifiedNameReferences = internQualifiedNames(qualifiedNameReferences);
- this.simpleNameReferences = internSimpleNames(simpleNameReferences, true);
-}
-
-void addDependencies(String[] typeNameDependencies) {
- // if each qualified type name is already known then all of its subNames can be skipped
- // and its expected that very few qualified names in typeNameDependencies need to be added
- // but could always take 'p1.p2.p3.X' and make all qualified names 'p1' 'p1.p2' 'p1.p2.p3' 'p1.p2.p3.X', then intern
- char[][][] qNames = new char[typeNameDependencies.length][][];
- for (int i = typeNameDependencies.length; --i >= 0;)
- qNames[i] = CharOperation.splitOn('.', typeNameDependencies[i].toCharArray());
- qNames = internQualifiedNames(qNames);
-
- next : for (int i = qNames.length; --i >= 0;) {
- char[][] qualifiedTypeName = qNames[i];
- while (!includes(qualifiedTypeName)) {
- if (!includes(qualifiedTypeName[qualifiedTypeName.length - 1])) {
- int length = this.simpleNameReferences.length;
- System.arraycopy(this.simpleNameReferences, 0, this.simpleNameReferences = new char[length + 1][], 0, length);
- this.simpleNameReferences[length] = qualifiedTypeName[qualifiedTypeName.length - 1];
- }
- int length = this.qualifiedNameReferences.length;
- System.arraycopy(this.qualifiedNameReferences, 0, this.qualifiedNameReferences = new char[length + 1][][], 0, length);
- this.qualifiedNameReferences[length] = qualifiedTypeName;
-
- qualifiedTypeName = CharOperation.subarray(qualifiedTypeName, 0, qualifiedTypeName.length - 1);
- char[][][] temp = internQualifiedNames(new char[][][] {qualifiedTypeName});
- if (temp == EmptyQualifiedNames)
- continue next; // qualifiedTypeName is a well known name
- qualifiedTypeName = temp[0];
- }
- }
-}
-
-boolean includes(char[] simpleName) {
- for (int i = 0, l = simpleNameReferences.length; i < l; i++)
- if (simpleName == simpleNameReferences[i]) return true;
- return false;
-}
-
-boolean includes(char[][] qualifiedName) {
- for (int i = 0, l = qualifiedNameReferences.length; i < l; i++)
- if (qualifiedName == qualifiedNameReferences[i]) return true;
- return false;
-}
-
-boolean includes(char[][][] qualifiedNames, char[][] simpleNames) {
- // if either collection of names is null, it means it contained a well known name so we know it already has a match
- if (simpleNames == null || qualifiedNames == null) {
- if (simpleNames == null && qualifiedNames == null) {
- if (JavaBuilder.DEBUG)
- System.out.println("Found well known match"); //$NON-NLS-1$
- return true;
- } else if (qualifiedNames == null) {
- for (int i = 0, l = simpleNames.length; i < l; i++) {
- if (includes(simpleNames[i])) {
- if (JavaBuilder.DEBUG)
- System.out.println("Found match in well known package to " + new String(simpleNames[i])); //$NON-NLS-1$
- return true;
- }
- }
- } else {
- for (int i = 0, l = qualifiedNames.length; i < l; i++) {
- char[][] qualifiedName = qualifiedNames[i];
- if (qualifiedName.length == 1 ? includes(qualifiedName[0]) : includes(qualifiedName)) {
- if (JavaBuilder.DEBUG)
- System.out.println("Found well known match in " + CharOperation.toString(qualifiedName)); //$NON-NLS-1$
- return true;
- }
- }
- }
- } else {
- for (int i = 0, l = simpleNames.length; i < l; i++) {
- if (includes(simpleNames[i])) {
- for (int j = 0, m = qualifiedNames.length; j < m; j++) {
- char[][] qualifiedName = qualifiedNames[j];
- if (qualifiedName.length == 1 ? includes(qualifiedName[0]) : includes(qualifiedName)) {
- if (JavaBuilder.DEBUG)
- System.out.println("Found match in " + CharOperation.toString(qualifiedName) //$NON-NLS-1$
- + " to " + new String(simpleNames[i])); //$NON-NLS-1$
- return true;
- }
- }
- return false;
- }
- }
- }
- return false;
-}
-
-
-// When any type is compiled, its methods are verified for certain problems
-// the MethodVerifier requests 3 well known types which end up in the reference collection
-// having WellKnownQualifiedNames & WellKnownSimpleNames, saves every type 40 bytes
-// NOTE: These collections are sorted by length
-static final char[][][] WellKnownQualifiedNames = new char[][][] {
-// TypeConstants.JAVA_LANG_RUNTIMEEXCEPTION,
-// TypeConstants.JAVA_LANG_THROWABLE,
- TypeConstants.JAVA_LANG_OBJECT,
-// TypeConstants.JAVA_LANG,
-// new char[][] {TypeConstants.JAVA},
-// new char[][] {new char[] {'o', 'r', 'g'}},
-// new char[][] {new char[] {'c', 'o', 'm'}},
- CharOperation.NO_CHAR_CHAR}; // default package
-static final char[][] WellKnownSimpleNames = new char[][] {
-// TypeConstants.JAVA_LANG_RUNTIMEEXCEPTION[2],
-// TypeConstants.JAVA_LANG_THROWABLE[2],
- TypeConstants.JAVA_LANG_OBJECT[0],
-// TypeConstants.JAVA,
-// TypeConstants.LANG,
-// new char[] {'o', 'r', 'g'},
-// new char[] {'c', 'o', 'm'}
- };
-
-static final char[][][] EmptyQualifiedNames = new char[0][][];
-static final char[][] EmptySimpleNames = CharOperation.NO_CHAR_CHAR;
-
-// each array contains qualified char[][], one for size 2, 3, 4, 5, 6, 7 & the rest
-static final int MaxQualifiedNames = 7;
-static QualifiedNameSet[] InternedQualifiedNames = new QualifiedNameSet[MaxQualifiedNames];
-// each array contains simple char[], one for size 1 to 29 & the rest
-static final int MaxSimpleNames = 30;
-static NameSet[] InternedSimpleNames = new NameSet[MaxSimpleNames];
-static {
- for (int i = 0; i < MaxQualifiedNames; i++)
- InternedQualifiedNames[i] = new QualifiedNameSet(37);
- for (int i = 0; i < MaxSimpleNames; i++)
- InternedSimpleNames[i] = new NameSet(37);
-}
-
-static char[][][] internQualifiedNames(StringSet qualifiedStrings) {
- if (qualifiedStrings == null) return EmptyQualifiedNames;
- int length = qualifiedStrings.elementSize;
- if (length == 0) return EmptyQualifiedNames;
-
- char[][][] result = new char[length][][];
- String[] strings = qualifiedStrings.values;
- for (int i = 0, l = strings.length; i < l; i++)
- if (strings[i] != null)
- result[--length] = CharOperation.splitOn('/', strings[i].toCharArray());
- return internQualifiedNames(result);
-}
-
-static char[][][] internQualifiedNames(char[][][] qualifiedNames) {
- if (qualifiedNames == null) return EmptyQualifiedNames;
- int length = qualifiedNames.length;
- if (length == 0) return EmptyQualifiedNames;
-
- char[][][] keepers = new char[length][][];
- int index = 0;
- next : for (int i = 0; i < length; i++) {
- char[][] qualifiedName = qualifiedNames[i];
- int qLength = qualifiedName.length;
- for (int j = 0, m = WellKnownQualifiedNames.length; j < m; j++) {
- char[][] wellKnownName = WellKnownQualifiedNames[j];
- if (qLength > wellKnownName.length)
- break; // all remaining well known names are shorter
- if (CharOperation.equals(qualifiedName, wellKnownName))
- continue next;
- }
-
- // InternedQualifiedNames[0] is for the rest (> 7 & 1)
- // InternedQualifiedNames[1] is for size 2...
- // InternedQualifiedNames[6] is for size 7
- QualifiedNameSet internedNames = InternedQualifiedNames[qLength <= MaxQualifiedNames ? qLength - 1 : 0];
- qualifiedName = internSimpleNames(qualifiedName, false);
- keepers[index++] = internedNames.add(qualifiedName);
- }
- if (length > index) {
- if (index == 0) return EmptyQualifiedNames;
- System.arraycopy(keepers, 0, keepers = new char[index][][], 0, index);
- }
- return keepers;
-}
-
-static char[][] internSimpleNames(StringSet simpleStrings) {
- if (simpleStrings == null) return EmptySimpleNames;
- int length = simpleStrings.elementSize;
- if (length == 0) return EmptySimpleNames;
-
- char[][] result = new char[length][];
- String[] strings = simpleStrings.values;
- for (int i = 0, l = strings.length; i < l; i++)
- if (strings[i] != null)
- result[--length] = strings[i].toCharArray();
- return internSimpleNames(result, true);
-}
-
-static char[][] internSimpleNames(char[][] simpleNames, boolean removeWellKnown) {
- if (simpleNames == null) return EmptySimpleNames;
- int length = simpleNames.length;
- if (length == 0) return EmptySimpleNames;
-
- char[][] keepers = new char[length][];
- int index = 0;
- next : for (int i = 0; i < length; i++) {
- char[] name = simpleNames[i];
- int sLength = name.length;
- for (int j = 0, m = WellKnownSimpleNames.length; j < m; j++) {
- char[] wellKnownName = WellKnownSimpleNames[j];
- if (sLength > wellKnownName.length)
- break; // all remaining well known names are shorter
- if (CharOperation.equals(name, wellKnownName)) {
- if (!removeWellKnown)
- keepers[index++] = WellKnownSimpleNames[j];
- continue next;
- }
- }
-
- // InternedSimpleNames[0] is for the rest (> 29)
- // InternedSimpleNames[1] is for size 1...
- // InternedSimpleNames[29] is for size 29
- NameSet internedNames = InternedSimpleNames[sLength < MaxSimpleNames ? sLength : 0];
- keepers[index++] = internedNames.add(name);
- }
- if (length > index) {
- if (index == 0) return EmptySimpleNames;
- System.arraycopy(keepers, 0, keepers = new char[index][], 0, index);
- }
- return keepers;
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/SourceFile.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/SourceFile.java
deleted file mode 100644
index 6a653e8f..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/SourceFile.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.LibrarySuperType;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.wst.jsdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.wst.jsdt.internal.core.util.Util;
-
-public class SourceFile implements ICompilationUnit {
-
-public IFile resource;
-ClasspathMultiDirectory sourceLocation;
-String initialTypeName;
-boolean updateClassFile;
-
-public SourceFile(IFile resource, ClasspathMultiDirectory sourceLocation) {
- this.resource = resource;
- this.sourceLocation = sourceLocation;
- this.initialTypeName = extractTypeName();
- this.updateClassFile = false;
-}
-
-public SourceFile(IFile resource, ClasspathMultiDirectory sourceLocation, boolean updateClassFile) {
- this(resource, sourceLocation);
-
- this.updateClassFile = updateClassFile;
-}
-
-public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof SourceFile)) return false;
-
- SourceFile f = (SourceFile) o;
- return this.sourceLocation == f.sourceLocation && this.resource.getFullPath().equals(f.resource.getFullPath());
-}
-
-String extractTypeName() {
- // answer a String with the qualified type name for the source file in the form: 'p1/p2/A'
- IPath fullPath = this.resource.getFullPath();
- int resourceSegmentCount = fullPath.segmentCount();
- int sourceFolderSegmentCount = this.sourceLocation.sourceFolder.getFullPath().segmentCount();
- int charCount = (resourceSegmentCount - sourceFolderSegmentCount - 1);
- resourceSegmentCount--; // deal with the last segment separately
- for (int i = sourceFolderSegmentCount; i < resourceSegmentCount; i++)
- charCount += fullPath.segment(i).length();
- String lastSegment = fullPath.segment(resourceSegmentCount);
- int extensionIndex = Util.indexOfJavaLikeExtension(lastSegment);
- charCount += extensionIndex;
-
- char[] result = new char[charCount];
- int offset = 0;
- for (int i = sourceFolderSegmentCount; i < resourceSegmentCount; i++) {
- String segment = fullPath.segment(i);
- int size = segment.length();
- segment.getChars(0, size, result, offset);
- offset += size;
- result[offset++] = '/';
- }
- lastSegment.getChars(0, extensionIndex, result, offset);
- return new String(result);
-}
-
-public char[] getContents() {
-
- try {
- return Util.getResourceContentsAsCharArray(this.resource);
- } catch (CoreException e) {
- throw new AbortCompilation(true, new MissingSourceFileException(this.resource.getFullPath().toString()));
- }
-}
-
-/**
- * @see org.eclipse.wst.jsdt.internal.compiler.env.IDependent#getFileName()
- */
-public char[] getFileName() {
- return this.resource.getFullPath().toString().toCharArray(); // do not know what you want to return here
-}
-
-public char[] getMainTypeName() {
- char[] typeName = this.initialTypeName.toCharArray();
- int lastIndex = CharOperation.lastIndexOf('/', typeName);
- return CharOperation.subarray(typeName, lastIndex + 1, -1);
-}
-
-public char[][] getPackageName() {
- char[] typeName = this.initialTypeName.toCharArray();
- int lastIndex = CharOperation.lastIndexOf('/', typeName);
- return CharOperation.splitOn('/', typeName, 0, lastIndex);
-}
-public int hashCode() {
- return this.initialTypeName.hashCode();
-}
-String typeLocator() {
- return this.resource.getProjectRelativePath().toString();
-}
-
-public String toString() {
- return "SourceFile[" //$NON-NLS-1$
- + this.resource.getFullPath() + "]"; //$NON-NLS-1$
-}
-
-/* (non-Javadoc)
- * @see org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit#getCommonSuperType()
- */
-public LibrarySuperType getCommonSuperType() {
- IProject myProject = this.resource.getProject();
- IJavaScriptProject jp = JavaScriptCore.create(myProject);
- return jp.getCommonSuperType();
-}
-
-public String getInferenceID() {
- return null;
-}
-
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/State.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/State.java
deleted file mode 100644
index 1bc55b57..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/State.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.internal.compiler.env.AccessRule;
-import org.eclipse.wst.jsdt.internal.compiler.env.AccessRuleSet;
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleLookupTable;
-import org.eclipse.wst.jsdt.internal.core.ClasspathAccessRule;
-import org.eclipse.wst.jsdt.internal.core.JavaModelManager;
-
-public class State {
-// NOTE: this state cannot contain types that are not defined in this project
-
-String javaProjectName;
-ClasspathMultiDirectory[] sourceLocations;
-ClasspathLocation[] binaryLocations;
-// keyed by the project relative path of the type (ie. "src1/p1/p2/A.js"), value is a ReferenceCollection or an AdditionalTypeCollection
-SimpleLookupTable references;
-// keyed by qualified type name "p1/p2/A", value is the project relative path which defines this type "src1/p1/p2/A.js"
-public SimpleLookupTable typeLocators;
-
-int buildNumber;
-long lastStructuralBuildTime;
-SimpleLookupTable structuralBuildTimes;
-
-private String[] knownPackageNames; // of the form "p1/p2"
-
-private long previousStructuralBuildTime;
-private StringSet structurallyChangedTypes;
-public static int MaxStructurallyChangedTypes = 100; // keep track of ? structurally changed types, otherwise consider all to be changed
-
-public static final byte VERSION = 0x0015; // changed access rule presentation
-
-static final byte SOURCE_FOLDER = 1;
-static final byte BINARY_FOLDER = 2;
-static final byte EXTERNAL_JAR = 3;
-static final byte INTERNAL_JAR = 4;
-static final byte LIBRARY = 5;
-
-State() {
- // constructor with no argument
-}
-
-protected State(JavaBuilder javaBuilder) {
- this.knownPackageNames = null;
- this.previousStructuralBuildTime = -1;
- this.structurallyChangedTypes = null;
- this.javaProjectName = javaBuilder.currentProject.getName();
- this.sourceLocations = javaBuilder.nameEnvironment.sourceLocations;
- this.binaryLocations = javaBuilder.nameEnvironment.binaryLocations;
- this.references = new SimpleLookupTable(7);
- this.typeLocators = new SimpleLookupTable(7);
-
- this.buildNumber = 0; // indicates a full build
- this.lastStructuralBuildTime = computeStructuralBuildTime(javaBuilder.lastState == null ? 0 : javaBuilder.lastState.lastStructuralBuildTime);
- this.structuralBuildTimes = new SimpleLookupTable(3);
-}
-
-long computeStructuralBuildTime(long previousTime) {
- long newTime = System.currentTimeMillis();
- if (newTime <= previousTime)
- newTime = previousTime + 1;
- return newTime;
-}
-
-void copyFrom(State lastState) {
- this.knownPackageNames = null;
- this.previousStructuralBuildTime = lastState.previousStructuralBuildTime;
- this.structurallyChangedTypes = lastState.structurallyChangedTypes;
- this.buildNumber = lastState.buildNumber + 1;
- this.lastStructuralBuildTime = lastState.lastStructuralBuildTime;
- this.structuralBuildTimes = lastState.structuralBuildTimes;
-
- try {
- this.references = (SimpleLookupTable) lastState.references.clone();
- this.typeLocators = (SimpleLookupTable) lastState.typeLocators.clone();
- } catch (CloneNotSupportedException e) {
- this.references = new SimpleLookupTable(lastState.references.elementSize);
- Object[] keyTable = lastState.references.keyTable;
- Object[] valueTable = lastState.references.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- this.references.put(keyTable[i], valueTable[i]);
-
- this.typeLocators = new SimpleLookupTable(lastState.typeLocators.elementSize);
- keyTable = lastState.typeLocators.keyTable;
- valueTable = lastState.typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- this.typeLocators.put(keyTable[i], valueTable[i]);
- }
-}
-public char[][] getDefinedTypeNamesFor(String typeLocator) {
- Object c = references.get(typeLocator);
- if (c instanceof AdditionalTypeCollection)
- return ((AdditionalTypeCollection) c).definedTypeNames;
- return null; // means only one type is defined with the same name as the file... saves space
-}
-
-StringSet getStructurallyChangedTypes(State prereqState) {
- if (prereqState != null && prereqState.previousStructuralBuildTime > 0) {
- Object o = structuralBuildTimes.get(prereqState.javaProjectName);
- long previous = o == null ? 0 : ((Long) o).longValue();
- if (previous == prereqState.previousStructuralBuildTime)
- return prereqState.structurallyChangedTypes;
- }
- return null;
-}
-
-boolean isDuplicateLocator(String qualifiedTypeName, String typeLocator) {
- String existing = (String) typeLocators.get(qualifiedTypeName);
- return existing != null && !existing.equals(typeLocator);
-}
-
-boolean isKnownPackage(String qualifiedPackageName) {
- if (knownPackageNames == null) {
- ArrayList names = new ArrayList(typeLocators.elementSize);
- Object[] keyTable = typeLocators.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- String packageName = (String) keyTable[i]; // is a type name of the form p1/p2/A
- int last = packageName.lastIndexOf('/');
- packageName = last == -1 ? null : packageName.substring(0, last);
- while (packageName != null && !names.contains(packageName)) {
- names.add(packageName);
- last = packageName.lastIndexOf('/');
- packageName = last == -1 ? null : packageName.substring(0, last);
- }
- }
- }
- knownPackageNames = new String[names.size()];
- names.toArray(knownPackageNames);
- }
- for (int i = 0, l = knownPackageNames.length; i < l; i++)
- if (knownPackageNames[i].equals(qualifiedPackageName))
- return true;
- return false;
-}
-
-boolean isKnownType(String qualifiedTypeName) {
- return typeLocators.containsKey(qualifiedTypeName);
-}
-
-void record(String typeLocator, char[][][] qualifiedRefs, char[][] simpleRefs, char[] mainTypeName, ArrayList typeNames) {
- if (typeNames==null)
- typeNames=new ArrayList();
- if (typeNames.size() == 1 && CharOperation.equals(mainTypeName, (char[]) typeNames.get(0))) {
- references.put(typeLocator, new ReferenceCollection(qualifiedRefs, simpleRefs));
- } else {
- char[][] definedTypeNames = new char[typeNames.size()][]; // can be empty when no types are defined
- typeNames.toArray(definedTypeNames);
- references.put(typeLocator, new AdditionalTypeCollection(definedTypeNames, qualifiedRefs, simpleRefs));
- }
-}
-
-void recordLocatorForType(String qualifiedTypeName, String typeLocator) {
- this.knownPackageNames = null;
- // in the common case, the qualifiedTypeName is a substring of the typeLocator so share the char[] by using String.substring()
- int start = typeLocator.indexOf(qualifiedTypeName, 0);
- if (start > 0)
- qualifiedTypeName = typeLocator.substring(start, start + qualifiedTypeName.length());
- typeLocators.put(qualifiedTypeName, typeLocator);
-}
-
-void recordStructuralDependency(IProject prereqProject, State prereqState) {
- if (prereqState != null)
- if (prereqState.lastStructuralBuildTime > 0) // can skip if 0 (full build) since its assumed to be 0 if unknown
- structuralBuildTimes.put(prereqProject.getName(), new Long(prereqState.lastStructuralBuildTime));
-}
-
-void removeLocator(String typeLocatorToRemove) {
- this.knownPackageNames = null;
- references.removeKey(typeLocatorToRemove);
- typeLocators.removeValue(typeLocatorToRemove);
-}
-
-void removePackage(IResourceDelta sourceDelta) {
- IResource resource = sourceDelta.getResource();
- switch(resource.getType()) {
- case IResource.FOLDER :
- IResourceDelta[] children = sourceDelta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- removePackage(children[i]);
- return;
- case IResource.FILE :
- IPath typeLocatorPath = resource.getProjectRelativePath();
- if (org.eclipse.wst.jsdt.internal.core.util.Util.isJavaLikeFileName(typeLocatorPath.lastSegment()))
- removeLocator(typeLocatorPath.toString());
- }
-}
-
-void removeQualifiedTypeName(String qualifiedTypeNameToRemove) {
- this.knownPackageNames = null;
- typeLocators.removeKey(qualifiedTypeNameToRemove);
-}
-
-static State read(IProject project, DataInputStream in) throws IOException {
- if (JavaBuilder.DEBUG)
- System.out.println("About to read state " + project.getName()); //$NON-NLS-1$
- if (VERSION != in.readByte()) {
- if (JavaBuilder.DEBUG)
- System.out.println("Found non-compatible state version... answered null for " + project.getName()); //$NON-NLS-1$
- return null;
- }
-
- State newState = new State();
- newState.javaProjectName = in.readUTF();
- if (!project.getName().equals(newState.javaProjectName)) {
- if (JavaBuilder.DEBUG)
- System.out.println("Project's name does not match... answered null"); //$NON-NLS-1$
- return null;
- }
- newState.buildNumber = in.readInt();
- newState.lastStructuralBuildTime = in.readLong();
-
- int length = in.readInt();
- newState.sourceLocations = new ClasspathMultiDirectory[length];
- for (int i = 0; i < length; i++) {
- IContainer sourceFolder = project, outputFolder = project;
- String folderName;
- if ((folderName = in.readUTF()).length() > 0) sourceFolder = project.getFolder(folderName);
- if ((folderName = in.readUTF()).length() > 0) outputFolder = project.getFolder(folderName);
- ClasspathMultiDirectory md =
- (ClasspathMultiDirectory) ClasspathLocation.forSourceFolder(sourceFolder, outputFolder, readNames(in), readNames(in));
- if (in.readBoolean())
- md.hasIndependentOutputFolder = true;
- newState.sourceLocations[i] = md;
- }
-
- length = in.readInt();
- newState.binaryLocations = new ClasspathLocation[length];
- IWorkspaceRoot root = project.getWorkspace().getRoot();
- for (int i = 0; i < length; i++) {
- switch (in.readByte()) {
- case SOURCE_FOLDER :
- newState.binaryLocations[i] = newState.sourceLocations[in.readInt()];
- break;
- case BINARY_FOLDER :
- IPath path = new Path(in.readUTF());
- IContainer outputFolder = path.segmentCount() == 1
- ? (IContainer) root.getProject(path.toString())
- : (IContainer) root.getFolder(path);
- newState.binaryLocations[i] = ClasspathLocation.forBinaryFolder(outputFolder, in.readBoolean(), readRestriction(in));
- break;
- case EXTERNAL_JAR :
- newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF(), in.readLong(), readRestriction(in));
- break;
- case LIBRARY :
- newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF(), readRestriction(in));
- }
- }
-
- newState.structuralBuildTimes = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++)
- newState.structuralBuildTimes.put(in.readUTF(), new Long(in.readLong()));
-
- String[] internedTypeLocators = new String[length = in.readInt()];
- for (int i = 0; i < length; i++)
- internedTypeLocators[i] = in.readUTF();
-
- newState.typeLocators = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++)
- newState.recordLocatorForType(in.readUTF(), internedTypeLocators[in.readInt()]);
-
- char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(readNames(in), false);
- char[][][] internedQualifiedNames = new char[length = in.readInt()][][];
- for (int i = 0; i < length; i++) {
- int qLength = in.readInt();
- char[][] qName = new char[qLength][];
- for (int j = 0; j < qLength; j++)
- qName[j] = internedSimpleNames[in.readInt()];
- internedQualifiedNames[i] = qName;
- }
- internedQualifiedNames = ReferenceCollection.internQualifiedNames(internedQualifiedNames);
-
- newState.references = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++) {
- String typeLocator = internedTypeLocators[in.readInt()];
- ReferenceCollection collection = null;
- switch (in.readByte()) {
- case 1 :
- char[][] additionalTypeNames = readNames(in);
- char[][][] qualifiedNames = new char[in.readInt()][][];
- for (int j = 0, m = qualifiedNames.length; j < m; j++)
- qualifiedNames[j] = internedQualifiedNames[in.readInt()];
- char[][] simpleNames = new char[in.readInt()][];
- for (int j = 0, m = simpleNames.length; j < m; j++)
- simpleNames[j] = internedSimpleNames[in.readInt()];
- collection = new AdditionalTypeCollection(additionalTypeNames, qualifiedNames, simpleNames);
- break;
- case 2 :
- char[][][] qNames = new char[in.readInt()][][];
- for (int j = 0, m = qNames.length; j < m; j++)
- qNames[j] = internedQualifiedNames[in.readInt()];
- char[][] sNames = new char[in.readInt()][];
- for (int j = 0, m = sNames.length; j < m; j++)
- sNames[j] = internedSimpleNames[in.readInt()];
- collection = new ReferenceCollection(qNames, sNames);
- }
- newState.references.put(typeLocator, collection);
- }
- if (JavaBuilder.DEBUG)
- System.out.println("Successfully read state for " + newState.javaProjectName); //$NON-NLS-1$
- return newState;
-}
-
-private static char[] readName(DataInputStream in) throws IOException {
- int nLength = in.readInt();
- char[] name = new char[nLength];
- for (int j = 0; j < nLength; j++)
- name[j] = in.readChar();
- return name;
-}
-
-private static char[][] readNames(DataInputStream in) throws IOException {
- int length = in.readInt();
- char[][] names = new char[length][];
- for (int i = 0; i < length; i++)
- names[i] = readName(in);
- return names;
-}
-
-private static AccessRuleSet readRestriction(DataInputStream in) throws IOException {
- int length = in.readInt();
- if (length == 0) return null; // no restriction specified
- AccessRule[] accessRules = new AccessRule[length];
- for (int i = 0; i < length; i++) {
- char[] pattern = readName(in);
- int problemId = in.readInt();
- accessRules[i] = new ClasspathAccessRule(pattern, problemId);
- }
- JavaModelManager manager = JavaModelManager.getJavaModelManager();
- String[] messageTemplates = new String[AccessRuleSet.MESSAGE_TEMPLATES_LENGTH];
- for (int i = 0; i < AccessRuleSet.MESSAGE_TEMPLATES_LENGTH; i++) {
- messageTemplates[i] = manager.intern(in.readUTF());
- }
- AccessRuleSet accessRuleSet = new AccessRuleSet(accessRules, messageTemplates);
- return accessRuleSet;
-}
-
-void tagAsNoopBuild() {
- this.buildNumber = -1; // tag the project since it has no source folders and can be skipped
-}
-
-boolean wasNoopBuild() {
- return buildNumber == -1;
-}
-
-void tagAsStructurallyChanged() {
- this.previousStructuralBuildTime = this.lastStructuralBuildTime;
- this.structurallyChangedTypes = new StringSet(7);
- this.lastStructuralBuildTime = computeStructuralBuildTime(this.previousStructuralBuildTime);
-}
-
-boolean wasStructurallyChanged(IProject prereqProject, State prereqState) {
- if (prereqState != null) {
- Object o = structuralBuildTimes.get(prereqProject.getName());
- long previous = o == null ? 0 : ((Long) o).longValue();
- if (previous == prereqState.lastStructuralBuildTime) return false;
- }
- return true;
-}
-
-void wasStructurallyChanged(String typeName) {
- if (this.structurallyChangedTypes != null) {
- if (this.structurallyChangedTypes.elementSize > MaxStructurallyChangedTypes)
- this.structurallyChangedTypes = null; // too many to keep track of
- else
- this.structurallyChangedTypes.add(typeName);
- }
-}
-
-void write(DataOutputStream out) throws IOException {
- int length;
- Object[] keyTable;
- Object[] valueTable;
-
-/*
- * byte VERSION
- * String project name
- * int build number
- * int last structural build number
-*/
- out.writeByte(VERSION);
- out.writeUTF(javaProjectName);
- out.writeInt(buildNumber);
- out.writeLong(lastStructuralBuildTime);
-
-/*
- * ClasspathMultiDirectory[]
- * int id
- * String path(s)
-*/
- out.writeInt(length = sourceLocations.length);
- for (int i = 0; i < length; i++) {
- ClasspathMultiDirectory md = sourceLocations[i];
- out.writeUTF(md.sourceFolder.getProjectRelativePath().toString());
- out.writeUTF(md.binaryFolder.getProjectRelativePath().toString());
- writeNames(md.inclusionPatterns, out);
- writeNames(md.exclusionPatterns, out);
- out.writeBoolean(md.hasIndependentOutputFolder);
- }
-
-/*
- * ClasspathLocation[]
- * int id
- * String path(s)
-*/
- out.writeInt(length = binaryLocations.length);
- next : for (int i = 0; i < length; i++) {
- ClasspathLocation c = binaryLocations[i];
- if (c instanceof ClasspathMultiDirectory) {
- out.writeByte(SOURCE_FOLDER);
- for (int j = 0, m = sourceLocations.length; j < m; j++) {
- if (sourceLocations[j] == c) {
- out.writeInt(j);
- continue next;
- }
- }
- } else if (c instanceof ClasspathDirectory) {
- out.writeByte(BINARY_FOLDER);
- ClasspathDirectory cd = (ClasspathDirectory) c;
- out.writeUTF(cd.binaryFolder.getFullPath().toString());
- out.writeBoolean(cd.isOutputFolder);
- writeRestriction(cd.accessRuleSet, out);
- } else {
- ClasspathLibrary library = (ClasspathLibrary) c;
- out.writeByte(LIBRARY);
- out.writeUTF(library.filename);
- writeRestriction(library.accessRuleSet, out);
- }
- }
-
-/*
- * Structural build numbers table
- * String prereq project name
- * int last structural build number
-*/
- out.writeInt(length = structuralBuildTimes.elementSize);
- if (length > 0) {
- keyTable = structuralBuildTimes.keyTable;
- valueTable = structuralBuildTimes.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- out.writeUTF((String) keyTable[i]);
- out.writeLong(((Long) valueTable[i]).longValue());
- }
- }
- if (JavaBuilder.DEBUG && length != 0)
- System.out.println("structuralBuildNumbers table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * String[] Interned type locators
- */
- out.writeInt(length = references.elementSize);
- SimpleLookupTable internedTypeLocators = new SimpleLookupTable(length);
- if (length > 0) {
- keyTable = references.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- String key = (String) keyTable[i];
- out.writeUTF(key);
- internedTypeLocators.put(key, new Integer(internedTypeLocators.elementSize));
- }
- }
- if (JavaBuilder.DEBUG && length != 0)
- System.out.println("references table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * Type locators table
- * String type name
- * int interned locator id
- */
- out.writeInt(length = typeLocators.elementSize);
- if (length > 0) {
- keyTable = typeLocators.keyTable;
- valueTable = typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- out.writeUTF((String) keyTable[i]);
- Integer index = (Integer) internedTypeLocators.get(valueTable[i]);
- out.writeInt(index.intValue());
- }
- }
- if (JavaBuilder.DEBUG && length != 0)
- System.out.println("typeLocators table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * char[][][] Interned qualified names
- * char[][] Interned simple names
- */
- SimpleLookupTable internedQualifiedNames = new SimpleLookupTable(31);
- SimpleLookupTable internedSimpleNames = new SimpleLookupTable(31);
- valueTable = references.valueTable;
- for (int i = 0, l = valueTable.length; i < l; i++) {
- if (valueTable[i] != null) {
- ReferenceCollection collection = (ReferenceCollection) valueTable[i];
- char[][][] qNames = collection.qualifiedNameReferences;
- for (int j = 0, m = qNames.length; j < m; j++) {
- char[][] qName = qNames[j];
- if (!internedQualifiedNames.containsKey(qName)) { // remember the names have been interned
- internedQualifiedNames.put(qName, new Integer(internedQualifiedNames.elementSize));
- for (int k = 0, n = qName.length; k < n; k++) {
- char[] sName = qName[k];
- if (!internedSimpleNames.containsKey(sName)) // remember the names have been interned
- internedSimpleNames.put(sName, new Integer(internedSimpleNames.elementSize));
- }
- }
- }
- char[][] sNames = collection.simpleNameReferences;
- for (int j = 0, m = sNames.length; j < m; j++) {
- char[] sName = sNames[j];
- if (!internedSimpleNames.containsKey(sName)) // remember the names have been interned
- internedSimpleNames.put(sName, new Integer(internedSimpleNames.elementSize));
- }
- }
- }
- char[][] internedArray = new char[internedSimpleNames.elementSize][];
- Object[] simpleNames = internedSimpleNames.keyTable;
- Object[] positions = internedSimpleNames.valueTable;
- for (int i = positions.length; --i >= 0; ) {
- if (positions[i] != null) {
- int index = ((Integer) positions[i]).intValue();
- internedArray[index] = (char[]) simpleNames[i];
- }
- }
- writeNames(internedArray, out);
- // now write the interned qualified names as arrays of interned simple names
- char[][][] internedQArray = new char[internedQualifiedNames.elementSize][][];
- Object[] qualifiedNames = internedQualifiedNames.keyTable;
- positions = internedQualifiedNames.valueTable;
- for (int i = positions.length; --i >= 0; ) {
- if (positions[i] != null) {
- int index = ((Integer) positions[i]).intValue();
- internedQArray[index] = (char[][]) qualifiedNames[i];
- }
- }
- out.writeInt(length = internedQArray.length);
- for (int i = 0; i < length; i++) {
- char[][] qName = internedQArray[i];
- int qLength = qName.length;
- out.writeInt(qLength);
- for (int j = 0; j < qLength; j++) {
- Integer index = (Integer) internedSimpleNames.get(qName[j]);
- out.writeInt(index.intValue());
- }
- }
-
-/*
- * References table
- * int interned locator id
- * ReferenceCollection
-*/
- out.writeInt(length = references.elementSize);
- if (length > 0) {
- keyTable = references.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- Integer index = (Integer) internedTypeLocators.get(keyTable[i]);
- out.writeInt(index.intValue());
- ReferenceCollection collection = (ReferenceCollection) valueTable[i];
- if (collection instanceof AdditionalTypeCollection) {
- out.writeByte(1);
- AdditionalTypeCollection atc = (AdditionalTypeCollection) collection;
- writeNames(atc.definedTypeNames, out);
- } else {
- out.writeByte(2);
- }
- char[][][] qNames = collection.qualifiedNameReferences;
- int qLength = qNames.length;
- out.writeInt(qLength);
- for (int j = 0; j < qLength; j++) {
- index = (Integer) internedQualifiedNames.get(qNames[j]);
- out.writeInt(index.intValue());
- }
- char[][] sNames = collection.simpleNameReferences;
- int sLength = sNames.length;
- out.writeInt(sLength);
- for (int j = 0; j < sLength; j++) {
- index = (Integer) internedSimpleNames.get(sNames[j]);
- out.writeInt(index.intValue());
- }
- }
- }
- if (JavaBuilder.DEBUG && length != 0)
- System.out.println("references table is inconsistent"); //$NON-NLS-1$
- }
-}
-
-private void writeName(char[] name, DataOutputStream out) throws IOException {
- int nLength = name.length;
- out.writeInt(nLength);
- for (int j = 0; j < nLength; j++)
- out.writeChar(name[j]);
-}
-
-private void writeNames(char[][] names, DataOutputStream out) throws IOException {
- int length = names == null ? 0 : names.length;
- out.writeInt(length);
- for (int i = 0; i < length; i++)
- writeName(names[i], out);
-}
-
-private void writeRestriction(AccessRuleSet accessRuleSet, DataOutputStream out) throws IOException {
- if (accessRuleSet == null) {
- out.writeInt(0);
- } else {
- AccessRule[] accessRules = accessRuleSet.getAccessRules();
- int length = accessRules.length;
- out.writeInt(length);
- if (length != 0) {
- for (int i = 0; i < length; i++) {
- AccessRule accessRule = accessRules[i];
- writeName(accessRule.pattern, out);
- out.writeInt(accessRule.problemId);
- }
- for (int i = 0; i < AccessRuleSet.MESSAGE_TEMPLATES_LENGTH; i++)
- out.writeUTF(accessRuleSet.messageTemplates[i]);
- }
- }
-}
-
-/**
- * Returns a string representation of the receiver.
- */
-public String toString() {
- return "State for " + javaProjectName //$NON-NLS-1$
- + " (#" + buildNumber //$NON-NLS-1$
- + " @ " + new Date(lastStructuralBuildTime) //$NON-NLS-1$
- + ")"; //$NON-NLS-1$
-}
-
-/* Debug helper
-void dump() {
- System.out.println("State for " + javaProjectName + " (" + buildNumber + " @ " + new Date(lastStructuralBuildTime) + ")");
- System.out.println("\tClass path source locations:");
- for (int i = 0, l = sourceLocations.length; i < l; i++)
- System.out.println("\t\t" + sourceLocations[i]);
- System.out.println("\tClass path binary locations:");
- for (int i = 0, l = binaryLocations.length; i < l; i++)
- System.out.println("\t\t" + binaryLocations[i]);
-
- System.out.print("\tStructural build numbers table:");
- if (structuralBuildTimes.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = structuralBuildTimes.keyTable;
- Object[] valueTable = structuralBuildTimes.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
- }
-
- System.out.print("\tType locators table:");
- if (typeLocators.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = typeLocators.keyTable;
- Object[] valueTable = typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
- }
-
- System.out.print("\n\tReferences table:");
- if (references.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = references.keyTable;
- Object[] valueTable = references.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- System.out.print("\n\t\t" + keyTable[i].toString());
- ReferenceCollection c = (ReferenceCollection) valueTable[i];
- char[][][] qRefs = c.qualifiedNameReferences;
- System.out.print("\n\t\t\tqualified:");
- if (qRefs.length == 0)
- System.out.print(" <empty>");
- else for (int j = 0, m = qRefs.length; j < m; j++)
- System.out.print(" '" + CharOperation.toString(qRefs[j]) + "'");
- char[][] sRefs = c.simpleNameReferences;
- System.out.print("\n\t\t\tsimple:");
- if (sRefs.length == 0)
- System.out.print(" <empty>");
- else for (int j = 0, m = sRefs.length; j < m; j++)
- System.out.print(" " + new String(sRefs[j]));
- if (c instanceof AdditionalTypeCollection) {
- char[][] names = ((AdditionalTypeCollection) c).definedTypeNames;
- System.out.print("\n\t\t\tadditional type names:");
- for (int j = 0, m = names.length; j < m; j++)
- System.out.print(" " + new String(names[j]));
- }
- }
- }
- }
- System.out.print("\n\n");
-}
-*/
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/StringSet.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/StringSet.java
deleted file mode 100644
index 56c5a5cc..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/StringSet.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-public class StringSet {
-
-// to avoid using Enumerations, walk the individual values skipping nulls
-public String[] values;
-public int elementSize; // number of elements in the table
-public int threshold;
-
-public StringSet(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.5f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.values = new String[extraRoom];
-}
-
-public boolean add(String value) {
- int length = this.values.length;
- int index = (value.hashCode() & 0x7FFFFFFF) % length;
- String current;
- while ((current = this.values[index]) != null) {
- if (value.equals(current)) return false; // did not add it since it already existed
- if (++index == length) index = 0;
- }
- this.values[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold) rehash();
- return true;
-}
-
-public void clear() {
- for (int i = this.values.length; --i >= 0;)
- this.values[i] = null;
- this.elementSize = 0;
-}
-
-public boolean includes(String value) {
- int length = values.length;
- int index = (value.hashCode() & 0x7FFFFFFF) % length;
- String current;
- while ((current = this.values[index]) != null) {
- if (value.equals(current)) return true;
- if (++index == length) index = 0;
- }
- return false;
-}
-
-private void rehash() {
- StringSet newSet = new StringSet(elementSize * 2); // double the number of expected elements
- String current;
- for (int i = this.values.length; --i >= 0;)
- if ((current = this.values[i]) != null)
- newSet.add(current);
-
- this.values = newSet.values;
- this.elementSize = newSet.elementSize;
- this.threshold = newSet.threshold;
-}
-
-public String toString() {
- String s = ""; //$NON-NLS-1$
- String value;
- for (int i = 0, l = this.values.length; i < l; i++)
- if ((value = this.values[i]) != null)
- s += value + "\n"; //$NON-NLS-1$
- return s;
-}
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ValidationParticipantResult.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ValidationParticipantResult.java
deleted file mode 100644
index 15178bb3..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/ValidationParticipantResult.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - rewrote spec
- *
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
-
-public class ValidationParticipantResult {
- protected SourceFile sourceFile;
- protected IFile[] addedFiles; // added/changed generated source files that need to be compiled
- protected IFile[] deletedFiles; // previously generated source files that should be deleted
- protected CategorizedProblem[] problems; // new problems to report against this compilationUnit
- protected String[] dependencies; // fully-qualified type names of any new dependencies, each name is of the form 'p1.p2.A.B'
-
-protected ValidationParticipantResult(SourceFile sourceFile) {
- this.sourceFile = sourceFile;
- this.addedFiles = null;
- this.deletedFiles = null;
- this.problems = null;
- this.dependencies = null;
-}
-
-void reset() {
- this.addedFiles = null;
- this.deletedFiles = null;
- this.problems = null;
- this.dependencies = null;
-}
-
-public String toString() {
- return this.sourceFile.toString();
-}
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/WorkQueue.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/WorkQueue.java
deleted file mode 100644
index b578dec0..00000000
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/builder/WorkQueue.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.internal.core.builder;
-
-import org.eclipse.wst.jsdt.internal.compiler.util.SimpleSet;
-
-public class WorkQueue {
-
-private SimpleSet needsCompileList;
-private SimpleSet compiledList;
-
-public WorkQueue() {
- this.needsCompileList = new SimpleSet();
- this.compiledList = new SimpleSet();
-}
-
-public void add(SourceFile element) {
- needsCompileList.add(element);
-}
-
-public void addAll(SourceFile[] elements) {
- for (int i = 0, l = elements.length; i < l; i++)
- add(elements[i]);
-}
-
-public void clear() {
- this.needsCompileList.clear();
- this.compiledList.clear();
-}
-
-public void finished(SourceFile element) {
- needsCompileList.remove(element);
- compiledList.add(element);
-}
-
-public boolean isCompiled(SourceFile element) {
- return compiledList.includes(element);
-}
-
-public boolean isWaiting(SourceFile element) {
- return needsCompileList.includes(element);
-}
-
-public String toString() {
- return "WorkQueue: " + needsCompileList; //$NON-NLS-1$
-}
-}

Back to the top