Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Morgner2018-11-14 09:26:59 +0000
committerMarco Stornelli2020-03-13 07:35:34 +0000
commitbcb955a32104da02f3748dd3ef080cbcb43c646b (patch)
tree3cd7a84dd8ae93796adae1ebd3394e880eaa269e /core/org.eclipse.cdt.ui/src/org/eclipse
parent5823d56a2d15c0719fb33b23cb1197af3a7ba71c (diff)
downloadorg.eclipse.cdt-bcb955a32104da02f3748dd3ef080cbcb43c646b.tar.gz
org.eclipse.cdt-bcb955a32104da02f3748dd3ef080cbcb43c646b.tar.xz
org.eclipse.cdt-bcb955a32104da02f3748dd3ef080cbcb43c646b.zip
541239: [C++17] Implement parser support for deduction guides
Change-Id: I1683583af981d276b346ba8470a9044cfd8921cd Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=541239 Signed-off-by: Felix Morgner <fmorgner@hsr.ch> Also-by: Marco Stornelli <marco.stornelli@gmail.com>
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java23
3 files changed, 32 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java
index 7deb8d1086b..82737ec5982 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java
@@ -212,6 +212,10 @@ final class FormatterMessages extends NLS {
public static String WhiteSpaceOptions_structured_binding_before_comma_in_name_list;
public static String WhiteSpaceOptions_structured_binding_after_comma_in_name_list;
public static String WhiteSpaceOptions_structured_binding_before_name_list_closing_bracket;
+ public static String WhiteSpaceTabPage_deduction_guide_declarations;
+ public static String WhiteSpaceTabPage_deduction_guide_before_arrow;
+ public static String WhiteSpaceTabPage_deduction_guide_after_arrow;
+ public static String WhiteSpaceOptions_deduction_guide_arrow_operator;
// public static String WhiteSpaceOptions_before_ellipsis;
// public static String WhiteSpaceOptions_after_ellipsis;
// public static String WhiteSpaceOptions_return_with_parenthesized_expression;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties
index 6921dc869ed..94d45b8107f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties
@@ -34,6 +34,10 @@ WhiteSpaceTabPage_lambda_expressions=Lambda expressions
WhiteSpaceTabPage_lambda_before_return=before return arrow
WhiteSpaceTabPage_lambda_after_return=after return arrow
+WhiteSpaceTabPage_deduction_guide_declarations=Deduction guide
+WhiteSpaceTabPage_deduction_guide_before_arrow=before arrow
+WhiteSpaceTabPage_deduction_guide_after_arrow=after arrow
+
WhiteSpaceTabPage_classes=Types
WhiteSpaceTabPage_classes_before_opening_brace_of_a_class=before opening brace of a class
WhiteSpaceTabPage_classes_before_colon_of_base_clause=before colon of base clause
@@ -146,6 +150,7 @@ WhiteSpaceOptions_unary_operator=Unary operator
WhiteSpaceOptions_prefix_operator=Prefix operator
WhiteSpaceOptions_postfix_operator=Postfix operator
WhiteSpaceOptions_lambda_arrow_operator=Lambda arrow operator
+WhiteSpaceOptions_deduction_guide_arrow_operator=Deduction guide arrow operator
WhiteSpaceOptions_pointer=Pointer
WhiteSpaceOptions_before_pointer=Before pointer
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
index 95e938b5ff6..78116c21743 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
@@ -183,6 +183,9 @@ public final class WhiteSpaceOptions {
private final PreviewSnippet LAMBDA_PREVIEW = new PreviewSnippet(CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"void foo() { auto f = []()->int{return 0;};}"); //$NON-NLS-1$
+ private final PreviewSnippet DEDUCTION_GUIDE_PREVIEW = new PreviewSnippet(CodeFormatter.K_CLASS_BODY_DECLARATIONS,
+ "template<typename T> struct U;\ntemplate<typename C>\nU(C) -> U<C>;"); //$NON-NLS-1$
+
private final PreviewSnippet INITIALIZER_LIST_PREVIEW = new PreviewSnippet(CodeFormatter.K_STATEMENTS,
"int array[]= {1, 2, 3};"); //$NON-NLS-1$
@@ -478,6 +481,7 @@ public final class WhiteSpaceOptions {
createLinkageTree(workingValues, declarations);
// createConstructorTree(workingValues, declarations);
createLambdaDeclTree(workingValues, declarations);
+ createDeductionDeclTree(workingValues, declarations);
createMethodDeclTree(workingValues, declarations);
createExceptionSpecificationTree(workingValues, declarations);
createLabelTree(workingValues, declarations);
@@ -606,6 +610,9 @@ public final class WhiteSpaceOptions {
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lambda_arrow_operator,
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_LAMBDA_RETURN, LAMBDA_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_deduction_guide_arrow_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_DEDUCTION_GUIDE_ARROW,
+ DEDUCTION_GUIDE_PREVIEW);
}
private void createBeforeClosingBracketTree(Map<String, String> workingValues, final InnerNode parent) {
@@ -852,6 +859,9 @@ public final class WhiteSpaceOptions {
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lambda_arrow_operator,
DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_LAMBDA_RETURN, LAMBDA_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_deduction_guide_arrow_operator,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_DEDUCTION_GUIDE_ARROW,
+ DEDUCTION_GUIDE_PREVIEW);
}
private void createAfterOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
@@ -1004,6 +1014,19 @@ public final class WhiteSpaceOptions {
return root;
}
+ private InnerNode createDeductionDeclTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root = new InnerNode(parent, workingValues,
+ FormatterMessages.WhiteSpaceTabPage_deduction_guide_declarations);
+
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_deduction_guide_before_arrow,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_DEDUCTION_GUIDE_ARROW,
+ DEDUCTION_GUIDE_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_deduction_guide_after_arrow,
+ DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_DEDUCTION_GUIDE_ARROW,
+ DEDUCTION_GUIDE_PREVIEW);
+ return root;
+ }
+
private InnerNode createLambdaDeclTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root = new InnerNode(parent, workingValues,
FormatterMessages.WhiteSpaceTabPage_lambda_expressions);

Back to the top