mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Bug 547450 - Options default/delete/inline/definition
It's now possible to select among four options for the implementation of single method stub: delete, default, inline or definition. Change-Id: I9aac9c53a5a7143235d0f2f447b8d22fa2e2c839 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
parent
4332b0fbc7
commit
0c147ecb93
14 changed files with 176 additions and 66 deletions
|
@ -19,17 +19,37 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public abstract class AbstractMethodStub implements IMethodStub {
|
||||
protected String fName;
|
||||
protected String fDescription;
|
||||
protected ASTAccessVisibility fAccess;
|
||||
protected boolean fIsVirtual;
|
||||
protected boolean fIsInline;
|
||||
private String fName;
|
||||
private String fDescription;
|
||||
private ASTAccessVisibility fAccess;
|
||||
private boolean fIsVirtual;
|
||||
private EImplMethod fImplMethod;
|
||||
|
||||
public AbstractMethodStub(String name, ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
|
||||
public AbstractMethodStub(String name, ASTAccessVisibility access, boolean isVirtual, EImplMethod impl) {
|
||||
fName = name;
|
||||
fAccess = access;
|
||||
fIsVirtual = isVirtual;
|
||||
fIsInline = isInline;
|
||||
fImplMethod = impl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EImplMethod getImplMethod() {
|
||||
return fImplMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeleted() {
|
||||
return fImplMethod == EImplMethod.DELETED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return fImplMethod == EImplMethod.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDefinition() {
|
||||
return fImplMethod == EImplMethod.DEFINITION;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,12 +84,12 @@ public abstract class AbstractMethodStub implements IMethodStub {
|
|||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return fIsInline;
|
||||
return fImplMethod == EImplMethod.INLINE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInline(boolean isInline) {
|
||||
fIsInline = isInline;
|
||||
public void setImplMethod(EImplMethod method) {
|
||||
fImplMethod = method;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,7 +103,7 @@ public abstract class AbstractMethodStub implements IMethodStub {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canModifyInline() {
|
||||
public boolean canModifyImplementation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ public final class AssignOpMethodStub extends AbstractMethodStub {
|
|||
private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_assign_op_name;
|
||||
|
||||
public AssignOpMethodStub() {
|
||||
this(ASTAccessVisibility.PUBLIC, false);
|
||||
this(ASTAccessVisibility.PUBLIC, EImplMethod.DEFINITION);
|
||||
}
|
||||
|
||||
public AssignOpMethodStub(ASTAccessVisibility access, boolean isInline) {
|
||||
super(NAME, access, false, isInline);
|
||||
public AssignOpMethodStub(ASTAccessVisibility access, EImplMethod method) {
|
||||
super(NAME, access, false, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public final class AssignOpMethodStub extends AbstractMethodStub {
|
|||
buf.append("& operator=(const "); //$NON-NLS-1$
|
||||
buf.append(className);
|
||||
buf.append("& other)"); //$NON-NLS-1$
|
||||
if (fIsInline) {
|
||||
if (isInline()) {
|
||||
buf.append('{');
|
||||
buf.append(lineDelimiter);
|
||||
String body = CodeGeneration.getMethodBodyContent(tu, className, "operator=", null, lineDelimiter); //$NON-NLS-1$
|
||||
|
@ -46,6 +46,10 @@ public final class AssignOpMethodStub extends AbstractMethodStub {
|
|||
buf.append(lineDelimiter);
|
||||
}
|
||||
buf.append('}');
|
||||
} else if (isDefault()) {
|
||||
buf.append(" = default;"); //$NON-NLS-1$
|
||||
} else if (isDeleted()) {
|
||||
buf.append(" = delete;"); //$NON-NLS-1$
|
||||
} else {
|
||||
buf.append(";"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -55,7 +59,7 @@ public final class AssignOpMethodStub extends AbstractMethodStub {
|
|||
@Override
|
||||
public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
|
||||
String lineDelimiter) throws CoreException {
|
||||
if (fIsInline) {
|
||||
if (!hasDefinition()) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.cdt.internal.ui.wizards.classwizard;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.IMethodStub.EImplMethod;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
|
@ -26,6 +27,11 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
|
|||
private static final String ACCESS_PROTECTED = NewClassWizardMessages.BaseClassesLabelProvider_access_protected_label;
|
||||
private static final String ACCESS_PRIVATE = NewClassWizardMessages.BaseClassesLabelProvider_access_private_label;
|
||||
|
||||
private static final String IMPL_DEFINITION = NewClassWizardMessages.BaseClassesLabelProvider_impl_definition;
|
||||
private static final String IMPL_DEFAULT = NewClassWizardMessages.BaseClassesLabelProvider_impl_default;
|
||||
private static final String IMPL_DELETED = NewClassWizardMessages.BaseClassesLabelProvider_impl_deleted;
|
||||
private static final String IMPL_INLINE = NewClassWizardMessages.BaseClassesLabelProvider_impl_inline;
|
||||
|
||||
public static final String getYesNoText(boolean value) {
|
||||
return value ? YES_VALUE : NO_VALUE;
|
||||
}
|
||||
|
@ -38,6 +44,20 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
|
|||
return ACCESS_PUBLIC;
|
||||
}
|
||||
|
||||
public static final String getImplText(EImplMethod method) {
|
||||
switch (method) {
|
||||
case DELETED:
|
||||
return IMPL_DELETED;
|
||||
case DEFAULT:
|
||||
return IMPL_DEFAULT;
|
||||
case INLINE:
|
||||
return IMPL_INLINE;
|
||||
case DEFINITION:
|
||||
default:
|
||||
return IMPL_DEFINITION;
|
||||
}
|
||||
}
|
||||
|
||||
private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(
|
||||
TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ public final class ConstructorMethodStub extends AbstractMethodStub {
|
|||
private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_constructor_name;
|
||||
|
||||
public ConstructorMethodStub() {
|
||||
this(ASTAccessVisibility.PUBLIC, false);
|
||||
this(ASTAccessVisibility.PUBLIC, EImplMethod.DEFINITION);
|
||||
}
|
||||
|
||||
public ConstructorMethodStub(ASTAccessVisibility access, boolean isInline) {
|
||||
super(NAME, access, false, isInline);
|
||||
public ConstructorMethodStub(ASTAccessVisibility access, EImplMethod method) {
|
||||
super(NAME, access, false, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,7 +35,7 @@ public final class ConstructorMethodStub extends AbstractMethodStub {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(className);
|
||||
buf.append("()"); //$NON-NLS-1$
|
||||
if (fIsInline) {
|
||||
if (isInline()) {
|
||||
buf.append('{');
|
||||
buf.append(lineDelimiter);
|
||||
String body = CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
|
||||
|
@ -44,6 +44,10 @@ public final class ConstructorMethodStub extends AbstractMethodStub {
|
|||
buf.append(lineDelimiter);
|
||||
}
|
||||
buf.append('}');
|
||||
} else if (isDefault()) {
|
||||
buf.append(" = default;"); //$NON-NLS-1$
|
||||
} else if (isDeleted()) {
|
||||
buf.append(" = delete;"); //$NON-NLS-1$
|
||||
} else {
|
||||
buf.append(";"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -53,7 +57,7 @@ public final class ConstructorMethodStub extends AbstractMethodStub {
|
|||
@Override
|
||||
public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
|
||||
String lineDelimiter) throws CoreException {
|
||||
if (fIsInline) {
|
||||
if (!hasDefinition()) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -22,11 +22,11 @@ public final class CopyConstructorMethodStub extends AbstractMethodStub {
|
|||
private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_copy_constructor_name;
|
||||
|
||||
public CopyConstructorMethodStub() {
|
||||
this(ASTAccessVisibility.PUBLIC, false);
|
||||
this(ASTAccessVisibility.PUBLIC, EImplMethod.DEFINITION);
|
||||
}
|
||||
|
||||
public CopyConstructorMethodStub(ASTAccessVisibility access, boolean isInline) {
|
||||
super(NAME, access, false, isInline);
|
||||
public CopyConstructorMethodStub(ASTAccessVisibility access, EImplMethod method) {
|
||||
super(NAME, access, false, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public final class CopyConstructorMethodStub extends AbstractMethodStub {
|
|||
buf.append("(const "); //$NON-NLS-1$
|
||||
buf.append(className);
|
||||
buf.append("& other)"); //$NON-NLS-1$
|
||||
if (fIsInline) {
|
||||
if (isInline()) {
|
||||
buf.append('{');
|
||||
buf.append(lineDelimiter);
|
||||
String body = CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
|
||||
|
@ -46,6 +46,10 @@ public final class CopyConstructorMethodStub extends AbstractMethodStub {
|
|||
buf.append(lineDelimiter);
|
||||
}
|
||||
buf.append('}');
|
||||
} else if (isDefault()) {
|
||||
buf.append(" = default;"); //$NON-NLS-1$
|
||||
} else if (isDeleted()) {
|
||||
buf.append(" = delete;"); //$NON-NLS-1$
|
||||
} else {
|
||||
buf.append(";"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -55,7 +59,7 @@ public final class CopyConstructorMethodStub extends AbstractMethodStub {
|
|||
@Override
|
||||
public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
|
||||
String lineDelimiter) throws CoreException {
|
||||
if (fIsInline) {
|
||||
if (!hasDefinition()) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -24,24 +24,24 @@ public final class DestructorMethodStub extends AbstractMethodStub {
|
|||
private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_destructor_name;
|
||||
|
||||
public DestructorMethodStub() {
|
||||
this(ASTAccessVisibility.PUBLIC, true, false);
|
||||
this(ASTAccessVisibility.PUBLIC, true, EImplMethod.DEFINITION);
|
||||
}
|
||||
|
||||
public DestructorMethodStub(ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
|
||||
super(NAME, access, isVirtual, isInline);
|
||||
public DestructorMethodStub(ASTAccessVisibility access, boolean isVirtual, EImplMethod method) {
|
||||
super(NAME, access, isVirtual, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
|
||||
String lineDelimiter) throws CoreException {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (fIsVirtual) {
|
||||
if (isVirtual()) {
|
||||
buf.append("virtual "); //$NON-NLS-1$
|
||||
}
|
||||
buf.append("~"); //$NON-NLS-1$
|
||||
buf.append(className);
|
||||
buf.append("()"); //$NON-NLS-1$
|
||||
if (fIsInline) {
|
||||
if (isInline()) {
|
||||
buf.append('{');
|
||||
buf.append(lineDelimiter);
|
||||
String body = CodeGeneration.getDestructorBodyContent(tu, className, null, lineDelimiter);
|
||||
|
@ -50,6 +50,10 @@ public final class DestructorMethodStub extends AbstractMethodStub {
|
|||
buf.append(lineDelimiter);
|
||||
}
|
||||
buf.append('}');
|
||||
} else if (isDefault()) {
|
||||
buf.append(" = default;"); //$NON-NLS-1$
|
||||
} else if (isDeleted()) {
|
||||
buf.append(" = delete;"); //$NON-NLS-1$
|
||||
} else {
|
||||
buf.append(";"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -59,7 +63,7 @@ public final class DestructorMethodStub extends AbstractMethodStub {
|
|||
@Override
|
||||
public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
|
||||
String lineDelimiter) throws CoreException {
|
||||
if (fIsInline) {
|
||||
if (!hasDefinition()) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -19,6 +19,10 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public interface IMethodStub {
|
||||
public enum EImplMethod {
|
||||
DEFINITION, INLINE, DEFAULT, DELETED
|
||||
}
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getDescription();
|
||||
|
@ -35,11 +39,19 @@ public interface IMethodStub {
|
|||
|
||||
public void setVirtual(boolean isVirtual);
|
||||
|
||||
public EImplMethod getImplMethod();
|
||||
|
||||
public boolean isInline();
|
||||
|
||||
public boolean canModifyInline();
|
||||
public boolean isDeleted();
|
||||
|
||||
public void setInline(boolean isVirtual);
|
||||
public boolean isDefault();
|
||||
|
||||
public boolean hasDefinition();
|
||||
|
||||
public boolean canModifyImplementation();
|
||||
|
||||
public void setImplMethod(EImplMethod method);
|
||||
|
||||
public boolean isConstructor();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public final class MethodStubsLabelProvider implements ITableLabelProvider {
|
|||
case 2:
|
||||
return BaseClassesLabelProvider.getYesNoText(stub.isVirtual());
|
||||
case 3:
|
||||
return BaseClassesLabelProvider.getYesNoText(stub.isInline());
|
||||
return BaseClassesLabelProvider.getImplText(stub.getImplMethod());
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.eclipse.cdt.internal.ui.wizards.classwizard;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.IMethodStub.EImplMethod;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||
|
@ -38,13 +39,18 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
|||
private static final String CP_NAME = "name"; //$NON-NLS-1$
|
||||
private static final String CP_ACCESS = "access"; //$NON-NLS-1$
|
||||
private static final String CP_VIRTUAL = "virtual"; //$NON-NLS-1$
|
||||
private static final String CP_INLINE = "inline"; //$NON-NLS-1$
|
||||
private static final String CP_IMPL = "impl"; //$NON-NLS-1$
|
||||
static final Integer INDEX_YES = 0;
|
||||
static final Integer INDEX_NO = 1;
|
||||
static final Integer INDEX_PUBLIC = 0;
|
||||
static final Integer INDEX_PROTECTED = 1;
|
||||
static final Integer INDEX_PRIVATE = 2;
|
||||
|
||||
static final Integer INDEX_DEFINITION = EImplMethod.DEFINITION.ordinal();
|
||||
static final Integer INDEX_INLINE = EImplMethod.INLINE.ordinal();
|
||||
static final Integer INDEX_DEFAULT = EImplMethod.DEFAULT.ordinal();
|
||||
static final Integer INDEX_DELETED = EImplMethod.DELETED.ordinal();
|
||||
|
||||
private final class CellHandler implements ICellModifier {
|
||||
@Override
|
||||
public boolean canModify(Object element, String property) {
|
||||
|
@ -54,8 +60,8 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
|||
return stub.canModifyAccess();
|
||||
} else if (property.equals(CP_VIRTUAL)) {
|
||||
return stub.canModifyVirtual();
|
||||
} else if (property.equals(CP_INLINE)) {
|
||||
return stub.canModifyInline();
|
||||
} else if (property.equals(CP_IMPL)) {
|
||||
return stub.canModifyImplementation();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -79,10 +85,14 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
|||
if (stub.isVirtual())
|
||||
return INDEX_YES;
|
||||
return INDEX_NO;
|
||||
} else if (property.equals(CP_INLINE)) {
|
||||
} else if (property.equals(CP_IMPL)) {
|
||||
if (stub.isInline())
|
||||
return INDEX_YES;
|
||||
return INDEX_NO;
|
||||
return INDEX_INLINE;
|
||||
else if (stub.isDefault())
|
||||
return INDEX_DEFAULT;
|
||||
else if (stub.isDeleted())
|
||||
return INDEX_DELETED;
|
||||
return INDEX_DEFINITION;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -112,9 +122,9 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
|||
Integer yesno = (Integer) value;
|
||||
stub.setVirtual(yesno.equals(INDEX_YES));
|
||||
refresh();
|
||||
} else if (property.equals(CP_INLINE) && value instanceof Integer) {
|
||||
Integer yesno = (Integer) value;
|
||||
stub.setInline(yesno.equals(INDEX_YES));
|
||||
} else if (property.equals(CP_IMPL) && value instanceof Integer) {
|
||||
EImplMethod m = EImplMethod.values()[(int) value];
|
||||
stub.setImplMethod(m);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
@ -128,9 +138,9 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
|||
String[] headers = new String[] { NewClassWizardMessages.MethodStubsDialogField_headings_name,
|
||||
NewClassWizardMessages.MethodStubsDialogField_headings_access,
|
||||
NewClassWizardMessages.MethodStubsDialogField_headings_virtual,
|
||||
NewClassWizardMessages.MethodStubsDialogField_headings_inline };
|
||||
NewClassWizardMessages.MethodStubsDialogField_headings_implementation };
|
||||
ColumnLayoutData[] columns = new ColumnLayoutData[] { new ColumnWeightData(70, 30),
|
||||
new ColumnWeightData(40, 30), new ColumnWeightData(30, 25), new ColumnWeightData(30, 25), };
|
||||
new ColumnWeightData(40, 30), new ColumnWeightData(30, 25), new ColumnWeightData(50, 30), };
|
||||
setTableColumns(new ListDialogField.ColumnsDescription(columns, headers, true));
|
||||
}
|
||||
|
||||
|
@ -153,7 +163,14 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
|||
|
||||
CellEditor virtualCellEditor = new ComboBoxCellEditor(table,
|
||||
new String[] { /* INDEX_YES */BaseClassesLabelProvider.getYesNoText(true),
|
||||
/* INDEX_NO */BaseClassesLabelProvider.getYesNoText(false) },
|
||||
/* INDEX_NO */ BaseClassesLabelProvider.getYesNoText(false) },
|
||||
SWT.READ_ONLY);
|
||||
|
||||
CellEditor implCellEditor = new ComboBoxCellEditor(table,
|
||||
new String[] { /* INDEX_DEFINITION */BaseClassesLabelProvider.getImplText(EImplMethod.DEFINITION),
|
||||
/* INDEX_INLINE */BaseClassesLabelProvider.getImplText(EImplMethod.INLINE),
|
||||
/* INDEX_DEFAULT */BaseClassesLabelProvider.getImplText(EImplMethod.DEFAULT),
|
||||
/* INDEX_DELETED */BaseClassesLabelProvider.getImplText(EImplMethod.DELETED) },
|
||||
SWT.READ_ONLY);
|
||||
|
||||
CellEditor accessCellEditor = new ComboBoxCellEditor(table,
|
||||
|
@ -162,8 +179,8 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
|
|||
/* INDEX_PRIVATE */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PRIVATE) },
|
||||
SWT.READ_ONLY);
|
||||
|
||||
viewer.setCellEditors(new CellEditor[] { null, accessCellEditor, virtualCellEditor, virtualCellEditor });
|
||||
viewer.setColumnProperties(new String[] { CP_NAME, CP_ACCESS, CP_VIRTUAL, CP_INLINE });
|
||||
viewer.setCellEditors(new CellEditor[] { null, accessCellEditor, virtualCellEditor, implCellEditor });
|
||||
viewer.setColumnProperties(new String[] { CP_NAME, CP_ACCESS, CP_VIRTUAL, CP_IMPL });
|
||||
viewer.setCellModifier(new CellHandler());
|
||||
return viewer;
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ public final class MoveAssignOpMethodStub extends AbstractMethodStub {
|
|||
private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_move_op_name;
|
||||
|
||||
public MoveAssignOpMethodStub() {
|
||||
this(ASTAccessVisibility.PUBLIC, false);
|
||||
this(ASTAccessVisibility.PUBLIC, EImplMethod.DEFINITION);
|
||||
}
|
||||
|
||||
public MoveAssignOpMethodStub(ASTAccessVisibility access, boolean isInline) {
|
||||
super(NAME, access, false, isInline);
|
||||
public MoveAssignOpMethodStub(ASTAccessVisibility access, EImplMethod method) {
|
||||
super(NAME, access, false, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public final class MoveAssignOpMethodStub extends AbstractMethodStub {
|
|||
buf.append("& operator=("); //$NON-NLS-1$
|
||||
buf.append(className);
|
||||
buf.append("&& other)"); //$NON-NLS-1$
|
||||
if (fIsInline) {
|
||||
if (isInline()) {
|
||||
buf.append('{');
|
||||
buf.append(lineDelimiter);
|
||||
String body = CodeGeneration.getMethodBodyContent(tu, className, "operator=", null, lineDelimiter); //$NON-NLS-1$
|
||||
|
@ -46,6 +46,10 @@ public final class MoveAssignOpMethodStub extends AbstractMethodStub {
|
|||
buf.append(lineDelimiter);
|
||||
}
|
||||
buf.append('}');
|
||||
} else if (isDefault()) {
|
||||
buf.append(" = default;"); //$NON-NLS-1$
|
||||
} else if (isDeleted()) {
|
||||
buf.append(" = delete;"); //$NON-NLS-1$
|
||||
} else {
|
||||
buf.append(";"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -55,7 +59,7 @@ public final class MoveAssignOpMethodStub extends AbstractMethodStub {
|
|||
@Override
|
||||
public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
|
||||
String lineDelimiter) throws CoreException {
|
||||
if (fIsInline) {
|
||||
if (!hasDefinition()) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -22,11 +22,11 @@ public final class MoveConstructorMethodStub extends AbstractMethodStub {
|
|||
private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_move_constructor_name;
|
||||
|
||||
public MoveConstructorMethodStub() {
|
||||
this(ASTAccessVisibility.PUBLIC, false);
|
||||
this(ASTAccessVisibility.PUBLIC, EImplMethod.DEFINITION);
|
||||
}
|
||||
|
||||
public MoveConstructorMethodStub(ASTAccessVisibility access, boolean isInline) {
|
||||
super(NAME, access, false, isInline);
|
||||
public MoveConstructorMethodStub(ASTAccessVisibility access, EImplMethod method) {
|
||||
super(NAME, access, false, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public final class MoveConstructorMethodStub extends AbstractMethodStub {
|
|||
buf.append("("); //$NON-NLS-1$
|
||||
buf.append(className);
|
||||
buf.append("&& other)"); //$NON-NLS-1$
|
||||
if (fIsInline) {
|
||||
if (isInline()) {
|
||||
buf.append('{');
|
||||
buf.append(lineDelimiter);
|
||||
String body = CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
|
||||
|
@ -46,6 +46,10 @@ public final class MoveConstructorMethodStub extends AbstractMethodStub {
|
|||
buf.append(lineDelimiter);
|
||||
}
|
||||
buf.append('}');
|
||||
} else if (isDefault()) {
|
||||
buf.append(" = default;"); //$NON-NLS-1$
|
||||
} else if (isDeleted()) {
|
||||
buf.append(" = delete;"); //$NON-NLS-1$
|
||||
} else {
|
||||
buf.append(";"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -55,7 +59,7 @@ public final class MoveConstructorMethodStub extends AbstractMethodStub {
|
|||
@Override
|
||||
public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses,
|
||||
String lineDelimiter) throws CoreException {
|
||||
if (fIsInline) {
|
||||
if (!hasDefinition()) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
|
|
@ -89,10 +89,14 @@ public final class NewClassWizardMessages extends NLS {
|
|||
public static String BaseClassesLabelProvider_access_public_label;
|
||||
public static String BaseClassesLabelProvider_access_protected_label;
|
||||
public static String BaseClassesLabelProvider_access_private_label;
|
||||
public static String BaseClassesLabelProvider_impl_definition;
|
||||
public static String BaseClassesLabelProvider_impl_deleted;
|
||||
public static String BaseClassesLabelProvider_impl_default;
|
||||
public static String BaseClassesLabelProvider_impl_inline;
|
||||
public static String MethodStubsDialogField_headings_name;
|
||||
public static String MethodStubsDialogField_headings_access;
|
||||
public static String MethodStubsDialogField_headings_virtual;
|
||||
public static String MethodStubsDialogField_headings_inline;
|
||||
public static String MethodStubsDialogField_headings_implementation;
|
||||
public static String NamespaceSelectionDialog_title;
|
||||
public static String NamespaceSelectionDialog_message;
|
||||
public static String EnclosingClassSelectionDialog_title;
|
||||
|
|
|
@ -105,12 +105,16 @@ BaseClassesLabelProvider_boolean_no_label=no
|
|||
BaseClassesLabelProvider_access_public_label=public
|
||||
BaseClassesLabelProvider_access_protected_label=protected
|
||||
BaseClassesLabelProvider_access_private_label=private
|
||||
BaseClassesLabelProvider_impl_definition=definition
|
||||
BaseClassesLabelProvider_impl_deleted=deleted
|
||||
BaseClassesLabelProvider_impl_default=default
|
||||
BaseClassesLabelProvider_impl_inline=inline
|
||||
|
||||
# -----------MethodStubsDialogField -------------
|
||||
MethodStubsDialogField_headings_name=Name
|
||||
MethodStubsDialogField_headings_access=Access
|
||||
MethodStubsDialogField_headings_virtual=Virtual
|
||||
MethodStubsDialogField_headings_inline=Inline
|
||||
MethodStubsDialogField_headings_implementation=Implementation
|
||||
|
||||
# ------- NamespaceSelectionDialog -----
|
||||
NamespaceSelectionDialog_title=Choose Namespace
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.eclipse.cdt.internal.ui.wizards.classwizard.CopyConstructorMethodStub
|
|||
import org.eclipse.cdt.internal.ui.wizards.classwizard.DestructorMethodStub;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.IBaseClassInfo;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.IMethodStub;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.IMethodStub.EImplMethod;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.MethodStubsListDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.MoveAssignOpMethodStub;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.MoveConstructorMethodStub;
|
||||
|
@ -120,7 +121,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
private static final String KEY_TEST_FILE_SELECTED = "testFileSelected"; //$NON-NLS-1$
|
||||
private static final String KEY_STUB_SELECTED = "stubSelected"; //$NON-NLS-1$
|
||||
private static final String KEY_STUB_VIRTUAL = "stubVirtual"; //$NON-NLS-1$
|
||||
private static final String KEY_STUB_INLINE = "stubInline"; //$NON-NLS-1$
|
||||
private static final String KEY_STUB_IMPL = "stubImpl"; //$NON-NLS-1$
|
||||
|
||||
// Field IDs
|
||||
protected static final int SOURCE_FOLDER_ID = 1;
|
||||
|
@ -492,8 +493,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
if (stub.canModifyVirtual()) {
|
||||
stub.setVirtual(getBooleanSettingWithDefault(KEY_STUB_VIRTUAL + i, stub.isVirtual()));
|
||||
}
|
||||
if (stub.canModifyInline()) {
|
||||
stub.setInline(getBooleanSettingWithDefault(KEY_STUB_INLINE + i, stub.isInline()));
|
||||
if (stub.canModifyImplementation()) {
|
||||
stub.setImplMethod(getEnumSettingWithDefault(KEY_STUB_IMPL + i, EImplMethod.DEFINITION));
|
||||
}
|
||||
addMethodStub(stub, getBooleanSettingWithDefault(KEY_STUB_SELECTED + i, stub.isEnabledByDefault()));
|
||||
}
|
||||
|
@ -510,6 +511,14 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
return Boolean.valueOf(value);
|
||||
}
|
||||
|
||||
private EImplMethod getEnumSettingWithDefault(String key, EImplMethod defaultValue) {
|
||||
String value = fDialogSettings.get(key);
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return EImplMethod.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to extract a C Element from the initial selection.
|
||||
*
|
||||
|
@ -2079,8 +2088,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
if (stub.canModifyVirtual()) {
|
||||
fDialogSettings.put(KEY_STUB_VIRTUAL + i, stub.isVirtual());
|
||||
}
|
||||
if (stub.canModifyInline()) {
|
||||
fDialogSettings.put(KEY_STUB_INLINE + i, stub.isInline());
|
||||
if (stub.canModifyImplementation()) {
|
||||
fDialogSettings.put(KEY_STUB_IMPL + i, stub.getImplMethod().name());
|
||||
}
|
||||
fDialogSettings.put(KEY_STUB_SELECTED + i, fMethodStubsDialogField.isChecked(stub));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue