1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Merge branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2011-11-17 22:30:15 -05:00
commit 4f2cea1002
334 changed files with 8918 additions and 8128 deletions

View file

@ -1774,8 +1774,27 @@ If this attribute is not specified, MBS will assume that there are no reserved m
<attribute name="parallelBuildCmd" type="string">
<annotation>
<documentation>
specifies the &quot;parallel build&quot; builder option.
If the builder supports specifying custom number of parallel jobs, the option definition may contain &quot;*&quot; the Build System sill substitute the &quot;*&quot; with the number of parallel threads to be used.
Specifies the command for &quot;parallel build&quot;.
If the builder supports specifying custom number of parallel jobs the option definition may contain &quot;*&quot;. The Build System will substitute the &quot;*&quot; with the number of parallel threads to be used. In case of &quot;unlimited&quot; jobs jobs number will be omitted.
For example, builder representing GNU make would define parallelBuildCmd as &quot;-j*&quot;.
</documentation>
</annotation>
</attribute>
<attribute name="parallelBuildOn" type="boolean">
<annotation>
<documentation>
Defines if the parallel build is enabled in newly created project by default (when parallel build is supported). The number of jobs is defined by &quot;parallelizationNumber&quot; attribute. If &quot;parallelizationNumber&quot; is not defined &quot;optimal&quot; value will be used.
</documentation>
</annotation>
</attribute>
<attribute name="parallelizationNumber" type="string">
<annotation>
<documentation>
Sets maximum number of parallel threads/jobs to be used by builder (that value can be changed after creation of project by user).
A positive number or value &quot;optimal&quot; or &quot;unlimited&quot; are recognized:
- number 1 will cause parallel build to be turned off,
- &quot;optimal&quot; will set maximum number of jobs to number of processors on the system,
- &quot;unlimited&quot; will make builder to run as many threads/jobs as possible.
</documentation>
</annotation>
</attribute>

View file

