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:
commit
74a30a506e
16 changed files with 226 additions and 182 deletions
|
@ -3460,29 +3460,43 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
|
|
||||||
private int visit(IASTSwitchStatement node) {
|
private int visit(IASTSwitchStatement node) {
|
||||||
final int headerIndent= scribe.numberOfIndentations;
|
final int headerIndent= scribe.numberOfIndentations;
|
||||||
scribe.printNextToken(Token.t_switch);
|
/*
|
||||||
scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_switch);
|
* 'switch' keyword
|
||||||
|
*/
|
||||||
if (preferences.insert_space_after_opening_paren_in_switch) {
|
if (!startsWithMacroExpansion(node)) {
|
||||||
scribe.space();
|
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
|
* switch body
|
||||||
*/
|
*/
|
||||||
String switch_brace = preferences.brace_position_for_switch;
|
String brace_position = preferences.brace_position_for_switch;
|
||||||
formatOpeningBrace(switch_brace, preferences.insert_space_before_opening_brace_in_switch);
|
int braceIndent = -1;
|
||||||
scribe.startNewLine();
|
|
||||||
final int braceIndent= scribe.numberOfIndentations;
|
|
||||||
if (braceIndent > headerIndent) {
|
|
||||||
scribe.unIndent();
|
|
||||||
}
|
|
||||||
if (preferences.indent_switchstatements_compare_to_switch) {
|
|
||||||
scribe.indent();
|
|
||||||
}
|
|
||||||
IASTStatement bodyStmt= node.getBody();
|
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;
|
final List<IASTStatement> statements;
|
||||||
if (bodyStmt instanceof IASTCompoundStatement) {
|
if (bodyStmt instanceof IASTCompoundStatement) {
|
||||||
statements= Arrays.asList(((IASTCompoundStatement) bodyStmt).getStatements());
|
statements= Arrays.asList(((IASTCompoundStatement) bodyStmt).getStatements());
|
||||||
|
@ -3497,6 +3511,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
boolean wasAStatement = false;
|
boolean wasAStatement = false;
|
||||||
for (int i = 0; i < statementsLength; i++) {
|
for (int i = 0; i < statementsLength; i++) {
|
||||||
final IASTStatement statement = statements.get(i);
|
final IASTStatement statement = statements.get(i);
|
||||||
|
if (doNodeLocationsOverlap(controllerExpression, statement)) {
|
||||||
|
statement.accept(this);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (statement instanceof IASTCaseStatement || statement instanceof IASTDefaultStatement) {
|
if (statement instanceof IASTCaseStatement || statement instanceof IASTDefaultStatement) {
|
||||||
if (wasACase) {
|
if (wasACase) {
|
||||||
scribe.startNewLine();
|
scribe.startNewLine();
|
||||||
|
@ -3598,15 +3616,17 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.indent_switchstatements_compare_to_switch) {
|
if (!startsWithMacroExpansion(bodyStmt)) {
|
||||||
scribe.unIndent();
|
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 {
|
} finally {
|
||||||
endOfNode(bodyStmt);
|
endOfNode(bodyStmt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2369,6 +2369,37 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
assertFormatterResult();
|
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() {
|
//int main() {
|
||||||
// std::vector<std::vector<int>> test;
|
// std::vector<std::vector<int>> test;
|
||||||
// // some comment
|
// // some comment
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.browser.opentype;
|
package org.eclipse.cdt.internal.ui.browser.opentype;
|
||||||
|
|
||||||
import java.util.Arrays;
|
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.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
*/
|
*/
|
||||||
public class ElementSelectionDialog extends TypeSelectionDialog {
|
public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job to update the element list in the background.
|
* Job to update the element list in the background.
|
||||||
*/
|
*/
|
||||||
private class UpdateElementsJob extends Job {
|
private class UpdateElementsJob extends Job {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last used prefix to query the index. <code>null</code> means
|
* The last used prefix to query the index. <code>null</code> means
|
||||||
* the query result should be empty.
|
* the query result should be empty.
|
||||||
|
@ -111,14 +108,12 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
}
|
}
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A job listener for simple job status reporting.
|
* A job listener for simple job status reporting.
|
||||||
*/
|
*/
|
||||||
private final class UpdateJobListener extends JobChangeAdapter {
|
private final class UpdateJobListener extends JobChangeAdapter {
|
||||||
|
|
||||||
boolean fDone;
|
boolean fDone;
|
||||||
private IProgressMonitor fMonitor;
|
private IProgressMonitor fMonitor;
|
||||||
|
|
||||||
|
@ -183,7 +178,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
fUpdateJob= new UpdateElementsJob(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_name);
|
fUpdateJob= new UpdateElementsJob(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_name);
|
||||||
fUpdateJob.setRule(SINGLE_INSTANCE_RULE);
|
fUpdateJob.setRule(SINGLE_INSTANCE_RULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#create()
|
* @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
|
// the low-level filter is useless for us
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createDialogArea(org.eclipse.swt.widgets.Composite)
|
* @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||||
*/
|
*/
|
||||||
|
@ -261,7 +256,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
createProgressMonitorPart(parent);
|
createProgressMonitorPart(parent);
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the control for progress reporting.
|
* Create the control for progress reporting.
|
||||||
* @param parent
|
* @param parent
|
||||||
|
@ -290,7 +285,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
HashSet<IndexTypeInfo> types = new HashSet<IndexTypeInfo>();
|
HashSet<IndexTypeInfo> types = new HashSet<IndexTypeInfo>();
|
||||||
if(prefix != null) {
|
if (prefix != null) {
|
||||||
final IndexFilter filter= new IndexFilter() {
|
final IndexFilter filter= new IndexFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptBinding(IBinding binding) throws CoreException {
|
public boolean acceptBinding(IBinding binding) throws CoreException {
|
||||||
|
@ -305,7 +300,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
|
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()) {
|
if (i % 0x1000 == 0 && monitor.isCanceled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -315,7 +310,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
|
|
||||||
if (isVisibleType(ICElement.C_MACRO)) {
|
if (isVisibleType(ICElement.C_MACRO)) {
|
||||||
IIndexMacro[] macros= index.findMacrosForPrefix(prefix, IndexFilter.ALL_DECLARED, monitor);
|
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()) {
|
if (i % 0x1000 == 0 && monitor.isCanceled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -326,20 +321,20 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.log(ce);
|
CUIPlugin.log(e);
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException e) {
|
||||||
CUIPlugin.log(ie);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return types.toArray(new ITypeInfo[types.size()]);
|
return types.toArray(new ITypeInfo[types.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void setListElements(Object[] elements) {
|
protected final void setListElements(Object[] elements) {
|
||||||
super.setListElements(elements);
|
super.setListElements(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Unsupported
|
* @deprecated Unsupported
|
||||||
*/
|
*/
|
||||||
|
@ -348,12 +343,12 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
public void setElements(Object[] elements) {
|
public void setElements(Object[] elements) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleEmptyList() {
|
protected void handleEmptyList() {
|
||||||
updateOkState();
|
updateOkState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Text createFilterText(Composite parent) {
|
protected Text createFilterText(Composite parent) {
|
||||||
final Text result = super.createFilterText(parent);
|
final Text result = super.createFilterText(parent);
|
||||||
|
@ -377,7 +372,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
newPrefix= null;
|
newPrefix= null;
|
||||||
needQuery= needQuery || currentPrefix != null;
|
needQuery= needQuery || currentPrefix != null;
|
||||||
}
|
}
|
||||||
if(needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) {
|
if (needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) {
|
||||||
fUpdateJob.cancel();
|
fUpdateJob.cancel();
|
||||||
fUpdateJob.scheduleQuery(newPrefix);
|
fUpdateJob.scheduleQuery(newPrefix);
|
||||||
}
|
}
|
||||||
|
@ -393,11 +388,11 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
}
|
}
|
||||||
int asterisk= userFilter.indexOf("*"); //$NON-NLS-1$
|
int asterisk= userFilter.indexOf("*"); //$NON-NLS-1$
|
||||||
int questionMark= userFilter.indexOf("?"); //$NON-NLS-1$
|
int questionMark= userFilter.indexOf("?"); //$NON-NLS-1$
|
||||||
int prefixEnd = asterisk < 0 ? questionMark
|
int prefixEnd = asterisk < 0 ? questionMark :
|
||||||
: (questionMark < 0 ? asterisk : Math.min(asterisk, questionMark));
|
questionMark < 0 ? asterisk : Math.min(asterisk, questionMark);
|
||||||
return (prefixEnd==-1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray();
|
return (prefixEnd == -1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) {
|
private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) {
|
||||||
if (currentPrefix == null || currentPrefix.length > newPrefix.length) {
|
if (currentPrefix == null || currentPrefix.length > newPrefix.length) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -406,5 +401,4 @@ public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||||
}
|
}
|
||||||
return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length));
|
return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.StringMatcher;
|
import org.eclipse.cdt.internal.ui.util.StringMatcher;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dialog to select a type from a list of types.
|
* 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) {
|
public void setVisibleTypes(int[] types) {
|
||||||
fKnownTypes.clear();
|
fKnownTypes.clear();
|
||||||
for (int i = 0; i < types.length; ++i) {
|
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.
|
* Answer whether the given type is visible in the dialog.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type the type constant, see {@link ICElement}
|
||||||
* the type constant, see {@link ICElement}
|
|
||||||
* @return <code>true</code> if the given type is visible,
|
* @return <code>true</code> if the given type is visible,
|
||||||
* <code>false</code> otherwise
|
* <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
protected boolean isVisibleType(int type) {
|
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;
|
upperLayout.marginWidth = 0;
|
||||||
upperRow.setLayout(upperLayout);
|
upperRow.setLayout(upperLayout);
|
||||||
|
|
||||||
// the for loop is here to guarantee we always
|
// The 'for' loop is here to guarantee that we always create the checkboxes in the same order.
|
||||||
// create the checkboxes in the same order
|
|
||||||
for (int i = 0; i < ALL_TYPES.length; ++i) {
|
for (int i = 0; i < ALL_TYPES.length; ++i) {
|
||||||
Integer typeObject = new Integer(ALL_TYPES[i]);
|
Integer typeObject = new Integer(ALL_TYPES[i]);
|
||||||
if (fKnownTypes.contains(typeObject))
|
if (fKnownTypes.contains(typeObject))
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery {
|
||||||
if (searchName != null) {
|
if (searchName != null) {
|
||||||
label= searchName.toString();
|
label= searchName.toString();
|
||||||
IBinding binding= searchName.resolveBinding();
|
IBinding binding= searchName.resolveBinding();
|
||||||
if (binding instanceof IProblemBinding == false) {
|
if (!(binding instanceof IProblemBinding)) {
|
||||||
if (binding != null) {
|
if (binding != null) {
|
||||||
IScope scope= null;
|
IScope scope= null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
public class NamespaceSelectionDialog extends TypeSelectionDialog {
|
public class NamespaceSelectionDialog extends TypeSelectionDialog {
|
||||||
|
|
||||||
private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName();
|
private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName();
|
||||||
private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE };
|
private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE };
|
||||||
|
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.wizards.classwizard;
|
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.browser.ITypeInfo;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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.internal.ui.dialogs.StatusInfo;
|
||||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
import org.eclipse.osgi.util.NLS;
|
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.PlatformUI;
|
||||||
import org.eclipse.ui.progress.IProgressService;
|
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 String DIALOG_SETTINGS = NewBaseClassSelectionDialog.class.getName();
|
||||||
private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
|
private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
|
||||||
private static final int ADD_ID = IDialogConstants.CLIENT_ID + 1;
|
private static final int ADD_ID = IDialogConstants.CLIENT_ID + 1;
|
||||||
private List<ITypeInfo> fTypeList;
|
private List<ITypeInfo> fTypeList;
|
||||||
private List<ITypeSelectionListener> fTypeListeners;
|
private List<ITypeSelectionListener> fTypeListeners;
|
||||||
|
|
||||||
public interface ITypeSelectionListener {
|
public interface ITypeSelectionListener {
|
||||||
void typeAdded(ITypeInfo baseClass);
|
void typeAdded(ITypeInfo baseClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewBaseClassSelectionDialog(Shell parent) {
|
public NewBaseClassSelectionDialog(Shell parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
setTitle(NewClassWizardMessages.NewBaseClassSelectionDialog_title);
|
setTitle(NewClassWizardMessages.NewBaseClassSelectionDialog_title);
|
||||||
setMessage(NewClassWizardMessages.NewBaseClassSelectionDialog_message);
|
setMessage(NewClassWizardMessages.NewBaseClassSelectionDialog_message);
|
||||||
setDialogSettings(DIALOG_SETTINGS);
|
setDialogSettings(DIALOG_SETTINGS);
|
||||||
setVisibleTypes(VISIBLE_TYPES);
|
setVisibleTypes(VISIBLE_TYPES);
|
||||||
setFilter("*", true); //$NON-NLS-1$
|
|
||||||
setStatusLineAboveButtons(true);
|
setStatusLineAboveButtons(true);
|
||||||
fTypeList = new ArrayList<ITypeInfo>();
|
fTypeList = new ArrayList<ITypeInfo>();
|
||||||
fTypeListeners = new ArrayList<ITypeSelectionListener>();
|
fTypeListeners = new ArrayList<ITypeSelectionListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(ITypeSelectionListener listener) {
|
public void addListener(ITypeSelectionListener listener) {
|
||||||
if (!fTypeListeners.contains(listener))
|
if (!fTypeListeners.contains(listener))
|
||||||
fTypeListeners.add(listener);
|
fTypeListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener(ITypeSelectionListener listener) {
|
public void removeListener(ITypeSelectionListener listener) {
|
||||||
fTypeListeners.remove(listener);
|
fTypeListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyTypeAddedListeners(ITypeInfo type) {
|
private void notifyTypeAddedListeners(ITypeInfo type) {
|
||||||
// first copy listeners in case one calls removeListener
|
// first copy listeners in case one calls removeListener
|
||||||
List<ITypeSelectionListener> list = new ArrayList<ITypeSelectionListener>(fTypeListeners);
|
List<ITypeSelectionListener> list = new ArrayList<ITypeSelectionListener>(fTypeListeners);
|
||||||
|
@ -67,7 +67,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
|
||||||
listener.typeAdded(type);
|
listener.typeAdded(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITypeInfo[] getAddedTypes() {
|
public ITypeInfo[] getAddedTypes() {
|
||||||
return fTypeList.toArray(new ITypeInfo[fTypeList.size()]);
|
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);
|
createButton(parent, ADD_ID, NewClassWizardMessages.NewBaseClassSelectionDialog_addButton_label, true);
|
||||||
super.createButtonsForButtonBar(parent);
|
super.createButtonsForButtonBar(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see Dialog#buttonPressed
|
* @see Dialog#buttonPressed
|
||||||
*/
|
*/
|
||||||
|
@ -91,7 +91,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
|
||||||
}
|
}
|
||||||
super.buttonPressed(buttonId);
|
super.buttonPressed(buttonId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see Dialog#okPressed
|
* @see Dialog#okPressed
|
||||||
*/
|
*/
|
||||||
|
@ -100,7 +100,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
|
||||||
addType(getLowerSelectedElement());
|
addType(getLowerSelectedElement());
|
||||||
super.okPressed();
|
super.okPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addType(Object elem) {
|
private void addType(Object elem) {
|
||||||
if (elem instanceof ITypeInfo) {
|
if (elem instanceof ITypeInfo) {
|
||||||
ITypeInfo type = (ITypeInfo)elem;
|
ITypeInfo type = (ITypeInfo)elem;
|
||||||
|
@ -119,8 +119,8 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
|
||||||
NewClassWizardUtil.resolveClassLocation(type, service);
|
NewClassWizardUtil.resolveClassLocation(type, service);
|
||||||
canAdd = (type.getResolvedReference() != null);
|
canAdd = (type.getResolvedReference() != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // resolve location of base class
|
// // Resolve location of base class
|
||||||
// if (type.getResolvedReference() == null) {
|
// if (type.getResolvedReference() == null) {
|
||||||
// final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
|
// final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
|
||||||
// IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
// IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||||
|
@ -131,7 +131,7 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// IProgressService service = PlatformUI.getWorkbench().getProgressService();
|
// IProgressService service = PlatformUI.getWorkbench().getProgressService();
|
||||||
// try {
|
// try {
|
||||||
// service.busyCursorWhile(runnable);
|
// service.busyCursorWhile(runnable);
|
||||||
|
@ -140,13 +140,13 @@ public class NewBaseClassSelectionDialog extends TypeSelectionDialog {
|
||||||
// String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$
|
// String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$
|
||||||
// ExceptionHandler.handle(e, title, errorMessage);
|
// ExceptionHandler.handle(e, title, errorMessage);
|
||||||
// } catch (InterruptedException e) {
|
// } catch (InterruptedException e) {
|
||||||
// // cancelled by user
|
// // Cancelled by user
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (canAdd) {
|
if (canAdd) {
|
||||||
fTypeList.add(type);
|
fTypeList.add(type);
|
||||||
|
|
||||||
message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classadded_info, qualifiedName);
|
message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classadded_info, qualifiedName);
|
||||||
updateStatus(new StatusInfo(IStatus.INFO, message));
|
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
|
* @return <code>true</code> if the base classes should be verified
|
||||||
*/
|
*/
|
||||||
public boolean verifyBaseClasses() {
|
public boolean verifyBaseClasses() {
|
||||||
return NewClassWizardPrefs.verifyBaseClasses();
|
return NewClassWizardPrefs.verifyBaseClasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see AbstractElementListSelectionDialog#handleDefaultSelected()
|
* @see AbstractElementListSelectionDialog#handleDefaultSelected()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,8 +17,6 @@ public final class NewClassWizardMessages extends NLS {
|
||||||
public static String NewClassCreationWizard_title;
|
public static String NewClassCreationWizard_title;
|
||||||
public static String NewClassCreationWizardPage_title;
|
public static String NewClassCreationWizardPage_title;
|
||||||
public static String NewClassCreationWizardPage_description;
|
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_title;
|
||||||
public static String NewClassCreationWizardPage_getTypes_noNamespaces_message;
|
public static String NewClassCreationWizardPage_getTypes_noNamespaces_message;
|
||||||
public static String NewClassCreationWizardPage_sourceFolder_label;
|
public static String NewClassCreationWizardPage_sourceFolder_label;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#
|
#
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# QNX Software Systems - Initial API and implementation
|
# QNX Software Systems - Initial API and implementation
|
||||||
# IBM Corporation
|
# IBM Corporation
|
||||||
# Anton Leherbauer (Wind River Systems)
|
# Anton Leherbauer (Wind River Systems)
|
||||||
# Sergey Prigogin (Google)
|
# Sergey Prigogin (Google)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -19,8 +19,6 @@ NewClassCreationWizard_title=New C++ Class
|
||||||
NewClassCreationWizardPage_title=C++ Class
|
NewClassCreationWizardPage_title=C++ Class
|
||||||
NewClassCreationWizardPage_description=Create a new 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_title=Namespace Selection
|
||||||
NewClassCreationWizardPage_getTypes_noNamespaces_message=No namespaces available.
|
NewClassCreationWizardPage_getTypes_noNamespaces_message=No namespaces available.
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.wizards.classwizard;
|
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.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
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.ui.views.contentoutline.ContentOutline;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.IQualifiedTypeName;
|
||||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||||
import org.eclipse.cdt.core.browser.ITypeReference;
|
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.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
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.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
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.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
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;
|
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||||
|
|
||||||
public class NewClassWizardUtil {
|
public class NewClassWizardUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parent source folder of the given element. If the given
|
* Returns the parent source folder of the given element. If the given
|
||||||
* element is already a source folder, the element itself is returned.
|
* element is already a source folder, the element itself is returned.
|
||||||
|
@ -276,41 +267,6 @@ public class NewClassWizardUtil {
|
||||||
return type.getResolvedReference();
|
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
|
* Checks whether the given type can be found in the given project or the
|
||||||
* given include paths.
|
* given include paths.
|
||||||
|
@ -402,7 +358,7 @@ public class NewClassWizardUtil {
|
||||||
boolean sameNameDifferentTypeExists = false;
|
boolean sameNameDifferentTypeExists = false;
|
||||||
|
|
||||||
for (int i = 0; i < bindings.length; ++i) {
|
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
|
//get the fully qualified name of this binding
|
||||||
String bindingFullName = renderQualifiedName(binding.getQualifiedName());
|
String bindingFullName = renderQualifiedName(binding.getQualifiedName());
|
||||||
|
@ -424,8 +380,7 @@ public class NewClassWizardUtil {
|
||||||
IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration
|
IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration
|
||||||
ICPPNamespace.class.isAssignableFrom(currentNodeType) ||
|
ICPPNamespace.class.isAssignableFrom(currentNodeType) ||
|
||||||
ITypedef.class.isAssignableFrom(currentNodeType) ||
|
ITypedef.class.isAssignableFrom(currentNodeType) ||
|
||||||
ICPPBasicType.class.isAssignableFrom(currentNodeType))
|
ICPPBasicType.class.isAssignableFrom(currentNodeType)) {
|
||||||
{
|
|
||||||
if (bindingFullName.equals(fullyQualifiedTypeName)) {
|
if (bindingFullName.equals(fullyQualifiedTypeName)) {
|
||||||
return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
|
return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -446,8 +401,7 @@ public class NewClassWizardUtil {
|
||||||
return SEARCH_MATCH_ERROR;
|
return SEARCH_MATCH_ERROR;
|
||||||
}
|
}
|
||||||
return SEARCH_MATCH_NOTFOUND;
|
return SEARCH_MATCH_NOTFOUND;
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1178,14 +1178,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseBaseClasses() {
|
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();
|
List<IBaseClassInfo> oldContents = fBaseClassesDialogField.getElements();
|
||||||
NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell());
|
NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell());
|
||||||
dialog.addListener(new ITypeSelectionListener() {
|
dialog.addListener(new ITypeSelectionListener() {
|
||||||
|
@ -1193,16 +1185,15 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false);
|
addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.setElements(elements);
|
|
||||||
int result = dialog.open();
|
int result = dialog.open();
|
||||||
if (result != IDialogConstants.OK_ID) {
|
if (result != IDialogConstants.OK_ID) {
|
||||||
// restore the old contents
|
// Restore the old contents
|
||||||
fBaseClassesDialogField.setElements(oldContents);
|
fBaseClassesDialogField.setElements(oldContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handles changes to the method stubs field
|
* Handles changes to the method stubs field
|
||||||
*/
|
*/
|
||||||
private final class MethodStubsFieldAdapter implements IListAdapter<IMethodStub> {
|
private final class MethodStubsFieldAdapter implements IListAdapter<IMethodStub> {
|
||||||
|
|
||||||
|
@ -1667,7 +1658,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
|
|
||||||
ICProject project = getCurrentProject();
|
ICProject project = getCurrentProject();
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
|
|
||||||
IQualifiedTypeName fullyQualifiedName = typeName;
|
IQualifiedTypeName fullyQualifiedName = typeName;
|
||||||
if (isNamespaceSelected()) {
|
if (isNamespaceSelected()) {
|
||||||
String namespace = getNamespaceText();
|
String namespace = getNamespaceText();
|
||||||
|
@ -1745,7 +1735,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
||||||
ITypeInfo baseType = baseClass.getType();
|
ITypeInfo baseType = baseClass.getType();
|
||||||
StatusInfo baseClassStatus = new StatusInfo();
|
StatusInfo baseClassStatus = new StatusInfo();
|
||||||
if (!NewClassWizardUtil.isTypeReachable(baseType, project, includePaths)) {
|
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);
|
status.add(baseClassStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.debug.mi.core; singleton:=true
|
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-Activator: org.eclipse.cdt.debug.mi.core.MIPlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* ENEA Software AB - CLI command extension - fix for bug 190277
|
* 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;
|
package org.eclipse.cdt.debug.mi.core.command;
|
||||||
|
@ -88,10 +89,20 @@ public class CommandFactory {
|
||||||
return new MIDataDisassemble(getMIVersion(), start, end, mixed);
|
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) {
|
public MIDataDisassemble createMIDataDisassemble(String file, int linenum, int lines, boolean mixed) {
|
||||||
return new MIDataDisassemble(getMIVersion(), file, linenum, lines, 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) {
|
public MIDataEvaluateExpression createMIDataEvaluateExpression(String expression) {
|
||||||
return new MIDataEvaluateExpression(getMIVersion(), expression);
|
return new MIDataEvaluateExpression(getMIVersion(), expression);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* 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;
|
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.
|
* END-ADDR, only the lines up to END-ADDR are displayed.
|
||||||
*
|
*
|
||||||
*`MODE'
|
*`MODE'
|
||||||
* is either 0 (meaning only disassembly) or 1 (meaning mixed source
|
* - 0 disassembly
|
||||||
* and 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
|
*Result
|
||||||
*......
|
*......
|
||||||
|
@ -64,32 +68,48 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
* * Instruction
|
* * Instruction
|
||||||
*
|
*
|
||||||
* Note that whatever included in the instruction field, is not
|
* 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.
|
*format.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MIDataDisassemble extends MICommand
|
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) {
|
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$
|
super(miVersion, "-data-disassemble"); //$NON-NLS-1$
|
||||||
setOptions(new String[]{"-s", start, "-e", end}); //$NON-NLS-1$ //$NON-NLS-2$
|
setOptions(new String[]{"-s", start, "-e", end}); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
String mixed = "0"; //$NON-NLS-1$
|
|
||||||
if (mode) {
|
if (mode >= MIN_MODE && mode <= MAX_MODE) {
|
||||||
mixed = "1"; //$NON-NLS-1$
|
setParameters(new String[] { Integer.toString(mode) });
|
||||||
}
|
} else {
|
||||||
setParameters(new String[]{mixed});
|
throw new IllegalArgumentException(MODE_OUT_OF_RANGE + mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIDataDisassemble(String miVersion, String file, int linenum, int lines, boolean 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$
|
super(miVersion, "-data-disassemble"); //$NON-NLS-1$
|
||||||
setOptions(new String[]{"-f", file, "-l", //$NON-NLS-1$ //$NON-NLS-2$
|
setOptions(new String[]{"-f", file, "-l", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
Integer.toString(linenum), "-n", Integer.toString(lines)}); //$NON-NLS-1$
|
Integer.toString(linenum), "-n", Integer.toString(lines)}); //$NON-NLS-1$
|
||||||
String mixed = "0"; //$NON-NLS-1$
|
|
||||||
if (mode) {
|
if (mode >= MIN_MODE && mode <= MAX_MODE) {
|
||||||
mixed = "1"; //$NON-NLS-1$
|
setParameters(new String[] { Integer.toString(mode) });
|
||||||
}
|
} else {
|
||||||
setParameters(new String[]{mixed});
|
throw new IllegalArgumentException(MODE_OUT_OF_RANGE + mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MIDataDisassembleInfo getMIDataDisassembleInfo() throws MIException {
|
public MIDataDisassembleInfo getMIDataDisassembleInfo() throws MIException {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
|
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
|
||||||
* Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
|
* Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306)
|
||||||
* Abeer Bagul - Support for -exec-arguments (bug 337687)
|
* 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;
|
package org.eclipse.cdt.dsf.mi.service.command;
|
||||||
|
@ -347,10 +348,20 @@ public class CommandFactory {
|
||||||
return new MIDataDisassemble(ctx, start, end, mode);
|
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) {
|
public ICommand<MIDataDisassembleInfo> createMIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, boolean mode) {
|
||||||
return new MIDataDisassemble(ctx, file, linenum, lines, 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) {
|
public ICommand<MIDataEvaluateExpressionInfo> createMIDataEvaluateExpression(ICommandControlDMContext ctx, String expr) {
|
||||||
return new MIDataEvaluateExpression<MIDataEvaluateExpressionInfo>(ctx, expr);
|
return new MIDataEvaluateExpression<MIDataEvaluateExpressionInfo>(ctx, expr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Ericsson - Modified for DSF Reference 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;
|
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.
|
* END-ADDR, only the lines up to END-ADDR are displayed.
|
||||||
*
|
*
|
||||||
* '-- MODE'
|
* '-- MODE'
|
||||||
* is either 0 (meaning only disassembly) or 1 (meaning mixed source
|
* - 0 disassembly
|
||||||
* and 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 class MIDataDisassemble extends MICommand<MIDataDisassembleInfo> {
|
||||||
|
|
||||||
public MIDataDisassemble(IDisassemblyDMContext ctx, String start, String end, boolean mode) {
|
private static final int MIN_MODE = 0;
|
||||||
super(ctx, "-data-disassemble"); //$NON-NLS-1$
|
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$
|
setOptions(new String[]{"-s", start, "-e", end}); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
String mixed = "0"; //$NON-NLS-1$
|
|
||||||
if (mode) {
|
if (mode >= MIN_MODE && mode <= MAX_MODE) {
|
||||||
mixed = "1"; //$NON-NLS-1$
|
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) {
|
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$
|
super(ctx, "-data-disassemble"); //$NON-NLS-1$
|
||||||
setOptions(new String[]{"-f", file, "-l", //$NON-NLS-1$ //$NON-NLS-2$
|
setOptions(new String[]{"-f", file, "-l", //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
Integer.toString(linenum), "-n", Integer.toString(lines)}); //$NON-NLS-1$
|
Integer.toString(linenum), "-n", Integer.toString(lines)}); //$NON-NLS-1$
|
||||||
String mixed = "0"; //$NON-NLS-1$
|
|
||||||
if (mode) {
|
if (mode >= MIN_MODE && mode <= MAX_MODE) {
|
||||||
mixed = "1"; //$NON-NLS-1$
|
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
|
* So override the MICommand
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue