aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManju Mathew2013-03-21 12:50:46 (EDT)
committerMarkus Keller2013-03-21 12:50:46 (EDT)
commite22f118178ef366019ebbb07d469d6a8a346515f (patch)
tree8381435d89d065f10aa7c896b71e7b3a25e6700f
parente115c9755c1b358c0fd0aabfc8934f903f5ede20 (diff)
downloadeclipse.jdt.ui-e22f118178ef366019ebbb07d469d6a8a346515f.zip
eclipse.jdt.ui-e22f118178ef366019ebbb07d469d6a8a346515f.tar.gz
eclipse.jdt.ui-e22f118178ef366019ebbb07d469d6a8a346515f.tar.bz2
Bug 401666: UI for Java 8 code formatter options
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/BracesTabPage.java9
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java11
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties15
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java20
4 files changed, 50 insertions, 5 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/BracesTabPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/BracesTabPage.java
index 39092ec..4a30492 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/BracesTabPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/BracesTabPage.java
@@ -4,6 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
@@ -42,6 +46,9 @@ public class BracesTabPage extends FormatterTabPage {
" int [] myArray= {1,2,3,4,5,6};" + //$NON-NLS-1$
" int [] emptyArray= new int[] {};" + //$NON-NLS-1$
" Example() {" + //$NON-NLS-1$
+ " Runnable r = () -> {"+ //$NON-NLS-1$
+ " fField.set(20);"+ //$NON-NLS-1$
+ " };"+ //$NON-NLS-1$
" }" + //$NON-NLS-1$
" void bar(int p) {" + //$NON-NLS-1$
" for (int i= 0; i<10; i++) {" + //$NON-NLS-1$
@@ -125,6 +132,8 @@ public class BracesTabPage extends FormatterTabPage {
}
});
updateOptionEnablement(arrayInitOption, arrayInitCheckBox);
+
+ createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_lambda_body, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_LAMBDA_BODY);
}
protected final void updateOptionEnablement(ComboPreference arrayInitOption, CheckboxPreference arrayInitCheckBox) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java
index ca0d05a..1eeb0ac 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* istvan@benedek-home.de - 103706 [formatter] indent empty lines
@@ -162,6 +166,8 @@ final class FormatterMessages extends NLS {
public static String WhiteSpaceOptions_after;
public static String WhiteSpaceOptions_operator;
public static String WhiteSpaceOptions_assignment_operator;
+ public static String WhiteSpaceOptions_lambda_after_arrow_operator;
+ public static String WhiteSpaceOptions_lambda_before_arrow_operator;
public static String WhiteSpaceOptions_binary_operator;
public static String WhiteSpaceOptions_unary_operator;
public static String WhiteSpaceOptions_prefix_operator;
@@ -205,6 +211,7 @@ final class FormatterMessages extends NLS {
public static String WhiteSpaceOptions_array_element_access;
public static String WhiteSpaceOptions_array_alloc;
public static String WhiteSpaceOptions_array_init;
+ public static String WhiteSpaceOptions_arrow_operator;
public static String WhiteSpaceOptions_arguments;
public static String WhiteSpaceOptions_initialization;
public static String WhiteSpaceOptions_incrementation;
@@ -220,6 +227,7 @@ final class FormatterMessages extends NLS {
public static String WhiteSpaceOptions_conditional;
public static String WhiteSpaceOptions_wildcard;
public static String WhiteSpaceOptions_label;
+ public static String WhiteSpaceOptions_lambda;
public static String WhiteSpaceOptions_comma;
public static String WhiteSpaceOptions_semicolon;
public static String WhiteSpaceOptions_question_mark;
@@ -355,6 +363,7 @@ final class FormatterMessages extends NLS {
public static String BracesTabPage_option_enum_declaration;
public static String BracesTabPage_option_enumconst_declaration;
public static String BracesTabPage_option_annotation_type_declaration;
+ public static String BracesTabPage_option_lambda_body;
public static String CodingStyleConfigurationBlock_preview_title;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties
index 3c2ed08..79b0c3a 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties
@@ -1,10 +1,14 @@
###############################################################################
-# Copyright (c) 2000, 2011 IBM Corporation and others.
+# Copyright (c) 2000, 2013 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
+# This is an implementation of an early-draft specification developed under the Java
+# Community Process (JCP) and is made available for testing and evaluation purposes
+# only. The code is not compatible with any specification of the JCP.
+#
# Contributors:
# IBM Corporation - initial API and implementation
# istvan@benedek-home.de - 103706 [formatter] indent empty lines
@@ -174,6 +178,8 @@ WhiteSpaceOptions_after=After
WhiteSpaceOptions_operator=Operator
WhiteSpaceOptions_assignment_operator=Assignment operator
+WhiteSpaceOptions_lambda_after_arrow_operator=after arrow operator
+WhiteSpaceOptions_lambda_before_arrow_operator=before arrow operator
WhiteSpaceOptions_binary_operator=Binary operator
WhiteSpaceOptions_unary_operator=Unary operator
WhiteSpaceOptions_prefix_operator=Prefix operator
@@ -223,6 +229,7 @@ WhiteSpaceOptions_array_decl=Array declaration
WhiteSpaceOptions_array_element_access=Array element access
WhiteSpaceOptions_array_alloc=Array allocation
WhiteSpaceOptions_array_init=Array initializer
+WhiteSpaceOptions_arrow_operator=Arrow operator
WhiteSpaceOptions_arguments=Arguments
WhiteSpaceOptions_initialization=Initialization
@@ -242,6 +249,7 @@ WhiteSpaceOptions_colon=Colon
WhiteSpaceOptions_conditional=Conditional
WhiteSpaceOptions_wildcard=Wildcard type
WhiteSpaceOptions_label=Label
+WhiteSpaceOptions_lambda=Lambda
WhiteSpaceOptions_comma=Comma
WhiteSpaceOptions_semicolon=Semicolon
@@ -383,7 +391,7 @@ BracesTabPage_position_next_line_indented=Next line indented
BracesTabPage_position_next_line_on_wrap=Next line on wrap
BracesTabPage_group_brace_positions_title=Brace positions
-BracesTabPage_option_class_declaration=&Class or interface declaration:
+BracesTabPage_option_class_declaration=Class or inter&face declaration:
BracesTabPage_option_anonymous_class_declaration=Anon&ymous class declaration:
BracesTabPage_option_method_declaration=Met&hod declaration:
BracesTabPage_option_constructor_declaration=Constr&uctor declaration:
@@ -393,8 +401,9 @@ BracesTabPage_option_switch_case='&switch' statement:
BracesTabPage_option_array_initializer=Array initiali&zer:
BracesTabPage_option_keep_empty_array_initializer_on_one_line=Keep empty array &initializer on one line
BracesTabPage_option_enum_declaration=&Enum declaration:
-BracesTabPage_option_enumconst_declaration=Enum c&onstant body:
+BracesTabPage_option_enumconst_declaration=Enum &constant body:
BracesTabPage_option_annotation_type_declaration=&Annotation type declaration:
+BracesTabPage_option_lambda_body=Lambda b&ody:
CodingStyleConfigurationBlock_preview_title=A sample source file for the code formatter preview
CommentsTabPage_group1_title=General settings
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
index 73ce3e9..dffe754 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -322,6 +326,10 @@ public final class WhiteSpaceOptions {
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"Map<X<?>, Y<? extends K, ? super V>> t;" //$NON-NLS-1$
);
+
+ private final PreviewSnippet LAMBDA_EXPR_PREVIEW= new PreviewSnippet(
+ CodeFormatter.K_STATEMENTS,
+ "Runnable r = ()->process();"); //$NON-NLS-1$
/**
* Create the tree, in this order: syntax element - position - abstract element
@@ -539,6 +547,7 @@ public final class WhiteSpaceOptions {
createAnnotationTree(workingValues, declarations);
createEnumTree(workingValues, declarations);
createAnnotationTypeTree(workingValues, declarations);
+ createLambdaTree(workingValues, declarations);
final InnerNode statements= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_statements);
createOption(statements, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
@@ -583,6 +592,13 @@ public final class WhiteSpaceOptions {
return roots;
}
+ private InnerNode createLambdaTree(Map<String, String> workingValues, InnerNode parent) {
+ final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lambda);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceOptions_lambda_before_arrow_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_LAMBDA_ARROW, LAMBDA_EXPR_PREVIEW);
+ createOption(root, workingValues, FormatterMessages.WhiteSpaceOptions_lambda_after_arrow_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_LAMBDA_ARROW, LAMBDA_EXPR_PREVIEW);
+ return root;
+ }
+
private void createBeforeQuestionTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_wildcard, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD, WILDCARD_PREVIEW);
@@ -656,6 +672,7 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrow_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_LAMBDA_ARROW, LAMBDA_EXPR_PREVIEW);
}
private void createBeforeClosingBracketTree(Map<String, String> workingValues, final InnerNode parent) {
@@ -832,6 +849,7 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
+ createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrow_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_LAMBDA_ARROW, LAMBDA_EXPR_PREVIEW);
}
private void createAfterOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {