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

Merge remote branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2011-09-13 10:54:33 -04:00
commit 74a30a506e
16 changed files with 226 additions and 182 deletions

View file

@ -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<IASTStatement> 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);
}

View file

@ -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<std::vector<int>> test;
// // some comment

View file

@ -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. <code>null</code> 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<IndexTypeInfo> types = new HashSet<IndexTypeInfo>();
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<bindings.length; i++) {
for (int i= 0; i < bindings.length; i++) {
if (i % 0x1000 == 0 && monitor.isCanceled()) {
return null;
}
@ -315,7 +310,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
if (isVisibleType(ICElement.C_MACRO)) {
IIndexMacro[] macros= index.findMacrosForPrefix(prefix, IndexFilter.ALL_DECLARED, monitor);
for(int i=0; i<macros.length; i++) {
for (int i= 0; i < macros.length; i++) {
if (i % 0x1000 == 0 && monitor.isCanceled()) {
return null;
}
@ -326,20 +321,20 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
} finally {
index.releaseReadLock();
}
} catch(CoreException ce) {
CUIPlugin.log(ce);
} catch(InterruptedException ie) {
CUIPlugin.log(ie);
} catch (CoreException e) {
CUIPlugin.log(e);
} catch (InterruptedException e) {
CUIPlugin.log(e);
}
}
return types.toArray(new ITypeInfo[types.size()]);
}
@Override
protected final void setListElements(Object[] elements) {
super.setListElements(elements);
}
/**
* @deprecated Unsupported
*/
@ -348,12 +343,12 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
public void setElements(Object[] elements) {
throw new UnsupportedOperationException();
}
@Override
protected void handleEmptyList() {
updateOkState();
}
@Override
protected Text createFilterText(Composite parent) {
final Text result = super.createFilterText(parent);
@ -377,7 +372,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
newPrefix= null;
needQuery= needQuery || currentPrefix != null;
}
if(needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) {
if (needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) {
fUpdateJob.cancel();
fUpdateJob.scheduleQuery(newPrefix);
}
@ -393,11 +388,11 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
}
int asterisk= userFilter.indexOf("*"); //$NON-NLS-1$
int questionMark= userFilter.indexOf("?"); //$NON-NLS-1$
int prefixEnd = asterisk < 0 ? questionMark
: (questionMark < 0 ? asterisk : Math.min(asterisk, questionMark));
return (prefixEnd==-1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray();
int prefixEnd = asterisk < 0 ? questionMark :
questionMark < 0 ? asterisk : Math.min(asterisk, questionMark);
return (prefixEnd == -1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray();
}
private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) {
if (currentPrefix == null || currentPrefix.length > newPrefix.length) {
return false;
@ -406,5 +401,4 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
}
return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length));
}
}

View file

@ -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 <code>true</code> if the given type is visible,
* <code>false</code> 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))

View file

@ -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 {

View file

@ -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 };

View file

@ -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<ITypeInfo> fTypeList;
private List<ITypeSelectionListener> 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<ITypeInfo>();
fTypeListeners = new ArrayList<ITypeSelectionListener>();
}
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<ITypeSelectionListener> list = new ArrayList<ITypeSelectionListener>(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 <code>true</code> if the base classes should be verified
*/
public boolean verifyBaseClasses() {
return NewClassWizardPrefs.verifyBaseClasses();
}
/*
* @see AbstractElementListSelectionDialog#handleDefaultSelected()
*/

View file

@ -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;

View file

@ -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.

View file

@ -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<ITypeInfo> filteredTypes = new ArrayList<ITypeInfo>();
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();
}
}

View file

@ -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<IBaseClassInfo> 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<IMethodStub> {
@ -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);
}

View file

@ -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

View file

@ -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);
}

View file

@ -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 {

View file

@ -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<MIDataDisassembleInfo> createMIDataDisassemble(IDisassemblyDMContext ctx, String start, String end, int mode) {
return new MIDataDisassemble(ctx, start, end, mode);
}
public ICommand<MIDataDisassembleInfo> createMIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, boolean mode) {
return new MIDataDisassemble(ctx, file, linenum, lines, mode);
}
/** @since 4.1 */
public ICommand<MIDataDisassembleInfo> createMIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, int mode) {
return new MIDataDisassemble(ctx, file, linenum, lines, mode);
}
public ICommand<MIDataEvaluateExpressionInfo> createMIDataEvaluateExpression(ICommandControlDMContext ctx, String expr) {
return new MIDataEvaluateExpression<MIDataEvaluateExpressionInfo>(ctx, expr);
}

View file

@ -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<MIDataDisassembleInfo> {
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