Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2019-05-18 12:43:12 -0400
committerMarco Stornelli2019-05-24 14:39:49 -0400
commit0c147ecb93de92709655d8d446b3d9a569d424ef (patch)
tree7560f0cfb21dc0e62ffee5b628900b095dbefba6
parent4332b0fbc7721de4a212f825f995609cde9d0d87 (diff)
downloadorg.eclipse.cdt-0c147ecb93de92709655d8d446b3d9a569d424ef.tar.gz
org.eclipse.cdt-0c147ecb93de92709655d8d446b3d9a569d424ef.tar.xz
org.eclipse.cdt-0c147ecb93de92709655d8d446b3d9a569d424ef.zip
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>
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java42
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AssignOpMethodStub.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/CopyConstructorMethodStub.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveAssignOpMethodStub.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveConstructorMethodStub.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java19
14 files changed, 176 insertions, 66 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java
index 46970bc339..9c014c9e81 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java
@@ -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;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AssignOpMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AssignOpMethodStub.java
index 9609dd37ed..e8f2330ed7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AssignOpMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AssignOpMethodStub.java
@@ -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();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
index fc200736fd..b654bf3330 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
@@ -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);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java
index fad372aeff..edd69c1e07 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java
@@ -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();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/CopyConstructorMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/CopyConstructorMethodStub.java
index 2dbae40e58..31203faf17 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/CopyConstructorMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/CopyConstructorMethodStub.java
@@ -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();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java
index 13a7c89acf..384a10840f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java
@@ -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();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java
index 7191ce8913..cb3b2a8454 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java
@@ -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 boolean isDefault();
+
+ public boolean hasDefinition();
+
+ public boolean canModifyImplementation();
- public void setInline(boolean isVirtual);
+ public void setImplMethod(EImplMethod method);
public boolean isConstructor();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java
index 22e9e26514..58261eb0ab 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java
@@ -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;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java
index 8b6b2aea2c..e2e87d7b8b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java
@@ -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;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveAssignOpMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveAssignOpMethodStub.java
index b337e18238..48299f162a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveAssignOpMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveAssignOpMethodStub.java
@@ -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();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveConstructorMethodStub.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveConstructorMethodStub.java
index 8213eede30..a8dda9bf3c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveConstructorMethodStub.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MoveConstructorMethodStub.java
@@ -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();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
index 056d1e8878..9ce8764e9d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
@@ -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;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
index 66386faa77..d0d4b1b366 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
@@ -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
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
index 1d2a9d3b45..2365b4055e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
@@ -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));
}

Back to the top