@ -75,14 +75,17 @@ public interface IBuilder extends IHoldsOptions, IMakeBuilderInfo {
static final String ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS = "customizedErrorParsers"; //$NON-NLS-1$
static final String ATTRIBUTE_CUSTOM_PROPS = "customBuilderProperties"; //$NON-NLS-1$
// static final String ATTRIBUTE_CUSTOMIZED_ERROR_PARSERS = "customizedErrorParsers"; //$NON-NLS-1$
static final String ATTRIBUTE_IGNORE_ERR_CMD = "ignoreErrCmd"; //$NON-NLS-1$
static final String ATTRIBUTE_STOP_ON_ERR = "stopOnErr"; //$NON-NLS-1$
static final String ATTRIBUTE_PARALLEL_BUILD_CMD = "parallelBuildCmd"; //$NON-NLS-1$
static final String ATTRIBUTE_PARALLELIZATION_NUMBER = "parallelizationNumber"; //$NON-NLS-1$
static final String ATTRIBUTE_PARALLEL_BUILD_ON = "parallelBuildOn"; //$NON-NLS-1$
static final String ATTRIBUTE_PARALLELIZATION_NUMBER = "parallelizationNumber"; //$NON-NLS-1$
/** @since 8.1 */
static final String VALUE_OPTIMAL = "optimal"; //$NON-NLS-1$
/** @since 8.1 */
static final String VALUE_UNLIMITED = "unlimited"; //$NON-NLS-1$
static final String PARALLEL_PATTERN_NUM = "*"; //$NON-NLS-1$
static final String PARALLEL_PATTERN_NUM_START = "["; //$NON-NLS-1$
static final String PARALLEL_PATTERN_NUM_END = "]"; //$NON-NLS-1$
@ -92,15 +95,9 @@ public interface IBuilder extends IHoldsOptions, IMakeBuilderInfo {
static final String DEFAULT_TARGET_INCREMENTAL = "all"; //$NON-NLS-1$
static final String DEFAULT_TARGET_CLEAN = "clean"; //$NON-NLS-1$
static final String DEFAULT_TARGET_AUTO = "all"; //$NON-NLS-1$
/**
* @since 6.0
*/
/** @since 6.0 */
static final String ATTRIBUTE_COMMAND_LAUNCHER = "commandLauncher"; //$NON-NLS-1$
/**
* @since 8.0
*/
/** @since 8.0 */
static final String ATTRIBUTE_BUILD_RUNNER = "buildRunner"; //$NON-NLS-1$
/**

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation and others.
* Copyright (c) 2007, 2011 Intel 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
@ -13,19 +13,56 @@ package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
/**
* This class is to combine multiple configurations to one to support
* selection of multiple configurations on property pages.
*
* @noextend This class is not intended to be subclassed by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IMultiConfiguration extends IConfiguration, ICMultiItemsHolder {
/**
* Check if all configurations' builders are operating in parallel mode.
* @return {@code true} if parallel mode is enabled for all configurations,
* {@code false} otherwise.
*/
boolean getParallelDef();
void setParallelDef(boolean def);
int getParallelNumber();
void setParallelNumber(int num);
/**
* Set same parallel execution mode for all configurations' builders.
* @see Builder#setParallelBuildOn(boolean)
*
* @param parallel - the flag to enable or disable parallel mode.
*/
void setParallelDef(boolean parallel);
/**
* Returns maximum number of parallel threads/jobs used by the configurations' builders.
* @see #setParallelDef(boolean)
*
* @return - maximum number of parallel threads or jobs used by each builder or 0 if the numbers
* don't match.
*/
int getParallelNumber();
/**
* Sets maximum number of parallel threads/jobs to be used by each builder.
*
* @param jobs - maximum number of jobs or threads, see for more details
* {@link Builder#getOptimalParallelJobNum()}.
*/
void setParallelNumber(int jobs);
/**
* Check if all configurations' internal builders are operating in parallel mode.
* @return {@code true} if parallel mode is enabled for all configurations,
* {@code false} otherwise.
*
* @deprecated since CDT 9.0. Use {@link #getParallelDef()}
*/
@Deprecated
boolean getInternalBuilderParallel();
boolean isInternalBuilderEnabled();

View file

@ -92,7 +92,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
IBuilder builder, IConsole console, IMarkerGenerator markerGenerator,
IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException {
boolean isParallel = builder.isParallelBuildOn() && builder.getParallelizationNum() > 1;
boolean isParallel = builder.getParallelizationNum() > 1;
// boolean buildIncrementaly = true;
boolean resumeOnErr = !builder.isStopOnError();
@ -226,8 +226,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
break;
case IBuildModelBuilder.STATUS_ERROR_LAUNCH:
default:
buf.append(ManagedMakeMessages
.getResourceString(BUILD_FAILED_ERR));
buf.append(ManagedMakeMessages.getResourceString(BUILD_FAILED_ERR));
break;
}
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
@ -248,8 +247,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
epmOutputStream = null;
// Generate any error markers that the build has discovered
monitor.subTask(ManagedMakeMessages
.getResourceString(MARKERS));
monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
bsMngr.setProjectBuildState(project, pBS);
} else {

View file

@ -153,13 +153,13 @@ import org.w3c.dom.ProcessingInstruction;
public class ManagedBuildManager extends AbstractCExtension {
public static final String MBS_LANGUAGE_SETTINGS_PROVIDER = "org.eclipse.cdt.managedbuilder.core.LanguageSettingsProvider";
// private static final QualifiedName buildInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "managedBuildInfo"); //$NON-NLS-1$
// private static final QualifiedName buildInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.PLUGIN_ID, "managedBuildInfo"); //$NON-NLS-1$
private static final String ROOT_NODE_NAME = "ManagedProjectBuildInfo"; //$NON-NLS-1$
public static final String SETTINGS_FILE_NAME = ".cdtbuild"; //$NON-NLS-1$
private static final ITarget[] emptyTargets = new ITarget[0];
public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ManagedBuildManager"; //$NON-NLS-1$
public static final String EXTENSION_POINT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".buildDefinitions"; //$NON-NLS-1$
public static final String EXTENSION_POINT_ID_V2 = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ManagedBuildInfo"; //$NON-NLS-1$
public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.PLUGIN_ID + ".ManagedBuildManager"; //$NON-NLS-1$
public static final String EXTENSION_POINT_ID = ManagedBuilderCorePlugin.PLUGIN_ID + ".buildDefinitions"; //$NON-NLS-1$
public static final String EXTENSION_POINT_ID_V2 = ManagedBuilderCorePlugin.PLUGIN_ID + ".ManagedBuildInfo"; //$NON-NLS-1$
private static final String REVISION_ELEMENT_NAME = "managedBuildRevision"; //$NON-NLS-1$
private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$
private static final String MANIFEST_VERSION_ERROR ="ManagedBuildManager.error.manifest.version.error"; //$NON-NLS-1$
@ -188,7 +188,7 @@ public class ManagedBuildManager extends AbstractCExtension {
public static final String BUILD_ARTEFACT_TYPE_PROPERTY_STATICLIB = "org.eclipse.cdt.build.core.buildArtefactType.staticLib"; //$NON-NLS-1$
public static final String BUILD_ARTEFACT_TYPE_PROPERTY_SHAREDLIB = "org.eclipse.cdt.build.core.buildArtefactType.sharedLib"; //$NON-NLS-1$
public static final String CFG_DATA_PROVIDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".configurationDataProvider"; //$NON-NLS-1$
public static final String CFG_DATA_PROVIDER_ID = ManagedBuilderCorePlugin.PLUGIN_ID + ".configurationDataProvider"; //$NON-NLS-1$
private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
@ -261,16 +261,19 @@ public class ManagedBuildManager extends AbstractCExtension {
private static Map<IProject, IManagedBuildInfo> fInfoMap = new HashMap<IProject, IManagedBuildInfo>();
private static ISorter fToolChainSorter = new ISorter(){
@Override
public void sort() {
resortToolChains();
}
};
private static ISorter fToolSorter = new ISorter(){
@Override
public void sort() {
resortTools();
}
};
private static ISorter fBuilderSorter = new ISorter(){
@Override
public void sort() {
resortBuilders();
}
@ -284,6 +287,7 @@ public class ManagedBuildManager extends AbstractCExtension {
static {
getEnvironmentVariableProvider().subscribe(
fEnvironmentBuildPathsChangeListener = new IEnvironmentBuildPathsChangeListener(){
@Override
public void buildPathsChanged(IConfiguration configuration, int buildPathType){
// if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE){
// initializePathEntries(configuration,null);
@ -1331,6 +1335,7 @@ public class ManagedBuildManager extends AbstractCExtension {
if (shell != null) {
final String exceptionMsg = err.getMessage();
shell.getDisplay().syncExec( new Runnable() {
@Override
public void run() {
MessageDialog.openError(shell,
ManagedMakeMessages.getResourceString("ManagedBuildManager.error.write_failed_title"), //$NON-NLS-1$
@ -1880,13 +1885,13 @@ public class ManagedBuildManager extends AbstractCExtension {
initBuildInfoContainer(buildInfo);
} catch (CoreException e) {
return new Status(IStatus.ERROR,
ManagedBuilderCorePlugin.getUniqueIdentifier(),
ManagedBuilderCorePlugin.PLUGIN_ID,
IStatus.ERROR,
e.getLocalizedMessage(),
e);
}
return new Status(IStatus.OK,
ManagedBuilderCorePlugin.getUniqueIdentifier(),
ManagedBuilderCorePlugin.PLUGIN_ID,
IStatus.OK,
ManagedMakeMessages.getFormattedString("ManagedBuildInfo.message.init.ok", resource.getName()), //$NON-NLS-1$
null);
@ -1903,7 +1908,7 @@ public class ManagedBuildManager extends AbstractCExtension {
// private static void initBuildInfoContainer(ManagedBuildInfo info) throws CoreException {
// if (info == null) {
// throw new CoreException(new Status(IStatus.ERROR,
// ManagedBuilderCorePlugin.getUniqueIdentifier(),
// ManagedBuilderCorePlugin.PLUGIN_ID,
// IStatus.ERROR,
// new String(),
// null));
@ -2156,6 +2161,7 @@ public class ManagedBuildManager extends AbstractCExtension {
final Shell shell = window.getShell();
final String errMsg = ManagedMakeMessages.getFormattedString(MANIFEST_VERSION_ERROR, extension.getUniqueIdentifier());
shell.getDisplay().asyncExec( new Runnable() {
@Override
public void run() {
MessageDialog.openError(shell,
ManagedMakeMessages.getResourceString("ManagedBuildManager.error.manifest_load_failed_title"), //$NON-NLS-1$
@ -2943,7 +2949,7 @@ public class ManagedBuildManager extends AbstractCExtension {
if(info != null)
doSetLoaddedInfo(project, info, false);
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e));
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, e.getLocalizedMessage(), e));
}
}
@ -4585,6 +4591,7 @@ public class ManagedBuildManager extends AbstractCExtension {
*
* @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void run(IProgressMonitor monitor) throws CoreException {
int ticks = 1;
if (buildKind==IncrementalProjectBuilder.CLEAN_BUILD) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Intel Corporation and others.
* Copyright (c) 2006, 2011 Intel 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
@ -11,41 +11,27 @@
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* This class implements process pool management for internal builder
*
* NOTE: This class is subject to change and discuss,
* and is currently available in experimental mode only
*/
public class BuildProcessManager {
protected OutputStream out;
protected OutputStream err;
protected boolean show;
protected ProcessLauncher[] processes;
protected int maxProcesses;
// Number of CPUs is not dependent of object instance.
// But user can change UI settings for processes number.
// So we cannot set procNumber directly to maxProcesses.
static int procNumber = 0;
protected Vector<ProcessLauncher> processes;
protected int maxProcesses;
/**
* Initializes process manager
@ -59,7 +45,7 @@ public class BuildProcessManager {
err = _err;
show = _show;
maxProcesses = _procNumber;
processes = new ProcessLauncher[maxProcesses];
processes = new Vector<ProcessLauncher>(Math.min(10, maxProcesses), 10);
}
/**
@ -79,18 +65,19 @@ public class BuildProcessManager {
* @param monitor Progress monitor for this task
*/
public ProcessLauncher launchProcess(IBuildCommand cmd, IPath cwd, IProgressMonitor monitor) {
if (hasEmpty()) {
int i = 0;
for (; i < maxProcesses; i++) {
if (processes[i] == null || processes[i].queryState() == ProcessLauncher.STATE_DONE) {
break;
}
for (int i = 0; i < maxProcesses; i++) {
if (i >= processes.size()) {
ProcessLauncher process = new ProcessLauncher(cmd.getCommand(), cmd.getArgs(), mapToStringArray(cmd.getEnvironment()), cwd, out, err, monitor, show);
processes.add(process);
process.launch();
return process;
}
if (i < maxProcesses) {
processes[i] = new ProcessLauncher(cmd.getCommand(), cmd.getArgs(), mapToStringArray(cmd.getEnvironment()), cwd, out, err, monitor, show);
processes[i].launch();
return processes[i];
if (processes.get(i).queryState() == ProcessLauncher.STATE_DONE) {
ProcessLauncher process = new ProcessLauncher(cmd.getCommand(), cmd.getArgs(), mapToStringArray(cmd.getEnvironment()), cwd, out, err, monitor, show);
processes.set(i, process);
process.launch();
return process;
}
}
return null;
@ -102,36 +89,37 @@ public class BuildProcessManager {
* returned as a result. Otherwise this method returns null.
*/
public ProcessLauncher queryStates() {
ProcessLauncher result = null;
for (int i = 0; i < maxProcesses; i++) {
if (processes[i] != null) {
int state = processes[i].queryState();
if (state != ProcessLauncher.STATE_RUNNING) {
if (state != ProcessLauncher.STATE_DONE && result == null)
result = processes[i];
}
}
for (ProcessLauncher process : processes) {
int state = process.queryState();
if (state != ProcessLauncher.STATE_RUNNING && state != ProcessLauncher.STATE_DONE)
return process;
}
return result;
return null;
}
/**
* Checks states of all currently running processes.
*/
public boolean hasEmpty() {
for (int i = 0; i < maxProcesses; i++) {
if (processes[i] == null)
if (processes.size() < maxProcesses)
return true;
for (ProcessLauncher process : processes) {
if (process.queryState() != ProcessLauncher.STATE_RUNNING)
return true;
else {
if (processes[i].queryState() != ProcessLauncher.STATE_RUNNING)
return true;
}
}
return false;
}
/**
* Returns maximum threads used up to that point
*/
public int getThreadsUsed() {
return processes.size();
}
/**
* Converts map to strings array
@ -152,40 +140,10 @@ public class BuildProcessManager {
/**
* @return Number of processors detected
* @deprecated since CDT 9.0 - just use Runtime.getRuntime().availableProcessors()
*/
@Deprecated
static public int checkCPUNumber() {
if (procNumber > 0) return procNumber;
procNumber = 1;
int x = 0;
String os = System.getProperty("os.name"); //$NON-NLS-1$
if (os != null) {
if (os.startsWith("Win")) { //$NON-NLS-1$
IEnvironmentVariableProvider evp = ManagedBuildManager.getEnvironmentVariableProvider();
if (evp != null) {
IBuildEnvironmentVariable var = evp.getVariable("NUMBER_OF_PROCESSORS", null, false, false); //$NON-NLS-1$
if (var != null) {
try {
x = new Integer(var.getValue()).intValue();
if (x > 0) { procNumber = x; }
} catch (NumberFormatException e) {} // fallthrough and return default
}
}
} else { // linux
String p = "/proc/cpuinfo"; //$NON-NLS-1$
try {
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(p)));
String s;
while ((s = r.readLine() ) != null )
{ if (s.startsWith("processor\t:")) x++; } //$NON-NLS-1$
r.close();
if (x > 0) { procNumber = x; }
}
catch (IOException e) {} // fallthrough and return default
}
}
if(DbgUtil.DEBUG)
DbgUtil.trace("Number of processors detected: " + procNumber); //$NON-NLS-1$
return procNumber;
return Runtime.getRuntime().availableProcessors();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006 Intel Corporation and others.
* Copyright (c) 2006, 2011 Intel 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
@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand;
@ -91,6 +92,7 @@ public class ParallelBuilder {
return step.hashCode();
}
@Override
public int compareTo(BuildQueueElement elem) {
if (elem == null)
throw new NullPointerException();
@ -205,18 +207,16 @@ public class ParallelBuilder {
if(cwd == null) cwd = des.getDefaultBuildDirLocation();
int threads = 1;
if (cfg instanceof Configuration) {
if (((Configuration)cfg).getParallelDef())
threads = BuildProcessManager.checkCPUNumber();
else
threads = ((Configuration)cfg).getParallelNumber();
threads = ((Configuration)cfg).getParallelNumber();
}
ParallelBuilder builder = new ParallelBuilder(cwd, dirs, out, err, monitor, resumeOnErrors, buildIncrementally);
builder.enqueueAll(des);
builder.sortQueue();
monitor.beginTask("", builder.queue.size()); //$NON-NLS-1$
builder.dispatch(new BuildProcessManager(out, err, true, threads));
BuildProcessManager buildProcessManager = new BuildProcessManager(out, err, true, threads);
builder.dispatch(buildProcessManager);
lastThreadsUsed = buildProcessManager.getThreadsUsed();
monitor.done();
lastThreadsUsed = threads;
return IBuildModelBuilder.STATUS_OK;
}
@ -295,10 +295,8 @@ public class ParallelBuilder {
* Dispatches the build queue and returns build status
*/
protected int dispatch(BuildProcessManager mgr) {
ActiveBuildStep[] active = new ActiveBuildStep[mgr.getMaxProcesses()];
for (int i = 0; i < active.length; i++) {
active[i] = null; // new ActiveBuildStep();
}
int maxProcesses = mgr.getMaxProcesses();
Vector<ActiveBuildStep> active = new Vector<ActiveBuildStep>(Math.min(maxProcesses, 10), 10);
int activeCount = 0;
int maxLevel = 0;
@ -332,9 +330,8 @@ public class ParallelBuilder {
proceed = false;
} else {
// Check "active steps" list for completed ones
for (int i = 0; i < active.length; i++) {
if (active[i] == null) continue;
ProcessLauncher pl = active[i].getLauncher();
for (ActiveBuildStep buildStep : active) {
ProcessLauncher pl = buildStep.getLauncher();
if (pl == null) continue;
if (pl.queryState() == ProcessLauncher.STATE_DONE) {
// If process has terminated with error, break loop
@ -345,8 +342,8 @@ public class ParallelBuilder {
break main_loop;
}
// Try to launch next command for the current active step
if (active[i].isDone()) continue;
if (active[i].launchNextCmd(mgr)) {
if (buildStep.isDone()) continue;
if (buildStep.launchNextCmd(mgr)) {
// Command has been launched. Check if process pool is not maximized yet
if (!mgr.hasEmpty()) {
proceed = false;
@ -354,7 +351,7 @@ public class ParallelBuilder {
}
} else {
// Command has not been launched: step complete
refreshOutputs(active[i].getStep());
refreshOutputs(buildStep.getStep());
activeCount--;
monitor.worked(1);
}
@ -373,7 +370,7 @@ public class ParallelBuilder {
}
// Check if we need to schedule another process
if (queue.size() != 0 && activeCount < active.length) {
if (queue.size() != 0 && activeCount < maxProcesses) {
// Need to schedule another process
Iterator<BuildQueueElement> iter = queue.iterator();
@ -381,8 +378,8 @@ public class ParallelBuilder {
while (iter.hasNext()) {
BuildQueueElement elem = iter.next();
// If "active steps" list is full, then break loop
if (activeCount == active.length)
// If "active steps" list reaches maximum, then break loop
if (activeCount == maxProcesses)
break;
// If current element's level exceeds maximum level of currently built
@ -391,14 +388,13 @@ public class ParallelBuilder {
break;
//Check if all prerequisites are built
IBuildResource[] res = elem.getStep().getInputResources();
boolean prereqBuilt = true;
for (int j = 0; j < res.length; j++) {
IBuildStep stp = res[j].getProducerStep(); // step which produces input for curr
for (IBuildResource bldRes : elem.getStep().getInputResources()) {
IBuildStep step = bldRes.getProducerStep(); // step which produces input for curr
boolean built = true;
if (stp != stp.getBuildDescription().getInputStep()) {
for (int k = 0; k < active.length; k++) {
if (active[k] != null && active[k].getStep().equals(stp) && !active[k].isDone()) {
if (step != step.getBuildDescription().getInputStep()) {
for (ActiveBuildStep buildStep : active) {
if (buildStep != null && buildStep.getStep().equals(step) && !buildStep.isDone()) {
built = false;
break;
}
@ -417,10 +413,21 @@ public class ParallelBuilder {
// Remove element from the build queue and add it to the
// "active steps" list.
iter.remove();
for (int i = 0; i < active.length; i++) {
if (active[i] == null || active[i].isDone()) {
active[i] = new ActiveBuildStep(step);
if (active[i].launchNextCmd(mgr)) activeCount++;
for (int i = 0; i < maxProcesses; i++) {
if (i >= active.size()) {
// add new item
ActiveBuildStep buildStep = new ActiveBuildStep(step);
active.add(buildStep);
if (buildStep.launchNextCmd(mgr))
activeCount++;
break;
}
if (active.get(i).isDone()) {
// replace old item
ActiveBuildStep buildStep = new ActiveBuildStep(step);
active.set(i, buildStep);
if (buildStep.launchNextCmd(mgr))
activeCount++;
break;
}
}

View file

@ -753,7 +753,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
* E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
*/
/* (non-Javadoc)
/**
* Initialize the configuration information from an element in the
* manifest file or provided by a dynamicElementProvider
*
@ -807,7 +807,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
isTest = Boolean.valueOf(tmp).booleanValue();
}
/* (non-Javadoc)
/**
* Initialize the configuration information from the XML element
* specified in the argument
*
@ -878,8 +878,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
if (element.getAttribute(CLEAN_COMMAND) != null) {
cleanCommand = SafeStringInterner.safeIntern(element.getAttribute(CLEAN_COMMAND));
}
// Get the pre-build and post-build commands
// Get the pre-build and post-build commands
if (element.getAttribute(PREBUILD_STEP) != null) {
prebuildStep = SafeStringInterner.safeIntern(element.getAttribute(PREBUILD_STEP));
}
@ -895,7 +895,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
if (element.getAttribute(POSTANNOUNCEBUILD_STEP) != null) {
postannouncebuildStep = SafeStringInterner.safeIntern(element.getAttribute(POSTANNOUNCEBUILD_STEP));
}
}
}
/**
@ -974,6 +974,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getParent()
*/
@Override
public IConfiguration getParent() {
return parent;
}
@ -981,6 +982,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getOwner()
*/
@Override
public IResource getOwner() {
if (managedProject != null)
return managedProject.getOwner();
@ -992,6 +994,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getProjectType()
*/
@Override
public IProjectType getProjectType() {
return projectType;
}
@ -999,6 +1002,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getManagedProject()
*/
@Override
public IManagedProject getManagedProject() {
return managedProject;
}
@ -1006,6 +1010,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain(IToolChain, String, String, boolean)
*/
@Override
public IToolChain createToolChain(IToolChain superClass, String Id, String name, boolean isExtensionElement) {
if(rootFolderInfo == null){
createRootFolderInfo();
@ -1034,6 +1039,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getToolChain()
*/
@Override
public IToolChain getToolChain() {
return rootFolderInfo.getToolChain();
}
@ -1041,6 +1047,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getResourceConfigurations()
*/
@Override
public IResourceConfiguration[] getResourceConfigurations() {
return (IResourceConfiguration[])rcInfos.getResourceInfos(ICSettingBase.SETTING_FILE, IResourceConfiguration.class);
}
@ -1048,6 +1055,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfiguration(java.lang.String)
*/
@Override
public IResourceConfiguration getResourceConfiguration(String resPath) {
return rcInfos.getFileInfo(new Path(resPath).removeFirstSegments(1));
}
@ -1055,6 +1063,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
*/
@Override
public ITool[] getFilteredTools() {
return rootFolderInfo.getFilteredTools();
}
@ -1062,6 +1071,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getTools()
*/
@Override
public ITool[] getTools() {
return rootFolderInfo.getTools();
}
@ -1069,6 +1079,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTool(java.lang.String)
*/
@Override
public ITool getTool(String id) {
return rootFolderInfo.getTool(id);
}
@ -1076,6 +1087,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String)
*/
@Override
public ITool[] getToolsBySuperClassId(String id) {
return rootFolderInfo.getToolsBySuperClassId(id);
}
@ -1083,6 +1095,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
*/
@Override
public ITool getTargetTool() {
String[] targetToolIds = rootFolderInfo.getToolChain().getTargetToolList();
if (targetToolIds == null || targetToolIds.length == 0) return null;
@ -1110,6 +1123,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
*/
@Override
public String getToolCommand(ITool tool) {
// TODO: Do we need to verify that the tool is part of the configuration?
return tool.getToolCommand();
@ -1118,6 +1132,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
*/
@Override
public void setToolCommand(ITool tool, String command) {
// TODO: Do we need to verify that the tool is part of the configuration?
tool.setToolCommand(command);
@ -1126,6 +1141,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, boolean)
*/
@Override
public IOption setOption(IHoldsOptions holder, IOption option, boolean value) throws BuildException {
return getRootFolderInfo().setOption(holder, option, value);
}
@ -1133,6 +1149,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String)
*/
@Override
public IOption setOption(IHoldsOptions holder, IOption option, String value) throws BuildException {
return getRootFolderInfo().setOption(holder, option, value);
}
@ -1140,6 +1157,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setOption(org.eclipse.cdt.core.build.managed.IOption, java.lang.String[])
*/
@Override
public IOption setOption(IHoldsOptions holder, IOption option, String[] value) throws BuildException {
return getRootFolderInfo().setOption(holder, option, value);
}
@ -1157,6 +1175,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
// rebuildNeeded = true;
}
@Override
public void removeResourceConfiguration(IResourceInfo resConfig) {
ManagedBuildManager.performValueHandlerEvent(resConfig,
IManagedOptionValueHandler.EVENT_CLOSE);
@ -1182,6 +1201,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getArtifactExtension()
*/
@Override
public String getArtifactExtension() {
String ext = getArtifactExtensionAttribute(true);
return ext != null ? ext : EMPTY_STRING;
@ -1201,6 +1221,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getArtifactName()
*/
@Override
public String getArtifactName() {
if (artifactName == null) {
// If I have a parent, ask it
@ -1218,6 +1239,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildArguments()
*/
@Override
public String getBuildArguments() {
IToolChain tc = getToolChain();
IBuilder builder = tc.getBuilder();
@ -1230,6 +1252,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildCommand()
*/
@Override
public String getBuildCommand() {
IToolChain tc = getToolChain();
IBuilder builder = tc.getBuilder();
@ -1244,6 +1267,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
*
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPrebuildStep()
*/
@Override
public String getPrebuildStep() {
if (prebuildStep == null) {
// If I have a parent, ask it
@ -1263,6 +1287,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
*
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostbuildStep()
*/
@Override
public String getPostbuildStep() {
if (postbuildStep == null) {
// If I have a parent, ask it
@ -1282,6 +1307,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
*
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPreannouncebuildStep()
*/
@Override
public String getPreannouncebuildStep() {
if (preannouncebuildStep == null) {
// If I have a parent, ask it
@ -1301,6 +1327,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
*
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getPostannouncebuildStep()
*/
@Override
public String getPostannouncebuildStep() {
if (postannouncebuildStep == null) {
// If I have a parent, ask it
@ -1320,6 +1347,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
*
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getCleanCommand()
*/
@Override
public String getCleanCommand() {
// Return the command used to remove files
if (cleanCommand == null) {
@ -1342,6 +1370,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getDescription()
*/
@Override
public String getDescription() {
if (description == null) {
// If I have a parent, ask it
@ -1361,6 +1390,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
*
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserIds()
*/
@Override
public String getErrorParserIds() {
if (errorParserIds != null) {
return errorParserIds;
@ -1396,6 +1426,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserList()
*/
@Override
public String[] getErrorParserList() {
Set<String> set = contributeErrorParsers(null, true);
if(set != null){
@ -1436,6 +1467,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String)
*/
@Override
public void setArtifactExtension(String extension) {
if (extension == null && artifactExtension == null) return;
if (artifactExtension == null || extension == null || !artifactExtension.equals(extension)) {
@ -1457,6 +1489,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setArtifactName(java.lang.String)
*/
@Override
public void setArtifactName(String name) {
if (name == null && artifactName == null) return;
if (artifactName == null || name == null || !artifactName.equals(name)) {
@ -1498,6 +1531,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setErrorParserIds()
*/
@Override
public void setErrorParserIds(String ids) {
String currentIds = getErrorParserIds();
if (ids == null && currentIds == null) return;
@ -1510,6 +1544,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setCleanCommand()
*/
@Override
public void setCleanCommand(String command) {
if (command == null && cleanCommand == null) return;
if (cleanCommand == null || command == null || !cleanCommand.equals(command)) {
@ -1521,6 +1556,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setDescription(java.lang.String)
*/
@Override
public void setDescription(String description) {
if (description == null && this.description == null) return;
if (this.description == null || description == null || !description.equals(this.description)) {
@ -1532,6 +1568,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildArguments()
*/
@Override
public void setBuildArguments(String makeArgs) {
IToolChain tc = getToolChain();
IBuilder builder = tc.getBuilder();
@ -1554,6 +1591,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildCommand()
*/
@Override
public void setBuildCommand(String command) {
IToolChain tc = getToolChain();
IBuilder builder = tc.getBuilder();
@ -1576,7 +1614,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPrebuildStep(java.lang.String)
*/
public void setPrebuildStep(String step) {
@Override
public void setPrebuildStep(String step) {
if (step == null && prebuildStep == null) return;
if (prebuildStep == null || step == null || !prebuildStep.equals(step)) {
prebuildStep = step;
@ -1589,7 +1628,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostbuildStep(java.lang.String)
*/
public void setPostbuildStep(String step) {
@Override
public void setPostbuildStep(String step) {
if (step == null && postbuildStep == null) return;
if (postbuildStep == null || step == null || !postbuildStep.equals(step)) {
postbuildStep = step;
@ -1601,7 +1641,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPreannouncebuildStep(java.lang.String)
*/
public void setPreannouncebuildStep(String announceStep) {
@Override
public void setPreannouncebuildStep(String announceStep) {
if (announceStep == null && preannouncebuildStep == null) return;
if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) {
preannouncebuildStep = announceStep;
@ -1613,7 +1654,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setPostannouncebuildStep(java.lang.String)
*/
public void setPostannouncebuildStep(String announceStep) {
@Override
public void setPostannouncebuildStep(String announceStep) {
if (announceStep == null && postannouncebuildStep == null) return;
if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) {
postannouncebuildStep = announceStep;
@ -1625,6 +1667,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isSupported()
*/
@Override
public boolean isSupported(){
IFolderInfo foInfo = getRootFolderInfo();
if(foInfo != null)
@ -1635,6 +1678,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isHeaderFile(java.lang.String)
*/
@Override
public boolean isHeaderFile(String ext) {
return getRootFolderInfo().isHeaderFile(ext);
}
@ -1646,6 +1690,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isExtensionElement()
*/
@Override
public boolean isExtensionElement() {
return isExtensionConfig;
}
@ -1653,6 +1698,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
*/
@Override
public boolean isDirty() {
// This shouldn't be called for an extension configuration
if (isExtensionConfig) return false;
@ -1673,10 +1719,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsRebuild()
*/
@Override
public boolean needsRebuild() {
return needsRebuild(true);
}
@Override
public boolean needsFullRebuild() {
return needsRebuild(false);
}
@ -1700,6 +1748,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
*/
@Override
public void setDirty(boolean isDirty) {
// Override the dirty flag
this.isDirty = isDirty;
@ -1716,6 +1765,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setRebuildState(boolean)
*/
@Override
public void setRebuildState(boolean rebuild) {
if(isExtensionElement() && rebuild)
return;
@ -1739,6 +1789,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#hasOverriddenBuildCommand()
*/
@Override
public boolean hasOverriddenBuildCommand() {
IBuilder builder = getToolChain().getBuilder();
if (builder != null) {
@ -1793,21 +1844,24 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
((FolderInfo)getRootFolderInfo()).resetOptionSettings();
}
/*
/**
* Create a resource configuration object for the passed-in file
*/
@Override
public IResourceConfiguration createResourceConfiguration(IFile file)
{
return createFileInfo(file.getFullPath().removeFirstSegments(1));
}
@Override
public IFileInfo createFileInfo(IPath path){
String resourceName = path.lastSegment();
String id = ManagedBuildManager.calculateChildId(getId(), path.toString());
return createFileInfo(path, id, resourceName);
}
@Override
public IFileInfo createFileInfo(IPath path, String id, String name){
IResourceInfo info = getResourceInfo(path, false);
IFileInfo fileInfo = null;
@ -1820,6 +1874,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return fileInfo;
}
@Override
public IFileInfo createFileInfo(IPath path, IFolderInfo base, ITool baseTool, String id, String name){
if(base.getPath().equals(path))
return null;
@ -1831,6 +1886,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return fileInfo;
}
@Override
public IFileInfo createFileInfo(IPath path, IFileInfo base, String id, String name){
if(base.getPath().equals(path))
return null;
@ -1845,6 +1901,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEnvironmentVariableSupplier()
*/
@Override
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
IToolChain toolChain = getToolChain();
if(toolChain != null)
@ -1873,6 +1930,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildMacroSupplier()
*/
@Override
public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
IToolChain toolChain = getToolChain();
if(toolChain != null)
@ -1884,6 +1942,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isTemporary()
*/
@Override
public boolean isTemporary(){
return isTemporary;
}
@ -1910,6 +1969,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
@Override
public ITool calculateTargetTool(){
ITool tool = getTargetTool();
@ -1932,15 +1992,17 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return tool;
}
@Override
public ITool getToolFromOutputExtension(String extension) {
return getRootFolderInfo().getToolFromOutputExtension(extension);
}
@Override
public ITool getToolFromInputExtension(String sourceExtension) {
return getRootFolderInfo().getToolFromInputExtension(sourceExtension);
}
/*
/**
* The resource delta passed to the builder is not always up-to-date
* for the given configuration because between two builds of the same configuration
* any number of other configuration builds may occur
@ -2012,7 +2074,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
prefs.getBoolean(pref, false) : defaultValue;
}
*/
/*
/**
* this method is used for enabling/disabling the internal builder
* for the given configuration
*
@ -2129,7 +2191,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return null;
}
/*
/**
* returns whether the internal builder is enabled
* @return boolean
*/
@ -2137,7 +2199,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return getBuilder().isInternalBuilder();
}
/*
/**
*
* sets the Internal Builder mode
*
@ -2152,7 +2214,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
/*
/**
* returns the Internal Builder mode
* if true, internal builder will ignore build errors while building,
* otherwise it will stop at the first build error
@ -2164,73 +2226,73 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
/**
*
* sets the Internal Builder Parallel mode
*
* @param parallel if true, internal builder will use parallel mode
*
* @deprecated since CDT 9.0. Use {@link #setParallelDef(boolean)}
*/
@Deprecated
public void setInternalBuilderParallel(boolean parallel){
if(getInternalBuilderParallel() == parallel)
return;
try {
getEditableBuilder().setParallelBuildOn(parallel);
} catch (CoreException e) {
}
setParallelDef(parallel);
}
/**
* returns the Internal Builder parallel mode
* if true, internal builder will work in parallel mode
* otherwise it will use only one thread
*
* @return boolean
*
* @deprecated since CDT 9.0. Use {@link #getParallelDef()}
*/
@Deprecated
public boolean getInternalBuilderParallel(){
return getBuilder().isParallelBuildOn();
return getParallelDef();
}
/**
* @param parallel if true, internal builder will use parallel mode
* Set parallel execution mode for the configuration's builder.
* @see Builder#setParallelBuildOn(boolean)
*
* @param parallel - the flag to enable or disable parallel mode.
*/
public void setParallelDef(boolean parallel){
if(getParallelDef() == parallel)
return;
int num = getParallelNumber();
if(num != 0){
setParallelNumber(-num);
} else {
if(parallel){
setParallelNumber(-1);
} else {
setParallelNumber(1);
}
try {
getEditableBuilder().setParallelBuildOn(parallel);
} catch (CoreException e) {
ManagedBuilderCorePlugin.log(e);
}
}
/**
* @return boolean
* Check if the configuration's builder is operating in parallel mode.
* @return {@code true} if parallel mode is enabled, {@code false} otherwise.
*/
public boolean getParallelDef(){
int num = getBuilder().getParallelizationNum();
return num <= 0;
return getBuilder().isParallelBuildOn();
}
/**
* sets number of Parallel threads
* Sets maximum number of parallel threads/jobs to be used by builder.
*
* @param jobs - maximum number of jobs or threads. For details how
* the number is interpreted see {@link Builder#setParallelizationNum(int)}.
*/
public void setParallelNumber(int n){
public void setParallelNumber(int jobs){
try {
getEditableBuilder().setParallelizationNum(n);
getEditableBuilder().setParallelizationNum(jobs);
} catch (CoreException e) {
ManagedBuilderCorePlugin.log(e);
}
}
/**
* returns number of Parallel threads
* Returns maximum number of parallel threads/jobs used by the configuration's builder.
* @see #setParallelDef(boolean)
*
* @return int
* @return - maximum number of parallel threads or jobs used by the builder.
*/
public int getParallelNumber(){
return getBuilder().getParallelizationNum();
@ -2254,14 +2316,17 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
// return prefs;
// }
@Override
public IResourceInfo[] getResourceInfos() {
return rcInfos.getResourceInfos();
}
@Override
public IResourceInfo getResourceInfo(IPath path, boolean exactPath) {
return rcInfos.getResourceInfo(path, exactPath);
}
@Override
public IResourceInfo getResourceInfoById(String id) {
IResourceInfo infos[] = rcInfos.getResourceInfos();
for(int i = 0; i < infos.length; i++){
@ -2271,6 +2336,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return null;
}
@Override
public IFolderInfo getRootFolderInfo() {
return rootFolderInfo;
}
@ -2280,22 +2346,26 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return new ResourceInfoContainer(cr, false);
}
@Override
public CConfigurationData getConfigurationData(){
return fCfgData;
}
@Override
public void removeResourceInfo(IPath path) {
IResourceInfo info = getResourceInfo(path, true);
if(info != null)
removeResourceConfiguration(info);
}
@Override
public IFolderInfo createFolderInfo(IPath path) {
String resourceName = path.lastSegment();
String id = ManagedBuildManager.calculateChildId(getId(), path.toString());
return createFolderInfo(path, id, resourceName);
}
@Override
public IFolderInfo createFolderInfo(IPath path, String id, String name) {
IResourceInfo info = getResourceInfo(path, false);
IFolderInfo folderInfo = null;
@ -2308,6 +2378,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return folderInfo;
}
@Override
public IFolderInfo createFolderInfo(IPath path, IFolderInfo base, String id, String name) {
if(base.getPath().equals(path))
return null;
@ -2320,6 +2391,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return folderInfo;
}
@Override
public ICSourceEntry[] getSourceEntries() {
if(sourceEntries == null || sourceEntries.length == 0){
if(parent != null && sourceEntries == null)
@ -2330,6 +2402,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return sourceEntries.clone();
}
@Override
public void setSourceEntries(ICSourceEntry[] entries) {
setSourceEntries(entries, true);
}
@ -2363,6 +2436,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
@Override
public void setErrorParserList(String[] ids) {
if(ids == null){
//reset
@ -2402,10 +2476,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
@Override
public CBuildData getBuildData() {
return getEditableBuilder().getBuildData();
}
@Override
public IBuilder getEditableBuilder(){
IToolChain tc = getToolChain();
IBuilder builder = tc.getBuilder();
@ -2417,10 +2493,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return builder;
}
@Override
public IBuilder getBuilder(){
return getToolChain().getBuilder();
}
@Override
public String getOutputPrefix(String outputExtension) {
// Treat null extensions as empty string
String ext = outputExtension == null ? new String() : outputExtension;
@ -2445,6 +2523,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
fCfgDes = cfgDes;
}
@Override
public IBuildObjectProperties getBuildProperties() {
if(buildProperties == null){
BuildObjectProperties parentProps = findBuildProperties();
@ -2475,6 +2554,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return supportsValue(type.getId(), value.getId());
}
@Override
public void propertiesChanged() {
if(isExtensionConfig)
return;
@ -2498,6 +2578,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return booleanExpressionCalculator;
}
@Override
public boolean isSystemObject() {
if(isTest)
return true;
@ -2508,10 +2589,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return false;
}
@Override
public String getOutputExtension(String resourceExtension) {
return getRootFolderInfo().getOutputExtension(resourceExtension);
}
@Override
public String getOutputFlag(String outputExt) {
// Treat null extension as an empty string
String ext = outputExt == null ? new String() : outputExt;
@ -2529,6 +2612,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return flags;
}
@Override
public IManagedCommandLineInfo generateToolCommandLineInfo( String sourceExtension, String[] flags,
String outputFlag, String outputPrefix, String outputName, String[] inputResources, IPath inputLocation, IPath outputLocation ){
ITool[] tools = getFilteredTools();
@ -2581,6 +2665,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return null;
}
@Override
public String[] getUserObjects(String extension) {
Vector<String> objs = new Vector<String>();
ITool tool = calculateTargetTool();
@ -2622,6 +2707,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return objs.toArray(new String[objs.size()]);
}
@Override
public String[] getLibs(String extension) {
Vector<String> libs = new Vector<String>();
ITool tool = calculateTargetTool();
@ -2676,6 +2762,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return libs.toArray(new String[libs.size()]);
}
@Override
public boolean buildsFileType(String srcExt) {
return getRootFolderInfo().buildsFileType(srcExt);
}
@ -2743,6 +2830,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
@Override
public boolean supportsBuild(boolean managed) {
return supportsBuild(managed, true);
}
@ -2763,6 +2851,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return true;
}
@Override
public boolean supportsType(String typeId) {
SupportedProperties props = findSupportedProperties();
boolean supports = false;
@ -2776,6 +2865,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return supports;
}
@Override
public boolean supportsValue(String typeId, String valueId) {
SupportedProperties props = findSupportedProperties();
boolean supports = false;
@ -2802,6 +2892,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
supportedProperties = new SupportedProperties(el);
}
@Override
public String[] getRequiredTypeIds() {
SupportedProperties props = findSupportedProperties();
List<String> list = new ArrayList<String>();
@ -2814,6 +2905,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return list.toArray(new String[list.size()]);
}
@Override
public String[] getSupportedTypeIds() {
SupportedProperties props = findSupportedProperties();
List<String> list = new ArrayList<String>();
@ -2826,6 +2918,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return list.toArray(new String[list.size()]);
}
@Override
public String[] getSupportedValueIds(String typeId) {
SupportedProperties props = findSupportedProperties();
List<String> list = new ArrayList<String>();
@ -2838,6 +2931,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return list.toArray(new String[list.size()]);
}
@Override
public boolean requiresType(String typeId) {
SupportedProperties props = findSupportedProperties();
boolean requires = false;
@ -2851,10 +2945,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return requires;
}
@Override
public boolean isManagedBuildOn() {
return getBuilder().isManagedBuildOn();
}
@Override
public void setManagedBuildOn(boolean on) throws BuildException {
try {
getEditableBuilder().setManagedBuildOn(on);
@ -2863,6 +2959,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
@Override
public void changeBuilder(IBuilder newBuilder, String id, String name){
changeBuilder(newBuilder, id, name, false);
}
@ -2892,6 +2989,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
@Override
public boolean isBuilderCompatible(IBuilder builder){
return builder.supportsBuild(isManagedBuildOn());
}
@ -2972,6 +3070,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return isPreferenceConfig;
}
@Override
public IBuildPropertyValue getBuildArtefactType() {
IBuildObjectProperties props = findBuildProperties();
if(props != null){
@ -2982,6 +3081,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return null;
}
@Override
public void setBuildArtefactType(String id) throws BuildException {
IBuildObjectProperties props = getBuildProperties();
try {
@ -3034,34 +3134,42 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
}
}
@Override
public IRealBuildObjectAssociation getExtensionObject() {
return isExtensionConfig ? this : (Configuration)getParent();
}
@Override
public IRealBuildObjectAssociation[] getIdenticBuildObjects() {
return new Configuration[]{(Configuration)getExtensionObject()};
}
@Override
public IRealBuildObjectAssociation getRealBuildObject() {
return getExtensionObject();
}
@Override
public IRealBuildObjectAssociation getSuperClassObject() {
return (IRealBuildObjectAssociation)getParent();
}
@Override
public int getType() {
return OBJECT_CONFIGURATION;
}
@Override
public boolean isRealBuildObject() {
return getRealBuildObject() == this;
}
@Override
public String getUniqueRealName() {
return getName();
}
@Override
public boolean isExtensionBuildObject() {
return isExtensionElement();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2010 IBM Corporation and others.
* Copyright (c) 2002, 2011 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
@ -151,6 +151,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
return fullBuildNeeded;
}
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
IResource resource = delta.getResource();
// If the project has changed, then a build is needed and we can stop
@ -231,6 +232,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
}
@Override
public boolean visit(IResourceDelta delta) throws CoreException {
IResource rc = delta.getResource();
@ -906,244 +908,242 @@ public class GeneratedMakefileBuilder extends ACBuilder {
}
IPath makeCommand = new Path(makeCmd);
if (makeCommand != null) {
String[] msgs = new String[2];
msgs[0] = makeCommand.toString();
msgs[1] = currentProject.getName();
monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
String[] msgs = new String[2];
msgs[0] = makeCommand.toString();
msgs[1] = currentProject.getName();
monitor.subTask(ManagedMakeMessages.getFormattedString(MAKE, msgs));
// Get a build console for the project
StringBuffer buf = new StringBuffer();
IConsole console = CCorePlugin.getDefault().getConsole();
console.start(currentProject);
ConsoleOutputStream consoleOutStream = console.getOutputStream();
String[] consoleHeader = new String[3];
// Get a build console for the project
StringBuffer buf = new StringBuffer();
IConsole console = CCorePlugin.getDefault().getConsole();
console.start(currentProject);
ConsoleOutputStream consoleOutStream = console.getOutputStream();
String[] consoleHeader = new String[3];
switch (buildType) {
case FULL_BUILD:
case INCREMENTAL_BUILD:
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
break;
case CLEAN_BUILD:
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
break;
}
consoleHeader[1] = info.getConfigurationName();
consoleHeader[2] = currentProject.getName();
buf.append(NEWLINE);
buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE);
buf.append(NEWLINE);
IConfiguration cfg = info.getDefaultConfiguration();
if(!cfg.isSupported()){
String msg = ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()});
buf.append(msg).append(NEWLINE);
buf.append(NEWLINE);
}
consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush();
// Remove all markers for this project
removeAllMarkers(currentProject);
// Get a launcher for the make command
String errMsg = null;
IBuilder builder = info.getDefaultConfiguration().getBuilder();
ICommandLauncher launcher = builder.getCommandLauncher();
launcher.setProject(currentProject);
launcher.showCommand(true);
// Set the environmennt
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
String[] env = null;
ArrayList<String> envList = new ArrayList<String>();
if (variables != null) {
for(int i = 0; i < variables.length; i++){
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
}
env = envList.toArray(new String[envList.size()]);
}
// Hook up an error parser manager
String[] errorParsers = info.getDefaultConfiguration().getErrorParserList();
ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, errorParsers);
epm.setOutputStream(consoleOutStream);
// This variable is necessary to ensure that the EPM stream stay open
// until we explicitly close it. See bug#123302.
OutputStream epmOutputStream = epm.getOutputStream();
// Get the arguments to be passed to make from build model
ArrayList<String> makeArgs = new ArrayList<String>();
String arg = info.getBuildArguments();
if (arg.length() > 0) {
String[] args = arg.split("\\s"); //$NON-NLS-1$
for (int i = 0; i < args.length; ++i) {
makeArgs.add(args[i]);
}
}
String[] makeTargets;
String prebuildStep = info.getPrebuildStep();
//try to resolve the build macros in the prebuildStep
try{
prebuildStep = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
prebuildStep,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_CONFIGURATION,
cfg);
} catch (BuildMacroException e){
}
boolean prebuildStepPresent = (prebuildStep.length() > 0);
Process proc = null;
boolean isuptodate = false;
if (prebuildStepPresent) {
@SuppressWarnings("unchecked")
ArrayList<String> premakeArgs = (ArrayList<String>) makeArgs.clone();
String[] premakeTargets;
switch (buildType) {
case FULL_BUILD:
case INCREMENTAL_BUILD:
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC);
break;
case CLEAN_BUILD:
consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN);
break;
}
consoleHeader[1] = info.getConfigurationName();
consoleHeader[2] = currentProject.getName();
buf.append(NEWLINE);
buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE);
buf.append(NEWLINE);
IConfiguration cfg = info.getDefaultConfiguration();
if(!cfg.isSupported()){
String msg = ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()});
buf.append(msg).append(NEWLINE);
buf.append(NEWLINE);
}
consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush();
// Remove all markers for this project
removeAllMarkers(currentProject);
// Get a launcher for the make command
String errMsg = null;
IBuilder builder = info.getDefaultConfiguration().getBuilder();
ICommandLauncher launcher = builder.getCommandLauncher();
launcher.setProject(currentProject);
launcher.showCommand(true);
// Set the environmennt
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true,true);
String[] env = null;
ArrayList<String> envList = new ArrayList<String>();
if (variables != null) {
for(int i = 0; i < variables.length; i++){
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
}
env = envList.toArray(new String[envList.size()]);
}
// Hook up an error parser manager
String[] errorParsers = info.getDefaultConfiguration().getErrorParserList();
ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, errorParsers);
epm.setOutputStream(consoleOutStream);
// This variable is necessary to ensure that the EPM stream stay open
// until we explicitly close it. See bug#123302.
OutputStream epmOutputStream = epm.getOutputStream();
// Get the arguments to be passed to make from build model
ArrayList<String> makeArgs = new ArrayList<String>();
String arg = info.getBuildArguments();
if (arg.length() > 0) {
String[] args = arg.split("\\s"); //$NON-NLS-1$
for (int i = 0; i < args.length; ++i) {
makeArgs.add(args[i]);
}
}
String[] makeTargets;
String prebuildStep = info.getPrebuildStep();
//try to resolve the build macros in the prebuildStep
try{
prebuildStep = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
prebuildStep,
"", //$NON-NLS-1$
" ", //$NON-NLS-1$
IBuildMacroProvider.CONTEXT_CONFIGURATION,
cfg);
} catch (BuildMacroException e){
}
boolean prebuildStepPresent = (prebuildStep.length() > 0);
Process proc = null;
boolean isuptodate = false;
if (prebuildStepPresent) {
@SuppressWarnings("unchecked")
ArrayList<String> premakeArgs = (ArrayList<String>) makeArgs.clone();
String[] premakeTargets;
switch (buildType) {
case INCREMENTAL_BUILD: {
// For an incremental build with a prebuild step:
// Check the status of the main build with "make -q main-build"
// If up to date:
// then: don't invoke the prebuild step, which should be run only if
// something needs to be built in the main build
// else: invoke the prebuild step and the main build step
premakeArgs.add("-q"); //$NON-NLS-1$
premakeArgs.add("main-build"); //$NON-NLS-1$
premakeTargets = premakeArgs.toArray(new String[premakeArgs.size()]);
proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory, monitor);
if (proc != null) {
try {
// Close the input of the process since we will never write to it
proc.getOutputStream().close();
} catch (IOException e) {
}
if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
new SubProgressMonitor(monitor,
IProgressMonitor.UNKNOWN)) != ICommandLauncher.OK) {
errMsg = launcher.getErrorMessage();
}
} else {
errMsg = launcher.getErrorMessage();
}
if ((errMsg != null && errMsg.length() > 0) || proc == null) {
// Can't tell if the build is needed, so assume it is, and let any errors be triggered
// when the "real" build is invoked below
makeArgs.add("pre-build"); //$NON-NLS-1$
makeArgs.add("main-build"); //$NON-NLS-1$
} else {
// The "make -q" command launch was successful
if (proc.exitValue() == 0) {
// If the status value returned from "make -q" is 0, then the build state is up-to-date
isuptodate = true;
// Report that the build was up to date, and thus nothing needs to be built
String uptodateMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, currentProject.getName());
buf = new StringBuffer();
buf.append(NEWLINE);
buf.append(uptodateMsg).append(NEWLINE);
// Write message on the console
consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush();
epmOutputStream.close();
consoleOutStream.close();
} else {
// The status value was other than 0, so press on with the build process
makeArgs.add("pre-build"); //$NON-NLS-1$
makeArgs.add("main-build"); //$NON-NLS-1$
}
}
break;
}
case FULL_BUILD: {
// makeArgs.add("clean"); //$NON-NLS-1$
makeArgs.add("pre-build"); //$NON-NLS-1$
makeArgs.add("main-build"); //$NON-NLS-1$
break;
}
case CLEAN_BUILD: {
makeArgs.add("clean"); //$NON-NLS-1$
break;
}
}
} else {
// No prebuild step
//
makeArgs.addAll(Arrays.asList(getMakeTargets(buildType)));
}
makeTargets = makeArgs.toArray(new String[makeArgs.size()]);
// Launch make - main invocation
if (!isuptodate) {
proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory, monitor);
case INCREMENTAL_BUILD: {
// For an incremental build with a prebuild step:
// Check the status of the main build with "make -q main-build"
// If up to date:
// then: don't invoke the prebuild step, which should be run only if
// something needs to be built in the main build
// else: invoke the prebuild step and the main build step
premakeArgs.add("-q"); //$NON-NLS-1$
premakeArgs.add("main-build"); //$NON-NLS-1$
premakeTargets = premakeArgs.toArray(new String[premakeArgs.size()]);
proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory, monitor);
if (proc != null) {
try {
// Close the input of the process since we will never write to it
proc.getOutputStream().close();
} catch (IOException e) {
}
int state = launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
if (launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
new SubProgressMonitor(monitor,
IProgressMonitor.UNKNOWN));
if(state != ICommandLauncher.OK){
IProgressMonitor.UNKNOWN)) != ICommandLauncher.OK) {
errMsg = launcher.getErrorMessage();
if(state == ICommandLauncher.COMMAND_CANCELED){
//TODO: the better way of handling cancel is needed
//currently the rebuild state is set to true forcing the full rebuild
//on the next builder invocation
info.getDefaultConfiguration().setRebuildState(true);
}
}
// Force a resync of the projects without allowing the user to cancel.
// This is probably unkind, but short of this there is no way to insure
// the UI is up-to-date with the build results
monitor.subTask(ManagedMakeMessages
.getResourceString(REFRESH));
try {
//currentProject.refreshLocal(IResource.DEPTH_INFINITE, null);
// use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(currentProject);
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
monitor.subTask(ManagedMakeMessages
.getResourceString(REFRESH_ERROR));
}
} else {
errMsg = launcher.getErrorMessage();
}
// Report either the success or failure of our mission
buf = new StringBuffer();
if (errMsg != null && errMsg.length() > 0) {
String errorDesc = ManagedMakeMessages.getResourceString(BUILD_ERROR);
buf.append(errorDesc).append(NEWLINE);
buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
if ((errMsg != null && errMsg.length() > 0) || proc == null) {
// Can't tell if the build is needed, so assume it is, and let any errors be triggered
// when the "real" build is invoked below
makeArgs.add("pre-build"); //$NON-NLS-1$
makeArgs.add("main-build"); //$NON-NLS-1$
} else {
// Report a successful build
String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED,
currentProject.getName());
buf.append(successMsg).append(NEWLINE);
// The "make -q" command launch was successful
if (proc.exitValue() == 0) {
// If the status value returned from "make -q" is 0, then the build state is up-to-date
isuptodate = true;
// Report that the build was up to date, and thus nothing needs to be built
String uptodateMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, currentProject.getName());
buf = new StringBuffer();
buf.append(NEWLINE);
buf.append(uptodateMsg).append(NEWLINE);
// Write message on the console
consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush();
epmOutputStream.close();
consoleOutStream.close();
} else {
// The status value was other than 0, so press on with the build process
makeArgs.add("pre-build"); //$NON-NLS-1$
makeArgs.add("main-build"); //$NON-NLS-1$
}
}
break;
}
case FULL_BUILD: {
// makeArgs.add("clean"); //$NON-NLS-1$
makeArgs.add("pre-build"); //$NON-NLS-1$
makeArgs.add("main-build"); //$NON-NLS-1$
break;
}
case CLEAN_BUILD: {
makeArgs.add("clean"); //$NON-NLS-1$
break;
}
}
} else {
// No prebuild step
//
makeArgs.addAll(Arrays.asList(getMakeTargets(buildType)));
}
makeTargets = makeArgs.toArray(new String[makeArgs.size()]);
// Launch make - main invocation
if (!isuptodate) {
proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory, monitor);
if (proc != null) {
try {
// Close the input of the process since we will never write to it
proc.getOutputStream().close();
} catch (IOException e) {
}
// Write message on the console
consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush();
epmOutputStream.close();
int state = launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(),
new SubProgressMonitor(monitor,
IProgressMonitor.UNKNOWN));
if(state != ICommandLauncher.OK){
errMsg = launcher.getErrorMessage();
if(state == ICommandLauncher.COMMAND_CANCELED){
//TODO: the better way of handling cancel is needed
//currently the rebuild state is set to true forcing the full rebuild
//on the next builder invocation
info.getDefaultConfiguration().setRebuildState(true);
}
}
// Generate any error markers that the build has discovered
monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
addBuilderMarkers(epm);
consoleOutStream.close();
// Force a resync of the projects without allowing the user to cancel.
// This is probably unkind, but short of this there is no way to insure
// the UI is up-to-date with the build results
monitor.subTask(ManagedMakeMessages
.getResourceString(REFRESH));
try {
//currentProject.refreshLocal(IResource.DEPTH_INFINITE, null);
// use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(currentProject);
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
monitor.subTask(ManagedMakeMessages
.getResourceString(REFRESH_ERROR));
}
} else {
errMsg = launcher.getErrorMessage();
}
// Report either the success or failure of our mission
buf = new StringBuffer();
if (errMsg != null && errMsg.length() > 0) {
String errorDesc = ManagedMakeMessages.getResourceString(BUILD_ERROR);
buf.append(errorDesc).append(NEWLINE);
buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
// Report a successful build
String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED,
currentProject.getName());
buf.append(successMsg).append(NEWLINE);
}
// Write message on the console
consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush();
epmOutputStream.close();
// Generate any error markers that the build has discovered
monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
addBuilderMarkers(epm);
consoleOutStream.close();
}
} catch (Exception e) {
forgetLastBuiltState();
@ -1196,7 +1196,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
boolean resumeOnErr,
IProgressMonitor monitor) {
boolean isParallel = ((Configuration)cfg).getInternalBuilderParallel();
boolean isParallel = ((Configuration)cfg).getParallelDef();
// Get the project and make sure there's a monitor to cancel the build
IProject currentProject = cfg.getOwner().getProject();

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation and others.
* Copyright (c) 2007, 2011 Intel 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
@ -44,6 +44,7 @@ import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSu
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.osgi.framework.Version;
@ -91,6 +92,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#buildsFileType(java.lang.String)
*/
@Override
public boolean buildsFileType(String srcExt) {
return curr().buildsFileType(srcExt);
}
@ -98,6 +100,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#calculateTargetTool()
*/
@Override
public ITool calculateTargetTool() {
return curr().calculateTargetTool();
}
@ -105,6 +108,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#changeBuilder(org.eclipse.cdt.managedbuilder.core.IBuilder, java.lang.String, java.lang.String)
*/
@Override
public void changeBuilder(IBuilder newBuilder, String id, String name) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].changeBuilder(newBuilder, id, name);
@ -113,6 +117,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createFileInfo(org.eclipse.core.runtime.IPath)
*/
@Override
public IFileInfo createFileInfo(IPath path) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.createFileInfo(1)"); //$NON-NLS-1$
@ -122,6 +127,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createFileInfo(org.eclipse.core.runtime.IPath, java.lang.String, java.lang.String)
*/
@Override
public IFileInfo createFileInfo(IPath path, String id, String name) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.createFileInfo(3)"); //$NON-NLS-1$
@ -131,6 +137,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createFileInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IFolderInfo, org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String, java.lang.String)
*/
@Override
public IFileInfo createFileInfo(IPath path, IFolderInfo base,
ITool baseTool, String id, String name) {
if (DEBUG)
@ -141,6 +148,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createFileInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IFileInfo, java.lang.String, java.lang.String)
*/
@Override
public IFileInfo createFileInfo(IPath path, IFileInfo base, String id, String name) {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.createFileInfo(4)"); //$NON-NLS-1$
@ -150,6 +158,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createFolderInfo(org.eclipse.core.runtime.IPath)
*/
@Override
public IFolderInfo createFolderInfo(IPath path) {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.createFolderInfo()"); //$NON-NLS-1$
@ -159,6 +168,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createFolderInfo(org.eclipse.core.runtime.IPath, java.lang.String, java.lang.String)
*/
@Override
public IFolderInfo createFolderInfo(IPath path, String id, String name) {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.createFolderInfo(3)"); //$NON-NLS-1$
@ -168,6 +178,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createFolderInfo(org.eclipse.core.runtime.IPath, org.eclipse.cdt.managedbuilder.core.IFolderInfo, java.lang.String, java.lang.String)
*/
@Override
public IFolderInfo createFolderInfo(IPath path, IFolderInfo base, String id, String name) {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.createFolderInfo(4)"); //$NON-NLS-1$
@ -177,6 +188,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createResourceConfiguration(org.eclipse.core.resources.IFile)
*/
@Override
public IResourceConfiguration createResourceConfiguration(IFile file) {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.createResourceConfiguration()"); //$NON-NLS-1$
@ -186,6 +198,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#createToolChain(org.eclipse.cdt.managedbuilder.core.IToolChain, java.lang.String, java.lang.String, boolean)
*/
@Override
public IToolChain createToolChain(IToolChain superClass, String Id,
String name, boolean isExtensionElement) {
if (DEBUG)
@ -196,6 +209,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#generateToolCommandLineInfo(java.lang.String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String[], org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
*/
@Override
public IManagedCommandLineInfo generateToolCommandLineInfo(
String sourceExtension,
String[] flags,
@ -221,6 +235,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getArtifactExtension()
*/
@Override
public String getArtifactExtension() {
String s = fCfgs[0].getArtifactExtension();
for (int i=1; i<fCfgs.length; i++)
@ -239,6 +254,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getArtifactName()
*/
@Override
public String getArtifactName() {
String s = fCfgs[0].getArtifactName();
for (int i=1; i<fCfgs.length; i++)
@ -253,20 +269,30 @@ public class MultiConfiguration extends MultiItemsHolder implements
return s;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildArguments()
/**
* @return build arguments if the arguments for all configurations match
* or {@code null} otherwise.
*/
@Override
public String getBuildArguments() {
String s = fCfgs[0].getBuildArguments();
for (int i=1; i<fCfgs.length; i++)
if (! s.equals(fCfgs[i].getBuildArguments()))
return EMPTY_STR;
return s;
String args0 = fCfgs[0].getBuildArguments();
if (args0 == null)
args0 = EMPTY_STR;
for (IConfiguration cfg : fCfgs) {
String args = cfg.getBuildArguments();
if (args == null)
args = EMPTY_STR;
if (!args0.equals(args))
return null;
}
return args0;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildArtefactType()
*/
@Override
public IBuildPropertyValue getBuildArtefactType() {
IBuildPropertyValue b = fCfgs[0].getBuildArtefactType();
if (b == null)
@ -280,6 +306,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildCommand()
*/
@Override
public String getBuildCommand() {
String s = fCfgs[0].getBuildCommand();
if (s == null || s.length() == 0)
@ -293,6 +320,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildData()
*/
@Override
public CBuildData getBuildData() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getBuildData()"); //$NON-NLS-1$
@ -302,6 +330,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuildMacroSupplier()
*/
@Override
public IConfigurationBuildMacroSupplier getBuildMacroSupplier() {
IConfigurationBuildMacroSupplier ms = fCfgs[0].getBuildMacroSupplier();
if (ms == null)
@ -315,6 +344,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getBuilder()
*/
@Override
public IBuilder getBuilder() {
IBuilder b = fCfgs[0].getBuilder();
if (b == null)
@ -328,6 +358,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getCleanCommand()
*/
@Override
public String getCleanCommand() {
String s = fCfgs[0].getCleanCommand();
for (int i=1; i<fCfgs.length; i++)
@ -339,6 +370,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getConfigurationData()
*/
@Override
public CConfigurationData getConfigurationData() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getConfigurationData()"); //$NON-NLS-1$
@ -348,6 +380,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getDescription()
*/
@Override
public String getDescription() {
String s = fCfgs[0].getDescription();
for (int i=1; i<fCfgs.length; i++)
@ -359,6 +392,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEditableBuilder()
*/
@Override
public IBuilder getEditableBuilder() {
return curr().getEditableBuilder();
}
@ -366,6 +400,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEnvironmentVariableSupplier()
*/
@Override
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier() {
IConfigurationEnvironmentVariableSupplier vs = fCfgs[0].getEnvironmentVariableSupplier();
if (vs == null)
@ -380,6 +415,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserIds()
*/
@Override
public String getErrorParserIds() {
String s = fCfgs[0].getErrorParserIds();
if (s == null || s.length() == 0)
@ -393,6 +429,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getErrorParserList()
*/
@Override
public String[] getErrorParserList() {
String[] s = fCfgs[0].getErrorParserList();
if (s == null || s.length == 0)
@ -411,6 +448,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
*/
@Override
public ITool[] getFilteredTools() {
ITool[] ts = curr().getFilteredTools();
return ts;
@ -419,6 +457,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getLibs(java.lang.String)
*/
@Override
public String[] getLibs(String extension) {
String[] s = fCfgs[0].getLibs(extension);
if (s == null || s.length == 0)
@ -432,6 +471,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getManagedProject()
*/
@Override
public IManagedProject getManagedProject() {
IManagedProject s = fCfgs[0].getManagedProject();
if (s == null)
@ -445,6 +485,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getOutputExtension(java.lang.String)
*/
@Override
public String getOutputExtension(String resourceExtension) {
String s = fCfgs[0].getOutputExtension(resourceExtension);
if (s == null || s.length() == 0)
@ -458,6 +499,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getOutputFlag(java.lang.String)
*/
@Override
public String getOutputFlag(String outputExt) {
String s = fCfgs[0].getOutputFlag(outputExt);
if (s == null || s.length() == 0)
@ -471,6 +513,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getOutputPrefix(java.lang.String)
*/
@Override
public String getOutputPrefix(String outputExtension) {
String s = fCfgs[0].getOutputPrefix(outputExtension);
if (s == null || s.length() == 0)
@ -484,6 +527,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getOwner()
*/
@Override
public IResource getOwner() {
IResource s = fCfgs[0].getOwner();
if (s == null)
@ -497,6 +541,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getParent()
*/
@Override
public IConfiguration getParent() {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.getParent()"); //$NON-NLS-1$
@ -506,6 +551,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getPostannouncebuildStep()
*/
@Override
public String getPostannouncebuildStep() {
String s = fCfgs[0].getPostannouncebuildStep();
if (s == null || s.length() == 0)
@ -519,6 +565,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getPostbuildStep()
*/
@Override
public String getPostbuildStep() {
String s = fCfgs[0].getPostbuildStep();
if (s == null || s.length() == 0)
@ -532,6 +579,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getPreannouncebuildStep()
*/
@Override
public String getPreannouncebuildStep() {
String s = fCfgs[0].getPreannouncebuildStep();
if (s == null || s.length() == 0)
@ -545,6 +593,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getPrebuildStep()
*/
@Override
public String getPrebuildStep() {
String s = fCfgs[0].getPrebuildStep();
if (s == null || s.length() == 0)
@ -558,6 +607,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getProjectType()
*/
@Override
public IProjectType getProjectType() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getProjectType()"); //$NON-NLS-1$
@ -567,6 +617,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfiguration(java.lang.String)
*/
@Override
public IResourceConfiguration getResourceConfiguration(String path) {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.getResourceConfiguration()"); //$NON-NLS-1$
@ -576,6 +627,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceConfigurations()
*/
@Override
public IResourceConfiguration[] getResourceConfigurations() {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.getResourceConfigurations()"); //$NON-NLS-1$
@ -585,6 +637,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceInfo(org.eclipse.core.runtime.IPath, boolean)
*/
@Override
public IResourceInfo getResourceInfo(IPath path, boolean exactPath) {
IResourceInfo ris[] = new IResourceInfo[fCfgs.length];
boolean isFolder = true;
@ -604,6 +657,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceInfoById(java.lang.String)
*/
@Override
public IResourceInfo getResourceInfoById(String id) {
if (DEBUG)
System.out.println("Bad multi access: MultiConfiguration.getResourceInfoById()"); //$NON-NLS-1$
@ -613,6 +667,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getResourceInfos()
*/
@Override
public IResourceInfo[] getResourceInfos() {
ArrayList<IResourceInfo> ri = new ArrayList<IResourceInfo>();
for (int i=0; i<fCfgs.length; i++) {
@ -625,6 +680,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getRootFolderInfo()
*/
@Override
public IFolderInfo getRootFolderInfo() {
IFolderInfo ris[] = new IFolderInfo[fCfgs.length];
for (int i=0; i<fCfgs.length; i++)
@ -635,6 +691,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getSourceEntries()
*/
@Override
public ICSourceEntry[] getSourceEntries() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getSourceEntries()"); //$NON-NLS-1$
@ -644,6 +701,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
*/
@Override
public ITool getTargetTool() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getTargetTool()"); //$NON-NLS-1$
@ -653,6 +711,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTool(java.lang.String)
*/
@Override
public ITool getTool(String id) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getTool()"); //$NON-NLS-1$
@ -662,6 +721,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolChain()
*/
@Override
public IToolChain getToolChain() {
return curr().getToolChain();
}
@ -669,6 +729,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolCommand(org.eclipse.cdt.managedbuilder.core.ITool)
*/
@Override
public String getToolCommand(ITool tool) {
return curr().getToolCommand(tool);
}
@ -676,6 +737,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolFromInputExtension(java.lang.String)
*/
@Override
public ITool getToolFromInputExtension(String sourceExtension) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getToolFromInputExtension()"); //$NON-NLS-1$
@ -685,6 +747,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolFromOutputExtension(java.lang.String)
*/
@Override
public ITool getToolFromOutputExtension(String extension) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getToolFromOutputExtension()"); //$NON-NLS-1$
@ -694,6 +757,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTools()
*/
@Override
public ITool[] getTools() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getTools()"); //$NON-NLS-1$
@ -703,6 +767,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolsBySuperClassId(java.lang.String)
*/
@Override
public ITool[] getToolsBySuperClassId(String id) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getToolsBySuperClassId()"); //$NON-NLS-1$
@ -712,6 +777,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getUserObjects(java.lang.String)
*/
@Override
public String[] getUserObjects(String extension) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getUserObjects()"); //$NON-NLS-1$
@ -721,6 +787,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#hasOverriddenBuildCommand()
*/
@Override
public boolean hasOverriddenBuildCommand() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i].hasOverriddenBuildCommand())
@ -731,6 +798,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isBuilderCompatible(org.eclipse.cdt.managedbuilder.core.IBuilder)
*/
@Override
public boolean isBuilderCompatible(IBuilder builder) {
for (int i=0; i<fCfgs.length; i++)
if (! fCfgs[i].isBuilderCompatible(builder))
@ -741,6 +809,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isDirty()
*/
@Override
public boolean isDirty() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i].isDirty())
@ -751,6 +820,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isExtensionElement()
*/
@Override
public boolean isExtensionElement() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.isExtensionElement()"); //$NON-NLS-1$
@ -760,6 +830,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isHeaderFile(java.lang.String)
*/
@Override
public boolean isHeaderFile(String ext) {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.isHeaderFile()"); //$NON-NLS-1$
@ -769,6 +840,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isManagedBuildOn()
*/
@Override
public boolean isManagedBuildOn() {
for (int i=0; i<fCfgs.length; i++)
if (! fCfgs[i].isManagedBuildOn())
@ -786,6 +858,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isSupported()
*/
@Override
public boolean isSupported() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i].isSupported())
@ -796,6 +869,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isSystemObject()
*/
@Override
public boolean isSystemObject() {
for (int i=0; i<fCfgs.length; i++)
if (! fCfgs[i].isSystemObject())
@ -806,6 +880,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#isTemporary()
*/
@Override
public boolean isTemporary() {
for (int i=0; i<fCfgs.length; i++)
if (! fCfgs[i].isTemporary())
@ -816,6 +891,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsFullRebuild()
*/
@Override
public boolean needsFullRebuild() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i].needsFullRebuild())
@ -826,6 +902,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#needsRebuild()
*/
@Override
public boolean needsRebuild() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i].needsRebuild())
@ -836,6 +913,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#removeResourceConfiguration(org.eclipse.cdt.managedbuilder.core.IResourceInfo)
*/
@Override
public void removeResourceConfiguration(IResourceInfo resConfig) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].removeResourceConfiguration(resConfig);
@ -844,6 +922,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#removeResourceInfo(org.eclipse.core.runtime.IPath)
*/
@Override
public void removeResourceInfo(IPath path) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].removeResourceInfo(path);
@ -852,6 +931,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String)
*/
@Override
public void setArtifactExtension(String extension) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setArtifactExtension(extension);
@ -860,6 +940,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactName(java.lang.String)
*/
@Override
public void setArtifactName(String name) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setArtifactName(name);
@ -868,6 +949,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildArguments(java.lang.String)
*/
@Override
public void setBuildArguments(String makeArgs) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setBuildArguments(makeArgs);
@ -876,6 +958,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildArtefactType(java.lang.String)
*/
@Override
public void setBuildArtefactType(String id) throws BuildException {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setBuildArtefactType(id);
@ -884,6 +967,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setBuildCommand(java.lang.String)
*/
@Override
public void setBuildCommand(String command) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setBuildCommand(command);
@ -892,6 +976,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setCleanCommand(java.lang.String)
*/
@Override
public void setCleanCommand(String command) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setCleanCommand(command);
@ -900,6 +985,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDescription(java.lang.String)
*/
@Override
public void setDescription(String description) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setDescription(description);
@ -908,6 +994,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setDirty(boolean)
*/
@Override
public void setDirty(boolean isDirty) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setDirty(isDirty);
@ -916,6 +1003,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setErrorParserIds(java.lang.String)
*/
@Override
public void setErrorParserIds(String ids) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setErrorParserIds(ids);
@ -924,6 +1012,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setErrorParserList(java.lang.String[])
*/
@Override
public void setErrorParserList(String[] ids) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setErrorParserList(ids);
@ -932,6 +1021,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setManagedBuildOn(boolean)
*/
@Override
public void setManagedBuildOn(boolean on) throws BuildException {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setManagedBuildOn(on);
@ -940,11 +1030,13 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setName(java.lang.String)
*/
@Override
public void setName(String name) {} // do nothing
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setOption(org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption, boolean)
*/
@Override
public IOption setOption(IHoldsOptions parent, IOption option, boolean value)
throws BuildException {
IOption op = null;
@ -956,6 +1048,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setOption(org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption, java.lang.String)
*/
@Override
public IOption setOption(IHoldsOptions parent, IOption option, String value)
throws BuildException {
IOption op = null;
@ -967,6 +1060,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setOption(org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption, java.lang.String[])
*/
@Override
public IOption setOption(IHoldsOptions parent, IOption option,
String[] value) throws BuildException {
IOption op = null;
@ -978,6 +1072,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setPostannouncebuildStep(java.lang.String)
*/
@Override
public void setPostannouncebuildStep(String announceStep) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setPostannouncebuildStep(announceStep);
@ -986,6 +1081,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setPostbuildStep(java.lang.String)
*/
@Override
public void setPostbuildStep(String step) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setPostbuildStep(step);
@ -994,6 +1090,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setPreannouncebuildStep(java.lang.String)
*/
@Override
public void setPreannouncebuildStep(String announceStep) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setPreannouncebuildStep(announceStep);
@ -1002,6 +1099,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setPrebuildStep(java.lang.String)
*/
@Override
public void setPrebuildStep(String step) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setPrebuildStep(step);
@ -1010,6 +1108,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setRebuildState(boolean)
*/
@Override
public void setRebuildState(boolean rebuild) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setRebuildState(rebuild);
@ -1018,6 +1117,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setSourceEntries(org.eclipse.cdt.core.settings.model.ICSourceEntry[])
*/
@Override
public void setSourceEntries(ICSourceEntry[] entries) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setSourceEntries(entries);
@ -1026,6 +1126,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String)
*/
@Override
public void setToolCommand(ITool tool, String command) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].setToolCommand(tool, command);
@ -1034,6 +1135,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#supportsBuild(boolean)
*/
@Override
public boolean supportsBuild(boolean managed) {
for (int i=0; i<fCfgs.length; i++)
if (! fCfgs[i].supportsBuild(managed))
@ -1044,6 +1146,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getBaseId()
*/
@Override
public String getBaseId() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getBaseId()"); //$NON-NLS-1$
@ -1053,6 +1156,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getId()
*/
@Override
public String getId() {
return curr().getId() + "_etc"; //$NON-NLS-1$
}
@ -1060,6 +1164,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getManagedBuildRevision()
*/
@Override
public String getManagedBuildRevision() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getMngBuildRevision()"); //$NON-NLS-1$
@ -1069,6 +1174,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
*/
@Override
public String getName() {
return "Multiple configurations"; //$NON-NLS-1$
}
@ -1076,6 +1182,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getVersion()
*/
@Override
public Version getVersion() {
if (DEBUG)
System.out.println("Strange multi access: MultiConfiguration.getVersion()"); //$NON-NLS-1$
@ -1085,61 +1192,69 @@ public class MultiConfiguration extends MultiItemsHolder implements
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#setVersion(org.eclipse.core.runtime.PluginVersionIdentifier)
*/
@Override
public void setVersion(Version version) {} // do nothing
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IBuildObjectPropertiesContainer#getBuildProperties()
*/
@Override
public IBuildObjectProperties getBuildProperties() {
return curr().getBuildProperties();
}
@Override
public boolean getParallelDef() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration) {
if (!((Configuration)fCfgs[i]).getParallelDef())
for (IConfiguration cfg : fCfgs) {
if (cfg instanceof Configuration) {
if (!((Configuration)cfg).getParallelDef())
return false;
} else
return false;
}
return true; // all cfgs report true
}
public void setParallelDef(boolean def) {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration)
((Configuration)fCfgs[i]).setParallelDef(def);
@Override
public void setParallelDef(boolean parallel) {
for (IConfiguration cfg : fCfgs) {
if (cfg instanceof Configuration)
((Configuration)cfg).setParallelDef(parallel);
}
}
@Override
public int getParallelNumber() {
int res = -1;
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration) {
int x = ((Configuration)fCfgs[i]).getParallelNumber();
if (res == -1)
res = x;
else if (res != x)
int res = 0;
for (IConfiguration cfg : fCfgs) {
if (cfg instanceof Configuration) {
int num = ((Configuration)cfg).getParallelNumber();
Assert.isTrue(num != 0); // can't be 0, see IMakeCommonBuildInfo.getParallelizationNum()
if (res == 0)
res = num;
else if (res != num)
return 0; // values are different !
} else
return 0;
return (res == -1 ? 0: res); // all cfgs report true
}
return res; // all cfgs report same value
}
@Override
public void setParallelNumber(int num) {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration)
((Configuration)fCfgs[i]).setParallelNumber(num);
for (IConfiguration cfg : fCfgs) {
if (cfg instanceof Configuration)
((Configuration)cfg).setParallelNumber(num);
}
}
@Override
public boolean getInternalBuilderParallel() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration) {
if (!((Configuration)fCfgs[i]).getInternalBuilderParallel())
return false;
} else
return false;
return true; // all cfgs report true
return getParallelDef();
}
@Override
public boolean isInternalBuilderEnabled() {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration) {
@ -1150,6 +1265,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
return true; // all cfgs report true
}
@Override
public boolean canEnableInternalBuilder(boolean v) {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration) {
@ -1160,6 +1276,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
return true; // all cfgs report true
}
@Override
public void enableInternalBuilder(boolean v) {
for (int i=0; i<fCfgs.length; i++)
if (fCfgs[i] instanceof Configuration)
@ -1173,6 +1290,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
return fCfgs[curr];
}
@Override
public String getToolOutputPrefix() {
String s = fCfgs[0].calculateTargetTool().getOutputPrefix();
if (s == null || s.length() == 0)
@ -1183,11 +1301,13 @@ public class MultiConfiguration extends MultiItemsHolder implements
return s;
}
@Override
public void setOutputPrefixForPrimaryOutput(String pref) {
for (int i=0; i<fCfgs.length; i++)
fCfgs[i].calculateTargetTool().setOutputPrefixForPrimaryOutput(pref);
}
@Override
public IBuildProperty getBuildProperty(String id) {
IBuildProperty b = fCfgs[0].getBuildProperties().getProperty(id);
if (b == null )
@ -1201,6 +1321,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
}
// Performing conjunction of supported values for each cfg
@Override
public IBuildPropertyValue[] getSupportedValues(String id) {
IBuildPropertyValue[] a = fCfgs[0].getBuildProperties().getSupportedValues(id);
if (a == null || a.length == 0)
@ -1237,6 +1358,7 @@ public class MultiConfiguration extends MultiItemsHolder implements
}
}
@Override
public void setBuildProperty(String id, String val) {
try {
for (int i=0; i<fCfgs.length; i++)

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2010 QNX Software Systems and others.
* Copyright (c) 2004, 2011 QNX Software Systems 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
@ -12,6 +12,7 @@ package org.eclipse.cdt.newmake.core;
import java.util.Map;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -42,10 +43,39 @@ public interface IMakeCommonBuildInfo {
void setStopOnError(boolean on) throws CoreException;
boolean supportsStopOnError(boolean on);
/**
* @return the maximum number of parallel jobs to be used for build.
*/
int getParallelizationNum();
void setParallelizationNum(int num) throws CoreException;
/**
* Sets maximum number of parallel threads/jobs to be used by builder.
* Note that this number can be interpreted by builder in a special way.
* @see Builder#setParallelizationNum(int)
*
* @param jobs - maximum number of jobs.
*/
void setParallelizationNum(int jobs) throws CoreException;
/**
* @return {@code true} if builder supports parallel build,
* {@code false} otherwise.
*/
boolean supportsParallelBuild();
/**
* @return {@code true} if builder support for parallel build is enabled,
* {@code false} otherwise.
*/
boolean isParallelBuildOn();
/**
* Set parallel execution mode for the builder.
* @see Builder#setParallelBuildOn(boolean)
*
* @param on - the flag to enable or disable parallel mode.
*/
void setParallelBuildOn(boolean on) throws CoreException;
boolean isDefaultBuildCmd();

View file

@ -27,9 +27,10 @@ public class Messages extends NLS {
public static String BuilderSettingsTab_0;
public static String BuilderSettingsTab_1;
public static String BuilderSettingsTab_10;
public static String BuilderSettingsTab_11;
public static String BuilderSettingsTab_12;
public static String BuilderSettingsTab_13;
public static String BuilderSettingsTab_EnableParallelBuild;
public static String BuilderSettingsTab_UseOptimalJobs;
public static String BuilderSettingsTab_UseUnlimitedJobs;
public static String BuilderSettingsTab_UseParallelJobs;
public static String BuilderSettingsTab_14;
public static String BuilderSettingsTab_15;
public static String BuilderSettingsTab_16;

View file

@ -31,9 +31,10 @@ BuilderSettingsTab_7=&Generate Makefiles automatically
BuilderSettingsTab_8=&Expand Env. Variable Refs in Makefiles
BuilderSettingsTab_9=Build settings
BuilderSettingsTab_10=Stop on first build error
BuilderSettingsTab_11=Use parallel build
BuilderSettingsTab_12=Use optimal jobs number
BuilderSettingsTab_13=Use parallel jobs:
BuilderSettingsTab_EnableParallelBuild=Enable parallel build
BuilderSettingsTab_UseOptimalJobs=Use number of processors ({0})
BuilderSettingsTab_UseParallelJobs=Use parallel jobs:
BuilderSettingsTab_UseUnlimitedJobs=Use unlimited jobs
BuilderSettingsTab_14=Workbench Build Behavior
BuilderSettingsTab_15=Workbench build type:
BuilderSettingsTab_16=Make build target:

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation and others.
* Copyright (c) 2007, 2011 Intel 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
@ -11,6 +11,8 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
import java.text.MessageFormat;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
@ -18,7 +20,6 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IMultiConfiguration;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildProcessManager;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.MultiConfiguration;
@ -51,6 +52,8 @@ import org.eclipse.swt.widgets.Widget;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
private static final int SPINNER_MAX_VALUE = 10000;
private static final int SPINNER_MIN_VALUE = 2;
private static final int TRI_STATES_SIZE = 4;
// Widgets
@ -58,9 +61,10 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
private Button b_stopOnError; // 3
private Button b_parallel; // 3
private Button b_parallelOpt;
private Button b_parallelNum;
private Spinner parallelProcesses;
private Button b_parallelOptimal;
private Button b_parallelSpecific;
private Button b_parallelUnlimited;
private Spinner s_parallelNumber;
private Label title2;
private Button b_autoBuild; //3
@ -70,11 +74,11 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
private Button b_cmdClean; // 3
private Text t_cmdClean;
private IBuilder bldr;
private Builder bldr;
private IConfiguration icfg;
private boolean canModify = true;
protected final int cpuNumber = BuildProcessManager.checkCPUNumber();
protected final int cpuNumber = Runtime.getRuntime().availableProcessors();
@Override
public void createControls(Composite parent) {
@ -110,7 +114,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
gl.marginHeight = 0;
c2.setLayout(gl);
b_parallel = setupCheck(c2, Messages.BuilderSettingsTab_11, 1, GridData.BEGINNING);
b_parallel = setupCheck(c2, Messages.BuilderSettingsTab_EnableParallelBuild, 1, GridData.BEGINNING);
Composite c3 = new Composite(g3, SWT.NONE);
setupControl(c3, 1, GridData.FILL_BOTH);
@ -120,39 +124,60 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
gl.marginHeight = 0;
c3.setLayout(gl);
b_parallelOpt= new Button(c3, SWT.RADIO);
b_parallelOpt.setText(Messages.BuilderSettingsTab_12);
setupControl(b_parallelOpt, 2, GridData.BEGINNING);
((GridData)(b_parallelOpt.getLayoutData())).horizontalIndent = 15;
b_parallelOpt.addSelectionListener(new SelectionAdapter() {
b_parallelOptimal= new Button(c3, SWT.RADIO);
b_parallelOptimal.setText(MessageFormat.format(Messages.BuilderSettingsTab_UseOptimalJobs, 1));
setupControl(b_parallelOptimal, 2, GridData.BEGINNING);
((GridData)(b_parallelOptimal.getLayoutData())).horizontalIndent = 15;
b_parallelOptimal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
setParallelDef(b_parallelOpt.getSelection());
updateButtons();
if (b_parallelOptimal.getSelection()) {
setParallelDef(true);
setParallelNumber(-1);
updateButtons();
}
}});
b_parallelNum= new Button(c3, SWT.RADIO);
b_parallelNum.setText(Messages.BuilderSettingsTab_13);
setupControl(b_parallelNum, 1, GridData.BEGINNING);
((GridData)(b_parallelNum.getLayoutData())).horizontalIndent = 15;
b_parallelNum.addSelectionListener(new SelectionAdapter() {
b_parallelSpecific= new Button(c3, SWT.RADIO);
b_parallelSpecific.setText(Messages.BuilderSettingsTab_UseParallelJobs);
setupControl(b_parallelSpecific, 1, GridData.BEGINNING);
((GridData)(b_parallelSpecific.getLayoutData())).horizontalIndent = 15;
b_parallelSpecific.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
setParallelDef(!b_parallelNum.getSelection());
updateButtons();
if (b_parallelSpecific.getSelection()) {
setParallelDef(true);
setParallelNumber(s_parallelNumber.getSelection());
updateButtons();
}
}});
parallelProcesses = new Spinner(c3, SWT.BORDER);
setupControl(parallelProcesses, 1, GridData.BEGINNING);
parallelProcesses.setValues(cpuNumber, 1, 10000, 0, 1, 10);
parallelProcesses.addSelectionListener(new SelectionAdapter () {
s_parallelNumber = new Spinner(c3, SWT.BORDER);
setupControl(s_parallelNumber, 1, GridData.BEGINNING);
s_parallelNumber.setValues(cpuNumber, SPINNER_MIN_VALUE, SPINNER_MAX_VALUE, 0, 1, 10);
s_parallelNumber.addSelectionListener(new SelectionAdapter () {
@Override
public void widgetSelected(SelectionEvent e) {
setParallelNumber(parallelProcesses.getSelection());
setParallelDef(true);
setParallelNumber(s_parallelNumber.getSelection());
updateButtons();
}
});
b_parallelUnlimited= new Button(c3, SWT.RADIO);
b_parallelUnlimited.setText(Messages.BuilderSettingsTab_UseUnlimitedJobs);
setupControl(b_parallelUnlimited, 2, GridData.BEGINNING);
((GridData)(b_parallelUnlimited.getLayoutData())).horizontalIndent = 15;
b_parallelUnlimited.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (b_parallelUnlimited.getSelection()) {
setParallelDef(true);
setParallelNumber(Builder.UNLIMITED_JOBS);
updateButtons();
}
}});
// Workbench behaviour group
AccessibleListener makeTargetLabelAccessibleListener = new AccessibleAdapter() {
@Override
@ -166,6 +191,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
b_autoBuild = setupCheck(g4, Messages.BuilderSettingsTab_17, 1, GridData.BEGINNING);
t_autoBuild = setupBlock(g4, b_autoBuild);
t_autoBuild.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (canModify)
setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, t_autoBuild.getText());
@ -175,6 +201,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
b_cmdBuild = setupCheck(g4, Messages.BuilderSettingsTab_19, 1, GridData.BEGINNING);
t_cmdBuild = setupBlock(g4, b_cmdBuild);
t_cmdBuild.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (canModify)
setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, t_cmdBuild.getText());
@ -183,6 +210,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
b_cmdClean = setupCheck(g4, Messages.BuilderSettingsTab_20, 1, GridData.BEGINNING);
t_cmdClean = setupBlock(g4, b_cmdClean);
t_cmdClean.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (canModify)
setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, t_cmdClean.getText());
@ -191,6 +219,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
}
/**
* Calculate enablements when multiple configurations selected on property page.
*
* @return:
* Mode 0:
@ -202,56 +231,52 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
* 0: isStopOnError
* 1: supportsStopOnError(true)
* 2: bld.supportsStopOnError(false)
* 3: cfg.getInternalBuilderParallel()
* 3: N/A
* Mode 2:
* 0: b.isAutoBuildEnable()
* 1: b.isIncrementalBuildEnabled()
* 2: b.isCleanBuildEnabled()
* 3: getParallelDef()
* 3: N/A
*/
static int[] calc3states(ICPropertyProvider p,
IConfiguration c,
int mode) {
if (p.isMultiCfg() &&
c instanceof ICMultiItemsHolder)
{
boolean p0 = (mode == 0);
boolean p1 = (mode == 1);
static int[] calc3states(ICPropertyProvider p, IConfiguration mcfg, int mode) {
if (p.isMultiCfg() && mcfg instanceof ICMultiItemsHolder) {
boolean m0 = (mode == 0);
boolean m1 = (mode == 1);
IConfiguration[] cfs = (IConfiguration[])((ICMultiItemsHolder)c).getItems();
IBuilder b = cfs[0].getBuilder();
int[] res = new int[TRI_STATES_SIZE];
boolean[] x = new boolean[TRI_STATES_SIZE];
x[0] = p0 ? b.isManagedBuildOn() :
(p1 ? b.isStopOnError() : b.isAutoBuildEnable());
x[1] = p0 ? b.isDefaultBuildCmd():
(p1 ? b.supportsStopOnError(true) : b.isIncrementalBuildEnabled() );
x[2] = p0 ? b.canKeepEnvironmentVariablesInBuildfile() :
(p1 ? b.supportsStopOnError(false) : b.isCleanBuildEnabled());
x[3] = p0 ? b.keepEnvironmentVariablesInBuildfile() :
( p1 ? ((Configuration)cfs[0]).getInternalBuilderParallel() : getParallelDef(c));
for (int i=1; i<cfs.length; i++) {
b = cfs[i].getBuilder();
if (x[0] != (p0 ? b.isManagedBuildOn() :
(p1 ? b.isStopOnError() : b.isAutoBuildEnable())))
IConfiguration[] cfgs = (IConfiguration[])((ICMultiItemsHolder)mcfg).getItems();
IBuilder bldr0 = cfgs[0].getBuilder();
int[] res = new int[TRI_STATES_SIZE];
boolean[] b = new boolean[TRI_STATES_SIZE];
b[0] = m0 ? bldr0.isManagedBuildOn() :
(m1 ? bldr0.isStopOnError() : bldr0.isAutoBuildEnable());
b[1] = m0 ? bldr0.isDefaultBuildCmd():
(m1 ? bldr0.supportsStopOnError(true) : bldr0.isIncrementalBuildEnabled() );
b[2] = m0 ? bldr0.canKeepEnvironmentVariablesInBuildfile() :
(m1 ? bldr0.supportsStopOnError(false) : bldr0.isCleanBuildEnabled());
b[3] = m0 ? bldr0.keepEnvironmentVariablesInBuildfile() : false;
for (int i=1; i<cfgs.length; i++) {
IBuilder bldr = cfgs[i].getBuilder();
if (b[0] != (m0 ? bldr.isManagedBuildOn() :
(m1 ? bldr.isStopOnError() : bldr.isAutoBuildEnable())))
res[0] = TRI_UNKNOWN;
if (x[1] != (p0 ? b.isDefaultBuildCmd() :
(p1 ? b.supportsStopOnError(true) : b.isIncrementalBuildEnabled())))
if (b[1] != (m0 ? bldr.isDefaultBuildCmd() :
(m1 ? bldr.supportsStopOnError(true) : bldr.isIncrementalBuildEnabled())))
res[1] = TRI_UNKNOWN;
if (x[2] != (p0 ? b.canKeepEnvironmentVariablesInBuildfile() :
(p1 ? b.supportsStopOnError(false) : b.isCleanBuildEnabled())))
if (b[2] != (m0 ? bldr.canKeepEnvironmentVariablesInBuildfile() :
(m1 ? bldr.supportsStopOnError(false) : bldr.isCleanBuildEnabled())))
res[2] = TRI_UNKNOWN;
if (x[3] != (p0 ? b.keepEnvironmentVariablesInBuildfile() :
(p1 ? ((Configuration)cfs[i]).getInternalBuilderParallel() : getParallelDef(c))))
if (b[3] != (m0 ? bldr.keepEnvironmentVariablesInBuildfile() : false)) {
res[3] = TRI_UNKNOWN;
}
}
for (int i=0; i<TRI_STATES_SIZE; i++) {
if (res[i] != TRI_UNKNOWN)
res[i] = x[i] ? TRI_YES : TRI_NO;
res[i] = b[i] ? TRI_YES : TRI_NO;
}
return res;
} else
return null;
}
return null;
}
/**
@ -259,10 +284,11 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
*/
@Override
protected void updateButtons() {
bldr = icfg.getEditableBuilder();
bldr = (Builder) icfg.getEditableBuilder();
canModify = false;
int[] extStates = calc3states(page, icfg, 1);
// Stop on error
if (extStates != null) {
setTriSelection(b_stopOnError, extStates[0]);
b_stopOnError.setEnabled(
@ -273,42 +299,24 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
b_stopOnError.setEnabled(
bldr.supportsStopOnError(true) &&
bldr.supportsStopOnError(false));
}
// parallel
if (extStates == null) // no extended states
setTriSelection(b_parallel, getInternalBuilderParallel());
else
setTriSelection(b_parallel, extStates[3]);
}
updateParallelBlock();
int n = getParallelNumber();
if (n < 0) n = -n;
parallelProcesses.setSelection(n);
b_parallel.setVisible(bldr.supportsParallelBuild());
b_parallelOpt.setVisible(bldr.supportsParallelBuild());
b_parallelNum.setVisible(bldr.supportsParallelBuild());
parallelProcesses.setVisible(bldr.supportsParallelBuild());
// Build commands
extStates = calc3states(page, icfg, 2);
if (extStates == null) {
setTriSelection(b_autoBuild, bldr.isAutoBuildEnable());
setTriSelection(b_cmdBuild, bldr.isIncrementalBuildEnabled());
setTriSelection(b_cmdClean, bldr.isCleanBuildEnabled());
b_parallelOpt.setSelection(getParallelDef(icfg));
b_parallelNum.setSelection(!getParallelDef(icfg));
} else {
if (extStates != null) {
// multiple configurations selected
setTriSelection(b_autoBuild, extStates[0]);
setTriSelection(b_cmdBuild, extStates[1]);
setTriSelection(b_cmdClean, extStates[2]);
if (extStates[3] == TRI_UNKNOWN) {
b_parallelOpt.setSelection(false);
b_parallelNum.setSelection(false);
} else {
b_parallelOpt.setSelection(getParallelDef(icfg));
b_parallelNum.setSelection(!getParallelDef(icfg));
}
} else {
setTriSelection(b_autoBuild, bldr.isAutoBuildEnable());
setTriSelection(b_cmdBuild, bldr.isIncrementalBuildEnabled());
setTriSelection(b_cmdClean, bldr.isCleanBuildEnabled());
}
if (page.isMultiCfg()) {
MultiConfiguration mc = (MultiConfiguration)icfg;
t_autoBuild.setText(mc.getBuildAttribute(IBuilder.BUILD_TARGET_AUTO, EMPTY_STR));
@ -320,13 +328,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
t_cmdClean.setText(bldr.getBuildAttribute(IBuilder.BUILD_TARGET_CLEAN, EMPTY_STR));
}
boolean external = ! isInternalBuilderEnabled();
boolean parallel = b_parallel.getSelection();
b_parallelNum.setEnabled(parallel);
b_parallelOpt.setEnabled(parallel);
parallelProcesses.setEnabled(parallel & b_parallelNum.getSelection());
boolean external = ! isInternalBuilderEnabled();
title2.setVisible(external);
t_autoBuild.setVisible(external);
((Control)t_autoBuild.getData()).setVisible(external);
@ -334,7 +336,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
((Control)t_cmdBuild.getData()).setVisible(external);
t_cmdClean.setVisible(external);
((Control)t_cmdClean.getData()).setVisible(external);
if (external) {
checkPressed(b_autoBuild, false);
checkPressed(b_cmdBuild, false);
@ -343,6 +345,79 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
canModify = true;
}
private void updateParallelBlock() {
// note: for multi-config selection bldr is from Active cfg
boolean isParallelSupported = bldr.supportsParallelBuild();
boolean isParallelOn = bldr.isParallelBuildOn();
int triSelection = isParallelOn ? TRI_YES : TRI_NO;
int parallelizationNumInternal = bldr.getParallelizationNumAttribute();
int optimalParallelNumber = bldr.getOptimalParallelJobNum();
int parallelNumber = bldr.getParallelizationNum();
if (icfg instanceof ICMultiItemsHolder) {
IConfiguration[] cfgs = (IConfiguration[])((ICMultiItemsHolder)icfg).getItems();
boolean isAnyParallelOn = isParallelOn;
boolean isAnyParallelSupported = isParallelSupported;
boolean isParallelDiffers = false;
for (IConfiguration cfg : cfgs) {
Builder builder = (Builder) cfg.getBuilder();
isParallelDiffers = isParallelDiffers
|| builder.isParallelBuildOn() != isParallelOn
|| builder.getParallelizationNumAttribute() != parallelizationNumInternal;
isAnyParallelOn = isAnyParallelOn || builder.isParallelBuildOn();
isAnyParallelSupported = isAnyParallelSupported || builder.supportsParallelBuild();
}
// reset initial display to "optimal" to enhance user experience:
if ((!isParallelSupported && isAnyParallelSupported) // parallel is supported by other than Active cfg
|| (!isParallelOn && isAnyParallelOn) // prevent showing the 1 job as parallel in the spinner
) {
isParallelSupported = true;
parallelizationNumInternal = -optimalParallelNumber;
parallelNumber = optimalParallelNumber;
}
if (isParallelSupported && isParallelDiffers) {
triSelection = TRI_UNKNOWN;
}
}
b_parallel.setVisible(isParallelSupported);
b_parallelOptimal.setVisible(isParallelSupported);
b_parallelSpecific.setVisible(isParallelSupported);
b_parallelUnlimited.setVisible(isParallelSupported);
s_parallelNumber.setVisible(isParallelSupported);
if (isParallelSupported) {
setTriSelection(b_parallel, triSelection);
boolean isParallelSelected = b_parallel.getSelection();
b_parallelOptimal.setText(MessageFormat.format(Messages.BuilderSettingsTab_UseOptimalJobs, optimalParallelNumber));
b_parallelOptimal.setEnabled(isParallelSelected);
b_parallelSpecific.setEnabled(isParallelSelected);
b_parallelUnlimited.setEnabled(isParallelSelected);
if (isParallelSelected) {
boolean isOptimal = parallelizationNumInternal <= 0;
boolean isUnlimited = parallelizationNumInternal == Builder.UNLIMITED_JOBS;
b_parallelOptimal.setSelection(isOptimal);
b_parallelSpecific.setSelection(!isOptimal && !isUnlimited);
b_parallelUnlimited.setSelection(isUnlimited);
s_parallelNumber.setEnabled(b_parallelSpecific.getEnabled() && b_parallelSpecific.getSelection());
s_parallelNumber.setSelection(s_parallelNumber.isEnabled() ? parallelNumber : optimalParallelNumber);
} else {
b_parallelOptimal.setSelection(true);
b_parallelSpecific.setSelection(false);
b_parallelUnlimited.setSelection(false);
s_parallelNumber.setEnabled(false);
s_parallelNumber.setSelection(optimalParallelNumber);
}
}
}
/**
* Sets up text + corresponding button
* Checkbox can be implemented either by Button or by TriButton
@ -446,7 +521,7 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
}
b2.setStopOnError(b1.isStopOnError());
b2.setParallelBuildOn(b1.isParallelBuildOn());
b2.setParallelizationNum(b1.getParallelizationNum());
b2.setParallelizationNum(((Builder) b1).getParallelizationNumAttribute());
if (b2.canKeepEnvironmentVariablesInBuildfile())
b2.setKeepEnvironmentVariablesInBuildfile(b1.keepEnvironmentVariablesInBuildfile());
((Builder)b2).setBuildPath(((Builder)b1).getBuildPathAttribute());
@ -488,14 +563,6 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
updateData(getResDesc());
}
private static boolean getParallelDef(IConfiguration cfg) {
if (cfg instanceof Configuration)
return ((Configuration)cfg).getParallelDef();
if (cfg instanceof IMultiConfiguration)
return ((IMultiConfiguration)cfg).getParallelDef();
return false;
}
private void setParallelDef(boolean def) {
if (icfg instanceof Configuration)
((Configuration)icfg).setParallelDef(def);
@ -503,13 +570,6 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
((IMultiConfiguration)icfg).setParallelDef(def);
}
private int getParallelNumber() {
if (icfg instanceof Configuration)
return ((Configuration)icfg).getParallelNumber();
if (icfg instanceof IMultiConfiguration)
return ((IMultiConfiguration)icfg).getParallelNumber();
return 0;
}
private void setParallelNumber(int num) {
if (icfg instanceof Configuration)
((Configuration)icfg).setParallelNumber(num);
@ -517,14 +577,6 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab {
((IMultiConfiguration)icfg).setParallelNumber(num);
}
private boolean getInternalBuilderParallel() {
if (icfg instanceof Configuration)
return ((Configuration)icfg).getInternalBuilderParallel();
if (icfg instanceof IMultiConfiguration)
return ((IMultiConfiguration)icfg).getInternalBuilderParallel();
return false;
}
private boolean isInternalBuilderEnabled() {
if (icfg instanceof Configuration)
return ((Configuration)icfg).isInternalBuilderEnabled();

View file

@ -87,6 +87,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
setupLabel(g1, Messages.BuilderSettingsTab_5, 1, GridData.BEGINNING);
t_buildCmd = setupBlock(g1, b_useDefault);
t_buildCmd.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (! canModify)
return;
@ -111,6 +112,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
setupLabel(group_dir, Messages.BuilderSettingsTab_22, 1, GridData.BEGINNING);
t_dir = setupText(group_dir, 1, GridData.FILL_HORIZONTAL);
t_dir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (canModify)
setBuildPath(t_dir.getText());
@ -171,7 +173,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
canEnableInternalBuilder(true) &&
canEnableInternalBuilder(false));
t_buildCmd.setText(getMC());
t_buildCmd.setText(getMakeCommand());
if (page.isMultiCfg()) {
group_dir.setVisible(false);
@ -293,11 +295,14 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
/**
* @return make command
*/
private String getMC() {
String makeCommand = bldr.getCommand();
String makeArgs = bldr.getArguments();
if (makeArgs != null) { makeCommand += " " + makeArgs; } //$NON-NLS-1$
return makeCommand;
private String getMakeCommand() {
String makeCommand = icfg.getBuildCommand();
String makeArgs = icfg.getBuildArguments();
if (!makeCommand.isEmpty() && makeArgs != null) {
return makeCommand + " " + makeArgs; //$NON-NLS-1$
}
return EMPTY_STR;
}
/**
* Performs common settings for all controls

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2010, 2011 Tomasz Wesolowski 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:
* Tomasz Wesolowski - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
@ -18,7 +28,7 @@ public class CaseBreakQuickFixTest extends QuickFixTestCase {
// case 2:
// }
// }
public void testMiddleCase() {
public void testMiddleCase() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("break; case 2:", result);
@ -31,11 +41,12 @@ public class CaseBreakQuickFixTest extends QuickFixTestCase {
// hello();
// }
// }
public void testLastCase() {
public void testLastCase() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("break; }", result);
}
// void func() {
// int a;
// switch(a) {
@ -44,9 +55,9 @@ public class CaseBreakQuickFixTest extends QuickFixTestCase {
// }
// }
// }
public void testLastCaseComp() {
public void testLastCaseComp() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("hello(); break;", result);
assertContainedIn("hello();\t\tbreak;", result);
}
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tomasz Wesolowski - initial API and implementation
* Tomasz Wesolowski - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
@ -93,5 +93,4 @@ public class CatchByReferenceQuickFixTest extends QuickFixTestCase {
String result = runQuickFixOneFile();
assertContainedIn("catch (const C &)", result); //$NON-NLS-1$
}
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tomasz Wesolowski - initial API and implementation
* Tomasz Wesolowski - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
@ -30,7 +30,7 @@ public class CreateLocalVariableQuickFixTest extends QuickFixTestCase {
/*
* (non-Javadoc)
*
*
* @see org.eclipse.cdt.codan.core.test.CodanTestCase#setUp()
*/
@Override
@ -43,7 +43,7 @@ public class CreateLocalVariableQuickFixTest extends QuickFixTestCase {
// void func() {
// aChar = 'a';
// }
public void testChar() {
public void testChar() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("char aChar;", result); //$NON-NLS-1$
@ -52,7 +52,7 @@ public class CreateLocalVariableQuickFixTest extends QuickFixTestCase {
// void func() {
// aDouble = 40.;
// }
public void testDouble() {
public void testDouble() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("double aDouble;", result); //$NON-NLS-1$
@ -61,25 +61,25 @@ public class CreateLocalVariableQuickFixTest extends QuickFixTestCase {
// void func() {
// aString = "foo";
// }
public void testString() {
public void testString() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("const char *aString;", result); //$NON-NLS-1$
assertContainedIn("const char* aString;", result); //$NON-NLS-1$
}
// void func() {
// aWString = L"foo";
// }
public void testWString() {
public void testWString() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("const wchar_t *aWString;", result); //$NON-NLS-1$
assertContainedIn("const wchar_t* aWString;", result); //$NON-NLS-1$
}
// void func() {
// aFuncPtr = func;
// }
public void testFuncPtr() {
public void testFuncPtr() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("void (*aFuncPtr)();", result); //$NON-NLS-1$

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
@ -17,7 +17,6 @@ import org.eclipse.cdt.codan.core.test.CheckerTestCase;
import org.eclipse.cdt.codan.core.test.TestUtils;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPreferenceStore;
@ -27,19 +26,19 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* TODO: add description
* Abstract base class for Quck Fix tests.
*/
@SuppressWarnings("restriction")
public abstract class QuickFixTestCase extends CheckerTestCase {
AbstractCodanCMarkerResolution quickFix;
Display display;
/**
* Dispatch ui events for at least msec - milliseconds
*
*
* @param msec -
* milliseconds delay
* @param display -
@ -60,7 +59,7 @@ public abstract class QuickFixTestCase extends CheckerTestCase {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = window.getActivePage();
IWorkbenchPart activePart = activePage.getActivePart();
if (activePart.getTitle().equals("Welcome")) {
if (activePart.getTitle().equals("Welcome")) { //$NON-NLS-1$
//activePage.close();
activePart.dispose();
}
@ -69,7 +68,6 @@ public abstract class QuickFixTestCase extends CheckerTestCase {
}
}
@SuppressWarnings("restriction")
@Override
public void setUp() throws Exception {
super.setUp();
@ -77,7 +75,7 @@ public abstract class QuickFixTestCase extends CheckerTestCase {
display = PlatformUI.getWorkbench().getDisplay();
closeWelcome();
IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(cproject.getProject());
// turn off editor reconsiler
// turn off editor reconciler
store.setValue(PreferenceConstants.P_RUN_IN_EDITOR, false);
}
@ -105,31 +103,15 @@ public abstract class QuickFixTestCase extends CheckerTestCase {
return new TextSelection(code.indexOf(string), string.length());
}
/**
* @return
* @throws CModelException
* @throws PartInitException
* @throws IOException
* @throws CoreException
*/
public String runQuickFixOneFile() {
public String runQuickFixOneFile() throws IOException, CoreException {
// need to load before running codan because otherwise marker is lost when doing quick fix 8[]
try {
runCodan();
doRunQuickFix();
dispatch(500);
String result = TestUtils.loadFile(currentIFile.getContents());
return result;
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
return null;
}
runCodan();
doRunQuickFix();
dispatch(500);
String result = TestUtils.loadFile(currentIFile.getContents());
return result;
}
/**
*
*/
public void doRunQuickFix() {
for (int i = 0; i < markers.length; i++) {
IMarker marker = markers[i];

View file

@ -6,25 +6,22 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
import java.io.File;
import java.io.FileInputStream;
import org.eclipse.cdt.codan.core.test.TestUtils;
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.core.runtime.CoreException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* Test for quick fix for suggested parenthesis
*/
@SuppressWarnings("restriction")
public class SuggestedParenthesisQuickFixTest extends QuickFixTestCase {
@SuppressWarnings("restriction")
@Override
public AbstractCodanCMarkerResolution createQuickFix() {
return new SuggestedParenthesisQuickFix();
@ -34,7 +31,7 @@ public class SuggestedParenthesisQuickFixTest extends QuickFixTestCase {
// int a=1,b=3;
// if (b+a && a>b || b-a) b--; // error here
// }
public void testSimple() throws IOException, CoreException {
public void testSimple() throws Exception {
loadcode(getAboveComment());
String result = runQuickFixOneFile();
assertContainedIn("(b+a && a>b)", result); //$NON-NLS-1$
@ -52,23 +49,18 @@ public class SuggestedParenthesisQuickFixTest extends QuickFixTestCase {
* this test is using two files, there was not actually bugs here so
* quick fix is not called
*/
public void test2FilesExample() throws FileNotFoundException, IOException {
public void test2FilesExample() throws Exception {
CharSequence[] code = getContents(2);
File f1 = loadcode(code[0].toString());
File f2 = loadcode(code[1].toString());
// lets pretend marker is found in main.c but fixes go in both files,
// to check do something like this
try {
EditorUtility.openInEditor(f2);
runCodan();
doRunQuickFix();
String result_main = TestUtils.loadFile(new FileInputStream(f2));
String result_header = TestUtils.loadFile(new FileInputStream(f1));
assertContainedIn("foo", result_main); //$NON-NLS-1$
assertContainedIn("foo", result_header); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
EditorUtility.openInEditor(f2);
runCodan();
doRunQuickFix();
String result_main = TestUtils.loadFile(new FileInputStream(f2));
String result_header = TestUtils.loadFile(new FileInputStream(f1));
assertContainedIn("foo", result_main); //$NON-NLS-1$
assertContainedIn("foo", result_header); //$NON-NLS-1$
}
}

View file

View file

View file

@ -266,8 +266,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertNoProblemBindings(col);
}
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception
{
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@ -285,8 +284,7 @@ public class AST2CPPTests extends AST2BaseTest {
return new BindingAssertionHelper(code, true);
}
public void testBug40422() throws Exception
{
public void testBug40422() throws Exception {
IASTTranslationUnit tu = parse("class A { int y; }; int A::* x = 0;", ParserLanguage.CPP); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);

View file

@ -5574,4 +5574,13 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testDependentUsingDeclaration() throws Exception {
parseAndCheckBindings();
}
// template <int> void* foo(int);
// template <typename T> void f(T t) {
// if (T* i = foo<0>(0))
// return;
// }
public void testDirectlyNestedAmbiguity_362976() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -0,0 +1,122 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.io.IOException;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.parser.ParserException;
/**
* Tests for ClassTypeHelper class.
*/
public class ClassTypeHelperTests extends AST2BaseTest {
public ClassTypeHelperTests() {
}
public ClassTypeHelperTests(String name) {
super(name);
}
public static TestSuite suite() {
return suite(ClassTypeHelperTests.class);
}
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
String code= getAboveComment();
return new BindingAssertionHelper(code, true);
}
// struct A {
// A(const A& a);
// };
//
// class B {
// public:
// B();
// int x;
// A* y;
// const A& z;
// static A s;
// };
//
// class C {
// public:
// A a;
// };
public void testHasTrivialCopyCtor() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialCopyCtor(classA));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.hasTrivialCopyCtor(classB));
ICPPClassType classC = helper.assertNonProblem("C {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialCopyCtor(classC));
}
// struct A {
// ~A();
// };
//
// class B {
// public:
// B();
// B(const B& a);
// int x;
// B* y;
// const B& z;
// static A s;
// };
//
// class C {
// public:
// A a;
// };
public void testHasTrivialDestructor() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialDestructor(classA));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.hasTrivialDestructor(classB));
ICPPClassType classC = helper.assertNonProblem("C {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.hasTrivialDestructor(classC));
}
// struct A {
// virtual void m();
// };
//
// class B {
// public:
// B();
// B(const B& a);
// void m();
// int x;
// B* y;
// const B& z;
// };
//
// class C : public A {
// };
public void testIsPolymorphic() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
ICPPClassType classA = helper.assertNonProblem("A {", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.isPolymorphic(classA));
ICPPClassType classB = helper.assertNonProblem("B {", 1, ICPPClassType.class);
assertFalse(ClassTypeHelper.isPolymorphic(classB));
ICPPClassType classC = helper.assertNonProblem("C", 1, ICPPClassType.class);
assertTrue(ClassTypeHelper.isPolymorphic(classC));
}
}

View file

@ -30,6 +30,7 @@ public class DOMParserTestSuite extends TestCase {
suite.addTest(ASTCPPSpecDefectTests.suite());
suite.addTest(AST2CPPImplicitNameTests.suite());
suite.addTest(AST2TemplateTests.suite());
suite.addTest(ClassTypeHelperTests.suite());
suite.addTestSuite(QuickParser2Tests.class);
suite.addTest(CompleteParser2Tests.suite());
suite.addTest(DOMLocationTests.suite());

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;
@ -27,7 +27,6 @@ import org.eclipse.jface.text.TextSelection;
/**
* @author Guido Zgraggen IFS
*
*/
public abstract class RewriteBaseTest extends BaseTestFramework implements ILogListener{
protected static final NullProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
@ -49,37 +48,37 @@ public abstract class RewriteBaseTest extends BaseTestFramework implements ILogL
@Override
protected abstract void runTest() throws Throwable;
@Override
protected void setUp() throws Exception {
super.setUp();
for (TestSourceFile testFile : fileMap.values()) {
if(testFile.getSource().length() > 0) {
if (testFile.getSource().length() > 0) {
importFile(testFile.getName(), testFile.getSource());
}
}
}
protected void assertEquals(TestSourceFile file, IFile file2) throws Exception {
StringBuffer code = getCodeFromIFile(file2);
StringBuilder code = getCodeFromFile(file2);
assertEquals(file.getExpectedSource(), TestHelper.unifyNewLines(code.toString()));
}
protected void compareFiles(Map<String,TestSourceFile> testResourceFiles) throws Exception {
protected void compareFiles(Map<String, TestSourceFile> testResourceFiles) throws Exception {
for (String fileName : testResourceFiles.keySet()) {
TestSourceFile file = testResourceFiles.get(fileName);
IFile iFile = project.getFile(new Path(fileName));
StringBuffer code = getCodeFromIFile(iFile);
assertEquals(TestHelper.unifyNewLines(file.getExpectedSource()), TestHelper.unifyNewLines(code.toString()));
StringBuilder code = getCodeFromFile(iFile);
assertEquals(TestHelper.unifyNewLines(file.getExpectedSource()),
TestHelper.unifyNewLines(code.toString()));
}
}
protected StringBuffer getCodeFromIFile(IFile file) throws Exception {
protected StringBuilder getCodeFromFile(IFile file) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(file.getContents()));
StringBuffer code = new StringBuffer();
StringBuilder code = new StringBuilder();
String line;
while((line = br.readLine()) != null) {
while ((line = br.readLine()) != null) {
code.append(line);
code.append('\n');
}
@ -96,10 +95,10 @@ public abstract class RewriteBaseTest extends BaseTestFramework implements ILogL
public void logging(IStatus status, String plugin) {
Throwable ex = status.getException();
StringBuffer stackTrace = new StringBuffer();
if(ex != null) {
StringBuilder stackTrace = new StringBuilder();
if (ex != null) {
stackTrace.append('\n');
for(StackTraceElement ste : ex.getStackTrace()) {
for (StackTraceElement ste : ex.getStackTrace()) {
stackTrace.append(ste.toString());
}
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;
@ -33,10 +33,8 @@ import org.osgi.framework.Bundle;
/**
* @author Emanuel Graf
*
*/
public class RewriteTester extends TestSuite{
public class RewriteTester extends TestSuite {
enum MatcherState{skip, inTest, inSource, inExpectedResult}
private static final String classRegexp = "//#(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
@ -44,7 +42,7 @@ public class RewriteTester extends TestSuite{
private static final String fileRegexp = "//@(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$
public static Test suite(String name, String file)throws Exception {
public static Test suite(String name, String file) throws Exception {
BufferedReader in = createReader(file);
ArrayList<RewriteBaseTest> testCases = createTests(in);
@ -60,7 +58,6 @@ public class RewriteTester extends TestSuite{
}
private static ArrayList<RewriteBaseTest> createTests(BufferedReader inputReader) throws Exception {
String line;
Vector<TestSourceFile> files = new Vector<TestSourceFile>();
TestSourceFile actFile = null;
@ -70,10 +67,9 @@ public class RewriteTester extends TestSuite{
String className = null;
boolean bevorFirstTest = true;
while ((line = inputReader.readLine()) != null){
if(lineMatchesBeginOfTest(line)) {
if(!bevorFirstTest) {
while ((line = inputReader.readLine()) != null) {
if (lineMatchesBeginOfTest(line)) {
if (!bevorFirstTest) {
RewriteBaseTest test = createTestClass(className, testName, files);
testCases.add(test);
files = new Vector<TestSourceFile>();
@ -84,27 +80,27 @@ public class RewriteTester extends TestSuite{
testName = getNameOfTest(line);
bevorFirstTest = false;
continue;
} else if (lineMatchesBeginOfResult(line)) {
} else if (lineMatchesBeginOfResult(line)) {
matcherState = MatcherState.inExpectedResult;
continue;
}else if (lineMatchesFileName(line)) {
} else if (lineMatchesFileName(line)) {
matcherState = MatcherState.inSource;
actFile = new TestSourceFile(getFileName(line));
files.add(actFile);
continue;
}else if(lineMatchesClassName(line)) {
} else if (lineMatchesClassName(line)) {
className = getNameOfClass(line);
continue;
}
switch(matcherState) {
switch (matcherState) {
case inSource:
if(actFile != null) {
if (actFile != null) {
actFile.addLineToSource(line);
}
break;
case inExpectedResult:
if(actFile != null) {
if (actFile != null) {
actFile.addLineToExpectedSource(line);
}
break;
@ -117,11 +113,8 @@ public class RewriteTester extends TestSuite{
return testCases;
}
private static RewriteBaseTest createTestClass(String className, String testName, Vector<TestSourceFile> files) throws Exception {
private static RewriteBaseTest createTestClass(String className, String testName,
Vector<TestSourceFile> files) throws Exception {
try {
Class<?> refClass = Class.forName(className);
Class<?> paratypes[] = new Class[2];
@ -134,7 +127,7 @@ public class RewriteTester extends TestSuite{
RewriteBaseTest test = (RewriteBaseTest) ct.newInstance(arglist);
for (TestSourceFile file : files) {
TextSelection sel = file.getSelection();
if(sel != null) {
if (sel != null) {
test.setFileWithSelection(file.getName());
test.setSelection(sel);
break;
@ -142,7 +135,8 @@ public class RewriteTester extends TestSuite{
}
return test;
} catch (ClassNotFoundException e) {
throw new Exception("Unknown TestClass: " + e.getMessage() + ". Make sure the test's sourcefile specifies a valid test class.");
throw new Exception("Unknown TestClass: " + e.getMessage() +
". Make sure the test's sourcefile specifies a valid test class.");
} catch (SecurityException e) {
throw new Exception("Security Exception during Test creation", e);
} catch (NoSuchMethodException e) {
@ -160,18 +154,16 @@ public class RewriteTester extends TestSuite{
private static String getFileName(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(fileRegexp, line);
if(matcherBeginOfTest.find())
if (matcherBeginOfTest.find())
return matcherBeginOfTest.group(1);
else
return null;
return null;
}
private static String getNameOfClass(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(classRegexp, line);
if(matcherBeginOfTest.find())
if (matcherBeginOfTest.find())
return matcherBeginOfTest.group(1);
else
return null;
return null;
}
private static boolean lineMatchesBeginOfTest(String line) {
@ -192,10 +184,9 @@ public class RewriteTester extends TestSuite{
private static String getNameOfTest(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(testRegexp, line);
if(matcherBeginOfTest.find())
if (matcherBeginOfTest.find())
return matcherBeginOfTest.group(1);
else
return "Not Named";
return "Not Named";
}
private static boolean lineMatchesBeginOfResult(String line) {
@ -205,7 +196,7 @@ public class RewriteTester extends TestSuite{
private static TestSuite createSuite(ArrayList<RewriteBaseTest> testCases, String name) {
TestSuite suite = new TestSuite(name);
Iterator<RewriteBaseTest> it = testCases.iterator();
while(it.hasNext()) {
while (it.hasNext()) {
RewriteBaseTest subject =it.next();
suite.addTest(subject);
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite;

View file

@ -18,10 +18,8 @@ import org.eclipse.jface.text.TextSelection;
/**
* @author Emanuel Graf
*
*/
public class TestSourceFile {
private static final String REPLACEMENT = ""; //$NON-NLS-1$
private String name;
private StringBuffer source = new StringBuffer();
@ -39,29 +37,32 @@ public class TestSourceFile {
super();
this.name = name;
}
public String getExpectedSource() {
String exp = expectedSource.toString();
if(exp.length() == 0) {
if (exp.length() == 0) {
return getSource();
}else {
} else {
return exp;
}
}
public String getName() {
return name;
}
public String getSource() {
return source.toString();
}
public void addLineToSource(String code) {
Matcher start = createMatcherFromString(selectionStartLineRegex, code);
if(start.matches()) {
if (start.matches()) {
selectionStart = start.start(2) + source.length();
code = code.replaceAll(selectionStartRegex, REPLACEMENT);
}
Matcher end = createMatcherFromString(selectionEndLineRegex, code);
if(end.matches()) {
if (end.matches()) {
selectionEnd = end.start(2) + source.length();
code = code.replaceAll(selectionEndRegex, REPLACEMENT);
}
@ -75,11 +76,9 @@ public class TestSourceFile {
}
public TextSelection getSelection() {
if(selectionStart < 0 || selectionEnd <0 ) {
if (selectionStart < 0 || selectionEnd <0 )
return null;
}else {
return new TextSelection(selectionStart, selectionEnd -selectionStart);
}
return new TextSelection(selectionStart, selectionEnd -selectionStart);
}
protected static Matcher createMatcherFromString(String pattern, String line) {

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@ -57,7 +57,7 @@ public class ASTWriterTest extends RewriteBaseTest {
protected void setUp() throws Exception {
super.setUp();
for (TestSourceFile testFile : fileMap.values()) {
if(testFile.getSource().length() > 0) {
if (testFile.getSource().length() > 0) {
file = importFile(testFile.getName(), testFile.getSource());
}
}
@ -70,11 +70,12 @@ public class ASTWriterTest extends RewriteBaseTest {
}
@Override
protected void compareFiles(Map<String,TestSourceFile> testResourceFiles) throws Exception {
protected void compareFiles(Map<String, TestSourceFile> testResourceFiles) throws Exception {
for (String fileName : testResourceFiles.keySet()) {
TestSourceFile testFile = testResourceFiles.get(fileName);
String code = generateSource(testFile);
assertEquals(TestHelper.unifyNewLines(testFile.getExpectedSource()), TestHelper.unifyNewLines(code + System.getProperty("line.separator"))); //$NON-NLS-1$
assertEquals(TestHelper.unifyNewLines(testFile.getExpectedSource()),
TestHelper.unifyNewLines(code + System.getProperty("line.separator"))); //$NON-NLS-1$
}
}
@ -84,7 +85,7 @@ public class ASTWriterTest extends RewriteBaseTest {
ASTModificationMap map = new ASTModificationMap();
map.getModificationsForNode(unit.getDeclarations()[0]);
ASTWriter writer = new ASTWriter();
return writer.write(unit, null, commentMap);
return writer.write(unit, commentMap);
}
protected ISourceCodeParser getParser(TestSourceFile testFile) throws Exception {
@ -97,43 +98,37 @@ public class ASTWriterTest extends RewriteBaseTest {
IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
ISourceCodeParser parser2 = null;
if( language == ParserLanguage.CPP ) {
if (language == ParserLanguage.CPP) {
ICPPParserExtensionConfiguration config = null;
if (useGNUExtensions){
if (useGNUExtensions) {
config = new GPPParserExtensionConfiguration();
} else{
} else {
config = new ANSICPPParserExtensionConfiguration();
}
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config );
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
} else {
ICParserExtensionConfiguration config = null;
if (useGNUExtensions){
if (useGNUExtensions) {
config = new GCCParserExtensionConfiguration();
} else{
} else {
config = new ANSICParserExtensionConfiguration();
}
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config );
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
}
return parser2;
}
private boolean getGNUExtension(TestSourceFile file) {
if(file instanceof ASTWriterTestSourceFile) {
return ((ASTWriterTestSourceFile)file).isUseGNUExtensions();
}
else {
return false;
}
if (file instanceof ASTWriterTestSourceFile)
return ((ASTWriterTestSourceFile) file).isUseGNUExtensions();
return false;
}
private ParserLanguage getLanguage(TestSourceFile file) {
if(file instanceof ASTWriterTestSourceFile) {
return ((ASTWriterTestSourceFile)file).getParserLanguage();
}
else {
return ParserLanguage.CPP;
}
if (file instanceof ASTWriterTestSourceFile)
return ((ASTWriterTestSourceFile) file).getParserLanguage();
return ParserLanguage.CPP;
}
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile;
/**
* @author Guido Zgraggen IFS
*
*/
public class ASTWriterTestSourceFile extends TestSourceFile {
private ParserLanguage parserLanguage = ParserLanguage.CPP;

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@ -17,35 +17,35 @@ import junit.framework.TestSuite;
/**
* @author Emanuel Graf
*/
public class AstWriterTestSuite{
public class AstWriterTestSuite {
public static Test suite() throws Exception {
TestSuite suite = new TestSuite("AstWriterTests");
suite.addTest(SourceRewriteTester.suite("ExpressionTests", "resources/rewrite/ASTWriterExpressionTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("DelcSpecifierTests", "resources/rewrite/ASTWriterDeclSpecTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented DelcSpecifierTests",
"resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("DeclaratorTests", "resources/rewrite/ASTWriterDeclaratorTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented DeclaratorTests",
"resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("StatementsTests", "resources/rewrite/ASTWriterStatementTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented StatementsTests",
"resources/rewrite/ASTWriterCommentedStatementTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("NameTests", "resources/rewrite/ASTWriterNameTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented NameTests", "resources/rewrite/ASTWriterCommentedNameTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("InitializerTests", "resources/rewrite/ASTWriterInitializerTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("DeclarationTests", "resources/rewrite/ASTWriterDeclarationTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("Commented DeclarationTests",
"resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("TemplatesTests", "resources/rewrite/ASTWriterTemplateTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("CommentTests", "resources/rewrite/ASTWriterCommentedTestSource.awts"));
suite.addTest(SourceRewriteTester.suite("NewCommentTests", "resources/rewrite/ASTWriterCommentedTestSource2.awts"));
suite.addTestSuite(ExpressionWriterTest.class);

View file

@ -5,7 +5,8 @@
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Pascal Kesseli (HSR) - Initial API and implementation
* Contributors:
* Pascal Kesseli (HSR) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@ -182,8 +183,7 @@ public class ExpressionWriterTest extends TestCase {
ICPPASTLambdaExpression lambda = new CPPASTLambdaExpression();
CPPASTCompoundStatement stmt = new CPPASTCompoundStatement();
stmt.addStatement(new CPPASTReturnStatement(new CPPASTLiteralExpression(
IASTLiteralExpression.lk_integer_constant,
new char[] { '7' })));
IASTLiteralExpression.lk_integer_constant, new char[] { '7' })));
lambda.setBody(stmt);
return lambda;
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.astwriter;
@ -31,7 +31,6 @@ import org.eclipse.jface.text.TextSelection;
import org.osgi.framework.Bundle;
public class SourceRewriteTester extends TestSuite {
private static final String testRegexp = "//!(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
private static final String codeTypeRegexp = "//%(C|CPP)( GNU)?$"; //$NON-NLS-1$
private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$
@ -56,8 +55,8 @@ public class SourceRewriteTester extends TestSuite {
private static TestSuite createSuite(ArrayList<RewriteBaseTest> testCases, String name) {
TestSuite suite = new TestSuite(name);
Iterator<RewriteBaseTest> it = testCases.iterator();
while(it.hasNext()) {
RewriteBaseTest subject =it.next();
while (it.hasNext()) {
RewriteBaseTest subject = it.next();
suite.addTest(subject);
}
return suite;
@ -77,10 +76,11 @@ public class SourceRewriteTester extends TestSuite {
protected static String getNameOfTest(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(testRegexp, line);
if(matcherBeginOfTest.find())
if (matcherBeginOfTest.find()) {
return matcherBeginOfTest.group(1);
else
} else {
return "Not Named";
}
}
protected static boolean lineMatchesBeginOfResult(String line) {
@ -88,37 +88,37 @@ public class SourceRewriteTester extends TestSuite {
}
private static ArrayList<RewriteBaseTest> createTests(BufferedReader inputReader) throws Exception {
String line;
ASTWriterTestSourceFile file = null;
MatcherState matcherState = MatcherState.skip;
ArrayList<RewriteBaseTest> testCases = new ArrayList<RewriteBaseTest>();
while ((line = inputReader.readLine()) != null){
if(lineMatchesBeginOfTest(line)) {
String line;
while ((line = inputReader.readLine()) != null) {
if (lineMatchesBeginOfTest(line)) {
matcherState = MatcherState.inTest;
file = new ASTWriterTestSourceFile("ASTWritterTest.h"); //$NON-NLS-1$
testCases.add(createTestClass(getNameOfTest(line), file));
continue;
} else if (lineMatchesBeginOfResult(line)) {
} else if (lineMatchesBeginOfResult(line)) {
matcherState = MatcherState.inExpectedResult;
continue;
}else if (lineMatchesCodeType(line)) {
} else if (lineMatchesCodeType(line)) {
matcherState = MatcherState.inSource;
if(file != null) {
if (file != null) {
file.setParserLanguage(getParserLanguage(line));
file.setUseGNUExtensions(useGNUExtensions(line));
}
continue;
}
switch(matcherState) {
switch (matcherState) {
case inSource:
if(file != null) {
if (file != null) {
file.addLineToSource(line);
}
break;
case inExpectedResult:
if(file != null) {
if (file != null) {
file.addLineToExpectedSource(line);
}
break;
@ -131,11 +131,11 @@ public class SourceRewriteTester extends TestSuite {
protected static boolean useGNUExtensions(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(codeTypeRegexp, line);
if(matcherBeginOfTest.find()) {
if (matcherBeginOfTest.find()) {
String codeType = matcherBeginOfTest.group(2);
if(codeType == null) {
if (codeType == null) {
return false;
}else {
} else {
return true;
}
}
@ -144,11 +144,11 @@ public class SourceRewriteTester extends TestSuite {
protected static ParserLanguage getParserLanguage(String line) {
Matcher matcherBeginOfTest = createMatcherFromString(codeTypeRegexp, line);
if(matcherBeginOfTest.find()) {
if (matcherBeginOfTest.find()) {
String codeType = matcherBeginOfTest.group(1);
if(codeType.equalsIgnoreCase("CPP")) { //$NON-NLS-1$
if (codeType.equalsIgnoreCase("CPP")) { //$NON-NLS-1$
return ParserLanguage.CPP;
}else {
} else {
return ParserLanguage.C;
}
}
@ -156,9 +156,9 @@ public class SourceRewriteTester extends TestSuite {
}
private static RewriteBaseTest createTestClass(String testName, ASTWriterTestSourceFile file) throws Exception {
ASTWriterTest test = new ASTWriterTest(testName,file);
ASTWriterTest test = new ASTWriterTest(testName, file);
TextSelection sel = file.getSelection();
if(sel != null) {
if (sel != null) {
test.setFileWithSelection(file.getName());
test.setSelection(sel);
}

View file

@ -38,6 +38,10 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
super();
}
public ChangeGeneratorTest(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
CCorePlugin.getIndexManager().joinIndexer(IIndexManager.FOREVER, new NullProgressMonitor());
@ -45,7 +49,7 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
}
@Override
public void runTest() throws Exception{
public void runTest() throws Exception {
final ASTModificationStore modStore = new ASTModificationStore();
IFile testFile = importFile("source.h", source); //$NON-NLS-1$
@ -65,8 +69,7 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
changegenartor.generateChange(unit);
Document doc = new Document(source);
for (Change curChange : ((CompositeChange) changegenartor.getChange())
.getChildren()) {
for (Change curChange : ((CompositeChange) changegenartor.getChange()).getChildren()) {
if (curChange instanceof TextFileChange) {
TextFileChange textChange = (TextFileChange) curChange;
textChange.getEdit().apply(doc);
@ -77,10 +80,6 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
protected abstract ASTVisitor createModificator(ASTModificationStore modStore);
public ChangeGeneratorTest(String name) {
super(name);
}
@Override
protected void tearDown() throws Exception {
System.gc();

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator;
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace.Replace
/**
* @author Thomas Corbat
*
*/
public class ChangeGeneratorTestSuite{

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
@ -51,13 +52,14 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
arrayDeclarator.getArrayModifiers();
IASTArrayModifier newModifier = new CPPASTArrayModifier();
IASTExpression expr = new CPPASTLiteralExpression(0, "3"); //$NON-NLS-1$
IASTExpression expr = new CPPASTLiteralExpression(
IASTLiteralExpression.lk_integer_constant, "3".toCharArray()); //$NON-NLS-1$
newModifier.setConstantExpression(expr);
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, declarator, newModifier, null);
modStore.storeModification(null, modification);
}
return PROCESS_CONTINUE;
}
}
};
}

View file

@ -7,18 +7,18 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software (IFS)- initial API and implementation
* Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
@ -29,26 +29,26 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
/**
* @author Emanuel Graf IFS
*
*/
public class AddDeclarationBug extends ChangeGeneratorTest {
public AddDeclarationBug() {
super("Add Declaration Bug Test");
AddDeclarationBug() {
super("AddDeclarationBug");
}
public static Test suite() {
return new AddDeclarationBug();
}
@Override
protected void setUp() throws Exception {
source = "class A\n{\npublic:\n A();\n virtual ~A();\n int foo();\n \nprivate:\n int help();\n};"; //$NON-NLS-1$
expectedSource = "class A\n{\npublic:\n A();\n virtual ~A();\n int foo();\n \nprivate:\n int help();\n int exp(int i);\n};"; //$NON-NLS-1$
expectedSource = "class A\n{\npublic:\n A();\n virtual ~A();\n int foo();\n \nprivate:\n int help();\n\tint exp(int i);\n};"; //$NON-NLS-1$
super.setUp();
}
@ -84,8 +84,4 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new AddDeclarationBug();
}
}

View file

@ -7,40 +7,44 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ArrayModifierTest extends ChangeGeneratorTest {
public ArrayModifierTest(){
super("Replace Array Modifier"); //$NON-NLS-1$
ArrayModifierTest() {
super("ArrayModifierTest");
}
public static Test suite() {
return new ArrayModifierTest();
}
@Override
protected void setUp() throws Exception {
source = "int *pi[3];"; //$NON-NLS-1$
expectedSource = "int *pi[5][3];"; //$NON-NLS-1$
source = "int* pi[3];"; //$NON-NLS-1$
expectedSource = "int* pi[5][3];"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -49,11 +53,12 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
@Override
public int visit(IASTDeclarator declarator) {
if (declarator instanceof IASTArrayDeclarator) {
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator) declarator;
IASTArrayModifier[] modifiers = arrayDeclarator.getArrayModifiers();
IASTArrayModifier newModifier = new CPPASTArrayModifier();
IASTExpression expr = new CPPASTLiteralExpression(0, "5"); //$NON-NLS-1$
IASTExpression expr =
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "5".toCharArray()); //$NON-NLS-1$
newModifier.setConstantExpression(expr);
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, modifiers[0], newModifier, null);
modStore.storeModification(null, modification);
@ -62,8 +67,4 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ArrayModifierTest();
}
}

View file

@ -7,17 +7,18 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
@ -25,25 +26,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ArraySizeExpressionTest extends ChangeGeneratorTest {
public ArraySizeExpressionTest(){
super("Insert Array Size Expression"); //$NON-NLS-1$
ArraySizeExpressionTest() {
super("ArraySizeExpressionTest");
}
public static Test suite() {
return new ArraySizeExpressionTest();
}
@Override
protected void setUp() throws Exception {
source = "int *values = new int[5];"; //$NON-NLS-1$
expectedSource = "int *values = new int[6][5];"; //$NON-NLS-1$
source = "int* values = new int[5];"; //$NON-NLS-1$
expectedSource = "int* values = new int[6][5];"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitExpressions = true;
@ -56,7 +57,8 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
IASTTypeId id= newExpression.getTypeId();
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
IASTArrayModifier[] mods= dtor.getArrayModifiers();
IASTArrayModifier add= new CPPASTArrayModifier(new CPPASTLiteralExpression(0, "6"));
IASTArrayModifier add= new CPPASTArrayModifier(
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "6".toCharArray()));
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE, mods[0], add, null);
modStore.storeModification(null, modification);
}
@ -64,9 +66,4 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ArraySizeExpressionTest();
}
}

View file

@ -7,14 +7,14 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConstructorChainInitializer;
@ -22,25 +22,28 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class CtorChainInitializerTest extends ChangeGeneratorTest {
public CtorChainInitializerTest(){
super("Insert Before Ctor Initializer"); //$NON-NLS-1$
CtorChainInitializerTest() {
super("CtorChainInitializerTest");
}
public static Test suite() {
return new CtorChainInitializerTest();
}
@Override
protected void setUp() throws Exception {
source = "TestClass::TestClass(int a, int b):beta(b){\n}\n\n"; //$NON-NLS-1$
expectedSource = "TestClass::TestClass(int a, int b):alpha(a), beta(b){\n}\n\n"; //$NON-NLS-1$
source = "TestClass::TestClass(int a, int b):beta(b) {\n}\n\n"; //$NON-NLS-1$
expectedSource = "TestClass::TestClass(int a, int b) :\n\t\talpha(a), beta(b) {\n}\n\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -49,7 +52,7 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
@Override
public int visit(IASTDeclarator declarator) {
if (declarator instanceof CPPASTFunctionDeclarator) {
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
ICPPASTConstructorChainInitializer ctorInitializer = functionDeclarator.getConstructorChain()[0];
CPPASTIdExpression initExpr = new CPPASTIdExpression(new CPPASTName("a".toCharArray())); //$NON-NLS-1$
CPPASTName initName = new CPPASTName("alpha".toCharArray()); //$NON-NLS-1$
@ -63,9 +66,4 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new CtorChainInitializerTest();
}
}

View file

@ -7,16 +7,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
@ -24,15 +24,19 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ExceptionTest extends ChangeGeneratorTest {
public ExceptionTest(){
super("Insert Before Exception Declaration"); //$NON-NLS-1$
ExceptionTest() {
super("ExceptionTest");
}
public static Test suite() {
return new ExceptionTest();
}
@Override
protected void setUp() throws Exception {
source = "void foo(int parameter) throw (/*Test*/float) /*Test2*/{\n}\n\n"; //$NON-NLS-1$
@ -41,8 +45,7 @@ public class ExceptionTest extends ChangeGeneratorTest {
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -69,9 +72,4 @@ public class ExceptionTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ExceptionTest();
}
}

View file

@ -7,16 +7,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
@ -25,14 +25,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ExpressionTest extends ChangeGeneratorTest {
public ExpressionTest(){
super("Insert Expression"); //$NON-NLS-1$
ExpressionTest() {
super("ExpressionTest");
}
public static Test suite() {
return new ExpressionTest();
}
@Override
@ -41,10 +41,9 @@ public class ExpressionTest extends ChangeGeneratorTest {
expectedSource = "void main(){int s = 0, c = 0, h = 0;\ns = 3, c = 9, h = 5;}"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitExpressions = true;
@ -63,9 +62,4 @@ public class ExpressionTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ExpressionTest();
}
}

View file

@ -7,16 +7,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
@ -24,17 +24,17 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class FirstParameterTest extends ChangeGeneratorTest {
public FirstParameterTest(){
super("Insert Before First Parameter"); //$NON-NLS-1$
FirstParameterTest() {
super("FirstParameterTest");
}
public static Test suite() {
return new FirstParameterTest();
}
@Override
@ -43,11 +43,9 @@ public class FirstParameterTest extends ChangeGeneratorTest {
expectedSource = "void foo(int newParameter, int a){\n}\n\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -77,9 +75,4 @@ public class FirstParameterTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new FirstParameterTest();
}
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
@ -16,12 +16,11 @@ import junit.framework.TestSuite;
/**
* @author Thomas Corbat
*
*/
public class InsertBeforeTestSuite{
public class InsertBeforeTestSuite {
public static Test suite() throws Exception {
TestSuite suite = new TestSuite("Changegenerator InsertBefore Tests");
TestSuite suite = new TestSuite("ChangeGenerator InsertBefore Tests");
suite.addTest(FirstParameterTest.suite());
suite.addTest(PointerParameterTest.suite());

View file

@ -7,50 +7,44 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class MultilineWhitespaceHandlingTest extends ChangeGeneratorTest {
public MultilineWhitespaceHandlingTest(){
super("Multiline Whitespace Handling"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n\r\n }\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n int i;\r\n int j;\r\n\r\n }\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
MultilineWhitespaceHandlingTest() {
super("MultilineWhitespaceHandlingTest");
}
public static Test suite() {
return new MultilineWhitespaceHandlingTest();
}
@Override
protected void setUp() throws Exception {
source = "void foo() {\r\n\r\n\tfor(int i = 0; i < 10; i++) {\r\n\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo() {\r\n\r\n\tfor(int i = 0; i < 10; i++) {\r\n\t\tint i;\r\n\t\tint j;\r\n\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;

View file

@ -7,27 +7,31 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class PointerParameterTest extends ChangeGeneratorTest {
public PointerParameterTest(){
super("Insert Pointer for Parameter"); //$NON-NLS-1$
PointerParameterTest() {
super("PointerParameterTest");
}
public static Test suite() {
return new PointerParameterTest();
}
@Override
@ -38,8 +42,7 @@ public class PointerParameterTest extends ChangeGeneratorTest {
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -63,9 +66,4 @@ public class PointerParameterTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new PointerParameterTest();
}
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
@ -21,31 +21,25 @@ import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGenerator
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class SelfInsertionTest extends ChangeGeneratorTest {
public SelfInsertionTest(){
super("Self Insertion Test"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n }\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n for(int i = 0;i < 10;i++){\r\n }\r\n }\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
SelfInsertionTest() {
super("SelfInsertionTest");
}
public static Test suite() {
return new SelfInsertionTest();
}
@Override
protected void setUp() throws Exception {
source = "void foo() {\r\n\r\n\tfor (int i = 0; i < 10; i++) {\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo() {\r\n\r\n\tfor (int i = 0; i < 10; i++) {\r\n\t\tfor (int i = 0; i < 10; i++) {\r\n\t\t}\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;

View file

@ -7,16 +7,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
@ -25,32 +25,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class MoveRenameTest extends ChangeGeneratorTest {
public MoveRenameTest(){
super("Swap Rename Declarations"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int b;\r\n int a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int d;\r\n int b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
MoveRenameTest() {
super("MoveRenameTest");
}
public static Test suite() {
public static Test suite() {
return new MoveRenameTest();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint b;\r\n\tint a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint d;\r\n\tint b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclSpecifiers = true;
@ -70,8 +63,6 @@ public class MoveRenameTest extends ChangeGeneratorTest {
}
return super.visit(declSpec);
}
};
}
}

View file

@ -7,46 +7,40 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class MoveTest extends ChangeGeneratorTest {
public MoveTest(){
super("Swap Declarations"); //$NON-NLS-1$
MoveTest() {
super("MoveTest");
}
@Override
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int b;\r\n int a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int a;\r\n int b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
}
public static Test suite() {
public static Test suite() {
return new MoveTest();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint b;\r\n\tint a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint a;\r\n\tint b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclSpecifiers = true;
@ -64,8 +58,6 @@ public class MoveTest extends ChangeGeneratorTest {
}
return super.visit(declSpec);
}
};
}
}

View file

@ -7,12 +7,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
@ -20,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement;
@ -33,43 +33,37 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ReplaceInsertStatementTest extends ChangeGeneratorTest {
public ReplaceInsertStatementTest() {
super("Replace Insert Statement Test");
ReplaceInsertStatementTest() {
super("ReplaceInsertStatementTest");
}
public static Test suite() {
return new ReplaceInsertStatementTest();
}
@Override
protected void setUp() throws Exception {
source = "void main(){\r\n int i = 0;\r\n ++i;\r\n}"; //$NON-NLS-1$
expectedSource = "void main(){\r\n int i = 0;\r\n i = 42;\r\n i++;\r\n}"; //$NON-NLS-1$
source = "void main() {\r\n\tint i = 0;\r\n\t++i;\r\n}"; //$NON-NLS-1$
expectedSource = "void main() {\r\n\tint i = 0;\r\n\ti = 42;\r\n\ti++;\r\n}"; //$NON-NLS-1$
super.setUp();
}
public static Test suite() {
return new ReplaceInsertStatementTest();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest#createModificator(org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore)
*/
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;
}
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTCompoundStatement) {
IASTCompoundStatement compStmt = (IASTCompoundStatement) statement;
IASTStatement stmt = compStmt.getStatements()[1];
IASTIdExpression id = new CPPASTIdExpression(
new CPPASTName("i".toCharArray()));
IASTIdExpression id = new CPPASTIdExpression(new CPPASTName("i".toCharArray()));
IASTLiteralExpression value = new CPPASTLiteralExpression(
IASTLiteralExpression.lk_integer_constant, "42");
IASTLiteralExpression.lk_integer_constant, "42".toCharArray());
IASTExpressionStatement insertStmt = new CPPASTExpressionStatement(
new CPPASTBinaryExpression(
IASTBinaryExpression.op_assign, id, value));
@ -82,15 +76,12 @@ public class ReplaceInsertStatementTest extends ChangeGeneratorTest {
incExp);
ASTModification replaceMod = new ASTModification(
ASTModification.ModificationKind.REPLACE, stmt,
replaceStatement, null);
ASTModification.ModificationKind.REPLACE, stmt, replaceStatement, null);
modStore.storeModification(null, replaceMod);
ASTModification insertMod = new ASTModification(
ASTModification.ModificationKind.INSERT_BEFORE,
stmt, insertStmt, null);
ASTModification.ModificationKind.INSERT_BEFORE, stmt, insertStmt, null);
modStore.storeModification(null, insertMod);
}
return PROCESS_CONTINUE;

View file

@ -7,16 +7,16 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement;
@ -26,31 +26,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUnaryExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class StatementTest extends ChangeGeneratorTest {
public StatementTest(){
super("Replace Then-Statement"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "int f()\r\n{\r\n\tint i = 0;\r\n\tif(i < 1){\r\n\t\t++i;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "int f()\r\n{\r\n\tint i = 0;\r\n\tif(i < 1){\r\n\t i++;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
StatementTest() {
super("StatementTest");
}
public static Test suite() {
return new StatementTest();
}
@Override
protected void setUp() throws Exception {
source = "int f()\r\n{\r\n\tint i = 0;\r\n\tif (i < 1) {\r\n\t\t++i;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "int f()\r\n{\r\n\tint i = 0;\r\n\tif (i < 1) {\r\n\t\ti++;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
@ -33,9 +33,12 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
import org.eclipse.core.runtime.CoreException;
/**
* This test tests the behavoir of the class ASTCommenter. It checks if the ASTCommenter assigns the comments contained in an AST to the right ASTNodes.<br>
* The source for the CommentHandling tests is located at /resources/rewrite/CommentHandlingTestSource.rts.<br>
* This file contains the source code and the expected output for all the tests. Following a little example how such a test looks like:<br><br>
* This test tests the behavior of the class ASTCommenter. It checks if the ASTCommenter assigns
* the comments contained in an AST to the right ASTNodes.<br>
* The source for the CommentHandling tests is located at
* /resources/rewrite/CommentHandlingTestSource.rts.<br>
* This file contains the source code and the expected output for all the tests.
* Following a little example how such a test looks like:<br><br>
*
* <code><pre>
* //!NameOfTheTest - will be used as JUnit test name
@ -62,12 +65,13 @@ import org.eclipse.core.runtime.CoreException;
*
* The second line (//#org.eclipse.cdt...) indicates the test class (in this case this class).<br>
* The "//=" indicates the beginning of the expected test result.<br>
* The test result contains three sections (separated by "=>leading", "=>trailing" and "=>freestanding").<br>
* Each section contains the raw signature of the node to which a comment is assigned plus " = " and the comment. If there are several comments
* assigned to the same node they are concatenated with a " , ".
* The test result contains three sections (separated by "=>leading", "=>trailing" and
* "=>freestanding").<br>
* Each section contains the raw signature of the node to which a comment is assigned plus " = "
* and the comment. If there are several comments assigned to the same node they are concatenated
* with a " , ".
*
* @author Guido Zgraggen IFS, Lukas Felber IFS
*
*/
public class CommentHandlingTest extends RewriteBaseTest {
@ -88,12 +92,11 @@ public class CommentHandlingTest extends RewriteBaseTest {
@Override
protected void runTest() throws Throwable {
if (fileMap.size() == 0) {
fail("No file for testing"); //$NON-NLS-1$
}
for(String fileName : fileMap.keySet()) {
for (String fileName : fileMap.keySet()) {
TestSourceFile file = fileMap.get(fileName);
NodeCommentMap nodeMap = ASTCommenter.getCommentedNodeMap(getUnit(fileName));
@ -105,8 +108,8 @@ public class CommentHandlingTest extends RewriteBaseTest {
}
private StringBuilder buildExpectedResult(TestSourceFile file) {
Matcher matcher = Pattern.compile(CommentHandlingTest.getSeparatingRegexp(), Pattern.MULTILINE | Pattern.DOTALL).matcher(file.getExpectedSource());
Matcher matcher = Pattern.compile(CommentHandlingTest.getSeparatingRegexp(),
Pattern.MULTILINE | Pattern.DOTALL).matcher(file.getExpectedSource());
if (!matcher.find()) {
fail("Missing expected section. Expected result code must be of the following format:\n\"=>leading\n...\n=>trailing\n...\n=>freestanding\""); //$NON-NLS-1$
}
@ -143,7 +146,6 @@ public class CommentHandlingTest extends RewriteBaseTest {
StringBuilder output = new StringBuilder();
for (IASTNode actNode : keyTree) {
ArrayList<IASTComment> comments = map.get(actNode);
output.append(getSignature(actNode) + " = "); //$NON-NLS-1$
boolean first = true;
for (IASTComment actComment : comments) {
@ -170,11 +172,13 @@ public class CommentHandlingTest extends RewriteBaseTest {
}
private static String getSeparatingRegexp() {
return LEADING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + TRAILING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + FREESTANDING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP;
return LEADING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP + TRAILING_COMMENT_SEPARATOR +
ANY_CHAR_REGEXP + FREESTANDING_COMMENT_SEPARATOR + ANY_CHAR_REGEXP;
}
private IASTTranslationUnit getUnit(String fileName) throws CoreException {
ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(project.getFile(fileName));
ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(
project.getFile(fileName));
return tu.getAST();
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
@ -18,18 +18,14 @@ import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTester;
/**
* @author Guido Zgraggen IFS
*
*/
public class CommentHandlingTestSuite extends TestSuite {
public static Test suite() throws Exception {
TestSuite suite = new TestSuite(CommentHandlingTestSuite.class.getName());
suite.addTest(RewriteTester.suite("CommentTests", "resources/rewrite/CommentHandlingTestSource.rts")); //$NON-NLS-1$ //$NON-NLS-2$
suite.addTest(RewriteTester.suite("CommentTests",
"resources/rewrite/CommentHandlingTestSource.rts")); //$NON-NLS-1$ //$NON-NLS-2$
suite.addTestSuite(NodeCommentMapTest.class);
return suite;
}
}

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
@ -21,10 +21,8 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
* @author Guido Zgraggen IFS
*
*/
public class NodeCommentMapTest extends TestCase {
private NodeCommentMap map;
@Override
@ -39,7 +37,6 @@ public class NodeCommentMapTest extends TestCase {
public void testNoComment(){
ASTNode node = new CPPASTName();
assertEquals(0, map.getLeadingCommentsForNode(node).size());
assertEquals(0, map.getTrailingCommentsForNode(node).size());
assertEquals(0, map.getFreestandingCommentsForNode(node).size());
@ -51,7 +48,6 @@ public class NodeCommentMapTest extends TestCase {
IASTComment comm2 = new Comment();
IASTComment comm3 = new Comment();
map.addLeadingCommentToNode(node, comm1);
map.addTrailingCommentToNode(node, comm2);
map.addFreestandingCommentToNode(node, comm3);
@ -88,8 +84,7 @@ public class NodeCommentMapTest extends TestCase {
assertEquals(com1, map.getFreestandingCommentsForNode(node).get(0));
assertEquals(com2, map.getFreestandingCommentsForNode(node).get(1));
}
public void testCommentOnDifferentNodes(){
ASTNode node1 = new CPPASTName();
ASTNode node2 = new CPPASTName();
@ -129,19 +124,22 @@ public class NodeCommentMapTest extends TestCase {
assertEquals(com3, map.getFreestandingCommentsForNode(node1).get(1));
}
//=== InternalComment class for testing
private class Comment extends ASTNode implements IASTComment{
private class Comment extends ASTNode implements IASTComment {
private char[] comment;
public char[] getComment() {
return comment;
}
public void setComment(char[] comment) {
this.comment = comment;
}
//not used
public boolean isBlockComment() {return false;}
// not used
public boolean isBlockComment() {
return false;
}
public IASTNode copy() {
return null;

View file

@ -11,11 +11,12 @@ const int a = 1;
//Test3
volatile int b = 3;
//Test4
typedef int *intp;
typedef int* intp;
//Test5
extern int b;
//Test6
static int c;
//Test7
int foo()
{
@ -59,7 +60,7 @@ public:
//!Commented ElaboratedTypeSpecifier 1
//%CPP
//Test1
class A *A; //Test2
class A* A; //Test2
//Test3
enum Status{ good, bad}; //Test4
//Test5

View file

@ -76,42 +76,51 @@ extern "C" typedef void FUNC(); /*TEST 2*/
//!Commented NamespaceAlias 1
//%CPP
//TEST 1
namespace kurz = ziemlichlangernamespace; //TEST 2
namespace kurz = somenamespace; //TEST 2
//!Commented NamespaceAlias 2
//%CPP
/*TEST 1*/
namespace kurz = ziemlichlangernamespace; /*TEST 2*/
namespace kurz = somenamespace; /*TEST 2*/
//!Commented NamespaceDefinition 1
//%CPP
//TEST 1
namespace ziemlichlangernamespace
namespace namespace1
{
//TEST 2
//TEST 2
} //TEST 3
//!Commented NamespaceDefinition 2
//%CPP
/*TEST 1*/
namespace ziemlichlangernamespace
namespace namespace2
{
/*TEST 2*/
/*TEST 2*/
} /*TEST 3*/
//!Commented NamespaceDefinition 3
//%CPP
namespace ziemlichlangernamespace
namespace namespace3
{
//TEST
//TEST
}
//!Commented NamespaceDefinition 4
//%CPP
namespace ziemlichlangernamespace
namespace namespace4
{
//TEST
//TEST
}
void doIt()
{
int i = 0;
@ -158,8 +167,9 @@ template<> class MyQueue<double> //TEST 2
{
//TEST 3
std::vector<double> data;
public:
void Add(const double& );
void Add(const double&);
void Remove();
void Print();
//TEST 4
@ -173,8 +183,9 @@ template<> class MyQueue<double> /*TEST 2*/
{
/*TEST 3*/
std::vector<double> data;
public:
void Add(const double& );
void Add(const double&);
void Remove();
void Print();
/*TEST 4*/
@ -214,9 +225,11 @@ class A
//TEST 1
public: //TEST 2
int hallo();
/*TEST 3*/
protected: /*TEST 4*/
int b, c;
private:
int p;
};
@ -231,13 +244,13 @@ int i = 2; //TEST 2
/*TEST 1*/
int i = 2; /*TEST 2*/
//!Commented typename qualfier 1
//!Commented typename qualifier 1
//%CPP
//TEST 1
typename T::A *a6; //TEST 2
typename T::A* a6; //TEST 2
//!Commented typename qualfier 2
//!Commented typename qualifier 2
//%CPP
/*TEST 1*/
typename T::A *a6; /*TEST 2*/
typename T::A* a6; /*TEST 2*/

View file

@ -8,7 +8,7 @@ void foo()
{
int f();
};
int (B::* pb)() = &B::f;
int (B::*pb)() = &B::f;
}
@ -22,13 +22,14 @@ void foo()
{
int f();
};
int (B::* pb)() = &B::f;
int (B::*pb)() = &B::f;
}
//!Commented CPPFunctionDeclaratorTest 1
//%CPP
char & operator [](unsigned int);
char& operator [](unsigned int);
//TEST 1
TestClass::TestClass(int a) //TEST 2
{
@ -38,7 +39,8 @@ TestClass::TestClass(int a) //TEST 2
//!Commented CPPFunctionDeclaratorTest 2
//%CPP
char & operator [](unsigned int);
char& operator [](unsigned int);
/*TEST 1*/
TestClass::TestClass(int a) /*TEST 2*/
{
@ -48,7 +50,8 @@ TestClass::TestClass(int a) /*TEST 2*/
//!Commented CPPFunctionDeclaratorTest 3
//%CPP
char & operator [](unsigned int);
char& operator [](unsigned int);
//TEST 1
TestClass::TestClass(int a)
:alpha(a) //TEST 2
@ -59,7 +62,8 @@ TestClass::TestClass(int a)
//!Commented CPPFunctionDeclaratorTest 4
//%CPP
char & operator [](unsigned int);
char& operator [](unsigned int);
/*TEST 1*/
TestClass::TestClass(int a)
:alpha(a) /*TEST 3*/
@ -76,7 +80,7 @@ void foo()
try {
i++;
}
catch(...){
catch (...){
}
}
@ -90,7 +94,7 @@ void foo()
try {
i++;
}
catch(...){
catch (...){
}
}
@ -104,7 +108,7 @@ void foo()
//Test
i++;
}
catch(...){
catch (...){
}
}
@ -118,7 +122,7 @@ void foo()
{
i++;
}
catch(...){
catch (...){
}
}
@ -132,7 +136,7 @@ void foo()
//Test
i++;
}
catch(...){
catch (...){
}
}
@ -145,7 +149,7 @@ void foo()
try {
i++; //Test
}
catch(...){
catch (...){
}
}
@ -159,7 +163,7 @@ void foo()
i++;
//Test
}
catch(...){
catch (...){
}
}
@ -172,7 +176,7 @@ void foo()
try {
i++;
} //Test
catch(...){
catch (...){
}
}
@ -185,7 +189,7 @@ void foo()
try {
i++;
}
catch(...){
catch (...){
//Test
}
}
@ -199,7 +203,7 @@ void foo()
try {
i++;
}
catch(...){
catch (...){
//Test
}
}
@ -213,7 +217,7 @@ void foo()
try {
i++;
}
catch(...){
catch (...){
}
//Test
}
@ -227,9 +231,9 @@ void foo()
try {
i++;
}
catch(Overflow oo){
catch (Overflow oo){
}
catch(Matherr mm){
catch (Matherr mm){
}
}
@ -242,9 +246,9 @@ void foo()
try {
i++;
}
catch(Overflow oo){
catch (Overflow oo){
}
catch(Matherr mm){
catch (Matherr mm){
//Test
}
}

View file

@ -30,7 +30,7 @@ class Foo
{
public:
//Test
char & operator [](unsigned int);
char& operator [](unsigned int);
};
//!Commented OperatorName2
@ -38,7 +38,7 @@ public:
class Foo
{
public:
char & operator [](unsigned int); //Test
char& operator [](unsigned int); //Test
};
//!Commented ConversionName1

View file

@ -2,7 +2,7 @@
//%CPP
void foo()
{
while(true){
while (true){
//TEST 1
break; //TEST 2
}
@ -13,7 +13,7 @@ void foo()
//%CPP
void foo()
{
while(true){
while (true){
/*TEST 1*/
break; /*TEST 2*/
}
@ -62,7 +62,7 @@ void foo()
//%CPP
void foo()
{
while(true){
while (true){
//TEST 1
continue; //TEST 2
}
@ -73,7 +73,7 @@ void foo()
//%CPP
void foo()
{
while(true){
while (true){
/*TEST 1*/
continue; /*TEST 2*/
}
@ -112,7 +112,7 @@ void foo()
do{ //TEST 2
continue; //TEST 3
//TEST 4
} while(true); //TEST 5
} while (true); //TEST 5
}
@ -124,7 +124,7 @@ void foo()
//TEST 2
continue; //TEST 3
//TEST 4
} while(true); //TEST 5
} while (true); //TEST 5
}
@ -136,7 +136,7 @@ void foo()
do{ /*TEST 2*/
continue; /*TEST 3*/
/*TEST 4*/
} while(true); /*TEST 5*/
} while (true); /*TEST 5*/
}
@ -148,7 +148,7 @@ void foo()
/*TEST 2*/
continue; /*TEST 3*/
/*TEST 4*/
} while(true); /*TEST 5*/
} while (true); /*TEST 5*/
}
@ -158,7 +158,7 @@ void foo()
{
do{
continue;
} while(true); /*TEST 1*/
} while (true); /*TEST 1*/
}
@ -197,7 +197,7 @@ void foo()
void foo()
{
//TEST 1
for(int i = 0;i < 1;++i){ //TEST 2
for (int i = 0;i < 1;++i){ //TEST 2
break; //TEST 3
} //TEST 4
}
@ -207,7 +207,7 @@ void foo()
void foo()
{
//TEST 1
for(int i = 0;i < 1;++i){
for (int i = 0;i < 1;++i){
//TEST 2
break; //TEST 3
} //TEST 4
@ -219,7 +219,7 @@ void foo()
void foo()
{
/*TEST 1*/
for(int i = 0;i < 1;++i){ /*TEST 2*/
for (int i = 0;i < 1;++i){ /*TEST 2*/
break; /*TEST 3*/
} /*TEST 4*/
}
@ -229,7 +229,7 @@ void foo()
void foo()
{
/*TEST 1*/
for(int i = 0;i < 1;++i){
for (int i = 0;i < 1;++i){
/*TEST 2*/
break; /*TEST 3*/
} /*TEST 4*/
@ -240,7 +240,7 @@ void foo()
//%CPP
void foo()
{
for(int i = 0;i < 1;++i){
for (int i = 0;i < 1;++i){
break;
} /*TEST 4*/
}
@ -385,7 +385,7 @@ void foo()
//%CPP
int f()
{
if(int c = f()){
if (int c = f()){
c++;
} //TEST 1
return i;
@ -398,7 +398,7 @@ int f()
{
int i = 0;
//TEST 1
if(i < 1){
if (i < 1){
//TEST 3
++i;
//TEST 4
@ -407,7 +407,7 @@ int f()
--i;
//TEST 6
} //TEST 7
if(int c = f()){
if (int c = f()){
c++;
} //TEST 8
return i;
@ -420,7 +420,7 @@ int f()
{
int i = 0;
/*TEST 1*/
if(i < 1){
if (i < 1){
/*TEST 1*/
++i;
/*TEST 1*/
@ -429,7 +429,7 @@ int f()
--i;
/*TEST 1*/
} /*TEST 1*/
if(int c = f()){
if (int c = f()){
c++;
} /*TEST 1*/
return i;
@ -440,7 +440,7 @@ int f()
//%CPP
int g()
{
if(10 > 5) //TEST 1
if (10 > 5) //TEST 1
return 1; //TEST 2
return 0;
@ -449,7 +449,7 @@ int g()
//=
int g()
{
if(10 > 5)
if (10 > 5)
//TEST 1
return 1; //TEST 2
@ -460,7 +460,7 @@ int g()
//%CPP
int g()
{
if(10 > 5) /*TEST 1*/
if (10 > 5) /*TEST 1*/
return 1; /*TEST 2*/
return 0;
@ -469,7 +469,7 @@ int g()
//=
int g()
{
if(10 > 5)
if (10 > 5)
/*TEST 1*/
return 1; /*TEST 2*/
@ -583,7 +583,7 @@ void foo()
void foo()
{
//TEST 1
while(true){ //TEST 2
while (true){ //TEST 2
//TEST 3
break; //TEST 4
//TEST 5
@ -595,7 +595,7 @@ void foo()
void foo()
{
//TEST 1
while(true){
while (true){
//TEST 2
//TEST 3
break; //TEST 4
@ -609,7 +609,7 @@ void foo()
void foo()
{
/*TEST 1*/
while(true){ /*TEST 2*/
while (true){ /*TEST 2*/
/*TEST 3*/
break; /*TEST 4*/
/*TEST 5*/
@ -621,7 +621,7 @@ void foo()
void foo()
{
/*TEST 1*/
while(true){
while (true){
/*TEST 2*/
/*TEST 3*/
break; /*TEST 4*/
@ -634,7 +634,7 @@ void foo()
//%CPP
void foo()
{
while(true){
while (true){
break;
} /*TEST 6*/
}
@ -650,10 +650,10 @@ int foo()
++i;
return i;
}
catch(...){
catch (...){
}
}
catch(...){
catch (...){
}
}

View file

@ -1,6 +1,7 @@
//!Commented TemplateFunction1
//%CPP
template<typename T> int tempFunct(T p)
template<typename T>
int tempFunct(T p)
{
++p;
//Kommentar
@ -12,7 +13,8 @@ template<typename T> int tempFunct(T p)
//!Commented TemplateFunction2
//%CPP
//Kommentar
template<typename T> int tempFunct(T p)
template<typename T>
int tempFunct(T p)
{
++p;
p + 4;
@ -22,7 +24,8 @@ template<typename T> int tempFunct(T p)
//!Commented TemplateFunction3
//%CPP
template<typename T> int tempFunct(T p)
template<typename T>
int tempFunct(T p)
{
++p;
p + 4;

View file

@ -7,9 +7,10 @@ inline int foo()
const int a = 1;
volatile int b = 3;
typedef int *intp;
typedef int* intp;
extern int b;
static int c;
int foo()
{
int i = 1;
@ -43,7 +44,7 @@ public:
//!ElaboratedTypeSpecifier
//%CPP
class A *A;
class A* A;
enum Status{ good, bad};
enum Status stat;
union D
@ -52,7 +53,7 @@ union D
int y;
};
union D d;
struct S *S;
struct S* S;
//!EnumeratioSpecifier
//%CPP

View file

@ -32,12 +32,14 @@ extern "C" typedef void FUNC();
//!NamespaceAlias
//%CPP
namespace kurz = ziemlichlangernamespace;
namespace kurz = somenamespace;
//!NamespaceDefinition
//%CPP
namespace ziemlichlangernamespace
namespace somenamespace
{
}
//!TemplateDeclaration
@ -58,8 +60,9 @@ template<typename T> class MyQueue;
template<> class MyQueue<double>
{
std::vector<double> data;
public:
void Add(const double& );
void Add(const double&);
void Remove();
void Print();
};
@ -92,9 +95,11 @@ using namespace B;
class A
{
public:
int hallo();
int hello();
protected:
int b, c;
private:
int p;
};
@ -104,7 +109,7 @@ private:
//Comment
int i = 2;
//!typename qualfier
//!Typename qualifier
//%CPP
typename T::A *a6;
typename T::A* a6;

View file

@ -1,22 +1,23 @@
//!DeclaratorTest
//%CPP
int sd;
int *ip;
int* ip;
int hs = 1;
char & c;
char& c;
void foo()
{
struct B
{
int f();
};
int (B::* pb)() = &B::f;
int (B::*pb)() = &B::f;
}
//!ArrayDeclaratorTest
//%CPP
int *pi[3];
int* pi[3];
int (*p3i)[3];
//!FieldDeclaratorTest
@ -30,38 +31,39 @@ struct Bit
//%C
int foo();
int bar(int a, int b);
int fun(const char *a, ...);
int fun3(int i, const char *a, ...);
int fun(const char* a, ...);
int fun3(int i, const char* a, ...);
//!CPPStandardFunctionDeclaratorTest
//%CPP
int foo();
int bar(int a, int b);
int fun(const char *a, ...);
int fun2(const char *a ...);
int fun3(int i, const char *a, ...);
int fun(const char* a, ...);
int fun2(const char* a ...);
int fun3(int i, const char* a, ...);
//= ,... is synonymous with ...
int foo();
int bar(int a, int b);
int fun(const char *a, ...);
int fun2(const char *a, ...);
int fun3(int i, const char *a, ...);
int fun(const char* a, ...);
int fun2(const char* a, ...);
int fun3(int i, const char* a, ...);
//!CPPFunctionDeclaratorTest
//%CPP
char & operator [](unsigned int);
char& operator [](unsigned int);
class TestClass
{
int alpha;
TestClass(int a);
virtual void pure() =0;
virtual void pure() = 0;
};
TestClass::TestClass(int a)
:alpha(a)
{
}
void undefPar(const char *c) throw (int);
void undefPar(const char* c) throw (int);
int getV() const;
int vol() volatile;
@ -72,15 +74,17 @@ class C
{
int i;
double d;
public:
C(int, double);
};
C::C(int ii, double id)
try
:i(f(ii)), d(id)
{
}
catch(...){
catch (...){
}
@ -94,7 +98,7 @@ int b, a;
//!ICPPASTDeclarator with nested declarator being a variable
//%C
int *(*var[3]);
int* (*var[3]);
//!ICPPASTDeclarator with nested declarator and redundant parentheses
//%C
@ -108,8 +112,8 @@ class Foo
};
//!ICPPASTReferenceOperator rvalue reference
//%CPP
int && foo(int && a)
int&& foo(int&& a)
{
char && b;
char&& b;
}

View file

@ -4,10 +4,10 @@ int i = (int)'A';
//!CPPCastExpression
//%CPP
TestClass *i = dynamic_cast<TestClass*>(tc);
TestClass *i = static_cast<TestClass*>(tc);
TestClass *i = reinterpret_cast<TestClass*>(tc);
TestClass *i = const_cast<TestClass*>(tc);
TestClass* i = dynamic_cast<TestClass*>(tc);
TestClass* i = static_cast<TestClass*>(tc);
TestClass* i = reinterpret_cast<TestClass*>(tc);
TestClass* i = const_cast<TestClass*>(tc);
//!ArraySubscrition
//%C GNU
@ -33,6 +33,7 @@ int i = 1 | x;
bool b = 1 && x;
bool b = 1 || x;
int i = x;
void foo()
{
i *= x;
@ -131,7 +132,7 @@ string s = "abc";
//!CPPLiteralExpression
//%CPP
TestClass *tc = this;
TestClass* tc = this;
bool b = true;
bool b = false;
@ -141,7 +142,7 @@ int i = ++a;
int i = --a;
int i = +a;
int i = -a;
int *b = &a;
int* b = &a;
int i = *b;
int i = ~b;
bool b = !false;
@ -167,7 +168,7 @@ void rethrow()
int i = 1;
throw i;
}
catch(int j){
catch (int j){
throw ;
}
}
@ -191,7 +192,7 @@ void f()
//!CPPNewExpression
//%CPP
TestClass *tc = new TestClass();
TestClass* tc = new TestClass();
//!CPPSimpleTypeConstructorExpression
//%CPP

View file

@ -11,7 +11,7 @@ int TestClass::Hallo;
class Foo
{
public:
char & operator [](unsigned int);
char& operator [](unsigned int);
};
//!ConversionName

View file

@ -2,7 +2,7 @@
//%CPP
void foo()
{
while(true){
while (true){
break;
}
}
@ -41,7 +41,7 @@ void foo()
//%CPP
void foo()
{
while(true){
while (true){
continue;
}
}
@ -62,7 +62,7 @@ void foo()
{
do{
continue;
} while(true);
} while (true);
}
@ -79,13 +79,13 @@ void foo()
//%CPP
void foo()
{
for(int i = 0;i < 1;++i){
for (int i = 0;i < 1;++i){
break;
}
for(;;){
for (;;){
break;
}
for(;int c = f();){
for (;int c = f();){
c++;
}
}
@ -96,7 +96,7 @@ void foo()
void foo()
{
int i;
for(i = 0;i < 1;++i){
for (i = 0;i < 1;++i){
}
}
@ -115,12 +115,12 @@ int f()
int f()
{
int i = 0;
if(i < 1){
if (i < 1){
++i;
}else{
--i;
}
if(int c = f()){
if (int c = f()){
c++;
}
return i;
@ -131,7 +131,7 @@ int f()
//%CPP
int g()
{
if(10 > 5)
if (10 > 5)
return 1;
return 0;
@ -141,7 +141,7 @@ int g()
//%C
int g()
{
if(10 > 5)
if (10 > 5)
return 1;
return 0;
@ -240,14 +240,14 @@ int foo(int a)
//%CPP
void foo()
{
while(true){
while (true){
break;
}
}
void fa()
{
while(int i = f()){
while (int i = f()){
++i;
break;
}
@ -255,7 +255,7 @@ void fa()
void fb()
{
while(true);
while (true);
}
@ -263,7 +263,7 @@ void fb()
//%C
void foo()
{
while(true){
while (true){
break;
}
}
@ -279,10 +279,10 @@ int foo()
++i;
return i;
}
catch(...){
catch (...){
}
}
catch(...){
catch (...){
}
}
@ -293,7 +293,7 @@ int foo()
int foo()
{
int i = 1;
if( i == ZWO)
if (i == ZWO)
{
}
}
@ -301,7 +301,7 @@ int foo()
int foo()
{
int i = 1;
if( i == ZWO)
if (i == ZWO)
{
}
}
@ -309,5 +309,5 @@ int foo()
//!ArrayDeclarationStatementTest
//%CPP
string *newElements = new string[m_capacity];
string* newElements = new string[m_capacity];

View file

@ -1,10 +1,11 @@
//![temp.names] examples abschnitt 4/1
//%CPP
T *p1 = p->template alloc<100>();
T* p1 = p->template alloc<100>();
//![temp.names] examples abschnitt 4/2, didn't work cause of Bug# 164482
//%CPP
template<class T> void f(T *p)
template<class T>
void f(T* p)
{
T::template adjust<100>();
}

View file

@ -148,6 +148,7 @@ class Klasse0
public:
Klasse0(); //Comment
std::string toString();
private:
int i;
};
@ -170,6 +171,7 @@ class Klasse0
public:
Klasse1();
std::string toString();
private:
int i;
};
@ -182,6 +184,7 @@ class Klasse0
public:
Klasse1();
std::string toString();
private:
int i;
}; = //Comment1
@ -2779,26 +2782,26 @@ int foo = bar; = //Zweiteilig
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@Klasse1.h
//TEST 1
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} //TEST 3
//=
=>leading
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} = //TEST 1
=>trailing
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} = //TEST 3
=>freestanding
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} = //TEST 2
@ -2807,7 +2810,7 @@ namespace ziemlichlangernamespace
//!CommentRecognition215 - von ASTWriter NamesapceDefinition
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@Klasse1.h
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST
}
@ -2822,7 +2825,7 @@ void doIt(){
=>trailing
=>freestanding
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST
} = //TEST
@ -2830,7 +2833,7 @@ namespace ziemlichlangernamespace
//!CommentRecognition216 - von ASTWriter NamesapceDefinition
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@Klasse1.h
namespace ziemlichlangernamespace
namespace somenamespace
{
int i = 0;
//TEST
@ -2846,7 +2849,7 @@ void doIt(){
=>trailing
=>freestanding
namespace ziemlichlangernamespace
namespace somenamespace
{
int i = 0;
//TEST

View file

@ -6,18 +6,17 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* A composite type specifier represents a ocmposite structure (contains
* declarations).
* A composite type specifier represents a composite structure (contains declarations).
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier , IASTNameOwner, IASTDeclarationListOwner {
public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner, IASTDeclarationListOwner {
/**
* <code>TYPE_NAME</code> represents the relationship between an
@ -101,5 +100,6 @@ public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier , IASTName
/**
* @since 5.1
*/
@Override
public IASTCompositeTypeSpecifier copy();
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -52,10 +52,12 @@ public interface IASTCompoundStatement extends IASTStatement {
/**
* @since 5.1
*/
@Override
public IASTCompoundStatement copy();
/**
* @since 5.3
*/
@Override
public IASTCompoundStatement copy(CopyStyle style);
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -18,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTDeclSpecifier extends IASTNode {
/**
* No storage class specified.
*/
@ -52,11 +51,13 @@ public interface IASTDeclSpecifier extends IASTNode {
/**
* @since 5.1
*/
@Override
public IASTDeclSpecifier copy();
/**
* @since 5.3
*/
@Override
public IASTDeclSpecifier copy(CopyStyle style);
/**
@ -90,6 +91,4 @@ public interface IASTDeclSpecifier extends IASTNode {
*/
@Deprecated
public static final int sc_last = sc_register;
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -103,10 +103,12 @@ public interface IASTFunctionDefinition extends IASTDeclaration {
/**
* @since 5.1
*/
@Override
public IASTFunctionDefinition copy();
/**
* @since 5.3
*/
@Override
public IASTFunctionDefinition copy(CopyStyle style);
}

View file

@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2004, 2011 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
* Copyright (c) 2004, 2011 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:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -18,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noextend This interface is not intended to be extended by clients.
*/
public interface IASTLiteralExpression extends IASTExpression {
/**
* An integer literal e.g. 5
*/
@ -79,6 +78,7 @@ public interface IASTLiteralExpression extends IASTExpression {
* Returns the value of the literal as string.
* @since 5.1
*/
@Override
public String toString();
/**
@ -95,11 +95,13 @@ public interface IASTLiteralExpression extends IASTExpression {
/**
* @since 5.1
*/
@Override
public IASTLiteralExpression copy();
/**
* @since 5.3
*/
@Override
public IASTLiteralExpression copy(CopyStyle style);
/**

View file

@ -64,6 +64,7 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomi
*
* @param declaration <code>IASTDeclaration</code>
*/
@Override
public void addDeclaration(IASTDeclaration declaration);
/**
@ -324,6 +325,7 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomi
* @noreference This method is not intended to be referenced by clients.
* @since 5.1
*/
@Override
public IASTTranslationUnit copy();
/**
@ -335,6 +337,7 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomi
* @noreference This method is not intended to be referenced by clients.
* @since 5.3
*/
@Override
public IASTTranslationUnit copy(CopyStyle style);
/**

View file

@ -84,11 +84,13 @@ public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifie
/**
* @since 5.1
*/
@Override
public ICPPASTBaseSpecifier copy();
/**
* @since 5.3
*/
@Override
public ICPPASTBaseSpecifier copy(CopyStyle style);
/**
@ -125,15 +127,18 @@ public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifie
/**
* @since 5.1
*/
@Override
public ICPPClassScope getScope();
/**
* @since 5.1
*/
@Override
public ICPPASTCompositeTypeSpecifier copy();
/**
* @since 5.3
*/
@Override
public ICPPASTCompositeTypeSpecifier copy(CopyStyle style);
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTParameterDeclaration extends ICPPASTTemplateParameter, IASTParameterDeclaration {
/**
* @since 5.2
*/
@ -27,15 +26,18 @@ public interface ICPPASTParameterDeclaration extends ICPPASTTemplateParameter, I
/**
* @since 5.1
*/
@Override
public ICPPASTParameterDeclaration copy();
/**
* @since 5.3
*/
@Override
public ICPPASTParameterDeclaration copy(CopyStyle style);
/**
* @since 5.2
*/
@Override
public ICPPASTDeclarator getDeclarator();
}

View file

@ -33,19 +33,20 @@ public interface ICPPClassType extends ICompositeType, ICPPBinding {
public ICPPBase[] getBases();
/**
* Get fields is restated here just to point out that this method returns a
* list of ICPPField objects representing all fields, declared or inherited.
* Get fields is restated here just to point out that this method returns a list of ICPPField
* objects representing all fields, declared or inherited.
*/
@Override
public IField[] getFields();
/**
* findField is restated here to point out that this method looks through
* the inheritance tree of this class while looking for a field with the
* given name If no field is found, null is returned, if the name is found
* to be ambiguous a IProblemBinding is returned.
* findField is restated here to point out that this method looks through the inheritance tree
* of this class while looking for a field with the given name If no field is found, null is
* returned, if the name is found to be ambiguous a IProblemBinding is returned.
*
* @param name
*/
@Override
public IField findField(String name);
/**

View file

@ -55,10 +55,12 @@ public class GPPLanguage extends AbstractCLikeLanguage {
return super.getAdapter(adapter);
}
@Override
public String getId() {
return ID;
}
@Override
public int getLinkageID() {
return ILinkage.CPP_LINKAGE_ID;
}
@ -68,6 +70,9 @@ public class GPPLanguage extends AbstractCLikeLanguage {
return CPP_GNU_SCANNER_EXTENSION;
}
/**
* @since 5.4
*/
@Override
protected IScannerExtensionConfiguration getScannerExtensionConfiguration(IScannerInfo info) {
return GPPScannerExtensionConfiguration.getInstance(info);

View file

@ -202,8 +202,8 @@ public final class ASTRewrite {
* changes.
* </p>
*
* @return Change object describing the changes to the
* document corresponding to the changes recorded by this rewriter
* @return Change object describing the changes to the document corresponding to the changes
* recorded by this rewriter
* @since 5.0
*/
public Change rewriteAST() {

Some files were not shown because too many files have changed in this diff Show more