From bb0f0865d8d269e597f77297e06c4329c41f61a5 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 11 Sep 2011 18:54:40 -0700 Subject: [PATCH 1/5] Cosmetics. --- .../opentype/ElementSelectionDialog.java | 44 ++++++++----------- .../classwizard/NamespaceSelectionDialog.java | 1 - 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java index d7c67811ec2..6f1a856519e 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java @@ -9,7 +9,6 @@ * Anton Leherbauer (Wind River Systems) - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.browser.opentype; import java.util.Arrays; @@ -62,12 +61,10 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds; * @noextend This class is not intended to be subclassed by clients. */ public class ElementSelectionDialog extends TypeSelectionDialog { - /** * Job to update the element list in the background. */ private class UpdateElementsJob extends Job { - /** * The last used prefix to query the index. null means * the query result should be empty. @@ -111,14 +108,12 @@ public class ElementSelectionDialog extends TypeSelectionDialog { } return Status.CANCEL_STATUS; } - } /** * A job listener for simple job status reporting. */ private final class UpdateJobListener extends JobChangeAdapter { - boolean fDone; private IProgressMonitor fMonitor; @@ -183,7 +178,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { fUpdateJob= new UpdateElementsJob(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_name); fUpdateJob.setRule(SINGLE_INSTANCE_RULE); } - + /* * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#create() */ @@ -242,7 +237,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { // the low-level filter is useless for us return false; } - + /* * @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createDialogArea(org.eclipse.swt.widgets.Composite) */ @@ -261,7 +256,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { createProgressMonitorPart(parent); return table; } - + /** * Create the control for progress reporting. * @param parent @@ -290,7 +285,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { return null; } HashSet types = new HashSet(); - if(prefix != null) { + if (prefix != null) { final IndexFilter filter= new IndexFilter() { @Override public boolean acceptBinding(IBinding binding) throws CoreException { @@ -305,7 +300,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { index.acquireReadLock(); try { IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor); - for(int i=0; i newPrefix.length) { return false; @@ -406,5 +401,4 @@ public class ElementSelectionDialog extends TypeSelectionDialog { } return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length)); } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java index ada34e4faae..a3358bd7f73 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java @@ -15,7 +15,6 @@ import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog; import org.eclipse.swt.widgets.Shell; public class NamespaceSelectionDialog extends TypeSelectionDialog { - private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName(); private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE }; From ae0cde8d3af6c4b723a86f62fba2d24ef4c179c0 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 11 Sep 2011 19:54:48 -0700 Subject: [PATCH 2/5] Bug 292839 - Adding a base class takes too much time in New Class wizard. --- .../browser/typeinfo/TypeSelectionDialog.java | 11 ++-- .../NewBaseClassSelectionDialog.java | 46 ++++++++-------- .../classwizard/NewClassWizardMessages.java | 2 - .../NewClassWizardMessages.properties | 4 +- .../classwizard/NewClassWizardUtil.java | 52 ++----------------- .../wizards/NewClassCreationWizardPage.java | 17 ++---- 6 files changed, 35 insertions(+), 97 deletions(-) diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java index 5cae83cb0b5..d52441a03f7 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java @@ -48,7 +48,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.util.StringMatcher; - /** * A dialog to select a type from a list of types. * @@ -264,20 +263,19 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { public void setVisibleTypes(int[] types) { fKnownTypes.clear(); for (int i = 0; i < types.length; ++i) { - fKnownTypes.add(new Integer(types[i])); + fKnownTypes.add(types[i]); } } /** * Answer whether the given type is visible in the dialog. * - * @param type - * the type constant, see {@link ICElement} + * @param type the type constant, see {@link ICElement} * @return true if the given type is visible, * false otherwise */ protected boolean isVisibleType(int type) { - return fKnownTypes.contains(new Integer(type)); + return fKnownTypes.contains(type); } /** @@ -436,8 +434,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { upperLayout.marginWidth = 0; upperRow.setLayout(upperLayout); - // the for loop is here to guarantee we always - // create the checkboxes in the same order + // The 'for' loop is here to guarantee that we always create the checkboxes in the same order. for (int i = 0; i < ALL_TYPES.length; ++i) { Integer typeObject = new Integer(ALL_TYPES[i]); if (fKnownTypes.contains(typeObject)) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java index 6fef55a6c2a..d605c0db3b1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 QNX Software Systems and others. + * Copyright (c) 2004, 2011 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.wizards.classwizard; @@ -16,8 +17,9 @@ import java.util.List; import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.model.ICElement; + +import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; -import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.osgi.util.NLS; @@ -26,39 +28,37 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.progress.IProgressService; -public class NewBaseClassSelectionDialog extends TypeSelectionDialog { - +public class NewBaseClassSelectionDialog extends ElementSelectionDialog { private static final String DIALOG_SETTINGS = NewBaseClassSelectionDialog.class.getName(); private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT }; private static final int ADD_ID = IDialogConstants.CLIENT_ID + 1; private List fTypeList; private List fTypeListeners; - + public interface ITypeSelectionListener { void typeAdded(ITypeInfo baseClass); } - + public NewBaseClassSelectionDialog(Shell parent) { super(parent); setTitle(NewClassWizardMessages.NewBaseClassSelectionDialog_title); setMessage(NewClassWizardMessages.NewBaseClassSelectionDialog_message); setDialogSettings(DIALOG_SETTINGS); setVisibleTypes(VISIBLE_TYPES); - setFilter("*", true); //$NON-NLS-1$ setStatusLineAboveButtons(true); fTypeList = new ArrayList(); fTypeListeners = new ArrayList(); } - + public void addListener(ITypeSelectionListener listener) { if (!fTypeListeners.contains(listener)) fTypeListeners.add(listener); } - + public void removeListener(ITypeSelectionListener listener) { fTypeListeners.remove(listener); } - + private void notifyTypeAddedListeners(ITypeInfo type) { // first copy listeners in case one calls removeListener List list = new ArrayList(fTypeListeners); @@ -67,7 +67,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { listener.typeAdded(type); } } - + public ITypeInfo[] getAddedTypes() { return fTypeList.toArray(new ITypeInfo[fTypeList.size()]); } @@ -80,7 +80,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { createButton(parent, ADD_ID, NewClassWizardMessages.NewBaseClassSelectionDialog_addButton_label, true); super.createButtonsForButtonBar(parent); } - + /* * @see Dialog#buttonPressed */ @@ -91,7 +91,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { } super.buttonPressed(buttonId); } - + /* * @see Dialog#okPressed */ @@ -100,7 +100,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { addType(getLowerSelectedElement()); super.okPressed(); } - + private void addType(Object elem) { if (elem instanceof ITypeInfo) { ITypeInfo type = (ITypeInfo)elem; @@ -119,8 +119,8 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { NewClassWizardUtil.resolveClassLocation(type, service); canAdd = (type.getResolvedReference() != null); } - -// // resolve location of base class + +// // Resolve location of base class // if (type.getResolvedReference() == null) { // final ITypeInfo[] typesToResolve = new ITypeInfo[] { type }; // IRunnableWithProgress runnable = new IRunnableWithProgress() { @@ -131,7 +131,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { // } // } // }; -// +// // IProgressService service = PlatformUI.getWorkbench().getProgressService(); // try { // service.busyCursorWhile(runnable); @@ -140,13 +140,13 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { // String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$ // ExceptionHandler.handle(e, title, errorMessage); // } catch (InterruptedException e) { -// // cancelled by user +// // Cancelled by user // } // } - + if (canAdd) { fTypeList.add(type); - + message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classadded_info, qualifiedName); updateStatus(new StatusInfo(IStatus.INFO, message)); @@ -158,16 +158,16 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog { } } } - + /** - * Checks if the base classes need to be verified (ie they must exist in the project) + * Checks if the base classes need to be verified (i.e. they must exist in the project) * * @return true if the base classes should be verified */ public boolean verifyBaseClasses() { return NewClassWizardPrefs.verifyBaseClasses(); } - + /* * @see AbstractElementListSelectionDialog#handleDefaultSelected() */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java index 3c1510f2046..b2cd29b36cf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java @@ -17,8 +17,6 @@ public final class NewClassWizardMessages extends NLS { public static String NewClassCreationWizard_title; public static String NewClassCreationWizardPage_title; public static String NewClassCreationWizardPage_description; - public static String NewClassCreationWizardPage_getTypes_noClasses_title; - public static String NewClassCreationWizardPage_getTypes_noClasses_message; public static String NewClassCreationWizardPage_getTypes_noNamespaces_title; public static String NewClassCreationWizardPage_getTypes_noNamespaces_message; public static String NewClassCreationWizardPage_sourceFolder_label; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties index db06f35dc59..ff35ba93539 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties @@ -7,7 +7,7 @@ # # Contributors: # QNX Software Systems - Initial API and implementation -# IBM Corporation +# IBM Corporation # Anton Leherbauer (Wind River Systems) # Sergey Prigogin (Google) ############################################################################### @@ -19,8 +19,6 @@ NewClassCreationWizard_title=New C++ Class NewClassCreationWizardPage_title=C++ Class NewClassCreationWizardPage_description=Create a new C++ class. -NewClassCreationWizardPage_getTypes_noClasses_title=Class Selection -NewClassCreationWizardPage_getTypes_noClasses_message=No classes available. NewClassCreationWizardPage_getTypes_noNamespaces_title=Namespace Selection NewClassCreationWizardPage_getTypes_noNamespaces_message=No namespaces available. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java index 3beb305e7df..a479240e672 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java @@ -13,11 +13,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.wizards.classwizard; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; @@ -34,11 +30,9 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.views.contentoutline.ContentOutline; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.browser.AllTypesCache; import org.eclipse.cdt.core.browser.IQualifiedTypeName; import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.browser.ITypeReference; -import org.eclipse.cdt.core.browser.TypeSearchScope; import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -56,8 +50,6 @@ import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ISourceRoot; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.ui.CUIPlugin; @@ -65,7 +57,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider; public class NewClassWizardUtil { - /** * Returns the parent source folder of the given element. If the given * element is already a source folder, the element itself is returned. @@ -276,41 +267,6 @@ public class NewClassWizardUtil { return type.getResolvedReference(); } - private static final int[] CLASS_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT }; - - /** - * Returns all classes/structs which are accessible from the include - * paths of the given project. - * - * @param cProject the given project - * @return array of classes/structs - */ - public static ITypeInfo[] getReachableClasses(ICProject cProject) { - ITypeInfo[] elements = AllTypesCache.getTypes(new TypeSearchScope(true), CLASS_TYPES); - if (elements != null && elements.length > 0) { - if (cProject != null) { - IProject project = cProject.getProject(); - IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); - if (provider != null) { - //TODO get the scanner info for the actual source folder - IScannerInfo info = provider.getScannerInformation(project); - if (info != null) { - String[] includePaths = info.getIncludePaths(); - List filteredTypes = new ArrayList(); - for (int i = 0; i < elements.length; ++i) { - ITypeInfo baseType = elements[i]; - if (isTypeReachable(baseType, cProject, includePaths)) { - filteredTypes.add(baseType); - } - } - return filteredTypes.toArray(new ITypeInfo[filteredTypes.size()]); - } - } - } - } - return elements; - } - /** * Checks whether the given type can be found in the given project or the * given include paths. @@ -402,7 +358,7 @@ public class NewClassWizardUtil { boolean sameNameDifferentTypeExists = false; for (int i = 0; i < bindings.length; ++i) { - ICPPBinding binding = (ICPPBinding)bindings[i]; + ICPPBinding binding = (ICPPBinding) bindings[i]; //get the fully qualified name of this binding String bindingFullName = renderQualifiedName(binding.getQualifiedName()); @@ -424,8 +380,7 @@ public class NewClassWizardUtil { IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration ICPPNamespace.class.isAssignableFrom(currentNodeType) || ITypedef.class.isAssignableFrom(currentNodeType) || - ICPPBasicType.class.isAssignableFrom(currentNodeType)) - { + ICPPBasicType.class.isAssignableFrom(currentNodeType)) { if (bindingFullName.equals(fullyQualifiedTypeName)) { return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE; } @@ -446,8 +401,7 @@ public class NewClassWizardUtil { return SEARCH_MATCH_ERROR; } return SEARCH_MATCH_NOTFOUND; - } - finally { + } finally { index.releaseReadLock(); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java index f57fb9261cb..ae4f03403c3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java @@ -1178,14 +1178,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { } private void chooseBaseClasses() { - ITypeInfo[] elements = NewClassWizardUtil.getReachableClasses(getCurrentProject()); - if (elements == null || elements.length == 0) { - String title = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noClasses_title; - String message = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noClasses_message; - MessageDialog.openInformation(getShell(), title, message); - return; - } - List oldContents = fBaseClassesDialogField.getElements(); NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell()); dialog.addListener(new ITypeSelectionListener() { @@ -1193,16 +1185,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false); } }); - dialog.setElements(elements); int result = dialog.open(); if (result != IDialogConstants.OK_ID) { - // restore the old contents + // Restore the old contents fBaseClassesDialogField.setElements(oldContents); } } /** - * handles changes to the method stubs field + * Handles changes to the method stubs field */ private final class MethodStubsFieldAdapter implements IListAdapter { @@ -1667,7 +1658,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { ICProject project = getCurrentProject(); if (project != null) { - IQualifiedTypeName fullyQualifiedName = typeName; if (isNamespaceSelected()) { String namespace = getNamespaceText(); @@ -1745,7 +1735,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { ITypeInfo baseType = baseClass.getType(); StatusInfo baseClassStatus = new StatusInfo(); if (!NewClassWizardUtil.isTypeReachable(baseType, project, includePaths)) { - baseClassStatus.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_BaseClassNotExistsInProject, baseType.getQualifiedTypeName().toString())); + baseClassStatus.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_BaseClassNotExistsInProject, + baseType.getQualifiedTypeName().toString())); } status.add(baseClassStatus); } From 6d7a8182a01e264b6726f48e9bf29e9bd774d753 Mon Sep 17 00:00:00 2001 From: Daniel Thomas Date: Mon, 12 Sep 2011 09:37:11 -0400 Subject: [PATCH 3/5] Bug 357073: MIDataDisassemble should support modes 2 and 3 added in GDB 7.3 --- .../META-INF/MANIFEST.MF | 2 +- .../debug/mi/core/command/CommandFactory.java | 15 +++++- .../mi/core/command/MIDataDisassemble.java | 48 ++++++++++++------ .../mi/service/command/CommandFactory.java | 11 ++++ .../command/commands/MIDataDisassemble.java | 50 +++++++++++++------ 5 files changed, 94 insertions(+), 32 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF index d3e6a6a24bc..6607628edb9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.mi.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.mi.core; singleton:=true -Bundle-Version: 7.1.100.qualifier +Bundle-Version: 7.2.0.qualifier Bundle-Activator: org.eclipse.cdt.debug.mi.core.MIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java index 113bb1d6f92..61ed6871aff 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2011 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * ENEA Software AB - CLI command extension - fix for bug 190277 + * Marc Khouzam (Ericsson) - New methods for new MIDataDisassemble (Bug 357073) *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.command; @@ -88,10 +89,20 @@ public class CommandFactory { return new MIDataDisassemble(getMIVersion(), start, end, mixed); } + /** @since 7.2 */ + public MIDataDisassemble createMIDataDisassemble(String start, String end, int mode) { + return new MIDataDisassemble(getMIVersion(), start, end, mode); + } + public MIDataDisassemble createMIDataDisassemble(String file, int linenum, int lines, boolean mixed) { return new MIDataDisassemble(getMIVersion(), file, linenum, lines, mixed); } - + + /** @since 7.2 */ + public MIDataDisassemble createMIDataDisassemble(String file, int linenum, int lines, int mode) { + return new MIDataDisassemble(getMIVersion(), file, linenum, lines, mode); + } + public MIDataEvaluateExpression createMIDataEvaluateExpression(String expression) { return new MIDataEvaluateExpression(getMIVersion(), expression); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIDataDisassemble.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIDataDisassemble.java index e112576e753..6ec648ee2eb 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIDataDisassemble.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIDataDisassemble.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 QNX Software Systems and others. + * Copyright (c) 2000, 2011 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Daniel Thomas (Broadcom corp.) - Added support for mode 2 and 3 (Bug 357073) *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.command; @@ -47,8 +48,11 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput; * END-ADDR, only the lines up to END-ADDR are displayed. * *`MODE' - * is either 0 (meaning only disassembly) or 1 (meaning mixed source - * and disassembly). + * - 0 disassembly + * - 1 mixed source and disassembly + * - 2 disassembly with raw opcodes + * - 3 mixed source and disassembly with raw opcodes + * Note: Modes 2 and 3 are only available starting with GDB 7.3 * *Result *...... @@ -64,32 +68,48 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput; * * Instruction * * Note that whatever included in the instruction field, is not - *manipulated directely by GDB/MI, i.e. it is not possible to adjust its + *manipulated directly by GDB/MI, i.e. it is not possible to adjust its *format. * * */ public class MIDataDisassemble extends MICommand { + private static final int MIN_MODE = 0; + private static final int MAX_MODE = 3; + private static final String MODE_OUT_OF_RANGE = "Mode out of range: "; //$NON-NLS-1$ + public MIDataDisassemble(String miVersion, String start, String end, boolean mode) { + this(miVersion, start, end, mode ? 1 : 0); + } + + /** @since 7.2 */ + public MIDataDisassemble(String miVersion, String start, String end, int mode) { super(miVersion, "-data-disassemble"); //$NON-NLS-1$ setOptions(new String[]{"-s", start, "-e", end}); //$NON-NLS-1$ //$NON-NLS-2$ - String mixed = "0"; //$NON-NLS-1$ - if (mode) { - mixed = "1"; //$NON-NLS-1$ - } - setParameters(new String[]{mixed}); + + if (mode >= MIN_MODE && mode <= MAX_MODE) { + setParameters(new String[] { Integer.toString(mode) }); + } else { + throw new IllegalArgumentException(MODE_OUT_OF_RANGE + mode); + } } public MIDataDisassemble(String miVersion, String file, int linenum, int lines, boolean mode) { + this(miVersion, file, linenum, lines, mode ? 1 : 0); + } + + /** @since 7.2 */ + public MIDataDisassemble(String miVersion, String file, int linenum, int lines, int mode) { super(miVersion, "-data-disassemble"); //$NON-NLS-1$ setOptions(new String[]{"-f", file, "-l", //$NON-NLS-1$ //$NON-NLS-2$ Integer.toString(linenum), "-n", Integer.toString(lines)}); //$NON-NLS-1$ - String mixed = "0"; //$NON-NLS-1$ - if (mode) { - mixed = "1"; //$NON-NLS-1$ - } - setParameters(new String[]{mixed}); + + if (mode >= MIN_MODE && mode <= MAX_MODE) { + setParameters(new String[] { Integer.toString(mode) }); + } else { + throw new IllegalArgumentException(MODE_OUT_OF_RANGE + mode); + } } public MIDataDisassembleInfo getMIDataDisassembleInfo() throws MIException { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java index cc7d731c265..64d5612ff6b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java @@ -14,6 +14,7 @@ * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306) * Abeer Bagul - Support for -exec-arguments (bug 337687) + * Marc Khouzam (Ericsson) - New methods for new MIDataDisassemble (Bug 357073) *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command; @@ -347,10 +348,20 @@ public class CommandFactory { return new MIDataDisassemble(ctx, start, end, mode); } + /** @since 4.1 */ + public ICommand createMIDataDisassemble(IDisassemblyDMContext ctx, String start, String end, int mode) { + return new MIDataDisassemble(ctx, start, end, mode); + } + public ICommand createMIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, boolean mode) { return new MIDataDisassemble(ctx, file, linenum, lines, mode); } + /** @since 4.1 */ + public ICommand createMIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, int mode) { + return new MIDataDisassemble(ctx, file, linenum, lines, mode); + } + public ICommand createMIDataEvaluateExpression(ICommandControlDMContext ctx, String expr) { return new MIDataEvaluateExpression(ctx, expr); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataDisassemble.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataDisassemble.java index 7dd40aa7307..e8ad471a1b7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataDisassemble.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIDataDisassemble.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2011 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Ericsson - Modified for DSF Reference Implementation + * Daniel Thomas (Broadcom corp.) - Added support for mode 2 and 3 (Bug 357073) *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.commands; @@ -46,35 +47,54 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; * END-ADDR, only the lines up to END-ADDR are displayed. * * '-- MODE' - * is either 0 (meaning only disassembly) or 1 (meaning mixed source - * and disassembly). + * - 0 disassembly + * - 1 mixed source and disassembly + * - 2 disassembly with raw opcodes + * - 3 mixed source and disassembly with raw opcodes + * Note: Modes 2 and 3 are only available starting with GDB 7.3 */ public class MIDataDisassemble extends MICommand { - public MIDataDisassemble(IDisassemblyDMContext ctx, String start, String end, boolean mode) { - super(ctx, "-data-disassemble"); //$NON-NLS-1$ + private static final int MIN_MODE = 0; + private static final int MAX_MODE = 3; + private static final String MODE_OUT_OF_RANGE = "Mode out of range: "; //$NON-NLS-1$ + + public MIDataDisassemble(IDisassemblyDMContext ctx, String start, String end, boolean mode) { + this(ctx, start, end, mode ? 1 : 0); + } + + /** @since 4.1 */ + public MIDataDisassemble(IDisassemblyDMContext ctx, String start, String end, int mode) { + super(ctx, "-data-disassemble"); //$NON-NLS-1$ setOptions(new String[]{"-s", start, "-e", end}); //$NON-NLS-1$ //$NON-NLS-2$ - String mixed = "0"; //$NON-NLS-1$ - if (mode) { - mixed = "1"; //$NON-NLS-1$ + + if (mode >= MIN_MODE && mode <= MAX_MODE) { + setParameters(new String[] { Integer.toString(mode) }); + } else { + throw new IllegalArgumentException(MODE_OUT_OF_RANGE + mode); } - setParameters(new String[]{mixed}); - } + } public MIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, boolean mode) { + this(ctx, file, linenum, lines, mode ? 1 : 0); + } + + /** @since 4.1 */ + public MIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, int mode) { super(ctx, "-data-disassemble"); //$NON-NLS-1$ setOptions(new String[]{"-f", file, "-l", //$NON-NLS-1$ //$NON-NLS-2$ Integer.toString(linenum), "-n", Integer.toString(lines)}); //$NON-NLS-1$ - String mixed = "0"; //$NON-NLS-1$ - if (mode) { - mixed = "1"; //$NON-NLS-1$ + + if (mode >= MIN_MODE && mode <= MAX_MODE) { + setParameters(new String[] { Integer.toString(mode) }); + } else { + throw new IllegalArgumentException(MODE_OUT_OF_RANGE + mode); } - setParameters(new String[]{mixed}); } /* - * GDB the -data-disassemble uses "--" as a separator wit only the MODE + * -data-disassemble uses "--" as a separator with only the MODE * So override the MICommand */ @Override From 7065e4648d6f0ac0621540841207da1f1136ce7f Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 12 Sep 2011 16:11:54 -0700 Subject: [PATCH 4/5] Bug 357423 - Code formatter gets confused by a macro. --- .../formatter/CodeFormatterVisitor.java | 72 ++++++++++++------- .../cdt/ui/tests/text/CodeFormatterTest.java | 31 ++++++++ 2 files changed, 77 insertions(+), 26 deletions(-) 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 e93c0e53547..a5299967ae1 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 @@ -3460,29 +3460,43 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, private int visit(IASTSwitchStatement node) { final int headerIndent= scribe.numberOfIndentations; - scribe.printNextToken(Token.t_switch); - scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_switch); - - if (preferences.insert_space_after_opening_paren_in_switch) { - scribe.space(); + /* + * 'switch' keyword + */ + if (!startsWithMacroExpansion(node)) { + scribe.printNextToken(Token.t_switch); + } + /* + * Controller expression + */ + IASTExpression controllerExpression = node.getControllerExpression(); + if (!enclosedInMacroExpansion(controllerExpression)) { + scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_switch); + if (preferences.insert_space_after_opening_paren_in_switch) { + scribe.space(); + } + } + controllerExpression.accept(this); + if (!enclosedInMacroExpansion(controllerExpression)) { + scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_switch); } - - node.getControllerExpression().accept(this); - scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_switch); /* * switch body */ - String switch_brace = preferences.brace_position_for_switch; - formatOpeningBrace(switch_brace, preferences.insert_space_before_opening_brace_in_switch); - scribe.startNewLine(); - final int braceIndent= scribe.numberOfIndentations; - if (braceIndent > headerIndent) { - scribe.unIndent(); - } - if (preferences.indent_switchstatements_compare_to_switch) { - scribe.indent(); - } + String brace_position = preferences.brace_position_for_switch; + int braceIndent = -1; IASTStatement bodyStmt= node.getBody(); + if (!startsWithMacroExpansion(bodyStmt)) { + formatOpeningBrace(brace_position, preferences.insert_space_before_opening_brace_in_switch); + scribe.startNewLine(); + braceIndent= scribe.numberOfIndentations; + if (braceIndent > headerIndent) { + scribe.unIndent(); + } + if (preferences.indent_switchstatements_compare_to_switch) { + scribe.indent(); + } + } final List statements; if (bodyStmt instanceof IASTCompoundStatement) { statements= Arrays.asList(((IASTCompoundStatement) bodyStmt).getStatements()); @@ -3497,6 +3511,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, boolean wasAStatement = false; for (int i = 0; i < statementsLength; i++) { final IASTStatement statement = statements.get(i); + if (doNodeLocationsOverlap(controllerExpression, statement)) { + statement.accept(this); + continue; + } if (statement instanceof IASTCaseStatement || statement instanceof IASTDefaultStatement) { if (wasACase) { scribe.startNewLine(); @@ -3598,15 +3616,17 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - if (preferences.indent_switchstatements_compare_to_switch) { - scribe.unIndent(); + if (!startsWithMacroExpansion(bodyStmt)) { + if (preferences.indent_switchstatements_compare_to_switch) { + scribe.unIndent(); + } + if (scribe.numberOfIndentations < braceIndent) { + scribe.indent(); + } + scribe.startNewLine(); + + formatClosingBrace(brace_position); } - if (scribe.numberOfIndentations < braceIndent) { - scribe.indent(); - } - scribe.startNewLine(); - - formatClosingBrace(switch_brace); } finally { endOfNode(bodyStmt); } 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 12f57841fc3..98bae6602eb 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 @@ -2369,6 +2369,37 @@ public class CodeFormatterTest extends BaseUITestCase { assertFormatterResult(); } + //struct Stream { + //Stream& operator <<(const char*); + //}; + //Stream GetStream(); + // + //#define MY_MACRO switch (0) case 0: default: GetStream() + // + //void test() { + //MY_MACRO << "Loooooooooooooooooooong string literal" << " another literal."; + //MY_MACRO << "Looooooooooooooooooooong string literal" << " another literal."; + //} + + //struct Stream { + // Stream& operator <<(const char*); + //}; + //Stream GetStream(); + // + //#define MY_MACRO switch (0) case 0: default: GetStream() + // + //void test() { + // MY_MACRO << "Loooooooooooooooooooong string literal" << " another literal."; + // MY_MACRO << "Looooooooooooooooooooong string literal" + // << " another literal."; + //} + public void testOverloadedLeftShiftChain_5() throws Exception { + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE); + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_OVERLOADED_LEFT_SHIFT_CHAIN, + Integer.toString(Alignment.M_COMPACT_SPLIT | Alignment.M_INDENT_ON_COLUMN)); + assertFormatterResult(); + } + //int main() { // std::vector> test; // // some comment From d6e2e3bbf679e3c6611872e9ba420cf294bb4be0 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 12 Sep 2011 18:13:00 -0700 Subject: [PATCH 5/5] Cosmetics. --- .../cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java index 049400e3d8f..4cd34574581 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java @@ -59,7 +59,7 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery { if (searchName != null) { label= searchName.toString(); IBinding binding= searchName.resolveBinding(); - if (binding instanceof IProblemBinding == false) { + if (!(binding instanceof IProblemBinding)) { if (binding != null) { IScope scope= null; try {