diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc2/test1DepCalc2.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc2/test1DepCalc2.zip old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc3/test1DepCalc3.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc3/test1DepCalc3.zip old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalcPreBuild/test1DepCalcPreBuild.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalcPreBuild/test1DepCalcPreBuild.zip old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd index 7a72c38ed00..626bbb55757 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd +++ b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd @@ -1774,8 +1774,27 @@ If this attribute is not specified, MBS will assume that there are no reserved m - specifies the "parallel build" builder option. -If the builder supports specifying custom number of parallel jobs, the option definition may contain "*" the Build System sill substitute the "*" with the number of parallel threads to be used. + Specifies the command for "parallel build". +If the builder supports specifying custom number of parallel jobs the option definition may contain "*". The Build System will substitute the "*" with the number of parallel threads to be used. In case of "unlimited" jobs jobs number will be omitted. +For example, builder representing GNU make would define parallelBuildCmd as "-j*". + + + + + + + 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 "parallelizationNumber" attribute. If "parallelizationNumber" is not defined "optimal" value will be used. + + + + + + + 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 "optimal" or "unlimited" are recognized: +- number 1 will cause parallel build to be turned off, +- "optimal" will set maximum number of jobs to number of processors on the system, +- "unlimited" will make builder to run as many threads/jobs as possible. diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java index 3a60bedc114..f168b77ee8d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IBuilder.java @@ -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$ /** diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java index a35d89b66cd..77a092baff5 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IMultiConfiguration.java @@ -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(); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java index 949bd36d05c..0efc2b6724f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/InternalBuildRunner.java @@ -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 { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index f016158c2a4..c7f29939418 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -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 fInfoMap = new HashMap(); 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) { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java index 28a31ae2d5a..5525b20774b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildProcessManager.java @@ -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 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(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(); } } \ No newline at end of file diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java index 782c3d59075..b6e41fd3345 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/ParallelBuilder.java @@ -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 active = new Vector(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 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; } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java index bb9f105b626..86129eac8bb 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java @@ -40,10 +40,10 @@ import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer; import org.eclipse.cdt.internal.core.SafeStringInterner; +import org.eclipse.cdt.managedbuilder.core.AbstractBuildRunner; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner; import org.eclipse.cdt.managedbuilder.core.IBuildObject; -import org.eclipse.cdt.managedbuilder.core.AbstractBuildRunner; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; @@ -66,6 +66,7 @@ import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator2; import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; @@ -79,7 +80,7 @@ import org.eclipse.core.variables.VariablesPlugin; import org.osgi.framework.Version; public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider, IRealBuildObjectAssociation { - + public static final int UNLIMITED_JOBS = Integer.MAX_VALUE; private static final String EMPTY_STRING = ""; //$NON-NLS-1$ // Superclass @@ -119,10 +120,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider private HashMap customBuildProperties; // private Boolean isWorkspaceBuildPath; private String ignoreErrCmd; - private String parallelBuildCmd; private Boolean stopOnErr; - private Integer parallelNum; - private Boolean parallelBuildOn; + // parallelization + private String parallelBuildCmd; + private Boolean isParallelBuildEnabled; + private Integer parallelNumberAttribute; // negative number denotes "optimal" value, see getOptimalParallelJobNum() + private boolean isTest; // Miscellaneous @@ -327,9 +330,10 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider stopOnErr = builder.stopOnErr; ignoreErrCmd = builder.ignoreErrCmd; + + isParallelBuildEnabled = builder.isParallelBuildEnabled; + parallelNumberAttribute = builder.parallelNumberAttribute; parallelBuildCmd = builder.parallelBuildCmd; - parallelNum = builder.parallelNum; - parallelBuildOn = builder.parallelBuildOn; if(builder.outputEntries != null){ outputEntries = builder.outputEntries.clone(); @@ -372,17 +376,15 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } catch (CoreException e) { } } - if(getParallelizationNum() != builder.getParallelizationNum() - && supportsParallelBuild()){ + if (isParallelBuildOn() != builder.isParallelBuildOn() && supportsParallelBuild()) { try { - setParallelizationNum(builder.getParallelizationNum()); + setParallelBuildOn(builder.isParallelBuildOn()); } catch (CoreException e) { } } - if(isParallelBuildOn() != builder.isParallelBuildOn() - && supportsParallelBuild()){ + if (getParallelizationNumAttribute() != builder.getParallelizationNumAttribute() && supportsParallelBuild()) { try { - setParallelBuildOn(builder.isParallelBuildOn()); + setParallelizationNum(builder.getParallelizationNumAttribute()); } catch (CoreException e) { } } @@ -552,23 +554,23 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider ignoreErrCmd = SafeStringInterner.safeIntern(element.getAttribute(ATTRIBUTE_IGNORE_ERR_CMD)); - tmp = element.getAttribute(ATTRIBUTE_STOP_ON_ERR); - if(tmp != null) - stopOnErr = Boolean.valueOf(tmp); - - parallelBuildCmd = SafeStringInterner.safeIntern(element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD)); - - tmp = element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER); - if(tmp != null){ - try { - parallelNum = Integer.decode(tmp); - } catch (NumberFormatException e){ - } - } - tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_ON); - if(tmp != null) - parallelBuildOn = Boolean.valueOf(tmp); - + tmp = element.getAttribute(ATTRIBUTE_STOP_ON_ERR); + if (tmp != null) + stopOnErr = Boolean.valueOf(tmp); + + tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD); + if (tmp != null) + parallelBuildCmd = SafeStringInterner.safeIntern(tmp); + + tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_ON); + if (tmp != null) { + isParallelBuildEnabled = Boolean.valueOf(tmp); + if (isParallelBuildEnabled) { + tmp = element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER); + setParallelizationNumAttribute(decodeParallelizationNumber(element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER))); + } + } + // Get the semicolon separated list of IDs of the error parsers errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(IToolChain.ERROR_PARSERS)); @@ -618,6 +620,43 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider fBuildRunnerElement = ((DefaultManagedConfigElement)element).getConfigurationElement(); } + private String encodeParallelizationNumber(Integer jobsNumber) { + if (jobsNumber <= 0) + return VALUE_OPTIMAL; + + if (jobsNumber.equals(UNLIMITED_JOBS)) + return VALUE_UNLIMITED; + + return jobsNumber.toString(); + } + + private int decodeParallelizationNumber(String value) { + int parallelNumber = -1; + if (VALUE_OPTIMAL.equals(value)) { + parallelNumber = -getOptimalParallelJobNum(); + } else if (VALUE_UNLIMITED.equals(value)) { + parallelNumber = UNLIMITED_JOBS; + } else { + try { + parallelNumber = Integer.decode(value); + } catch (NumberFormatException e) { + ManagedBuilderCorePlugin.log(e); + parallelNumber = getOptimalParallelJobNum(); + } + if (parallelNumber <= 0) { + // compatibility with legacy representation - it was that inconsistent + if (isInternalBuilder()) { + // "optimal" for Internal Builder + parallelNumber = -getOptimalParallelJobNum(); + } else { + // unlimited for External Builder + parallelNumber = UNLIMITED_JOBS; + } + } + } + return parallelNumber; + } + /** * Initialize the builder information from the XML element * specified in the argument @@ -748,24 +787,22 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider if(element.getAttribute(ATTRIBUTE_IGNORE_ERR_CMD) != null) ignoreErrCmd = SafeStringInterner.safeIntern(element.getAttribute(ATTRIBUTE_IGNORE_ERR_CMD)); - tmp = element.getAttribute(ATTRIBUTE_STOP_ON_ERR); - if(tmp != null) - stopOnErr = Boolean.valueOf(tmp); - - if(element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD) != null) - parallelBuildCmd = SafeStringInterner.safeIntern(element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD)); - - tmp = element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER); - if(tmp != null){ - try { - parallelNum = Integer.decode(tmp); - } catch (NumberFormatException e){ - } - } - - tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_ON); - if(tmp != null) - parallelBuildOn = Boolean.valueOf(tmp); + tmp = element.getAttribute(ATTRIBUTE_STOP_ON_ERR); + if (tmp != null) + stopOnErr = Boolean.valueOf(tmp); + + tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD); + if (tmp != null) + parallelBuildCmd = SafeStringInterner.safeIntern(tmp); + + tmp = element.getAttribute(ATTRIBUTE_PARALLEL_BUILD_ON); + if (tmp != null) { + isParallelBuildEnabled = Boolean.valueOf(tmp); + if (isParallelBuildEnabled) { + tmp = element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER); + setParallelizationNumAttribute(decodeParallelizationNumber(element.getAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER))); + } + } ICStorageElement[] children = element.getChildren(); for(int i = 0; i < children.length; i++){ @@ -869,16 +906,19 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider if(customBuildProperties != null) element.setAttribute(ATTRIBUTE_CUSTOM_PROPS, MapStorageElement.encodeMap(customBuildProperties)); - if(ignoreErrCmd != null) - element.setAttribute(ATTRIBUTE_IGNORE_ERR_CMD, ignoreErrCmd); - if(stopOnErr != null) - element.setAttribute(ATTRIBUTE_STOP_ON_ERR, stopOnErr.toString()); - if(parallelBuildCmd != null) - element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD, parallelBuildCmd); - if(parallelNum != null) - element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, parallelNum.toString()); - if(parallelBuildOn != null) - element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_ON, parallelBuildOn.toString()); + if (ignoreErrCmd != null) + element.setAttribute(ATTRIBUTE_IGNORE_ERR_CMD, ignoreErrCmd); + if (stopOnErr != null) + element.setAttribute(ATTRIBUTE_STOP_ON_ERR, stopOnErr.toString()); + + if (parallelBuildCmd != null) + element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD, parallelBuildCmd); + + if (isParallelBuildEnabled != null) + element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_ON, isParallelBuildEnabled.toString()); + if (isParallelBuildOn() && parallelNumberAttribute != null) + element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, encodeParallelizationNumber(parallelNumberAttribute)); + // Note: build file generator cannot be specified in a project file because // an IConfigurationElement is needed to load it! if (buildFileGeneratorElement != null) { @@ -965,13 +1005,18 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider if(customBuildProperties != null) element.setAttribute(ATTRIBUTE_CUSTOM_PROPS, MapStorageElement.encodeMap(customBuildProperties)); - if(getIgnoreErrCmdAttribute() != null) - element.setAttribute(ATTRIBUTE_IGNORE_ERR_CMD, getIgnoreErrCmdAttribute()); - element.setAttribute(ATTRIBUTE_STOP_ON_ERR, Boolean.valueOf(isStopOnError()).toString()); - if(getParrallelBuildCmd() != null) - element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD, getParrallelBuildCmd()); - element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, new Integer(getParallelizationNumAttribute()).toString()); - element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_ON, Boolean.valueOf(isParallelBuildOn()).toString()); + if (getIgnoreErrCmdAttribute() != null) + element.setAttribute(ATTRIBUTE_IGNORE_ERR_CMD, getIgnoreErrCmdAttribute()); + element.setAttribute(ATTRIBUTE_STOP_ON_ERR, Boolean.valueOf(isStopOnError()).toString()); + + if (parallelBuildCmd != null) + element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_CMD, parallelBuildCmd); + + if (isParallelBuildEnabled != null) + element.setAttribute(ATTRIBUTE_PARALLEL_BUILD_ON, isParallelBuildEnabled.toString()); + if (isParallelBuildOn() && parallelNumberAttribute != null) + element.setAttribute(ATTRIBUTE_PARALLELIZATION_NUMBER, encodeParallelizationNumber(parallelNumberAttribute)); + // Note: build file generator cannot be specified in a project file because // an IConfigurationElement is needed to load it! if (buildFileGeneratorElement != null) { @@ -995,6 +1040,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider * P A R E N T A N D C H I L D H A N D L I N G */ + @Override public IToolChain getParent() { return parent; } @@ -1003,6 +1049,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider * M O D E L A T T R I B U T E A C C E S S O R S */ + @Override public IBuilder getSuperClass() { return (IBuilder)superClass; } @@ -1012,6 +1059,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return (name == null && superClass != null) ? superClass.getName() : name; } + @Override public boolean isAbstract() { if (isAbstract != null) { return isAbstract.booleanValue(); @@ -1020,6 +1068,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } } + @Override public String getUnusedChildren() { if (unusedChildren != null) { return unusedChildren; @@ -1027,6 +1076,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return EMPTY_STRING; // Note: no inheritance from superClass } + @Override public String getCommand() { if (command == null) { // If I have a superClass, ask it @@ -1039,19 +1089,21 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return command; } + @Override public String getArguments() { String args = getArgumentsAttribute(); String stopOnErrCmd = getStopOnErrCmd(isStopOnError()); - String parallelBuildCmd = isParallelBuildOn() ? getParallelizationCmd(getParallelizationNum()) : EMPTY_STRING; + int parallelNum = getParallelizationNum(); + String parallelCmd = isParallelBuildOn() ? getParallelizationCmd(parallelNum) : EMPTY_STRING; String reversedStopOnErrCmd = getStopOnErrCmd(!isStopOnError()); - String reversedParallelBuildCmd = !isParallelBuildOn() ? getParallelizationCmd(getParallelizationNum()) : EMPTY_STRING; + String reversedParallelBuildCmd = !isParallelBuildOn() ? getParallelizationCmd(parallelNum) : EMPTY_STRING; args = removeCmd(args, reversedStopOnErrCmd); args = removeCmd(args, reversedParallelBuildCmd); args = addCmd(args, stopOnErrCmd); - args = addCmd(args, parallelBuildCmd); + args = addCmd(args, parallelCmd); return args != null ? args.trim() : null; } @@ -1114,18 +1166,27 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return index; } - public String getParallelizationCmd(int num){ + public String getParallelizationCmd(int num) { String pattern = getParrallelBuildCmd(); - if(pattern.length() == 0){ - return EMPTY_STRING; - }if(num == 0){ + if (pattern.length() == 0 || num == 0) { return EMPTY_STRING; } - - return processParallelPattern(pattern, num < 0, num); + // "unlimited" number of jobs results in not adding the number to parallelization cmd + // that behavior corresponds that of "make" flag "-j". + return processParallelPattern(pattern, num == UNLIMITED_JOBS, num); } + /** + * This method turns the supplied pattern to parallelization command + * + * It supports 2 kinds of pattern where "*" is replaced with number of jobs: + *
  • Pattern 1 (supports "-j*"): "text*text" -> "text#text"
  • + *
  • Pattern 2 (supports "-[j*]"): "text[text*text]text" -> "texttext#texttext
  • + *
    Where # is num or empty if {@code empty} is {@code true}) + */ private String processParallelPattern(String pattern, boolean empty, int num){ + Assert.isTrue(num > 0); + int start = pattern.indexOf(PARALLEL_PATTERN_NUM_START); int end = -1; boolean hasStartChar = false; @@ -1190,6 +1251,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return args; } + @Override public String getErrorParserIds() { String ids = errorParserIds; if (ids == null) { @@ -1201,6 +1263,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return ids; } + @Override public String[] getErrorParserList() { String parserIDs = getErrorParserIds(); String[] errorParsers = null; @@ -1223,6 +1286,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return errorParsers; } + @Override public void setCommand(String cmd) { if(getCommand().equals(cmd)) return; if (cmd == null && command == null) return; @@ -1232,16 +1296,17 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } } + @Override public void setArguments(String newArgs) { if(getArguments().equals(newArgs)) return; if(newArgs != null){ String stopOnErrCmd = getStopOnErrCmd(isStopOnError()); - String parallelBuildCmd = isParallelBuildOn() ? getParallelizationCmd(getParallelizationNum()) : EMPTY_STRING; + String parallelCmd = isParallelBuildOn() ? getParallelizationCmd(getParallelizationNum()) : EMPTY_STRING; newArgs = removeCmd(newArgs, stopOnErrCmd); - newArgs = removeCmd(newArgs, parallelBuildCmd); + newArgs = removeCmd(newArgs, parallelCmd); } setArgumentsAttribute(newArgs); } @@ -1254,6 +1319,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } } + @Override public void setErrorParserIds(String ids) { String currentIds = getErrorParserIds(); if (ids == null && currentIds == null) return; @@ -1263,11 +1329,13 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } } + @Override public void setIsAbstract(boolean b) { isAbstract = new Boolean(b); setDirty(true); } + @Override public IConfigurationElement getBuildFileGeneratorElement() { if (buildFileGeneratorElement == null) { if (superClass != null) { @@ -1277,6 +1345,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return buildFileGeneratorElement; } + @Override public IManagedBuilderMakefileGenerator getBuildFileGenerator(){ IConfigurationElement element = getBuildFileGeneratorElement(); if (element != null) { @@ -1299,6 +1368,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } + @Override public void setBuildFileGeneratorElement(IConfigurationElement element) { buildFileGeneratorElement = element; setDirty(true); @@ -1344,6 +1414,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } } + @Override public String getConvertToId() { if (convertToId == null) { // If I have a superClass, ask it @@ -1356,6 +1427,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return convertToId; } + @Override public void setConvertToId(String convertToId) { if (convertToId == null && this.convertToId == null) return; if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) { @@ -1365,6 +1437,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return; } + @Override public String getVersionsSupported() { if (versionsSupported == null) { // If I have a superClass, ask it @@ -1377,6 +1450,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return versionsSupported; } + @Override public void setVersionsSupported(String versionsSupported) { if (versionsSupported == null && this.versionsSupported == null) return; if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) { @@ -1386,18 +1460,21 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return; } + @Override public IFileContextBuildMacroValues getFileContextBuildMacroValues(){ if(fileContextBuildMacroValues == null && superClass != null) return getSuperClass().getFileContextBuildMacroValues(); return fileContextBuildMacroValues; } + @Override public String getBuilderVariablePattern(){ if(builderVariablePattern == null && superClass != null) return getSuperClass().getBuilderVariablePattern(); return builderVariablePattern; } + @Override public boolean isVariableCaseSensitive(){ if(isVariableCaseSensitive == null){ if(superClass != null) @@ -1407,12 +1484,14 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return isVariableCaseSensitive.booleanValue(); } + @Override public String[] getReservedMacroNames(){ if(reservedMacroNames == null && superClass != null) return getSuperClass().getReservedMacroNames(); return reservedMacroNames; } + @Override public IReservedMacroNameSupplier getReservedMacroNameSupplier(){ if(reservedMacroNameSupplier == null && reservedMacroNameSupplierElement != null){ try{ @@ -1617,6 +1696,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return currentMbsVersionConversionElement; } + @Override public CBuildData getBuildData() { return fBuildData; } @@ -1627,6 +1707,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider // return null; // } + @Override public String[] getErrorParsers() { if(isCustomBuilder() && customizedErrorParserIds != null) return customizedErrorParserIds.clone(); @@ -1646,6 +1727,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider customizedErrorParserIds = ids != null ? (String[])ids.clone() : ids; } + @Override public void setErrorParsers(String[] parsers) throws CoreException { if(isCustomBuilder()){ customizedErrorParserIds = (parsers != null && parsers.length != 0) ? (String[])parsers.clone() : parsers; @@ -1660,6 +1742,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return this;//!isExtensionBuilder ? (Object)this : (Object)getParent().getParent(); } + @Override public String getBuildArguments() { String args = getArguments(); IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider(); @@ -1672,6 +1755,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return args; } + @Override public IPath getBuildCommand() { String command = getCommand(); IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider(); @@ -1697,6 +1781,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return buildPath; } + @Override public void setBuildPath(String path){ setBuildPathAttribute(path); } @@ -1706,6 +1791,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider setDirty(true); } + @Override public String getBuildPath(){ if(isManagedBuildOn()) return getDefaultBuildPath(); @@ -1791,6 +1877,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return isWorkspaceBuildPath.booleanValue(); } */ + @Override public IPath getBuildLocation() { String path = getBuildPath(); @@ -1804,10 +1891,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return new Path(path); } + @Override public boolean isDefaultBuildCmd() { return isExtensionBuilder || (command == null && args == null /*&& stopOnErr == null && parallelBuildOn == null && parallelNum == null */ && superClass != null); } + @Override public boolean isStopOnError() { if(stopOnErr == null){ if(superClass != null){ @@ -1818,20 +1907,24 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return stopOnErr.booleanValue(); } + @Override public void setBuildArguments(String args) throws CoreException { setArguments(args); } + @Override public void setBuildCommand(IPath command) throws CoreException { String cmd = command != null ? command.toString() : null; setCommand(cmd); } + @Override public void setBuildLocation(IPath location) throws CoreException { String path = location != null ? location.toString() : null; setBuildPath(path); } + @Override public void setStopOnError(boolean on) throws CoreException { if(isStopOnError() == on) return; @@ -1847,6 +1940,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider setDirty(true); } + @Override public void setUseDefaultBuildCmd(boolean on) throws CoreException { if(!isExtensionBuilder && superClass != null){ if(on){ @@ -1870,6 +1964,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return autoBuildTarget; } + @Override public String getAutoBuildTarget() { String attr = getAutoBuildTargetAttribute(); @@ -1898,6 +1993,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return cleanBuildTarget; } + @Override public String getCleanBuildTarget() { String attr = getCleanBuildTargetAttribute(); @@ -1917,6 +2013,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } + @Override public String getFullBuildTarget() { return getIncrementalBuildTarget(); } @@ -1930,6 +2027,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return incrementalBuildTarget; } + @Override public String getIncrementalBuildTarget() { String attr = getIncrementalBuildTargetAttribute(); @@ -1948,6 +2046,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return attr; } + @Override public boolean isAutoBuildEnable() { if(autoBuildEnabled == null){ if(superClass != null) @@ -1957,6 +2056,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return autoBuildEnabled.booleanValue(); } + @Override public boolean isCleanBuildEnabled() { if(cleanBuildEnabled == null){ if(superClass != null) @@ -1966,10 +2066,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return cleanBuildEnabled.booleanValue(); } + @Override public boolean isFullBuildEnabled() { return isIncrementalBuildEnabled(); } + @Override public boolean isIncrementalBuildEnabled() { if(incrementalBuildEnabled == null){ if(superClass != null) @@ -1979,38 +2081,47 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return incrementalBuildEnabled.booleanValue(); } + @Override public void setAutoBuildEnable(boolean enabled) throws CoreException { autoBuildEnabled = Boolean.valueOf(enabled); } + @Override public void setAutoBuildTarget(String target) throws CoreException { autoBuildTarget = target; } + @Override public void setCleanBuildEnable(boolean enabled) throws CoreException { cleanBuildEnabled = Boolean.valueOf(enabled); } + @Override public void setCleanBuildTarget(String target) throws CoreException { cleanBuildTarget = target; } + @Override public void setFullBuildEnable(boolean enabled) throws CoreException { setIncrementalBuildEnable(enabled); } + @Override public void setFullBuildTarget(String target) throws CoreException { setIncrementalBuildTarget(target); } + @Override public void setIncrementalBuildEnable(boolean enabled) throws CoreException { incrementalBuildEnabled = Boolean.valueOf(enabled); } + @Override public void setIncrementalBuildTarget(String target) throws CoreException { incrementalBuildTarget = target; } + @Override public boolean appendEnvironment() { if(appendEnvironment == null){ if(superClass != null){ @@ -2021,6 +2132,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return appendEnvironment.booleanValue(); } + @Override public String getBuildAttribute(String name, String defaultValue) { String result = null; if(BUILD_TARGET_INCREMENTAL.equals(name)){ @@ -2156,12 +2268,14 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } + @Override public Map getEnvironment() { if(customizedEnvironment != null) return cloneMap(customizedEnvironment); return null; } + @Override public Map getExpandedEnvironment() throws CoreException { if(customizedEnvironment != null){ Map expanded = cloneMap(customizedEnvironment); @@ -2183,10 +2297,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return null; } + @Override public void setAppendEnvironment(boolean append) throws CoreException { appendEnvironment = Boolean.valueOf(append); } + @Override public void setBuildAttribute(String name, String value) throws CoreException { if(BUILD_TARGET_INCREMENTAL.equals(name)){ @@ -2255,10 +2371,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return customBuildProperties; } + @Override public void setEnvironment(Map env) throws CoreException { customizedEnvironment = new HashMap(env); } + @Override public boolean isCustomBuilder() { if(!isExtensionBuilder && getParent().getBuilder() != this) return true; @@ -2271,6 +2389,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return null; } + @Override public boolean isManagedBuildOn() { IConfiguration cfg = getConfguration(); if(cfg != null){ @@ -2295,14 +2414,17 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return managedBuildOn; } + @Override public void setManagedBuildOn(boolean on) throws CoreException { managedBuildOn = Boolean.valueOf(on); } + @Override public boolean canKeepEnvironmentVariablesInBuildfile() { return BuildMacroProvider.canKeepMacrosInBuildfile(this); } + @Override public boolean keepEnvironmentVariablesInBuildfile() { if(keepEnvVarInBuildfile == null){ if(superClass != null) @@ -2312,10 +2434,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return keepEnvVarInBuildfile.booleanValue(); } + @Override public void setKeepEnvironmentVariablesInBuildfile(boolean keep) { keepEnvVarInBuildfile = Boolean.valueOf(keep); } + @Override public boolean supportsCustomizedBuild() { if(fSupportsCustomizedBuild == null){ IManagedBuilderMakefileGenerator makeGen = getBuildFileGenerator(); @@ -2327,6 +2451,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return fSupportsCustomizedBuild.booleanValue(); } + @Override public boolean supportsBuild(boolean managed) { if(supportsManagedBuild == null){ if(superClass != null) @@ -2340,6 +2465,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider parent = toolChain; } + @Override public boolean matches(IBuilder builder){ if(builder == this) return true; @@ -2351,6 +2477,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return rBld == ManagedBuildManager.getRealBuilder(builder); } + @Override public MatchKey getMatchKey() { if(isAbstract()) return null; @@ -2359,6 +2486,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return new MatchKey(this); } + @Override public void setIdenticalList(List list) { identicalList = list; } @@ -2372,10 +2500,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return name; } + @Override public List getIdenticalList() { return identicalList; } + @Override public boolean isInternalBuilder() { IBuilder internalBuilder = ManagedBuildManager.getInternalBuilder(); for(IBuilder builder = this; builder != null; builder = builder.getSuperClass()){ @@ -2385,42 +2515,92 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return false; } - public int getParallelizationNum() { - if(supportsParallelBuild()) - return getParallelizationNumAttribute(); - return 1; + /** + * Returns the optimal number of parallel jobs. + * The number is the number of available processors on the machine. + * + * The function never returns number smaller than 1. + */ + public int getOptimalParallelJobNum() { + return Runtime.getRuntime().availableProcessors(); } - public int getParallelizationNumAttribute(){ - if(parallelNum == null){ + /** + * Returns the internal representation of maximum number of parallel jobs + * to be used for a build. + * Note that negative number represents "optimal" value. + * + * The value of the number is encoded as follows: + *
    +	 *  Status       Returns
    +	 * No parallel      1       
    +	 * Optimal       -CPU# (negative number of processors) 
    +	 * Specific        >0  (positive number)
    +	 * Unlimited    Builder.UNLIMITED_JOBS
    +	 * 
    + */ + public int getParallelizationNumAttribute() { + if (!isParallelBuildOn()) + return 1; + + if(parallelNumberAttribute == null){ if(superClass != null){ return ((Builder)superClass).getParallelizationNumAttribute(); } return 1; } - return parallelNum.intValue(); + return parallelNumberAttribute.intValue(); } - public void setParallelizationNum(int num) throws CoreException { -// if(num == 0 || supportsParallelBuild()){ - Integer newParallelNum = new Integer(num); + private void setParallelizationNumAttribute(int parallelNumber) { + isParallelBuildEnabled = (parallelNumber != 1); + if (parallelNumber > 0) { + parallelNumberAttribute = parallelNumber; + } else { + // "optimal" + parallelNumberAttribute = -getOptimalParallelJobNum(); + } + } + + @Override + public int getParallelizationNum() { + return Math.abs(getParallelizationNumAttribute()); + } + + /** + * {@inheritDoc} + * + * @param jobs - maximum number of jobs. There are 2 special cases: + *
    - any number <=0 is interpreted as setting "optimal" property, + * the value of the number itself is ignored in this case + *
    - value 1 will turn parallel mode off. + */ + @Override + public void setParallelizationNum(int jobs) throws CoreException { + if (!supportsParallelBuild()) + return; + + if (parallelNumberAttribute == null || parallelNumberAttribute != jobs) { String curCmd = getParallelizationCmd(getParallelizationNum()); String args = getArgumentsAttribute(); String updatedArgs = removeCmd(args, curCmd); - if(!updatedArgs.equals(args)){ + if (!updatedArgs.equals(args)) { setArgumentsAttribute(updatedArgs); } - parallelNum = newParallelNum; + + setParallelizationNumAttribute(jobs); setDirty(true); -// } + } } + @Override public boolean supportsParallelBuild() { if(isInternalBuilder()) return true; return getParrallelBuildCmd().length() != 0; } + @Override public boolean supportsStopOnError(boolean on) { if(isInternalBuilder()) return true; @@ -2446,42 +2626,48 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return ignoreErrCmd; } - public String getParrallelBuildCmd(){ - if(parallelBuildCmd == null){ - if(superClass != null){ - return ((Builder)superClass).getParrallelBuildCmd(); + public String getParrallelBuildCmd() { + if (parallelBuildCmd == null) { + if (superClass != null) { + return ((Builder) superClass).getParrallelBuildCmd(); } return EMPTY_STRING; } return parallelBuildCmd; } + @Override public boolean isParallelBuildOn() { - if(parallelBuildOn == null){ - if(superClass != null){ + if (!supportsParallelBuild()) { + return false; + } + if (isParallelBuildEnabled == null) { + if (superClass != null) { return getSuperClass().isParallelBuildOn(); } return false; } - return parallelBuildOn.booleanValue(); + return isParallelBuildEnabled.booleanValue(); } - public void setParallelBuildOn(boolean on) throws CoreException{ - if(isParallelBuildOn() == on) - return; - if(on && !supportsParallelBuild()) - return; - - String curCmd = getParallelizationCmd(getParallelizationNum()); - String args = getArgumentsAttribute(); - String updatedArgs = removeCmd(args, curCmd); - if(!updatedArgs.equals(args)){ - setArgumentsAttribute(updatedArgs); + /** + * {@inheritDoc} + * + * @param on - the flag to enable or disable parallel mode. + *
    {@code true} to enable, in this case the maximum number of jobs + * will be set to "optimal" number, see {@link #getOptimalParallelJobNum()}. + *
    {@code false} to disable, the number of jobs will be set to 1. + */ + @Override + public void setParallelBuildOn(boolean on) throws CoreException { + if (on) { + // set "optimal" jobs by default when enabling parallel build + setParallelizationNum(-1); + } else { + setParallelizationNum(1); } - parallelBuildOn = Boolean.valueOf(on); - setDirty(true); } - + public Set contributeErrorParsers(Set set){ if(getErrorParserIds() != null){ if(set == null) @@ -2521,6 +2707,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider } } + @Override public boolean isSystemObject() { if(isTest) return true; @@ -2533,6 +2720,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return false; } + @Override public String getUniqueRealName() { String name = getName(); if(name == null){ @@ -2604,6 +2792,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return num; } + @Override public int compareTo(Builder other) { if(other.isSystemObject() != isSystemObject()) return isSystemObject() ? 1 : -1; @@ -2611,30 +2800,37 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return getSuperClassNum() - other.getSuperClassNum(); } + @Override public IRealBuildObjectAssociation getExtensionObject() { return (Builder)ManagedBuildManager.getExtensionBuilder(this); } + @Override public IRealBuildObjectAssociation[] getIdenticBuildObjects() { return (IRealBuildObjectAssociation[])ManagedBuildManager.findIdenticalBuilders(this); } + @Override public IRealBuildObjectAssociation getRealBuildObject() { return (Builder)ManagedBuildManager.getRealBuilder(this); } + @Override public IRealBuildObjectAssociation getSuperClassObject() { return (Builder)getSuperClass(); } + @Override public final int getType() { return OBJECT_BUILDER; } + @Override public boolean isRealBuildObject() { return ManagedBuildManager.getRealBuilder(this) == this; } + @Override public boolean isExtensionBuildObject() { return isExtensionElement(); } @@ -2643,6 +2839,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return getUniqueRealName(); } + @Override public ICommandLauncher getCommandLauncher() { if(fCommandLauncher != null) return fCommandLauncher; @@ -2664,6 +2861,7 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return fCommandLauncher; } + @Override public AbstractBuildRunner getBuildRunner() throws CoreException { // Already defined if (fBuildRunner != null) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index a2093855a1c..d5ce4df6687 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -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 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 objs = new Vector(); 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 libs = new Vector(); 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 list = new ArrayList(); @@ -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 list = new ArrayList(); @@ -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 list = new ArrayList(); @@ -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(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java index 4acd71aeba6..5446824dae3 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java @@ -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 envList = new ArrayList(); + 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 makeArgs = new ArrayList(); + 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 premakeArgs = (ArrayList) 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 envList = new ArrayList(); - 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 makeArgs = new ArrayList(); - 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 premakeArgs = (ArrayList) 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(); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java index a2bfbc22137..c3e3fc4c404 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java @@ -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 ri = new ArrayList(); for (int i=0; ib || 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$ } } diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib old mode 100755 new mode 100644 diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib old mode 100755 new mode 100644 diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index ea5a472b683..aef89346a57 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -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); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index ca6240ec93e..4b1d5d9e4d3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -5574,4 +5574,13 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDependentUsingDeclaration() throws Exception { parseAndCheckBindings(); } + + // template void* foo(int); + // template void f(T t) { + // if (T* i = foo<0>(0)) + // return; + // } + public void testDirectlyNestedAmbiguity_362976() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ClassTypeHelperTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ClassTypeHelperTests.java new file mode 100644 index 00000000000..f3454e8e5cd --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ClassTypeHelperTests.java @@ -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)); + } +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java index f29296daa4d..1aa2dc3e859 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java @@ -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()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java index 8952f7df321..aa2db5ed3e9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteBaseTest.java @@ -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 testResourceFiles) throws Exception { + protected void compareFiles(Map 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()); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java index ee1912a8ef5..a3a3d20a8a4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTester.java @@ -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 testCases = createTests(in); @@ -60,7 +58,6 @@ public class RewriteTester extends TestSuite{ } private static ArrayList createTests(BufferedReader inputReader) throws Exception { - String line; Vector files = new Vector(); 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(); @@ -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 files) throws Exception { - - + private static RewriteBaseTest createTestClass(String className, String testName, + Vector 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 testCases, String name) { TestSuite suite = new TestSuite(name); Iterator it = testCases.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { RewriteBaseTest subject =it.next(); suite.addTest(subject); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java index c616d78c7bb..a6f3be6113d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/RewriteTests.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java index 69625d06b15..18e02659db8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestHelper.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java index e2d3f4de406..f4ed7aa83bd 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/TestSourceFile.java @@ -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) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java index 293a2afb5c0..29f9781df2a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java @@ -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 testResourceFiles) throws Exception { + protected void compareFiles(Map 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; } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java index 82024fe01eb..d67a2e34232 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTestSourceFile.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java index d26fe7dddb7..b95598ad1ca 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/AstWriterTestSuite.java @@ -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); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java index be01525aff9..c93c7225e21 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ExpressionWriterTest.java @@ -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; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java index 26ba7fd4f18..ee1b12a3f24 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/SourceRewriteTester.java @@ -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 testCases, String name) { TestSuite suite = new TestSuite(name); Iterator 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 createTests(BufferedReader inputReader) throws Exception { - String line; ASTWriterTestSourceFile file = null; MatcherState matcherState = MatcherState.skip; ArrayList testCases = new ArrayList(); - 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); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java index 3e38fdb3f41..f40b77b2e2f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java @@ -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(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java index d7c29b43c6f..68acede3815 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTestSuite.java @@ -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{ diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ArrayModifierTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ArrayModifierTest.java index 54eda488093..c076cf39eea 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ArrayModifierTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ArrayModifierTest.java @@ -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; - } + } }; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBug.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBug.java index 98d6a212734..a4ee61615bd 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBug.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/AddDeclarationBug.java @@ -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(); - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArrayModifierTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArrayModifierTest.java index 5c748a3ec06..68f994fbdeb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArrayModifierTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArrayModifierTest.java @@ -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(); - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArraySizeExpressionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArraySizeExpressionTest.java index 19767bdc6a7..df71239e075 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArraySizeExpressionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ArraySizeExpressionTest.java @@ -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(); - - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java index 68c0d52dba0..983348efcbb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/CtorChainInitializerTest.java @@ -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(); - - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExceptionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExceptionTest.java index 85250707810..4612e5a13fb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExceptionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExceptionTest.java @@ -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(); - - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExpressionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExpressionTest.java index 6dcd8c941e7..af06f5d44fb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExpressionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/ExpressionTest.java @@ -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(); - - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/FirstParameterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/FirstParameterTest.java index 0646e1e5966..52e3fc5e10d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/FirstParameterTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/FirstParameterTest.java @@ -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(); - - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java index 8790942047d..bd847e623ad 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/InsertBeforeTestSuite.java @@ -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()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/MultilineWhitespaceHandlingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/MultilineWhitespaceHandlingTest.java index f1b0c65f424..fd334b535b6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/MultilineWhitespaceHandlingTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/MultilineWhitespaceHandlingTest.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/PointerParameterTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/PointerParameterTest.java index 46ae41e6c06..aebdd2799d6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/PointerParameterTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/PointerParameterTest.java @@ -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(); - - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/SelfInsertionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/SelfInsertionTest.java index 946678acd02..ebaf97b3a3c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/SelfInsertionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/insertbefore/SelfInsertionTest.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveRenameTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveRenameTest.java index a6b0409d91e..57cbb37f25a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveRenameTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveRenameTest.java @@ -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); } - }; } - } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveTest.java index 9904ceebd81..a5c48afa3a0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/MoveTest.java @@ -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); } - }; } - } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/ReplaceInsertStatementTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/ReplaceInsertStatementTest.java index 7f44495590a..ec9997d57c1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/ReplaceInsertStatementTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/ReplaceInsertStatementTest.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/StatementTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/StatementTest.java index 6bad67fc412..a45f81c17f0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/StatementTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/replace/StatementTest.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java index 63ac04f1a90..067a29f8f28 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTest.java @@ -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.
    - * The source for the CommentHandling tests is located at /resources/rewrite/CommentHandlingTestSource.rts.
    - * This file contains the source code and the expected output for all the tests. Following a little example how such a test looks like:

    + * 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.
    + * The source for the CommentHandling tests is located at + * /resources/rewrite/CommentHandlingTestSource.rts.
    + * This file contains the source code and the expected output for all the tests. + * Following a little example how such a test looks like:

    * *
      * //!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).
    * The "//=" indicates the beginning of the expected test result.
    - * The test result contains three sections (separated by "=>leading", "=>trailing" and "=>freestanding").
    - * 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").
    + * 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 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(); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java index 0aa0ead6105..0eb83f788cf 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/CommentHandlingTestSuite.java @@ -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; } - } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java index 1121f531929..d12dfec2009 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/comenthandler/NodeCommentMapTest.java @@ -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; diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts index 7dca475d679..255cd87c3d7 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclSpecTestSource.awts @@ -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 diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts index 8a28473db06..f09bc5f0599 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclarationTestSource.awts @@ -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 //TEST 2 { //TEST 3 std::vector data; + public: - void Add(const double& ); + void Add(const double&); void Remove(); void Print(); //TEST 4 @@ -173,8 +183,9 @@ template<> class MyQueue /*TEST 2*/ { /*TEST 3*/ std::vector 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*/ diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts index 564bcd0506f..407ee5bfebd 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedDeclaratorTestSource.awts @@ -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 } } diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedNameTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedNameTestSource.awts index b6009c399a4..916e7952ba1 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedNameTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedNameTestSource.awts @@ -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 diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedStatementTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedStatementTestSource.awts index 9a790cd0c9d..7f6a0c46acb 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedStatementTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedStatementTestSource.awts @@ -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 (...){ } } diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource.awts index 87a1133feb4..a91d64e3e99 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource.awts @@ -1,45 +1,49 @@ //!CommentRecognition000 //%CPP -class Klasse0 +class Class0 { public: - Klasse0(); /* + Class0(); /* * Comment */ std::string toString(); + private: int i; }; //= -class Klasse0 +class Class0 { public: - Klasse0(); /* + Class0(); /* * Comment */ std::string toString(); + private: int i; }; //!CommentRecognition00 //%CPP -class Klasse0 +class Class0 { public: - Klasse0(); //Comment + Class0(); //Comment std::string toString(); + private: int i; }; //= -class Klasse0 +class Class0 { public: - Klasse0(); //Comment + Class0(); //Comment std::string toString(); + private: int i; }; @@ -47,12 +51,13 @@ private: //!CommentRecognition0 //%CPP //Comment1 -class Klasse0 +class Class0 { //Comment2 public: - Klasse0(); + Class0(); std::string toString(); + private: int i; }; @@ -131,6 +136,7 @@ public: void lala(); //test virtual ~test(); + protected: class test2 { @@ -153,6 +159,7 @@ public: void lala(); //test virtual ~test(); + protected: class test2 { @@ -175,6 +182,7 @@ public: void lala(); //test virtual ~test(); + protected: class test2 { @@ -187,7 +195,7 @@ protected: //%CPP class test { - //Klasse... + //Class... public: test(); /* @@ -196,6 +204,7 @@ public: void lala(); //test virtual ~test(); + protected: class test2 { @@ -206,122 +215,133 @@ protected: //!CommentRecognition1 - von CERP //%CPP -class Klasse1 +class Class1 { //TEST public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition2 - von CERP //%CPP -class Klasse1 +class Class1 { public: //TEST - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition3 - von CERP //%CPP -class Klasse1 +class Class1 { public: //TEST - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition4 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition5 - von CERP //%CPP -class Klasse1 +class Class1 { //TEST public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //= -class Klasse1 +class Class1 { //TEST public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition6 - von CERP //%CPP -class Klasse1{ //TEST +class Class1{ //TEST public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //= -class Klasse1 +class Class1 { //TEST public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition7 - von CERP //%CPP -class Klasse1 +class Class1 {//TEST public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //= -class Klasse1 +class Class1 { //TEST public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition8 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; int i = 5; //lala @@ -329,75 +349,82 @@ private: //!CommentRecognition9 - von CERP //%CPP -class Klasse1 +class Class1 { /*TEST*/ public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition10 - von CERP //%CPP -class Klasse1{ /*TEST*/ +class Class1{ /*TEST*/ public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //= -class Klasse1 +class Class1 { /*TEST*/ public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition11 - von CERP //%CPP -class Klasse1 +class Class1 { public: /*TEST*/ - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition11b - von CERP //%CPP -class Klasse1 +class Class1 { -public: /*TEST*/ Klasse1(); +public: /*TEST*/ Class1(); std::string toString(); + private: int i; }; //= -class Klasse1 +class Class1 { public: /*TEST*/ - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition12 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; int i = 5; /*TEST*/ @@ -405,25 +432,27 @@ private: //!CommentRecognition13 - von CERP //%CPP -class Klasse1 +class Class1 { /* * TEST */ public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition14 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; int i = 5; /* @@ -433,47 +462,51 @@ private: //!CommentRecognition15 - von CERP //%CPP -class Klasse1 +class Class1 { public: /* * TEST */ - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition16 - von CERP //%CPP -class Klasse1{ //Test mit +class Class1{ //Test mit //2 Zeilen public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //= -class Klasse1 +class Class1 { //Test mit //2 Zeilen public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition17 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; int i = 5; //Test mit @@ -482,48 +515,52 @@ private: //!CommentRecognition18 - von CERP //%CPP -class Klasse1{ +class Class1{ //Test mit //2 Zeilen public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //= -class Klasse1 +class Class1 { //Test mit //2 Zeilen public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition19 - von CERP //%CPP -class Klasse1 +class Class1 { //Test mit //2 Zeilen public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition20 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -536,11 +573,12 @@ private: //!CommentRecognition21 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; //TEST @@ -552,11 +590,12 @@ public: //!CommentRecognition22 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -569,11 +608,12 @@ private: //!CommentRecognition23 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + //KommentarDavor void inlineMethode() { @@ -587,11 +627,12 @@ private: //!CommentRecognition24 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -604,11 +645,12 @@ private: //!CommentRecognition25 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -622,11 +664,12 @@ private: //!CommentRecognition26 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -641,11 +684,12 @@ private: //!CommentRecognition27 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -658,11 +702,12 @@ private: //!CommentRecognition28 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -676,11 +721,12 @@ private: //!CommentRecognition29 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -695,11 +741,12 @@ private: //!CommentRecognition30 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + //TEST void inlineMethode() { @@ -713,11 +760,12 @@ private: //!CommentRecognition31 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + /*TEST*/ void inlineMethode() { @@ -732,11 +780,12 @@ private: //!CommentRecognition32 - von CERP //%CPP //Vorher -class Klasse1 //Nachher +class Class1 //Nachher { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -750,11 +799,12 @@ private: //!CommentRecognition33 - von CERP //%CPP //Vorher -class Klasse1 /*Nachher*/ +class Class1 /*Nachher*/ { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -768,12 +818,13 @@ private: //!CommentRecognition34 - von CERP //%CPP /*Vorher*/ -class Klasse1 +class Class1 { /*Nachher*/ public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -787,12 +838,13 @@ private: //!CommentRecognition35 - von CERP //%CPP /*Vorher*/ -class Klasse1 +class Class1 { //Nachher public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -808,12 +860,13 @@ private: /* * Vorher */ -class Klasse1 +class Class1 { //Nachher public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -826,11 +879,12 @@ private: //!CommentRecognition37 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -843,11 +897,12 @@ private: //!CommentRecognition38 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -860,11 +915,12 @@ private: //!CommentRecognition39 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -879,11 +935,12 @@ private: //!CommentRecognition40 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -899,11 +956,12 @@ private: //!CommentRecognition41 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -917,11 +975,12 @@ private: //!CommentRecognition42 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + void inlineMethode() { int i = 0; @@ -935,7 +994,7 @@ private: //!CommentRecognition43 - von CERP //%CPP -class Klasse1 +class Class1 { private: int i; @@ -943,7 +1002,7 @@ private: //!CommentRecognition44 - von CERP //%CPP -class Klasse1 +class Class1 { private: int i; @@ -952,7 +1011,7 @@ private: //!CommentRecognition44b - von CERP //%CPP -class Klasse1 +class Class1 { private: int i; //TEST @@ -960,7 +1019,7 @@ private: //!CommentRecognition44c - von CERP //%CPP -class Klasse1 +class Class1 { private: int i; @@ -969,7 +1028,7 @@ private: //!CommentRecognition44d - von CERP //%CPP -class Klasse1 +class Class1 { private: int i; @@ -979,7 +1038,7 @@ private: //!CommentRecognition45 - von CERP //%CPP -class Klasse1 +class Class1 { private: //TEST @@ -988,7 +1047,7 @@ private: //!CommentRecognition46 - von CERP //%CPP -class Klasse1 +class Class1 { //TEST private: @@ -997,137 +1056,148 @@ private: //!CommentRecognition47 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: //TEST int i; }; //!CommentRecognition48 - von CERP //%CPP -class Klasse1 +class Class1 { //TEST public: /*TEST*/ - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition48b - von CERP //%CPP -class Klasse1 +class Class1 { //TEST public: /*TEST*/ - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition49 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); //TEST1 + Class1(); //TEST1 //TEST2 std::string toString(); + private: int i; }; //!CommentRecognition50 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); /*TEST1*/ + Class1(); /*TEST1*/ /*TEST2*/ std::string toString(); + private: int i; }; //!CommentRecognition51 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); //TEST1 + Class1(); //TEST1 /*TEST2*/ std::string toString(); + private: int i; }; //!CommentRecognition52 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); /*TEST1*/ + Class1(); /*TEST1*/ //TEST2 std::string toString(); + private: int i; }; //!CommentRecognition53 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); /*TEST1*/ + Class1(); /*TEST1*/ //TEST3 //TEST2 std::string toString(); + private: int i; }; //!CommentRecognition54 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); /*TEST1*/ + Class1(); /*TEST1*/ /*TEST3*/ //TEST2 std::string toString(); + private: int i; }; //!CommentRecognition55 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); //TEST1 + Class1(); //TEST1 /* * TEST3 */ std::string toString(); + private: int i; }; //!CommentRecognition56 - von CERP //%CPP -class Klasse1 +class Class1 { public: - Klasse1(); /* + Class1(); /* * TEST1 */ //TEST2 std::string toString(); + private: int i; }; @@ -1136,27 +1206,31 @@ private: //%CPP namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition58 - von CERP //%CPP -//Kommentar +//Comment namespace testNamespace { -class Klasse1 +class Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; @@ -1164,224 +1238,264 @@ private: } //= -//Kommentar +//Comment namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition59 - von CERP //%CPP -namespace testNamespace //Kommentar +namespace testNamespace //Comment { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition60 - von CERP //%CPP -/*Kommentar*/ +/*Comment*/ namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition61 - von CERP //%CPP -namespace testNamespace /*Kommentar*/ +namespace testNamespace /*Comment*/ { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition62 - von CERP //%CPP /* - * Kommentar + * Comment */ namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition63 - von CERP //%CPP namespace testNamespace /* - * Kommentar + * Comment */ { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition64 - von CERP //%CPP namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; -} //Kommentar + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + +} //Comment //!CommentRecognition65 - von CERP //%CPP namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; -} /*Kommentar*/ + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + +} /*Comment*/ //!CommentRecognition66 - von CERP //%CPP namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } /* - * Kommentar + * Comment */ //!CommentRecognition67 - von CERP //%CPP namespace testNamespace { - class Klasse1 //TEST - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; + +class Class1 //TEST +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; + } //!CommentRecognition68 - von CERP //%CPP namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; //TEST - }; + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; //TEST +}; + } //!CommentRecognition69 - von CERP //%CPP namespace testNamespace { - class Klasse1 - { - public: - Klasse1(); - std::string toString(); - private: - int i; - }; //TEST + +class Class1 +{ +public: + Class1(); + std::string toString(); + +private: + int i; +}; //TEST + } //!CommentRecognition100 - von CERP //%CPP -struct Klasse1 +struct Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition101 - von CERP //%CPP -//Kommentar -struct Klasse1 +//Comment +struct Class1 { public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition102 - von CERP //%CPP -struct Klasse1 +struct Class1 { - //Kommentar + //Comment public: - Klasse1(); + Class1(); std::string toString(); + private: int i; }; //!CommentRecognition103 - von CERP //%CPP -struct Klasse1 +struct Class1 { - //Kommentar + //Comment private: - Klasse1(); + Class1(); std::string toString(); + protected: int i; }; @@ -1389,11 +1503,12 @@ protected: //!CommentRecognition104 - von CERP //%CPP /*Davor*/ -struct Klasse1 //Kommentar +struct Class1 //Comment { private: - Klasse1(); + Class1(); std::string toString(); + protected: int i; }; diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts index 42b22752dd6..5568c0a37de 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterCommentedTestSource2.awts @@ -1,6 +1,7 @@ //!Commented TemplateFunction1 //%CPP -template int tempFunct(T p) +template +int tempFunct(T p) { ++p; //Kommentar @@ -12,7 +13,8 @@ template int tempFunct(T p) //!Commented TemplateFunction2 //%CPP //Kommentar -template int tempFunct(T p) +template +int tempFunct(T p) { ++p; p + 4; @@ -22,7 +24,8 @@ template int tempFunct(T p) //!Commented TemplateFunction3 //%CPP -template int tempFunct(T p) +template +int tempFunct(T p) { ++p; p + 4; diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclSpecTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclSpecTestSource.awts index ae154ea2686..542373ff4c8 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclSpecTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclSpecTestSource.awts @@ -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 diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts index 4280ae8027e..14653f5cc88 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclarationTestSource.awts @@ -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 class MyQueue; template<> class MyQueue { std::vector 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; diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts index 0c541c209c8..97c1ba19ac8 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterDeclaratorTestSource.awts @@ -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; } diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts index 345c4453981..b2d0faa9f80 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterExpressionTestSource.awts @@ -4,10 +4,10 @@ int i = (int)'A'; //!CPPCastExpression //%CPP -TestClass *i = dynamic_cast(tc); -TestClass *i = static_cast(tc); -TestClass *i = reinterpret_cast(tc); -TestClass *i = const_cast(tc); +TestClass* i = dynamic_cast(tc); +TestClass* i = static_cast(tc); +TestClass* i = reinterpret_cast(tc); +TestClass* i = const_cast(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 diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterNameTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterNameTestSource.awts index 11081af1532..9117bb41bbc 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterNameTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterNameTestSource.awts @@ -11,7 +11,7 @@ int TestClass::Hallo; class Foo { public: - char & operator [](unsigned int); + char& operator [](unsigned int); }; //!ConversionName diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterStatementTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterStatementTestSource.awts index 0d1dfe14ba6..a322f51b197 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterStatementTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterStatementTestSource.awts @@ -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]; diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts index c11a70ff3ce..32ff7264c82 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/ASTWriterTemplateTestSource.awts @@ -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 void f(T *p) +template +void f(T* p) { T::template adjust<100>(); } diff --git a/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts b/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts index 07dac1713bc..422b99ae02b 100644 --- a/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts +++ b/core/org.eclipse.cdt.core.tests/resources/rewrite/CommentHandlingTestSource.rts @@ -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 diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java index 1dd364ab631..c4c407f62a7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompositeTypeSpecifier.java @@ -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 { /** * TYPE_NAME represents the relationship between an @@ -101,5 +100,6 @@ public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier , IASTName /** * @since 5.1 */ + @Override public IASTCompositeTypeSpecifier copy(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java index b2c555cf3d5..7a8b29c66b4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTCompoundStatement.java @@ -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); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java index 74c9d07096e..0a216e04747 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java @@ -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; - - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java index 99ea2f6955e..7cf4d873fe1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFunctionDefinition.java @@ -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); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java index bbce9799508..86e6b25e52b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java @@ -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); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java index 3a7dfea8172..baab11bdb0d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java @@ -64,6 +64,7 @@ public interface IASTTranslationUnit extends IASTDeclarationListOwner, IFileNomi * * @param declaration IASTDeclaration */ + @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); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java index b41944e68f5..96ab919ceca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCompositeTypeSpecifier.java @@ -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); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java index e302b4e2e19..b08da127cb6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTParameterDeclaration.java @@ -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(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java index c12b248514f..16bfa987063 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java @@ -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); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java index b4350e2666a..ce06349cc78 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java @@ -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); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java index ec1ee98719e..ee2b2e90f12 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java @@ -202,8 +202,8 @@ public final class ASTRewrite { * changes. *

    * - * @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() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java index ecc6fb867c9..c59986d92d3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/DeclarationGenerator.java @@ -6,9 +6,8 @@ * 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.core.dom.rewrite; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; @@ -18,8 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl; /** - * - * This class handles the creation of {@link IASTDeclarator}s and {@link IASTDeclSpecifier}s basing on given type. + * This class handles the creation of {@link IASTDeclarator}s and {@link IASTDeclSpecifier}s + * for a given type. * * @author Tomasz Wesolowski * @noextend This interface is not intended to be extended by clients. @@ -45,5 +44,4 @@ public abstract class DeclarationGenerator { * @return the generated declarator */ public abstract IASTDeclarator createDeclaratorFromType(IType type, char[] name); - } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/TypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/TypeHelper.java new file mode 100644 index 00000000000..d3c7d53c6e7 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/TypeHelper.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.dom.rewrite; + +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.ICompositeType; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; +import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator; +import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; + +/** + * A collection of static methods related to types. + * @since 5.4 + */ +public class TypeHelper { + + // Do not instantiate - all methods are static. + private TypeHelper() { + } + + /** + * Returns true if it is preferable to pass parameters of the given type to methods + * by reference, not by value. A parameter should be passed by reference if it is + * a class, struct, or union, and either has a nontrivial + * copy constructor or nontrivial destructor, or is larger than pointer. + * + * @param type the type in question. + * @param ast the AST used as a context. + * @return true is passing by reverence is preferable. + */ + public static boolean shouldBePassedByReference(IType type, IASTTranslationUnit ast) { + type = SemanticUtil.getNestedType(type, SemanticUtil.CVTYPE | SemanticUtil.TDEF); + if (type instanceof ICompositeType) { + if (type instanceof ICPPClassType) { + ICPPClassType classType = ((ICPPClassType) type); + if (!ClassTypeHelper.hasTrivialCopyCtor(classType) || + !ClassTypeHelper.hasTrivialDestructor(classType)) { + return true; + } + } + SizeofCalculator calc = ((ASTTranslationUnit) ast).getSizeofCalculator(); + SizeAndAlignment sizeofPointer = calc.sizeAndAlignmentOfPointer(); + if (sizeofPointer == null) + return true; + SizeAndAlignment sizeofType = calc.sizeAndAlignment(type); + if (sizeofType == null || sizeofType.size > sizeofPointer.size) + return true; + } + return false; + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java index 721950391e1..91b92405adf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousBinaryVsCastExpression.java @@ -40,15 +40,18 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod fCastExpression= castExpression; } - public final IASTExpression copy() { + @Override + public final IASTExpression copy() { throw new UnsupportedOperationException(); } + @Override public final IASTExpression copy(CopyStyle style) { throw new UnsupportedOperationException(); } - public final void addExpression(IASTExpression e) { + @Override + public final void addExpression(IASTExpression e) { throw new UnsupportedOperationException(); } @@ -57,12 +60,13 @@ public abstract class ASTAmbiguousBinaryVsCastExpression extends ASTAmbiguousNod return getExpressions(); } + @Override public IASTExpression[] getExpressions() { return new IASTExpression[] {fBinaryExpression, fCastExpression}; } @Override - public final IASTNode resolveAmbiguity(ASTVisitor visitor) { + protected final IASTNode doResolveAmbiguity(ASTVisitor visitor) { final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java index dcc060262b2..873e540bd39 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousCastVsFunctionCallExpression.java @@ -49,24 +49,28 @@ public abstract class ASTAmbiguousCastVsFunctionCallExpression extends ASTAmbigu return getExpressions(); } - public final IASTExpression copy() { + @Override + public final IASTExpression copy() { throw new UnsupportedOperationException(); } + @Override public final IASTExpression copy(CopyStyle style) { throw new UnsupportedOperationException(); } - public void addExpression(IASTExpression e) { + @Override + public void addExpression(IASTExpression e) { throw new UnsupportedOperationException(); } + @Override public IASTExpression[] getExpressions() { return new IASTExpression[] {fCastExpression, fFunctionCallExpression}; } @Override - public final IASTNode resolveAmbiguity(ASTVisitor visitor) { + protected final IASTNode doResolveAmbiguity(ASTVisitor visitor) { final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java index 772fd3e70c8..3f56c3c2d08 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java @@ -49,6 +49,8 @@ public abstract class ASTAmbiguousNode extends ASTNode { return names; } } + + private IASTNode fResolution; /** * Return the alternative nodes for this ambiguity. @@ -73,7 +75,11 @@ public abstract class ASTAmbiguousNode extends ASTNode { protected void afterResolution(ASTVisitor resolver, IASTNode best) { } - public IASTNode resolveAmbiguity(ASTVisitor resolver) { + public IASTNode resolveAmbiguity(ASTVisitor resolver) { + return fResolution= doResolveAmbiguity(resolver); + } + + protected IASTNode doResolveAmbiguity(ASTVisitor resolver) { beforeResolution(); final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; @@ -85,23 +91,23 @@ public abstract class ASTAmbiguousNode extends ASTNode { for (IASTNode alternative : alternatives) { // Setup the ast to use the alternative owner.replace(nodeToReplace, alternative); - nodeToReplace= alternative; beforeAlternative(alternative); + + // Handle nested ambiguities + alternative= resolveNestedAmbiguities(alternative, resolver); + nodeToReplace= alternative; - // handle nested ambiguities first, otherwise we cannot visit the alternative - alternative.accept(resolver); - - // find nested names + // Find nested names final NameCollector nameCollector= new NameCollector(); alternative.accept(nameCollector); final IASTName[] names= nameCollector.getNames(); - // resolve names and count issues + // Resolve names and count issues int issues= 0; for (IASTName name : names) { try { - // avoid resolution of parameters (can always be resolved), + // Avoid resolution of parameters (can always be resolved), // it can triggers resolution of declaration it belongs to, // while the declarator is still ambiguous. Could be solved by introducing an // intermediate binding for parameters, similar to template parameters. @@ -133,7 +139,7 @@ public abstract class ASTAmbiguousNode extends ASTNode { } } - // switch back to the best alternative, if necessary. + // Switch back to the best alternative, if necessary. if (nodeToReplace != bestAlternative) { owner.replace(nodeToReplace, bestAlternative); } @@ -141,7 +147,14 @@ public abstract class ASTAmbiguousNode extends ASTNode { return bestAlternative; } - public final IType getExpressionType() { + protected IASTNode resolveNestedAmbiguities(IASTNode alternative, ASTVisitor resolver) { + alternative.accept(resolver); + if (alternative instanceof ASTAmbiguousNode) + return ((ASTAmbiguousNode) alternative).fResolution; + return alternative; + } + + public final IType getExpressionType() { throw new UnsupportedOperationException(); } public final ValueCategory getValueCategory() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java index 8499a973a28..6d05a310554 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/SizeofCalculator.java @@ -34,7 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; /** - * Calculator of in-memory size and of types. + * Calculator of in-memory size and alignment of types. */ public class SizeofCalculator { /** Size and alignment pair */ @@ -95,16 +95,16 @@ public class SizeofCalculator { sizeof_bool = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$ sizeof_wchar_t = getSize(sizeofMacros, "__SIZEOF_WCHAR_T__", maxAlignment); //$NON-NLS-1$ sizeof_float = getSize(sizeofMacros, "__SIZEOF_FLOAT__", maxAlignment); //$NON-NLS-1$ - sizeof_complex_float = getDoubleSize(sizeof_float); + sizeof_complex_float = getSizeOfPair(sizeof_float); sizeof_double = getSize(sizeofMacros, "__SIZEOF_DOUBLE__", maxAlignment); //$NON-NLS-1$ - sizeof_complex_double = getDoubleSize(sizeof_double); + sizeof_complex_double = getSizeOfPair(sizeof_double); sizeof_long_double = getSize(sizeofMacros, "__SIZEOF_LONG_DOUBLE__", maxAlignment); //$NON-NLS-1$ - sizeof_complex_long_double = getDoubleSize(sizeof_long_double); + sizeof_complex_long_double = getSizeOfPair(sizeof_long_double); } /** * Calculates size and alignment for the given type. - * @param type + * @param type the type to get size and alignment for. * @return size and alignment, or null if could not be calculated. */ public SizeAndAlignment sizeAndAlignment(IType type) { @@ -130,6 +130,14 @@ public class SizeofCalculator { return null; } + /** + * Returns size and alignment of pointer types. + * @return size and alignment of pointer types, or null if unknown. + */ + public SizeAndAlignment sizeAndAlignmentOfPointer() { + return sizeof_pointer; + } + private SizeAndAlignment sizeAndAlignment(IBasicType type) { Kind kind = type.getKind(); switch (kind) { @@ -262,7 +270,7 @@ public class SizeofCalculator { } } - private SizeAndAlignment getDoubleSize(SizeAndAlignment sizeAndAlignment) { + private SizeAndAlignment getSizeOfPair(SizeAndAlignment sizeAndAlignment) { return sizeAndAlignment == null ? null : new SizeAndAlignment(sizeAndAlignment.size * 2, sizeAndAlignment.alignment); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 72fc9fc330c..5d212fc4ee1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -91,11 +91,12 @@ public class Value implements IValue { fResolvedUnknown= resolvedUnknowns; fMap= map; } + public void nextSeperator() throws UnknownValueException { final char[] expression = fExpression; final int len = expression.length; int idx = pos; - while(idx < len) { + while (idx < len) { if (expression[idx++] == SEPARATOR) break; } @@ -105,7 +106,7 @@ public class Value implements IValue { private static class UnknownValueException extends Exception {} private static UnknownValueException UNKNOWN_EX= new UnknownValueException(); - private static int sUnique=0; + private static int sUnique= 0; private final char[] fExpression; private final ICPPUnknownBinding[] fUnknownBindings; @@ -404,7 +405,8 @@ public class Value implements IValue { * Returns a {@code Number} for numerical values or a {@code String}, otherwise. * @throws UnknownValueException */ - private static Object evaluate(IASTExpression e, Map unknownSigs, List unknowns, int maxdepth) throws UnknownValueException { + private static Object evaluate(IASTExpression e, Map unknownSigs, + List unknowns, int maxdepth) throws UnknownValueException { if (maxdepth < 0 || e == null) throw UNKNOWN_EX; @@ -437,7 +439,8 @@ public class Value implements IValue { final IASTExpression pe = cexpr.getPositiveResultExpression(); Object po= pe == null ? o : evaluate(pe, unknownSigs, unknowns, maxdepth); Object neg= evaluate(cexpr.getNegativeResultExpression(), unknownSigs, unknowns, maxdepth); - return "" + CONDITIONAL_CHAR + SEPARATOR + o.toString() + SEPARATOR + po.toString() + SEPARATOR + neg.toString(); //$NON-NLS-1$ + return "" + CONDITIONAL_CHAR + SEPARATOR + o.toString() + SEPARATOR + po.toString() + //$NON-NLS-1$ + SEPARATOR + neg.toString(); } if (e instanceof IASTIdExpression) { IBinding b= ((IASTIdExpression) e).getName().resolvePreBinding(); @@ -487,7 +490,8 @@ public class Value implements IValue { /** * Extract a value off a binding. */ - private static Object evaluateBinding(IBinding b, Map unknownSigs, List unknowns, int maxdepth) throws UnknownValueException { + private static Object evaluateBinding(IBinding b, Map unknownSigs, + List unknowns, int maxdepth) throws UnknownValueException { if (b instanceof IType) { throw UNKNOWN_EX; } @@ -514,7 +518,8 @@ public class Value implements IValue { throw UNKNOWN_EX; } - private static Object createReference(ICPPUnknownBinding unknown, Map unknownSigs, List unknowns) { + private static Object createReference(ICPPUnknownBinding unknown, + Map unknownSigs, List unknowns) { String sig= getSignatureForUnknown(unknown); Integer idx= unknownSigs.get(sig); if (idx == null) { @@ -525,7 +530,8 @@ public class Value implements IValue { return "" + REFERENCE_CHAR + idx.toString(); //$NON-NLS-1$ } - private static Object evaluateValue(IValue cv, Map unknownSigs, List unknowns) throws UnknownValueException { + private static Object evaluateValue(IValue cv, Map unknownSigs, + List unknowns) throws UnknownValueException { if (cv == Value.UNKNOWN) throw UNKNOWN_EX; @@ -568,7 +574,9 @@ public class Value implements IValue { return buf.toString(); } - private static Object evaluateUnaryExpression(IASTUnaryExpression ue, Map unknownSigs, List unknowns, int maxdepth) throws UnknownValueException { + private static Object evaluateUnaryExpression(IASTUnaryExpression ue, + Map unknownSigs, List unknowns, int maxdepth) + throws UnknownValueException { final int unaryOp= ue.getOperator(); if (unaryOp == IASTUnaryExpression.op_sizeof) { @@ -630,7 +638,8 @@ public class Value implements IValue { } private static Object evaluateBinaryExpression(IASTBinaryExpression be, - Map unknownSigs, List unknowns, int maxdepth) throws UnknownValueException { + Map unknownSigs, List unknowns, int maxdepth) + throws UnknownValueException { final Object o1= evaluate(be.getOperand1(), unknownSigs, unknowns, maxdepth); final Object o2= evaluate(be.getOperand2(), unknownSigs, unknowns, maxdepth); @@ -638,7 +647,8 @@ public class Value implements IValue { return combineBinary(op, o1, o2); } - private static Object combineBinary(final int op, final Object o1, final Object o2) throws UnknownValueException { + private static Object combineBinary(final int op, final Object o1, final Object o2) + throws UnknownValueException { if (o1 instanceof Number && o2 instanceof Number) { long v1= ((Number) o1).longValue(); long v2= ((Number) o2).longValue(); @@ -725,7 +735,8 @@ public class Value implements IValue { return "" + BINARY_OP_CHAR + op + SEPARATOR + o1.toString() + SEPARATOR + o2.toString(); //$NON-NLS-1$ } - public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns, ICPPTemplateParameterMap map, int maxdepth) { + public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns, + ICPPTemplateParameterMap map, int maxdepth) { try { Map unknownSigs= new HashMap(); List unknown= new ArrayList(); @@ -787,7 +798,8 @@ public class Value implements IValue { } return po; } - return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + po.toString() + SEPARATOR + neg.toString(); //$NON-NLS-1$ + return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + //$NON-NLS-1$ + po.toString() + SEPARATOR + neg.toString(); case REFERENCE_CHAR: int num= parseNonNegative(buf, idx + 1); final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown; @@ -889,7 +901,7 @@ public class Value implements IValue { * Parses a long. */ private static long parseLong(char[] value, int offset) throws UnknownValueException { - final long maxvalue= Long.MAX_VALUE/10; + final long maxvalue= Long.MAX_VALUE / 10; final int len= value.length; boolean negative= false; long result = 0; @@ -920,7 +932,7 @@ public class Value implements IValue { * Parses a long, returns null if not possible */ private static Long parseLong(char[] value) { - final long maxvalue= Long.MAX_VALUE/10; + final long maxvalue= Long.MAX_VALUE / 10; final int len= value.length; boolean negative= false; long result = 0; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java index 27e7424a91c..c62e6eede27 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTAmbiguousSimpleDeclaration.java @@ -56,39 +56,45 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements return new IASTNode[] {fSimpleDecl, fAltDeclSpec, fAltDtor}; } + @Override public IASTSimpleDeclaration copy() { throw new UnsupportedOperationException(); } + @Override public IASTSimpleDeclaration copy(CopyStyle style) { throw new UnsupportedOperationException(); } + @Override public void addDeclarator(IASTDeclarator declarator) { fSimpleDecl.addDeclarator(declarator); } + @Override public IASTDeclSpecifier getDeclSpecifier() { return fSimpleDecl.getDeclSpecifier(); } + @Override public IASTDeclarator[] getDeclarators() { return fSimpleDecl.getDeclarators(); } + @Override public void setDeclSpecifier(IASTDeclSpecifier declSpec) { fSimpleDecl.setDeclSpecifier(declSpec); } @Override - public final IASTNode resolveAmbiguity(ASTVisitor visitor) { + protected final IASTNode doResolveAmbiguity(ASTVisitor resolver) { final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; // handle nested ambiguities first owner.replace(nodeToReplace, fSimpleDecl); IASTDeclSpecifier declSpec= fSimpleDecl.getDeclSpecifier(); - declSpec.accept(visitor); + declSpec.accept(resolver); // find nested names @@ -118,7 +124,7 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements } // resolve further nested ambiguities - fSimpleDecl.accept(visitor); + fSimpleDecl.accept(resolver); return fSimpleDecl; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java index f58d3afbb9b..81b864a9bfc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java @@ -43,13 +43,14 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem fParameterDecl= decl; } + @Override public void addParameterDeclaration(IASTParameterDeclaration d) { assert false; } @Override - public IASTNode resolveAmbiguity(ASTVisitor resolver) { + protected final IASTNode doResolveAmbiguity(ASTVisitor resolver) { final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); // Setup the ast to use the alternative @@ -79,6 +80,7 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem } } + @Override public IASTParameterDeclaration[] getParameterDeclarations() { return new IASTParameterDeclaration[] {fParameterDecl}; } @@ -88,32 +90,39 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem return getParameterDeclarations(); } + @Override public IASTDeclSpecifier getDeclSpecifier() { return fParameterDecl.getDeclSpecifier(); } + @Override public ICPPASTDeclarator getDeclarator() { return fParameterDecl.getDeclarator(); } + @Override public void setDeclSpecifier(IASTDeclSpecifier declSpec) { Assert.isLegal(false); } + @Override public void setDeclarator(IASTDeclarator declarator) { Assert.isLegal(false); } + @Override public ICPPASTParameterDeclaration copy() { Assert.isLegal(false); return null; } + @Override public ICPPASTParameterDeclaration copy(CopyStyle style) { Assert.isLegal(false); return null; } + @Override public boolean isParameterPack() { Assert.isLegal(false); return true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java index a546fb979d2..483a0652c50 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java @@ -58,39 +58,45 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement return new IASTNode[] {fSimpleDecl, fAltDeclSpec, fAltDtor}; } + @Override public IASTSimpleDeclaration copy() { throw new UnsupportedOperationException(); } + @Override public IASTSimpleDeclaration copy(CopyStyle style) { throw new UnsupportedOperationException(); } + @Override public void addDeclarator(IASTDeclarator declarator) { fSimpleDecl.addDeclarator(declarator); } + @Override public IASTDeclSpecifier getDeclSpecifier() { return fSimpleDecl.getDeclSpecifier(); } + @Override public IASTDeclarator[] getDeclarators() { return fSimpleDecl.getDeclarators(); } + @Override public void setDeclSpecifier(IASTDeclSpecifier declSpec) { fSimpleDecl.setDeclSpecifier(declSpec); } @Override - public final IASTNode resolveAmbiguity(ASTVisitor visitor) { + protected final IASTNode doResolveAmbiguity(ASTVisitor resolver) { final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; // handle nested ambiguities first owner.replace(nodeToReplace, fSimpleDecl); IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0]; - dtor.accept(visitor); + dtor.accept(resolver); // find nested names @@ -120,7 +126,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement } // resolve further nested ambiguities - fSimpleDecl.accept(visitor); + fSimpleDecl.accept(resolver); return fSimpleDecl; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java index dd0ec944973..9d4f2b54089 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCastExpression.java @@ -44,10 +44,12 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi setTypeId(typeId); } + @Override public CPPASTCastExpression copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTCastExpression copy(CopyStyle style) { CPPASTCastExpression copy = new CPPASTCastExpression(); copy.setOperator(getOperator()); @@ -61,6 +63,7 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi return copy; } + @Override public void setTypeId(IASTTypeId typeId) { assertNotFrozen(); this.typeId = typeId; @@ -70,24 +73,29 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi } } - public IASTTypeId getTypeId() { + @Override + public IASTTypeId getTypeId() { return typeId; } + @Override public int getOperator() { return op; } - public void setOperator(int operator) { + @Override + public void setOperator(int operator) { assertNotFrozen(); op = operator; } - public IASTExpression getOperand() { + @Override + public IASTExpression getOperand() { return operand; } - public void setOperand(IASTExpression expression) { + @Override + public void setOperand(IASTExpression expression) { assertNotFrozen(); operand = expression; if (expression != null) { @@ -120,7 +128,8 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi return true; } - public void replace(IASTNode child, IASTNode other) { + @Override + public void replace(IASTNode child, IASTNode other) { if (child == operand) { other.setPropertyInParent(child.getPropertyInParent()); other.setParent(child.getParent()); @@ -128,6 +137,7 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi } } + @Override public IType getExpressionType() { if (fType == null) { IType t= CPPVisitor.createType(typeId.getAbstractDeclarator()); @@ -137,6 +147,7 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi return fType; } + @Override public ValueCategory getValueCategory() { if (fValueCategory == null) { getExpressionType(); // as a side effect fValueCategory is computed @@ -144,6 +155,7 @@ public class CPPASTCastExpression extends ASTNode implements ICPPASTCastExpressi return fValueCategory; } + @Override public boolean isLValue() { return getValueCategory() == LVALUE; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java index 0ffd9be7e1f..4eb7e05307f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompoundStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -23,17 +23,17 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * @author jcamelon */ -public class CPPASTCompoundStatement extends ASTNode implements - IASTCompoundStatement, IASTAmbiguityParent { +public class CPPASTCompoundStatement extends ASTNode + implements IASTCompoundStatement, IASTAmbiguityParent { + private IASTStatement[] statements = new IASTStatement[2]; + private ICPPScope scope; - private IASTStatement [] statements = new IASTStatement[2]; - private ICPPScope scope = null; - - - public CPPASTCompoundStatement copy() { + @Override + public CPPASTCompoundStatement copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTCompoundStatement copy(CopyStyle style) { CPPASTCompoundStatement copy = new CPPASTCompoundStatement(); for (IASTStatement statement : getStatements()) @@ -45,57 +45,61 @@ public class CPPASTCompoundStatement extends ASTNode implements return copy; } - public IASTStatement[] getStatements() { - if( statements == null ) return IASTStatement.EMPTY_STATEMENT_ARRAY; - return (IASTStatement[]) ArrayUtil.trim( IASTStatement.class, statements ); + @Override + public IASTStatement[] getStatements() { + if (statements == null) + return IASTStatement.EMPTY_STATEMENT_ARRAY; + return (IASTStatement[]) ArrayUtil.trim(IASTStatement.class, statements); } - public void addStatement(IASTStatement statement) { + @Override + public void addStatement(IASTStatement statement) { assertNotFrozen(); - statements = (IASTStatement[]) ArrayUtil.append( IASTStatement.class, statements, statement ); + statements = (IASTStatement[]) ArrayUtil.append(IASTStatement.class, statements, statement); if (statement != null) { statement.setParent(this); statement.setPropertyInParent(NESTED_STATEMENT); } } - public IScope getScope() { - if( scope == null ) - scope = new CPPBlockScope( this ); + @Override + public IScope getScope() { + if (scope == null) + scope = new CPPBlockScope(this); return scope; } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action) { + if (action.shouldVisitStatements) { + switch (action.visit(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } - IASTStatement [] s = getStatements(); - for ( int i = 0; i < s.length; i++ ) { - if( !s[i].accept( action ) ) return false; + IASTStatement[] s = getStatements(); + for (int i = 0; i < s.length; i++) { + if (!s[i].accept(action)) + return false; } - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements) { + switch (action.leave(this)) { + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } - public void replace(IASTNode child, IASTNode other) { - if( statements == null ) return; - for( int i = 0; i < statements.length; ++i ) - { - if( statements[i] == child ) - { - other.setParent( statements[i].getParent() ); - other.setPropertyInParent( statements[i].getPropertyInParent() ); + @Override + public void replace(IASTNode child, IASTNode other) { + if (statements == null) return; + for (int i = 0; i < statements.length; ++i) { + if (statements[i] == child) { + other.setParent(statements[i].getParent()); + other.setPropertyInParent(statements[i].getPropertyInParent()); statements[i] = (IASTStatement) other; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java index c9477d3ce9f..4742eb26e0a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java @@ -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: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Contributors: + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -44,10 +44,12 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx this.value = value; } + @Override public CPPASTLiteralExpression copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTLiteralExpression copy(CopyStyle style) { CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind, value == null ? null : value.clone()); @@ -58,20 +60,24 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx return copy; } + @Override public int getKind() { return kind; } - public void setKind(int value) { + @Override + public void setKind(int value) { assertNotFrozen(); kind = value; } - public char[] getValue() { + @Override + public char[] getValue() { return value; } - public void setValue(char[] value) { + @Override + public void setValue(char[] value) { assertNotFrozen(); this.value= value; } @@ -100,7 +106,8 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx return true; } - public IType getExpressionType() { + @Override + public IType getExpressionType() { switch (getKind()) { case lk_this: { IScope scope = CPPVisitor.getContainingScope(this); @@ -127,10 +134,12 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION); } + @Override public boolean isLValue() { return getKind() == IASTLiteralExpression.lk_string_literal; } + @Override public ValueCategory getValueCategory() { return isLValue() ? ValueCategory.LVALUE : ValueCategory.PRVALUE; } @@ -231,7 +240,8 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx /** * @deprecated, use {@link #setValue(char[])}, instead. */ - @Deprecated + @Override + @Deprecated public void setValue(String value) { assertNotFrozen(); this.value = value.toCharArray(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java index 9a4d26cb47e..54dd18bef60 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon(IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Bryan Wilkinson (QNX) - * Anton Leherbauer (Wind River Systems) + * John Camelon(IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -45,10 +45,12 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte name = CharArrayUtils.EMPTY; } - public CPPASTName copy() { + @Override + public CPPASTName copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTName copy(CopyStyle style) { CPPASTName copy = new CPPASTName(name == null ? null : name.clone()); copy.setOffsetAndLength(this); @@ -78,6 +80,7 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte return null; } + @Override public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) { IASTNode parent = getParent(); if (parent instanceof ICPPASTElaboratedTypeSpecifier) { @@ -142,14 +145,17 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings); } - public char[] toCharArray() { + @Override + public char[] toCharArray() { return name; } - public char[] getSimpleID() { + @Override + public char[] getSimpleID() { return name; } + @Override public char[] getLookupKey() { return name; } @@ -185,6 +191,7 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte return true; } + @Override public IBinding[] findBindings(IASTName n, boolean isPrefix) { return findBindings(n, isPrefix, null); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java index 7fa03b047a4..f317d66b1f7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTParameterDeclaration.java @@ -37,14 +37,17 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame setDeclarator(declarator); } + @Override public boolean isParameterPack() { return fDeclarator != null && CPPVisitor.findInnermostDeclarator(fDeclarator).declaresParameterPack(); } + @Override public CPPASTParameterDeclaration copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTParameterDeclaration copy(CopyStyle style) { CPPASTParameterDeclaration copy = new CPPASTParameterDeclaration(); copy.setDeclSpecifier(fDeclSpec == null ? null : fDeclSpec.copy(style)); @@ -56,15 +59,18 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame return copy; } + @Override public IASTDeclSpecifier getDeclSpecifier() { return fDeclSpec; } - public ICPPASTDeclarator getDeclarator() { + @Override + public ICPPASTDeclarator getDeclarator() { return fDeclarator; } - public void setDeclSpecifier(IASTDeclSpecifier declSpec) { + @Override + public void setDeclSpecifier(IASTDeclSpecifier declSpec) { assertNotFrozen(); this.fDeclSpec = declSpec; if (declSpec != null) { @@ -73,7 +79,8 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame } } - public void setDeclarator(IASTDeclarator declarator) { + @Override + public void setDeclarator(IASTDeclarator declarator) { assertNotFrozen(); if (declarator instanceof ICPPASTDeclarator) { fDeclarator = (ICPPASTDeclarator) declarator; @@ -85,7 +92,7 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame } @Override - public boolean accept( ASTVisitor action ){ + public boolean accept(ASTVisitor action) { if (action.shouldVisitParameterDeclarations) { switch (action.visit((IASTParameterDeclaration) this)) { case ASTVisitor.PROCESS_ABORT: return false; @@ -105,7 +112,8 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame } return true; } - + + @Override public void replace(IASTNode child, IASTNode other) { if (child == fDeclarator) { other.setPropertyInParent(child.getPropertyInParent()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java index 4cb5929ce15..6ae39e11ae9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java @@ -57,7 +57,7 @@ public class CPPASTTemplateIDAmbiguity extends ASTAmbiguousNode implements IASTA } @Override - public IASTNode resolveAmbiguity(ASTVisitor resolver) { + protected final IASTNode doResolveAmbiguity(ASTVisitor resolver) { final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; @@ -77,10 +77,7 @@ public class CPPASTTemplateIDAmbiguity extends ASTAmbiguousNode implements IASTA // Setup the ast to use the alternative owner.replace(nodeToReplace, expression); - nodeToReplace= expression; - - // Handle nested ambiguities first - expression.accept(resolver); + nodeToReplace= resolveNestedAmbiguities(expression, resolver); int count= checkNames(templateNames); if (count > bestCount) { @@ -163,18 +160,22 @@ public class CPPASTTemplateIDAmbiguity extends ASTAmbiguousNode implements IASTA return fNodes; } + @Override public IASTExpression copy() { throw new UnsupportedOperationException(); } + @Override public IASTExpression copy(CopyStyle style) { throw new UnsupportedOperationException(); } + @Override public void addExpression(IASTExpression e) { throw new UnsupportedOperationException(); } + @Override public IASTExpression[] getExpressions() { throw new UnsupportedOperationException(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java index d27172e0038..4dd50a7d918 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ClassTypeHelper.java @@ -15,6 +15,10 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ARRAY; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -180,7 +184,7 @@ public class ClassTypeHelper { ICPPClassType backup= getBackupDefinition(host); if (backup != null) return backup.getBases(); - + return ICPPBase.EMPTY_BASE_ARRAY; } } @@ -203,7 +207,7 @@ public class ClassTypeHelper { ICPPClassType backup= getBackupDefinition(host); if (backup != null) return backup.getDeclaredFields(); - + return ICPPField.EMPTY_CPPFIELD_ARRAY; } } @@ -235,7 +239,7 @@ public class ClassTypeHelper { } return (ICPPField[]) ArrayUtil.trim(ICPPField.class, result); } - + /** * Returns all direct and indirect base classes. * @param classType a class @@ -248,7 +252,7 @@ public class ClassTypeHelper { result.remove(classType); return result.toArray(new ICPPClassType[result.size()]); } - + private static void getAllBases(ICPPClassType classType, HashSet result) { ICPPBase[] bases= classType.getBases(); for (ICPPBase base : bases) { @@ -291,10 +295,10 @@ public class ClassTypeHelper { } return (ICPPMethod[]) ArrayUtil.trim(ICPPMethod.class, methods); } - + public static ICPPMethod[] getMethods(ICPPClassType ct) { ObjectSet set = getOwnMethods(ct); - + ICPPClassType[] bases= getAllBases(ct); for (ICPPClassType base : bases) { set.addAll(base.getDeclaredMethods()); @@ -319,7 +323,7 @@ public class ClassTypeHelper { } return set; } - + public static ICPPMethod[] getDeclaredMethods(ICPPInternalClassTypeMixinHost host) { if (host.getDefinition() == null) { host.checkForDefinition(); @@ -393,7 +397,7 @@ public class ClassTypeHelper { ICPPClassType backup= getBackupDefinition(host); if (backup != null) return backup.getNestedClasses(); - + return ICPPClassType.EMPTY_CLASS_ARRAY; } } @@ -445,18 +449,17 @@ public class ClassTypeHelper { } return field; } - - + /** - * Returns whether {@code method} is virtual. This is the case if it is declared to be virtual or - * overrides another virtual method. + * Returns whether {@code method} is virtual. This is the case if it is declared to be virtual + * or overrides another virtual method. */ public static boolean isVirtual(ICPPMethod m) { if (m instanceof ICPPConstructor) return false; if (m.isVirtual()) return true; - + final char[] mname= m.getNameCharArray(); final ICPPClassType mcl= m.getClassOwner(); if (mcl != null) { @@ -511,18 +514,18 @@ public class ClassTypeHelper { return false; if (!functionTypesAllowOverride(source.getType(), target.getType())) return false; - + final ICPPClassType sourceClass= source.getClassOwner(); final ICPPClassType targetClass= target.getClassOwner(); if (sourceClass == null || targetClass == null) return false; - + ICPPClassType[] bases= getAllBases(sourceClass); for (ICPPClassType base : bases) { if (base.isSameType(targetClass)) return true; } - + return false; } @@ -532,12 +535,12 @@ public class ClassTypeHelper { public static ICPPMethod[] findOverridden(ICPPMethod method) { if (method instanceof ICPPConstructor) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; - + final char[] mname= method.getNameCharArray(); final ICPPClassType mcl= method.getClassOwner(); if (mcl == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; - + final ArrayList result= new ArrayList(); final HashMap virtualInClass= new HashMap(); final ICPPFunctionType mft= method.getType(); @@ -550,7 +553,7 @@ public class ClassTypeHelper { findOverridden((ICPPClassType) b, mname, mft, virtualInClass, result); } } - + // list is filled from most derived up to here, reverse it Collections.reverse(result); return result.toArray(new ICPPMethod[result.size()]); @@ -567,7 +570,7 @@ public class ClassTypeHelper { Boolean visitedBefore= virtualInClass.get(cl); if (visitedBefore != null) return visitedBefore; - + ICPPMethod[] methods= cl.getDeclaredMethods(); ICPPMethod candidate= null; boolean hasOverridden= false; @@ -578,7 +581,7 @@ public class ClassTypeHelper { break; } } - + // prevent recursion virtualInClass.put(cl, hasOverridden); ICPPBase[] bases= cl.getBases(); @@ -610,7 +613,7 @@ public class ClassTypeHelper { final ICPPClassType mcl= method.getClassOwner(); if (mcl == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; - + ICPPClassType[] subclasses= getSubClasses(index, mcl); return findOverriders(subclasses, method); } @@ -645,7 +648,7 @@ public class ClassTypeHelper { private static void getSubClasses(IIndex index, ICPPBinding classOrTypedef, List result, HashSet handled) throws CoreException { if (!(classOrTypedef instanceof IType)) return; - + final String key = ASTTypeUtil.getType((IType) classOrTypedef, true); if (!handled.add(key)) { return; @@ -674,7 +677,7 @@ public class ClassTypeHelper { private static final int KIND_ASSIGNMENT_OP= 2; private static final int KIND_DTOR= 3; private static final int KIND_OTHER= 4; - + /** * For implicit methods the exception specification is inherited, search it */ @@ -688,7 +691,7 @@ public class ClassTypeHelper { int kind= getImplicitMethodKind(owner, implicitMethod); if (kind == KIND_OTHER) return null; - + List inheritedTypeids = new ArrayList(); ICPPClassType[] bases= getAllBases(owner); for (ICPPClassType base : bases) { @@ -737,13 +740,13 @@ public class ClassTypeHelper { } return KIND_OTHER; } - return KIND_OTHER; + return KIND_OTHER; } private static boolean isRefToConstClass(ICPPClassType ct, IType t) { while (t instanceof ITypedef) t= ((ITypedef) t).getType(); - + if (t instanceof ICPPReferenceType) { t= ((ICPPReferenceType) t).getType(); while (t instanceof ITypedef) @@ -809,6 +812,126 @@ public class ClassTypeHelper { return true; } + /** + * Returns true if and only if the given class has a trivial copy constructor. + * A copy constructor is trivial if: + *
      + *
    • it is implicitly defined by the compiler, and
    • + *
    • isPolymorphic(classTarget) == false, and
    • + *
    • the class has no virtual base classes, and
    • + *
    • every direct base class has trivial copy constructor, and
    • + *
    • for every nonstatic data member that has class type or array of class type, that type + * has trivial copy constructor.
    • + *
    + * Similar to std::tr1::has_trivial_copy. + * + * @param classTarget the class to check + * @return true if the class has a trivial copy constructor + */ + public static boolean hasTrivialCopyCtor(ICPPClassType classTarget) { + if (getImplicitCopyCtor(classTarget) == null) + return false; + if (isPolymorphic(classTarget)) + return false; + for (ICPPBase base : classTarget.getBases()) { + if (base.isVirtual()) + return false; + } + for (ICPPClassType baseClass : getAllBases(classTarget)) { + if (!classTarget.isSameType(baseClass) && !hasTrivialCopyCtor(baseClass)) + return false; + } + for (ICPPField field : classTarget.getDeclaredFields()) { + if (!field.isStatic()) { + IType type = field.getType(); + type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY); + if (type instanceof ICPPClassType && !classTarget.isSameType(type) && + !hasTrivialCopyCtor((ICPPClassType) type)) { + return false; + } + } + } + return true; + } + + /** + * Returns the compiler-generated copy constructor for the given class, or null + * if the class doesn't have a compiler-generated copy constructor. + * + * @param classTarget the class to get the copy ctor for. + * @return the compiler-generated copy constructor, or null if the class doesn't + * have a compiler-generated copy constructor. + */ + private static ICPPConstructor getImplicitCopyCtor(ICPPClassType classTarget) { + for (ICPPConstructor ctor : classTarget.getConstructors()) { + if (ctor.isImplicit() && getImplicitMethodKind(classTarget, ctor) == KIND_COPY_CTOR) + return ctor; + } + return null; + } + + /** + * Returns true if and only if the given class has a trivial destructor. + * A destructor is trivial if: + *
      + *
    • it is implicitly defined by the compiler, and
    • + *
    • every direct base class has trivial destructor, and
    • + *
    • for every nonstatic data member that has class type or array of class type, that type + * has trivial destructor.
    • + *
    + * Similar to std::tr1::has_trivial_destructor. + * + * @param classTarget the class to check + * @return true if the class has a trivial destructor + */ + public static boolean hasTrivialDestructor(ICPPClassType classTarget) { + for (ICPPMethod method : classTarget.getDeclaredMethods()) { + if (method.isDestructor()) + return false; + } + for (ICPPClassType baseClass : getAllBases(classTarget)) { + if (!classTarget.isSameType(baseClass) && !hasTrivialDestructor(baseClass)) + return false; + } + for (ICPPField field : classTarget.getDeclaredFields()) { + if (!field.isStatic()) { + IType type = field.getType(); + type = SemanticUtil.getNestedType(type, TDEF | CVTYPE | ARRAY); + if (type instanceof ICPPClassType && !classTarget.isSameType(type) && + !hasTrivialDestructor((ICPPClassType) type)) { + return false; + } + } + } + return true; + } + + /** + * Returns true if and only if the given class declares or inherits a virtual + * function. Similar to std::tr1::is_polymorphic. + * + * @param classTarget the class to check + * @return true if the class declares or inherits a virtual function. + */ + public static boolean isPolymorphic(ICPPClassType classTarget) { + if (hasDeclaredVirtualMethod(classTarget)) + return true; + for (ICPPClassType baseClass : getAllBases(classTarget)) { + if (hasDeclaredVirtualMethod(baseClass)) + return true; + } + return false; + } + + private static boolean hasDeclaredVirtualMethod(ICPPClassType classTarget) { + for (ICPPMethod method : classTarget.getDeclaredMethods()) { + if (method.isVirtual()) { + return true; + } + } + return false; + } + /** * Checks whether class is abstract, i.e. has pure virtual functions that were * not implemented in base after declaration. @@ -820,7 +943,7 @@ public class ClassTypeHelper { public static ICPPMethod[] getPureVirtualMethods(ICPPClassType classType) { Map> result= collectPureVirtualMethods(classType, new HashMap>>()); - + int resultArraySize = 0; for (List methods : result.values()) { resultArraySize += methods.size(); @@ -837,14 +960,13 @@ public class ClassTypeHelper { private static Map> collectPureVirtualMethods(ICPPClassType classType, Map>> cache) { - Map> result = cache.get(classType); if (result != null) return result; - + result= new HashMap>(); cache.put(classType, result); - + // Look at the pure virtual methods of the base classes Set handledBaseClasses= new HashSet(); for (ICPPBase base : classType.getBases()) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java index 638108f78a5..7d7b5b74e5f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite; @@ -31,10 +31,12 @@ public class ASTLiteralNode implements IASTNode { fCode= code; } + @Override public String getRawSignature() { return fCode; } + @Override public boolean accept(ASTVisitor visitor) { if (visitor instanceof ASTWriterVisitor) { ((ASTWriterVisitor) visitor).visit(this); @@ -42,72 +44,90 @@ public class ASTLiteralNode implements IASTNode { return true; } + @Override public boolean contains(IASTNode node) { return false; } + @Override public String getContainingFilename() { return null; } + @Override public IASTFileLocation getFileLocation() { return null; } + @Override public IASTNodeLocation[] getNodeLocations() { return null; } + @Override public IASTNode getParent() { return null; } + @Override public IASTNode[] getChildren() { return IASTNode.EMPTY_NODE_ARRAY; } + @Override public ASTNodeProperty getPropertyInParent() { return null; } + @Override public IASTTranslationUnit getTranslationUnit() { return null; } + @Override public boolean isPartOfTranslationUnitFile() { return false; } + @Override public void setParent(IASTNode node) { } + @Override public void setPropertyInParent(ASTNodeProperty property) { } + @Override public IToken getSyntax() { throw new UnsupportedOperationException(); } + @Override public IToken getLeadingSyntax() { throw new UnsupportedOperationException(); } + @Override public IToken getTrailingSyntax() { throw new UnsupportedOperationException(); } + @Override public boolean isFrozen() { return false; } + @Override public IASTNode copy() { throw new UnsupportedOperationException(); } + @Override public IASTNode copy(CopyStyle style) { throw new UnsupportedOperationException(); } + @Override public boolean isActive() { return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java index 3b249519953..ee4c9d86257 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java @@ -6,15 +6,15 @@ * 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.internal.core.dom.rewrite; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; @@ -51,35 +51,23 @@ import org.eclipse.cdt.core.dom.rewrite.DeclarationGenerator; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** - * * @author Tomasz Wesolowski - * */ public class DeclarationGeneratorImpl extends DeclarationGenerator { - private INodeFactory factory; /** * Creates a new generator using the given factory. * - * @param factory - * a factory to use. If a C++ type is requested, it has to be an instance of - * {@link ICPPNodeFactory}. + * @param factory The factory to use. If a C++ type is requested, it has to be an instance of + * {@link ICPPNodeFactory}. */ public DeclarationGeneratorImpl(INodeFactory factory) { this.factory = factory; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.cdt.core.dom.rewrite.IDeclarationGenerator#createDeclSpecFromType(org.eclipse.cdt.core. - * dom.ast.IType) - */ @Override public IASTDeclSpecifier createDeclSpecFromType(IType type) { - IASTDeclSpecifier returnedDeclSpec = null; if (type instanceof IPointerType) { @@ -133,20 +121,11 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { return returnedDeclSpec; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.cdt.core.dom.rewrite.IDeclarationGenerator#createDeclaratorFromType(org.eclipse.cdt.core - * .dom.ast.IType, char[]) - */ @Override public IASTDeclarator createDeclaratorFromType(IType type, char[] name) { - IASTDeclarator returnedDeclarator = null; try { - // Addition of pointer operators has to be in reverse order, so it's deferred until the end Map> pointerOperatorMap = new HashMap>(); @@ -225,9 +204,8 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { } finalizePointerOperators(pointerOperatorMap); - } catch (DOMException e) { - e.printStackTrace(); + CCorePlugin.log(e); } // Fallback @@ -273,7 +251,7 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { if (type instanceof ICPPPointerToMemberType) { String classStr = ASTTypeUtil.getType(((ICPPPointerToMemberType) type).getMemberOfClass()); IASTName newName = factory.newName((classStr + "::").toCharArray()); //$NON-NLS-1$ - // any better way of getting class name from ICPPPointerToMemberType? + // Any better way of getting class name from ICPPPointerToMemberType? ICPPASTPointerToMember member = ((ICPPNodeFactory) factory).newPointerToMember(newName); member.setConst(((ICPPPointerToMemberType) type).isConst()); @@ -286,8 +264,8 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { return pointer; } else { ICPPReferenceType refType = (ICPPReferenceType) type; - ICPPASTReferenceOperator op = ((ICPPNodeFactory) factory).newReferenceOperator(refType - .isRValueReference()); + ICPPASTReferenceOperator op = + ((ICPPNodeFactory) factory).newReferenceOperator(refType.isRValueReference()); return op; } } @@ -303,14 +281,13 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { private IASTDeclSpecifier getDeclSpecForTemplate(ICPPTemplateInstance type) { IASTName name = getName(type); if (factory instanceof ICPPNodeFactory) { - if (name instanceof ICPPASTQualifiedName) { ICPPASTQualifiedName fullQualifiedName = (ICPPASTQualifiedName) name; IASTName templateName = fullQualifiedName.getLastName(); ICPPASTTemplateId tempId = getTemplateId(type, templateName); - ICPPASTQualifiedName newQualifiedName = ((ICPPNodeFactory) factory) - .newQualifiedName(); + ICPPASTQualifiedName newQualifiedName = + ((ICPPNodeFactory) factory).newQualifiedName(); int nbQualifiedNames = fullQualifiedName.getNames().length; if (nbQualifiedNames > 1) { for (int i = 0; i < nbQualifiedNames - 1; i++) { @@ -320,7 +297,6 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { newQualifiedName.addName(tempId); return factory.newTypedefNameSpecifier(newQualifiedName); - } else { IASTName templateName = getName(type); ICPPASTTemplateId tempId = getTemplateId(type, templateName); @@ -352,12 +328,10 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { char[][] qualifiedNameCharArray = CPPVisitor.getQualifiedNameCharArray(binding); IASTName name; if (qualifiedNameCharArray.length > 1) { - name = ((ICPPNodeFactory) factory).newQualifiedName(); for (char[] cs : qualifiedNameCharArray) { ((ICPPASTQualifiedName) name).addName(factory.newName(cs)); } - } else if (qualifiedNameCharArray.length == 1) { name = factory.newName(qualifiedNameCharArray[0]); } else { @@ -365,5 +339,4 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator { } return name; } - } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java index d31331325c4..d92ade75747 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java @@ -30,9 +30,7 @@ public class TrackedNodePosition implements ITrackedNodePosition { this.node= node; } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.corext.dom.ITrackedNodePosition#getStartPosition() - */ + @Override public int getStartPosition() { if (this.group.isEmpty()) { return this.node.getOffset(); @@ -44,9 +42,7 @@ public class TrackedNodePosition implements ITrackedNodePosition { return coverage.getOffset(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.corext.dom.ITrackedNodePosition#getLength() - */ + @Override public int getLength() { if (this.group.isEmpty()) { return this.node.getLength(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java index 701cfdb6b92..5b7229e5de9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java @@ -8,10 +8,19 @@ * * Contributors: * Institute for Software - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; +import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; +import org.eclipse.cdt.core.dom.ast.IASTIfStatement; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTStatement; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore; import org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.ChangeGeneratorWriterVisitor; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.ASTCommenter; @@ -19,14 +28,11 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; /** * ASTWriter main class. Generates source code from IASTNode. - * Uses a hangeGeneratorWriterVisitor to generate the code for the given nodes. - * - * @see ChangeGeneratorWriterVisitor + * Uses a {@link ChangeGeneratorWriterVisitor} to generate the code for the given nodes. * * @author Emanuel Graf */ public class ASTWriter { - private ChangeGeneratorWriterVisitor transformationVisitor; private ASTModificationStore modificationStore = new ASTModificationStore(); private String givenIndentation = ""; //$NON-NLS-1$ @@ -55,18 +61,13 @@ public class ASTWriter { * @throws ProblemRuntimeException if the node or one of it's children is a IASTProblemNode. */ public String write(IASTNode rootNode) throws ProblemRuntimeException { - return write(rootNode, null, new NodeCommentMap()); - } - - public String write(IASTNode rootNode, NodeCommentMap commentMap) { - return write(rootNode, null, commentMap); + return write(rootNode, new NodeCommentMap()); } /** * Generates the source code representing this node including comments. * * @param rootNode Node to write. - * @param fileScope * @param commentMap Node Comment Map ASTCommenter * @return A String representing the source code for the node. * @throws ProblemRuntimeException if the node or one of it's children is @@ -74,19 +75,95 @@ public class ASTWriter { * * @see ASTCommenter#getCommentedNodeMap(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit) */ - public String write(IASTNode rootNode, String fileScope, NodeCommentMap commentMap) + public String write(IASTNode rootNode, NodeCommentMap commentMap) throws ProblemRuntimeException { - transformationVisitor = new ChangeGeneratorWriterVisitor(modificationStore, givenIndentation, - fileScope, commentMap); + ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor( + modificationStore, givenIndentation, null, commentMap); if (rootNode != null) { - rootNode.accept(transformationVisitor); + rootNode.accept(writer); } - String str = transformationVisitor.toString(); - transformationVisitor.cleanCache(); - return str; + return writer.toString(); } public void setModificationStore(ASTModificationStore modificationStore) { this.modificationStore = modificationStore; } + + /** + * Returns true if the node should be separated by a blank line from the node + * before it. + * + * @param node The node. + * @return true if the node should be separated by a blank line from the node + * before it. + */ + public static boolean requiresLeadingBlankLine(IASTNode node) { + if (node instanceof ICPPASTTemplateDeclaration) { + node = ((ICPPASTTemplateDeclaration) node).getDeclaration(); + } + return node instanceof IASTASMDeclaration || + node instanceof IASTFunctionDefinition || + node instanceof ICPPASTVisibilityLabel; + } + + /** + * Returns true if the node should be separated by a blank line from the node + * after it. + * + * @param node The node. + * @return true if the node should be separated by a blank line from the node + * after it. + */ + public static boolean requiresTrailingBlankLine(IASTNode node) { + if (node instanceof ICPPASTNamespaceDefinition) + return true; + if (node instanceof IASTFunctionDefinition) + return true; + if (node instanceof IASTIfStatement) { + IASTIfStatement statement = ((IASTIfStatement) node); + IASTStatement lastClause = statement.getElseClause(); + if (lastClause == null) + lastClause = statement.getThenClause(); + + if (!(lastClause instanceof IASTCompoundStatement) && + !doNodesHaveSameOffset(lastClause, statement)) { + return true; + } + } + return false; + } + + /** + * Returns true if there should be no blank line after this node even if a blank + * line is normally required before the subsequent node. + * + * @param node The node. + * @return true if there should be no blank line after this node. + */ + public static boolean suppressesTrailingBlankLine(IASTNode node) { + return node instanceof ICPPASTVisibilityLabel; + } + + /** + * Returns true if the two given nodes should be separated by a blank line. + * + * @param node1 The first node. + * @param node2 The second node. + * @return true if the blank line between the nodes is needed. + */ + public static boolean requireBlankLineInBetween(IASTNode node1, IASTNode node2) { + if (requiresTrailingBlankLine(node1)) + return true; + + return !suppressesTrailingBlankLine(node1) && requiresLeadingBlankLine(node2); + } + + /** + * Returns true if the two given nodes have the same offset. For nodes that are normally + * separated by other tokens this is an indication that they were produced by the same macro + * expansion. + */ + private static boolean doNodesHaveSameOffset(IASTNode node1, IASTNode node2) { + return node1.getFileLocation().getNodeOffset() == node2.getFileLocation().getNodeOffset(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java index 553d8907c64..16f9325785f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java @@ -9,6 +9,7 @@ * Contributors: * Institute for Software - initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; @@ -38,15 +39,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; /** * Visits all nodes, prints leading comments and handles macro expansions. The - * source code generation is delegated to severals NodeWriters. + * source code generation is delegated to severals {@code NodeWriter}s. * - * @see NodeWriter * @see MacroExpansionHandler * * @author Emanuel Graf IFS */ public class ASTWriterVisitor extends ASTVisitor { - protected Scribe scribe = new Scribe(); + protected final Scribe scribe = new Scribe(); protected NodeCommentMap commentMap; protected ExpressionWriter expWriter; protected DeclSpecWriter declSpecWriter; @@ -57,6 +57,9 @@ public class ASTWriterVisitor extends ASTVisitor { protected NameWriter nameWriter; protected TemplateParameterWriter tempParameterWriter; protected MacroExpansionHandler macroHandler; + private boolean insertLeadingBlankLine; + private boolean suppressLeadingBlankLine; + private boolean spaceNeededBeforeName; { shouldVisitExpressions = true; @@ -83,6 +86,7 @@ public class ASTWriterVisitor extends ASTVisitor { scribe.setGivenIndentation(givenIndentation); init(commentMap); this.commentMap = commentMap; + this.suppressLeadingBlankLine = true; } private void init(NodeCommentMap commentMap) { @@ -135,6 +139,10 @@ public class ASTWriterVisitor extends ASTVisitor { @Override public int visit(IASTName name) { + if (spaceNeededBeforeName && name.getSimpleID().length != 0) { + scribe.printSpace(); + spaceNeededBeforeName = false; + } writeLeadingComments(name); if (!macroHandler.checkisMacroExpansionNode(name)) { nameWriter.writeName(name); @@ -166,24 +174,31 @@ public class ASTWriterVisitor extends ASTVisitor { @Override public int visit(IASTStatement statement) { + insertBlankLineIfNeeded(statement); writeLeadingComments(statement); - if (macroHandler.isStatementWithMixedLocation(statement) && - !(statement instanceof IASTCompoundStatement)) { - return statementWriter.writeMixedStatement(statement); + try { + if (macroHandler.isStatementWithMixedLocation(statement) && + !(statement instanceof IASTCompoundStatement)) { + return statementWriter.writeMixedStatement(statement); + } + if (macroHandler.checkisMacroExpansionNode(statement)) { + return ASTVisitor.PROCESS_SKIP; + } + return statementWriter.writeStatement(statement, true); + } finally { + setLeadingBlankLineFlags(statement); } - if (macroHandler.checkisMacroExpansionNode(statement)) { - return ASTVisitor.PROCESS_SKIP; - } - return statementWriter.writeStatement(statement, true); } @Override public int visit(IASTDeclaration declaration) { + insertBlankLineIfNeeded(declaration); writeLeadingComments(declaration); if (!macroHandler.checkisMacroExpansionNode(declaration)) { declarationWriter.writeDeclaration(declaration); + setLeadingBlankLineFlags(declaration); } - return ASTVisitor.PROCESS_SKIP; + return ASTVisitor.PROCESS_SKIP; } @Override @@ -219,9 +234,7 @@ public class ASTWriterVisitor extends ASTVisitor { parameterDeclaration.getDeclSpecifier().accept(this); IASTDeclarator declarator = getParameterDeclarator(parameterDeclaration); - if (getParameterName(declarator).toString().length() != 0) { - scribe.printSpaces(1); - } + spaceNeededBeforeName = true; declarator.accept(this); } return ASTVisitor.PROCESS_SKIP; @@ -237,9 +250,11 @@ public class ASTWriterVisitor extends ASTVisitor { @Override public int visit(ICPPASTNamespaceDefinition namespace) { + insertBlankLineIfNeeded(namespace); writeLeadingComments(namespace); if (!macroHandler.checkisMacroExpansionNode(namespace)) { declarationWriter.writeDeclaration(namespace); + setLeadingBlankLineFlags(namespace); } return ASTVisitor.PROCESS_SKIP; } @@ -257,4 +272,38 @@ public class ASTWriterVisitor extends ASTVisitor { scribe.cleanCache(); macroHandler.reset(); } + + private void insertBlankLineIfNeeded(IASTNode node) { + if (!suppressLeadingBlankLine && + (insertLeadingBlankLine || ASTWriter.requiresLeadingBlankLine(node))) { + scribe.newLine(); + } + insertLeadingBlankLine = false; + suppressLeadingBlankLine = false; + } + + private void setLeadingBlankLineFlags(IASTNode node) { + insertLeadingBlankLine = ASTWriter.requiresTrailingBlankLine(node); + suppressLeadingBlankLine = ASTWriter.suppressesTrailingBlankLine(node); + } + + public boolean isSuppressLeadingBlankLine() { + return suppressLeadingBlankLine; + } + + public void setSuppressLeadingBlankLine(boolean value) { + this.suppressLeadingBlankLine = value; + } + + public boolean isSpaceNeededBeforeName() { + return spaceNeededBeforeName; + } + + public void setSpaceNeededBeforeName(boolean value) { + this.spaceNeededBeforeName = value; + } + + public void newLine() { + scribe.newLine(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java index a9cfdeee41b..f32f3a57262 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java @@ -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.internal.core.dom.rewrite.astwriter; @@ -20,18 +20,14 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; - /** - * - * This class serves as a container to pass several nodes to the - * ASTWriter. This container is used if source code for several sibling nodes but - * for their common parent node should be generated. + * This class serves as a container to pass several nodes to the ASTWriter. + * This container is used if source code for several sibling nodes but for their common parent + * node should be generated. * * @author Emanuel Graf IFS - * */ public class ContainerNode extends ASTNode { - private final IASTTranslationUnit tu = null; private final ArrayList nodes = new ArrayList(); @@ -42,10 +38,12 @@ public class ContainerNode extends ASTNode { } } + @Override public ContainerNode copy() { return copy(CopyStyle.withoutLocations); } + @Override public ContainerNode copy(CopyStyle style) { ContainerNode copy = new ContainerNode(); for (IASTNode node : getNodes()) @@ -59,7 +57,7 @@ public class ContainerNode extends ASTNode { public void addNode(IASTNode node) { nodes.add(node); - if(node.getParent() == null) { + if (node.getParent() == null) { node.setParent(tu); } } @@ -80,5 +78,4 @@ public class ContainerNode extends ASTNode { public List getNodes(){ return Collections.unmodifiableList(nodes); } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java index d643b8a317d..ba7fb2e8623 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclSpecWriter.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -62,12 +61,12 @@ public class DeclSpecWriter extends NodeWriter { private static final String ENUM = "enum "; //$NON-NLS-1$ private static final String _BOOL = "_Bool"; //$NON-NLS-1$ - public DeclSpecWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); } protected void writeDelcSpec(IASTDeclSpecifier declSpec) { -// Write general DelcSpec Keywords + // Write general DelcSpec Keywords writeDeclSpec(declSpec); if (declSpec instanceof ICPPASTDeclSpecifier) { writeCPPDeclSpec((ICPPASTDeclSpecifier) declSpec); @@ -129,7 +128,6 @@ public class DeclSpecWriter extends NodeWriter { break; } - System.err.println("Unknown specifier type: " + type); //$NON-NLS-1$ throw new IllegalArgumentException("Unknown specifier type: " + type); //$NON-NLS-1$ } @@ -152,7 +150,7 @@ public class DeclSpecWriter extends NodeWriter { } private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) { - if ( namedSpc.isTypename() ){ + if (namedSpc.isTypename()) { scribe.print(TYPENAME); } namedSpc.getName().accept(visitor); @@ -168,7 +166,7 @@ public class DeclSpecWriter extends NodeWriter { } private String getElabTypeString(int kind) { - switch(kind) { + switch (kind) { case IASTElaboratedTypeSpecifier.k_enum: return ENUM; case IASTElaboratedTypeSpecifier.k_struct: @@ -179,8 +177,7 @@ public class DeclSpecWriter extends NodeWriter { return CLASS_SPACE; default: - System.err.println("Unknown ElaboratedType: " + kind); //$NON-NLS-1$ - throw new IllegalArgumentException("Unknown ElaboratedType: " + kind); //$NON-NLS-1$ + throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$ } } @@ -217,14 +214,13 @@ public class DeclSpecWriter extends NodeWriter { scribe.print('{'); scribe.printSpace(); IASTEnumerator[] enums = enumSpec.getEnumerators(); - for (int i = 0; i< enums.length;++i) { + for (int i = 0; i < enums.length; ++i) { writeEnumerator(enums[i]); - if (i+1< enums.length) { + if (i + 1 < enums.length) { scribe.print(NodeWriter.COMMA_SPACE); } } scribe.print('}'); - } private void writeEnumerator(IASTEnumerator enumerator) { @@ -246,21 +242,22 @@ public class DeclSpecWriter extends NodeWriter { ICPPASTBaseSpecifier[] baseSpecifiers = cppComp.getBaseSpecifiers(); if (baseSpecifiers.length > 0) { scribe.print(SPACE_COLON_SPACE); - for (int i = 0; i < baseSpecifiers.length;++i) { + for (int i = 0; i < baseSpecifiers.length; ++i) { writeBaseSpecifiers(baseSpecifiers[i]); - if (i+1 < baseSpecifiers.length) { + if (i + 1 < baseSpecifiers.length) { scribe.print(COMMA_SPACE); } } hasTrailingComments = hasTrailingComments(baseSpecifiers[baseSpecifiers.length-1].getName()); } } - if (!hasTrailingComments){ + if (!hasTrailingComments) { scribe.newLine(); } scribe.print('{'); scribe.newLine(); scribe.incrementIndentationLevel(); + visitor.setSuppressLeadingBlankLine(true); IASTDeclaration[] decls = getMembers(compDeclSpec); if (decls.length > 0) { @@ -285,7 +282,7 @@ public class DeclSpecWriter extends NodeWriter { } private void writeBaseSpecifiers(ICPPASTBaseSpecifier specifier) { - switch(specifier.getVisibility()) { + switch (specifier.getVisibility()) { case ICPPASTBaseSpecifier.v_public: scribe.printStringSpace(PUBLIC); break; @@ -307,8 +304,7 @@ public class DeclSpecWriter extends NodeWriter { case ICPPASTCompositeTypeSpecifier.k_class: return CLASS; default: - System.err.println("Unknow Specifiertype: " + key); //$NON-NLS-1$ - throw new IllegalArgumentException("Unknow Specifiertype: " + key); //$NON-NLS-1$ + throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$ } } @@ -319,8 +315,7 @@ public class DeclSpecWriter extends NodeWriter { case IASTCompositeTypeSpecifier.k_union: return UNION; default: - System.err.println("Unknow Specifiertype: " + key); //$NON-NLS-1$ - throw new IllegalArgumentException("Unknow Specifiertype: " + key); //$NON-NLS-1$ + throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$ } } @@ -328,7 +323,7 @@ public class DeclSpecWriter extends NodeWriter { if (declSpec.isInline()) { scribe.print(INLINE); } - switch(declSpec.getStorageClass()) { + switch (declSpec.getStorageClass()) { case IASTDeclSpecifier.sc_typedef: scribe.print(TYPEDEF); break; @@ -369,7 +364,7 @@ public class DeclSpecWriter extends NodeWriter { private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) { if (simpDeclSpec.isSigned()) { scribe.printStringSpace(SIGNED); - } else if (simpDeclSpec.isUnsigned()){ + } else if (simpDeclSpec.isUnsigned()) { scribe.printStringSpace(UNSIGNED); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java index 6976f5fcf65..41ed66fc643 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclarationWriter.java @@ -9,10 +9,10 @@ * Contributors: * Institute for Software - initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -47,7 +47,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; * @see IASTDeclaration * @author Emanuel Graf IFS */ -public class DeclarationWriter extends NodeWriter{ +public class DeclarationWriter extends NodeWriter { private static final String ASM_END = ")"; //$NON-NLS-1$ private static final String ASM_START = "asm("; //$NON-NLS-1$ private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$ @@ -57,7 +57,7 @@ public class DeclarationWriter extends NodeWriter{ private static final String USING = "using "; //$NON-NLS-1$ private boolean printSemicolon; - public DeclarationWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); } @@ -72,6 +72,7 @@ public class DeclarationWriter extends NodeWriter{ writeASMDeclatation((IASTASMDeclaration) declaration); } else if (declaration instanceof IASTFunctionDefinition) { writeFunctionDefinition((IASTFunctionDefinition) declaration); + addNewLine = false; } else if (declaration instanceof IASTProblemDeclaration) { throw new ProblemRuntimeException((IASTProblemDeclaration) declaration); } else if (declaration instanceof IASTSimpleDeclaration) { @@ -98,17 +99,17 @@ public class DeclarationWriter extends NodeWriter{ } if (hasTrailingComments(declaration)) { - writeTrailingComments(declaration, addNewLine); - } else if (addNewLine) { + writeTrailingComments(declaration, false); + } + if (addNewLine) { scribe.newLine(); } if (hasFreestandingComments(declaration)) { + if (declaration instanceof IASTFunctionDefinition) { + scribe.newLine(); + } writeFreeStandingComments(declaration); } - - if (declaration instanceof ICPPASTUsingDirective) { - scribe.newLine(); - } } private void writeVisibilityLabel(ICPPASTVisibilityLabel visiblityLabel) { @@ -181,17 +182,18 @@ public class DeclarationWriter extends NodeWriter{ if (!hasTrailingComments(namespaceDefinition.getName())) { scribe.newLine(); } - scribe.printLBrace(); - scribe.newLine(); + scribe.print('{'); + scribe.newLine(2); writeDeclarationsInNamespace(namespaceDefinition, namespaceDefinition.getDeclarations()); if (hasFreestandingComments(namespaceDefinition)) { writeFreeStandingComments(namespaceDefinition); } - scribe.printRBrace(); + scribe.newLine(); + scribe.print('}'); if (hasTrailingComments(namespaceDefinition)) { writeTrailingComments(namespaceDefinition); - }else{ + } else { scribe.newLine(); } } @@ -211,7 +213,7 @@ public class DeclarationWriter extends NodeWriter{ } private void writeLinkageSpecification(ICPPASTLinkageSpecification linkageSpecification) { - scribe.print( EXTERN); + scribe.print(EXTERN); scribe.print(linkageSpecification.getLiteral()); scribe.printSpaces(1); @@ -266,10 +268,10 @@ public class DeclarationWriter extends NodeWriter{ if (declSpecifier instanceof IASTSimpleDeclSpecifier) { IASTSimpleDeclSpecifier simDeclSpec = (IASTSimpleDeclSpecifier) declSpecifier; if (simDeclSpec.getType() != IASTSimpleDeclSpecifier.t_unspecified) { - scribe.printSpace(); + visitor.setSpaceNeededBeforeName(true); } - }else { - scribe.printSpace(); + } else { + visitor.setSpaceNeededBeforeName(true); } IASTDeclarator declarator = ASTQueries.findOutermostDeclarator(funcDef.getDeclarator()); declarator.accept(visitor); @@ -325,10 +327,16 @@ public class DeclarationWriter extends NodeWriter{ } if (decls.length > 0) { - if (!noSpace) { - scribe.printSpace(); + if (decls.length == 1) { + if (!noSpace) + visitor.setSpaceNeededBeforeName(true); + decls[0].accept(visitor); + } else { + if (!noSpace) { + scribe.printSpace(); + } + writeNodeList(decls); } - writeNodeList(decls); } printSemicolon(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java index 53c2655397c..4a9a8af3852 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/DeclaratorWriter.java @@ -7,12 +7,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation - * Markus Schorn (Wind River Systems) + * Institute for Software - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; -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.IASTDeclaration; @@ -32,44 +31,38 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; - /** - * * Generates source code of declarator nodes. The actual string operations are delegated - * to the Scribe class. + * to the {@link Scribe} class. * - * @see Scribe * @see IASTDeclarator * @author Emanuel Graf IFS - * */ public class DeclaratorWriter extends NodeWriter { - - private static final String AMPERSAND_SPACE = "& "; //$NON-NLS-1$ - private static final String AMPERSAND__AMPERSAND_SPACE = "&& "; //$NON-NLS-1$ - private static final String STAR_SPACE = "* "; //$NON-NLS-1$ - private static final String PURE_VIRTUAL = " =0"; //$NON-NLS-1$ + private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$ + private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$ private static final String MUTABLE = "mutable"; //$NON-NLS-1$ private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$ - public DeclaratorWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); } protected void writeDeclarator(IASTDeclarator declarator) { if (declarator instanceof IASTStandardFunctionDeclarator) { writeFunctionDeclarator((IASTStandardFunctionDeclarator) declarator); - }else if (declarator instanceof IASTArrayDeclarator) { + } else if (declarator instanceof IASTArrayDeclarator) { writeArrayDeclarator((IASTArrayDeclarator) declarator); - }else if (declarator instanceof IASTFieldDeclarator) { + } else if (declarator instanceof IASTFieldDeclarator) { writeFieldDeclarator((IASTFieldDeclarator) declarator); - }else if (declarator instanceof ICASTKnRFunctionDeclarator) { + } else if (declarator instanceof ICASTKnRFunctionDeclarator) { writeCKnRFunctionDeclarator((ICASTKnRFunctionDeclarator) declarator); - }else{ + } else { writeDefaultDeclarator(declarator); } - - if(hasTrailingComments(declarator)) { + + visitor.setSpaceNeededBeforeName(false); + if (hasTrailingComments(declarator)) { writeTrailingComments(declarator, false); } } @@ -81,7 +74,7 @@ public class DeclaratorWriter extends NodeWriter { name.accept(visitor); writeNestedDeclarator(declarator); IASTInitializer init = getInitializer(declarator); - if(init!= null) { + if (init != null) { init.accept(visitor); } } @@ -109,7 +102,7 @@ public class DeclaratorWriter extends NodeWriter { private void writeInitializer(IASTStandardFunctionDeclarator funcDec) { IASTInitializer init = getInitializer(funcDec); - if(init != null) { + if (init != null) { init.accept(visitor); } } @@ -123,7 +116,11 @@ public class DeclaratorWriter extends NodeWriter { private void writeNestedDeclarator(IASTDeclarator funcDec) { IASTDeclarator nestedDeclarator = funcDec.getNestedDeclarator(); - if(nestedDeclarator != null) { + if (nestedDeclarator != null) { + if (visitor.isSpaceNeededBeforeName()) { + scribe.printSpace(); + visitor.setSpaceNeededBeforeName(false); + } scribe.print('('); nestedDeclarator.accept(visitor); scribe.print(')'); @@ -143,7 +140,7 @@ public class DeclaratorWriter extends NodeWriter { scribe.printSpace(); scribe.print(MUTABLE); } - if(funcDec.isPureVirtual()) { + if (funcDec.isPureVirtual()) { scribe.print(PURE_VIRTUAL); } writeExceptionSpecification(funcDec, funcDec.getExceptionSpecification()); @@ -165,10 +162,10 @@ public class DeclaratorWriter extends NodeWriter { } } - protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec, IASTParameterDeclaration[] paraDecls) { - writeNodeList(paraDecls); - if(funcDec.takesVarArgs()){ - if(paraDecls.length > 0){ + protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec, IASTParameterDeclaration[] paramDecls) { + writeNodeList(paramDecls); + if (funcDec.takesVarArgs()) { + if (paramDecls.length > 0) { scribe.print(COMMA_SPACE); } scribe.print(VAR_ARGS); @@ -178,15 +175,14 @@ public class DeclaratorWriter extends NodeWriter { private void writePointer(IASTPointer operator) { if (operator instanceof ICPPASTPointerToMember) { ICPPASTPointerToMember pointerToMemberOp = (ICPPASTPointerToMember) operator; - if(pointerToMemberOp.getName() != null){ + if (pointerToMemberOp.getName() != null) { pointerToMemberOp.getName().accept(visitor); - scribe.print(STAR_SPACE); + scribe.print('*'); } } else { scribe.print('*'); } - - + if (operator.isConst()) { scribe.printStringSpace(CONST); } @@ -204,9 +200,9 @@ public class DeclaratorWriter extends NodeWriter { writePointer(pointOp); } else if (operator instanceof ICPPASTReferenceOperator) { if (((ICPPASTReferenceOperator) operator).isRValueReference()) { - scribe.print(AMPERSAND__AMPERSAND_SPACE); + scribe.print(AMPERSAND_AMPERSAND); } else { - scribe.print(AMPERSAND_SPACE); + scribe.print('&'); } } } @@ -222,7 +218,7 @@ public class DeclaratorWriter extends NodeWriter { IASTArrayModifier[] arrMods = arrDecl.getArrayModifiers(); writeArrayModifiers(arrDecl, arrMods); IASTInitializer initializer = getInitializer(arrDecl); - if(initializer != null) { + if (initializer != null) { initializer.accept(visitor); } } @@ -255,7 +251,7 @@ public class DeclaratorWriter extends NodeWriter { scribe.printSpace(); fieldDecl.getBitFieldSize().accept(visitor); IASTInitializer initializer = getInitializer(fieldDecl); - if(initializer != null) { + if (initializer != null) { initializer.accept(visitor); } } @@ -267,17 +263,15 @@ public class DeclaratorWriter extends NodeWriter { scribe.print(')'); scribe.newLine(); writeKnRParameterDeclarations(knrFunct, knrFunct.getParameterDeclarations()); - - } - protected void writeKnRParameterDeclarations( - ICASTKnRFunctionDeclarator knrFunct, IASTDeclaration[] knrDeclarations) { + protected void writeKnRParameterDeclarations(ICASTKnRFunctionDeclarator knrFunct, + IASTDeclaration[] knrDeclarations) { for (int i = 0; i < knrDeclarations.length; ++i) { scribe.noNewLines(); knrDeclarations[i].accept(visitor); scribe.newLines(); - if(i + 1 < knrDeclarations.length) { + if (i + 1 < knrDeclarations.length) { scribe.newLine(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java index 8676cae0268..150f6c74545 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ExpressionWriter.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.IASTCastExpression; @@ -115,7 +114,7 @@ public class ExpressionWriter extends NodeWriter{ private static final String THIS = "this"; //$NON-NLS-1$ private final MacroExpansionHandler macroHandler; - public ExpressionWriter(Scribe scribe, ASTVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) { + public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); this.macroHandler = macroHandler; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java index 37aaff78c0a..7adc8fdce86 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/InitializerWriter.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; @@ -36,7 +35,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; */ public class InitializerWriter extends NodeWriter{ - public InitializerWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public InitializerWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/MacroExpansionHandler.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/MacroExpansionHandler.java index 798ef269639..1a6910dfea6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/MacroExpansionHandler.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/MacroExpansionHandler.java @@ -134,14 +134,13 @@ public class MacroExpansionHandler { PDOMMacroReferenceName mName = (PDOMMacroReferenceName) iIndexName; int eOff = mName.getFileLocation().getNodeOffset(); int eLength = mName.getFileLocation().getNodeLength(); - if (eOff < nOff && Math.abs((eOff+eLength-nOff)) < 3) { + if (eOff < nOff && Math.abs((eOff + eLength - nOff)) < 3) { scribe.print(mName.toString() + " "); //$NON-NLS-1$ } } } } } - } private IASTFileLocation getFileLocation(IASTNode node) { @@ -180,7 +179,7 @@ public class MacroExpansionHandler { IIndexName[] refs = index.findReferences(macroBinding[0]); for (IIndexName iIndexName : refs) { String filename2 = iIndexName.getFileLocation().getFileName(); - ListfileList = macroExpansion.get(filename2); + List fileList = macroExpansion.get(filename2); if (paths.contains(filename2)) { if (fileList == null) { fileList = new ArrayList(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java index c5c2a05f1af..941931511cd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java @@ -7,11 +7,10 @@ * 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.internal.core.dom.rewrite.astwriter; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -36,7 +35,7 @@ public class NameWriter extends NodeWriter { * @param scribe * @param visitor */ - public NameWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public NameWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); } @@ -45,7 +44,7 @@ public class NameWriter extends NodeWriter { writeTempalteId((ICPPASTTemplateId) name); } else if (name instanceof ICPPASTConversionName) { scribe.print(OPERATOR); - ((ICPPASTConversionName)name).getTypeId().accept(visitor); + ((ICPPASTConversionName) name).getTypeId().accept(visitor); } else if (name instanceof ICPPASTQualifiedName){ writeQualifiedName((ICPPASTQualifiedName) name); } else { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java index 61a7f241430..627e8158a5f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NodeWriter.java @@ -7,13 +7,12 @@ * 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.internal.core.dom.rewrite.astwriter; import java.util.ArrayList; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTCopyLocation; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -21,17 +20,14 @@ import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; /** - * * Base class for node writers. This class contains methods and string constants * used by multiple node writers. * * @author Emanuel Graf IFS - * */ public class NodeWriter { - protected Scribe scribe; - protected ASTVisitor visitor; + protected ASTWriterVisitor visitor; protected NodeCommentMap commentMap; protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$ protected static final String EQUALS = " = "; //$NON-NLS-1$ @@ -64,7 +60,7 @@ public class NodeWriter { protected static final String COLON_COLON = "::"; //$NON-NLS-1$ protected static final String COLON_SPACE = ": "; //$NON-NLS-1$ - public NodeWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public NodeWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(); this.scribe = scribe; this.visitor = visitor; @@ -72,31 +68,42 @@ public class NodeWriter { } protected void writeNodeList(IASTNode[] nodes) { - for(int i = 0; i < nodes.length; ++i) { + for (int i = 0; i < nodes.length; ++i) { nodes[i].accept(visitor); - if(i + 1 < nodes.length) { + if (i + 1 < nodes.length) { scribe.print(COMMA_SPACE); } } } - protected void visitNodeIfNotNull(IASTNode node){ - if(node != null){ + protected void visitNodeIfNotNull(IASTNode node) { + if (node != null) { node.accept(visitor); } } - protected void writeTrailingComments(IASTNode node) { - //default write newLine + // Default is to write a new line after trailing comments. writeTrailingComments(node, true); } - - protected boolean hasTrailingComments(IASTNode node){ - if(getTrailingComments(node).size()>0) { - return true; + + protected void writeTrailingComments(IASTNode node, boolean newLine) { + boolean first = true; + for (IASTComment comment : getTrailingComments(node)) { + if (!first) { + scribe.newLine(); + } + scribe.printSpace(); + scribe.print(comment.getComment()); + first = false; } - return false; + if (newLine) { + scribe.newLine(); + } + } + + protected boolean hasTrailingComments(IASTNode node) { + return !getTrailingComments(node).isEmpty(); } private ArrayList getTrailingComments(IASTNode node) { @@ -108,22 +115,9 @@ public class NodeWriter { } return trailingComments; } - - protected void writeTrailingComments(IASTNode node, boolean newLine) { - for(IASTComment comment : getTrailingComments(node)) { - scribe.printSpace(); - scribe.print(comment.getComment()); - if(newLine) { - scribe.newLine(); - } - } - } - protected boolean hasFreestandingComments(IASTNode node){ - if(getFreestandingComments(node).size()>0) { - return true; - } - return false; + protected boolean hasFreestandingComments(IASTNode node) { + return !getFreestandingComments(node).isEmpty(); } private ArrayList getFreestandingComments(IASTNode node) { @@ -137,7 +131,7 @@ public class NodeWriter { } protected void writeFreeStandingComments(IASTNode node) { - for(IASTComment comment : getFreestandingComments(node)) { + for (IASTComment comment : getFreestandingComments(node)) { scribe.print(comment.getComment()); scribe.newLine(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java index 1dbddc51c45..11a47db433c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java @@ -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.internal.core.dom.rewrite.astwriter; @@ -15,16 +15,13 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTProblemHolder; /** - * - * This exception is thrown if a problem nod is passed to the astwriter. The Exception + * This exception is thrown if a problem node is passed to the ASTWriter. The exception * contains the IASTProblemHolder that was passed to the writer. * * @see IASTProblem * @author Emanuel Graf IFS - * */ public class ProblemRuntimeException extends RuntimeException { - private static final long serialVersionUID = -3661425564246498786L; private IASTProblemHolder problem; @@ -32,8 +29,7 @@ public class ProblemRuntimeException extends RuntimeException { problem = statement; } - public IASTProblemHolder getProblem(){ + public IASTProblemHolder getProblem() { return problem; } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java index 7a35655c1f8..8bc32d8396d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/Scribe.java @@ -7,110 +7,106 @@ * 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.internal.core.dom.rewrite.astwriter; /** - * - * This class is responsible for the string concatination and the management of + * This class is responsible for the string concatenation and the management of * the indentations. * * @since 5.0 * @author Emanuel Graf IFS - * */ public class Scribe { - - private int indentationLevel = 0; - private int indentationSize = 4; //HSR tcorbat: could be a tab character too - this is not a very elegant solution - private StringBuffer buffer = new StringBuffer(); + // Any positive indentation size is good enough since the code is going to be formatted anyway. + private int indentationSize = 4; + private StringBuilder buffer = new StringBuilder(); private boolean isAtLineBeginning = true; private String newLine = System.getProperty("line.separator"); //$NON-NLS-1$ - private String givenIndentation = null; + private String givenIndentation; - private boolean noNewLine = false; - private boolean noSemicolon = false; - - public void newLine(){ - if(!noNewLine) { + private boolean skipLineBreaks; + private boolean skipSemicolons; + + public void newLine() { + if (!skipLineBreaks) { isAtLineBeginning = true; buffer.append(getNewline()); } } - - private void indent(){ - if( givenIndentation != null ){ - buffer.append( givenIndentation ); + + private void indent() { + if (givenIndentation != null) { + buffer.append(givenIndentation); } printSpaces(indentationLevel * indentationSize); } - - private void indentIfNewLine(){ - if(isAtLineBeginning){ + + private void indentIfNewLine() { + if (isAtLineBeginning) { isAtLineBeginning = false; indent(); } } - - private String getNewline(){ + + private String getNewline() { return newLine; } - - public void print(String code){ + + public void print(String code) { indentIfNewLine(); buffer.append(code); } - + public void println(String code) { print(code); newLine(); } - + public void print(String code, String code2) { print(code); buffer.append(code2); } - + public void println(String code, String code2) { print(code, code2); newLine(); } - - public void println(String code , char[] code2) { + + public void println(String code, char[] code2) { print(code); buffer.append(code2); newLine(); } - - public void printSpaces(int number){ + + public void printSpaces(int number) { indentIfNewLine(); - for(int i = 0; i < number; ++i){ + for (int i = 0; i < number; ++i) { printSpace(); } } - + public void noSemicolon() { - noSemicolon = true; + skipSemicolons = true; } - - public void printSemicolon(){ - if(!noSemicolon) { + + public void printSemicolon() { + if (!skipSemicolons) { indentIfNewLine(); buffer.append(';'); - } - else { - noSemicolon = false; + } else { + skipSemicolons = false; } } - + @Override - public String toString(){ + public String toString() { return buffer.toString(); } - - public void print (char code) { + + public void print(char code) { indentIfNewLine(); buffer.append(code); } @@ -119,19 +115,19 @@ public class Scribe { indentIfNewLine(); buffer.append(code); } - + public void println(char[] code) { print(code); newLine(); } - - public void printStringSpace(String code){ + + public void printStringSpace(String code) { print(code); printSpace(); } /** - * Prints a { to the Buffer an increases the Indentationlevel. + * Prints a { to the buffer an increases the indentation level. */ public void printLBrace() { print('{'); @@ -139,40 +135,40 @@ public class Scribe { } /** - * Prints a } to the Buffer an decrease the Indentationlevel. + * Prints a } to the buffer an decrease the indentation level. */ public void printRBrace() { --indentationLevel; print('}'); } - - public void incrementIndentationLevel(){ + + public void incrementIndentationLevel() { ++indentationLevel; } - - public void decrementIndentationLevel(){ - if(indentationLevel>0) { + + public void decrementIndentationLevel() { + if (indentationLevel > 0) { --indentationLevel; } } - - protected void noNewLines(){ - noNewLine = true; + + protected void noNewLines() { + skipLineBreaks = true; } - - protected void newLines(){ - noNewLine = false; + + protected void newLines() { + skipLineBreaks = false; } - + public void newLine(int i) { - while(i > 0) { + while (i > 0) { newLine(); --i; } } public void printSpace() { - buffer.append(' '); + buffer.append(' '); } public String getGivenIndentation() { @@ -184,6 +180,6 @@ public class Scribe { } public void cleanCache() { - buffer = new StringBuffer(); + buffer = new StringBuilder(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java index 2e1e6dcafd4..ac8c6f21f37 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/StatementWriter.java @@ -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.internal.core.dom.rewrite.astwriter; @@ -46,30 +46,27 @@ import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper; import org.eclipse.core.resources.IFile; /** - * * Generates source code of statement nodes. The actual string operations are delegated * to the Scribe class. * * @see Scribe * @see IASTStatement * @author Emanuel Graf IFS - * */ -public class StatementWriter extends NodeWriter{ - +public class StatementWriter extends NodeWriter { private static final String DEFAULT = "default:"; //$NON-NLS-1$ private static final String CASE = "case "; //$NON-NLS-1$ - private static final String WHILE = "while("; //$NON-NLS-1$ + private static final String WHILE = "while ("; //$NON-NLS-1$ private static final String TRY = "try "; //$NON-NLS-1$ - private static final String CATCH = "catch("; //$NON-NLS-1$ + private static final String CATCH = "catch ("; //$NON-NLS-1$ private static final String RETURN = "return"; //$NON-NLS-1$ private static final String GOTO = "goto "; //$NON-NLS-1$ private static final String CONTINUE = "continue"; //$NON-NLS-1$ private static final String BREAK = "break"; //$NON-NLS-1$ private static final String ELSE = "else"; //$NON-NLS-1$ - private static final String IF = "if("; //$NON-NLS-1$ - private static final String FOR = "for("; //$NON-NLS-1$ - private static final String DO_WHILE = " while("; //$NON-NLS-1$ + private static final String IF = "if ("; //$NON-NLS-1$ + private static final String FOR = "for ("; //$NON-NLS-1$ + private static final String DO_WHILE = " while ("; //$NON-NLS-1$ private static final String DO = "do"; //$NON-NLS-1$ private static final String SWITCH_BRACKET = "switch ("; //$NON-NLS-1$ private boolean compoundNoNewLine = false; @@ -77,15 +74,16 @@ public class StatementWriter extends NodeWriter{ private boolean decrementIndentationLevelOneMore = false; private final DeclarationWriter declWriter; - public StatementWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public StatementWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); declWriter = new DeclarationWriter(scribe, visitor, commentMap); } /** + * Prints a statement. * - * @param statement - * @param newLine if true print a newline if statment usually have one. + * @param statement the statement + * @param newLine if true print a newline if statement usually have one. * @return {@link ASTVisitor#PROCESS_SKIP} */ protected int writeStatement(IASTStatement statement, boolean newLine) { @@ -114,14 +112,14 @@ public class StatementWriter extends NodeWriter{ } else if (statement instanceof IASTCaseStatement) { writeCaseStatement((IASTCaseStatement) statement); // usually newLine - }else if (statement instanceof IASTDefaultStatement) { + } else if (statement instanceof IASTDefaultStatement) { writeDefaultStatement((IASTDefaultStatement)statement); - } else if (statement instanceof IASTContinueStatement){ + } else if (statement instanceof IASTContinueStatement) { writeContinueStatement((IASTContinueStatement)statement); // usually newLine } else if (statement instanceof IASTCompoundStatement) { writeCompoundStatement((IASTCompoundStatement) statement); - if(compoundNoNewLine){ + if (compoundNoNewLine) { newLine = false; compoundNoNewLine = false; } @@ -135,7 +133,7 @@ public class StatementWriter extends NodeWriter{ writeIfStatement((IASTIfStatement) statement); newLine = false; } else if (statement instanceof IASTWhileStatement) { - writeWhileStatement( (IASTWhileStatement) statement ); + writeWhileStatement((IASTWhileStatement) statement); newLine = false; } else if (statement instanceof IASTForStatement) { writeForStatement((IASTForStatement) statement); @@ -156,13 +154,10 @@ public class StatementWriter extends NodeWriter{ throw new ProblemRuntimeException((IASTProblemStatement)statement); } - if(hasTrailingComments(statement)) { + if (hasTrailingComments(statement)) { writeTrailingComments(statement, newLine); - } - else{ - if(newLine){ - scribe.newLine(); - } + } else if (newLine) { + scribe.newLine(); } return ASTVisitor.PROCESS_SKIP; @@ -179,32 +174,31 @@ public class StatementWriter extends NodeWriter{ scribe.printSemicolon(); } - private void writeForStatement(IASTForStatement forStatment) { + private void writeForStatement(IASTForStatement forStatement) { scribe.noNewLines(); scribe.print(FOR); - writeStatement(forStatment.getInitializerStatement(),false); - if (forStatment instanceof ICPPASTForStatement) { - ICPPASTForStatement cppForStatment = (ICPPASTForStatement) forStatment; + writeStatement(forStatement.getInitializerStatement(),false); + if (forStatement instanceof ICPPASTForStatement) { + ICPPASTForStatement cppForStatment = (ICPPASTForStatement) forStatement; IASTDeclaration cppConditionDeclaration = cppForStatment.getConditionDeclaration(); - if(cppConditionDeclaration == null) { + if (cppConditionDeclaration == null) { visitNodeIfNotNull(cppForStatment.getConditionExpression()); scribe.printSemicolon(); } else { cppConditionDeclaration.accept(visitor); } - } else { - if(forStatment.getConditionExpression() != null) { - forStatment.getConditionExpression().accept(visitor); + if (forStatement.getConditionExpression() != null) { + forStatement.getConditionExpression().accept(visitor); scribe.printSemicolon(); } } - visitNodeIfNotNull(forStatment.getIterationExpression()); + visitNodeIfNotNull(forStatement.getIterationExpression()); scribe.print(')'); scribe.newLines(); nextCompoundNoNewLine(); - writeBodyStatement(forStatment.getBody(), false); + writeBodyStatement(forStatement.getBody(), false); } private void writeForStatement(ICPPASTRangeBasedForStatement forStatment) { @@ -225,7 +219,7 @@ public class StatementWriter extends NodeWriter{ if (ifStatement instanceof ICPPASTIfStatement) { ICPPASTIfStatement cppIfStatment = (ICPPASTIfStatement) ifStatement; - if(cppIfStatment.getConditionDeclaration() == null) { + if (cppIfStatment.getConditionDeclaration() == null) { cppIfStatment.getConditionExpression().accept(visitor); } else { writeDeclarationWithoutSemicolon(cppIfStatment.getConditionDeclaration()); @@ -238,17 +232,16 @@ public class StatementWriter extends NodeWriter{ scribe.newLines(); nextCompoundNoNewLine(); IASTStatement elseClause = ifStatement.getElseClause(); - writeBodyStatement(ifStatement.getThenClause(), elseClause != null ? true : false); + writeBodyStatement(ifStatement.getThenClause(), elseClause != null); - if(elseClause != null){ + if (elseClause != null) { scribe.print(ELSE); nextCompoundNoNewLine(); writeBodyStatement(elseClause, false); } } - protected void writeDeclarationWithoutSemicolon( - IASTDeclaration declaration) { + protected void writeDeclarationWithoutSemicolon(IASTDeclaration declaration) { declWriter.writeDeclaration(declaration, false); } @@ -279,7 +272,7 @@ public class StatementWriter extends NodeWriter{ scribe.noNewLines(); scribe.print(RETURN); IASTExpression returnValue = returnStatement.getReturnValue(); - if(returnValue != null){ + if (returnValue != null) { scribe.printSpaces(1); returnValue.accept(visitor); } @@ -327,7 +320,7 @@ public class StatementWriter extends NodeWriter{ scribe.noNewLines(); if (whileStatment instanceof ICPPASTWhileStatement) { ICPPASTWhileStatement cppWhileStatment = (ICPPASTWhileStatement) whileStatment; - if(cppWhileStatment.getConditionDeclaration() == null) { + if (cppWhileStatment.getConditionDeclaration() == null) { cppWhileStatment.getCondition().accept(visitor); } else { writeDeclarationWithoutSemicolon(cppWhileStatment.getConditionDeclaration()); @@ -344,7 +337,7 @@ public class StatementWriter extends NodeWriter{ private void writeCaseStatement(IASTCaseStatement caseStatement) { nextCompoundIndentationLevelOneMore(); - if(!switchIsNew){ + if (!switchIsNew) { scribe.decrementIndentationLevel(); } scribe.print(CASE); @@ -361,7 +354,7 @@ public class StatementWriter extends NodeWriter{ scribe.noNewLines(); if (switchStatement instanceof ICPPASTSwitchStatement) { ICPPASTSwitchStatement cppSwitchStatement = (ICPPASTSwitchStatement) switchStatement; - if(cppSwitchStatement.getControllerDeclaration() == null) { + if (cppSwitchStatement.getControllerDeclaration() == null) { cppSwitchStatement.getControllerExpression().accept(visitor); } else { declWriter.writeDeclaration(cppSwitchStatement.getControllerDeclaration(), false); @@ -380,7 +373,7 @@ public class StatementWriter extends NodeWriter{ private void writeDefaultStatement(IASTDefaultStatement defaultStatement) { nextCompoundIndentationLevelOneMore(); - if(!switchIsNew){ + if (!switchIsNew) { scribe.decrementIndentationLevel(); } scribe.print(DEFAULT); @@ -395,11 +388,11 @@ public class StatementWriter extends NodeWriter{ statements.accept(visitor); } - if(hasFreestandingComments(compoundStatement)) { + if (hasFreestandingComments(compoundStatement)) { writeFreeStandingComments(compoundStatement); } - if(decrementIndentationLevelOneMore){ + if (decrementIndentationLevelOneMore) { scribe.decrementIndentationLevel(); decrementIndentationLevelOneMore = false; } @@ -411,14 +404,14 @@ public class StatementWriter extends NodeWriter{ } protected void writeBodyStatement(IASTStatement statement, boolean isDoStatement) { - if (statement instanceof IASTCompoundStatement){ + if (statement instanceof IASTCompoundStatement) { //TODO hsr existiert noch eine methode statement.accept(visitor); - if(!isDoStatement){ + if (!isDoStatement) { scribe.newLine(); } compoundNoNewLine = false; - } else if (statement instanceof IASTNullStatement){ + } else if (statement instanceof IASTNullStatement) { statement.accept(visitor); scribe.newLine(); } else { @@ -426,32 +419,29 @@ public class StatementWriter extends NodeWriter{ scribe.newLine(); statement.accept(visitor); scribe.decrementIndentationLevel(); - scribe.newLine(); } } - + /** * Write no new Line after the next Compound-Statement - * */ - protected void nextCompoundNoNewLine(){ + protected void nextCompoundNoNewLine() { compoundNoNewLine = true; } /** * Indent one time more at the end (before the closing Brackets) * of a Compound-Statement - * */ - protected void nextCompoundIndentationLevelOneMore(){ + protected void nextCompoundIndentationLevelOneMore() { decrementIndentationLevelOneMore = true; } protected int writeMixedStatement(IASTStatement statement) { - IFile file = FileHelper.getIFilefromIASTNode(statement); + IFile file = FileHelper.getFileFromNode(statement); int offset = statement.getFileLocation().getNodeOffset(); int length = statement.getFileLocation().getNodeLength(); - String code =FileContentHelper.getContent(file, offset, length); + String code = FileContentHelper.getContent(file, offset, length); scribe.println(code); return ASTVisitor.PROCESS_SKIP; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java index f1265c5bbd0..64d11679574 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/TemplateParameterWriter.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter; @@ -35,7 +34,7 @@ public class TemplateParameterWriter extends NodeWriter { * @param scribe * @param visitor */ - public TemplateParameterWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) { + public TemplateParameterWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ASTModificationHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ASTModificationHelper.java index 186f399fb41..3354844d4d1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ASTModificationHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ASTModificationHelper.java @@ -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.internal.core.dom.rewrite.changegenerator; @@ -28,30 +28,27 @@ import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; public class ASTModificationHelper { - private final ModificationScopeStack modificationStore; public ASTModificationHelper(ModificationScopeStack stack) { this.modificationStore = stack; } - - public T[] createModifiedChildArray(IASTNode parent, T[] unmodifiedChildren, Class clazz, NodeCommentMap commentMap){ + public T[] createModifiedChildArray(IASTNode parent, T[] unmodifiedChildren, Class clazz, NodeCommentMap commentMap) { ArrayList modifiedChildren = new ArrayList(Arrays.asList(unmodifiedChildren)); - for(ASTModification parentModification : modificationsForNode(parent)){ - switch(parentModification.getKind()){ + for (ASTModification parentModification : modificationsForNode(parent)) { + switch (parentModification.getKind()) { case APPEND_CHILD: IASTNode newNode = parentModification.getNewNode(); T appendedTNode = cast(newNode, clazz); if (appendedTNode != null) { modifiedChildren.add(appendedTNode); - } - else if (newNode instanceof ContainerNode){ + } else if (newNode instanceof ContainerNode) { ContainerNode nodeContainer = (ContainerNode) newNode; - for(IASTNode currentNode : nodeContainer.getNodes()){ + for (IASTNode currentNode : nodeContainer.getNodes()) { T tnode= cast(currentNode, clazz); - if(tnode != null){ + if (tnode != null) { modifiedChildren.add(tnode); } } @@ -71,6 +68,7 @@ public class ASTModificationHelper { break; case REPLACE: + break; } } @@ -145,42 +143,35 @@ public class ASTModificationHelper { @SuppressWarnings("unchecked") private T cast(IASTNode node, Class clazz) { - if (clazz.isInstance(node)){ + if (clazz.isInstance(node)) { return (T) node; } return null; } - - public List modificationsForNode( - IASTNode targetNode) { + public List modificationsForNode(IASTNode targetNode) { List modificationsForNode; - if(modificationStore.getModifiedNodes().contains(targetNode)){ + if (modificationStore.getModifiedNodes().contains(targetNode)) { modificationsForNode = modificationStore.getModificationsForNode(targetNode); - } - else{ + } else { modificationsForNode = Collections.emptyList(); } - return modificationsForNode; - + return modificationsForNode; } - - + public IASTInitializer getInitializer(IASTDeclarator decl) { IASTInitializer initializer = decl.getInitializer(); - if(initializer != null){ - for(ASTModification childModification : modificationsForNode(initializer)){ - switch(childModification.getKind()){ + if (initializer != null) { + for (ASTModification childModification : modificationsForNode(initializer)) { + switch (childModification.getKind()) { case REPLACE: - if(childModification.getNewNode() instanceof IASTInitializer){ + if (childModification.getNewNode() instanceof IASTInitializer) { return (IASTInitializer)childModification.getNewNode(); } else if (childModification.getNewNode() == null) { return null; } throw new UnhandledASTModificationException(childModification); - - case INSERT_BEFORE: throw new UnhandledASTModificationException(childModification); @@ -188,13 +179,11 @@ public class ASTModificationHelper { throw new UnhandledASTModificationException(childModification); } } - } - else - { - for(ASTModification parentModification : modificationsForNode(decl)){ - if(parentModification.getKind() == ModificationKind.APPEND_CHILD){ + } else { + for (ASTModification parentModification : modificationsForNode(decl)) { + if (parentModification.getKind() == ModificationKind.APPEND_CHILD) { IASTNode newNode = parentModification.getNewNode(); - if(newNode instanceof IASTInitializer){ + if (newNode instanceof IASTInitializer) { return (IASTInitializer) newNode; } } @@ -203,17 +192,15 @@ public class ASTModificationHelper { return initializer; } - @SuppressWarnings("unchecked") public T getNodeAfterReplacement(T replacedNode) { List modifications = modificationsForNode(replacedNode); - for(ASTModification currentModification : modifications){ - try{ - if(currentModification.getKind() == ModificationKind.REPLACE){ + for (ASTModification currentModification : modifications) { + try { + if (currentModification.getKind() == ModificationKind.REPLACE) { return (T) currentModification.getNewNode(); } - } - catch(ClassCastException e){ + } catch (ClassCastException e) { throw new UnhandledASTModificationException(currentModification); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java index 2c0b275e8df..d8d2b173c00 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java @@ -9,16 +9,23 @@ * Contributors: * Institute for Software - initial API and implementation * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator; +import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ToolFactory; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; import org.eclipse.cdt.core.dom.ast.IASTComment; +import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -31,7 +38,10 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.formatter.CodeFormatter; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification; +import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationMap; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore; import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer; @@ -41,16 +51,26 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.util.FileContentHelper; import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper; import org.eclipse.cdt.internal.core.resources.ResourceLookup; +import org.eclipse.cdt.internal.formatter.CCodeFormatter; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.TextUtilities; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.CompositeChange; import org.eclipse.ltk.core.refactoring.TextFileChange; import org.eclipse.text.edits.DeleteEdit; import org.eclipse.text.edits.InsertEdit; +import org.eclipse.text.edits.MalformedTreeException; import org.eclipse.text.edits.MultiTextEdit; import org.eclipse.text.edits.ReplaceEdit; +import org.eclipse.text.edits.TextEdit; import org.eclipse.text.edits.TextEditGroup; public class ChangeGenerator extends ASTVisitor { @@ -93,8 +113,10 @@ public class ChangeGenerator extends ASTVisitor { initParentModList(); rootNode.accept(pathProvider); for (IFile currentFile : changes.keySet()) { + MultiTextEdit edit = changes.get(currentFile); + edit = formatChangedCode(edit, currentFile); TextFileChange subchange= ASTRewriteAnalyzer.createCTextFileChange(currentFile); - subchange.setEdit(changes.get(currentFile)); + subchange.setEdit(edit); change.add(subchange); } } @@ -130,6 +152,63 @@ public class ChangeGenerator extends ASTVisitor { return modifiedNodeParent; } + /** + * Applies the C++ code formatter to the code affected by refactoring. + * + * @param edit The text edit produced by refactoring. + * @param file The file being modified. + * @return The text edit containing formatted refactoring changes, or the original text edit + * in case of errors. + */ + private MultiTextEdit formatChangedCode(MultiTextEdit edit, IFile file) { + String code; + try { + code = FileContentHelper.getContent(file, 0); + } catch (IOException e) { + CCorePlugin.log(e); + return edit; + } catch (CoreException e) { + CCorePlugin.log(e); + return edit; + } + IDocument document = new Document(code); + try { + TextEdit tempEdit = edit.copy(); + tempEdit.apply(document, TextEdit.UPDATE_REGIONS); + TextEdit[] edits = tempEdit.getChildren(); + IRegion[] regions = new IRegion[edits.length]; + for (int i = 0; i < edits.length; i++) { + regions[i] = edits[i].getRegion(); + } + ICProject project = CCorePlugin.getDefault().getCoreModel().create(file.getProject()); + Map options = project.getOptions(true); + CodeFormatter formatter = ToolFactory.createCodeFormatter(options); + code = document.get(); + TextEdit[] formatEdits = formatter.format(CCodeFormatter.K_TRANSLATION_UNIT, code, + regions, TextUtilities.getDefaultLineDelimiter(document)); + MultiTextEdit resultEdit = new MultiTextEdit(); + edits = edit.getChildren(); + for (int i = 0; i < edits.length; i++) { + IRegion region = regions[i]; + int offset = region.getOffset(); + TextEdit formatEdit = formatEdits[i]; + formatEdit.moveTree(-offset); + document = new Document(code.substring(offset, offset + region.getLength())); + formatEdit.apply(document, TextEdit.NONE); + TextEdit textEdit = edits[i]; + resultEdit.addChild( + new ReplaceEdit(textEdit.getOffset(), textEdit.getLength(), document.get())); + } + return resultEdit; + } catch (MalformedTreeException e) { + CCorePlugin.log(e); + return edit; + } catch (BadLocationException e) { + CCorePlugin.log(e); + return edit; + } + } + @Override public int visit(IASTTranslationUnit translationUnit) { if (hasChangedChild(translationUnit)) { @@ -145,11 +224,6 @@ public class ChangeGenerator extends ASTVisitor { return super.leave(tu); } - private int getOffsetForNodeFile(IASTNode rootNode) { - Integer offset = sourceOffsets.get(rootNode.getFileLocation().getFileName()); - return offset == null ? 0 : offset.intValue(); - } - @Override public int visit(IASTDeclaration declaration) { if (hasChangedChild(declaration)) { @@ -160,33 +234,126 @@ public class ChangeGenerator extends ASTVisitor { } private void synthTreatment(IASTNode synthNode) { - synthTreatment(synthNode, null); - } - - private void synthTreatment(IASTNode synthNode, String fileScope) { - String indent = getIndent(synthNode); - ASTWriter synthWriter = new ASTWriter(indent); - synthWriter.setModificationStore(modificationStore); - - String synthSource = synthWriter.write(synthNode, fileScope, commentMap); - + ChangeGeneratorWriterVisitor writer = + new ChangeGeneratorWriterVisitor(modificationStore, commentMap); + synthNode.accept(writer); + String synthSource = writer.toString(); createChange(synthNode, synthSource); - + IASTFileLocation fileLocation = synthNode.getFileLocation(); int newOffset = fileLocation.getNodeOffset() + fileLocation.getNodeLength(); sourceOffsets.put(fileLocation.getFileName(), Integer.valueOf(newOffset)); } + private void handleAppends(IASTNode node) { + ChangeGeneratorWriterVisitor writer = + new ChangeGeneratorWriterVisitor(modificationStore, commentMap); + List modifications = modificationParent.get(node); + ReplaceEdit anchor = getAppendAnchor(node); + Assert.isNotNull(anchor); + IASTNode precedingNode = getLastNodeBeforeAppendPoint(node); + if (precedingNode != null && + ASTWriter.requireBlankLineInBetween(precedingNode, modifications.get(0).getNewNode())) { + writer.newLine(); + } + for (ASTModification modification : modifications) { + IASTNode newNode = modification.getNewNode(); + newNode.accept(writer); + } + String code = writer.toString(); + IFile file = FileHelper.getFileFromNode(node); + MultiTextEdit parentEdit = getEdit(node, file); + ReplaceEdit edit = new ReplaceEdit(anchor.getOffset(), anchor.getLength(), + code + anchor.getText()); + parentEdit.addChild(edit); + IASTFileLocation fileLocation = node.getFileLocation(); + int newOffset = fileLocation.getNodeOffset() + fileLocation.getNodeLength(); + sourceOffsets.put(fileLocation.getFileName(), Integer.valueOf(newOffset)); + } + + private IASTNode getLastNodeBeforeAppendPoint(IASTNode node) { + IASTNode[] children; + if (node instanceof IASTCompositeTypeSpecifier) { + children = ((IASTCompositeTypeSpecifier) node).getDeclarations(true); + } else { + children = node.getChildren(); + } + return children.length > 0 ? children[children.length - 1] : null; + } + + private boolean isAppendable(Iterable modifications) { + for (ASTModification modification : modifications) { + if (!isAppendable(modification)) + return false; + } + return true; + } + + private boolean isAppendable(ASTModification modification) { + if (modification.getKind() != ModificationKind.APPEND_CHILD) + return false; + IASTNode node = modification.getNewNode(); + return node instanceof IASTDeclaration || node instanceof IASTStatement; + } + + /** + * Returns a replace edit whose offset is the position where child appended nodes should be + * inserted at. The text contains the content of the code region that will be disturbed by + * the insertion. + * @param node The node to append children to. + * @return a ReplaceEdit object, or null if the node does not support appending + * children to it. + */ + private ReplaceEdit getAppendAnchor(IASTNode node) { + if (!(node instanceof IASTCompositeTypeSpecifier || + node instanceof IASTCompoundStatement || + node instanceof ICPPASTNamespaceDefinition)) { + return null; + } + IFile file = FileHelper.getFileFromNode(node); + String code = originalCodeOfNode(node, file); + IASTFileLocation location = node.getFileLocation(); + int pos = location.getNodeOffset() + location.getNodeLength(); + int len = code.endsWith("}") ? 1 : 0; //$NON-NLS-1$ + int startOfLine = skipPrecedingBlankLines(code, code.length() - len); + if (startOfLine < 0) { + // Include the closing brace in the region that will be reformatted. + return new ReplaceEdit(pos - len, len, code.substring(code.length() - len)); + } + return new ReplaceEdit(location.getNodeOffset() + startOfLine, 0, ""); //$NON-NLS-1$ + } + + /** + * Skips blank lines preceding the given position. + * @param text the text to scan + * @param pos the position after that blank lines. + * @return the beginning of the first blank line, or -1 if the beginning of the line + * corresponding to the given position contains non-whitespace characters. + */ + private int skipPrecedingBlankLines(String text, int pos) { + int lineStart = -1; + while (--pos >= 0) { + char c = text.charAt(pos); + if (c == '\n') { + lineStart = pos + 1; + } else if (!Character.isWhitespace(c)) { + break; + } + } + return lineStart; + } + private void synthTreatment(IASTTranslationUnit synthTU) { ASTWriter synthWriter = new ASTWriter(); synthWriter.setModificationStore(modificationStore); for (ASTModification modification : modificationParent.get(synthTU)) { - IASTFileLocation targetLocation = modification.getTargetNode().getFileLocation(); + IASTNode targetNode = modification.getTargetNode(); + IASTFileLocation targetLocation = targetNode.getFileLocation(); String currentFile = targetLocation.getFileName(); IPath implPath = new Path(currentFile); IFile relevantFile= ResourceLookup.selectFileForLocation(implPath, null); - if (relevantFile == null || !relevantFile.exists()) { // if not in workspace or local file system + if (relevantFile == null || !relevantFile.exists()) { // If not in workspace or local file system throw new UnhandledASTModificationException(modification); } MultiTextEdit edit; @@ -196,7 +363,7 @@ public class ChangeGenerator extends ASTVisitor { edit = new MultiTextEdit(); changes.put(relevantFile, edit); } - String newNodeCode = synthWriter.write(modification.getNewNode(), null, commentMap); + String newNodeCode = synthWriter.write(modification.getNewNode(), commentMap); switch (modification.getKind()) { case REPLACE: @@ -204,18 +371,20 @@ public class ChangeGenerator extends ASTVisitor { targetLocation.getNodeLength(), newNodeCode)); break; case INSERT_BEFORE: - edit.addChild(new InsertEdit(getOffsetIncludingComments(modification.getTargetNode()), - newNodeCode)); + if (ASTWriter.requireBlankLineInBetween(modification.getNewNode(), targetNode)) { + newNodeCode = newNodeCode + "\n"; //$NON-NLS-1$ + } + edit.addChild(new InsertEdit(getOffsetIncludingComments(targetNode), newNodeCode)); break; case APPEND_CHILD: - if (modification.getTargetNode() instanceof IASTTranslationUnit && - ((IASTTranslationUnit)modification.getTargetNode()).getDeclarations().length > 0) { - IASTTranslationUnit tu = (IASTTranslationUnit)modification.getTargetNode(); - IASTDeclaration lastDecl = tu.getDeclarations()[tu.getDeclarations().length -1]; + if (targetNode instanceof IASTTranslationUnit && + ((IASTTranslationUnit) targetNode).getDeclarations().length > 0) { + IASTTranslationUnit tu = (IASTTranslationUnit) targetNode; + IASTDeclaration lastDecl = tu.getDeclarations()[tu.getDeclarations().length - 1]; targetLocation = lastDecl.getFileLocation(); } String lineDelimiter = FileHelper.determineLineDelimiter( - FileHelper.getIFilefromIASTNode(modification.getTargetNode())); + FileHelper.getFileFromNode(targetNode)); edit.addChild(new InsertEdit(targetLocation.getNodeOffset() + targetLocation.getNodeLength(), lineDelimiter + lineDelimiter + newNodeCode)); break; @@ -224,31 +393,33 @@ public class ChangeGenerator extends ASTVisitor { } private void createChange(IASTNode synthNode, String synthSource) { - IFile relevantFile = FileHelper.getIFilefromIASTNode(synthNode); - - String originalCode = originalCodeOfNode(synthNode); + IFile relevantFile = FileHelper.getFileFromNode(synthNode); + String originalCode = originalCodeOfNode(synthNode, relevantFile); CodeComparer codeComparer = new CodeComparer(originalCode, synthSource); - - MultiTextEdit edit; - if (changes.containsKey(relevantFile)) { - edit = changes.get(relevantFile); - } else { - edit = new MultiTextEdit(); - changes.put(relevantFile, edit); - } - - codeComparer.createChange(edit, synthNode); + codeComparer.createChange(getEdit(synthNode, relevantFile), synthNode); } - public String originalCodeOfNode(IASTNode node) { - if (node.getFileLocation() != null) { - IFile sourceFile = FileHelper.getIFilefromIASTNode(node); - int nodeOffset = getOffsetIncludingComments(node); - int nodeLength = getNodeLengthIncludingComments(node); - - return FileContentHelper.getContent(sourceFile, nodeOffset, nodeLength); + private MultiTextEdit getEdit(IASTNode modifiedNode, IFile file) { + MultiTextEdit edit = changes.get(file); + if (edit == null) { + edit = new MultiTextEdit(); + changes.put(file, edit); } - return null; + TextEditGroup editGroup = new TextEditGroup(Messages.ChangeGenerator_group); + for (ASTModification currentModification : modificationParent.get(modifiedNode)) { + if (currentModification.getAssociatedEditGroup() != null) { + editGroup = currentModification.getAssociatedEditGroup(); + edit.addChildren(editGroup.getTextEdits()); + break; + } + } + return edit; + } + + private String originalCodeOfNode(IASTNode node, IFile sourceFile) { + int nodeOffset = getOffsetIncludingComments(node); + int nodeLength = getNodeLengthIncludingComments(node); + return FileContentHelper.getContent(sourceFile, nodeOffset, nodeLength); } private int getNodeLengthIncludingComments(IASTNode node) { @@ -290,23 +461,15 @@ public class ChangeGenerator extends ASTVisitor { return nodeOffset; } - private String getIndent(IASTNode nextNode) { - IASTFileLocation fileLocation = nextNode.getFileLocation(); - int length = fileLocation.getNodeOffset() - getOffsetForNodeFile(nextNode); - - String originalSource = FileContentHelper.getContent(FileHelper.getIFilefromIASTNode(nextNode), - getOffsetForNodeFile(nextNode), length); - StringBuilder indent = new StringBuilder(originalSource); - indent.reverse(); - String lastline = indent.substring(0, Math.max(indent.indexOf("\n"), 0)); //$NON-NLS-1$ - if (lastline.trim().length() == 0) { - return lastline; - } - return ""; //$NON-NLS-1$ + private boolean hasChangedChild(IASTNode node) { + return modificationParent.containsKey(node); } - private boolean hasChangedChild(IASTNode parent) { - return modificationParent.containsKey(parent); + private boolean hasAppendsOnly(IASTNode node) { + List modifications = modificationParent.get(node); + if (modifications == null) + return false; + return isAppendable(modifications); } @Override @@ -329,22 +492,38 @@ public class ChangeGenerator extends ASTVisitor { @Override public int visit(ICPPASTNamespaceDefinition namespaceDefinition) { - if (hasChangedChild(namespaceDefinition)) { + if (hasChangedChild(namespaceDefinition) && !hasAppendsOnly(namespaceDefinition)) { synthTreatment(namespaceDefinition); return ASTVisitor.PROCESS_SKIP; } return super.visit(namespaceDefinition); } + @Override + public int leave(ICPPASTNamespaceDefinition namespaceDefinition) { + if (hasAppendsOnly(namespaceDefinition)) { + handleAppends(namespaceDefinition); + } + return super.leave(namespaceDefinition); + } + @Override public int visit(IASTDeclSpecifier declSpec) { - if (hasChangedChild(declSpec)) { + if (hasChangedChild(declSpec) && !hasAppendsOnly(declSpec)) { synthTreatment(declSpec); return ASTVisitor.PROCESS_SKIP; } return super.visit(declSpec); } + @Override + public int leave(IASTDeclSpecifier declSpec) { + if (hasAppendsOnly(declSpec)) { + handleAppends(declSpec); + } + return super.leave(declSpec); + } + @Override public int visit(IASTExpression expression) { if (hasChangedChild(expression)) { @@ -383,13 +562,21 @@ public class ChangeGenerator extends ASTVisitor { @Override public int visit(IASTStatement statement) { - if (hasChangedChild(statement)) { + if (hasChangedChild(statement) && !hasAppendsOnly(statement)) { synthTreatment(statement); return ASTVisitor.PROCESS_SKIP; } return super.visit(statement); } + @Override + public int leave(IASTStatement statement) { + if (hasAppendsOnly(statement)) { + handleAppends(statement); + } + return super.leave(statement); + } + class CodeComparer { private final StringBuilder originalCode; private final StringBuilder synthCode; @@ -536,14 +723,6 @@ public class ChangeGenerator extends ASTVisitor { protected void createChange(MultiTextEdit edit, IASTNode changedNode) { int changeOffset = getOffsetIncludingComments(changedNode); - TextEditGroup editGroup = new TextEditGroup(Messages.ChangeGenerator_group); - for (ASTModification currentModification : modificationParent.get(changedNode)) { - if (currentModification.getAssociatedEditGroup() != null) { - editGroup = currentModification.getAssociatedEditGroup(); - edit.addChildren(editGroup.getTextEdits()); - break; - } - } createChange(edit, changeOffset); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGeneratorWriterVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGeneratorWriterVisitor.java index c5b9513d1c2..72537365b5d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGeneratorWriterVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGeneratorWriterVisitor.java @@ -84,10 +84,8 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor { this.fileScope = fileScope; this.shouldVisitTranslationUnit = true; this.stack = new ModificationScopeStack(modificationStore); - declaratorWriter = new ModifiedASTDeclaratorWriter(scribe, this, - stack, commentMap); - expWriter = new ModifiedASTExpressionWriter(scribe, this, macroHandler, - stack, commentMap); + declaratorWriter = new ModifiedASTDeclaratorWriter(scribe, this, stack, commentMap); + expWriter = new ModifiedASTExpressionWriter(scribe, this, macroHandler, stack, commentMap); statementWriter = new ModifiedASTStatementWriter(scribe, this, stack, commentMap); declSpecWriter = new ModifiedASTDeclSpecWriter(scribe, this, stack, commentMap); declarationWriter = new ModifiedASTDeclarationWriter(scribe, this, stack, commentMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclSpecWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclSpecWriter.java index e6de9cb3271..cd591419002 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclSpecWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclSpecWriter.java @@ -11,9 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.DeclSpecWriter; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; @@ -21,8 +21,8 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; public class ModifiedASTDeclSpecWriter extends DeclSpecWriter { private final ASTModificationHelper modificationHelper; - public ModifiedASTDeclSpecWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack, - NodeCommentMap commentMap) { + public ModifiedASTDeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, + ModificationScopeStack stack, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); this.modificationHelper = new ASTModificationHelper(stack); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclarationWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclarationWriter.java index 59e3953fad8..0ea61f3aaca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclarationWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclarationWriter.java @@ -12,11 +12,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.DeclarationWriter; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; @@ -24,21 +24,26 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; public class ModifiedASTDeclarationWriter extends DeclarationWriter { private final ASTModificationHelper modificationHelper; - public ModifiedASTDeclarationWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) { + public ModifiedASTDeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, + ModificationScopeStack stack, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); this.modificationHelper = new ASTModificationHelper(stack); } @Override - protected void writeDeclarationsInNamespace(ICPPASTNamespaceDefinition namespaceDefinition, IASTDeclaration[] declarations) { - IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray(namespaceDefinition, declarations, IASTDeclaration.class, commentMap); + protected void writeDeclarationsInNamespace(ICPPASTNamespaceDefinition namespaceDefinition, + IASTDeclaration[] declarations) { + IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray( + namespaceDefinition, declarations, IASTDeclaration.class, commentMap); super.writeDeclarationsInNamespace(namespaceDefinition, modifiedDeclarations); } @Override protected void writeCtorChainInitializer(ICPPASTFunctionDefinition funcDec, ICPPASTConstructorChainInitializer[] ctorInitChain) { - ICPPASTConstructorChainInitializer[] modifiedChainInitializer = modificationHelper.createModifiedChildArray(funcDec, ctorInitChain, ICPPASTConstructorChainInitializer.class, commentMap); - super.writeCtorChainInitializer(funcDec, modifiedChainInitializer); + ICPPASTConstructorChainInitializer[] modifiedInitializer = + modificationHelper.createModifiedChildArray(funcDec, ctorInitChain, + ICPPASTConstructorChainInitializer.class, commentMap); + super.writeCtorChainInitializer(funcDec, modifiedInitializer); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclaratorWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclaratorWriter.java index cb764ab7edb..b5d416a7721 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclaratorWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTDeclaratorWriter.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator; -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.IASTDeclaration; @@ -25,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; +import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.DeclaratorWriter; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; @@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; public class ModifiedASTDeclaratorWriter extends DeclaratorWriter { private final ASTModificationHelper modificationHelper; - public ModifiedASTDeclaratorWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) { + public ModifiedASTDeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); this.modificationHelper = new ASTModificationHelper(stack); } @@ -40,29 +40,31 @@ public class ModifiedASTDeclaratorWriter extends DeclaratorWriter { @Override protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec, IASTParameterDeclaration[] paraDecls) { - IASTParameterDeclaration[] modifiedParameters = modificationHelper - .createModifiedChildArray(funcDec, paraDecls, IASTParameterDeclaration.class, - commentMap); + IASTParameterDeclaration[] modifiedParameters = modificationHelper.createModifiedChildArray( + funcDec, paraDecls, IASTParameterDeclaration.class, commentMap); super.writeParameterDeclarations(funcDec, modifiedParameters); } @Override - protected void writePointerOperators(IASTDeclarator declarator,IASTPointerOperator[] unmodifiedPointerOperations) { + protected void writePointerOperators(IASTDeclarator declarator, + IASTPointerOperator[] unmodifiedPointerOperations) { IASTPointerOperator[] modifiedPointer = modificationHelper.createModifiedChildArray( declarator, unmodifiedPointerOperations, IASTPointerOperator.class, commentMap); super.writePointerOperators(declarator, modifiedPointer); } @Override - protected void writeArrayModifiers(IASTArrayDeclarator arrDecl, - IASTArrayModifier[] arrMods) { - IASTArrayModifier[] modifiedModifiers = modificationHelper.createModifiedChildArray(arrDecl, arrMods, IASTArrayModifier.class, commentMap); + protected void writeArrayModifiers(IASTArrayDeclarator arrDecl, IASTArrayModifier[] arrMods) { + IASTArrayModifier[] modifiedModifiers = modificationHelper.createModifiedChildArray(arrDecl, + arrMods, IASTArrayModifier.class, commentMap); super.writeArrayModifiers(arrDecl, modifiedModifiers); } @Override - protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, IASTTypeId[] exceptions ) { - IASTTypeId[] modifiedExceptions = modificationHelper.createModifiedChildArray(funcDec, exceptions, IASTTypeId.class, commentMap); + protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, + IASTTypeId[] exceptions) { + IASTTypeId[] modifiedExceptions = modificationHelper.createModifiedChildArray(funcDec, + exceptions, IASTTypeId.class, commentMap); // it makes a difference whether the exception array is identical to // ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION if (modifiedExceptions.length == 0 && @@ -74,18 +76,18 @@ public class ModifiedASTDeclaratorWriter extends DeclaratorWriter { } @Override - protected void writeKnRParameterDeclarations( - ICASTKnRFunctionDeclarator knrFunct, + protected void writeKnRParameterDeclarations(ICASTKnRFunctionDeclarator knrFunct, IASTDeclaration[] knrDeclarations) { - IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray(knrFunct, knrDeclarations, IASTDeclaration.class, commentMap); - + IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray( + knrFunct, knrDeclarations, IASTDeclaration.class, commentMap); super.writeKnRParameterDeclarations(knrFunct, modifiedDeclarations); } @Override - protected void writeKnRParameterNames( - ICASTKnRFunctionDeclarator knrFunct, IASTName[] parameterNames) { - IASTName[] modifiedNames = modificationHelper.createModifiedChildArray(knrFunct, parameterNames, IASTName.class, commentMap); + protected void writeKnRParameterNames(ICASTKnRFunctionDeclarator knrFunct, + IASTName[] parameterNames) { + IASTName[] modifiedNames = modificationHelper.createModifiedChildArray(knrFunct, + parameterNames, IASTName.class, commentMap); super.writeKnRParameterNames(knrFunct, modifiedNames); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java index 08262e57d24..609182ec194 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTExpressionWriter.java @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTInitializer; @@ -20,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind; +import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ExpressionWriter; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.MacroExpansionHandler; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe; @@ -28,7 +28,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; public class ModifiedASTExpressionWriter extends ExpressionWriter { private final ASTModificationHelper modificationHelper; - public ModifiedASTExpressionWriter(Scribe scribe, ASTVisitor visitor, MacroExpansionHandler macroHandler, + public ModifiedASTExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, ModificationScopeStack stack, NodeCommentMap commentMap) { super(scribe, visitor, macroHandler, commentMap); this.modificationHelper = new ASTModificationHelper(stack); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTStatementWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTStatementWriter.java index 0f5f0491941..9977fbbf7e3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTStatementWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ModifiedASTStatementWriter.java @@ -11,10 +11,10 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTStatement; +import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.StatementWriter; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; @@ -22,7 +22,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; public class ModifiedASTStatementWriter extends StatementWriter { private final ASTModificationHelper modificationHelper; - public ModifiedASTStatementWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) { + public ModifiedASTStatementWriter(Scribe scribe, ASTWriterVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) { super(scribe, visitor, commentMap); this.modificationHelper = new ASTModificationHelper(stack); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileContentHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileContentHelper.java index 6c8aaa8c51f..8fc40a49d76 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileContentHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileContentHelper.java @@ -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.internal.core.dom.rewrite.util; @@ -22,33 +22,29 @@ import org.eclipse.core.runtime.CoreException; /** * @author Emanuel Graf IFS - * */ public class FileContentHelper { - - private static final int bufferSize = 512; + private static final int BUFFER_SIZE = 2048; - public static String getContent(IFile file, int start) throws CoreException, IOException{ - + public static String getContent(IFile file, int start) throws CoreException, IOException { InputStreamReader reader = getReaderForFile(file); skip(start, reader); final String rest = readRest(reader); reader.close(); return rest; - } public static String getContent(IFile file, int start, int length) { try { InputStreamReader r = getReaderForFile(file); - char[] bytes = new char[length]; + char[] chars = new char[length]; skip(start, r); - read(length, r, bytes); + read(length, r, chars); r.close(); - return new String(bytes); + return new String(chars); } catch (IOException e) { CCorePlugin.log(e); } catch (CoreException e) { @@ -60,29 +56,26 @@ public class FileContentHelper { private static InputStreamReader getReaderForFile(IFile file) throws CoreException, UnsupportedEncodingException { InputStream contents = file.getContents(); - InputStreamReader r = new InputStreamReader(contents, file.getCharset()); - return r; + return new InputStreamReader(contents, file.getCharset()); } - private static String readRest(InputStreamReader reader) throws IOException{ + private static String readRest(InputStreamReader reader) throws IOException { StringBuilder content = new StringBuilder(); - char[] buffer = new char[bufferSize]; + char[] buffer = new char[BUFFER_SIZE]; int bytesRead = 0; - while((bytesRead = reader.read(buffer)) >= 0){ + while ((bytesRead = reader.read(buffer)) >= 0) { content.append(buffer, 0, bytesRead); } - return content.toString(); } - private static void read(int length, InputStreamReader r, char[] bytes) - throws IOException { + private static void read(int length, InputStreamReader r, char[] bytes) throws IOException { int bufferOffset = 0; int charactersRead = 0; - while(charactersRead >= 0 && length > 0){ + while (charactersRead >= 0 && length > 0) { charactersRead = r.read(bytes, bufferOffset, length); - if(charactersRead > 0){ + if (charactersRead > 0) { bufferOffset += charactersRead; length -= charactersRead; } @@ -91,12 +84,11 @@ public class FileContentHelper { private static void skip(int start, InputStreamReader r) throws IOException { long skipped = 0; - while(skipped >= 0 && start > 0 && r.ready()){ + while (skipped >= 0 && start > 0 && r.ready()) { skipped = r.skip(start); - if(skipped > 0){ + if (skipped > 0) { start -= skipped; } } } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileHelper.java index 6c7ad12c6bb..fe37d7df6f2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/FileHelper.java @@ -31,7 +31,7 @@ import org.eclipse.jface.text.TextUtilities; public class FileHelper { private static final String DEFAULT_LINE_DELIMITTER = "\n"; //$NON-NLS-1$ - public static IFile getIFilefromIASTNode(IASTNode node) { + public static IFile getFileFromNode(IASTNode node) { IPath implPath = new Path(node.getContainingFilename()); return ResourceLookup.selectFileForLocation(implPath, null); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/OffsetHelper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/OffsetHelper.java index ba7a270190a..fca0030ba54 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/OffsetHelper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/util/OffsetHelper.java @@ -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.internal.core.dom.rewrite.util; @@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author Emanuel Graf IFS - * */ public class OffsetHelper { @@ -32,10 +31,11 @@ public class OffsetHelper { if (location instanceof IASTMacroExpansionLocation) { IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location; offset = macroLoc.asFileLocation().getNodeOffset(); - }else { + } else { offset = location.asFileLocation().getNodeOffset(); } - if(offset < nodeStart) nodeStart = offset; + if (offset < nodeStart) + nodeStart = offset; } } else { nodeStart = node.getFileLocation().getNodeOffset(); @@ -55,14 +55,13 @@ public class OffsetHelper { IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location; fileOffset = macroLoc.asFileLocation().getNodeOffset(); length = macroLoc.asFileLocation().getNodeLength(); - }else { + } else { fileOffset = location.asFileLocation().getNodeOffset(); length = location.asFileLocation().getNodeLength(); } } } else { IASTFileLocation loc = node.getFileLocation(); - fileOffset = loc.getNodeOffset(); length = loc.getNodeLength(); } @@ -75,7 +74,7 @@ public class OffsetHelper { } public static int getLengthIncludingComment(IASTNode node) { - return OffsetHelper.getEndOffsetIncludingComments(node) - OffsetHelper.getOffsetIncludingComment(node); + return getEndOffsetIncludingComments(node) - getOffsetIncludingComment(node); } public static int getNodeOffset(ASTNode node) { @@ -92,6 +91,5 @@ public class OffsetHelper { public static int getEndingLineNumber(IASTNode node) { return node.getFileLocation().getEndingLineNumber(); - } - + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java index 74e05607504..1d85f7fd0b1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java @@ -81,6 +81,7 @@ public class CIndex implements IIndex { this(fragments, fragments.length); } + @Override public IIndexBinding findBinding(IName name) throws CoreException { if (name instanceof IIndexFragmentName) { return adaptBinding(((IIndexFragmentName) name).getBinding()); @@ -99,11 +100,13 @@ public class CIndex implements IIndex { return null; } + @Override public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException { return findBindings(new Pattern[] { pattern }, isFullyQualified, filter, monitor); } + @Override public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { @@ -133,6 +136,7 @@ public class CIndex implements IIndex { } } + @Override public IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { @@ -162,6 +166,7 @@ public class CIndex implements IIndex { } } + @Override public IIndexName[] findNames(IBinding binding, int flags) throws CoreException { LinkedList result= new LinkedList(); if (binding instanceof ICPPUsingDeclaration) { @@ -179,62 +184,37 @@ public class CIndex implements IIndex { binding= bindings[0]; } - // Maps a file location to -1 if the file belongs to an earlier index fragment, - // or to the index of the last checked index fragment plus one, if the file doesn't belong - // to any of the index fragments up to the last checked one. - HashMap fileCheckCache = new HashMap(); + // Collect the names from all fragments. Since the same file may be represented by multiple + // variants in one or more index fragments, we need to filter out duplicate names. + // See bug 192352. + HashSet encounteredNames = new HashSet(); for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragment fragment = fFragments[i]; - final IIndexFragmentName[] names = fragment.findNames(binding, flags); + final IIndexFragmentName[] names = fFragments[i].findNames(binding, flags); for (IIndexFragmentName name : names) { - IIndexFileLocation location = name.getFile().getLocation(); - Integer checkState = fileCheckCache.get(location); - int checkOffset = checkState == null ? 0 : checkState.intValue(); - if (checkOffset >= 0) { - for (; checkOffset < i; checkOffset++) { - IIndexFragment fragment2 = fFragments[checkOffset]; - if (fragment2.getFiles(location).length != 0) { - checkOffset = -1; - break; - } - } - fileCheckCache.put(location, Integer.valueOf(checkOffset)); - } - if (checkOffset == i) { + if (encounteredNames.add(new NameKey(name))) { result.add(name); } } } -// // bug 192352, files can reside in multiple fragments, remove duplicates -// if (fragCount > 1 || (flags & IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES) != 0) { -// HashMap fileMap= new HashMap(); -// for (Iterator iterator = result.iterator(); iterator.hasNext();) { -// final IIndexFragmentName name = iterator.next(); -// final IIndexFile file= name.getFile(); -// final String fileKey= name.getFile().getLocation().getURI().toString(); -// final IIndexFile otherFile= fileMap.get(fileKey); -// if (otherFile == null) { -// fileMap.put(fileKey, file); -// } else if (!otherFile.equals(file)) { // same file in another fragment -// iterator.remove(); -// } -// } -// } return result.toArray(new IIndexName[result.size()]); } + @Override public IIndexName[] findDeclarations(IBinding binding) throws CoreException { return findNames(binding, FIND_DECLARATIONS_DEFINITIONS); } + @Override public IIndexName[] findDefinitions(IBinding binding) throws CoreException { return findNames(binding, FIND_DEFINITIONS); } + @Override public IIndexName[] findReferences(IBinding binding) throws CoreException { return findNames(binding, FIND_REFERENCES); } + @Override @Deprecated public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException { for (int i = 0; i < fPrimaryFragmentCount; i++) { @@ -246,6 +226,7 @@ public class CIndex implements IIndex { return null; } + @Override public IIndexFile getFile(int linkageID, IIndexFileLocation location, ISignificantMacros significantMacros) throws CoreException { for (int i = 0; i < fPrimaryFragmentCount; i++) { @@ -257,6 +238,7 @@ public class CIndex implements IIndex { return null; } + @Override public IIndexFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException { if (location == null) { return IIndexFile.EMPTY_FILE_ARRAY; @@ -280,6 +262,7 @@ public class CIndex implements IIndex { return result.toArray(new IIndexFile[result.size()]); } + @Override public IIndexFile[] getFiles(IIndexFileLocation location) throws CoreException { if (location == null) { return IIndexFile.EMPTY_FILE_ARRAY; @@ -302,6 +285,7 @@ public class CIndex implements IIndex { return result.toArray(new IIndexFile[result.size()]); } + @Override public IIndexFile resolveInclude(IIndexInclude include) throws CoreException { IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include; IIndexFragmentFile result= fragmentInclude.getIncludes(); @@ -315,10 +299,12 @@ public class CIndex implements IIndex { return getFile(result.getLinkageID(), result.getLocation(), result.getSignificantMacros()); } + @Override public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException { return findIncludedBy(file, 0); } + @Override public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException { List result= new ArrayList(); findIncludedBy(file.getLinkageID(), Collections.singletonList(file), result, depth, @@ -354,10 +340,12 @@ public class CIndex implements IIndex { findIncludedBy(linkageID, nextLevel, out, depth, handled); } + @Override public IIndexInclude[] findIncludes(IIndexFile file) throws CoreException { return findIncludes(file, 0); } + @Override public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException { List result= new ArrayList(); findIncludes(Collections.singletonList(file), result, depth, new HashSet()); @@ -393,6 +381,7 @@ public class CIndex implements IIndex { findIncludes(nextLevel, out, depth, handled); } + @Override public synchronized void acquireReadLock() throws InterruptedException { if (++fReadLock == 1) { int i= 0; @@ -412,6 +401,7 @@ public class CIndex implements IIndex { } } + @Override public synchronized void releaseReadLock() { if (--fReadLock == 0) { for (IIndexFragment fragment : fFragments) { @@ -424,6 +414,7 @@ public class CIndex implements IIndex { return fReadLock; } + @Override public boolean hasWaitingReaders() { for (IIndexFragment fragment : fFragments) { if (fragment.hasWaitingReaders()) { @@ -433,6 +424,7 @@ public class CIndex implements IIndex { return false; } + @Override public long getLastWriteAccess() { long result= 0; for (IIndexFragment fragment : fFragments) { @@ -441,6 +433,7 @@ public class CIndex implements IIndex { return result; } + @Override public IIndexBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { @@ -477,10 +470,10 @@ public class CIndex implements IIndex { } monitor.done(); return flatten(result); - } } + @Override public IIndexBinding adaptBinding(IBinding binding) { try { if (SPECIALCASE_SINGLES && fFragments.length == 1) { @@ -499,6 +492,7 @@ public class CIndex implements IIndex { return null; } + @Override public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException { return findBindings(name, true, filter, monitor); @@ -578,6 +572,7 @@ public class CIndex implements IIndex { }; } + @Override public IIndexBinding[] findBindingsForPrefix(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { @@ -607,6 +602,7 @@ public class CIndex implements IIndex { } } + @Override public IIndexBinding[] findBindingsForContentAssist(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { @@ -636,6 +632,7 @@ public class CIndex implements IIndex { } } + @Override public IIndexBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { @@ -665,10 +662,12 @@ public class CIndex implements IIndex { } } + @Override public IIndexMacro[] findMacros(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException { return findMacros(name, false, true, filter, monitor); } + @Override public IIndexMacro[] findMacrosForPrefix(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException { return findMacros(name, true, false, filter, monitor); @@ -676,7 +675,7 @@ public class CIndex implements IIndex { private IIndexMacro[] findMacros(char[] name, boolean isPrefix, boolean caseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException { - // macros can be represented multiple times when a header is parsed in c- and c++ context, + // Macros can be represented multiple times when a header is parsed in c- and c++ context, // so there is no special case for indexes with single fragments. if (monitor == null) { monitor= new NullProgressMonitor(); @@ -736,10 +735,12 @@ public class CIndex implements IIndex { } } + @Override public IIndexFileSet createFileSet() { return new IndexFileSet(); } + @Override public IIndexFile[] getAllFiles() throws CoreException { HashMap result= new HashMap(); for (IIndexFragment fragment : fFragments) { @@ -752,9 +753,7 @@ public class CIndex implements IIndex { return result.values().toArray(new IIndexFile[result.size()]); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.index.IIndex#getInlineNamespaces() - */ + @Override public IIndexScope[] getInlineNamespaces() throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { return fFragments[0].getInlineNamespaces(); @@ -768,11 +767,52 @@ public class CIndex implements IIndex { arr[j]= (IIndexFragmentBinding) raw[j].getScopeBinding(); } } - IIndexBinding[] compBinding = getCompositesFactory(ILinkage.CPP_LINKAGE_ID).getCompositeBindings(preresult); + IIndexBinding[] compBinding = + getCompositesFactory(ILinkage.CPP_LINKAGE_ID).getCompositeBindings(preresult); IIndexScope[] result = new IIndexScope[compBinding.length]; for (int i = 0; i < result.length; i++) { result[i]= (IIndexScope) ((ICPPNamespace) compBinding[i]).getNamespaceScope(); } return result; } + + /** + * A key used to uniquely identify an IIndexFragmentName object. Uniqueness is guaranteed only + * for names corresponding to the same binding. + */ + private static final class NameKey { + private final IIndexFileLocation location; + private final int linkageID; + private final int offset; + + NameKey(IIndexFragmentName name) throws CoreException { + IIndexFile file = name.getFile(); + location = file.getLocation(); + linkageID = file.getLinkageID(); + offset = name.getNodeOffset(); + } + + @Override + public int hashCode() { + return (location.hashCode() * 31 + linkageID) * 31 + offset; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NameKey other = (NameKey) obj; + if (offset != other.offset) + return false; + if (linkageID != other.linkageID) + return false; + if (!location.equals(other.location)) + return false; + return true; + } + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileLocation.java index caddbd0761f..b7a2207d829 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileLocation.java @@ -28,26 +28,16 @@ public class IndexFileLocation implements IIndexFileLocation { this.fullPath = fullPath; } - /* - * (non-Javadoc) - * @see org.eclipse.cdt.core.index.IIndexFileLocation#getFullPath() - */ + @Override public String getFullPath() { return fullPath; } - /* - * (non-Javadoc) - * @see org.eclipse.cdt.core.index.IIndexFileLocation#getURI() - */ + @Override public URI getURI() { return uri; } - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public boolean equals(Object obj) { if (obj instanceof IIndexFileLocation) { @@ -56,10 +46,6 @@ public class IndexFileLocation implements IIndexFileLocation { return false; } - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ @Override public int hashCode() { return uri.hashCode(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java index dac2a04cdc1..a896f2a3f58 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java @@ -89,6 +89,7 @@ public class PDOMFile implements IIndexFragmentFile { this.db = db; } + @Override public int compare(long record1, long record2) throws CoreException { IString name1 = db.getString(db.getRecPtr(record1 + LOCATION_REPRESENTATION)); IString name2 = db.getString(db.getRecPtr(record2 + LOCATION_REPRESENTATION)); @@ -215,6 +216,7 @@ public class PDOMFile implements IIndexFragmentFile { sourceFile.delete(); } + @Override public void transferIncluders(IIndexFragmentFile sourceFile) throws CoreException { PDOMFile source= (PDOMFile) sourceFile; PDOMInclude include = source.getFirstIncludedBy(); @@ -239,6 +241,7 @@ public class PDOMFile implements IIndexFragmentFile { } } + @Override public void transferContext(IIndexFragmentFile sourceFile) throws CoreException { PDOMFile source= (PDOMFile) sourceFile; PDOMInclude include = source.getFirstIncludedBy(); @@ -288,49 +291,59 @@ public class PDOMFile implements IIndexFragmentFile { location= null; } + @Override public int getLinkageID() throws CoreException { Database db = fLinkage.getDB(); return db.get3ByteUnsignedInt(record + LINKAGE_ID); } + @Override public long getTimestamp() throws CoreException { Database db = fLinkage.getDB(); return db.getLong(record + TIME_STAMP); } + @Override public void setTimestamp(long timestamp) throws CoreException { Database db= fLinkage.getDB(); db.putLong(record + TIME_STAMP, timestamp); } + @Override public long getContentsHash() throws CoreException { Database db = fLinkage.getDB(); return db.getLong(record + CONTENT_HASH); } + @Override public void setContentsHash(long hash) throws CoreException { Database db= fLinkage.getDB(); db.putLong(record + CONTENT_HASH, hash); } + @Override public int getScannerConfigurationHashcode() throws CoreException { return 0; } + @Override public int getEncodingHashcode() throws CoreException { Database db = fLinkage.getDB(); return db.getInt(record + ENCODING_HASH); } + @Override public void setEncodingHashcode(int hashcode) throws CoreException { Database db= fLinkage.getDB(); db.putInt(record + ENCODING_HASH, hashcode); } + @Override public boolean hasPragmaOnceSemantics() throws CoreException { return (fLinkage.getDB().getByte(record + FLAGS) & FLAG_PRAGMA_ONCE_SEMANTICS) != 0; } + @Override public void setPragmaOnceSemantics(boolean value) throws CoreException { Database db = fLinkage.getDB(); byte flags = db.getByte(record + FLAGS); @@ -377,6 +390,7 @@ public class PDOMFile implements IIndexFragmentFile { return rec != 0 ? new PDOMInclude(fLinkage, rec) : null; } + @Override public IIndexInclude getParsedInContext() throws CoreException { return getFirstIncludedBy(); } @@ -613,6 +627,7 @@ public class PDOMFile implements IIndexFragmentFile { } } + @Override public IIndexInclude[] getIncludes() throws CoreException { List result= new ArrayList(); PDOMInclude include = getFirstInclude(); @@ -623,6 +638,7 @@ public class PDOMFile implements IIndexFragmentFile { return result.toArray(new IIndexInclude[result.size()]); } + @Override public IIndexMacro[] getMacros() throws CoreException { List result= new ArrayList(); PDOMMacro macro = getFirstMacro(); @@ -633,10 +649,12 @@ public class PDOMFile implements IIndexFragmentFile { return result.toArray(new IIndexMacro[result.size()]); } + @Override public IIndexFragment getIndexFragment() { return fLinkage.getPDOM(); } + @Override public IIndexName[] findNames(int offset, int length) throws CoreException { ArrayList result= new ArrayList(); for (PDOMName name= getFirstName(); name != null; name= name.getNextInFile()) { @@ -788,6 +806,7 @@ public class PDOMFile implements IIndexFragmentFile { return records; } + @Override public int compare(long record) throws CoreException { IString name = db.getString(db.getRecPtr(record + PDOMFile.LOCATION_REPRESENTATION)); int cmp= name.compare(rawKey, true); @@ -810,6 +829,7 @@ public class PDOMFile implements IIndexFragmentFile { return rec != 0 ? db.getString(rec) : null; } + @Override public boolean visit(long record) throws CoreException { if (rawSignificantMacros != null) { this.record = record; @@ -836,6 +856,7 @@ public class PDOMFile implements IIndexFragmentFile { } } + @Override public IIndexFileLocation getLocation() throws CoreException { if (location == null) { Database db = fLinkage.getDB(); @@ -856,6 +877,7 @@ public class PDOMFile implements IIndexFragmentFile { } + @Override public ISignificantMacros getSignificantMacros() throws CoreException { if (sigMacros == null) { Database db= fLinkage.getDB(); @@ -865,6 +887,7 @@ public class PDOMFile implements IIndexFragmentFile { return sigMacros; } + @Override public boolean hasContent() throws CoreException { return getTimestamp() != -1; } @@ -890,9 +913,7 @@ public class PDOMFile implements IIndexFragmentFile { fLinkage.getDB().putRecPtr(record + LAST_USING_DIRECTIVE, rec); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.index.IIndexFile#getUsingDirectives() - */ + @Override public ICPPUsingDirective[] getUsingDirectives() throws CoreException { return fLinkage.getUsingDirectives(this); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java index 0ad5f9b5e16..3186172f93a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/CodeFormatter.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.core.formatter; import java.util.Map; +import org.eclipse.jface.text.IRegion; import org.eclipse.text.edits.TextEdit; /** @@ -64,15 +65,15 @@ public abstract class CodeFormatter { public static final int K_MULTI_LINE_COMMENT = 0x20; /** - * Format source, - * and returns a text edit that correspond to the difference between the given string and - * the formatted string. It returns null if the given string cannot be formatted. + * Formats source, and returns a text edit that correspond to the difference + * between the given string and the formatted string. It returns null if the given string cannot + * be formatted. * * If the offset position is matching a whitespace, the result can include whitespaces. * It would be up to the caller to get rid of preceding whitespaces. * * @param kind Use to specify the kind of the code snippet to format. It can be any of these: - * K_EXPRESSION, K_STATEMENTS, K_CLASS_BODY_DECLARATIONS, K_TRANSLATION_UNIT, K_UNKNOWN + * K_EXPRESSION, K_STATEMENTS, K_CLASS_BODY_DECLARATIONS, K_TRANSLATION_UNIT, K_UNKNOWN * @param source the document to format * @param offset the given offset to start recording the edits (inclusive). * @param length the given length to stop recording the edits (exclusive). @@ -87,7 +88,36 @@ public abstract class CodeFormatter { */ public abstract TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator); - + + /** + * Formats one or more regions of source, and returns an array of edits, one edit + * per region. If some of the regions cannot be formatted, the corresponding elements of + * the returned array will be null. + * + * If the offset of a region is matching a whitespace, the result can include whitespaces. + * It would be up to the caller to get rid of preceding whitespaces. + * + * Subclasses may override this method to provide a more efficient implementation. + * + * @param kind Use to specify the kind of the code snippet to format. It can be any of these: + * K_EXPRESSION, K_STATEMENTS, K_CLASS_BODY_DECLARATIONS, K_TRANSLATION_UNIT, K_UNKNOWN. + * @param source the document to format. + * @param regions regions of the source to be formatted. + * @param lineSeparator the line separator to use in formatted source, + * if set to null, then the platform default one will be used. + * @return the text edits, one per region. + * @throws IllegalArgumentException if any of the regions is invalid. + * @since 5.4 + */ + public TextEdit[] format(int kind, String source, IRegion[] regions, String lineSeparator) { + TextEdit[] edits = new TextEdit[regions.length]; + for (int i = 0; i < regions.length; i++) { + IRegion region = regions[i]; + edits[i] = format(kind, source, region.getOffset(), region.getLength(), 0, lineSeparator); + } + return edits; + } + /** * @param options - general formatter options */ diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java index 12a08dbb697..bdc678c626a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java @@ -7,7 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation - * Sergey Prigogin, Google + * Sergey Prigogin (Google) * Anton Leherbauer (Wind River Systems) * IBM Corporation *******************************************************************************/ @@ -34,6 +34,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.text.edits.TextEdit; +import org.eclipse.jface.text.IRegion; public class CCodeFormatter extends CodeFormatter { private DefaultCodeFormatterOptions preferences; @@ -117,9 +118,6 @@ public class CCodeFormatter extends CodeFormatter { } } - /* - * @see org.eclipse.cdt.core.formatter.CodeFormatter#format(int, java.lang.String, int, int, int, java.lang.String) - */ @Override public TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator) { TextEdit edit= null; @@ -188,4 +186,80 @@ public class CCodeFormatter extends CodeFormatter { } return edit; } + + @Override + public TextEdit[] format(int kind, String source, IRegion[] regions, String lineSeparator) { + TextEdit[] edits= new TextEdit[regions.length]; + ITranslationUnit tu= (ITranslationUnit) options.get(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT); + if (tu == null) { + IFile file= (IFile) options.get(DefaultCodeFormatterConstants.FORMATTER_CURRENT_FILE); + if (file != null) { + tu= (ITranslationUnit) CoreModel.getDefault().create(file); + } + } + if (lineSeparator != null) { + preferences.line_separator = lineSeparator; + } else { + preferences.line_separator = System.getProperty("line.separator"); //$NON-NLS-1$ + } + + if (tu != null) { + IIndex index; + try { + index = CCorePlugin.getIndexManager().getIndex(tu.getCProject()); + index.acquireReadLock(); + } catch (CoreException e) { + throw new AbortFormatting(e); + } catch (InterruptedException e) { + return null; + } + IASTTranslationUnit ast; + try { + try { + ast= tu.getAST(index, ITranslationUnit.AST_SKIP_ALL_HEADERS); + } catch (CoreException exc) { + throw new AbortFormatting(exc); + } + for (int i = 0; i < regions.length; i++) { + IRegion region = regions[i]; + CodeFormatterVisitor codeFormatter = + new CodeFormatterVisitor(preferences, region.getOffset(), region.getLength()); + edits[i] = codeFormatter.format(source, ast); + IStatus status= codeFormatter.getStatus(); + if (!status.isOK()) { + CCorePlugin.log(status); + } + } + } finally { + index.releaseReadLock(); + } + } else { + IncludeFileContentProvider contentProvider = IncludeFileContentProvider.getSavedFilesProvider(); + IScannerInfo scanInfo = new ScannerInfo(); + FileContent content = FileContent.create("", source.toCharArray()); //$NON-NLS-1$ + + ILanguage language= (ILanguage) options.get(DefaultCodeFormatterConstants.FORMATTER_LANGUAGE); + if (language == null) { + language= GPPLanguage.getDefault(); + } + IASTTranslationUnit ast; + try { + ast= language.getASTTranslationUnit(content, scanInfo, contentProvider, null, 0, + ParserUtil.getParserLogService()); + for (int i = 0; i < regions.length; i++) { + IRegion region = regions[i]; + CodeFormatterVisitor codeFormatter = + new CodeFormatterVisitor(preferences, region.getOffset(), region.getLength()); + edits[i]= codeFormatter.format(source, ast); + IStatus status= codeFormatter.getStatus(); + if (!status.isOK()) { + CCorePlugin.log(status); + } + } + } catch (CoreException e) { + throw new AbortFormatting(e); + } + } + return edits; + } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index b6808425482..fa373722958 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -187,7 +187,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - /* + /** * Formats a given token at a given position. * @see #formatList(List, ListOptions, boolean, boolean, Runnable) */ @@ -211,6 +211,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, spaceBeforeToken, spaceAfterToken); } + @Override public void run() { int offset = scribe.scanner.getCurrentPosition(); if (tokenPosition < 0 || offset > tokenPosition) @@ -229,7 +230,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - /* + /** * Formats a trailing semicolon. * @see #formatList(List, ListOptions, boolean, boolean, Runnable) */ @@ -242,7 +243,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - /* + /** * Formats the part of a function declaration following the parameter list. * @see #formatList(List, ListOptions, boolean, boolean, Runnable) */ @@ -256,6 +257,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, this.continuationFormatter = tailFormatter; } + @Override public void run() { boolean needSpace = skipConstVolatileRestrict(); int token = peekNextToken(); @@ -303,6 +305,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } + /** + * Formats a trailing semicolon. + * @see #formatList(List, ListOptions, boolean, boolean, Runnable) + */ private class ClosingParensesisTailFormatter implements Runnable { private final boolean spaceBeforeClosingParen; private final Runnable continuationFormatter; @@ -315,6 +321,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, this.parenPosition = scribe.findToken(Token.tRPAREN); } + @Override public void run() { int offset = scribe.scanner.getCurrentPosition(); if (parenPosition >= 0 && offset <= parenPosition) { @@ -783,17 +790,18 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } IASTName name= node.getName(); - if (name != null && name.getSimpleID().length != 0) { + IASTDeclarator nestedDecl= node.getNestedDeclarator(); + if (name != null && name.getSimpleID().length != 0 || nestedDecl != null) { if (node.getPropertyInParent() != IASTDeclarator.NESTED_DECLARATOR && isFirstDeclarator(node)) { - // Preserve non-space between pointer operator and name + // Preserve non-space between pointer operator and name or nested declarator. if (pointerOperators.length == 0 || scribe.printComment()) { scribe.space(); } } - name.accept(this); + if (name != null) + name.accept(this); } - IASTDeclarator nestedDecl= node.getNestedDeclarator(); if (nestedDecl != null) { scribe.printNextToken(Token.tLPAREN, false); nestedDecl.accept(this); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java index eb1dd7f967c..85e3ff3c7c6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java @@ -132,22 +132,29 @@ public class Scribe { } private final void addDeleteEdit(int start, int end) { - if (edits.length == editsIndex) { - resize(); - } addOptimizedReplaceEdit(start, end - start + 1, EMPTY_STRING); } public final void addInsertEdit(int insertPosition, CharSequence insertedString) { - if (edits.length == editsIndex) { - resize(); - } addOptimizedReplaceEdit(insertPosition, 0, insertedString); } + /** + * Adds a replace edit. + * @param start start offset (inclusive) + * @param end end offset (inclusive) + * @param replacement the replacement string + */ + public final void addReplaceEdit(int start, int end, CharSequence replacement) { + addOptimizedReplaceEdit(start, end - start + 1, replacement); + } + private final void addOptimizedReplaceEdit(int offset, int length, CharSequence replacement) { + if (edits.length == editsIndex) { + resize(); + } if (editsIndex > 0) { - // try to merge last two edits + // Try to merge last two edits final OptimizedReplaceEdit previous= edits[editsIndex - 1]; final int previousOffset= previous.offset; final int previousLength= previous.length; @@ -170,7 +177,8 @@ public class Scribe { if (endOffsetOfPreviousEdit == offset) { if (length != 0) { if (replacementLength != 0) { - edits[editsIndex - 1]= new OptimizedReplaceEdit(previousOffset, previousLength + length, + editsIndex--; + appendOptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement + replacement); } else if (previousLength + length == previousReplacementLength) { // Check the characters. If they are identical, @@ -178,8 +186,9 @@ public class Scribe { boolean canBeRemoved= true; loop: for (int i= previousOffset; i < previousOffset + previousReplacementLength; i++) { if (scanner.source[i] != previousReplacement.charAt(i - previousOffset)) { - edits[editsIndex - 1]= new OptimizedReplaceEdit(previousOffset, - previousReplacementLength, previousReplacement); + editsIndex--; + appendOptimizedReplaceEdit(previousOffset, previousReplacementLength, + previousReplacement); canBeRemoved= false; break loop; } @@ -195,35 +204,45 @@ public class Scribe { editsIndex--; } } else { - edits[editsIndex - 1]= new OptimizedReplaceEdit(previousOffset, previousLength + length, + editsIndex--; + appendOptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement); } } else { if (replacementLength != 0) { - edits[editsIndex - 1]= new OptimizedReplaceEdit(previousOffset, previousLength, + editsIndex--; + appendOptimizedReplaceEdit(previousOffset, previousLength, previousReplacement + replacement); } } } else { assert endOffsetOfPreviousEdit < offset; - edits[editsIndex++]= new OptimizedReplaceEdit(offset, length, replacement); + appendOptimizedReplaceEdit(offset, length, replacement); } } else { - edits[editsIndex++]= new OptimizedReplaceEdit(offset, length, replacement); + appendOptimizedReplaceEdit(offset, length, replacement); } } /** - * Add a replace edit. - * @param start start offset (inclusive) - * @param end end offset (inclusive) - * @param replacement the replacement string + * Trims redundant prefix from a replacement edit and, if there is anything left, appends + * the replacement edit to the edits array. */ - public final void addReplaceEdit(int start, int end, String replacement) { - if (edits.length == editsIndex) { - resize(); + private void appendOptimizedReplaceEdit(int offset, int length, CharSequence replacement) { + int replacementLength = replacement.length(); + int i; + for (i = 0; i < length && i < replacementLength; i++, offset++) { + if (scanner.source[offset] != replacement.charAt(i)) + break; + } + length -= i; + if (i > 0) { + replacement = i == replacementLength ? + EMPTY_STRING : replacement.subSequence(i, replacementLength); + } + if (length > 0 || replacement.length() > 0) { + edits[editsIndex++]= new OptimizedReplaceEdit(offset, length, replacement); } - addOptimizedReplaceEdit(start, end - start + 1, replacement); } public void alignFragment(Alignment alignment, int fragmentIndex) { @@ -562,7 +581,7 @@ public class Scribe { edit= new MultiTextEdit(0, textRegionEnd + 1); } } else { - edit= new MultiTextEdit(textRegionStart, textRegionEnd - textRegionStart + 1); + edit= new MultiTextEdit(textRegionStart, length); } for (int i= 0, max= editsIndex; i < max; i++) { OptimizedReplaceEdit currentEdit= edits[i]; @@ -1452,17 +1471,18 @@ public class Scribe { private void printEmptyLines(int linesNumber, int insertPosition) { final String buffer= getEmptyLines(linesNumber); - if (EMPTY_STRING == buffer) - return; - - addInsertEdit(insertPosition, buffer); + if (!buffer.isEmpty()) { + addInsertEdit(insertPosition, buffer); + } } void printIndentationIfNecessary() { + if (column > indentationLevel) + return; StringBuilder buffer= new StringBuilder(); printIndentationIfNecessary(buffer); if (buffer.length() > 0) { - addInsertEdit(scanner.getCurrentTokenStartPosition(), buffer.toString()); + addInsertEdit(scanner.getCurrentTokenStartPosition(), buffer); pendingSpace= false; } } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java index e536b53d38f..e4517d1523a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java @@ -34,9 +34,6 @@ public class SimpleScanner { private boolean fSplitPreprocessor; private final StringBuilder fUniversalCharBuffer= new StringBuilder(); - /** - * - */ public SimpleScanner() { super(); } @@ -736,8 +733,7 @@ public class SimpleScanner { matchStringLiteral(); c= getChar(); break; - } - else { + } else { ungetChar(c); return newPreprocessorToken(); } @@ -752,8 +748,7 @@ public class SimpleScanner { ungetChar(next); ungetChar(c); result= newPreprocessorToken(); - } - else { + } else { matchSinglelineComment(); result= newToken(Token.tLINECOMMENT); } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/DefinitionFinder.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/DefinitionFinder.rts index 0fbde7fc777..32b1c87152f 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/DefinitionFinder.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/DefinitionFinder.rts @@ -13,8 +13,6 @@ void foo(); //@A.cpp #include "A.h" -void foo() -{ - +void foo() { } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts index 741b028f6a8..52391193643 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts @@ -4,8 +4,7 @@ #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -20,14 +19,13 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); void bar(); - static const int theAnswer = 42; + static const int theAnswer = 42; }; #endif /*A_H_*/ @@ -36,21 +34,17 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - return /*$*/42/*$$*/; //Hallo +int A::foo() { + return /*$*/42/*$$*/; //Hello } -void A::bar() -{ +void A::bar() { int a = 42; int b = 42; } @@ -58,21 +52,17 @@ void A::bar() //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - return theAnswer; //Hallo +int A::foo() { + return theAnswer; //Hello } -void A::bar() -{ +void A::bar() { int a = theAnswer; int b = theAnswer; } @@ -83,8 +73,7 @@ void A::bar() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -99,14 +88,13 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); void bar(); - static const int theAnswer = 42; + static const int theAnswer = 42; }; #endif /*A_H_*/ @@ -115,22 +103,18 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { //Hallo return /*$*/42/*$$*/; } -void A::bar() -{ +void A::bar() { int a = 42; int b = 42; } @@ -138,22 +122,18 @@ void A::bar() //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { //Hallo return theAnswer; } -void A::bar() -{ +void A::bar() { int a = theAnswer; int b = theAnswer; } @@ -164,8 +144,7 @@ void A::bar() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -180,14 +159,13 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); float foo(); void bar(); - static const float theAnswer = 42.0f; + static const float theAnswer = 42.0f; }; #endif /*A_H_*/ @@ -196,21 +174,17 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -float A::foo() -{ +float A::foo() { return /*$*/42.0f/*$$*/; } -void A::bar() -{ +void A::bar() { float a = 42.0f; float b = 42.0f; } @@ -218,21 +192,17 @@ void A::bar() //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -float A::foo() -{ +float A::foo() { return theAnswer; } -void A::bar() -{ +void A::bar() { float a = theAnswer; float b = theAnswer; } @@ -243,8 +213,7 @@ void A::bar() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -259,14 +228,13 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); double foo(); void bar(); - static const double theAnswer = 42.0; + static const double theAnswer = 42.0; }; #endif /*A_H_*/ @@ -275,21 +243,17 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -double A::foo() -{ +double A::foo() { return /*$*/42.0/*$$*/; } -void A::bar() -{ +void A::bar() { double a = 42.0; double b = 42.0; } @@ -297,21 +261,17 @@ void A::bar() //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -double A::foo() -{ +double A::foo() { return theAnswer; } -void A::bar() -{ +void A::bar() { double a = theAnswer; double b = theAnswer; } @@ -322,8 +282,7 @@ void A::bar() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -337,8 +296,7 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -351,51 +309,43 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return 42; } -int bar() -{ +int bar() { return /*$*/42/*$$*/; } - //= #include "A.h" -namespace -{ - const int theAnswer = 42; -} -A::A() -{ +namespace { + +const int theAnswer = 42; + } -A::~A() -{ +A::A() { } -int A::foo() -{ +A::~A() { +} + +int A::foo() { return theAnswer; } -int bar() -{ +int bar() { return theAnswer; } - //!replaceNumberProtected //#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest //@.config @@ -404,8 +354,7 @@ visibility=protected #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -418,14 +367,14 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + protected: - static const int theAnswer = 42; + static const int theAnswer = 42; }; #endif /*A_H_*/ @@ -433,32 +382,26 @@ protected: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return /*$*/42/*$$*/; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return theAnswer; } @@ -470,8 +413,7 @@ visibility=private #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -484,14 +426,14 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + private: - static const int theAnswer = 42; + static const int theAnswer = 42; }; #endif /*A_H_*/ @@ -499,32 +441,26 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return /*$*/42/*$$*/; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return theAnswer; } @@ -535,18 +471,18 @@ filename=A.h //@A.h class X { void method() { - int a= /*$*/42/*$$*/; + int a = /*$*/42/*$$*/; } }; //= class X { void method() { - int a= theAnswer; - } + int a = theAnswer; + } public: - static const int theAnswer = 42; + static const int theAnswer = 42; }; //!ExtractConstantString @@ -556,30 +492,26 @@ visibility=private filename=A.h //@A.h class X { - void method() - { - char *a = /*$*/"sometext"/*$$*/; - } - - void method2() - { - const char *b = "sometext"; - } + void method() { + char* a = /*$*/"sometext"/*$$*/; + } + + void method2() { + const char* b = "sometext"; + } }; //= class X { - void method() - { - char *a = theAnswer; - } + void method() { + char* a = theAnswer; + } - void method2() - { - const char *b = theAnswer; - } + void method2() { + const char* b = theAnswer; + } - static const char *theAnswer = "sometext"; + static const char* theAnswer = "sometext"; }; //!ExtractConstantWideString @@ -589,31 +521,27 @@ visibility=private filename=A.h //@A.h class X { - void method() - { - wchar_t *a = /*$*/L"sometext"/*$$*/; - } - - void method2() - { - const wchar_t *b = L"sometext"; - const char *c = "sometext"; - } + void method() { + wchar_t* a = /*$*/L"sometext"/*$$*/; + } + + void method2() { + const wchar_t* b = L"sometext"; + const char* c = "sometext"; + } }; //= class X { - void method() - { - wchar_t *a = theAnswer; - } + void method() { + wchar_t* a = theAnswer; + } - void method2() - { - const wchar_t *b = theAnswer; - const char *c = "sometext"; - } + void method2() { + const wchar_t* b = theAnswer; + const char* c = "sometext"; + } - static const wchar_t *theAnswer = L"sometext"; + static const wchar_t* theAnswer = L"sometext"; }; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstantHistory.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstantHistory.rts index ad7301cdaea..10835096456 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstantHistory.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstantHistory.rts @@ -4,8 +4,7 @@ #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -19,14 +18,13 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); void bar(); - static const int theAnswer = 42; + static const int theAnswer = 42; }; #endif /*A_H_*/ @@ -34,21 +32,17 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - return 42; //Hallo +int A::foo() { + return 42; // Hello } -void A::bar() -{ +void A::bar() { int a = 42; int b = 42; } @@ -56,21 +50,17 @@ void A::bar() //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - return theAnswer; //Hallo +int A::foo() { + return theAnswer; // Hello } -void A::bar() -{ +void A::bar() { int a = theAnswer; int b = theAnswer; } @@ -91,8 +81,7 @@ project="RegressionTestProject" selection="64,2" visibility="public"/> #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -105,14 +94,14 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + protected: - static const int theAnswer = 42; + static const int theAnswer = 42; }; #endif /*A_H_*/ @@ -120,32 +109,26 @@ protected: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return 42; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return theAnswer; } @@ -164,8 +147,7 @@ project="RegressionTestProject" selection="64,2" visibility="protected"/> #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); @@ -178,14 +160,14 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + private: - static const int theAnswer = 42; + static const int theAnswer = 42; }; #endif /*A_H_*/ @@ -193,32 +175,26 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return 42; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { return theAnswer; } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts index ce5138b2e27..2381a7d7510 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts @@ -6,43 +6,38 @@ filename=test.cpp methodname=check //@test.h -class Test -{ - void test(); +class Test { + void test(); }; //= -class Test -{ - void test(); - bool check(); +class Test { + void test(); + bool check(); }; //@test.cpp #include "test.h" -void Test::test() -{ - if(/*$*/5 == 3 + 2/*$$*/) { +void Test::test() { + if (/*$*/5 == 3 + 2/*$$*/) { //... - } + } } //= #include "test.h" -bool Test::check() -{ - return 5 == 3 + 2; +bool Test::check() { + return 5 == 3 + 2; } -void Test::test() -{ - if(check()) { +void Test::test() { + if (check()) { //... - } + } } //!Extract boolean comparison from if-condition with parameter. @@ -53,45 +48,40 @@ filename=test.cpp methodname=check //@test.h -class Test -{ - void test(); +class Test { + void test(); }; //= -class Test -{ - void test(); - bool check(int num); +class Test { + void test(); + bool check(int num); }; //@test.cpp #include "test.h" -void Test::test() -{ - int num = 1; - if(/*$*/5 != 3 + num/*$$*/) { +void Test::test() { + int num = 1; + if (/*$*/5 != 3 + num/*$$*/) { //... - } + } } //= #include "test.h" -bool Test::check(int num) -{ - return 5 != 3 + num; +bool Test::check(int num) { + return 5 != 3 + num; } -void Test::test() -{ - int num = 1; - if(check(num)) { +void Test::test() { + int num = 1; + if (check(num)) { //... - } + } } //!Extract binary expression that results in a function with the same return type (BasicType) as the LHS. @@ -102,43 +92,38 @@ filename=test.cpp methodname=add //@test.h -class Test -{ - void test(); +class Test { + void test(); }; //= -class Test -{ - void test(); - int add(int five, int six); +class Test { + void test(); + int add(int five, int six); }; //@test.cpp #include "test.h" -void Test::test() -{ +void Test::test() { int five = 5; int six = 6; - int result = /*$*/five + six/*$$*/; + int result = /*$*/five + six/*$$*/; } //= #include "test.h" -int Test::add(int five, int six) -{ - return five + six; +int Test::add(int five, int six) { + return five + six; } -void Test::test() -{ +void Test::test() { int five = 5; int six = 6; - int result = add(five, six); + int result = add(five, six); } //!Extract binary expression that results in a function with the same return type (ClassType) as the LHS @@ -151,45 +136,40 @@ methodname=cat //@test.h struct helper {}; -class Test -{ - void test(); +class Test { + void test(); }; //= struct helper {}; -class Test -{ - void test(); - helper cat(helper s1, helper s2); +class Test { + void test(); + helper cat(helper s1, helper s2); }; //@test.cpp #include "test.h" -void Test::test() -{ +void Test::test() { helper s1 = "a"; helper s2 = "b"; - helper result = /*$*/s1 + s2/*$$*/; + helper result = /*$*/s1 + s2/*$$*/; } //= #include "test.h" -helper Test::cat(helper s1, helper s2) -{ - return s1 + s2; +helper Test::cat(helper s1, helper s2) { + return s1 + s2; } -void Test::test() -{ +void Test::test() { helper s1 = "a"; helper s2 = "b"; - helper result = cat(s1, s2); + helper result = cat(s1, s2); } //!Extract binary expression that results in a function with the same return type (Typedef) as the LHS @@ -203,9 +183,8 @@ methodname=cat struct helper {}; typedef helper new_helper; -class Test -{ - void test(); +class Test { + void test(); }; @@ -213,36 +192,32 @@ class Test struct helper {}; typedef helper new_helper; -class Test -{ - void test(); - new_helper cat(new_helper s1, new_helper s2); +class Test { + void test(); + new_helper cat(new_helper s1, new_helper s2); }; //@test.cpp #include "test.h" -void Test::test() -{ +void Test::test() { new_helper s1 = "a"; new_helper s2 = "b"; - new_helper result = /*$*/s1 + s2/*$$*/; + new_helper result = /*$*/s1 + s2/*$$*/; } //= #include "test.h" -new_helper Test::cat(new_helper s1, new_helper s2) -{ - return s1 + s2; +new_helper Test::cat(new_helper s1, new_helper s2) { + return s1 + s2; } -void Test::test() -{ +void Test::test() { new_helper s1 = "a"; new_helper s2 = "b"; - new_helper result = cat(s1, s2); + new_helper result = cat(s1, s2); } //!Extract new-Expression @@ -256,23 +231,20 @@ methodname=new_helper struct helper {}; -int main(int argc, char** argv) -{ - helper* h = /*$*/new helper/*$$*/; +int main(int argc, char** argv) { + helper* h = /*$*/new helper/*$$*/; return 0; } //= struct helper {}; -helper *new_helper() -{ - return new helper; +helper* new_helper() { + return new helper; } -int main(int argc, char** argv) -{ - helper* h = new_helper(); +int main(int argc, char** argv) { + helper* h = new_helper(); return 0; } //!Extract function call @@ -285,33 +257,28 @@ methodname=join_with_world //@test.cpp class string {}; -string join(string s1, char* s2) -{ - return s1 + " " + s2; +string join(string s1, char* s2) { + return s1 + " " + s2; } -int main() -{ - string hello = "Hello"; - cout << /*$*/join(hello, "World")/*$$*/ << endl; +int main() { + string hello = "Hello"; + cout << /*$*/join(hello, "World")/*$$*/ << endl; } //= class string {}; -string join(string s1, char* s2) -{ - return s1 + " " + s2; +string join(string s1, char* s2) { + return s1 + " " + s2; } -string join_with_world(string hello) -{ - return join(hello, "World"); +string join_with_world(string hello) { + return join(hello, "World"); } -int main() -{ - string hello = "Hello"; - cout << join_with_world(hello) << endl; +int main() { + string hello = "Hello"; + cout << join_with_world(hello) << endl; } //!Extract method call //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -321,40 +288,36 @@ filename=test.cpp methodname=value_from //@test.cpp -struct other -{ - bool value() {} +struct other { + bool value() {} }; -class Klass -{ - void set(bool b){} - void test() - { - other o; - this->set(/*$*/o.value()/*$$*/); +class Klass { + void set(bool b) { + } + + void test() { + other o; + this->set(/*$*/o.value()/*$$*/); } }; //= -struct other -{ - bool value() {} +struct other { + bool value() {} }; -class Klass -{ - void set(bool b){} +class Klass { + void set(bool b) { + } - bool value_from(other o) - { - return o.value(); - } + bool value_from(other o) { + return o.value(); + } - void test() - { - other o; - this->set(value_from(o)); + void test() { + other o; + this->set(value_from(o)); } }; @@ -380,9 +343,8 @@ class Cursor{}; Cursor* contains(const Cursor& pos); -Cursor *has(Cursor c) -{ - return contains(c); +Cursor* has(Cursor c) { + return contains(c); } int main() { @@ -400,8 +362,7 @@ methodname=has //@test.cpp class Cursor{}; -Cursor* contains(const Cursor& pos) -{ +Cursor* contains(const Cursor& pos) { ; } @@ -413,14 +374,12 @@ int main() { //= class Cursor{}; -Cursor* contains(const Cursor& pos) -{ +Cursor* contains(const Cursor& pos) { ; } -Cursor *has(Cursor c) -{ - return contains(c); +Cursor* has(Cursor c) { + return contains(c); } int main() { @@ -436,39 +395,34 @@ filename=test.cpp methodname=greeting //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - const char greeting(); + const char greeting(); }; //@test.cpp #include "test.h" -void Test::test() -{ - char* hi = /*$*/"hello"/*$$*/; +void Test::test() { + char* hi = /*$*/"hello"/*$$*/; } //= #include "test.h" -const char Test::greeting() -{ - return "hello"; +const char Test::greeting() { + return "hello"; } -void Test::test() -{ - char* hi = greeting(); +void Test::test() { + char* hi = greeting(); } //!Extract int constant @@ -479,39 +433,34 @@ filename=test.cpp methodname=size //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - int size(); + int size(); }; //@test.cpp #include "test.h" -void Test::test() -{ - int i = /*$*/42/*$$*/; +void Test::test() { + int i = /*$*/42/*$$*/; } //= #include "test.h" -int Test::size() -{ - return 42; +int Test::size() { + return 42; } -void Test::test() -{ - int i = size(); +void Test::test() { + int i = size(); } //!Extract float constant @@ -522,39 +471,34 @@ filename=test.cpp methodname=certainty //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - float certainty(); + float certainty(); }; //@test.cpp #include "test.h" -void Test::test() -{ - float f = /*$*/0.42f/*$$*/; +void Test::test() { + float f = /*$*/0.42f/*$$*/; } //= #include "test.h" -float Test::certainty() -{ - return 0.42f; +float Test::certainty() { + return 0.42f; } -void Test::test() -{ - float f = certainty(); +void Test::test() { + float f = certainty(); } //!Extract char constant @@ -565,39 +509,34 @@ filename=test.cpp methodname=newline //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - char newline(); + char newline(); }; //@test.cpp #include "test.h" -void Test::test() -{ - char nl = /*$*/'\n'/*$$*/; +void Test::test() { + char nl = /*$*/'\n'/*$$*/; } //= #include "test.h" -char Test::newline() -{ - return '\n'; +char Test::newline() { + return '\n'; } -void Test::test() -{ - char nl = newline(); +void Test::test() { + char nl = newline(); } //!Extract boolean true constant @@ -608,39 +547,34 @@ filename=test.cpp methodname=valid //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - bool valid(); + bool valid(); }; //@test.cpp #include "test.h" -void Test::test() -{ - bool b = /*$*/true/*$$*/; +void Test::test() { + bool b = /*$*/true/*$$*/; } //= #include "test.h" -bool Test::valid() -{ - return true; +bool Test::valid() { + return true; } -void Test::test() -{ - bool b = valid(); +void Test::test() { + bool b = valid(); } //!Extract boolean false constant @@ -651,39 +585,34 @@ filename=test.cpp methodname=invalid //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - bool invalid(); + bool invalid(); }; //@test.cpp #include "test.h" -void Test::test() -{ - bool b = /*$*/false/*$$*/; +void Test::test() { + bool b = /*$*/false/*$$*/; } //= #include "test.h" -bool Test::invalid() -{ - return false; +bool Test::invalid() { + return false; } -void Test::test() -{ - bool b = invalid(); +void Test::test() { + bool b = invalid(); } //!Extract int constant @@ -694,39 +623,34 @@ filename=test.cpp methodname=size //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - int size(); + int size(); }; //@test.cpp #include "test.h" -void Test::test() -{ - int i = /*$*/42/*$$*/; +void Test::test() { + int i = /*$*/42/*$$*/; } //= #include "test.h" -int Test::size() -{ - return 42; +int Test::size() { + return 42; } -void Test::test() -{ - int i = size(); +void Test::test() { + int i = size(); } //!Extract char constant @@ -737,39 +661,34 @@ filename=test.cpp methodname=newline //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - char newline(); + char newline(); }; //@test.cpp #include "test.h" -void Test::test() -{ - char nl = /*$*/'\n'/*$$*/; +void Test::test() { + char nl = /*$*/'\n'/*$$*/; } //= #include "test.h" -char Test::newline() -{ - return '\n'; +char Test::newline() { + return '\n'; } -void Test::test() -{ - char nl = newline(); +void Test::test() { + char nl = newline(); } //!Extract boolean true constant @@ -780,39 +699,34 @@ filename=test.cpp methodname=valid //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - bool valid(); + bool valid(); }; //@test.cpp #include "test.h" -void Test::test() -{ - bool b = /*$*/true/*$$*/; +void Test::test() { + bool b = /*$*/true/*$$*/; } //= #include "test.h" -bool Test::valid() -{ - return true; +bool Test::valid() { + return true; } -void Test::test() -{ - bool b = valid(); +void Test::test() { + bool b = valid(); } //!Extract boolean false constant @@ -823,39 +737,34 @@ filename=test.cpp methodname=invalid //@test.h -class Test -{ +class Test { void test(); }; //= -class Test -{ +class Test { void test(); - bool invalid(); + bool invalid(); }; //@test.cpp #include "test.h" -void Test::test() -{ - bool b = /*$*/false/*$$*/; +void Test::test() { + bool b = /*$*/false/*$$*/; } //= #include "test.h" -bool Test::invalid() -{ - return false; +bool Test::invalid() { + return false; } -void Test::test() -{ - bool b = invalid(); +void Test::test() { + bool b = invalid(); } //!Extract expresion with typdef Bug 331985 @@ -868,20 +777,19 @@ methodname=bar //@test.cpp typedef int& foo; int test(foo s) { - int a= /*$*/s + 1/*$$*/; // type of id-expression 's' is int, not 'foo' or 'int&' + int a = /*$*/s + 1/*$$*/; // type of id-expression 's' is int, not 'foo' or 'int&' return a; } //= typedef int& foo; -int bar(foo s) -{ - return s + 1; +int bar(foo s) { + return s + 1; } int test(foo s) { - int a= bar(s); // type of id-expression 's' is int, not 'foo' or 'int&' + int a = bar(s); // type of id-expression 's' is int, not 'foo' or 'int&' return a; } @@ -895,21 +803,20 @@ methodname=bar //@test.cpp -void foo(){ +void foo() { int x = 3; - double y = /*$*/x + 2.5/*$$*/; + double y = /*$*/x + 2.5/*$$*/; } //= -double bar(int x) -{ - return x + 2.5; +double bar(int x) { + return x + 2.5; } -void foo(){ +void foo() { int x = 3; - double y = bar(x); + double y = bar(x); } //! Extract macro @@ -923,7 +830,7 @@ methodname=bar #define five 5 #define ADD(a, b) a + b -int main(){ +int main() { int i = five; //comment3 i = /*$*/ADD(i, five)/*$$*/; @@ -934,12 +841,11 @@ int main(){ #define five 5 #define ADD(a, b) a + b -int bar(int & i) -{ - return ADD(i, five); +int bar(int& i) { + return ADD(i, five); } -int main(){ +int main() { int i = five; //comment3 i = bar(i); @@ -957,7 +863,7 @@ methodname=bar #define five 5 #define ADD(a, b) a + b -int main(){ +int main() { int i = five; //comment3 i = /*$*/ADD(i, five)/*$$*/; @@ -968,12 +874,11 @@ int main(){ #define five 5 #define ADD(a, b) a + b -int bar(int & i) -{ - return ADD(i, five); +int bar(int& i) { + return ADD(i, five); } -int main(){ +int main() { int i = five; //comment3 i = bar(i); diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractFunctionTemplates.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractFunctionTemplates.rts index 06a356fc171..271a5091f27 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractFunctionTemplates.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractFunctionTemplates.rts @@ -1,34 +1,34 @@ //!Extract template function //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@A.cpp -void test(){ +void test() { } + template -int tempFunct(){ - +int tempFunct() { T i; i = 0; /*$*/i++; - i+=3;/*$$*/ + i += 3;/*$$*/ return 0; } //= -void test(){ +void test() { } -template void exp(T i) -{ - i++; - i += 3; + +template +void exp(T i) { + i++; + i += 3; } template -int tempFunct(){ - +int tempFunct() { T i; i = 0; - exp(i); + exp(i); return 0; } @@ -36,39 +36,40 @@ int tempFunct(){ //!Extract template function with template parameter Bug #12 //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@A.cpp -void test(){ +void test() { } -template -int tempFunct(T p){ +template +int tempFunct(T p) { /*$*/++p; p + 4;/*$$*/ return 0; } //= -void test(){ +void test() { } -template void exp(T p) -{ - ++p; - p + 4; + +template +void exp(T p) { + ++p; + p + 4; } template -int tempFunct(T p){ - exp(p); +int tempFunct(T p) { + exp(p); return 0; } //!Extract template function with template type declaration Bug #11 //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@A.cpp -void test(){ +void test() { } -template -int tempFunct(){ +template +int tempFunct() { /*$*/T p; p = 0; p + 4;/*$$*/ @@ -77,19 +78,19 @@ int tempFunct(){ } //= -void test(){ +void test() { } -template T exp() -{ - T p; - p = 0; - p + 4; - return p; + +template +T exp() { + T p; + p = 0; + p + 4; + return p; } template -int tempFunct(){ - +int tempFunct() { T p = exp(); p + 2; return 0; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts index 61431473ef2..35bf54d93f3 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts @@ -4,12 +4,11 @@ #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -18,12 +17,11 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -31,34 +29,28 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - return /*$*/42/*$$*/; +int A::foo() { + return /*$*/42/*$$*/; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - int i = 42; - return i; +int A::foo() { + int i = 42; + return i; } //!ExtractLocalVariableRefactoringTest char @@ -67,12 +59,11 @@ int A::foo() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -81,12 +72,11 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -94,34 +84,28 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - return /*$*/'c'/*$$*/; +int A::foo() { + return /*$*/'c'/*$$*/; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - char temp = 'c'; - return temp; +int A::foo() { + char temp = 'c'; + return temp; } //!ExtractLocalVariableRefactoringTest float @@ -130,12 +114,11 @@ int A::foo() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - float foo(); + A(); + virtual ~A(); + float foo(); }; #endif /*A_H_*/ @@ -144,12 +127,11 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - float foo(); + A(); + virtual ~A(); + float foo(); }; #endif /*A_H_*/ @@ -157,34 +139,28 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -float A::foo() -{ - return /*$*/42.0f/*$$*/; +float A::foo() { + return /*$*/42.0f/*$$*/; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -float A::foo() -{ - float f = 42.0f; - return f; +float A::foo() { + float f = 42.0f; + return f; } //!ExtractLocalVariableRefactoringTest double @@ -193,12 +169,11 @@ float A::foo() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - float foo(); + A(); + virtual ~A(); + float foo(); }; #endif /*A_H_*/ @@ -207,12 +182,11 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - float foo(); + A(); + virtual ~A(); + float foo(); }; #endif /*A_H_*/ @@ -220,34 +194,28 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -float A::foo() -{ - return /*$*/42.0/*$$*/; +float A::foo() { + return /*$*/42.0/*$$*/; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -float A::foo() -{ - double f = 42.0; - return f; +float A::foo() { + double f = 42.0; + return f; } //!ExtractLocalVariableRefactoringTest parentheses @@ -256,12 +224,11 @@ float A::foo() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -270,12 +237,11 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -283,34 +249,28 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - return /*$*/(42)/*$$*/; +int A::foo() { + return /*$*/(42)/*$$*/; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - int i = 42; - return i; +int A::foo() { + int i = 42; + return i; } //!ExtractLocalVariableRefactoringTest proposed name in scope @@ -319,12 +279,11 @@ int A::foo() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -333,12 +292,11 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: - A(); - virtual ~A(); - int foo(); + A(); + virtual ~A(); + int foo(); }; #endif /*A_H_*/ @@ -346,96 +304,94 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - int x = 3; - return /*$*/(x + 2)/*$$*/ * 15; +int A::foo() { + int x = 3; + return /*$*/(x + 2)/*$$*/ * 15; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ - int x = 3; - int i = x + 2; - return i * 15; +int A::foo() { + int x = 3; + int i = x + 2; + return i * 15; } //!Bug #277065 extract local variable fails to extract from for loop //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -void foo(){ - for(int n = /*$*/5 + 2/*$$*/; n < 10; ++n); +void foo() { + for (int n = /*$*/5 + 2/*$$*/; n < 10; ++n) + ; } //= -void foo(){ - int i = 5 + 2; - for(int n = i; n < 10; ++n); +void foo() { + int i = 5 + 2; + for (int n = i; n < 10; ++n) + ; } //!ExtractLocalVariableRefactoringTest expression //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -void foo(){ - int a = 0; - float b = 0.1f; - double c = /*$*/(a + b)/*$$*/ * 0.2; +void foo() { + int a = 0; + float b = 0.1f; + double c = /*$*/(a + b)/*$$*/ * 0.2; } //= -void foo(){ - int a = 0; - float b = 0.1f; - float a0 = a + b; - double c = a0 * 0.2; +void foo() { + int a = 0; + float b = 0.1f; + float a0 = a + b; + double c = a0 * 0.2; } //!ExtractLocalVariableRefactoringTest pointer //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -void foo(){ - int a[2]; - int b = */*$*/(a + 1)/*$$*/; +void foo() { + int a[2]; + int b = */*$*/(a + 1)/*$$*/; } //= -void foo(){ - int a[2]; - int *i = a + 1; - int b = *i; +void foo() { + int a[2]; + int* i = a + 1; + int b = *i; } //!ExtractLocalVariableRefactoringTest qualifiers //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -const volatile int *k; -void foo(){ - /*$*/k;/*$$*/ +const volatile int* k; + +void foo() { + /*$*/k;/*$$*/ } //= -const volatile int *k; -void foo(){ - const volatile int *k0 = k; - k0; +const volatile int* k; + +void foo() { + const volatile int* k0 = k; + k0; } //!ExtractLocalVariableRefactoringTest overloaded operators @@ -443,24 +399,24 @@ void foo(){ //@A.cpp class K { public: - bool operator+(int b) {return true;} - float operator+(unsigned u) {return 1.0f;} + bool operator+(int b) { return true; } + float operator+(unsigned u) { return 1.0f; } }; -void foo(){ - K k; - /*$*/k+3u/*$$*/; +void foo() { + K k; + /*$*/k+3u/*$$*/; } //= class K { public: - bool operator+(int b) {return true;} - float operator+(unsigned u) {return 1.0f;} + bool operator+(int b) { return true; } + float operator+(unsigned u) { return 1.0f; } }; -void foo(){ - K k; - float i = k + 3u; - i; +void foo() { + K k; + float i = k + 3u; + i; } //!Bug 318784 DeclarationGenerator fails for some cases @@ -468,16 +424,16 @@ void foo(){ //@A.cpp void func() { - int *(*a)[2]; - /*$*/a/*$$*/; + int* (*a)[2]; + /*$*/a/*$$*/; } //= void func() { - int *(*a)[2]; - int *(*a0)[2] = a; - a0; + int* (*a)[2]; + int* (*a0)[2] = a; + a0; } //!Bug 331963 Extract local variable doesn't put template type parameters @@ -491,10 +447,8 @@ class Foo { Foo getFoo(); int main() { - - /*$*/getFoo()/*$$*/; - - return 0; + /*$*/getFoo()/*$$*/; + return 0; } //= @@ -506,163 +460,163 @@ class Foo { Foo getFoo(); int main() { - Foo foo = getFoo(); - foo; - - return 0; + Foo foo = getFoo(); + foo; + return 0; } //!Bug 331963 Extract local variable doesn't put template type parameters Namespace //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -namespace bar{ +namespace bar { + template class Foo { }; + } bar::Foo getFoo(); int main() { - - /*$*/getFoo()/*$$*/; - - return 0; + /*$*/getFoo()/*$$*/; + return 0; } //= -namespace bar{ +namespace bar { + template class Foo { }; + } bar::Foo getFoo(); int main() { - bar::Foo foo = getFoo(); - foo; - - return 0; + bar::Foo foo = getFoo(); + foo; + return 0; } //!Bug 330693 Improve suggested variable name in Extract Local Variable //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -struct Foo{ +struct Foo { int getVarWithLongName(); }; -void bar(){ +void bar() { Foo f; /*$*/f.getVarWithLongName()/*$$*/; } //= -struct Foo{ +struct Foo { int getVarWithLongName(); }; -void bar(){ +void bar() { Foo f; - int varWithLongName = f.getVarWithLongName(); - varWithLongName; + int varWithLongName = f.getVarWithLongName(); + varWithLongName; } //!Bug 330693 Improve suggested variable name in Extract Local Variable: name == prefix //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -struct Foo{ +struct Foo { int get(); }; -void bar(){ +void bar() { Foo f; /*$*/f.get()/*$$*/; } //= -struct Foo{ +struct Foo { int get(); }; -void bar(){ +void bar() { Foo f; - int get = f.get(); - get; + int get = f.get(); + get; } //!Bug 335202 Suggested name is wrong for nested function calls - outer function call //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -int getA(){ - return 0; +int getA() { + return 0; }; -int getB(int a){ - return a; +int getB(int a) { + return a; } -void bar(){ - /*$*/getB(getA())/*$$*/; +void bar() { + /*$*/getB(getA())/*$$*/; } //= -int getA(){ - return 0; +int getA() { + return 0; }; -int getB(int a){ - return a; +int getB(int a) { + return a; } -void bar(){ - int b = getB(getA()); - b; +void bar() { + int b = getB(getA()); + b; } //!Bug 335202 Suggested name is wrong for nested function calls - inner function call //#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest //@A.cpp -int getA(){ - return 0; +int getA() { + return 0; }; -int getB(int a){ - return a; +int getB(int a) { + return a; } -int getC(int a){ - return a; +int getC(int a) { + return a; } -void bar(){ - getB(/*$*/getC(getA())/*$$*/); +void bar() { + getB(/*$*/getC(getA())/*$$*/); } //= -int getA(){ - return 0; +int getA() { + return 0; }; -int getB(int a){ - return a; +int getB(int a) { + return a; } -int getC(int a){ - return a; +int getC(int a) { + return a; } -void bar(){ - int c = getC(getA()); - getB(c); +void bar() { + int c = getC(getA()); + getB(c); } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariableHistory.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariableHistory.rts index b01f4096137..ecbc8bbafdb 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariableHistory.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariableHistory.rts @@ -1,14 +1,16 @@ //!extract local variable from for loop //#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest //@main.cpp -void foo(){ - for(int n = 5 + 2; n < 10; ++n); +void foo() { + for (int n = 5 + 2; n < 10; ++n) + ; } //= -void foo(){ - int i = 5 + 2; - for(int n = i; n < 10; ++n); +void foo() { + int i = 5 + 2; + for (int n = i; n < 10; ++n) + ; } //@refScript.xml @@ -17,5 +19,5 @@ void foo(){ + name="i" project="RegressionTestProject" selection="27,5"/> diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts index 8f91ea478c7..c30d66c2640 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts @@ -4,13 +4,12 @@ #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -21,16 +20,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(); + int exp(); }; #endif /*A_H_*/ @@ -38,54 +36,47 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { /*$*/int i = 2; ++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp() -{ - int i = 2; - ++i; - help(); - return i; +A::~A() { } -int A::foo() -{ +int A::exp() { + int i = 2; + ++i; + help(); + return i; +} + +int A::foo() { int i = exp(); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with comment //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -93,13 +84,12 @@ int A::help() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -110,16 +100,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -127,15 +116,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; //comment /*$*/++i; @@ -143,40 +130,35 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) -{ - //comment - ++i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& i) { + //comment + ++i; + help(); +} + +int A::foo() { int i = 2; //comment - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@.config filename=A.cpp @@ -188,8 +170,7 @@ returnparameterindex=0 //!Extract Function first extracted statement with leading comment //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@main.cpp -int main(){ - +int main() { int i; // Comment /*$*/i= 7;/*$$*/ @@ -197,17 +178,15 @@ int main(){ } //= -void exp(int & i) -{ - // Comment - i = 7; +void exp(int& i) { + // Comment + i = 7; } -int main(){ - +int main() { int i; // Comment - exp(i); + exp(i); return i; } @@ -221,23 +200,20 @@ returnparameterindex=0 //!Extract Function last extracted statement with trailling comment //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@main.cpp -int main(){ - +int main() { int i; /*$*/i= 7;/*$$*/ // Comment return i; } //= -void exp(int & i) -{ - i = 7; // Comment +void exp(int& i) { + i = 7; // Comment } -int main(){ - +int main() { int i; - exp(i); // Comment + exp(i); // Comment return i; } @@ -256,13 +232,12 @@ fatalerror=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -272,16 +247,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ +int A::foo() { /*$*/int o = 1; int i = 2; ++i; @@ -289,10 +261,11 @@ int A::foo() help();/*$$*/ o++; return i; -}int A::help() -{ +} + +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with named typed field //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -302,14 +275,13 @@ int A::foo() #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); void foo(); B b; - + private: int help(); }; @@ -322,17 +294,16 @@ private: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); void foo(); B b; - + private: int help(); - void exp(); + void exp(); }; #endif /*A_H_*/ @@ -340,56 +311,48 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -void A::foo() -{ + +void A::foo() { /*$*/b = new B(); help();/*$$*/ } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp() -{ - b = new B(); - help(); +A::~A() { } -void A::foo() -{ - exp(); +void A::exp() { + b = new B(); + help(); } -int A::help() -{ +void A::foo() { + exp(); +} + +int A::help() { return 42; -} +} //@B.h #ifndef B_H_ #define B_H_ -class B -{ +class B { public: B(); virtual ~B(); @@ -405,14 +368,13 @@ public: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); void foo(); B b; - + private: int help(); }; @@ -425,17 +387,16 @@ private: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); void foo(); B b; - + private: int help(); - void exp(); + void exp(); }; #endif /*A_H_*/ @@ -443,56 +404,48 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -void A::foo() -{ + +void A::foo() { /*$*/b = new B(); help();/*$$*/ } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp() -{ - b = new B(); - help(); +A::~A() { } -void A::foo() -{ - exp(); +void A::exp() { + b = new B(); + help(); } -int A::help() -{ +void A::foo() { + exp(); +} + +int A::help() { return 42; -} +} //@B.h #ifndef B_H_ #define B_H_ -class B -{ +class B { public: B(); virtual ~B(); @@ -506,13 +459,12 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -523,16 +475,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -542,15 +493,13 @@ private: #define ZWO 2 -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; /*$*/++i; i += ZWO; @@ -558,41 +507,36 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" #define ZWO 2 -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) -{ - ++i; - i += ZWO; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& i) { + ++i; + i += ZWO; + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with FunctionStyleMacro //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -600,13 +544,12 @@ int A::help() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -617,16 +560,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -636,15 +578,13 @@ private: #define ADD(a,b) a + b + 2 -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; /*$*/++i; i = ADD(i, 42); @@ -652,41 +592,36 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" #define ADD(a,b) a + b + 2 -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) -{ - ++i; - i = ADD(i, 42); - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& i) { + ++i; + i = ADD(i, 42); + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractMethod with Pointer //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -694,13 +629,12 @@ int A::help() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -711,16 +645,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int *& i); + void exp(int*& i); }; #endif /*A_H_*/ @@ -728,51 +661,44 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int* i = new int(2); /*$*/++*i; help();/*$$*/ return *i; } -int A::help() -{ +int A::help() { return 42; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int *& i) -{ - ++*i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int*& i) { + ++*i; + help(); +} + +int A::foo() { int* i = new int(2); - exp(i); + exp(i); return *i; } -int A::help() -{ +int A::help() { return 42; } @@ -782,13 +708,12 @@ int A::help() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -799,16 +724,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int *& i); + void exp(int*& i); }; #endif /*A_H_*/ @@ -816,15 +740,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int* i = new int(2); /*$*/++*i; help(); @@ -832,37 +754,32 @@ int A::foo() return *i; } -int A::help() -{ +int A::help() { return 42; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int *& i) -{ - ++*i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int*& i) { + ++*i; + help(); +} + +int A::foo() { int* i = new int(2); - exp(i); + exp(i); //A end-comment return *i; } -int A::help() -{ +int A::help() { return 42; } @@ -872,13 +789,12 @@ int A::help() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -889,16 +805,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int *& i); + void exp(int*& i); }; #endif /*A_H_*/ @@ -906,15 +821,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { //A beautiful comment int* i = new int(2); /*$*/++*i; @@ -922,37 +835,32 @@ int A::foo() return *i; } -int A::help() -{ +int A::help() { return 42; } //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int *& i) -{ - ++*i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int*& i) { + ++*i; + help(); +} + +int A::foo() { //A beautiful comment int* i = new int(2); - exp(i); + exp(i); return *i; } -int A::help() -{ +int A::help() { return 42; } @@ -965,13 +873,12 @@ returnvalue=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -982,16 +889,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(int i); + int exp(int i); }; #endif /*A_H_*/ @@ -999,54 +905,47 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; /*$*/++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp(int i) -{ - ++i; - help(); - return i; +A::~A() { } -int A::foo() -{ - int i = 2; - i = exp(i); +int A::exp(int i) { + ++i; + help(); return i; } -int A::help() -{ +int A::foo() { + int i = 2; + i = exp(i); + return i; +} + +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with Return Value and Ref Parameter //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -1057,13 +956,12 @@ returnvalue=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1074,16 +972,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(int i, int & b); + int exp(int i, int& b); }; #endif /*A_H_*/ @@ -1091,15 +988,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; int b = i; /*$*/++i; @@ -1109,42 +1004,37 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp(int i, int & b) -{ - ++i; - i = i + b; - help(); - return i; +A::~A() { } -int A::foo() -{ +int A::exp(int i, int& b) { + ++i; + i = i + b; + help(); + return i; +} + +int A::foo() { int i = 2; int b = i; - i = exp(i, b); + i = exp(i, b); ++b; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with Return Value and Ref Parameter and some more not used aferwards //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -1155,13 +1045,12 @@ returnvalue=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1172,16 +1061,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(int i, B *b, int y, float & x); + int exp(int i, B* b, int y, float& x); }; #endif /*A_H_*/ @@ -1189,15 +1077,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; float x = i; B* b = new B(); @@ -1210,45 +1096,40 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp(int i, B *b, int y, float & x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return i; +A::~A() { } -int A::foo() -{ +int A::exp(int i, B* b, int y, float& x) { + ++i; + b->hello(y); + i = i + x; + help(); + return i; +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); int y = x + i; - i = exp(i, b, y, x); + i = exp(i, b, y, x); ++x; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with Return Value take the second and Ref Parameter and some more not used aferwards //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -1261,13 +1142,12 @@ returnvalue=true #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1280,16 +1160,15 @@ private: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - float exp(int & i, B *b, int y, float x); + float exp(int& i, B* b, int y, float x); }; #endif /*A_H_*/ @@ -1297,15 +1176,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; float x = i; B* b = new B(); @@ -1318,52 +1195,46 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -float A::exp(int & i, B *b, int y, float x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return x; +A::~A() { } -int A::foo() -{ +float A::exp(int& i, B* b, int y, float x) { + ++i; + b->hello(y); + i = i + x; + help(); + return x; +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); int y = x + i; - x = exp(i, b, y, x); + x = exp(i, b, y, x); ++x; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@B.h #ifndef B_H_ #define B_H_ -class B -{ +class B { public: B(); virtual ~B(); @@ -1383,13 +1254,12 @@ returnvalue=true #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1402,16 +1272,15 @@ private: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(int i, B *& b, int & y, float & x); + int exp(int i, B*& b, int& y, float& x); }; #endif /*A_H_*/ @@ -1419,15 +1288,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; float x = i; B* b = new B(); @@ -1441,53 +1308,47 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp(int i, B *& b, int & y, float & x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return i; +A::~A() { } -int A::foo() -{ +int A::exp(int i, B*& b, int& y, float& x) { + ++i; + b->hello(y); + i = i + x; + help(); + return i; +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); int y = x + i; - i = exp(i, b, y, x); + i = exp(i, b, y, x); b->hello(y); ++x; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@B.h #ifndef B_H_ #define B_H_ -class B -{ +class B { public: B(); virtual ~B(); @@ -1507,13 +1368,12 @@ returnvalue=true #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1526,16 +1386,15 @@ private: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - B *exp(int & i, B *b, int & y, float & x); + B* exp(int& i, B* b, int& y, float& x); }; #endif /*A_H_*/ @@ -1543,15 +1402,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; float x = i; B* b = new B(); @@ -1565,53 +1422,47 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -B *A::exp(int & i, B *b, int & y, float & x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return b; +A::~A() { } -int A::foo() -{ +B* A::exp(int& i, B* b, int& y, float& x) { + ++i; + b->hello(y); + i = i + x; + help(); + return b; +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); int y = x + i; - b = exp(i, b, y, x); + b = exp(i, b, y, x); b->hello(y); ++x; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@B.h #ifndef B_H_ #define B_H_ -class B -{ +class B { public: B(); virtual ~B(); @@ -1626,13 +1477,12 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1643,17 +1493,17 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); + protected: - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -1661,53 +1511,46 @@ protected: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; /*$*/++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) -{ - ++i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& i) { + ++i; + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@.config filename=A.cpp @@ -1723,13 +1566,12 @@ visibility=protected #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1740,14 +1582,13 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - void exp(int & i); - + void exp(int& i); + private: int help(); }; @@ -1757,53 +1598,46 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; /*$*/++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) -{ - ++i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& i) { + ++i; + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@.config filename=A.cpp @@ -1819,13 +1653,12 @@ visibility=public #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo() const; - + private: int help(); }; @@ -1836,16 +1669,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo() const; - + private: int help(); - void exp(int & i) const; + void exp(int& i) const; }; #endif /*A_H_*/ @@ -1853,53 +1685,46 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() const -{ + +int A::foo() const { int i = 2; /*$*/++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) const -{ - ++i; - help(); +A::~A() { } -int A::foo() const -{ +void A::exp(int& i) const { + ++i; + help(); +} + +int A::foo() const { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@.config filename=A.cpp @@ -1908,59 +1733,53 @@ replaceduplicates=false returnvalue=false returnparameterindex=0 -//!don't return variables that aren't used +//!Don't return variables that aren't used //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@.config filename=main.h methodname=loop //@main.h -void method() -{ +void method() { /*$*/for (int var = 0; var < 100; ++var) { - if(var < 50) + if (var < 50) continue; }/*$$*/ } //= -void loop() -{ - for(int var = 0;var < 100;++var){ - if(var < 50) - continue; - - } +void loop() { + for (int var = 0; var < 100; ++var) { + if (var < 50) + continue; + } } -void method() -{ - loop(); +void method() { + loop(); } -//!don't extract code that contains 'return' +//!Don't extract code that contains 'return' //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@.config filename=main.h fatalerror=true //@main.h -void method() -{ - /*$*/if(true) +void method() { + /*$*/if (true) return;/*$$*/ //unreachable } -//!test if we don't allow to extract 'continue' Bug #53 +//!Test if we don't allow to extract 'continue' Bug #53 //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@.config fatalerror=true filename=A.h //@A.h -void function() -{ +void function() { for (int var = 0; var < 100; ++var) { - /*$*/if(var < 50) + /*$*/if (var < 50) continue;/*$$*/ } } @@ -1974,31 +1793,30 @@ methodname=runTest #define ASSERTM(msg,cond) if (!(cond)) throw cute::test_failure((msg),__FILE__,__LINE__) #define ASSERT(cond) ASSERTM(#cond, cond) -void testFuerRainer(){ - int i=int(); - /*$*/++i; - //Leading Comment - ASSERT (i); - //Trailling Comment - --i;/*$$*/ +void testFuerRainer() { + int i = int(); + /*$*/++i; + //Leading Comment + ASSERT(i); + //Trailling Comment + --i;/*$$*/ } //= #define ASSERTM(msg,cond) if (!(cond)) throw cute::test_failure((msg),__FILE__,__LINE__) #define ASSERT(cond) ASSERTM(#cond, cond) -void runTest(int i) -{ - ++i; - //Leading Comment - ASSERT (i); - //Trailling Comment - --i; +void runTest(int i) { + ++i; + //Leading Comment + ASSERT(i); + //Trailling Comment + --i; } -void testFuerRainer(){ - int i=int(); - runTest(i); +void testFuerRainer() { + int i = int(); + runTest(i); } //! Bug #124 with comments Extract Function with a Macro call in selected code "forgets" the macro @@ -2010,27 +1828,26 @@ methodname=runTest #define ASSERTM(msg,cond) if (!(cond)) throw cute::test_failure((msg),__FILE__,__LINE__) #define ASSERT(cond) ASSERTM(#cond, cond) -void testFuerRainer(){ - int i=int(); - /*$*/++i; - ASSERT (i); - --i;/*$$*/ +void testFuerRainer() { + int i = int(); + /*$*/++i; + ASSERT(i); + --i;/*$$*/ } //= #define ASSERTM(msg,cond) if (!(cond)) throw cute::test_failure((msg),__FILE__,__LINE__) #define ASSERT(cond) ASSERTM(#cond, cond) -void runTest(int i) -{ - ++i; - ASSERT (i); - --i; +void runTest(int i) { + ++i; + ASSERT(i); + --i; } -void testFuerRainer(){ - int i=int(); - runTest(i); +void testFuerRainer() { + int i = int(); + runTest(i); } //! Bug #137 String Array problem in Extract Function @@ -2045,7 +1862,7 @@ using namespace std; int const INITIAL_CAPACITY = 10; -int main(){ +int main() { int m_capacity; /*$*/m_capacity += INITIAL_CAPACITY; string* newElements = new string[m_capacity];/*$$*/ @@ -2059,16 +1876,15 @@ using namespace std; int const INITIAL_CAPACITY = 10; -string *runTest(int m_capacity) -{ - m_capacity += INITIAL_CAPACITY; - string *newElements = new string[m_capacity]; - return newElements; +string* runTest(int m_capacity) { + m_capacity += INITIAL_CAPACITY; + string* newElements = new string[m_capacity]; + return newElements; } -int main(){ +int main() { int m_capacity; - string *newElements = runTest(m_capacity); + string* newElements = runTest(m_capacity); newElements[0] = "s"; } @@ -2081,13 +1897,11 @@ returnparameterindex=0 #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(int& a); - }; #endif /*A_H_*/ @@ -2096,15 +1910,14 @@ public: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(int& a); -private: - void exp(int & a, int b, int c); +private: + void exp(int& a, int b, int c); }; #endif /*A_H_*/ @@ -2112,15 +1925,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo(int& a) -{ + +int A::foo(int& a) { int b = 7; int c = 8; /*$*/a = b + c;/*$$*/ @@ -2129,26 +1940,23 @@ int A::foo(int& a) //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & a, int b, int c) -{ - a = b + c; +A::~A() { } -int A::foo(int& a) -{ +void A::exp(int& a, int b, int c) { + a = b + c; +} + +int A::foo(int& a) { int b = 7; int c = 8; - exp(a, b, c); + exp(a, b, c); return a; } -//!Bug 241717: Typdef causes void as return type +//!Bug 241717: Typedef causes void as return type //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@.config filename=Test.cpp @@ -2156,9 +1964,7 @@ filename=Test.cpp #ifndef TEST_H_ #define TEST_H_ -class RetValueType{ - - +class RetValueType { }; typedef RetValueType RetType; @@ -2176,9 +1982,7 @@ private: #ifndef TEST_H_ #define TEST_H_ -class RetValueType{ - - +class RetValueType { }; typedef RetValueType RetType; @@ -2189,7 +1993,7 @@ public: virtual ~Test(); private: void test(); - RetType exp(); + RetType exp(); }; #endif /* TEST_H_ */ @@ -2197,14 +2001,12 @@ private: #include "Test.h" Test::Test() { - } Test::~Test() { } -void Test::test() -{ +void Test::test() { RetType v = /*$*/RetType()/*$$*/; } @@ -2212,19 +2014,16 @@ void Test::test() #include "Test.h" Test::Test() { - } Test::~Test() { } -RetType Test::exp() -{ - return RetType(); +RetType Test::exp() { + return RetType(); } -void Test::test() -{ +void Test::test() { RetType v = exp(); } @@ -2235,22 +2034,19 @@ filename=Test.cpp methodname=startTag //@testString.h -namespace test{ +namespace test { - class string{ - public: +class string { +public: + friend string operator+(const string& lhs, const string& rhs) { + return rhs; + } - friend string operator+(const string& lhs, const string& rhs) - { - return rhs; - } + string operator+(const string& rhs) { return rhs; } + string(char* cp) {} + string() {}; +}; - - string operator+(const string& rhs){return rhs;} - string(char* cp){} - string(){}; - - }; } //@Test.cpp @@ -2269,9 +2065,8 @@ int main() { //= #include "testString.h" -test::string startTag(test::string & name) -{ - return "<" + name + ">"; +test::string startTag(test::string& name) { + return "<" + name + ">"; } test::string toXML() { @@ -2291,24 +2086,22 @@ filename=Test.cpp methodname=startTag //@testString.h -namespace test{ +namespace test { -class string2{ - public: +class string2 { +public: + friend string2 operator+(const string2& lhs, const string2& rhs) { + return rhs; + } - friend string2 operator+(const string2& lhs, const string2& rhs) - { - return rhs; - } + string2 operator+(const string2& rhs) { return rhs; } + string2(char* cp) {} + string2() {}; +}; - string2 operator+(const string2& rhs){return rhs;} - string2(char* cp){} - string2(){}; +typedef string2 string; - }; - - typedef string2 string; } //@Test.cpp @@ -2327,9 +2120,8 @@ int main() { //= #include "testString.h" -test::string startTag(test::string & name) -{ - return "<" + name + ">"; +test::string startTag(test::string& name) { + return "<" + name + ">"; } test::string toXML() { @@ -2349,22 +2141,19 @@ filename=Test.cpp methodname=endTag //@testString.h -namespace test{ +namespace test { - class string{ - public: +class string { +public: + friend string operator+(const string& lhs, const string& rhs) { + return rhs; + } - friend string operator+(const string& lhs, const string& rhs) - { - return rhs; - } + string operator+(const string& rhs) { return rhs; } + string(char* cp) {} + string() {}; +}; - - string operator+(const string& rhs){return rhs;} - string(char* cp){} - string(){}; - - }; } //@Test.cpp @@ -2383,9 +2172,8 @@ int main() { //= #include "testString.h" -const char endTag(test::string name) -{ - return ""; +const char endTag(test::string name) { + return ""; } test::string toXML() { @@ -2405,22 +2193,19 @@ filename=Test.cpp methodname=exp //@testString.h -namespace test{ +namespace test { - class string{ - public: +class string { +public: + friend string operator+(const string& lhs, const string& rhs) { + return rhs; + } - friend string operator+(const string& lhs, const string& rhs) - { - return rhs; - } + string operator+(const string& rhs) { return rhs; } + string(char* cp) {} + string() {}; +}; - - string operator+(const string& rhs){return rhs;} - string(char* cp){} - string(){}; - - }; } //@Test.cpp @@ -2439,9 +2224,8 @@ int main() { //= #include "testString.h" -const char exp() -{ - return ">" + "" + ""; +const char endTag(test::string name) { + return ""; } test::string toXML() { @@ -2517,22 +2297,19 @@ filename=Test.cpp methodname=exp //@testString.h -namespace test{ +namespace test { - class string{ - public: +class string { +public: + friend string operator+(const string& lhs, const string& rhs) { + return rhs; + } - friend string operator+(const string& lhs, const string& rhs) - { - return rhs; - } + string operator+(const string& rhs) { return rhs; } + string(char* cp) {} + string() {}; +}; - - string operator+(const string& rhs){return rhs;} - string(char* cp){} - string(){}; - - }; } //@Test.cpp @@ -2551,9 +2328,8 @@ int main() { //= #include "testString.h" -const char exp() -{ - return ">" + "" + "Extract Function in C Project (not C++) won't extract parameters @@ -2762,24 +2522,21 @@ int a = 0; filename=main.c methodname=exp //@main.c -int main() -{ - int a,b; - /*$*/b=a*2;/*$$*/ - return a; +int main() { + int a,b; + /*$*/b=a*2;/*$$*/ + return a; } //= -void exp(int b, int *a) -{ - b = a * 2; +void exp(int b, int* a) { + b = a * 2; } -int main() -{ - int a,b; - exp(b, a); - return a; +int main() { + int a,b; + exp(b, a); + return a; } //!ExtractFunctionRefactoringTest virtual @@ -2788,13 +2545,12 @@ int main() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -2805,14 +2561,13 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - virtual void exp(int & i); - + virtual void exp(int& i); + private: int help(); }; @@ -2822,15 +2577,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; //comment /*$*/++i; @@ -2838,40 +2591,35 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) -{ - //comment - ++i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& i) { + //comment + ++i; + help(); +} + +int A::foo() { int i = 2; //comment - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@.config filename=A.cpp @@ -2885,24 +2633,21 @@ visibility=public //!Bug 288268: c-refactoring creates c++-parameters //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest //@main.c -int main() -{ - int a,b; - /*$*/a = b*2;/*$$*/ - return a; +int main() { + int a,b; + /*$*/a = b*2;/*$$*/ + return a; } //= -void test(int *a, int b) -{ - a = b * 2; +void test(int* a, int b) { + a = b * 2; } -int main() -{ - int a,b; - test(a, b); - return a; +int main() { + int a,b; + test(a, b); + return a; } //@.config diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodDuplicates.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodDuplicates.rts index a3be46e65ad..438d6b780b6 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodDuplicates.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodDuplicates.rts @@ -6,13 +6,12 @@ replaceduplicates=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -23,16 +22,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -40,56 +38,51 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; ++i; help(); -}int A::foo() -{ +} + +int A::foo() { int i = 2; /*$*/++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; - exp(i); -}void A::exp(int & i) -{ - ++i; - help(); + exp(i); } -int A::foo() -{ +void A::exp(int& i) { + ++i; + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest duplicates with different Names //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -99,13 +92,12 @@ replaceduplicates=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -116,16 +108,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -133,56 +124,51 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; ++oo; help(); -}int A::foo() -{ +} + +int A::foo() { int i = 2; /*$*/++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; - exp(oo); -}void A::exp(int & i) -{ - ++i; - help(); + exp(oo); } -int A::foo() -{ +void A::exp(int& i) { + ++i; + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest dublicate with field //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -193,14 +179,13 @@ returnvalue=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); void foo(); int i; - + private: int help(); }; @@ -211,17 +196,16 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); void foo(); int i; - + private: int help(); - int exp(int j, int & a); + int exp(int j, int& a); }; #endif /*A_H_*/ @@ -229,18 +213,17 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int j = 0; i++; j++; help(); -}void A::foo() -{ +} + +void A::foo() { int j = 0; int a = 1; /*$*/j++; @@ -250,32 +233,29 @@ A::~A() j++; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int j = 0; i = exp(i, j); -}int A::exp(int j, int & a) -{ - j++; - a++; - help(); - return j; } -void A::foo() -{ +int A::exp(int j, int& a) { + j++; + a++; + help(); + return j; +} + +void A::foo() { int j = 0; int a = 1; j = exp(j, a); @@ -283,10 +263,9 @@ void A::foo() j++; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest dublicate with field in marked scope //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -297,15 +276,14 @@ returnvalue=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); void foo(); int i; int field; - + private: int help(); }; @@ -316,18 +294,17 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); void foo(); int i; int field; - + private: int help(); - int exp(int j); + int exp(int j); }; #endif /*A_H_*/ @@ -335,19 +312,18 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int j = 0; int a = 1; a++; j++; help(); -}void A::foo() -{ +} + +void A::foo() { int j = 0; /*$*/field++; @@ -357,45 +333,41 @@ A::~A() j++; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int j = 0; int a = 1; a++; j++; help(); -}int A::exp(int j) -{ - field++; - j++; - help(); - return j; } -void A::foo() -{ +int A::exp(int j) { + field++; + j++; + help(); + return j; +} + +void A::foo() { int j = 0; - j = exp(j); + j = exp(j); field++; j++; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest duplicates with different Names and return type //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -406,13 +378,12 @@ returnvalue=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -423,16 +394,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(int i, float & j); + int exp(int i, float& j); }; #endif /*A_H_*/ @@ -440,20 +410,19 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; float blabla = 0; ++oo; blabla += 1; help(); blabla += 1; -}int A::foo() -{ +} + +int A::foo() { int i = 2; float j = 8989; /*$*/++i; @@ -463,45 +432,41 @@ A::~A() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; float blabla = 0; - oo = exp(oo, blabla); + oo = exp(oo, blabla); blabla += 1; -}int A::exp(int i, float & j) -{ - ++i; - j += 1; - help(); - return i; } -int A::foo() -{ +int A::exp(int i, float& j) { + ++i; + j += 1; + help(); + return i; +} + +int A::foo() { int i = 2; float j = 8989; - i = exp(i, j); + i = exp(i, j); j++; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest duplicates with a lot of different Names an variable not used afterwards in the duplicate //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -511,13 +476,12 @@ replaceduplicates=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -528,16 +492,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i, float j); + void exp(int& i, float j); }; #endif /*A_H_*/ @@ -545,19 +508,18 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; float blabla = 0; ++oo; blabla += 1; help(); -}int A::foo() -{ +} + +int A::foo() { int i = 2; float j = 8989; /*$*/++i; @@ -566,42 +528,38 @@ A::~A() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; float blabla = 0; - exp(oo, blabla); -}void A::exp(int & i, float j) -{ - ++i; - j += 1; - help(); + exp(oo, blabla); } -int A::foo() -{ +void A::exp(int& i, float j) { + ++i; + j += 1; + help(); +} + +int A::foo() { int i = 2; float j = 8989; - exp(i, j); + exp(i, j); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with duplicates name used afterwards in duplicate but not in original selection this is no dublicate //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -611,13 +569,12 @@ replaceduplicates=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); void foo(); - + private: int help(); }; @@ -628,16 +585,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); void foo(); - + private: int help(); - void exp(int i); + void exp(int i); }; #endif /*A_H_*/ @@ -645,57 +601,52 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; ++i;// No Duplicate help(); ++i;// this is the reason -}void A::foo() -{ +} + +void A::foo() { int i = 2; /*$*/++i; help();/*$$*/ } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; ++i;// No Duplicate help(); ++i;// this is the reason -}void A::exp(int i) -{ - ++i; - help(); } -void A::foo() -{ +void A::exp(int i) { + ++i; + help(); +} + +void A::foo() { int i = 2; - exp(i); + exp(i); } -int A::help() -{ +int A::help() { return 42; -} +} //!ExtractFunctionRefactoringTest with Return Value and a lot Ref Parameter and a method call //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -708,13 +659,12 @@ returnvalue=true #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -727,16 +677,15 @@ private: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(int i, B *& b, int & y, float & x); + int exp(int i, B*& b, int& y, float& x); }; #endif /*A_H_*/ @@ -744,12 +693,10 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; float x = i; B* b = new B(); @@ -761,8 +708,9 @@ A::~A() b->hello(y); ++x; i++; -}int A::foo() -{ +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); @@ -776,53 +724,49 @@ A::~A() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; float x = i; B* b = new B(); int y = x + i; - i = exp(i, b, y, x); + i = exp(i, b, y, x); b->hello(y); ++x; i++; -}int A::exp(int i, B *& b, int & y, float & x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return i; } -int A::foo() -{ +int A::exp(int i, B*& b, int& y, float& x) { + ++i; + b->hello(y); + i = i + x; + help(); + return i; +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); int y = x + i; - i = exp(i, b, y, x); + i = exp(i, b, y, x); b->hello(y); ++x; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@B.h #ifndef B_H_ @@ -849,13 +793,12 @@ returnvalue=true #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -868,16 +811,15 @@ private: #include "B.h" -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(int i, B *& b, int & y, float x); + int exp(int i, B*& b, int& y, float x); }; #endif /*A_H_*/ @@ -885,12 +827,10 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; float x = i; B* b = new B(); @@ -902,8 +842,9 @@ A::~A() b->hello(y); ++x; i++; -}int A::foo() -{ +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); @@ -916,20 +857,17 @@ A::~A() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; float x = i; B* b = new B(); @@ -941,30 +879,29 @@ A::~A() b->hello(y); ++x; i++; -}int A::exp(int i, B *& b, int & y, float x) -{ - ++i; - b->hello(y); - i = i + x; - help(); - return i; } -int A::foo() -{ +int A::exp(int i, B*& b, int& y, float x) { + ++i; + b->hello(y); + i = i + x; + help(); + return i; +} + +int A::foo() { int i = 2; float x = i; B* b = new B(); int y = x + i; - i = exp(i, b, y, x); + i = exp(i, b, y, x); b->hello(y); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@B.h #ifndef B_H_ @@ -988,13 +925,12 @@ replaceduplicates=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -1005,16 +941,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -1022,54 +957,49 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; ++i; help(); -}int A::foo() -{ +} + +int A::foo() { int i = 2; /*$*/++i; help();/*$$*/ return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int i = 2; - exp(i); -}void A::exp(int & i) -{ - ++i; - help(); + exp(i); } -int A::foo() -{ +void A::exp(int& i) { + ++i; + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodHistory.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodHistory.rts index 3196f88be81..34e7e832400 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodHistory.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodHistory.rts @@ -4,13 +4,12 @@ #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -21,16 +20,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - int exp(); + int exp(); }; #endif /*A_H_*/ @@ -38,62 +36,55 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; ++i; help(); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp() -{ - int i = 2; - ++i; - help(); - return i; +A::~A() { } -int A::foo() -{ +int A::exp() { + int i = 2; + ++i; + help(); + return i; +} + +int A::foo() { int i = exp(); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@refScript.xml - + @@ -103,13 +94,12 @@ int A::help() #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -120,16 +110,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -137,15 +126,13 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; //comment ++i; @@ -153,40 +140,35 @@ int A::foo() return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & i) -{ - //comment - ++i; - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& i) { + //comment + ++i; + help(); +} + +int A::foo() { int i = 2; //comment - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@refScript.xml @@ -194,32 +176,29 @@ int A::help() + name="exp" project="RegressionTestProject" selection="69,24" visibility="private"/> //!Extract Function History first extracted statement with leading comment //#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest //@main.cpp -int main(){ - +int main() { int i; // Comment - i= 7; + i = 7; return i; } //= -void exp(int & i) -{ - // Comment - i = 7; +void exp(int& i) { + // Comment + i = 7; } -int main(){ - +int main() { int i; // Comment - exp(i); + exp(i); return i; } @@ -229,29 +208,26 @@ int main(){ + name="exp" project="RegressionTestProject" selection="34,6" visibility="private"/> //!Extract Function History extracted statement with trailling comment //#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest //@main.cpp -int main(){ - +int main() { int i; - i= 7; // Comment + i = 7; // Comment return i; } //= -void exp(int & i) -{ - i = 7; // Comment +void exp(int& i) { + i = 7; // Comment } -int main(){ - +int main() { int i; - exp(i); // Comment + exp(i); // Comment return i; } @@ -261,7 +237,7 @@ int main(){ + name="exp" project="RegressionTestProject" selection="22,6" visibility="private"/> //!ExtractFunctionRefactoringTest duplicates with different Names History Test @@ -270,13 +246,12 @@ int main(){ #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -287,16 +262,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & i); + void exp(int& i); }; #endif /*A_H_*/ @@ -304,61 +278,56 @@ private: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; ++oo; help(); -}int A::foo() -{ +} + +int A::foo() { int i = 2; ++i; help(); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { int oo = 99; - exp(oo); -}void A::exp(int & i) -{ - ++i; - help(); + exp(oo); } -int A::foo() -{ +void A::exp(int& i) { + ++i; + help(); +} + +int A::foo() { int i = 2; - exp(i); + exp(i); return i; } -int A::help() -{ +int A::help() { return 42; -} +} //@refScript.xml - + name="exp" project="RegressionTestProject" replaceDuplicates="true" selection="99,13" visibility="private"/> diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodPreprocessor.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodPreprocessor.rts index 572b4e22545..23d300881a7 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodPreprocessor.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethodPreprocessor.rts @@ -4,13 +4,12 @@ #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); }; @@ -21,16 +20,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); - + private: int help(); - void exp(int & ii); + void exp(int& ii); }; #endif /*A_H_*/ @@ -40,15 +38,13 @@ private: #define ADD(a,ab) a + ab + 2 + a -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int ii = 2; /*$*/++ii; ii = ADD(ii, 42); @@ -56,41 +52,36 @@ int A::foo() return ii; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" #define ADD(a,ab) a + ab + 2 + a -A::A() -{ +A::A() { } -A::~A() -{ -} -void A::exp(int & ii) -{ - ++ii; - ii = ADD(ii, 42); - help(); +A::~A() { } -int A::foo() -{ +void A::exp(int& ii) { + ++ii; + ii = ADD(ii, 42); + help(); +} + +int A::foo() { int ii = 2; - exp(ii); + exp(ii); return ii; } -int A::help() -{ +int A::help() { return 42; -} +} //!Extract Method return value assinged to Macrocall Bug //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -101,14 +92,14 @@ returnparameterindex=1 #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + private: - int help(); + int help(); }; #endif /*A_H_*/ @@ -117,15 +108,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + private: - int help(); - int exp(int & i, int b); + int help(); + int exp(int& i, int b); }; #endif /*A_H_*/ @@ -135,62 +126,55 @@ private: #define ADD(b) b = b + 2 -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; int b = 42; /*$*/++i; - help(); - ADD(b);/*$$*/ + help(); + ADD(b);/*$$*/ b += 2; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" #define ADD(b) b = b + 2 -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp(int & i, int b) -{ - ++i; - help(); - ADD(b); - return b; +A::~A() { } -int A::foo() -{ +int A::exp(int& i, int b) { + ++i; + help(); + ADD(b); + return b; +} + +int A::foo() { int i = 2; int b = 42; - b = exp(i, b); + b = exp(i, b); b += 2; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //!Extract Method Methodlength with more than 1 Macrocall Bug //#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest @@ -202,14 +186,14 @@ replaceduplicates=true #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + private: - int help(); + int help(); }; #endif /*A_H_*/ @@ -218,15 +202,15 @@ private: #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); virtual ~A(); int foo(); + private: - int help(); - int exp(int bb); + int help(); + int exp(int bb); }; #endif /*A_H_*/ @@ -236,60 +220,53 @@ private: #define ADD(b) b = b + 2 -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } -int A::foo() -{ + +int A::foo() { int i = 2; int bb = 42; ++i; - /*$*/ADD(bb); - ADD(bb);/*$$*/ + /*$*/ADD(bb); + ADD(bb);/*$$*/ bb += 2; return i; } -int A::help() -{ +int A::help() { return 42; -} +} //= #include "A.h" #define ADD(b) b = b + 2 -A::A() -{ +A::A() { } -A::~A() -{ -} -int A::exp(int bb) -{ - ADD(bb); - ADD(bb); - return bb; +A::~A() { } -int A::foo() -{ +int A::exp(int bb) { + ADD(bb); + ADD(bb); + return bb; +} + +int A::foo() { int i = 2; int bb = 42; ++i; - bb = exp(bb); + bb = exp(bb); bb += 2; return i; } -int A::help() -{ +int A::help() { return 42; -} +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts index bd0232174f5..f81bfc2c568 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts @@ -3,16 +3,14 @@ //@.config filename=C.h getters=name -inHeader=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= @@ -21,40 +19,34 @@ int main(int argc, char **argv) { #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - - int getSystemId(){ + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -67,44 +59,38 @@ int gooo = 1; #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - char *getName() const - { - return name; - } - - int getSystemId(){ + + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + + char* getName() const { + return name; + } + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -117,16 +103,14 @@ int gooo = 1; //@.config filename=C.h getters=name -inHeader=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= @@ -135,44 +119,40 @@ int main(int argc, char **argv) { #define C_H_ namespace Personal { - class Person { - - private: - - int systemId; - - protected: - - char *name; - - public: - - const int socSecNo; - - Person myFriend; - - - Person(int socSecNo); // contructor - - ~Person(); // destructor - - - char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - - int getSystemId(){ - return systemId; - } - - void setSystemId(int systemId){ - this->systemId = systemId; - } - }; + +class Person { +private: + int systemId; + +protected: + char* name; + +public: + const int socSecNo; + + Person myFriend; + + Person(int socSecNo); // contructor + + ~Person(); // destructor + + char* Name(); + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + + int getSystemId() { + return systemId; + } + + void setSystemId(int systemId) { + this->systemId = systemId; + } +}; + } int gooo = 1; @@ -184,48 +164,44 @@ int gooo = 1; #define C_H_ namespace Personal { - class Person { - - private: - - int systemId; - - protected: - - char *name; - - public: - - const int socSecNo; - - Person myFriend; - - - Person(int socSecNo); // contructor - - ~Person(); // destructor - - - char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - char *getName() const - { - return name; - } - - int getSystemId(){ - return systemId; - } - - void setSystemId(int systemId){ - this->systemId = systemId; - } - }; + +class Person { +private: + int systemId; + +protected: + char* name; + +public: + const int socSecNo; + + Person myFriend; + + Person(int socSecNo); // contructor + + ~Person(); // destructor + + char* Name(); + + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + + char* getName() const { + return name; + } + + int getSystemId() { + return systemId; + } + + void setSystemId(int systemId) { + this->systemId = systemId; + } +}; + } int gooo = 1; @@ -237,16 +213,14 @@ int gooo = 1; //@.config filename=C.h setters=name -inHeader=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= @@ -255,40 +229,34 @@ int main(int argc, char **argv) { #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - - int getSystemId(){ + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -302,44 +270,38 @@ int gooo = 1; #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - void setName(char *name) - { - this->name = name; - } - - int getSystemId(){ + + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + + void setName(char* name) { + this->name = name; + } + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -354,16 +316,14 @@ int gooo = 1; filename=C.h setters=name getters=name -inHeader=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= @@ -372,40 +332,34 @@ int main(int argc, char **argv) { #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - - int getSystemId(){ + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -419,49 +373,42 @@ int gooo = 1; #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - char *getName() const - { - return name; - } - void setName(char *name) - { - this->name = name; - } - - int getSystemId(){ + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + + char* getName() const { + return name; + } + + void setName(char* name) { + this->name = name; + } + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -476,16 +423,14 @@ int gooo = 1; filename=C.h getters=name,systemId setters=name,systemId -inHeader=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= @@ -494,35 +439,28 @@ int main(int argc, char **argv) { #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); }; int gooo = 1; @@ -534,54 +472,44 @@ int gooo = 1; #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; - char *getName() const - { - return name; - } + Person myFriend; - int getSystemId() const - { - return systemId; - } + char* getName() const { + return name; + } - void setName(char *name) - { - this->name = name; - } + int getSystemId() const { + return systemId; + } - void setSystemId(int systemId) - { - this->systemId = systemId; - } + void setName(char* name) { + this->name = name; + } + void setSystemId(int systemId) { + this->systemId = systemId; + } - Person(int socSecNo); // contructor - - ~Person(); // destructor + Person(int socSecNo); // contructor + ~Person(); // destructor char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); + void Print(); + + int SocSecNo(); + + int GetUniqueId(); }; int gooo = 1; @@ -594,7 +522,6 @@ int gooo = 1; filename=GaS.h getters=i,ok setters=i,ok -inHeader=true //@GaS.cpp #include "Getters.h" @@ -631,25 +558,22 @@ public: virtual ~GaS(); bool ok; void method2(); - int getI() const - { - return i; - } - bool isOk() const - { - return ok; - } + int getI() const { + return i; + } - void setI(int i) - { - this->i = i; - } + bool isOk() const { + return ok; + } - void setOk(bool ok) - { - this->ok = ok; - } + void setI(int i) { + this->i = i; + } + + void setOk(bool ok) { + this->ok = ok; + } private: int i; @@ -663,14 +587,13 @@ private: filename=C.h getters=id setters=id -inHeader=true //@C.h #ifndef C_H_ #define C_H_ class Person { private: - int /*$*/id/*$$*/; + int /*$*/id/*$$*/; }; #endif /*C_H_*/ @@ -681,17 +604,16 @@ private: class Person { private: - int id; -public: - int getId() const - { - return id; - } + int id; - void setId(int id) - { - this->id = id; - } +public: + int getId() const { + return id; + } + + void setId(int id) { + this->id = id; + } }; #endif /*C_H_*/ @@ -702,7 +624,6 @@ public: filename=C.h getters=i setters=i -inHeader=true //@C.h /* * test.h @@ -712,8 +633,7 @@ inHeader=true #define TEST_H_ //comment1 -class test -{ +class test { int /*$*/i/*$$*/; //comment2 char* b; //comment3 @@ -730,21 +650,19 @@ class test #define TEST_H_ //comment1 -class test -{ +class test { int i; //comment2 char* b; -public: - int getI() const - { - return i; - } - - void setI(int i) - { - this->i = i; - } //comment3 + +public: + int getI() const { + return i; + } + + void setI(int i) { + this->i = i; + } }; #endif /* TEST_H_ */ @@ -763,8 +681,7 @@ fatalerror=true #define TEST_H_ //comment1 -class test -{ +class test { void /*$*/test/*$$*/(); //comment3 }; @@ -780,44 +697,41 @@ class test #define TEST_H_ //comment1 -class test -{ +class test { void test(); //comment3 }; #endif /* TEST_H_ */ -//!Generate Getters and Setters One Getter Selection Implementation in CPP +//!Generate Getters and Setters One Getter Selection Separate Definition //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=C.h getters=name +definitionSeparate=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= #include "C.h" -char *Person::getName() const -{ - return name; +char* Person::getName() const { + return name; } -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //@C.h @@ -825,37 +739,31 @@ int main(int argc, char **argv) { #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + int getSystemId(); - + void setSystemId(int systemId); }; @@ -867,49 +775,44 @@ int gooo = 1; #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; - char *getName() const; + Person myFriend; + char* getName() const; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - + + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + int getSystemId(); - + void setSystemId(int systemId); }; int gooo = 1; #endif /*C_H_*/ -//!Generate Getters and Setters One Getter Selection with Namespace Implementation in CPP +//!Generate Getters and Setters One Getter Selection with Namespace Separate Definition //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=C.h getters=name +definitionSeparate=true //@C.cpp #include "C.h" @@ -921,17 +824,17 @@ int Person::SocSecNo() { } // namespace Personal -int main(int argc, char **argv) { +int main(int argc, char** argv) { } //= #include "C.h" namespace Personal { - char *Person::getName() const - { - return name; - } + +char* Person::getName() const { + return name; +} int Person::SocSecNo() { return socSecNo; @@ -939,7 +842,7 @@ int Person::SocSecNo() { } // namespace Personal -int main(int argc, char **argv) { +int main(int argc, char** argv) { } //@C.h @@ -947,44 +850,40 @@ int main(int argc, char **argv) { #define C_H_ namespace Personal { - class Person { - - private: - - int systemId; - - protected: - - char *name; - - public: - - const int socSecNo; - - Person myFriend; - - - Person(int socSecNo); // contructor - - ~Person(); // destructor - - - char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - - int getSystemId(){ - return systemId; - } - - void setSystemId(int systemId){ - this->systemId = systemId; - } - }; + +class Person { +private: + int systemId; + +protected: + char* name; + +public: + const int socSecNo; + + Person myFriend; + + Person(int socSecNo); // contructor + + ~Person(); // destructor + + char* Name(); + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + + int getSystemId() { + return systemId; + } + + void setSystemId(int systemId) { + this->systemId = systemId; + } +}; + } int gooo = 1; @@ -996,82 +895,76 @@ int gooo = 1; #define C_H_ namespace Personal { - class Person { - - private: - - int systemId; - - protected: - - char *name; - - public: - - const int socSecNo; - - Person myFriend; - - - Person(int socSecNo); // contructor - - ~Person(); // destructor - - - char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - char *getName() const; - - int getSystemId(){ - return systemId; - } - - void setSystemId(int systemId){ - this->systemId = systemId; - } - }; + +class Person { +private: + int systemId; + +protected: + char* name; + +public: + const int socSecNo; + + Person myFriend; + + Person(int socSecNo); // contructor + + ~Person(); // destructor + + char* Name(); + + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + char* getName() const; + + int getSystemId() { + return systemId; + } + + void setSystemId(int systemId) { + this->systemId = systemId; + } +}; + } int gooo = 1; #endif /*C_H_*/ -//!Generate Getters and Setters One Setter Selection Implementation in CPP +//!Generate Getters and Setters One Setter Selection Separate Definition //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=C.h setters=name +definitionSeparate=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= #include "C.h" -void Person::setName(char *name) -{ - this->name = name; +void Person::setName(char* name) { + this->name = name; } -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } @@ -1080,40 +973,34 @@ int main(int argc, char **argv) { #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - - int getSystemId(){ + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -1127,41 +1014,35 @@ int gooo = 1; #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - void setName(char *name); - - int getSystemId(){ + + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + void setName(char* name); + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -1170,42 +1051,39 @@ public: int gooo = 1; #endif /*C_H_*/ -//!Getter and Setter Selection Implementation in CPP +//!Getter and Setter Selection Separate Definition //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=C.h setters=name getters=name +definitionSeparate=true //@C.cpp #include "C.h" -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //= #include "C.h" -char *Person::getName() const -{ - return name; +char* Person::getName() const { + return name; } -void Person::setName(char *name) -{ - this->name = name; +void Person::setName(char* name) { + this->name = name; } -int Person::SocSecNo(){ +int Person::SocSecNo() { return socSecNo; } -int main(int argc, char **argv) { - +int main(int argc, char** argv) { } //@C.h @@ -1213,40 +1091,34 @@ int main(int argc, char **argv) { #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int /*$*/SocSecNo/*$$*/(); - - int GetUniqueId(); - - int getSystemId(){ + + void Print(); + + int /*$*/SocSecNo/*$$*/(); + + int GetUniqueId(); + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -1261,42 +1133,36 @@ int gooo = 1; #define C_H_ class Person { - private: - - int systemId; + int systemId; protected: - - char *name; + char* name; public: + const int socSecNo; - const int socSecNo; - - Person myFriend; + Person myFriend; + Person(int socSecNo); // contructor - Person(int socSecNo); // contructor - - ~Person(); // destructor - + ~Person(); // destructor char* Name(); - - void Print(); - - int SocSecNo(); - - int GetUniqueId(); - char *getName() const; - void setName(char *name); - - int getSystemId(){ + + void Print(); + + int SocSecNo(); + + int GetUniqueId(); + char* getName() const; + void setName(char* name); + + int getSystemId() { return systemId; } - - void setSystemId(int systemId){ + + void setSystemId(int systemId) { this->systemId = systemId; } }; @@ -1306,20 +1172,20 @@ int gooo = 1; #endif /*C_H_*/ -//!Generate Getters and Setters no Methods Implementation in CPP +//!Generate Getters and Setters no Methods Separate Definition //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=C.h getters=id setters=id -infos=1 +definitionSeparate=true //@C.h #ifndef C_H_ #define C_H_ class Person { private: - int /*$*/id/*$$*/; + int /*$*/id/*$$*/; }; #endif /*C_H_*/ @@ -1330,33 +1196,31 @@ private: class Person { private: - int id; + int id; + public: - int getId() const; - void setId(int id); + int getId() const; + void setId(int id); }; -int Person::getId() const -{ - return id; +inline int Person::getId() const { + return id; } -void Person::setId(int id) -{ - this->id = id; +inline void Person::setId(int id) { + this->id = id; } - #endif /*C_H_*/ -//!No Methods Implementation in CPP +//!No Methods Separate Definition //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=C.h getters=i setters=i -infos=1 +definitionSeparate=true //@C.h /* * test.h @@ -1366,8 +1230,7 @@ infos=1 #define TEST_H_ //comment1 -class test -{ +class test { int /*$*/i/*$$*/; //comment2 char* b; //comment3 @@ -1384,28 +1247,25 @@ class test #define TEST_H_ //comment1 -class test -{ +class test { int i; //comment2 char* b; -public: - int getI() const; - void setI(int i); //comment3 + +public: + int getI() const; + void setI(int i); }; -int test::getI() const -{ - return i; +inline int test::getI() const { + return i; } -void test::setI(int i) -{ - this->i = i; +inline void test::setI(int i) { + this->i = i; } - #endif /* TEST_H_ */ //!Bug 323780 "Generate Getters and Setters..." crashes @@ -1414,69 +1274,66 @@ void test::setI(int i) filename=Test.h getters=testField setters=testField +definitionSeparate=true //@Test.h #ifndef TEST_H_ #define TEST_H_ -namespace foo -{ - class Test - { - int /*$*/testField/*$$*/; - void foo(); - }; -} +namespace foo { + +class Test { + int /*$*/testField/*$$*/; + void foo(); +}; + +} // namespace foo #endif //= #ifndef TEST_H_ #define TEST_H_ -namespace foo -{ - class Test - { - int testField; - void foo(); - public: - int getTestField() const; - void setTestField(int testField); - }; -} +namespace foo { + +class Test { + int testField; + void foo(); + +public: + int getTestField() const; + void setTestField(int testField); +}; + +} // namespace foo #endif //@Test.cpp #include "Test.h" -namespace foo -{ - - void Test::foo() - { - - } +namespace foo { + +void Test::foo() { +} + } //= #include "Test.h" -namespace foo -{ - int Test::getTestField() const - { - return testField; - } +namespace foo { + +int Test::getTestField() const { + return testField; +} + +void Test::setTestField(int testField) { + this->testField = testField; +} + +void Test::foo() { +} - void Test::setTestField(int testField) - { - this->testField = testField; - } - - void Test::foo() - { - - } } //!Bug 337040 - Insert definition in empty implementation file (.cxx) @@ -1485,13 +1342,13 @@ namespace foo filename=Test.h getters=testField setters=testField +definitionSeparate=true //@Test.h #ifndef TEST_H_ #define TEST_H_ -class Test -{ +class Test { int /*$*/testField/*$$*/; }; @@ -1500,12 +1357,12 @@ class Test #ifndef TEST_H_ #define TEST_H_ -class Test -{ +class Test { int testField; + public: - int getTestField() const; - void setTestField(int testField); + int getTestField() const; + void setTestField(int testField); }; #endif @@ -1513,31 +1370,26 @@ public: //= - - -int Test::getTestField() const -{ - return testField; +int Test::getTestField() const { + return testField; } -void Test::setTestField(int testField) -{ - this->testField = testField; +void Test::setTestField(int testField) { + this->testField = testField; } - //!Bug 337040 - Insert definition in empty implementation file in complex directory structure //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=component_b/public_headers/Test.h getters=testField setters=testField +definitionSeparate=true //@component_b/public_headers/Test.h #ifndef TEST_H_ #define TEST_H_ -class Test -{ +class Test { int /*$*/testField/*$$*/; }; @@ -1546,12 +1398,12 @@ class Test #ifndef TEST_H_ #define TEST_H_ -class Test -{ +class Test { int testField; + public: - int getTestField() const; - void setTestField(int testField); + int getTestField() const; + void setTestField(int testField); }; #endif @@ -1559,18 +1411,13 @@ public: //= - - -int Test::getTestField() const -{ - return testField; +int Test::getTestField() const { + return testField; } -void Test::setTestField(int testField) -{ - this->testField = testField; +void Test::setTestField(int testField) { + this->testField = testField; } - //@component_a/public_headers/Test.h //= diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts index a7633a3ad28..4184e0be140 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts @@ -8,11 +8,12 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*$*/void method2();/*$$*/ - std::string toString(); + A(); + /*$*/void method2();/*$$*/ + std::string toString(); + private: int i; }; @@ -25,13 +26,14 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); + int i; + void method2(); }; #endif /*A_H_*/ @@ -46,14 +48,15 @@ filename=A.h #include -class A{ +class A { public: - A(); - //Kommentar - /*$*/void method2();/*$$*/ - std::string toString(); + A(); + //Comment + /*$*/void method2();/*$$*/ + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -64,14 +67,15 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - //Kommentar - void method2(); + int i; + //Comment + void method2(); }; #endif /*A_H_*/ @@ -86,15 +90,15 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*Kommentar*/ - /*$*/void method2();/*$$*/ - std::string toString(); + A(); + /*Comment*/ + /*$*/void method2();/*$$*/ + std::string toString(); private: - int i; + int i; }; #endif /*A_H_*/ @@ -105,14 +109,15 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - /*Kommentar*/ - void method2(); + int i; + /*Comment*/ + void method2(); }; #endif /*A_H_*/ @@ -127,13 +132,14 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*$*/void method2();/*$$*///Kommentar - std::string toString(); + A(); + /*$*/void method2();/*$$*///Comment + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -144,13 +150,14 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); //Kommentar + int i; + void method2(); //Comment }; #endif /*A_H_*/ @@ -165,13 +172,14 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*$*/void method2();/*$$*//*Kommentar*/ - std::string toString(); + A(); + /*$*/void method2();/*$$*//*Comment*/ + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -182,13 +190,14 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); /*Kommentar*/ + int i; + void method2(); /*Comment*/ }; #endif /*A_H_*/ @@ -203,15 +212,16 @@ filename=A.h #include -class A{ +class A { public: - A(); - - //Kommentar - /*$*/void method2();/*$$*/ - std::string toString(); + A(); + + //Comment + /*$*/void method2();/*$$*/ + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -222,14 +232,15 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - //Kommentar - void method2(); + int i; + //Comment + void method2(); }; #endif /*A_H_*/ @@ -244,15 +255,16 @@ filename=A.h #include -class A{ +class A { public: - A(); + A(); + + /*Comment*/ + /*$*/void method2();/*$$*/ + std::string toString(); - /*Kommentar*/ - /*$*/void method2();/*$$*/ - std::string toString(); private: - int i; + int i; }; #endif /*A_H_*/ @@ -263,14 +275,15 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - /*Kommentar*/ - void method2(); + int i; + /*Comment*/ + void method2(); }; #endif /*A_H_*/ @@ -285,13 +298,14 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*$*/void method2();/*$$*///Kommentar - std::string toString(); + A(); + /*$*/void method2();/*$$*///Comment + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -302,13 +316,14 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); //Kommentar + int i; + void method2(); //Comment }; #endif /*A_H_*/ @@ -323,14 +338,15 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*$*/void method2();/*$$*//*Kommentar*/ + A(); + /*$*/void method2();/*$$*//*Comment*/ + + std::string toString(); - std::string toString(); private: - int i; + int i; }; #endif /*A_H_*/ @@ -340,13 +356,14 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); /*Kommentar*/ + int i; + void method2(); /*Comment*/ }; #endif /*A_H_*/ @@ -360,16 +377,17 @@ filename=A.h #include -class A{ +class A { public: - A(); - /* - * Kommentar - */ - /*$*/void method2();/*$$*/ - std::string toString(); + A(); + /* + * Comment + */ + /*$*/void method2();/*$$*/ + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -379,16 +397,17 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - /* - * Kommentar - */ - void method2(); + int i; + /* + * Comment + */ + void method2(); }; #endif /*A_H_*/ @@ -402,15 +421,16 @@ filename=A.h #include -class A{ +class A { public: - A(); + A(); /*$*/void method2();/*$$*/ /* - * Kommentar + * Comment */ - std::string toString(); + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -421,15 +441,16 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); /* - * Kommentar - */ + int i; + void method2(); /* + * Comment + */ }; #endif /*A_H_*/ @@ -444,18 +465,19 @@ filename=A.h #include -class A{ +class A { public: - A(); - /* - * Davor - */ - /*$*/void method2();/*$$*/ /* - * Kommentar + A(); + /* + * Davor + */ + /*$*/void method2();/*$$*/ /* + * Comment */ - std::string toString(); + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -466,18 +488,19 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - /* - * Davor - */ - void method2(); /* - * Kommentar - */ + int i; + /* + * Davor + */ + void method2(); /* + * Comment + */ }; #endif /*A_H_*/ @@ -492,14 +515,15 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*123*/ - /*$*/void method2();/*$$*///TEST - std::string toString(); + A(); + /*123*/ + /*$*/void method2();/*$$*///TEST + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -510,14 +534,15 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - /*123*/ - void method2(); //TEST + int i; + /*123*/ + void method2(); //TEST }; #endif /*A_H_*/ @@ -532,14 +557,15 @@ filename=A.h #include -class A{ +class A { public: - A(); - /*123*/ - /*$*/void method2();/*$$*//*TEST*/ - std::string toString(); + A(); + /*123*/ + /*$*/void method2();/*$$*//*TEST*/ + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -549,14 +575,15 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - /*123*/ - void method2(); /*TEST*/ + int i; + /*123*/ + void method2(); /*TEST*/ }; #endif /*A_H_*/ @@ -571,9 +598,9 @@ errors=1 #include -class A{ +class A { private: - /*$*/void method2();/*$$*/ + /*$*/void method2();/*$$*/ }; #endif /*A_H_*/ @@ -584,9 +611,9 @@ private: #include -class A{ +class A { private: - void method2(); + void method2(); }; #endif /*A_H_*/ @@ -601,10 +628,10 @@ filename=A.h #include -class A{ +class A { public: - /*$*/void method1();/*$$*/ - void method2(); + /*$*/void method1();/*$$*/ + void method2(); }; #endif /*A_H_*/ @@ -615,11 +642,12 @@ public: #include -class A{ +class A { public: - void method2(); + void method2(); + private: - void method1(); + void method1(); }; #endif /*A_H_*/ @@ -634,9 +662,9 @@ filename=A.h #include -class A{ +class A { public: - /*$*/void method1();/*$$*/void method2(); + /*$*/void method1();/*$$*/void method2(); }; #endif /*A_H_*/ @@ -647,11 +675,12 @@ public: #include -class A{ +class A { public: - void method2(); + void method2(); + private: - void method1(); + void method1(); }; #endif /*A_H_*/ @@ -666,11 +695,11 @@ filename=A.h #include -class A{ +class A { public: - //Kommentar - /*$*/void method1();/*$$*/ - void method2(); + //Comment + /*$*/void method1();/*$$*/ + void method2(); }; #endif /*A_H_*/ @@ -681,12 +710,13 @@ public: #include -class A{ +class A { public: - void method2(); + void method2(); + private: - //Kommentar - void method1(); + //Comment + void method1(); }; #endif /*A_H_*/ @@ -701,10 +731,10 @@ filename=A.h #include -class A{ +class A { public: - //Kommentar - /*$*/void method1();/*$$*/void method2(); + //Comment + /*$*/void method1();/*$$*/void method2(); }; #endif /*A_H_*/ @@ -715,12 +745,13 @@ public: #include -class A{ +class A { public: - void method2(); + void method2(); + private: - //Kommentar - void method1(); + //Comment + void method1(); }; #endif /*A_H_*/ @@ -733,13 +764,14 @@ private: #include -class A{ +class A { public: - A(); - void method2(); - std::string toString(); + A(); + void method2(); + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -750,13 +782,14 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); + int i; + void method2(); }; #endif /*A_H_*/ @@ -776,14 +809,15 @@ void A::/*$*/method2/*$$*/() #include -class A{ +class A { public: - A(); - //TEST 1 - void method2(); //TEST 2 - std::string toString(); + A(); + //TEST 1 + void method2(); //TEST 2 + std::string toString(); + private: - int i; + int i; }; #endif /*A_H_*/ @@ -794,14 +828,15 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - //TEST 1 - void method2(); //TEST 2 + int i; + //TEST 1 + void method2(); //TEST 2 }; #endif /*A_H_*/ @@ -823,14 +858,12 @@ filename=HideMethod.h class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void /*$*/methode2/*$$*/(); - void methode3() - { - methode2(); - } - + HideMethod(); + virtual ~HideMethod(); + void /*$*/methode2/*$$*/(); + void methode3() { + methode2(); + } }; #endif /* HIDEMETHOD_H_ */ @@ -841,16 +874,14 @@ public: class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void methode3() - { - methode2(); - } + HideMethod(); + virtual ~HideMethod(); + void methode3() { + methode2(); + } private: - void methode2(); - + void methode2(); }; #endif /* HIDEMETHOD_H_ */ @@ -865,10 +896,10 @@ filename=HideMethod.h class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void /*$*/methode2/*$$*/(); - void methode3(); + HideMethod(); + virtual ~HideMethod(); + void /*$*/methode2/*$$*/(); + void methode3(); }; #endif /* HIDEMETHOD_H_ */ @@ -879,11 +910,12 @@ public: class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void methode3(); + HideMethod(); + virtual ~HideMethod(); + void methode3(); + private: - void methode2(); + void methode2(); }; #endif /* HIDEMETHOD_H_ */ @@ -947,7 +979,7 @@ public: class test{ public: - void call(){ + void call() { HideMethod hm; hm.methode2(); } @@ -964,13 +996,14 @@ public: HideMethod(); virtual ~HideMethod(); void methode3(); + private: - void methode2(); + void methode2(); }; class test{ public: - void call(){ + void call() { HideMethod hm; hm.methode2(); } @@ -989,10 +1022,10 @@ warnings=1 class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void /*$*/methode2/*$$*/(); - void methode3(); + HideMethod(); + virtual ~HideMethod(); + void /*$*/methode2/*$$*/(); + void methode3(); }; #endif /* HIDEMETHOD_H_ */ @@ -1003,11 +1036,12 @@ public: class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void methode3(); + HideMethod(); + virtual ~HideMethod(); + void methode3(); + private: - void methode2(); + void methode2(); }; #endif /* HIDEMETHOD_H_ */ @@ -1032,7 +1066,7 @@ void HideMethod::methode3() { //do nothing } -int main(){ +int main() { HideMethod hm; hm.methode2(); } @@ -1058,7 +1092,7 @@ void HideMethod::methode3() { //do nothing } -int main(){ +int main() { HideMethod hm; hm.methode2(); } @@ -1073,10 +1107,10 @@ filename=HideMethod.h class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void methode2(); - void methode3(); + HideMethod(); + virtual ~HideMethod(); + void methode2(); + void methode3(); }; #endif /* HIDEMETHOD_H_ */ @@ -1087,11 +1121,12 @@ public: class HideMethod { public: - HideMethod(); - virtual ~HideMethod(); - void methode3(); + HideMethod(); + virtual ~HideMethod(); + void methode3(); + private: - void methode2(); + void methode2(); }; #endif /* HIDEMETHOD_H_ */ @@ -1146,7 +1181,7 @@ filename=A.h #include -class A{ +class A { public: /*$*/void method2();/*$$*/ }; @@ -1159,7 +1194,7 @@ public: #include -class A{ +class A { public: private: void method2(); @@ -1178,7 +1213,7 @@ errors=1 #include -class A{ +class A { /*$*/void method2();/*$$*/ }; @@ -1190,7 +1225,7 @@ class A{ #include -class A{ +class A { void method2(); }; @@ -1206,7 +1241,7 @@ filename=A.h #include -struct A{ +struct A { /*$*/void method2();/*$$*/ }; @@ -1218,7 +1253,7 @@ struct A{ #include -struct A{ +struct A { private: void method2(); }; @@ -1230,40 +1265,33 @@ private: //@.config filename=A.cpp //@A.cpp -struct other -{ - bool value() {return true;} +struct other { + bool value() { return true; } }; -class Klass -{ +class Class { public: - void /*$*/set/*$$*/(bool b){} - void test() - { - other o; - this->set(o.value()); + void /*$*/set/*$$*/(bool b) {} + void test() { + other o; + this->set(o.value()); } }; //= -struct other -{ - bool value() {return true;} +struct other { + bool value() { return true; } }; -class Klass -{ +class Class { public: - void test() - { - other o; - this->set(o.value()); - } + void test() { + other o; + this->set(o.value()); + } private: - void set(bool b) - { + void set(bool b) { } }; @@ -1272,40 +1300,35 @@ private: //@.config filename=A.cpp //@A.cpp -struct other -{ - bool value() {return true;} +struct other { + bool value() { return true; } }; -class Klass -{ +class Class { public: - void set(bool b){} - void test() - { - other o; - this->/*$*/set/*$$*/(o.value()); + void set(bool b) { + } + + void test() { + other o; + this->/*$*/set/*$$*/(o.value()); } }; //= -struct other -{ - bool value() {return true;} +struct other { + bool value() { return true; } }; -class Klass -{ +class Class { public: - void test() - { - other o; - this->set(o.value()); - } + void test() { + other o; + this->set(o.value()); + } private: - void set(bool b) - { + void set(bool b) { } }; @@ -1315,37 +1338,31 @@ private: filename=A.cpp warnings=1 //@A.cpp -struct other -{ - bool /*$*/value/*$$*/() {return true;} +struct other { + bool /*$*/value/*$$*/() { return true; } }; -class Klass -{ +class Class { public: - void set(bool b){} - void test() - { - other o; - this->set(o.value()); + void set(bool b) {} + void test() { + other o; + this->set(o.value()); } }; //= -struct other -{ +struct other { private: - bool value() {return true;} + bool value() { return true; } }; -class Klass -{ +class Class { public: - void set(bool b){} - void test() - { - other o; - this->set(o.value()); + void set(bool b) {} + void test() { + other o; + this->set(o.value()); } }; @@ -1354,38 +1371,36 @@ public: //@.config filename=A.cpp //@A.cpp -struct other -{ - bool value() {return true;} +struct other { + bool value() { return true; } }; -class Klass -{ +class Class { public: - void set(bool b){} - void /*$*/test/*$$*/() - { - other o; - this->set(o.value()); + void set(bool b) { + } + + void /*$*/test/*$$*/() { + other o; + this->set(o.value()); } }; //= -struct other -{ - bool value() {return true;} +struct other { + bool value() { return true; } }; -class Klass -{ +class Class { public: - void set(bool b){} + void set(bool b) { + } private: - void test() - { - other o; - this->set(o.value()); + + void test() { + other o; + this->set(o.value()); } }; @@ -1395,14 +1410,14 @@ private: filename=A.cpp fatalerrors=1 //@A.cpp -int /*$*/main/*$$*/(){ +int /*$*/main/*$$*/() { int i = 2; i++; return 0; } //= -int main(){ +int main() { int i = 2; i++; return 0; @@ -1413,22 +1428,20 @@ int main(){ //@.config filename=A.h //@A.h -class Klass -{ +class Class { public: - void /*$*/to_move()/*$$*/; + void /*$*/to_move()/*$$*/; private: - void just_private(); + void just_private(); }; //= -class Klass -{ +class Class { public: private: - void just_private(); - void to_move(); + void just_private(); + void to_move(); }; //!HideMethod several private sections @@ -1436,23 +1449,23 @@ private: //@.config filename=A.h //@A.h -class Klass -{ +class Class { public: - void /*$*/to_move()/*$$*/; + void /*$*/to_move()/*$$*/; private: - void just_private(); + void just_private(); + private: }; //= -class Klass -{ +class Class { public: private: - void just_private(); - void to_move(); + void just_private(); + void to_move(); + private: }; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts index 70f04a80d94..de72504e590 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts @@ -6,11 +6,12 @@ #include -class A{ +class A { public: - A(); - void method2(); - std::string toString(); + A(); + void method2(); + std::string toString(); + private: int i; }; @@ -23,13 +24,14 @@ private: #include -class A{ +class A { public: - A(); - std::string toString(); + A(); + std::string toString(); + private: - int i; - void method2(); + int i; + void method2(); }; #endif /*A_H_*/ @@ -40,5 +42,5 @@ private: + project="RegressionTestProject" selection="78,7"/> diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts index 7fc4d475cc9..c2d1a0d3a9e 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts @@ -15,12 +15,10 @@ public: bool a(int = 100) const; }; -inline bool X::a(int int1) const -{ +inline bool X::a(int int1) const { } - //!Param const and reference and pointer two params //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -38,37 +36,34 @@ public: bool xy(int, int i) const; }; -inline bool X::xy(int int1, int i) const -{ +inline bool X::xy(int int1, int i) const { } - //!Test if TemplateMethod stays in header //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h infos=1 //@A.h -template class A -{ +template +class A { public: - /*$*/void test();/*$$*/ + /*$*/void test();/*$$*/ }; //= -template class A -{ +template +class A { public: - void test(); + void test(); }; -template inline void A::test() -{ +template +inline void A::test() { } - //@A.cpp #include "A.h" @@ -81,45 +76,42 @@ template inline void A::test() filename=A.h infos=1 //@A.h -template class A -{ +template +class A { public: - A(); - /*$*/void test();/*$$*/ + A(); + /*$*/void test();/*$$*/ }; -template A::A() -{ +template +A::A() { } //= -template class A -{ +template +class A { public: - A(); - void test(); + A(); + void test(); }; -template A::A() -{ +template +A::A() { } -template inline void A::test() -{ +template +inline void A::test() { } - //!member class //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h -class Demo -{ - class SubClass - { +class Demo { + class SubClass { /*$*/void test();/*$$*/ }; }; @@ -131,102 +123,88 @@ class Demo //= #include "A.h" - - -void Demo::SubClass::test() -{ +void Demo::SubClass::test() { } - -//!method declared in otherwise empty class without cpp file +//!Method declared in otherwise empty class without cpp file //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h infos=1 //@A.h -class A -{ +class A { public: - /*$*/void test();/*$$*/ + /*$*/void test();/*$$*/ }; //= -class A -{ +class A { public: - void test(); + void test(); }; -inline void A::test() -{ +inline void A::test() { } - -//!method declared in otherwise empty class +//!Method declared in otherwise empty class //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h -class A -{ +class A { public: - /*$*/void test();/*$$*/ + /*$*/void test();/*$$*/ }; //= -class A -{ +class A { public: - void test(); + void test(); }; //@A.cpp //= - - -void A::test() -{ +void A::test() { } - -//!implement in existing namespace +//!Implement in existing namespace //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h -namespace NameSpace -{ - class ClassInNamespace - { - public: - int test(); - /*$*/void test2();/*$$*/ - }; +namespace Namespace { + +class ClassInNamespace { +public: + int test(); + /*$*/void test2();/*$$*/ +}; + } //@A.cpp #include "A.h" -namespace NameSpace -{ - int ClassInNamespace::test() - { - return 5; - } +namespace Namespace { + +int ClassInNamespace::test() { + return 5; +} + } //= #include "A.h" -namespace NameSpace -{ - int ClassInNamespace::test() - { - return 5; - } +namespace Namespace { + +int ClassInNamespace::test() { + return 5; +} + +void ClassInNamespace::test2() { +} - void ClassInNamespace::test2() - {} } //!virtual method in the middle of con/destructor, without parameters and void return value //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest @@ -236,8 +214,7 @@ filename=A.h #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); /*$*/virtual void foo();/*$$*/ @@ -248,30 +225,25 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } -A::~A() -{ +A::~A() { } //= #include "A.h" -A::A() -{ +A::A() { } -void A::foo() -{ +void A::foo() { } -A::~A() -{ +A::~A() { } -//!implement a function at start of source file +//!Implement a function at start of source file //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -279,18 +251,15 @@ filename=A.h /*$*/void function();/*$$*/ void function_with_impl(); //@A.cpp -void function_with_impl() -{ +void function_with_impl() { } //= -void function() -{ +void function() { } -void function_with_impl() -{ +void function_with_impl() { } -//!method at end, without parameters and void return value +//!Method at end, without parameters and void return value //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -298,8 +267,7 @@ filename=A.h #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); /*$*/void foo();/*$$*/ @@ -309,24 +277,20 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } //= #include "A.h" -A::A() -{ +A::A() { } -void A::foo() -{ +void A::foo() { } - -//!method at beginning, without parameters, void return value and const +//!Method at beginning, without parameters, void return value and const //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -334,8 +298,7 @@ filename=A.h #ifndef A_H_ #define A_H_ -class A -{ +class A { public: /*$*/void foo() const;/*$$*/ A(); @@ -345,22 +308,19 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } //= #include "A.h" -void A::foo() const -{ +void A::foo() const { } -A::A() -{ +A::A() { } -//!method with int return value +//!Method with int return value //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -368,8 +328,7 @@ filename=A.h #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); /*$*/int foo();/*$$*/ @@ -379,24 +338,20 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } //= #include "A.h" -A::A() -{ +A::A() { } -int A::foo() -{ +int A::foo() { } - -//!method with two int parameters +//!Method with two int parameters //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -404,8 +359,7 @@ filename=A.h #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); /*$*/int foo(int param1, int param2);/*$$*/ @@ -415,59 +369,49 @@ public: //@A.cpp #include "A.h" -A::A() -{ +A::A() { } //= #include "A.h" -A::A() -{ +A::A() { } -int A::foo(int param1, int param2) -{ +int A::foo(int param1, int param2) { } - -//!method defined in header +//!Method defined in header //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h infos=1 //@A.h -class A -{ +class A { public: - A(); - /*$*/void test();/*$$*/ + A(); + /*$*/void test();/*$$*/ }; -A::A() -{ +A::A() { } //= -class A -{ +class A { public: - A(); - void test(); + A(); + void test(); }; -A::A() -{ +A::A() { } -inline void A::test() -{ +inline void A::test() { } - -//!implement a function at end of source file +//!Implement a function at end of source file //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -475,113 +419,111 @@ filename=A.h void function_with_impl(); /*$*/void function();/*$$*/ //@A.cpp -void function_with_impl() -{ +void function_with_impl() { } //= -void function_with_impl() -{ +void function_with_impl() { } -void function() -{ +void function() { } - -//!implement with namespace +//!Implement with namespace //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h -namespace NameSpace -{ - class ClassInNamespace - { - public: - int other_test(); - /*$*/void test();/*$$*/ - }; +namespace Namespace { + +class ClassInNamespace { +public: + int other_test(); + /*$*/void test();/*$$*/ +}; + } //@A.cpp #include "A.h" -void NameSpace::ClassInNamespace::other_test() -{ +void Namespace::ClassInNamespace::other_test() { } //= #include "A.h" -void NameSpace::ClassInNamespace::other_test() -{ +void Namespace::ClassInNamespace::other_test() { } -void NameSpace::ClassInNamespace::test() -{ +void Namespace::ClassInNamespace::test() { } - -//!implement function within namespace +//!Implement function within namespace //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h namespace OuterSpace { - namespace NameSpace - { - int test(); - /*$*/int test2();/*$$*/ - } +namespace Namespace { + +int test(); +/*$*/int test2();/*$$*/ + +} } //@A.cpp #include "A.h" namespace OuterSpace { - int NameSpace::test() - { - } + +int Namespace::test() { +} + } //= #include "A.h" namespace OuterSpace { - int NameSpace::test() - { - } - int NameSpace::test2() - {} +int Namespace::test() { } -//!implement function within namespaces + +int Namespace::test2() { +} + +} +//!Implement function within namespaces //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h namespace OuterSpace { - namespace NameSpace - { - int test(); - /*$*/int test2();/*$$*/ - } +namespace Namespace { + +int test(); +/*$*/int test2();/*$$*/ + +} } //@A.cpp #include "A.h" namespace OuterSpace { - namespace NameSpace { - int test() - { - } - } +namespace Namespace { + +int test() { +} + +} } //= #include "A.h" namespace OuterSpace { - namespace NameSpace { - int test() - { - } +namespace Namespace { - int test2() - {} - } +int test() { +} + +int test2() { +} + +} } //!class template member functions with multiple templates //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest @@ -589,43 +531,41 @@ namespace OuterSpace { filename=A.h infos=1 //@A.h -template class A -{ +template +class A { public: - A(); - /*$*/void test();/*$$*/ + A(); + /*$*/void test();/*$$*/ }; -template A::A() -{ +template +A::A() { } //= -template class A -{ +template +class A { public: - A(); - void test(); + A(); + void test(); }; -template A::A() -{ +template +A::A() { } -template inline void A::test() -{ +template +inline void A::test() { } - //!with default parameters //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h -class Class -{ +class Class { public: /*$*/void test(int param1, int param2 = 5, int param3 = 10);/*$$*/ }; @@ -637,20 +577,15 @@ public: //= #include "A.h" - - -void Class::test(int param1, int param2, int param3) -{ +void Class::test(int param1, int param2, int param3) { } - //!static method //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h -class Class -{ +class Class { public: /*$*/static void test();/*$$*/ }; @@ -662,12 +597,8 @@ public: //= #include "A.h" - - -void Class::test() -{ +void Class::test() { } - //! Bug 238253 Pointer refence of the return value lost //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -686,21 +617,16 @@ public: //= #include "A.h" - - -int *TestClass::get(char *val) -{ +int* TestClass::get(char* val) { } - //! Bug 238554 void parameters //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h //@A.h -class Test -{ - public: +class Test { +public: /*$*/void doNothing(void);/*$$*/ }; @@ -711,12 +637,8 @@ class Test //= #include "A.h" - - -void Test::doNothing(void) -{ +void Test::doNothing(void) { } - //! Bug 282989 Refactor->Implement method option doesn't qualify the name in the method definition with a fully qualified container class name //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -726,10 +648,12 @@ infos=1 #ifndef TESTCLASS_H_ #define TESTCLASS_H_ -namespace nspace{ +namespace nspace { + class TestClass { -void /*$*/testMethod()/*$$*/; + void /*$*/testMethod()/*$$*/; }; + } #endif /* TESTCLASS_H_ */ @@ -738,18 +662,18 @@ void /*$*/testMethod()/*$$*/; #ifndef TESTCLASS_H_ #define TESTCLASS_H_ -namespace nspace{ +namespace nspace { + class TestClass { -void testMethod(); + void testMethod(); }; + } -inline void nspace::TestClass::testMethod() -{ +inline void nspace::TestClass::testMethod() { } - #endif /* TESTCLASS_H_ */ //!Bug 290110 Source-> Implement Method @@ -768,6 +692,7 @@ public: A(); ~A(); void testmethod(int x); + protected: class B { public: @@ -810,12 +735,10 @@ A::~A() { } } -void n1::n2::A::B::testmethod2() -{ +void n1::n2::A::B::testmethod2() { } - //!Bug 337040 - Insert definition in empty implementation file (.cxx) //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -832,12 +755,8 @@ public: //= - - -void TestClass::foo() -{ +void TestClass::foo() { } - //!Bug 355006 - NPE implementing template function //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -845,15 +764,32 @@ filename=A.h infos=1 //@A.h -/*$*/template void func(T&);/*$$*/ +/*$*/template +void func(T&);/*$$*/ +//= + +template +void func(T&); + +template +inline void func(T&) { +} + +//!Bug 363111 - Remove explicit in constructor definition +//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest +//@.config +filename=A.h +//@A.h + +class TestClass { +public: + /*$*/explicit TestClass();/*$$*/ +}; + + +//@A.cpp //= -template void func(T&); - -template inline void func(T& ) -{ -} - - - +TestClass::TestClass() { +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewCreationTest.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewCreationTest.rts index 998e7a844d2..61c750b2d60 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewCreationTest.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewCreationTest.rts @@ -6,7 +6,7 @@ newfilecreation=true newfiles=A.cpp //@A.h void /*$*/freefunction/*$$*/() { - return; + return; } //= void freefunction(); @@ -17,9 +17,8 @@ void freefunction(); #include "A.h" -void freefunction() -{ - return; +void freefunction() { + return; } //!FreefunctionFromImplToHeader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -28,9 +27,8 @@ filename=A.cpp newfilecreation=true newfiles=A.h //@A.cpp -void /*$*/freefunction/*$$*/() -{ - return; +void /*$*/freefunction/*$$*/() { + return; } //= #include "A.h" @@ -40,8 +38,7 @@ void /*$*/freefunction/*$$*/() //= -void freefunction() -{ - return; +void freefunction() { + return; } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewImplementRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewImplementRefactoring.rts index 1b8b79b1022..95e338f8e91 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewImplementRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/NewImplementRefactoring.rts @@ -7,16 +7,14 @@ filename=A.h using namespace std; class A { - int /*$*/member/*$$*/(); + int /*$*/member/*$$*/(); }; //= #include using namespace std; class A { - int member() - { - return int(); - } - + int member() { + return int(); + } }; \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts index 6f9e5856cc9..61351a117fc 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts @@ -4,208 +4,190 @@ filename=A.h //@A.h class A { - void /*$*/member/*$$*/() - { - // return comment - return; - } + void /*$*/member/*$$*/() { + // return comment + return; + } }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - // return comment - return; +inline void A::member() { + // return comment + return; } - //!ClassToHeaderTopCommentOrder //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - // First Top Comment - // Second Top Comment - void /*$*/member/*$$*/() - { - return; - } + // First Top Comment + // Second Top Comment + void /*$*/member/*$$*/() { + return; + } }; //= class A { - // First Top Comment - // Second Top Comment - void member(); + // First Top Comment + // Second Top Comment + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - //!ClassToHeaderCatchComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void /*$*/member/*$$*/() try - { - return; - } catch (int i) { - // catch comment - } + void /*$*/member/*$$*/() try + { + return; + } + catch (int i) { + // catch comment + } }; //= class A { - void member(); + void member(); }; inline void A::member() -try -{ - return; +try { + return; } -catch(int i){ - // catch comment +catch (int i) { + // catch comment } - //!ClassToHeaderTopComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - // Top comment - void /*$*/member/*$$*/() - { - return; - } + // Top comment + void /*$*/member/*$$*/() { + return; + } }; //= class A { - // Top comment - void member(); + // Top comment + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - //!ClassToHeaderTemplateTopComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - // Top comment - template - T /*$*/member/*$$*/() - { - return T(); - } + // Top comment + template + T /*$*/member/*$$*/() { + return T(); + } }; //= class A { - // Top comment - template - T member(); + // Top comment + template + T member(); }; // Top comment -template inline T A::member() -{ - return T(); +template +inline T A::member() { + return T(); } - //!ClassToHeaderTrailingComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void /*$*/member/*$$*/() - { - return; - } // Trailing comment + void /*$*/member/*$$*/() { + return; + } // Trailing comment }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } // Trailing comment - //!ClassToHeaderTrailingCommentWithTryBlock //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void /*$*/member/*$$*/() try - { - return; - } catch (int e) { - } // Trailing comment + void /*$*/member/*$$*/() + try { + return; + } + catch (int e) { + } // Trailing comment }; //= class A { - void member(); + void member(); }; inline void A::member() -try -{ - return; +try { + return; } -catch(int e){ +catch (int e) { } - // Trailing comment - +// Trailing comment //!ClassToHeaderTrailingMultipleCommentsInTryBlock //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - int /*$*/member/*$$*/() try - { - // aans - } /* one */ catch (int i) { - // zwaa - } /* two */ catch (int j) { - // draa - } /* three */ + int /*$*/member/*$$*/() + try { + // aans + } /* one */ catch (int i) { + // zwaa + } /* two */ catch (int j) { + // draa + } /* three */ }; //= class A { - int member(); + int member(); }; inline int A::member() -try -{ - // aans +try { + // aans } /* one */ -catch(int i){ - // zwaa +catch (int i) { + // zwaa } - /* two */catch(int j){ - // draa +/* two */catch (int j) { + // draa } - /* three */ - +/* three */ diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToClass.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToClass.rts index e3c4166f074..61c768a4c0b 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToClass.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToClass.rts @@ -5,21 +5,21 @@ filename=A.h //@A.h template class A { - T /*$*/member/*$$*/(); + T /*$*/member/*$$*/(); }; -template inline T A::member() { - // body comment - return T(); +template +inline T A::member() { + // body comment + return T(); } //= template class A { - T member() - { - // body comment - return T(); - } + T member() { + // body comment + return T(); + } }; @@ -32,27 +32,25 @@ template class A { // First comment // Second comment - T /*$*/member/*$$*/(); + T /*$*/member/*$$*/(); }; // Third comment // Fourth comment template -inline T A::member() -{ - return T(); +inline T A::member() { + return T(); } //= template class A { // Third comment - // Fourth comment - // First comment - // Second comment - T member() - { - return T(); - } + // Fourth comment + // First comment + // Second comment + T member() { + return T(); + } }; @@ -65,32 +63,35 @@ filename=A.h //@A.h template class A { - T /*$*/member/*$$*/(); + T /*$*/member/*$$*/(); }; -template inline T A::member() try { - // body comment - return T(); -} catch(int e) { - // Catch 1 -} catch(int e) { - // Catch 2 +template +inline T A::member() +try { + // body comment + return T(); +} +catch (int e) { + // Catch 1 +} +catch (int e) { + // Catch 2 } //= template class A { - T member() - try - { - // body comment - return T(); - } - catch(int e){ - // Catch 1 - } - catch(int e){ - // Catch 2 - } + T member() + try { + // body comment + return T(); + } + catch (int e) { + // Catch 1 + } + catch (int e) { + // Catch 2 + } }; @@ -101,29 +102,27 @@ filename=A.h //@A.h template class A { - // Top Comment - template - T /*$*/member/*$$*/(); + // Top Comment + template + T /*$*/member/*$$*/(); }; // 2nd Top Comment template template inline T A::member() { - // body comment - return T(); + // body comment + return T(); } //= template class A { - // Top Comment - template - T member() - { - // body comment - return T(); - } - + // Top Comment + template + T member() { + // body comment + return T(); + } }; @@ -136,21 +135,21 @@ filename=A.h //@A.h template class A { - T /*$*/member/*$$*/(); + T /*$*/member/*$$*/(); }; // Top comment -template inline T A::member() { - return T(); +template +inline T A::member() { + return T(); } //= template class A { - // Top comment - T member() - { - return T(); - } + // Top comment + T member() { + return T(); + } }; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToImpl.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToImpl.rts index a5c548880a1..7ac828d6e94 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToImpl.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsHeaderToImpl.rts @@ -4,16 +4,16 @@ filename=A.h //@A.h class A { - void /*$*/member/*$$*/(); + void /*$*/member/*$$*/(); }; inline void A::member() { - // body comment - return; + // body comment + return; } //= class A { - void member(); + void member(); }; @@ -22,30 +22,27 @@ class A { //= #include "A.h" - -void A::member() -{ - // body comment - return; +void A::member() { + // body comment + return; } - //!HeaderToImplTryCatchComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void /*$*/member/*$$*/(); + void /*$*/member/*$$*/(); }; inline void A::member() try { - // body comment - return; + // body comment + return; } catch /*1*/ (int e) { /*2*/ } catch /*3*/ (int e) { /*4*/ } //= class A { - void member(); + void member(); }; @@ -54,37 +51,34 @@ class A { //= #include "A.h" - void A::member() -try -{ - // body comment - return; +try { + // body comment + return; } -catch(/*1*/int e){ - /*2*/ +catch (/*1*/int e) { + /*2*/ } -catch(/*3*/int e){ - /*4*/ +catch (/*3*/int e) { + /*4*/ } - //!HeaderToImplTopComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void /*$*/member/*$$*/(); + void /*$*/member/*$$*/(); }; // Top comment inline void A::member() { - // body comment - return; + // body comment + return; } //= class A { - void member(); + void member(); }; @@ -94,14 +88,11 @@ class A { //= #include "A.h" - // Top comment -void A::member() -{ - // body comment - return; +void A::member() { + // body comment + return; } - //!HeaderToImplFreeFuncTopComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -109,7 +100,7 @@ filename=A.h //@A.h // Definition comment void /*$*/member/*$$*/() { - return; + return; } //= // Definition comment @@ -121,11 +112,7 @@ void member(); //= #include "A.h" - - // Definition comment -void member() -{ - return; +void member() { + return; } - diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts index 46e33666500..62f1a398f6e 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts @@ -5,10 +5,9 @@ filename=A.cpp //@A.cpp #include "A.h" -void A::/*$*/member/*$$*/() -{ - // body comment - return; +void A::/*$*/member/*$$*/() { + // body comment + return; } //= #include "A.h" @@ -16,15 +15,14 @@ void A::/*$*/member/*$$*/() //@A.h class A { - void member(); + void member(); }; //= class A { - void member() - { - // body comment - return; - } + void member() { + // body comment + return; + } }; //!ImplToHeaderTopComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -34,9 +32,8 @@ filename=A.cpp #include "A.h" // Definition comment -void A::/*$*/member/*$$*/() -{ - return; +void A::/*$*/member/*$$*/() { + return; } //= #include "A.h" @@ -45,15 +42,14 @@ void A::/*$*/member/*$$*/() //@A.h class A { - void member(); + void member(); }; //= class A { - // Definition comment - void member() - { - return; - } + // Definition comment + void member() { + return; + } }; //!ImplToHeaderTryCatchComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -63,9 +59,8 @@ filename=A.cpp #include "A.h" // Definition comment -void A::/*$*/member/*$$*/() try -{ - return; +void A::/*$*/member/*$$*/() try { + return; } /*1*/ catch (int e) { /*2*/ } /*3*/ catch (int e) { /*4*/ } //= #include "A.h" @@ -74,22 +69,21 @@ void A::/*$*/member/*$$*/() try //@A.h class A { - void member(); + void member(); }; //= class A { - // Definition comment - void member() - try - { - return; - } /*1*/ - catch(int e){ - /*2*/ - } - /*3*/catch(int e){ - /*4*/ - } + // Definition comment + void member() + try { + return; + } /*1*/ + catch (int e) { + /*2*/ + } + /*3*/catch (int e) { + /*4*/ + } }; //!ImplToHeaderBodyCommentWithoutDeclaration //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -98,10 +92,9 @@ filename=A.cpp //@A.cpp #include "A.h" -void /*$*/member/*$$*/() -{ - // body comment - return; +void /*$*/member/*$$*/() { + // body comment + return; } //= #include "A.h" @@ -111,14 +104,10 @@ void /*$*/member/*$$*/() //= - - -void member() -{ - // body comment - return; +void member() { + // body comment + return; } - //!ImplToHeaderTopCommentWithoutDeclaration //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -127,10 +116,9 @@ filename=A.cpp #include "A.h" // Top comment -void /*$*/member/*$$*/() -{ - // body comment - return; +void /*$*/member/*$$*/() { + // body comment + return; } //= #include "A.h" @@ -141,12 +129,8 @@ void /*$*/member/*$$*/() //= - - // Top comment -void member() -{ - // body comment - return; +void member() { + // body comment + return; } - diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts index 8e84291e3d0..04ec07acf62 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts @@ -7,36 +7,34 @@ filename=A.h class A { private: - int a; - int b; + int a; + int b; + public: - /*$*/A/*$$*/(int x, int y) - :a(x), b(y) - {} - ~A() - { - } + /*$*/A/*$$*/(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; //= #include class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y); - ~A() - { - } + A(int x, int y); + ~A() { + } }; -inline A::A(int x, int y) -:a(x), b(y) -{ +inline A::A(int x, int y) : + a(x), b(y) { } - //!TestConstructorToggleInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -46,31 +44,30 @@ filename=A.h class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y); - ~A() - { - } + A(int x, int y); + ~A() { + } }; -inline A::/*$*/A/*$$*/(int x, int y) -:a(x), b(y) -{ +inline A::/*$*/A/*$$*/(int x, int y) : + a(x), b(y) { } //= #include class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y); - ~A() - { - } + A(int x, int y); + ~A() { + } }; @@ -78,21 +75,19 @@ public: #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -A::A(int x, int y) -:a(x), b(y) -{ +A::A(int x, int y) : + a(x), b(y) { } - //!TestConstructorToggleInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -100,13 +95,12 @@ filename=A.cpp //@A.cpp #include "A.h" -A::/*$*/A/*$$*/(int x, int y) -:a(x), b(y) -{ +A::/*$*/A/*$$*/(int x, int y) : + a(x), b(y) { } int main() { - return 0; + return 0; } //= #include "A.h" @@ -114,28 +108,25 @@ int main() { int main() { - return 0; + return 0; } //@A.h #include class A { - A(int x, int y); - ~A() - { - } + A(int x, int y); + ~A() { + } }; //= #include class A { - A(int x, int y) - :a(x), b(y) - { - } - ~A() - { - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; //!TestDestructorToggleInClassToInHeader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -146,28 +137,28 @@ filename=A.h class A { private: - int a; - int b; + int a; + int b; + public: - /*$*/~A/*$$*/() - {} + /*$*/~A/*$$*/() { + } }; //= #include class A { private: - int a; - int b; + int a; + int b; + public: - ~A(); + ~A(); }; -inline A::~A() -{ +inline A::~A() { } - //!TestDestructorToggleInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -177,24 +168,25 @@ filename=A.h class A { private: - int a; - int b; + int a; + int b; + public: - ~A(); + ~A(); }; -inline /*$*/A::~A/*$$*/() -{ +inline /*$*/A::~A/*$$*/() { } //= #include class A { private: - int a; - int b; + int a; + int b; + public: - ~A(); + ~A(); }; @@ -202,20 +194,18 @@ public: #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -A::~A() -{ +A::~A() { } - //!TestDestructorToggleInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -223,15 +213,14 @@ filename=A.cpp //@A.cpp #include "A.h" -/*$*/A::~A/*$$*/() -{ - int x; - int y; - return; +/*$*/A::~A/*$$*/() { + int x; + int y; + return; } int main() { - return 0; + return 0; } //= #include "A.h" @@ -239,28 +228,27 @@ int main() { int main() { - return 0; + return 0; } //@A.h #include class A { - A(int x, int y) - :a(x), b(y) - {} - ~A(); + A(int x, int y) : + a(x), b(y) { + } + ~A(); }; //= #include class A { - A(int x, int y) - :a(x), b(y) - {} - ~A() - { - int x; - int y; - return; - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + int x; + int y; + return; + } }; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts index 53c44c6cd8f..d1d2fa2b715 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts @@ -6,24 +6,21 @@ filename=A.h #include class A { - void /*$*/member/*$$*/(int a=0, int b=0) - { - return; - } + void /*$*/member/*$$*/(int a = 0, int b = 0) { + return; + } }; //= #include class A { - void member(int a=0, int b=0); + void member(int a = 0, int b = 0); }; -inline void A::member(int a, int b) -{ - return; +inline void A::member(int a, int b) { + return; } - //!TestDefaultParameterInitializerInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -32,18 +29,17 @@ filename=A.h #include class A { - void member(int a=0, int b=0); + void member(int a = 0, int b = 0); }; -inline void /*$*/A::member/*$$*/(int a, int b) -{ - return; +inline void /*$*/A::member/*$$*/(int a, int b) { + return; } //= #include class A { - void member(int a=0, int b=0); + void member(int a = 0, int b = 0); }; @@ -51,21 +47,19 @@ class A { #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -void A::member(int a, int b) -{ - return; +void A::member(int a, int b) { + return; } - //!TestDefaultParameterInitializerInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -73,36 +67,32 @@ filename=A.cpp //@A.cpp #include "A.h" -void A::/*$*/member/*$$*/(int a, int b) -{ - return; +void A::/*$*/member/*$$*/(int a, int b) { + return; } -int main() -{ - return 0; +int main() { + return 0; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //@A.h #include class A { - void member(int a = 0, int b = 0); + void member(int a = 0, int b = 0); }; //= #include class A { - void member(int a = 0, int b = 0) - { - return; - } + void member(int a = 0, int b = 0) { + return; + } }; \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDifferentSelections.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDifferentSelections.rts index f885a692437..535e98acf15 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDifferentSelections.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDifferentSelections.rts @@ -6,18 +6,17 @@ filename=A.cpp #include "A.h" int main() { - return 0; + return 0; } -void N::A::/*$*/foo/*$$*/() -{ - return; +void N::A::/*$*/foo/*$$*/() { + return; } //= #include "A.h" int main() { - return 0; + return 0; } @@ -26,21 +25,24 @@ int main() { #include namespace N { - class A { - void foo(); - }; + +class A { + void foo(); +}; + } //= #include #include namespace N { - class A { - void foo() - { - return; - } - }; + +class A { + void foo() { + return; + } +}; + } //!TestImplementationToClassWithDeclarationSelected //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -51,9 +53,11 @@ filename=A.h #include namespace N { - class A { - void /*$*/foo/*$$*/(); - }; + +class A { + void /*$*/foo/*$$*/(); +}; + } //= @@ -61,28 +65,30 @@ namespace N { #include namespace N { - class A { - void foo() - { - return; - } - }; + +class A { + void foo() { + return; + } +}; + } //@A.cpp #include "A.h" int main() { - return 0; + return 0; } -void N::A::foo() -{ - return; + +void N::A::foo() { + return; } //= #include "A.h" int main() { - return 0; + return 0; } + diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleErrorRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleErrorRefactoring.rts index bdeca96e7ce..307f138e3ef 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleErrorRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleErrorRefactoring.rts @@ -7,11 +7,11 @@ fatalerror=true class A { public: - void foo() - { - } + void foo() { + } + private: - int /*$*/x/*$$*/; + int /*$*/x/*$$*/; }; //!TestNotSupportedNoDefinition @@ -23,14 +23,13 @@ fatalerror=true class A { public: - void /*$*/foo/*$$*/(); + void /*$*/foo/*$$*/(); }; //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //!TestNotSupportedNoTranslationunit @@ -42,7 +41,7 @@ fatalerror=true class A { public: - void /*$*/foo/*$$*/(); + void /*$*/foo/*$$*/(); }; //!TestMultipleDeclarations @@ -54,15 +53,14 @@ fatalerror=true #include class A { - void /*$*/foo/*$$*/(); - void foo(); + void /*$*/foo/*$$*/(); + void foo(); }; //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //!TestMultipledefinitions @@ -73,28 +71,23 @@ fatalerror=true #include class A { - void foo(); - void /*$*/foo/*$$*/() - { - return; - } + void foo(); + void /*$*/foo/*$$*/() { + return; + } }; -void blah() -{ - +void blah() { } -inline void A::foo() -{ - return; +inline void A::foo() { + return; } //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //!TestNotSupportedNestedFunctions @@ -105,9 +98,8 @@ fatalerror=true #include class A { - void foo() - { - void /*$*/bar/*$$*/() { - } - } + void foo() { + void /*$*/bar/*$$*/() { + } + } }; \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts index 1166da4888c..57cf41340c6 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts @@ -7,57 +7,55 @@ filename=A.h class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y) - :a(x), b(y) - {} - ~A() - { - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; -int /*$*/freeFunction/*$$*/(int *a, int & b) { - return 42; +int /*$*/freeFunction/*$$*/(int* a, int& b) { + return 42; } //= #include class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y) - :a(x), b(y) - {} - ~A() - { - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; -int freeFunction(int *a, int & b); +int freeFunction(int* a, int& b); //@A.cpp #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -int freeFunction(int *a, int & b) -{ - return 42; +int freeFunction(int* a, int& b) { + return 42; } - //!TestFreeFunctionToggleFromImplementationToHeaderWithDeclaration //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -66,18 +64,17 @@ filename=A.cpp #include "A.h" int main() { - return 0; + return 0; } -int /*$*/freeFunction/*$$*/(int *a, int & b) -{ - return 42; +int /*$*/freeFunction/*$$*/(int* a, int& b) { + return 42; } //= #include "A.h" int main() { - return 0; + return 0; } @@ -86,40 +83,38 @@ int main() { class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y) - :a(x), b(y) - {} - ~A() - { - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; -int freeFunction(int *a, int & b); +int freeFunction(int* a, int& b); //= #include class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y) - :a(x), b(y) - {} - ~A() - { - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; -int freeFunction(int *a, int & b) -{ - return 42; +int freeFunction(int* a, int& b) { + return 42; } - //!TestFreeFunctionToggleFromImplementationToHeaderWithOutDeclaration //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -128,20 +123,20 @@ filename=A.cpp #include "A.h" int main() { - return 0; + return 0; } -int /*$*/freeFunction/*$$*/(int *a, int & b) +int /*$*/freeFunction/*$$*/(int* a, int& b) try { - return 42; -} catch (std::exception & e) -{ + return 42; +} +catch (std::exception& e) { } //= #include "A.h" int main() { - return 0; + return 0; } @@ -150,15 +145,15 @@ int main() { class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y) - :a(x), b(y) - {} - ~A() - { - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; //= @@ -166,35 +161,32 @@ public: class A { private: - int a; - int b; + int a; + int b; + public: - A(int x, int y) - :a(x), b(y) - {} - ~A() - { - } + A(int x, int y) : + a(x), b(y) { + } + ~A() { + } }; -int freeFunction(int *a, int & b) -try -{ - return 42; +int freeFunction(int* a, int& b) +try { + return 42; } -catch(std::exception & e){ +catch (std::exception& e) { } - //!TestFreeFunction //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h -int /*$*/freeFunction/*$$*/() -{ - return 42; +int /*$*/freeFunction/*$$*/() { + return 42; } //= int freeFunction(); @@ -204,12 +196,9 @@ int freeFunction(); //= #include "A.h" - -int freeFunction() -{ - return 42; +int freeFunction() { + return 42; } - //!TestQualifiedNameToggle //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -218,18 +207,15 @@ fatalerror=true //@A.cpp #include "A.h" -int /*$*/A::freefunction/*$$*/() -{ - return 42; +int /*$*/A::freefunction/*$$*/() { + return 42; } //= #include "A.h" -int A::freefunction() -{ - return 42; +int A::freefunction() { + return 42; } - //!TestNamespacedFreeFunction //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -241,10 +227,11 @@ filename=A.h #include namespace N { - void /*$*/freefunction/*$$*/() - { - return; - } + +void /*$*/freefunction/*$$*/() { + return; +} + } #endif /* A_H_ */ @@ -255,7 +242,9 @@ namespace N { #include namespace N { - void freefunction(); + +void freefunction(); + } #endif /* A_H_ */ @@ -263,21 +252,20 @@ namespace N { #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -namespace N -{ - void freefunction() - { - return; - } +namespace N { + +void freefunction() { + return; +} } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts index 568bf32d6ba..598bf314c06 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts @@ -7,24 +7,28 @@ filename=A.h #include namespace N { - class A { - void /*$*/foo/*$$*/() { - return; - } - }; + +class A { + void /*$*/foo/*$$*/() { + return; + } +}; + } //= #include #include namespace N { - class A { - void foo(); - }; - inline void A::foo() - { - return; - } + +class A { + void foo(); +}; + +inline void A::foo() { + return; +} + } //!TestSimpleNamespaceInHeaderToImplementationWithinNSDefinition //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -35,42 +39,45 @@ filename=A.h #include namespace N { - class A { - void foo(); - }; - inline void A::/*$*/foo/*$$*/() - { - return; - } + +class A { + void foo(); +}; + +inline void A::/*$*/foo/*$$*/() { + return; +} + } //= #include #include namespace N { - class A { - void foo(); - }; + +class A { + void foo(); +}; + } //@A.cpp #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -namespace N -{ - void A::foo() - { - return; - } +namespace N { + +void A::foo() { + return; +} } @@ -83,13 +90,14 @@ filename=A.h #include namespace N { - class A { - void foo(); - }; - inline void A::/*$*/foo/*$$*/() - { - return; - } + +class A { + void foo(); +}; + +inline void A::/*$*/foo/*$$*/() { + return; +} } //= @@ -97,34 +105,33 @@ namespace N { #include namespace N { - class A { - void foo(); - }; + +class A { + void foo(); +}; } //@A.cpp #include "A.h" int main() { - return 0; + return 0; } -namespace N -{ +namespace N { } //= #include "A.h" int main() { - return 0; + return 0; } -namespace N -{ - void A::foo() - { - return; - } +namespace N { + +void A::foo() { + return; +} } //!TestSimpleNamespaceInHeaderToImplementationWithNamespaceQualifiedName //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -135,23 +142,26 @@ filename=A.h #include namespace N { - class A { - void foo(); - }; + +class A { + void foo(); +}; + } -inline void /*$*/N::A::foo/*$$*/() -{ - return; +inline void /*$*/N::A::foo/*$$*/() { + return; } //= #include #include namespace N { - class A { - void foo(); - }; + +class A { + void foo(); +}; + } @@ -159,21 +169,20 @@ namespace N { #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -namespace N -{ - void A::foo() - { - return; - } +namespace N { + +void A::foo() { + return; +} } @@ -184,42 +193,42 @@ filename=A.cpp //@A.cpp #include "A.h" -void /*$*/N::A::foo/*$$*/() -{ - return; +void /*$*/N::A::foo/*$$*/() { + return; } -int main() -{ - return 0; +int main() { + return 0; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //@A.h #include namespace N { - class A { - void foo(); - }; + +class A { + void foo(); +}; + } //= #include namespace N { - class A { - void foo() - { - return; - } - }; + +class A { + void foo() { + return; + } +}; + } //!TestRemoveEmptyNamespaceFromImplentation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -229,10 +238,11 @@ filename=A.cpp #include "A.h" namespace N { - void /*$*/A::foo/*$$*/() - { - return; - } + +void /*$*/A::foo/*$$*/() { + return; +} + } //= #include "A.h" @@ -242,18 +252,21 @@ namespace N { #include namespace N { - class A { - void foo(); - }; + +class A { + void foo(); +}; + } //= #include namespace N { - class A { - void foo() - { - return; - } - }; -} \ No newline at end of file + +class A { + void foo() { + return; + } +}; + +} diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts index 012f07668e2..d73288018e8 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts @@ -6,27 +6,25 @@ filename=A.h #include class A { - class B { - void /*$*/member/*$$*/(int a, int b) { - return; - } - }; + class B { + void /*$*/member/*$$*/(int a, int b) { + return; + } + }; }; //= #include class A { - class B { - void member(int a, int b); - }; + class B { + void member(int a, int b); + }; }; -inline void A::B::member(int a, int b) -{ - return; +inline void A::B::member(int a, int b) { + return; } - //!TestNestedClassInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -35,46 +33,41 @@ filename=A.h #include class A { - class B { - void member(int a, int b); - }; + class B { + void member(int a, int b); + }; }; -inline void A::B::/*$*/member/*$$*/(int a, int b) -{ - return; +inline void A::B::/*$*/member/*$$*/(int a, int b) { + return; } //= #include class A { - class B { - void member(int a, int b); - }; + class B { + void member(int a, int b); + }; }; //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } -void A::B::member(int a, int b) -{ - return; +void A::B::member(int a, int b) { + return; } - //!TestNestedClassInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -82,21 +75,18 @@ filename=A.cpp //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } -void A::B::/*$*/member/*$$*/(int a, int b) -{ - return; +void A::B::/*$*/member/*$$*/(int a, int b) { + return; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } @@ -104,18 +94,17 @@ int main() #include class A { - class B { - void member(int a, int b); - }; + class B { + void member(int a, int b); + }; }; //= #include class A { - class B { - void member(int a, int b) - { - return; - } - }; + class B { + void member(int a, int b) { + return; + } + }; }; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleOrdering.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleOrdering.rts index 005ad09617f..6c1ccc5b5f9 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleOrdering.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleOrdering.rts @@ -7,46 +7,38 @@ filename=A.h class A { public: - void func1(); - void /*$*/func2/*$$*/() - { - } - void func3(); - void func4() - { - } + void func1(); + void /*$*/func2/*$$*/() { + } + void func3(); + void func4() { + } }; -inline void A::func1() -{ +inline void A::func1() { } -inline void A::func3() -{ +inline void A::func3() { } //= #include class A { public: - void func1(); - void func2(); - void func3(); - void func4() - { - } + void func1(); + void func2(); + void func3(); + void func4() { + } }; -inline void A::func1() -{ +inline void A::func1() { } -inline void A::func2() -{ +inline void A::func2() { } -inline void A::func3() -{ +inline void A::func3() { } //!TestCorrectOrderingInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -57,17 +49,15 @@ filename=A.h class A { public: - void func1(); - void func2(); - void func3(); - void func4() - { - } + void func1(); + void func2(); + void func3(); + void func4() { + } }; -inline void A::/*$*/func2/*$$*/() -{ - return; +inline void A::/*$*/func2/*$$*/() { + return; } //= @@ -75,12 +65,11 @@ inline void A::/*$*/func2/*$$*/() class A { public: - void func1(); - void func2(); - void func3(); - void func4() - { - } + void func1(); + void func2(); + void func3(); + void func4() { + } }; @@ -88,41 +77,34 @@ public: //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } -void A::func1() -{ - return; +void A::func1() { + return; } -void A::func3() -{ - return; +void A::func3() { + return; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } -void A::func1() -{ - return; +void A::func1() { + return; } -void A::func2() -{ - return; +void A::func2() { + return; } -void A::func3() -{ - return; +void A::func3() { + return; } //!TestCorrectTemplateOrderingInClassToInHeader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -134,21 +116,20 @@ filename=A.h template class A { public: - void func1(); - void /*$*/func2/*$$*/() - { - } - void func3(); - void func4() - { - } + void func1(); + void /*$*/func2/*$$*/() { + } + void func3(); + void func4() { + } }; -template inline void A::func1() -{ +template +inline void A::func1() { } -template inline void A::func3() -{ + +template +inline void A::func3() { } //= #include @@ -156,23 +137,23 @@ template inline void A::func3() template class A { public: - void func1(); - void func2(); - void func3(); - void func4() - { - } + void func1(); + void func2(); + void func3(); + void func4() { + } }; -template inline void A::func1() -{ -} -template inline void A::func2() -{ +template +inline void A::func1() { } -template inline void A::func3() -{ +template +inline void A::func2() { +} + +template +inline void A::func3() { } //!TestCorrectTemplateOrderingInHeaderToInClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -184,22 +165,23 @@ filename=A.h template class A { public: - void func1(); - void func2(); - void func3(); - void func4() - { - } + void func1(); + void func2(); + void func3(); + void func4() { + } }; -template inline void A::func1() -{ +template +inline void A::func1() { } -template inline void A::/*$*/func2/*$$*/() -{ + +template +inline void A::/*$*/func2/*$$*/() { } -template inline void A::func3() -{ + +template +inline void A::func3() { } //= #include @@ -207,20 +189,20 @@ template inline void A::func3() template class A { public: - void func1(); - void func2() - { - } - void func3(); - void func4() - { - } + void func1(); + void func2() { + } + void func3(); + void func4() { + } }; -template inline void A::func1() -{ +template +inline void A::func1() { } -template inline void A::func3() -{ + + +template +inline void A::func3() { } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts index f8cb1c31fb7..8551a6ca67e 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts @@ -4,153 +4,132 @@ filename=A.h //@A.h class A { - void me/*$*//*$$*/mber() - { - return; - } + void me/*$*//*$$*/mber() { + return; + } }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - //!TestSubstringSelection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void m/*$*/e/*$$*/mber() - { - return; - } + void m/*$*/e/*$$*/mber() { + return; + } }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - //!TestBodySelection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void member() - { - r/*$*//*$$*/eturn; - } + void member() { + r/*$*//*$$*/eturn; + } }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - //!TestBodySelectionWithConfusingName //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void member() - { - int /*$*/abcd/*$$*/ = 42; - return; - } + void member() { + int /*$*/abcd/*$$*/ = 42; + return; + } }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - int abcd = 42; - return; +inline void A::member() { + int abcd = 42; + return; } - //!TestLeftBorderSelection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - /*$*//*$$*/void member() - { - return; - } + /*$*//*$$*/void member() { + return; + } }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - //!TestRightBorderSelection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - void member() - { - return; - }/*$*//*$$*/ + void member() { + return; + }/*$*//*$$*/ }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - //!TestOverlappingSelection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h class A { - vo/*$*/id member() - { - ret/*$$*/urn; - } + vo/*$*/id member() { + ret/*$$*/urn; + } }; //= class A { - void member(); + void member(); }; -inline void A::member() -{ - return; +inline void A::member() { + return; } - diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts index a2f96afc6a8..b92b03b8a8a 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts @@ -7,29 +7,28 @@ filename=A.h class A { public: - int /*$*/function/*$$*/() - { - return 0; - } + int /*$*/function/*$$*/() { + return 0; + } + private: - int a; + int a; }; //= #include class A { public: - int function(); + int function(); + private: - int a; + int a; }; -inline int A::function() -{ - return 0; +inline int A::function() { + return 0; } - //!TestSimpleFunctionInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -39,23 +38,24 @@ filename=A.h class A { public: - int function(); + int function(); + private: - int a; + int a; }; -inline int A::/*$*/function/*$$*/() -{ - return 0; +inline int A::/*$*/function/*$$*/() { + return 0; } //= #include class A { public: - int function(); + int function(); + private: - int a; + int a; }; @@ -63,21 +63,19 @@ private: #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } -int A::function() -{ - return 0; +int A::function() { + return 0; } - //!TestSimpleFunctionInImplementationToInClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -85,44 +83,42 @@ filename=A.cpp //@A.cpp #include "A.h" -int A::/*$*/function/*$$*/() -{ - return 0; +int A::/*$*/function/*$$*/() { + return 0; } -int main() -{ - return 0; +int main() { + return 0; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //@A.h #include class A { public: - int function(); + int function(); + private: - int a; + int a; }; //= #include class A { public: - int function() - { - return 0; - } + int function() { + return 0; + } + private: - int a; + int a; }; //!TestDifferentParameterNames //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -131,36 +127,35 @@ filename=MyClass.cpp //@MyClass.cpp #include "MyClass.h" -myClass::/*$*/myClass/*$$*/(int implname) : fVal(implname) {} +myClass::/*$*/myClass/*$$*/(int implname) : + fVal(implname) { +} -int main() -{ - return 0; +int main() { + return 0; } //= #include "MyClass.h" -int main() -{ - return 0; +int main() { + return 0; } //@MyClass.h struct myClass { - int fVal; - myClass(int headername); + int fVal; + myClass(int headername); }; //= struct myClass { - int fVal; - myClass(int implname) - :fVal(implname) - { - } + int fVal; + myClass(int implname) : + fVal(implname) { + } }; //!TestMissingParameterNames @@ -170,35 +165,34 @@ filename=MyClass.cpp //@MyClass.cpp #include "MyClass.h" -myClass::/*$*/myClass/*$$*/(int implname) : fVal(implname) {} +myClass::/*$*/myClass/*$$*/(int implname) : + fVal(implname) { +} -int main() -{ - return 0; +int main() { + return 0; } //= #include "MyClass.h" -int main() -{ - return 0; +int main() { + return 0; } //@MyClass.h struct myClass { - int fVal; - myClass(int); + int fVal; + myClass(int); }; //= struct myClass { - int fVal; - myClass(int implname) - :fVal(implname) - { - } + int fVal; + myClass(int implname) : + fVal(implname) { + } }; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts index 5d50b808b0d..19c4330b515 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts @@ -7,29 +7,27 @@ filename=A.h template class A { - class B { - T /*$*/member/*$$*/() - { - return T(); - } - }; + class B { + T /*$*/member/*$$*/() { + return T(); + } + }; }; //= #include template class A { - class B { - T member(); - }; + class B { + T member(); + }; }; -template inline T A::B::member() -{ - return T(); +template +inline T A::B::member() { + return T(); } - //!TestTemplateFunctionInHeaderToInClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -39,28 +37,25 @@ filename=A.h template class A { - class B { - T member(); - }; - + class B { + T member(); + }; }; -template inline T A::B::/*$*/member/*$$*/() -{ - return T(); +template +inline T A::B::/*$*/member/*$$*/() { + return T(); } //= #include template class A { - class B { - T member() - { - return T(); - } - }; - + class B { + T member() { + return T(); + } + }; }; @@ -70,85 +65,76 @@ class A { filename=A.h //@A.h class A { - tem/*$*/plate/*$$*/ - T foo() { - return T(); - } + tem/*$*/plate/*$$*/ + T foo() { + return T(); + } }; //= class A { - template - T foo(); + template + T foo(); }; -template inline T A::foo() -{ - return T(); +template +inline T A::foo() { + return T(); } - //!TestComplexTemplateFunctionFromInClassToInheader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h template -class A -{ +class A { public: - template - void /*$*/foo/*$$*/(const U & u, const V &v) - { - return; - } + template + void /*$*/foo/*$$*/(const U& u, const V& v) { + return; + } }; //= template -class A -{ +class A { public: - template - void foo(const U & u, const V &v); + template + void foo(const U& u, const V& v); }; -template template inline void A::foo(const U & u, const V & v) -{ - return; +template +template +inline void A::foo(const U& u, const V& v) { + return; } - //!TestComplexTemplateFunctionFromInHeaderToInClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h //@A.h template -class A -{ +class A { public: - template - void /*$*/foo/*$$*/(const U & u, const V &v); - + template + void /*$*/foo/*$$*/(const U& u, const V& v); }; -template template inline void A::foo(const U & u, const V & v) -{ - return; +template +template +inline void A::foo(const U& u, const V& v) { + return; } //= template -class A -{ +class A { public: - template - void foo(const U & u, const V &v) - { - return; - } - - + template + void foo(const U& u, const V& v) { + return; + } }; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts index 41aec3dac98..30a83009e4b 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts @@ -7,33 +7,30 @@ filename=A.h #include class A { - void /*$*/member/*$$*/(int a, int b) - try - { - return; - } catch (std::exception & e1) - { - return; - } + void /*$*/member/*$$*/(int a, int b) + try { + return; + } + catch (std::exception& e1){ + return; + } }; //= #include #include class A { - void member(int a, int b); + void member(int a, int b); }; inline void A::member(int a, int b) -try -{ - return; +try { + return; } -catch(std::exception & e1){ - return; +catch (std::exception& e1) { + return; } - //!TestTryCatchFromInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -43,23 +40,22 @@ filename=A.h #include class A { - void member(int a, int b); + void member(int a, int b); }; inline void /*$*/A::member/*$$*/(int a, int b) -try -{ - return; +try { + return; } -catch(std::exception & e1){ - return; +catch (std::exception& e1) { + return; } //= #include #include class A { - void member(int a, int b); + void member(int a, int b); }; @@ -67,25 +63,23 @@ class A { #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } void A::member(int a, int b) -try -{ - return; +try { + return; } -catch(std::exception & e1){ - return; +catch (std::exception& e1) { + return; } - //!TestTryCatchFromInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -95,18 +89,15 @@ filename=A.cpp #include "A.h" void A::/*$*/member/*$$*/() -try -{ - return; +try { + return; } -catch(std::exception & e1) -{ - return; +catch (std::exception& e1) { + return; } -int main() -{ - return 0; +int main() { + return 0; } //= #include @@ -114,28 +105,26 @@ int main() -int main() -{ - return 0; +int main() { + return 0; } //@A.h #include class A { - void member(); + void member(); }; //= #include class A { - void member() - try - { - return; - } - catch(std::exception & e1){ - return; - } + void member() + try { + return; + } + catch (std::exception& e1) { + return; + } }; //!TestMultipleTryCatchFromInClassToInHeader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest @@ -146,39 +135,36 @@ filename=A.h #include class A { - void /*$*/member/*$$*/(int a, int b) - try - { - return; - } catch (std::exception & e1) - { - return; - } catch (std::exception & e2) - { - return; - } + void /*$*/member/*$$*/(int a, int b) + try { + return; + } + catch (std::exception& e1) { + return; + } + catch (std::exception& e2) { + return; + } }; //= #include #include class A { - void member(int a, int b); + void member(int a, int b); }; inline void A::member(int a, int b) -try -{ - return; +try { + return; } -catch(std::exception & e1){ - return; +catch (std::exception& e1) { + return; } -catch(std::exception & e2){ - return; +catch (std::exception& e2) { + return; } - //!TestMultipleTryCatchFromInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -188,26 +174,25 @@ filename=A.h #include class A { - void member(int a, int b); + void member(int a, int b); }; inline void /*$*/A::member/*$$*/(int a, int b) -try -{ - return; +try { + return; } -catch(std::exception & e1){ - return; +catch (std::exception& e1) { + return; } -catch(std::exception & e2){ - return; +catch (std::exception& e2) { + return; } //= #include #include class A { - void member(int a, int b); + void member(int a, int b); }; @@ -215,28 +200,26 @@ class A { #include "A.h" int main() { - return 0; + return 0; } //= #include "A.h" int main() { - return 0; + return 0; } void A::member(int a, int b) -try -{ - return; +try { + return; } -catch(std::exception & e1){ - return; +catch (std::exception& e1) { + return; } -catch(std::exception & e2){ - return; +catch (std::exception& e2) { + return; } - //!TestMultipleTryCatchFromInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -246,22 +229,18 @@ filename=A.cpp #include "A.h" void A::/*$*/member/*$$*/() -try -{ - return; +try { + return; } -catch(std::exception & e1) -{ - return; +catch (std::exception& e1) { + return; } -catch(std::exception & e2) -{ - return; +catch (std::exception& e2) { + return; } -int main() -{ - return 0; +int main() { + return 0; } //= #include @@ -269,29 +248,27 @@ int main() -int main() -{ - return 0; +int main() { + return 0; } //@A.h #include class A { - void member(); + void member(); }; //= #include class A { - void member() - try - { - return; - } - catch(std::exception & e1){ - return; - } - catch(std::exception & e2){ - return; - } + void member() + try { + return; + } + catch (std::exception& e1) { + return; + } + catch (std::exception& e2) { + return; + } }; \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts index 9c1ef038bf0..8a51d64b8c7 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts @@ -5,23 +5,20 @@ filename=A.h //@A.h class A { - virtual int /*$*/foo/*$$*/() - { - return 0; - } + virtual int /*$*/foo/*$$*/() { + return 0; + } }; //= class A { - virtual int foo(); + virtual int foo(); }; -inline int A::foo() -{ - return 0; +inline int A::foo() { + return 0; } - //!TestVirtualSpecifierFromInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //%CPP @@ -30,41 +27,36 @@ filename=A.h //@A.h class A { - virtual int /*$*/foo/*$$*/(); + virtual int /*$*/foo/*$$*/(); }; -inline int A::foo() -{ - return 0; +inline int A::foo() { + return 0; } //= class A { - virtual int foo(); + virtual int foo(); }; //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } -int A::foo() -{ - return 0; +int A::foo() { + return 0; } - //!TestVirtualSpecifierFromImplementationToHeader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -72,34 +64,30 @@ filename=A.h //@A.h class A { - virtual int /*$*/foo/*$$*/(); + virtual int /*$*/foo/*$$*/(); }; //= class A { - virtual int foo() - { - return 0; - } + virtual int foo() { + return 0; + } }; //@A.cpp #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } -int A::foo() -{ - return 0; +int A::foo() { + return 0; } //= #include "A.h" -int main() -{ - return 0; +int main() { + return 0; } diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/TranslationunitHelper.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/TranslationunitHelper.rts index 9f0ee147162..721fed99334 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/TranslationunitHelper.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/TranslationunitHelper.rts @@ -7,8 +7,7 @@ offset=27 #ifndef A_H_ #define A_H_ -class A -{ +class A { public: A(); void foo(); @@ -25,8 +24,7 @@ offset=0 //@A.h typedef int nummere; -class A -{ +class A { public: A(); }; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTest.java index 16298bf41d7..bef2a1e6ab6 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTest.java @@ -109,7 +109,7 @@ public abstract class RefactoringTest extends RefactoringBaseTest { protected void assertConditionsInfo(RefactoringStatus status, int number) { if (number > 0) { - assertTrue("Info in Condition expected", status.hasInfo()); //$NON-NLS-1$ + assertTrue("Info in condition expected", status.hasInfo()); //$NON-NLS-1$ } RefactoringStatusEntry[] entries = status.getEntries(); int count = 0; @@ -123,7 +123,7 @@ public abstract class RefactoringTest extends RefactoringBaseTest { protected void assertConditionsError(RefactoringStatus status, int number) { if (number > 0) { - assertTrue("Error in Condition expected", status.hasError()); //$NON-NLS-1$ + assertTrue("Error in condition expected", status.hasError()); //$NON-NLS-1$ } RefactoringStatusEntry[] entries = status.getEntries(); int count = 0; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java index 0420da30cef..a7e2db024dd 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java @@ -7,8 +7,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation - * Tom Ball (Google) + * Institute for Software - initial API and implementation + * Tom Ball (Google) *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java index 75282a4b647..8178f25069c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java @@ -41,10 +41,6 @@ public class ExtractFunctionRefactoringTest extends RefactoringTest { private boolean virtual; private static int nr = 1; - /** - * @param name - * @param files - */ public ExtractFunctionRefactoringTest(String name, Collection files) { super(name, files); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionTestSuite.java index 0f9339b18a6..46d16bd0457 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionTestSuite.java @@ -29,7 +29,7 @@ public class ExtractFunctionTestSuite extends TestSuite { suite.addTest(RefactoringTester.suite("ExtractMethodPreprocessorRefactoringTests", "resources/refactoring/ExtractMethodPreprocessor.rts")); suite.addTest(RefactoringTester.suite("Extract Function Templates Tests", "resources/refactoring/ExtractFunctionTemplates.rts")); suite.addTest(RefactoringTester.suite("Extract Method History Test", "resources/refactoring/ExtractMethodHistory.rts")); - suite.addTest(RefactoringTester.suite("Extract Function Dublicates Test", "resources/refactoring/ExtractMethodDuplicates.rts")); + suite.addTest(RefactoringTester.suite("Extract Function Duplicates Test", "resources/refactoring/ExtractMethodDuplicates.rts")); return suite; } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java index 7c9b90d2eb2..01d43779f2f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java @@ -4,7 +4,7 @@ * 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 + * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Emanuel Graf & Leo Buettiker - initial API and implementation @@ -41,7 +41,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest { private List selectedGetters; private List selectedSetters; private GenerateGettersAndSettersRefactoring refactoring; - private boolean keepInHeader; + private boolean definitionSeparate; private int infos; /** @@ -70,7 +70,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest { private void executeRefactoring() throws CoreException, Exception { selectFields(); - refactoring.getContext().setImplementationInHeader(keepInHeader); + refactoring.getContext().setDefinitionSeparate(definitionSeparate); RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); if (warnings > 0) { @@ -109,7 +109,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest { infos = new Integer(refactoringProperties.getProperty("infos", "0")); String getters = refactoringProperties.getProperty("getters", ""); //$NON-NLS-1$ //$NON-NLS-2$ String setters = refactoringProperties.getProperty("setters", ""); //$NON-NLS-1$ //$NON-NLS-2$ - keepInHeader = Boolean.valueOf(refactoringProperties.getProperty("inHeader", "false")); + definitionSeparate = Boolean.valueOf(refactoringProperties.getProperty("definitionSeparate", "false")); selectedGetters = new ArrayList(); for (String getterName : getters.split(",")) { //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTestSuite.java index 4dd28fc6684..32b524725d9 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTestSuite.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tom Ball (Google) - initial API and implementation + * Tom Ball (Google) - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.gettersandsetters; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/MockToggleRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/MockToggleRefactoringTest.java index b4af0209612..27196fdda6b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/MockToggleRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/MockToggleRefactoringTest.java @@ -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.ui.tests.refactoring.togglefunction; @@ -21,8 +21,7 @@ import org.eclipse.cdt.internal.ui.refactoring.togglefunction.ToggleRefactoringC public class MockToggleRefactoringTest extends ToggleRefactoring { - public MockToggleRefactoringTest(IFile file, TextSelection selection, - ICProject proj) { + public MockToggleRefactoringTest(IFile file, TextSelection selection, ICProject proj) { super(file, selection, proj); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleNodeHelperTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleNodeHelperTest.java index b8f2b2aaa54..e67bc202807 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleNodeHelperTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleNodeHelperTest.java @@ -19,10 +19,8 @@ import org.eclipse.cdt.internal.ui.refactoring.togglefunction.ToggleNodeHelper; /** * @author egraf - * */ public class ToggleNodeHelperTest extends TestCase { - /** * Test method for {@link org.eclipse.cdt.internal.ui.refactoring.togglefunction.ToggleNodeHelper#getFilenameWithoutExtension(java.lang.String)}. */ @@ -38,5 +36,4 @@ public class ToggleNodeHelperTest extends TestCase { public void testGetFilenameWithoutExtension2() { assertEquals("My.Class", ToggleNodeHelper.getFilenameWithoutExtension("My.Class.h")); } - } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java index 9d45da70813..32cc7e37448 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java @@ -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.ui.tests.refactoring.togglefunction; @@ -26,7 +26,6 @@ import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile; public class ToggleRefactoringTest extends RefactoringTest { - private boolean fatalError; private boolean newFileCreation; private String[] newfiles; @@ -77,7 +76,7 @@ public class ToggleRefactoringTest extends RefactoringTest { assertConditionsOk(refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR)); changes.perform(NULL_PROGRESS_MONITOR); filesDoExist(); - for(String fileName: fileMap.keySet()) { + for (String fileName: fileMap.keySet()) { IFile iFile = project.getFile(new Path(fileName)); String code = getCodeFromIFile(iFile); String expectedSource = fileMap.get(fileName).getExpectedSource(); @@ -91,21 +90,21 @@ public class ToggleRefactoringTest extends RefactoringTest { } private void filesDoExist() { - for(String fileName: newfiles) { + for (String fileName: newfiles) { IFile file = project.getFile(new Path(fileName)); assertTrue(file.exists()); } } private void filesDoNotExist() { - for(String fileName: newfiles) { + for (String fileName: newfiles) { IFile file = project.getFile(new Path(fileName)); assertFalse(file.exists()); } } private void removeFiles() throws CoreException { - for(String fileName: newfiles) { + for (String fileName: newfiles) { IFile file = project.getFile(new Path(fileName)); file.delete(true, NULL_PROGRESS_MONITOR); } @@ -117,5 +116,4 @@ public class ToggleRefactoringTest extends RefactoringTest { changes.perform(NULL_PROGRESS_MONITOR); compareFiles(fileMap); } - } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTestSuite.java index 657b54be781..cc0ff4bc61e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTestSuite.java @@ -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.ui.tests.refactoring.togglefunction; @@ -32,7 +32,7 @@ public class ToggleRefactoringTestSuite extends TestSuite { "resources/refactoring/ToggleSimpleFunctionRefactoring.rts")); suite.addTest(RefactoringTester.suite("ToggleTemplateRefactoringTest", "resources/refactoring/ToggleTemplateRefactoring.rts")); - suite.addTest(RefactoringTester.suite("ToggleNamespaceRefacotringTest", + suite.addTest(RefactoringTester.suite("ToggleNamespaceRefactoringTest", "resources/refactoring/ToggleNamespaceRefactoring.rts")); suite.addTest(RefactoringTester.suite("ToggleTryCatchRefactoringTest", "resources/refactoring/ToggleTryCatchRefactoring.rts")); @@ -49,7 +49,7 @@ public class ToggleRefactoringTestSuite extends TestSuite { "resources/refactoring/ToggleFreeFunction.rts")); suite.addTest(RefactoringTester.suite("ToggleVirtualFunctionTest", "resources/refactoring/ToggleVirtualFunction.rts")); - suite.addTest(RefactoringTester.suite("ToggleOrderintTest", + suite.addTest(RefactoringTester.suite("ToggleOrderingTest", "resources/refactoring/ToggleOrdering.rts")); suite.addTest(RefactoringTester.suite("ToggleCommentsClassToHeader", "resources/refactoring/ToggleCommentsClassToHeader.rts")); @@ -62,5 +62,4 @@ public class ToggleRefactoringTestSuite extends TestSuite { suite.addTestSuite(ToggleNodeHelperTest.class); return suite; } - } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index a38fe09518a..4eb659df105 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -535,11 +535,13 @@ public class CodeFormatterTest extends BaseUITestCase { //static void *f(){} //static void * g(); //static void* h(); + //int* (*a) [2]; //static void *f() { //} //static void * g(); //static void* h(); + //int* (*a)[2]; public void testSpaceBetweenDeclSpecAndDeclarator() throws Exception { assertFormatterResult(); } diff --git a/core/org.eclipse.cdt.ui/icons/dlcl16/pin_view.gif b/core/org.eclipse.cdt.ui/icons/dlcl16/pin_view.gif new file mode 100644 index 00000000000..61615d57dbe Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/dlcl16/pin_view.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/elcl16/pin_view.gif b/core/org.eclipse.cdt.ui/icons/elcl16/pin_view.gif new file mode 100644 index 00000000000..ec50b70fab1 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/elcl16/pin_view.gif differ diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 85f5d65431f..44ec840d861 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -286,7 +286,8 @@ class="org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart" icon="icons/view16/call_hierarchy.gif" id="org.eclipse.cdt.ui.callHierarchy" - name="%callHierarchy.name"/> + name="%callHierarchy.name" + allowMultiple="true"/> adapter= new IListAdapter() { + @Override public void customButtonPressed(ListDialogField field, int index) { doCustomButtonPressed(); } + @Override public void selectionChanged(ListDialogField field) { doSelectionChanged(); } + @Override public void doubleClicked(ListDialogField field) { doDoubleClicked(); } @@ -171,10 +174,10 @@ public class CHHistoryListAction extends Action { */ @Override public void run() { - ICElement[] historyEntries= fView.getHistoryEntries(); + ICElement[] historyEntries= CallHierarchyUI.getHistoryEntries(); HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries); if (dialog.open() == Window.OK) { - fView.setHistoryEntries(dialog.getRemaining()); + CallHierarchyUI.setHistoryEntries(dialog.getRemaining()); fView.setInput(dialog.getResult()); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java index 127fcd48c6f..620ceba59e8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, 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 @@ -55,6 +55,8 @@ public class CHMessages extends NLS { public static String OpenElementInCallHierarchyAction_message; public static String OpenElementInCallHierarchyAction_title; public static String OpenElementInCallHierarchyAction_upperListLabel; + public static String CHPinAction_label; + public static String CHPinAction_tooltip; static { // initialize resource bundle diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties index 2e8321e562a..0d8f98b6daa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. +# Copyright (c) 2006, 2011 Wind River Systems, 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 @@ -50,3 +50,5 @@ OpenElementInCallHierarchyAction_title=Open Element in Call Hierarchy OpenElementInCallHierarchyAction_upperListLabel=&Matching Elements: OpenElementInCallHierarchyAction_message=&Choose an element (? = any character, * = any string): OpenElementInCallHierarchyAction_errorNoDefinition=Could not locate definition of element ''{0}'' +CHPinAction_label=Pi&n Call Hierarchy View +CHPinAction_tooltip=Pin the Call Hierarchy View diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java new file mode 100644 index 00000000000..3b770e66d62 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHPinAction.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2011, 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: + * IBM Corporation - initial API and implementation + * Marc-Andre Laperle - Adapted to CDT from JDT + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.callhierarchy; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; + +import org.eclipse.cdt.internal.ui.CPluginImages; + +public class CHPinAction extends Action { + private CHViewPart fView= null; + + /** + * Constructs a 'Pin Call Hierarchy view' action. + * + * @param view the Call Hierarchy view + */ + public CHPinAction(CHViewPart view) { + super(CHMessages.CHPinAction_label, IAction.AS_CHECK_BOX); + setToolTipText(CHMessages.CHPinAction_tooltip); + CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "pin_view.gif"); //$NON-NLS-1$ + fView= view; + } + + /* + * @see org.eclipse.jface.action.Action#run() + */ + @Override + public void run() { + fView.setPinned(isChecked()); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java index dc1a0895479..9fd2f0163d2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java @@ -11,8 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.callhierarchy; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import org.eclipse.jface.action.Action; @@ -47,8 +45,11 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IMemento; +import org.eclipse.ui.IPartListener2; +import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.PartInitException; @@ -91,7 +92,6 @@ import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI; * The view part for the include browser. */ public class CHViewPart extends ViewPart { - private static final int MAX_HISTORY_SIZE = 10; private static final String TRUE = String.valueOf(true); private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$ private static final String KEY_FILTER_VARIABLES = "variableFilter"; //$NON-NLS-1$ @@ -101,8 +101,6 @@ public class CHViewPart extends ViewPart { private boolean fShowsMessage; private CHNode fNavigationNode; private int fNavigationDetail; - - private ArrayList fHistoryEntries= new ArrayList(MAX_HISTORY_SIZE); // widgets private PageBook fPagebook; @@ -131,6 +129,7 @@ public class CHViewPart extends ViewPart { private Action fHistoryAction; private Action fShowReference; private Action fOpenElement; + private Action fPinViewAction; private CopyTreeAction fCopyAction; // action groups @@ -138,6 +137,8 @@ public class CHViewPart extends ViewPart { private SelectionSearchGroup fSelectionSearchGroup; private CRefactoringActionGroup fRefactoringActionGroup; private IContextActivation fContextActivation; + private boolean fIsPinned = false; + private IPartListener2 fPartListener; @Override public void setFocus() { @@ -171,7 +172,7 @@ public class CHViewPart extends ViewPart { fTreeViewer.setInput(input); fPagebook.showPage(fViewerPage); updateDescription(); - updateHistory(input); + CallHierarchyUI.updateHistory(input); updateActionEnablement(); } @@ -218,8 +219,48 @@ public class CHViewPart extends ViewPart { } PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.CALL_HIERARCHY_VIEW); + addPartListener(); } + private void addPartListener() { + fPartListener= new IPartListener2() { + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partActivated(IWorkbenchPartReference partRef) { + if (isThisView(partRef)) + CallHierarchyUI.callHierarchyViewActivated(CHViewPart.this); + } + + @Override + public void partBroughtToTop(IWorkbenchPartReference partRef) { } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference) + */ + @Override + public void partClosed(IWorkbenchPartReference partRef) { + if (isThisView(partRef)) { + CallHierarchyUI.callHierarchyViewClosed(CHViewPart.this); + } + } + + @Override + public void partDeactivated(IWorkbenchPartReference partRef) {} + @Override + public void partOpened(IWorkbenchPartReference partRef) { } + @Override + public void partHidden(IWorkbenchPartReference partRef) { } + @Override + public void partVisible(IWorkbenchPartReference partRef) { } + @Override + public void partInputChanged(IWorkbenchPartReference partRef) { } + }; + getViewSite().getPage().addPartListener(fPartListener); + + } + @Override public void dispose() { if (fContextActivation != null) { @@ -245,6 +286,10 @@ public class CHViewPart extends ViewPart { fWorkingSetFilterUI.dispose(); fWorkingSetFilterUI= null; } + if (fPartListener != null) { + getViewSite().getPage().removePartListener(fPartListener); + fPartListener= null; + } super.dispose(); } @@ -276,6 +321,19 @@ public class CHViewPart extends ViewPart { super.init(site, memento); } + /** + * Tells whether the given part reference references this view. + * + * @param partRef the workbench part reference + * @return true if the given part reference references this view + */ + private boolean isThisView(IWorkbenchPartReference partRef) { + if (!CUIPlugin.ID_CALL_HIERARCHY.equals(partRef.getId())) + return false; + String partRefSecondaryId = ((IViewReference)partRef).getSecondaryId(); + String thisSecondaryId = getViewSite().getSecondaryId(); + return thisSecondaryId == null && partRefSecondaryId == null || thisSecondaryId != null && thisSecondaryId.equals(partRefSecondaryId); + } @Override public void saveState(IMemento memento) { @@ -291,7 +349,8 @@ public class CHViewPart extends ViewPart { MenuManager manager = new MenuManager(); manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager m) { + @Override + public void menuAboutToShow(IMenuManager m) { onContextMenuAboutToShow(m); } }); @@ -315,6 +374,7 @@ public class CHViewPart extends ViewPart { fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fLabelProvider)); fTreeViewer.setAutoExpandLevel(2); fTreeViewer.addOpenListener(new IOpenListener() { + @Override public void open(OpenEvent event) { onShowSelectedReference(event.getSelection()); } @@ -484,6 +544,7 @@ public class CHViewPart extends ViewPart { fHistoryAction = new CHHistoryDropDownAction(this); fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer); + fPinViewAction= new CHPinAction(this); // setup action bar // global action hooks @@ -509,6 +570,7 @@ public class CHViewPart extends ViewPart { tm.add(fMakesReferenceToAction); tm.add(fHistoryAction); tm.add(fRefreshAction); + tm.add(fPinViewAction); // local menu IMenuManager mm = actionBars.getMenuManager(); @@ -608,16 +670,6 @@ public class CHViewPart extends ViewPart { fTreeViewer.refresh(); } - private void updateHistory(ICElement input) { - if (input != null) { - fHistoryEntries.remove(input); - fHistoryEntries.add(0, input); - if (fHistoryEntries.size() > MAX_HISTORY_SIZE) { - fHistoryEntries.remove(MAX_HISTORY_SIZE-1); - } - } - } - private void updateSorter() { if (fReferencedByAction.isChecked()) { fTreeViewer.setComparator(fSorterAlphaNumeric); @@ -662,7 +714,7 @@ public class CHViewPart extends ViewPart { } private void updateActionEnablement() { - fHistoryAction.setEnabled(!fHistoryEntries.isEmpty()); + fHistoryAction.setEnabled(CallHierarchyUI.getHistoryEntries().length > 0); fNextAction.setEnabled(!fShowsMessage); fPreviousAction.setEnabled(!fShowsMessage); fRefreshAction.setEnabled(!fShowsMessage); @@ -782,16 +834,7 @@ public class CHViewPart extends ViewPart { public Control getPageBook() { return fPagebook; } - - public ICElement[] getHistoryEntries() { - return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]); - } - - public void setHistoryEntries(ICElement[] remaining) { - fHistoryEntries.clear(); - fHistoryEntries.addAll(Arrays.asList(remaining)); - } - + public ICElement getInput() { Object input= fTreeViewer.getInput(); if (input instanceof ICElement) { @@ -809,4 +852,22 @@ public class CHViewPart extends ViewPart { super(CHMessages.CHViewPart_CopyCallHierarchy_label, view, viewer); } } + + /** + * Marks the view as pinned. + * + * @param pinned if true the view is marked as pinned + */ + void setPinned(boolean pinned) { + fIsPinned= pinned; + } + + /** + * Indicates whether the Call Hierarchy view is pinned. + * + * @return true if the view is pinned, false otherwise + */ + boolean isPinned() { + return fIsPinned; + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java index 3aba5d15132..e0093cf82ac 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, 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 @@ -10,6 +10,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.callhierarchy; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -18,6 +23,7 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.text.ITextSelection; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.texteditor.ITextEditor; @@ -57,6 +63,15 @@ public class CallHierarchyUI { private static final ICElement[] NO_ELEMENTS = {}; private static boolean sIsJUnitTest= false; + /** + * List of the Call Hierarchy views in LRU order, where the most recently used view is at index 0. + */ + private static List fLRUCallHierarchyViews= new ArrayList(); + private static int fViewCount = 0; + + private static final int MAX_HISTORY_SIZE = 10; + private static List fHistoryEntries= new ArrayList(MAX_HISTORY_SIZE); + public static void setIsJUnitTest(boolean val) { sIsJUnitTest= val; } @@ -87,9 +102,19 @@ public class CallHierarchyUI { private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement input) { IWorkbenchPage page= window.getActivePage(); try { - CHViewPart result= (CHViewPart) page.showView(CUIPlugin.ID_CALL_HIERARCHY); - result.setInput(input); - return result; + CHViewPart viewPart = findLRUCallHierarchyViewPart(page); //find the first view which is not pinned + String secondaryId = null; + if (viewPart == null) { + if (page.findViewReference(CUIPlugin.ID_CALL_HIERARCHY) != null) { //all the current views are pinned, open a new instance + secondaryId = String.valueOf(++fViewCount); + } + } else { + secondaryId = viewPart.getViewSite().getSecondaryId(); + } + + viewPart = (CHViewPart) page.showView(CUIPlugin.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE); + viewPart.setInput(input); + return viewPart; } catch (CoreException e) { ExceptionHandler.handle(e, window.getShell(), CHMessages.OpenCallHierarchyAction_label, null); } @@ -331,4 +356,88 @@ public class CallHierarchyUI { } return false; } + + + /** + * Adds the activated view part to the head of the list. + * + * @param view the Call Hierarchy view part + */ + static void callHierarchyViewActivated(CHViewPart view) { + fLRUCallHierarchyViews.remove(view); + fLRUCallHierarchyViews.add(0, view); + } + + /** + * Removes the closed view part from the list. + * + * @param view the closed view part + */ + static void callHierarchyViewClosed(CHViewPart view) { + fLRUCallHierarchyViews.remove(view); + } + + /** + * Clears the history and updates all the open views. + */ + static void clearHistory() { + setHistoryEntries(new ICElement[0]); + for (Iterator iter= fLRUCallHierarchyViews.iterator(); iter.hasNext();) { + CHViewPart part= iter.next(); + part.setInput(null); + } + } + + /** + * Finds the first Call Hierarchy view part instance that is not pinned. + * + * @param page the active page + * @return the Call Hierarchy view part to open or null if none found + */ + private static CHViewPart findLRUCallHierarchyViewPart(IWorkbenchPage page) { + boolean viewFoundInPage= false; + for (Iterator iter= fLRUCallHierarchyViews.iterator(); iter.hasNext();) { + CHViewPart view= iter.next(); + if (page.equals(view.getSite().getPage())) { + if (!view.isPinned()) { + return view; + } + viewFoundInPage= true; + } + } + if (!viewFoundInPage) { + // find unresolved views + IViewReference[] viewReferences= page.getViewReferences(); + for (int i= 0; i < viewReferences.length; i++) { + IViewReference curr= viewReferences[i]; + if (CUIPlugin.ID_CALL_HIERARCHY.equals(curr.getId()) && page.equals(curr.getPage())) { + CHViewPart view= (CHViewPart)curr.getView(true); + if (view != null && !view.isPinned()) { + return view; + } + } + } + } + return null; + } + + static public ICElement[] getHistoryEntries() { + return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]); + } + + static public void setHistoryEntries(ICElement[] remaining) { + fHistoryEntries.clear(); + fHistoryEntries.addAll(Arrays.asList(remaining)); + } + + static public void updateHistory(ICElement input) { + if (input != null) { + fHistoryEntries.remove(input); + fHistoryEntries.add(0, input); + if (fHistoryEntries.size() > MAX_HISTORY_SIZE) { + fHistoryEntries.remove(MAX_HISTORY_SIZE-1); + } + } + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java index 41868e1e6f6..2341aa2c35e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; @@ -23,6 +23,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ICTextFileChangeFactory; */ public class CTextFileChangeFactory implements ICTextFileChangeFactory { + @Override public TextFileChange createCTextFileChange(IFile file) { return new CTextFileChange(file.getName(), file); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java index 12e40b4b9fb..bf623992367 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java @@ -6,12 +6,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Rational Software - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Rational Software - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; - import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -50,7 +49,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.model.IBufferFactory; - /** * Adapts IDocument to IBuffer. Uses the * same algorithm as the text widget to determine the buffer's line delimiter. @@ -60,14 +58,13 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory; * This class is similar to the JDT DocumentAdapter class. */ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { - /** * Executes a document set content call in the ui thread. */ protected class DocumentSetCommand implements Runnable { - private String fContents; + @Override public void run() { fDocument.set(fContents); } @@ -82,11 +79,11 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { * Executes a document replace call in the ui thread. */ protected class DocumentReplaceCommand implements Runnable { - private int fOffset; private int fLength; private String fText; + @Override public void run() { try { fDocument.replace(fOffset, fLength, fText); @@ -104,31 +101,52 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { } private static final boolean DEBUG_LINE_DELIMITERS= true; - public static final IBuffer NULL_BUFFER = new IBuffer(){ + public static final IBuffer NULL_BUFFER = new IBuffer() { + @Override public void addBufferChangedListener(IBufferChangedListener listener) {} + @Override public void append(char[] text) {} + @Override public void append(String text) {} + @Override public void close() {} - public char getChar(int position) {return 0;} - public char[] getCharacters() {return new char[0];} - public String getContents() {return "";} //$NON-NLS-1$ - public int getLength() {return 0;} + @Override + public char getChar(int position) { return 0; } + @Override + public char[] getCharacters() { return new char[0]; } + @Override + public String getContents() { return ""; } //$NON-NLS-1$ + @Override + public int getLength() { return 0; } + @Override public IOpenable getOwner() {return null;} - public String getText(int offset, int length) {return "";} //$NON-NLS-1$ - public IResource getUnderlyingResource() {return null;} - public boolean hasUnsavedChanges() {return false;} - public boolean isClosed() {return false;} - public boolean isReadOnly() {return true;} + @Override + public String getText(int offset, int length) { return ""; } //$NON-NLS-1$ + @Override + public IResource getUnderlyingResource() { return null; } + @Override + public boolean hasUnsavedChanges() { return false; } + @Override + public boolean isClosed() { return false; } + @Override + public boolean isReadOnly() { return true; } + @Override public void removeBufferChangedListener(IBufferChangedListener listener) {} + @Override public void replace(int position, int length, char[] text) {} + @Override public void replace(int position, int length, String text) {} + @Override public void save(IProgressMonitor progress, boolean force) throws CModelException {} + @Override public void setContents(char[] contents) {} + @Override public void setContents(String contents) {} }; public static IBufferFactory FACTORY= new IBufferFactory() { - public IBuffer createBuffer(IOpenable owner) { + @Override + public IBuffer createBuffer(IOpenable owner) { if (owner instanceof IWorkingCopy) { IWorkingCopy wc= (IWorkingCopy) owner; ITranslationUnit tu= wc.getOriginalElement(); @@ -206,6 +224,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IBuffer#addBufferChangedListener(IBufferChangedListener) */ + @Override public void addBufferChangedListener(IBufferChangedListener listener) { Assert.isNotNull(listener); if (!fBufferListeners.contains(listener)) @@ -215,6 +234,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IBuffer#removeBufferChangedListener(IBufferChangedListener) */ + @Override public void removeBufferChangedListener(IBufferChangedListener listener) { Assert.isNotNull(listener); fBufferListeners.remove(listener); @@ -224,6 +244,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#append(char[]) */ + @Override public void append(char[] text) { append(new String(text)); } @@ -231,6 +252,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String) */ + @Override public void append(String text) { if (DEBUG_LINE_DELIMITERS) { validateLineDelimiters(text); @@ -242,8 +264,8 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#close() */ + @Override public void close() { - if (isClosed()) return; @@ -268,6 +290,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getChar(int) */ + @Override public char getChar(int position) { try { return fDocument.getChar(position); @@ -279,6 +302,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getCharacters() */ + @Override public char[] getCharacters() { String content= getContents(); return content == null ? null : content.toCharArray(); @@ -287,6 +311,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getContents() */ + @Override public String getContents() { return fDocument.get(); } @@ -294,6 +319,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getLength() */ + @Override public int getLength() { return fDocument.getLength(); } @@ -301,6 +327,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getOwner() */ + @Override public IOpenable getOwner() { return fOwner; } @@ -308,6 +335,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int) */ + @Override public String getText(int offset, int length) { try { return fDocument.get(offset, length); @@ -319,6 +347,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource() */ + @Override public IResource getUnderlyingResource() { return fFile; } @@ -326,6 +355,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges() */ + @Override public boolean hasUnsavedChanges() { return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false; } @@ -333,6 +363,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#isClosed() */ + @Override public boolean isClosed() { return fDocument == null; } @@ -340,6 +371,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly() */ + @Override public boolean isReadOnly() { IResource resource= getUnderlyingResource(); if (resource != null) { @@ -354,6 +386,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[]) */ + @Override public void replace(int position, int length, char[] text) { replace(position, length, new String(text)); } @@ -361,6 +394,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String) */ + @Override public void replace(int position, int length, String text) { if (DEBUG_LINE_DELIMITERS) { validateLineDelimiters(text); @@ -371,6 +405,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean) */ + @Override public void save(IProgressMonitor progress, boolean force) throws CModelException { try { if (fTextFileBuffer != null) @@ -383,6 +418,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[]) */ + @Override public void setContents(char[] contents) { setContents(new String(contents)); } @@ -390,14 +426,13 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String) */ + @Override public void setContents(String contents) { int oldLength= fDocument.getLength(); if (contents == null) { - if (oldLength != 0) fSetCmd.set(""); //$NON-NLS-1$ - } else { // set only if different if (DEBUG_LINE_DELIMITERS) { @@ -407,12 +442,10 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { int newLength= contents.length(); if (oldLength != newLength || !contents.equals(fDocument.get())) fSetCmd.set(contents); - } } private void validateLineDelimiters(String contents) { - if (fLegalLineDelimiters == null) { // collect all line delimiters in the document HashSet existingDelimiters= new HashSet(); @@ -460,6 +493,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) */ + @Override public void documentAboutToBeChanged(DocumentEvent event) { // there is nothing to do here } @@ -467,6 +501,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IDocumentListener#documentChanged(DocumentEvent) */ + @Override public void documentChanged(DocumentEvent event) { fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText())); } @@ -483,6 +518,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { return fTextFileBuffer; } + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Class adapter) { if (adapter.isAssignableFrom(ITextFileBuffer.class)) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java index 650042f7770..e53a3e7f3f3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java @@ -885,7 +885,7 @@ public class ExtractFunctionRefactoring extends CRefactoring { arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$ arguments.put(ExtractFunctionRefactoringDescription.NAME, info.getMethodName()); arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY, info.getVisibility().toString()); - arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUBLICATES, Boolean.toString(info.isReplaceDuplicates())); + arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUPLICATES, Boolean.toString(info.isReplaceDuplicates())); return arguments; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java index ab641456027..4a9f4da9d9d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java @@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum; public class ExtractFunctionRefactoringDescription extends CRefactoringDescription { protected static final String NAME = "name"; //$NON-NLS-1$ protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$ - protected static final String REPLACE_DUBLICATES = "replaceDuplicates"; //$NON-NLS-1$ + protected static final String REPLACE_DUPLICATES = "replaceDuplicates"; //$NON-NLS-1$ public ExtractFunctionRefactoringDescription(String project, String description, String comment, Map arguments) { @@ -47,7 +47,7 @@ public class ExtractFunctionRefactoringDescription extends CRefactoringDescripti info.setMethodName(arguments.get(NAME)); info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY))); - info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUBLICATES))); + info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUPLICATES))); proj = getCProject(); file = getFile(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java index 83fed4468a9..fa5f8886718 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; import java.util.Arrays; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; +import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; @@ -181,7 +182,13 @@ public class FunctionFactory { public static IASTSimpleDeclaration createGetterDeclaration(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration) { IASTSimpleDeclaration getter = new CPPASTSimpleDeclaration(); - getter.setDeclSpecifier(fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations)); + IASTDeclSpecifier declSpec = fieldDeclaration.getDeclSpecifier(); + getter.setDeclSpecifier(declSpec.copy(CopyStyle.withLocations)); + // TODO(sprigogin): Implement return by reference +// IType type = CPPVisitor.createType(declSpec); +// if (TypeHelper.shouldBePassedByReference(type, fieldDeclaration.getTranslationUnit())) { +// declSpec.s +// } getter.addDeclarator(getGetterDeclarator(fieldName, fieldDeclaration, null)); return getter; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java index 5b272b2cf80..7e951188fd7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java @@ -52,6 +52,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl node.addPreferenceChangeListener(this); } + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); @@ -67,18 +68,18 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl gd = new GridData(); gd.verticalAlignment = SWT.TOP; btComp.setLayoutData(gd); - - final Button placeImplemetation = new Button(comp, SWT.CHECK); - placeImplemetation.setText(Messages.GenerateGettersAndSettersInputPage_PlaceImplHeader); + + final Button definitionSeparate = new Button(comp, SWT.CHECK); + definitionSeparate.setText(Messages.GenerateGettersAndSettersInputPage_SeparateDefinition); gd = new GridData(); gd.horizontalSpan = 2; gd.heightHint = 40; - placeImplemetation.setLayoutData(gd); - placeImplemetation.setSelection(context.isImplementationInHeader()); - placeImplemetation.addSelectionListener(new SelectionAdapter() { + definitionSeparate.setLayoutData(gd); + definitionSeparate.setSelection(context.isDefinitionSeparate()); + definitionSeparate.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - context.setImplementationInHeader(placeImplemetation.getSelection()); + context.setDefinitionSeparate(definitionSeparate.getSelection()); } }); @@ -206,7 +207,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl } } variableSelectionView.addCheckStateListener(new ICheckStateListener() { - + @Override public void checkStateChanged(CheckStateChangedEvent event) { Set checkedFunctions = context.selectedFunctions; for (Object currentElement : variableSelectionView.getCheckedElements()) { @@ -219,6 +220,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl }); } + @Override public void preferenceChange(PreferenceChangeEvent event) { if (variableSelectionView.getTree().isDisposed()) { return; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java index 674491ba813..b47facba584 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java @@ -121,9 +121,10 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 { public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext checkContext) throws CoreException, OperationCanceledException { RefactoringStatus result = new RefactoringStatus(); - if (!context.isImplementationInHeader()) { + if (context.isDefinitionSeparate()) { findDefinitionInsertLocation(pm); - if (definitionInsertLocation == null || tu.equals(definitionInsertLocation.getTranslationUnit())) { + if (definitionInsertLocation == null || + definitionInsertLocation.getTranslationUnit() == null) { result.addInfo(Messages.GenerateGettersAndSettersRefactoring_NoImplFile); } } @@ -230,14 +231,19 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 { List getterAndSetters = new ArrayList(); List definitions = new ArrayList(); for (GetterSetterInsertEditProvider currentProvider : context.selectedFunctions) { - if (context.isImplementationInHeader()) { - getterAndSetters.add(currentProvider.getFunctionDefinition(false)); - } else { + if (context.isDefinitionSeparate()) { getterAndSetters.add(currentProvider.getFunctionDeclaration()); - definitions.add(currentProvider.getFunctionDefinition(true)); + IASTFunctionDefinition functionDefinition = currentProvider.getFunctionDefinition(true); + // Standalone definitions in a header file have to be declared inline. + if (definitionInsertLocation.getTranslationUnit().isHeaderUnit()) { + functionDefinition.getDeclSpecifier().setInline(true); + } + definitions.add(functionDefinition); + } else { + getterAndSetters.add(currentProvider.getFunctionDefinition(false)); } } - if (!context.isImplementationInHeader()) { + if (context.isDefinitionSeparate()) { addDefinition(collector, definitions, pm); } ICPPASTCompositeTypeSpecifier classDefinition = @@ -271,9 +277,9 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 { } IASTSimpleDeclaration decl = context.existingFields.get(0); - MethodDefinitionInsertLocationFinder methodDefinitionInsertLocationFinder = new MethodDefinitionInsertLocationFinder(); - InsertLocation location = methodDefinitionInsertLocationFinder.find( - tu, decl.getFileLocation(), decl.getParent(), astCache, pm); + MethodDefinitionInsertLocationFinder locationFinder = new MethodDefinitionInsertLocationFinder(); + InsertLocation location = locationFinder.find(tu, decl.getFileLocation(), decl.getParent(), + astCache, pm); if (location.getFile() == null || NodeHelper.isContainedInTemplateDeclaration(decl)) { location.setNodeToInsertAfter(NodeHelper.findTopLevelParent(decl), tu); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java index 757619cb40c..6cd78af1bd2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java @@ -33,8 +33,9 @@ public class GetterSetterContext implements ITreeContentProvider { public SortedSet selectedFunctions = new TreeSet(); public IASTName selectedName; private ArrayList wrappedFields; - private boolean implementationInHeader = false; + private boolean definitionSeparate; + @Override public Object[] getChildren(Object parentElement) { ArrayList children = new ArrayList(); if (parentElement instanceof FieldWrapper) { @@ -63,10 +64,12 @@ public class GetterSetterContext implements ITreeContentProvider { return new GetterSetterInsertEditProvider(fieldName, simpleDeclaration, AccessorKind.SETTER); } + @Override public Object getParent(Object element) { return null; } + @Override public boolean hasChildren(Object element) { if (element instanceof FieldWrapper) { FieldWrapper wrapper = (FieldWrapper) element; @@ -75,14 +78,17 @@ public class GetterSetterContext implements ITreeContentProvider { return false; } + @Override public Object[] getElements(Object inputElement) { return getWrappedFields().toArray(); } public void refresh() { - // We only recreate the function declarations instead of recreating GetterSetterInsertEditProviders. - // That way, selectedFunctions is still valid. Also, the objects inside the TreeViewer are still the same - // which is convenient because that way we don't need to save then restore the collapsed/expanded+checked/unchecked state of the TreeViewer. + // We only recreate the function declarations instead of recreating + // GetterSetterInsertEditProviders. That way, selectedFunctions is still valid. + // Also, the objects inside the TreeViewer are still the same, which is convenient because + // that way we don't need to save then restore the collapsed/expanded+checked/unchecked + // state of the TreeViewer. for (FieldWrapper wrapper : wrappedFields) { for (GetterSetterInsertEditProvider provider : wrapper.childNodes) { provider.createFunctionDeclaration(); @@ -90,18 +96,20 @@ public class GetterSetterContext implements ITreeContentProvider { } } + @Override public void dispose() { } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } - public boolean isImplementationInHeader() { - return implementationInHeader; + public boolean isDefinitionSeparate() { + return definitionSeparate; } - public void setImplementationInHeader(boolean implementationInHeader) { - this.implementationInHeader = implementationInHeader; + public void setDefinitionSeparate(boolean definitionSeparate) { + this.definitionSeparate = definitionSeparate; } private ArrayList getWrappedFields() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java index 05eb4e954b1..eb47fdb3b6a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java @@ -4,7 +4,7 @@ * 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 + * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Institute for Software - initial API and implementation @@ -84,11 +84,11 @@ public class GetterSetterInsertEditProvider implements Comparable projects= new ArrayList(); IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); @@ -64,10 +64,12 @@ public class FindUnresolvedIncludesProjectAction implements IObjectActionDelegat NewSearchUI.runQueryInBackground(searchJob); } + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { fSite= targetPart.getSite(); } + @Override public void selectionChanged(IAction action, ISelection selection) { fSelection= selection; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 4e149bbbd68..7e846fcabc9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -149,6 +149,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { } } + @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { if (ast == null) { return Status.OK_STATUS; @@ -484,6 +485,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { } runInUIThread(new Runnable() { + @Override public void run() { ISourceReference target= null; if (uniqueElements.size() == 1) { @@ -561,6 +563,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { final int length = fileloc.getNodeLength(); runInUIThread(new Runnable() { + @Override public void run() { try { fAction.open(path, offset, length); @@ -588,6 +591,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { if (name != null) { final IPath path = new Path(name); runInUIThread(new Runnable() { + @Override public void run() { try { fAction.open(path, 0, 0); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java index 57018614991..c645caa46e8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java @@ -209,7 +209,7 @@ public class ChangeBuildConfigActionBase { project = null; else { ICConfigurationDescription[] tmp = getCfgs(project); - if (tmp == null || tmp.length == 0) project = null; + if (tmp.length == 0) project = null; } } if (project != null) { @@ -282,11 +282,13 @@ public class ChangeBuildConfigActionBase { private ICConfigurationDescription[] getCfgs(IProject prj) { ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false); - if (prjd == null) return null; - ICConfigurationDescription[] tmp = prjd.getConfigurations(); - if (tmp == null) return null; - return prjd.getConfigurations(); + if (prjd != null) { + ICConfigurationDescription[] cfgs = prjd.getConfigurations(); + if (cfgs != null) { + return cfgs; + } + } + + return new ICConfigurationDescription[0]; } - - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java index 691ea16bf74..412011c2196 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java @@ -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 @@ -131,6 +131,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { protected boolean visible; + @Override public void createControls(Composite _parent, ICPropertyProvider _provider) { page = _provider; createControls(_parent); @@ -145,12 +146,12 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { */ protected void createControls(Composite parent) { parent.setLayout(new FillLayout()); - pageBook = new PageBook(parent, SWT.NULL); + pageBook = new PageBook(parent, SWT.NULL); background = new CLabel(pageBook, SWT.CENTER | SWT.SHADOW_NONE); background.setText(EMPTY_STR); - GridData gd; + GridData gd; userdata= new Composite(pageBook, SWT.NONE); userdata.setLayout(new GridLayout(2, false)); @@ -166,7 +167,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { pageBook.showPage(userdata); - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, helpId); + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, helpId); } /** @@ -193,7 +194,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { protected void initButtons(Composite c, String[] names, int width) { if (names == null || names.length == 0) return; c.setLayoutData(new GridData(GridData.FILL_VERTICAL)); - c.setLayout(new GridLayout(1, false)); + c.setLayout(new GridLayout(1, false)); buttons = new Button[names.length]; for (int i=0; itrue to make this tab visible, - * and false to hide it - */ - public void setVisible(boolean _visible) { - visible = _visible; - if (visible) updateData(page.getResDesc()); - } + /** + * Sets the visibility of this property tab. + * + * @param _visible true to make this tab visible, + * and false to hide it + */ + public void setVisible(boolean _visible) { + visible = _visible; + if (visible) updateData(page.getResDesc()); + } - /** - * Descendant tabs should implement this method so - * that it copies it's data from one description - * to another. Only data affected by given tab - * should be copied. - * - * @param src - * @param dst - */ + /** + * Descendant tabs should implement this method so + * that it copies it's data from one description + * to another. Only data affected by given tab + * should be copied. + * + * @param src + * @param dst + */ protected abstract void performApply(ICResourceDescription src, ICResourceDescription dst); protected abstract void performDefaults(); protected abstract void updateData(ICResourceDescription cfg); @@ -261,7 +263,6 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { protected void performOK() {} /** - * * @param e - event to be handled */ private void buttonPressed(SelectionEvent e) { @@ -361,16 +362,17 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { } protected Button setupCheck(Composite c, String name, int span, int mode) { - Button b = new Button(c, SWT.CHECK); - b.setText(name); - setupControl(b, span, mode); - b.addSelectionListener(new SelectionAdapter() { - @Override + Button b = new Button(c, SWT.CHECK); + b.setText(name); + setupControl(b, span, mode); + b.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent event) { - setGrayed((Button)event.widget, false); - checkPressed(event); - }}); - return b; + ((Button) event.widget).setGrayed(false); + checkPressed(event); + } + }); + return b; } /** @@ -385,8 +387,9 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { * else if (b.equals(mySecondCheckbox) { ... } * ... } */ - protected void checkPressed(SelectionEvent e) {} - + protected void checkPressed(SelectionEvent e) { + } + protected void setupControl(Control c, int span, int mode) { // although we use GridLayout usually, // exceptions can occur: do nothing. @@ -484,16 +487,17 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { } dialog.setInitialSelection(container); dialog.setValidator(new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - if (selection != null) - if (selection.length > 0) - if ((selection[0] instanceof IFile)) - return new StatusInfo(IStatus.ERROR, WORKSPACE_DIR_DIALOG_ERR); - return new StatusInfo(); - } + @Override + public IStatus validate(Object[] selection) { + if (selection != null) + if (selection.length > 0) + if ((selection[0] instanceof IFile)) + return new StatusInfo(IStatus.ERROR, WORKSPACE_DIR_DIALOG_ERR); + return new StatusInfo(); + } }); - dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE); - dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG); + dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE); + dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG); } else { IResource resource = null; if(path.isAbsolute()){ @@ -501,16 +505,17 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { } dialog.setInitialSelection(resource); dialog.setValidator(new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - if (selection != null) - if (selection.length > 0) - if (!(selection[0] instanceof IFile)) - return new StatusInfo(IStatus.ERROR, WORKSPACE_FILE_DIALOG_ERR); - return new StatusInfo(); - } + @Override + public IStatus validate(Object[] selection) { + if (selection != null) + if (selection.length > 0) + if (!(selection[0] instanceof IFile)) + return new StatusInfo(IStatus.ERROR, WORKSPACE_FILE_DIALOG_ERR); + return new StatusInfo(); + } }); - dialog.setTitle(WORKSPACE_FILE_DIALOG_TITLE); - dialog.setMessage(WORKSPACE_FILE_DIALOG_MSG); + dialog.setTitle(WORKSPACE_FILE_DIALOG_TITLE); + dialog.setMessage(WORKSPACE_FILE_DIALOG_MSG); } if (dialog.open() == Window.OK) { IResource resource = (IResource) dialog.getFirstResult(); @@ -530,6 +535,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { /** * Common event handler: called by parent for each tab */ + @Override public void handleTabEvent (int kind, Object data) { switch(kind) { case ICPropertyTab.OK: @@ -567,8 +573,9 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { } } - // By default, returns true (no visibility restriction) - // But several pages should rewrite this functionality. + // By default, returns true (no visibility restriction) + // But several pages should rewrite this functionality. + @Override public boolean canBeVisible() { return true; } @@ -605,16 +612,16 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab { public static void setTriSelection(Button b, int state) { switch (state) { case TRI_NO: - setGrayed(b, false); + b.setGrayed(false); b.setSelection(false); break; case TRI_YES: - setGrayed(b, false); + b.setGrayed(false); b.setSelection(true); break; case TRI_UNKNOWN: + b.setGrayed(true); b.setSelection(true); - setGrayed(b, true); break; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java index 8c339a7237a..e4042acb048 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java @@ -31,7 +31,6 @@ import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.ui.refactoring.DocumentAdapter; import org.eclipse.cdt.internal.ui.refactoring.UndoCTextFileChange; - /** * A TextFileChange that uses a working copy in order to generate CModel events. * @@ -63,10 +62,6 @@ public class CTextFileChange extends TextFileChange { setTextType(TEXT_TYPE); } - /* - * (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.TextFileChange#acquireDocument(org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException { IDocument doc= super.acquireDocument(pm); @@ -85,16 +80,11 @@ public class CTextFileChange extends TextFileChange { protected void commit(final IDocument document, final IProgressMonitor pm) throws CoreException { if (fWorkingCopy == null) { super.commit(document, pm); - } - else if (needsSaving()) { + } else if (needsSaving()) { fWorkingCopy.commit(false, pm); } } - /* - * (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.TextFileChange#releaseDocument(org.eclipse.jface.text.IDocument, org.eclipse.core.runtime.IProgressMonitor) - */ @Override protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException { super.releaseDocument(document, pm); @@ -105,11 +95,7 @@ public class CTextFileChange extends TextFileChange { } } } - - /* - * (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.TextFileChange#createUndoChange(org.eclipse.text.edits.UndoEdit, org.eclipse.ltk.core.refactoring.ContentStamp) - */ + @Override protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) { return new UndoCTextFileChange(getName(), getFile(), edit, stampToRestore, getSaveMode()); diff --git a/cross/org.eclipse.cdt.build.crossgcc/.classpath b/cross/org.eclipse.cdt.build.crossgcc/.classpath old mode 100755 new mode 100644 index 64c5e31b7a2..8a8f1668cdc --- a/cross/org.eclipse.cdt.build.crossgcc/.classpath +++ b/cross/org.eclipse.cdt.build.crossgcc/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/cross/org.eclipse.cdt.build.crossgcc/.project b/cross/org.eclipse.cdt.build.crossgcc/.project old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/.settings/org.eclipse.jdt.core.prefs b/cross/org.eclipse.cdt.build.crossgcc/.settings/org.eclipse.jdt.core.prefs old mode 100755 new mode 100644 index 2884116de09..a75faebadf5 --- a/cross/org.eclipse.cdt.build.crossgcc/.settings/org.eclipse.jdt.core.prefs +++ b/cross/org.eclipse.cdt.build.crossgcc/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ -#Wed May 06 10:39:04 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:18:23 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cross/org.eclipse.cdt.build.crossgcc/META-INF/MANIFEST.MF b/cross/org.eclipse.cdt.build.crossgcc/META-INF/MANIFEST.MF old mode 100755 new mode 100644 index 6158156fa3c..ccea5ca7c3e --- a/cross/org.eclipse.cdt.build.crossgcc/META-INF/MANIFEST.MF +++ b/cross/org.eclipse.cdt.build.crossgcc/META-INF/MANIFEST.MF @@ -10,6 +10,6 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.managedbuilder.gnu.ui;bundle-version="5.0.100", org.eclipse.core.resources;bundle-version="3.5.0" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin diff --git a/cross/org.eclipse.cdt.build.crossgcc/build.properties b/cross/org.eclipse.cdt.build.crossgcc/build.properties old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/build/crossgcc/SetCrossCommandProcess.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/build/crossgcc/SetCrossCommandProcess.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/Activator.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/Activator.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossCommandLineGenerator.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossCommandLineGenerator.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossEnvironmentVariableSupplier.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossEnvironmentVariableSupplier.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/templates/setCrossCommand/template.xml b/cross/org.eclipse.cdt.build.crossgcc/templates/setCrossCommand/template.xml old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepinto.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepinto.gif old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepover.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepover.gif old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/uncall.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/uncall.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/btn_columns.png b/doc/org.eclipse.cdt.doc.user/images/btn_columns.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/btn_import_executables.png b/doc/org.eclipse.cdt.doc.user/images/btn_import_executables.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/btn_restart.png b/doc/org.eclipse.cdt.doc.user/images/btn_restart.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/c_exe_obj.png b/doc/org.eclipse.cdt.doc.user/images/c_exe_obj.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/c_object_file.png b/doc/org.eclipse.cdt.doc.user/images/c_object_file.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_define_build_var.png b/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_define_build_var.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_edit_build_var.png b/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_edit_build_var.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_menu_toggle_comments.png b/doc/org.eclipse.cdt.doc.user/images/cdt_menu_toggle_comments.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_pref_build_vars.png b/doc/org.eclipse.cdt.doc.user/images/cdt_pref_build_vars.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_pref_new_task_tag_dlg.png b/doc/org.eclipse.cdt.doc.user/images/cdt_pref_new_task_tag_dlg.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_pref_task_tags.png b/doc/org.eclipse.cdt.doc.user/images/cdt_pref_task_tags.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_w_basic06a.png b/doc/org.eclipse.cdt.doc.user/images/cdt_w_basic06a.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_01.png b/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_01.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_02.png b/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_02.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/command_link.png b/doc/org.eclipse.cdt.doc.user/images/command_link.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/editor_mark_preferences.png b/doc/org.eclipse.cdt.doc.user/images/editor_mark_preferences.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/editor_save_actions_preferences.png b/doc/org.eclipse.cdt.doc.user/images/editor_save_actions_preferences.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/hierarchy_co.gif b/doc/org.eclipse.cdt.doc.user/images/hierarchy_co.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/history_list.gif b/doc/org.eclipse.cdt.doc.user/images/history_list.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_build_make_target.png b/doc/org.eclipse.cdt.doc.user/images/icon_build_make_target.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_clear_console.png b/doc/org.eclipse.cdt.doc.user/images/icon_clear_console.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_edit_make_target.png b/doc/org.eclipse.cdt.doc.user/images/icon_edit_make_target.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_expand_all.png b/doc/org.eclipse.cdt.doc.user/images/icon_expand_all.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_hide_inactive_includes.png b/doc/org.eclipse.cdt.doc.user/images/icon_hide_inactive_includes.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_hide_make_targets.png b/doc/org.eclipse.cdt.doc.user/images/icon_hide_make_targets.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_hide_sys_includes.png b/doc/org.eclipse.cdt.doc.user/images/icon_hide_sys_includes.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_new_make_target.png b/doc/org.eclipse.cdt.doc.user/images/icon_new_make_target.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_next_error.png b/doc/org.eclipse.cdt.doc.user/images/icon_next_error.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_open_console.png b/doc/org.eclipse.cdt.doc.user/images/icon_open_console.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_pin.png b/doc/org.eclipse.cdt.doc.user/images/icon_pin.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_prev_error.png b/doc/org.eclipse.cdt.doc.user/images/icon_prev_error.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_repeat_search.png b/doc/org.eclipse.cdt.doc.user/images/icon_repeat_search.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_save_output_file.png b/doc/org.eclipse.cdt.doc.user/images/icon_save_output_file.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_show_error.png b/doc/org.eclipse.cdt.doc.user/images/icon_show_error.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/namespace_declared_obj.png b/doc/org.eclipse.cdt.doc.user/images/namespace_declared_obj.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/new_proj_convert_candidate.png b/doc/org.eclipse.cdt.doc.user/images/new_proj_convert_candidate.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_panel_build.png b/doc/org.eclipse.cdt.doc.user/images/pref_panel_build.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_panel_code_templates.png b/doc/org.eclipse.cdt.doc.user/images/pref_panel_code_templates.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_panel_edit_template_dlg.png b/doc/org.eclipse.cdt.doc.user/images/pref_panel_edit_template_dlg.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_traditional_memory_prefs.png b/doc/org.eclipse.cdt.doc.user/images/pref_traditional_memory_prefs.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/progress_stop.gif b/doc/org.eclipse.cdt.doc.user/images/progress_stop.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/refresh_nav.gif b/doc/org.eclipse.cdt.doc.user/images/refresh_nav.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/sub_co.gif b/doc/org.eclipse.cdt.doc.user/images/sub_co.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/super_co.gif b/doc/org.eclipse.cdt.doc.user/images/super_co.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/view_call_hierarchy.png b/doc/org.eclipse.cdt.doc.user/images/view_call_hierarchy.png index 6485a3bdccb..5e7d19ae682 100644 Binary files a/doc/org.eclipse.cdt.doc.user/images/view_call_hierarchy.png and b/doc/org.eclipse.cdt.doc.user/images/view_call_hierarchy.png differ diff --git a/doc/org.eclipse.cdt.doc.user/images/view_executables.png b/doc/org.eclipse.cdt.doc.user/images/view_executables.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/view_include_browser.png b/doc/org.eclipse.cdt.doc.user/images/view_include_browser.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/view_table_rendering.png b/doc/org.eclipse.cdt.doc.user/images/view_table_rendering.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_call_hierarchy_view.htm b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_call_hierarchy_view.htm index 8cd0d98f645..72ac6f8f195 100644 --- a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_call_hierarchy_view.htm +++ b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_call_hierarchy_view.htm @@ -60,6 +60,11 @@ Refresh View Contents Refreshes the view to reflect the current state of the function. + +
    Pin the Call Hierarchy View icon
    + Pin the Call Hierarchy View + Pins the current view and enables the user to open multiple Call Hierarchy views at the same time. +
    Menu icon
    View Menu diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepinto.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepinto.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepover.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepover.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/stop_visual_trace.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/stop_visual_trace.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/uncall.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/uncall.gif old mode 100755 new mode 100644 diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/.options b/dsf/org.eclipse.cdt.examples.dsf.pda/.options old mode 100755 new mode 100644 diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/memorybrowser_view.gif b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/memorybrowser_view.gif old mode 100755 new mode 100644 diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java index c68096d8fa7..aa9fd5f79d6 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/GoToAddressBarWidget.java @@ -268,16 +268,36 @@ public class GoToAddressBarWidget { public void loadSavedExpressions(Object context, String memorySpace) { try { + // Rebuild the combobox entries, but make sure we don't clear the + // (expression) field. It's an input field; don't trample anything + // the user may have previously entered or is in the process of + // entering (see bugzilla 356346). removeAll() clears all the + // entries and the field. remove(beg, end) leaves the field in-tact + // as long as it's not asked to remove the entry the user selected + // to set the current field value. So, if the current expression + // corresponds to an entry, we purge all the entries but that one. String[] expressions = getSavedExpressions(context, memorySpace); String currentExpression = fExpression.getText(); - fExpression.removeAll(); + if (currentExpression.length() > 0) + { + int index = fExpression.indexOf(currentExpression); + if(index > 0) { + fExpression.remove(0, index-1); + } + index = fExpression.indexOf(currentExpression); + if (fExpression.getItemCount() - index - 1 > 1) { + fExpression.remove(index+1, fExpression.getItemCount()-1); + } + } + else { + // No expression to trample. Use removeAll() + fExpression.removeAll(); + } for (String expression : expressions) { - fExpression.add(expression); + if (fExpression.indexOf(expression) < 0) { + fExpression.add(expression); + } } - if (currentExpression != null) { - fExpression.setText(currentExpression); - } - System.out.println("GoToAddressBarWidget: set context field to " + context); } catch (CoreException e) { // Unexpected snag dealing with launch configuration MemoryBrowserPlugin.log(e); diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java index 346effcc136..29b2fc88f8a 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java @@ -195,10 +195,15 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM /** * Property we attach to a CTabItem to track the expression we used to - * create memory blocks on the tab's behalf. Value is an - * {@link String} + * create memory blocks on the tab's behalf. Value is a String. */ - private final static String KEY_EXPRESSION = "EXPRESSION"; //$NON-NLS-1$ + private final static String KEY_EXPRESSION = "EXPRESSION"; //$NON-NLS-1$ + + /** + * Property we attach to a CTabItem to track the address associated with + * KEY_EXPRESSION. Value is a BigInteger + */ + private final static String KEY_EXPRESSION_ADDRESS = "EXPRESSION_ADDRESS"; //$NON-NLS-1$ public static final String PREF_DEFAULT_RENDERING = "org.eclipse.cdt.debug.ui.memory.memorybrowser.defaultRendering"; //$NON-NLS-1$ @@ -547,7 +552,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM @Override public void run() { try { - BigInteger newBase = getExpressionAddress(retrieval, expression, context, memorySpaceId); + final BigInteger newBase = getExpressionAddress(retrieval, expression, context, memorySpaceId); IMemoryBlockExtension block = (IMemoryBlockExtension) renderingFinal.getMemoryBlock(); if (block.supportBaseAddressModification()) { block.setBaseAddress(newBase); @@ -563,6 +568,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM public void run() { CTabItem selection = activeFolder.getSelection(); selection.setData(KEY_EXPRESSION, expression); + selection.setData(KEY_EXPRESSION_ADDRESS, newBase); fGotoAddressBar.handleExpressionStatus(Status.OK_STATUS); updateLabel(selection, renderingFinal); } @@ -609,13 +615,36 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM if (memorySpaceID != null) { IMemoryBlockRetrieval retrieval = (IMemoryBlockRetrieval) tab.getParent().getData(KEY_RETRIEVAL); if (retrieval instanceof IMemorySpaceAwareMemoryBlockRetrieval) { - label = ((IMemorySpaceAwareMemoryBlockRetrieval)retrieval).encodeAddress("0x" + viewportAddress.toString(16), memorySpaceID) + ' ' + renderingType; + label = ((IMemorySpaceAwareMemoryBlockRetrieval)retrieval).encodeAddress("0x" + viewportAddress.toString(16), memorySpaceID); } } if (label == null) { - label = "0x" + viewportAddress.toString(16) + ' ' + renderingType; + label = "0x" + viewportAddress.toString(16); } + // If the expression that was went to ("Go") is not a hex address, + // or it is but the user has scrolled/paged, then show the + // expression after the viewport hex address. Additionally, if some + // scrolling/paging has moved the viewport, also show the relative + // displacement. E.g., + // "0x10020 - gSomeVar(+20) " + // (for a tab where the user did a "Go" to "gSomeVar" then paged + // down, and where gSomeVar is at 0x10000) + // + String expression = (String)tab.getData(KEY_EXPRESSION); + BigInteger evaluatedAddress = (BigInteger)tab.getData(KEY_EXPRESSION_ADDRESS); + if(expression != null && !expression.equals("0x" + viewportAddress.toString(16))) { + label += " - " + expression; + BigInteger delta = evaluatedAddress.subtract(viewportAddress); + if (!delta.equals(BigInteger.ZERO)) { + label += "("; + label += delta.signum() < 0 ? '+' : '-'; + label += "0x" + delta.abs().toString(16) +")"; + } + } + + label += ' ' + renderingType;; + // Allow the memory block to customize the label. The platform's // Memory view support this (it was done in the call to // rendering.getLabel() above) @@ -969,7 +998,6 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { CTabItem tabItem = (CTabItem)e.item; - updateExpression(tabItem); updateMemorySpaceControlSelection(tabItem); fGotoAddressBar.loadSavedExpressions(context, fGotoMemorySpaceControl.isVisible() ? fGotoMemorySpaceControl.getText() : null); getSite().getSelectionProvider().setSelection(new StructuredSelection(tabItem.getData(KEY_RENDERING))); @@ -980,9 +1008,6 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM tabFolder.setData(KEY_RETRIEVAL, retrieval); fContextFolders.put(retrieval, tabFolder); fStackLayout.topControl = tabFolder; - // set empty initial expression - fGotoAddressBar.setExpressionText(""); //$NON-NLS-1$ - fGotoAddressBar.loadSavedExpressions(context, fGotoMemorySpaceControl.isVisible() ? fGotoMemorySpaceControl.getText() : null); } // update debug context to the new selection tabFolder.setData(KEY_CONTEXT, context); @@ -1015,7 +1040,6 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM setMemorySpaceControlVisible(false); } - updateExpression(activeFolder.getSelection()); updateMemorySpaceControlSelection(activeFolder.getSelection()); fGotoAddressBar.loadSavedExpressions(context, fGotoMemorySpaceControl.isVisible() ? fGotoMemorySpaceControl.getText() : null); @@ -1172,8 +1196,9 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM tab.setData(KEY_MEMORY_SPACE, memorySpaceId); tab.setData(KEY_CONTAINER, container); tab.setData(KEY_RENDERING_TYPE, type); + tab.setData(KEY_EXPRESSION, expression); + tab.setData(KEY_EXPRESSION_ADDRESS, ((IMemoryBlockExtension)rendering.getMemoryBlock()).getBigBaseAddress()); getSite().getSelectionProvider().setSelection(new StructuredSelection(tab.getData(KEY_RENDERING))); - updateLabel(tab, rendering); return rendering; } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/api/IMemoryBrowser.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/api/IMemoryBrowser.java old mode 100755 new mode 100644 diff --git a/upc/org.eclipse.cdt.core.parser.upc/.classpath b/upc/org.eclipse.cdt.core.parser.upc/.classpath index 64c5e31b7a2..8a8f1668cdc 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/.classpath +++ b/upc/org.eclipse.cdt.core.parser.upc/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/upc/org.eclipse.cdt.core.parser.upc/.settings/org.eclipse.jdt.core.prefs b/upc/org.eclipse.cdt.core.parser.upc/.settings/org.eclipse.jdt.core.prefs index 17fcd01cce6..bdd98f91374 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/.settings/org.eclipse.jdt.core.prefs +++ b/upc/org.eclipse.cdt.core.parser.upc/.settings/org.eclipse.jdt.core.prefs @@ -1,65 +1,70 @@ -#Fri Apr 25 15:23:35 EDT 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:06:14 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/upc/org.eclipse.cdt.core.parser.upc/META-INF/MANIFEST.MF b/upc/org.eclipse.cdt.core.parser.upc/META-INF/MANIFEST.MF index 59d655a778e..d0b72722d9d 100644 --- a/upc/org.eclipse.cdt.core.parser.upc/META-INF/MANIFEST.MF +++ b/upc/org.eclipse.cdt.core.parser.upc/META-INF/MANIFEST.MF @@ -14,4 +14,4 @@ Export-Package: org.eclipse.cdt.core.dom.upc, org.eclipse.cdt.internal.core.dom.parser.upc.ast;x-internal:=true Bundle-Localization: plugin Bundle-Vendor: %Bundle-Vendor.0 -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.classpath b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.classpath index dd30818f980..a02812f3394 100644 --- a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.classpath +++ b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.settings/org.eclipse.jdt.core.prefs b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.settings/org.eclipse.jdt.core.prefs index 3bb8e4665b8..a5e2cb2c47a 100644 --- a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.settings/org.eclipse.jdt.core.prefs +++ b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Thu Feb 18 14:50:43 EST 2010 -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +#Wed Nov 16 18:11:37 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/META-INF/MANIFEST.MF b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/META-INF/MANIFEST.MF index f9fe46dd111..70660327191 100644 --- a/upc/org.eclipse.cdt.managedbuilder.bupc.ui/META-INF/MANIFEST.MF +++ b/upc/org.eclipse.cdt.managedbuilder.bupc.ui/META-INF/MANIFEST.MF @@ -16,6 +16,6 @@ Require-Bundle: org.eclipse.cdt.ui, Import-Package: org.eclipse.cdt.ui.wizards, org.eclipse.ui.wizards.newresource Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin diff --git a/windows/org.eclipse.cdt.msw.build/.classpath b/windows/org.eclipse.cdt.msw.build/.classpath index 751c8f2e504..ed2bc1287f0 100644 --- a/windows/org.eclipse.cdt.msw.build/.classpath +++ b/windows/org.eclipse.cdt.msw.build/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/windows/org.eclipse.cdt.msw.build/.settings/org.eclipse.jdt.core.prefs b/windows/org.eclipse.cdt.msw.build/.settings/org.eclipse.jdt.core.prefs index 0f0eb3002b3..ffc055039b3 100644 --- a/windows/org.eclipse.cdt.msw.build/.settings/org.eclipse.jdt.core.prefs +++ b/windows/org.eclipse.cdt.msw.build/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Mon Jul 23 15:38:07 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:13:49 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/windows/org.eclipse.cdt.msw.build/META-INF/MANIFEST.MF b/windows/org.eclipse.cdt.msw.build/META-INF/MANIFEST.MF index fefb9432cf1..0e8401d0f4e 100644 --- a/windows/org.eclipse.cdt.msw.build/META-INF/MANIFEST.MF +++ b/windows/org.eclipse.cdt.msw.build/META-INF/MANIFEST.MF @@ -10,5 +10,5 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.core, org.eclipse.cdt.managedbuilder.core Eclipse-LazyStart: true -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Vendor: Eclipse CDT diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/.classpath b/xlc/org.eclipse.cdt.core.lrparser.xlc/.classpath index bc645e1d3be..d4af06824c8 100644 --- a/xlc/org.eclipse.cdt.core.lrparser.xlc/.classpath +++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/.classpath @@ -1,8 +1,8 @@ - - - - - - - - + + + + + + + + diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.core.lrparser.xlc/.settings/org.eclipse.jdt.core.prefs index 570ff24edd2..26a354aacf5 100644 --- a/xlc/org.eclipse.cdt.core.lrparser.xlc/.settings/org.eclipse.jdt.core.prefs +++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,12 @@ -#Mon Mar 30 15:50:28 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:01:26 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/xlc/org.eclipse.cdt.core.lrparser.xlc/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.core.lrparser.xlc/META-INF/MANIFEST.MF index 2da9ca31efc..efafa950e20 100644 --- a/xlc/org.eclipse.cdt.core.lrparser.xlc/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.core.lrparser.xlc/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.1 Bundle-SymbolicName: org.eclipse.cdt.core.lrparser.xlc;singleton:=true Bundle-Version: 5.1.0.qualifier -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Localization: plugin Require-Bundle: org.eclipse.cdt.core;bundle-version="5.1.0", org.eclipse.cdt.core.lrparser;bundle-version="5.1.0", diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath index 64c5e31b7a2..8a8f1668cdc 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.settings/org.eclipse.jdt.core.prefs index 038e0096d67..a7a2ccad7ea 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.settings/org.eclipse.jdt.core.prefs +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ -#Thu Apr 09 15:32:44 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:10:00 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF index 7dfe41129f8..9acc793c11f 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.errorparsers.xlc.tests/META-INF/MANIFEST.MF @@ -14,4 +14,4 @@ Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.errorparsers.xlc.tests Bundle-ClassPath: . Bundle-Vendor: Eclipse.org -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/.classpath b/xlc/org.eclipse.cdt.errorparsers.xlc/.classpath index 64c5e31b7a2..8a8f1668cdc 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc/.classpath +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.errorparsers.xlc/.settings/org.eclipse.jdt.core.prefs index 34ea9ef9497..70d6562b162 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc/.settings/org.eclipse.jdt.core.prefs +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,12 @@ -#Thu Apr 09 15:31:36 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:09:22 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF index e77845b4679..f656ee96e34 100644 --- a/xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.errorparsers.xlc/META-INF/MANIFEST.MF @@ -12,4 +12,4 @@ Require-Bundle: org.eclipse.ui, Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.errorparsers.xlc Bundle-Vendor: %providerName -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/xlc/org.eclipse.cdt.make.xlc.core/.classpath b/xlc/org.eclipse.cdt.make.xlc.core/.classpath index 751c8f2e504..ed2bc1287f0 100644 --- a/xlc/org.eclipse.cdt.make.xlc.core/.classpath +++ b/xlc/org.eclipse.cdt.make.xlc.core/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/xlc/org.eclipse.cdt.make.xlc.core/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.make.xlc.core/.settings/org.eclipse.jdt.core.prefs index b5f30c715f1..fc1b41df1ac 100644 --- a/xlc/org.eclipse.cdt.make.xlc.core/.settings/org.eclipse.jdt.core.prefs +++ b/xlc/org.eclipse.cdt.make.xlc.core/.settings/org.eclipse.jdt.core.prefs @@ -1,63 +1,74 @@ -#Mon Nov 23 16:55:49 EST 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false -org.eclipse.jdt.core.formatter.comment.format_comments=true -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +#Wed Nov 16 18:10:51 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false +org.eclipse.jdt.core.formatter.comment.format_comments=true +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert diff --git a/xlc/org.eclipse.cdt.make.xlc.core/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.make.xlc.core/META-INF/MANIFEST.MF index 31f7d607657..9aad2e6548b 100644 --- a/xlc/org.eclipse.cdt.make.xlc.core/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.make.xlc.core/META-INF/MANIFEST.MF @@ -16,4 +16,4 @@ Export-Package: org.eclipse.cdt.make.xlc.core.activator, org.eclipse.cdt.make.xlc.core.scannerconfig.util Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.cdt.make.xlc.core.activator.Activator -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.classpath b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.classpath index 64c5e31b7a2..8a8f1668cdc 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.classpath +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.settings/org.eclipse.jdt.core.prefs index d53c6074144..f80d524f191 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.settings/org.eclipse.jdt.core.prefs +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/.settings/org.eclipse.jdt.core.prefs @@ -1,251 +1,251 @@ -#Thu Apr 09 15:42:22 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=1 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=80 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +#Wed Nov 16 18:12:11 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=80 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/META-INF/MANIFEST.MF index 324d07f63ac..487da8f2249 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.core/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.core/META-INF/MANIFEST.MF @@ -14,5 +14,5 @@ Require-Bundle: org.eclipse.cdt.managedbuilder.core, org.eclipse.ui Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.cdt.managedbuilder.xlc.core.XLCCorePlugin -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.eclipse.cdt.managedbuilder.xlc.core diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.classpath b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.classpath index 64c5e31b7a2..8a8f1668cdc 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.classpath +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs index ce6bbbbaf9b..6b73101d46f 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Thu Apr 09 15:42:52 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:12:43 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF index fa0af12ec86..f593aefa767 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.managedbuilder.xlc.ui/META-INF/MANIFEST.MF @@ -22,4 +22,4 @@ Export-Package: org.eclipse.cdt.managedbuilder.xlc.aix, org.eclipse.cdt.managedbuilder.xlc.ui.variables, org.eclipse.cdt.managedbuilder.xlc.ui.wizards Bundle-Vendor: %providerName -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.classpath b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.classpath index 5e4c1fe99cf..c2c5a85e66d 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.classpath +++ b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.settings/org.eclipse.jdt.core.prefs b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.settings/org.eclipse.jdt.core.prefs index 7e21e60d91e..0b4a4646727 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.settings/org.eclipse.jdt.core.prefs +++ b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,70 +1,70 @@ -#Thu May 14 16:32:01 EDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +#Wed Nov 16 18:13:11 EST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/META-INF/MANIFEST.MF b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/META-INF/MANIFEST.MF index c7ed8631192..2dbd4d5c0a5 100644 --- a/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/META-INF/MANIFEST.MF +++ b/xlc/org.eclipse.cdt.managedbuilder.xlupc.ui/META-INF/MANIFEST.MF @@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.variables;bundle-version="3.2.100", org.eclipse.cdt.core.parser.upc;bundle-version="5.0.0", org.eclipse.cdt.managedbuilder.xlc.ui;bundle-version="6.0.0" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Vendor: %Bundle-Vendor.0 Export-Package: org.eclipse.cdt.managedbuilder.xlupc.ui,