1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-04-04 17:17:01 -07:00
parent ef82e2a7b2
commit b424f35ce4
6 changed files with 73 additions and 112 deletions

View file

@ -22,10 +22,10 @@ import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace.Replace
/** /**
* @author Thomas Corbat * @author Thomas Corbat
*/ */
public class ChangeGeneratorTestSuite{ public class ChangeGeneratorTestSuite {
public static Test suite() throws Exception { public static Test suite() throws Exception {
TestSuite suite = new TestSuite("ChangeGeneratorTests"); TestSuite suite = new TestSuite("ChangeGeneratorTestSuite");
suite.addTest(ReplaceTestSuite.suite()); suite.addTest(ReplaceTestSuite.suite());
suite.addTest(RemoveTestSuite.suite()); suite.addTest(RemoveTestSuite.suite());

View file

@ -20,7 +20,7 @@ import junit.framework.TestSuite;
public class InsertBeforeTestSuite { public class InsertBeforeTestSuite {
public static Test suite() throws Exception { public static Test suite() throws Exception {
TestSuite suite = new TestSuite("ChangeGenerator InsertBefore Tests"); TestSuite suite = new TestSuite("InsertBeforeTestSuite");
suite.addTest(FirstParameterTest.suite()); suite.addTest(FirstParameterTest.suite());
suite.addTest(PointerParameterTest.suite()); suite.addTest(PointerParameterTest.suite());

View file

@ -20,7 +20,7 @@ import junit.framework.TestSuite;
public class ReplaceTestSuite { public class ReplaceTestSuite {
public static Test suite() throws Exception { public static Test suite() throws Exception {
TestSuite suite = new TestSuite("ChangeGeneratorReplaceTests"); TestSuite suite = new TestSuite("ReplaceTestSuite");
suite.addTest(NameTest.suite()); suite.addTest(NameTest.suite());
suite.addTest(MoveTest.suite()); suite.addTest(MoveTest.suite());

View file

@ -85,6 +85,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
@ -494,6 +495,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER); String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
Properties props= IndexerPreferences.getProperties(prj); Properties props= IndexerPreferences.getProperties(prj);
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
synchronized (fUpdatePolicies) { synchronized (fUpdatePolicies) {
if (fClosingProjects.contains(prj.getName())) { if (fClosingProjects.contains(prj.getName())) {
return; return;
@ -517,7 +520,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
} }
enqueue(new PDOMRebuildTask(indexer)); enqueue(new PDOMRebuildTask(indexer));
} }
} }}
if (oldIndexer != null) { if (oldIndexer != null) {
stopIndexer(oldIndexer); stopIndexer(oldIndexer);
@ -550,6 +553,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
assert !Thread.holdsLock(fProjectToPDOM); assert !Thread.holdsLock(fProjectToPDOM);
try { try {
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
synchronized (fUpdatePolicies) { synchronized (fUpdatePolicies) {
if (fClosingProjects.contains(name)) { if (fClosingProjects.contains(name)) {
if (fTraceIndexerSetup) if (fTraceIndexerSetup)
@ -599,12 +604,14 @@ public class PDOMManager implements IWritableIndexManager, IListener {
} }
return; return;
} }
} }}
// rebuild is required, try import first. // rebuild is required, try import first.
TeamPDOMImportOperation operation= new TeamPDOMImportOperation(project); TeamPDOMImportOperation operation= new TeamPDOMImportOperation(project);
operation.run(pm); operation.run(pm);
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
synchronized (fUpdatePolicies) { synchronized (fUpdatePolicies) {
if (fClosingProjects.contains(name)) { if (fClosingProjects.contains(name)) {
if (fTraceIndexerSetup) if (fTraceIndexerSetup)
@ -633,7 +640,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
} }
enqueue(task); enqueue(task);
} }
} }}
} catch (CoreException e) { } catch (CoreException e) {
// Ignore if project is no longer open // Ignore if project is no longer open
if (prj.isOpen()) { if (prj.isOpen()) {

View file

@ -38,7 +38,6 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
/** /**
* A launch configuration tab that displays and edits program arguments, * A launch configuration tab that displays and edits program arguments,
* and working directory launch configuration attributes. * and working directory launch configuration attributes.
@ -47,7 +46,6 @@ import org.eclipse.swt.widgets.Text;
* </p> * </p>
*/ */
public class CArgumentsTab extends CLaunchConfigurationTab { public class CArgumentsTab extends CLaunchConfigurationTab {
/** /**
* Tab identifier used for ordering of tabs added using the * Tab identifier used for ordering of tabs added using the
* <code>org.eclipse.debug.ui.launchConfigurationTabs</code> * <code>org.eclipse.debug.ui.launchConfigurationTabs</code>
@ -65,20 +63,17 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
// Working directory // Working directory
protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock(); protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock();
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
public void createControl(Composite parent) { public void createControl(Composite parent) {
Font font = parent.getFont(); Font font = parent.getFont();
Composite comp = new Composite(parent, SWT.NONE); Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, true); GridLayout layout = new GridLayout(1, true);
comp.setLayout(layout); comp.setLayout(layout);
comp.setFont(font); comp.setFont(font);
GridData gd = new GridData(GridData.FILL_BOTH); GridData gd = new GridData(GridData.FILL_BOTH);
comp.setLayoutData(gd); comp.setLayoutData(gd);
setControl(comp); setControl(comp);
GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB); GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB);
@ -87,52 +82,46 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
fWorkingDirectoryBlock.createControl(comp); fWorkingDirectoryBlock.createControl(comp);
} }
protected void createArgumentComponent(Composite comp, int horizontalSpan) { protected void createArgumentComponent(Composite comp, int horizontalSpan) {
Font font = comp.getFont(); Font font = comp.getFont();
Group group = new Group(comp, SWT.NONE); Group group = new Group(comp, SWT.NONE);
group.setFont(font); group.setFont(font);
group.setLayout(new GridLayout()); group.setLayout(new GridLayout());
GridData gd = new GridData(GridData.FILL_BOTH); GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = horizontalSpan; gd.horizontalSpan = horizontalSpan;
group.setLayoutData(gd); group.setLayoutData(gd);
group.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$ group.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$
fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
fPrgmArgumentsText.getAccessible().addAccessibleListener( fPrgmArgumentsText.getAccessible().addAccessibleListener(
new AccessibleAdapter() { new AccessibleAdapter() {
@Override @Override
public void getName(AccessibleEvent e) { public void getName(AccessibleEvent e) {
e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$ e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$
} }
} });
); gd = new GridData(GridData.FILL_BOTH);
gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 40;
gd.heightHint = 40; gd.widthHint = 100;
gd.widthHint = 100; fPrgmArgumentsText.setLayoutData(gd);
fPrgmArgumentsText.setLayoutData(gd); fPrgmArgumentsText.setFont(font);
fPrgmArgumentsText.setFont(font); fPrgmArgumentsText.addModifyListener(new ModifyListener() {
fPrgmArgumentsText.addModifyListener(new ModifyListener() { @Override
@Override public void modifyText(ModifyEvent evt) {
public void modifyText(ModifyEvent evt) { updateLaunchConfigurationDialog();
updateLaunchConfigurationDialog(); }
} });
}); fArgumentVariablesButton= createPushButton(group, LaunchMessages.getString("CArgumentsTab.Variables"), null); //$NON-NLS-1$
fArgumentVariablesButton= createPushButton(group, LaunchMessages.getString("CArgumentsTab.Variables"), null); //$NON-NLS-1$ gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END); fArgumentVariablesButton.setLayoutData(gd);
fArgumentVariablesButton.setLayoutData(gd); fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() {
fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() { @Override
public void widgetSelected(SelectionEvent arg0) {
/* (non-Javadoc) handleVariablesButtonSelected(fPrgmArgumentsText);
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) }
*/ });
@Override addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons
public void widgetSelected(SelectionEvent arg0) { }
handleVariablesButtonSelected(fPrgmArgumentsText);
}
});
addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons
}
/** /**
* A variable entry button has been pressed for the given text * A variable entry button has been pressed for the given text
@ -142,7 +131,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
protected void handleVariablesButtonSelected(Text textField) { protected void handleVariablesButtonSelected(Text textField) {
String variable = getVariable(); String variable = getVariable();
if (variable != null) { if (variable != null) {
// We should use insert() but not append() to be consistent with the Platform behavior (e.g. Common tab)
textField.insert(variable); textField.insert(variable);
} }
} }
@ -158,7 +146,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
} }
public void addControlAccessibleListener(Control control, String controlName) { public void addControlAccessibleListener(Control control, String controlName) {
//strip mnemonic (&) // Strip mnemonic (&)
String[] strs = controlName.split("&"); //$NON-NLS-1$ String[] strs = controlName.split("&"); //$NON-NLS-1$
StringBuffer stripped = new StringBuffer(); StringBuffer stripped = new StringBuffer();
for (int i = 0; i < strs.length; i++) { for (int i = 0; i < strs.length; i++) {
@ -169,36 +157,28 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
private class ControlAccessibleListener extends AccessibleAdapter { private class ControlAccessibleListener extends AccessibleAdapter {
private String controlName; private String controlName;
ControlAccessibleListener(String name) { ControlAccessibleListener(String name) {
controlName = name; controlName = name;
} }
@Override @Override
public void getName(AccessibleEvent e) { public void getName(AccessibleEvent e) {
e.result = controlName; e.result = controlName;
} }
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
*/
@Override @Override
public boolean isValid(ILaunchConfiguration config) { public boolean isValid(ILaunchConfiguration config) {
return fWorkingDirectoryBlock.isValid(config); return fWorkingDirectoryBlock.isValid(config);
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
@Override @Override
public void setDefaults(ILaunchConfigurationWorkingCopy config) { public void setDefaults(ILaunchConfigurationWorkingCopy config) {
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
*/
@Override @Override
public void initializeFrom(ILaunchConfiguration configuration) { public void initializeFrom(ILaunchConfiguration configuration) {
try { try {
@ -211,9 +191,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
} }
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
@Override @Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) { public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute( configuration.setAttribute(
@ -242,26 +219,17 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
return TAB_ID; return TAB_ID;
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
@Override @Override
public String getName() { public String getName() {
return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$ return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setLaunchConfigurationDialog(org.eclipse.debug.ui.ILaunchConfigurationDialog)
*/
@Override @Override
public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) { public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) {
super.setLaunchConfigurationDialog(dialog); super.setLaunchConfigurationDialog(dialog);
fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog); fWorkingDirectoryBlock.setLaunchConfigurationDialog(dialog);
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getErrorMessage()
*/
@Override @Override
public String getErrorMessage() { public String getErrorMessage() {
String m = super.getErrorMessage(); String m = super.getErrorMessage();
@ -271,9 +239,6 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
return m; return m;
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getMessage()
*/
@Override @Override
public String getMessage() { public String getMessage() {
String m = super.getMessage(); String m = super.getMessage();
@ -283,17 +248,11 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
return m; return m;
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
*/
@Override @Override
public Image getImage() { public Image getImage() {
return LaunchImages.get(LaunchImages.IMG_VIEW_ARGUMENTS_TAB); return LaunchImages.get(LaunchImages.IMG_VIEW_ARGUMENTS_TAB);
} }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog()
*/
@Override @Override
protected void updateLaunchConfigurationDialog() { protected void updateLaunchConfigurationDialog() {
super.updateLaunchConfigurationDialog(); super.updateLaunchConfigurationDialog();

View file

@ -8,7 +8,6 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Ken Ryall (Nokia) - bug 178731 * Ken Ryall (Nokia) - bug 178731
* Anton Gorenkov
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.launch.ui; package org.eclipse.cdt.launch.ui;
@ -45,7 +44,6 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab { public abstract class CLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
/** /**
* Returns the current C element context from which to initialize default * Returns the current C element context from which to initialize default
* settings, or <code>null</code> if none. Note, if possible we will * settings, or <code>null</code> if none. Note, if possible we will
@ -85,9 +83,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
} }
} }
if (obj instanceof IResource) { if (obj instanceof IResource) {
ICElement ce = CoreModel.getDefault().create((IResource)obj); ICElement ce = CoreModel.getDefault().create((IResource) obj);
if (ce == null) { if (ce == null) {
IProject pro = ((IResource)obj).getProject(); IProject pro = ((IResource) obj).getProject();
ce = CoreModel.getDefault().create(pro); ce = CoreModel.getDefault().create(pro);
} }
obj = ce; obj = ce;
@ -96,7 +94,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
if (platform != null && !platform.equals("*")) { //$NON-NLS-1$ if (platform != null && !platform.equals("*")) { //$NON-NLS-1$
ICDescriptor descriptor; ICDescriptor descriptor;
try { try {
descriptor = CCorePlugin.getDefault().getCProjectDescription( ((ICElement)obj).getCProject().getProject(), descriptor = CCorePlugin.getDefault().getCProjectDescription(((ICElement) obj).getCProject().getProject(),
false); false);
if (descriptor != null) { if (descriptor != null) {
String projectPlatform = descriptor.getPlatform(); String projectPlatform = descriptor.getPlatform();
@ -109,9 +107,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
} }
if (obj != null) { if (obj != null) {
if (programName == null || programName.equals("")) { //$NON-NLS-1$ if (programName == null || programName.equals("")) { //$NON-NLS-1$
return (ICElement)obj; return (ICElement) obj;
} }
ICElement ce = (ICElement)obj; ICElement ce = (ICElement) obj;
IProject project; IProject project;
project = (IProject)ce.getCProject().getResource(); project = (IProject)ce.getCProject().getResource();
IPath programFile = project.getFile(programName).getLocation(); IPath programFile = project.getFile(programName).getLocation();
@ -119,11 +117,10 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
if (ce != null && ce.exists()) { if (ce != null && ce.exists()) {
return ce; return ce;
} }
return (ICElement)obj; return (ICElement) obj;
} }
} }
if (page != null) if (page != null) {
{
IEditorPart part = page.getActiveEditor(); IEditorPart part = page.getActiveEditor();
if (part != null) { if (part != null) {
IEditorInput input = part.getEditorInput(); IEditorInput input = part.getEditorInput();
@ -160,7 +157,6 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
} }
config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
} }
protected String getPlatform(ILaunchConfiguration config) { protected String getPlatform(ILaunchConfiguration config) {
@ -210,5 +206,4 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
dialog.open(); dialog.open();
return dialog.getVariableExpression(); return dialog.getVariableExpression();
} }
} }