diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java index bd0fd00a033..196a94eccb0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java @@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; +import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; @@ -433,4 +434,46 @@ public class BuilderFactory { return EMPTY_BUILDERS_ARRAY; } + public static int applyBuilder(IProjectDescription eDes, IBuilder builder){ + return applyBuilder(eDes, CommonBuilder.BUILDER_ID, builder); + } + + public static final int CMD_UNDEFINED = -1; + public static final int NO_CHANGES = 0; + public static final int CMD_CHANGED = 1; + + private static int applyBuilder(IProjectDescription eDes, String eBuilderId, IBuilder builder){ + ICommand cmd = ManagedCProjectNature.getBuildSpec(eDes, eBuilderId); + if(cmd == null) + return CMD_UNDEFINED; + + if(applyBuilder(cmd, builder)){ + ManagedCProjectNature.setBuildSpec(eDes, cmd); + return CMD_CHANGED; + } + return NO_CHANGES; + } + + private static boolean applyBuilder(ICommand cmd, IBuilder builder) { + boolean changesMade = false; + + if(cmd.isBuilding(IncrementalProjectBuilder.AUTO_BUILD) != builder.isAutoBuildEnable()) { + cmd.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, builder.isAutoBuildEnable()); + changesMade = true; + } + if(cmd.isBuilding(IncrementalProjectBuilder.FULL_BUILD) != builder.isFullBuildEnabled()) { + cmd.setBuilding(IncrementalProjectBuilder.FULL_BUILD, builder.isFullBuildEnabled()); + changesMade = true; + } + if(cmd.isBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD) != builder.isIncrementalBuildEnabled()) { + cmd.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, builder.isIncrementalBuildEnabled()); + changesMade = true; + } + if(cmd.isBuilding(IncrementalProjectBuilder.CLEAN_BUILD) != builder.isCleanBuildEnabled()) { + cmd.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, builder.isCleanBuildEnabled()); + changesMade = true; + } + return changesMade; + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java index eae4fbff647..2e198a9c3aa 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java @@ -34,6 +34,7 @@ import org.eclipse.cdt.core.settings.model.IModificationContext; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider; import org.eclipse.cdt.managedbuilder.core.BuildException; +import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IFolderInfo; import org.eclipse.cdt.managedbuilder.core.IInputType; @@ -47,6 +48,7 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.internal.core.Builder; +import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory; import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener; import org.eclipse.cdt.managedbuilder.internal.core.InputType; @@ -57,6 +59,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.SettingsChangeEvent; import org.eclipse.cdt.managedbuilder.internal.core.Tool; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.QualifiedName; @@ -85,6 +88,28 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem } } + private static class DesApplyRunnable implements IWorkspaceRunnable { + IBuilder fBuilder; + IProject fProject; + + DesApplyRunnable(IProject project, IBuilder builder){ + fProject = project; + fBuilder = builder; + } + + @Override + public void run(IProgressMonitor monitor) throws CoreException { + try { + IProjectDescription eDes = fProject.getDescription(); + if(BuilderFactory.applyBuilder(eDes, fBuilder) == BuilderFactory.CMD_CHANGED) { + fProject.setDescription(eDes, monitor); + } + } catch (Exception e){ + ManagedBuilderCorePlugin.log(e); + } + } + + } static BuildConfigurationData writeConfiguration(ICConfigurationDescription cfgDescription, BuildConfigurationData base) throws CoreException { BuildConfigurationData appliedCfg = base; @@ -159,6 +184,23 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem setPersistedFlag(cfgDescription); cacheNaturesIdsUsedOnCache(cfgDescription); } + + if(cfgDescription.isActive()){ + IConfiguration cfg = appliedCfg.getConfiguration(); + IBuilder builder = cfg.getEditableBuilder(); + IProject project = context.getProject(); + IProjectDescription eDes = context.getEclipseProjectDescription(); + switch(BuilderFactory.applyBuilder(eDes, builder)){ + case BuilderFactory.CMD_UNDEFINED: + IWorkspaceRunnable applyR = new DesApplyRunnable(project, builder); + context.addWorkspaceRunnable(applyR); + break; + case BuilderFactory.CMD_CHANGED: + context.setEclipseProjectDescription(eDes); + break; + } + } + return appliedCfg; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/DBStatus.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/DBStatus.java index 1f9d4e131cb..94fd4bf1d76 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/DBStatus.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/DBStatus.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation + * QNX - Initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.db; import java.io.IOException; @@ -19,15 +18,12 @@ import org.eclipse.core.runtime.Status; /** * @author Doug Schaefer - * */ public class DBStatus extends Status { - /** * @param exception */ public DBStatus(IOException exception) { super(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "IOException", exception); //$NON-NLS-1$ } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IString.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IString.java index c2368730a4d..b93e01e9228 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IString.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/IString.java @@ -10,7 +10,6 @@ * Andrew Ferguson (Symbian) * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.db; import org.eclipse.core.runtime.CoreException; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java index 6b9751836b2..963a1d2977c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java @@ -10,7 +10,6 @@ * Andrew Ferguson (Symbian) * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.db; import org.eclipse.cdt.core.CCorePlugin; @@ -47,8 +46,8 @@ public class LongString implements IString { } public LongString(Database db, final char[] chars, boolean useBytes) throws CoreException { - final int numChars1 = useBytes ? NUM_CHARS1*2 : NUM_CHARS1; - final int numCharsn = useBytes ? NUM_CHARSN*2 : NUM_CHARSN; + final int numChars1 = useBytes ? NUM_CHARS1 * 2 : NUM_CHARS1; + final int numCharsn = useBytes ? NUM_CHARSN * 2 : NUM_CHARSN; this.db = db; this.record = db.malloc(Database.MAX_MALLOC_SIZE); @@ -67,7 +66,7 @@ public class LongString implements IString { // write the subsequent records long lastNext = this.record + NEXT1; int start = numChars1; - while (length-start > numCharsn) { + while (length - start > numCharsn) { long nextRecord = db.malloc(Database.MAX_MALLOC_SIZE); db.putRecPtr(lastNext, nextRecord); chunk= db.getChunk(nextRecord); @@ -115,9 +114,9 @@ public class LongString implements IString { long p = record; Chunk chunk= db.getChunk(p); if (useBytes) { - chunk.getCharsFromBytes(p+CHARS1, chars, 0, numChars1); + chunk.getCharsFromBytes(p + CHARS1, chars, 0, numChars1); } else { - chunk.getChars(p+CHARS1, chars, 0, numChars1); + chunk.getChars(p + CHARS1, chars, 0, numChars1); } int start= numChars1; @@ -129,12 +128,12 @@ public class LongString implements IString { int partLen= Math.min(length-start, numCharsn); chunk= db.getChunk(p); if (useBytes) { - chunk.getCharsFromBytes(p+CHARSN, chars, start, partLen); + chunk.getCharsFromBytes(p + CHARSN, chars, start, partLen); } else { - chunk.getChars(p+CHARSN, chars, start, partLen); + chunk.getChars(p + CHARSN, chars, start, partLen); } - start+= partLen; - p=p+NEXTN; + start += partLen; + p=p + NEXTN; } return chars; } @@ -201,7 +200,7 @@ public class LongString implements IString { chars = getChars(); final int len = chars.length; for (int i = 0; i < len; i++) { - h = 31*h + chars[i]; + h = 31 * h + chars[i]; } } catch (CoreException e) { } @@ -235,7 +234,6 @@ public class LongString implements IString { return ShortString.comparePrefix(getChars(), other, caseSensitive); } - @Override public String getString() throws CoreException { return new String(getChars()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Messages.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Messages.java index e99562efe86..3f7e8bd1f99 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Messages.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Messages.java @@ -16,8 +16,7 @@ import java.util.ResourceBundle; public class Messages { private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.db.messages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private Messages() { } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index 5c9198bba2f..d260b1e4b9c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.db; @@ -28,7 +28,7 @@ import org.eclipse.core.runtime.CoreException; * For marshalling types to byte arrays. */ public class TypeMarshalBuffer implements ITypeMarshalBuffer { - public final static byte [] EMPTY= {0,0,0,0,0,0}; + public final static byte[] EMPTY= { 0, 0, 0, 0, 0, 0 }; public final static byte NULL_TYPE= 0; public final static byte INDIRECT_TYPE= (byte) -1; public final static byte BINDING_TYPE= (byte) -2; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java index 9a66f9369fa..0c287512edf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java @@ -408,10 +408,12 @@ public class BuildConsolePartitioner synchronized (fQueue) { StreamEntry entry = fQueue.peekLast(); if (entry != null) { - // If last stream is the same and we have not exceeded - // the display write limit, append. + // If last stream is the same and the size of the queued entry has not exceeded + // the batch size, avoid creating a new entry and append the new text to the last + // entry in the queue. The batch size is adaptive and grows with the length of + // the queue. if (entry.getStream() == stream && entry.getEventType() == StreamEntry.EVENT_APPEND && - entry.getMarker() == marker && entry.size() < 10000) { + entry.getMarker() == marker && entry.size() < 2000 * fQueue.size()) { entry.appendText(text); addToQueue = false; }