List of usage examples for org.eclipse.jdt.core.formatter DefaultCodeFormatterConstants NEXT_LINE
String NEXT_LINE
To view the source code for org.eclipse.jdt.core.formatter DefaultCodeFormatterConstants NEXT_LINE.
Click Source Link
FORMATTER / Value to set a brace location at the start of the next line with the right indentation.Usage
From source file:com.bsiag.eclipse.jdt.java.formatter.LineBreaksPreparator.java
License:Open Source License
private void handleBracePosition(Token openBraceToken, int closeBraceIndex, String bracePosition) { if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE)) { openBraceToken.breakBefore();/*w ww.j av a2 s . c o m*/ } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { openBraceToken.breakBefore(); openBraceToken.indent(); if (closeBraceIndex + 1 < this.tm.size()) this.tm.get(closeBraceIndex + 1).unindent(); } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP)) { openBraceToken.setNextLineOnWrap(); } }From source file:org.eclipse.emf.codegen.merge.java.facade.ast.ASTFacadeHelper.java
License:Open Source License
/** * Gets JavaCore options from JavaCore and updates tab and indentation settings from ControlModel. * //ww w.j a v a 2 s . c om * @return map of options * * @see #getJavaCoreOptions() * @see JavaCore#getOptions() * @see JControlModel#getLeadingTabReplacement() */ private Map<?, ?> getDefaultJavaCoreOptions() { Map<Object, String> javaCoreOptions = new HashMap<Object, String>(JavaCore.getOptions()); // Set of options that we want to copy from the current definition or use defaults // if (compilerCompliance != null) { javaCoreOptions.put(JavaCore.COMPILER_COMPLIANCE, compilerCompliance); javaCoreOptions.put(JavaCore.COMPILER_SOURCE, compilerCompliance); javaCoreOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, compilerCompliance); } else { useCurrentOption(javaCoreOptions, JavaCore.COMPILER_COMPLIANCE, "1.5"); useCurrentOption(javaCoreOptions, JavaCore.COMPILER_SOURCE, "1.5"); useCurrentOption(javaCoreOptions, JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "1.5"); } useCurrentOption(javaCoreOptions, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); useCurrentOption(javaCoreOptions, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "2"); useCurrentOption(javaCoreOptions, DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "2"); javaCoreOptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, "enabled"); if (getControlModel() != null) { String indent = getControlModel().getLeadingTabReplacement(); if (indent != null && indent.length() > 0) { String size = Integer.toString(indent.length()); if (indent.charAt(0) == '\t') { javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, size); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, size); } else if (indent.charAt(0) == ' ') { javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, size); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, size); } else { if (DEBUG) { logInfo("Unable to recognize indent string, using java core options."); } } } else { if (DEBUG) { logInfo("Indent is not set, using java core options."); } } } if (DEBUG) { logInfo("Tab char: " + javaCoreOptions.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR) + ", Indent size: " + javaCoreOptions.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE) + ", Tab size: " + javaCoreOptions.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE)); } // Set of options that we want to control javaCoreOptions.put("org.eclipse.jdt.core.incompleteClasspath", "warning"); javaCoreOptions.put("org.eclipse.jdt.core.circularClasspath", "warning"); // javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); // separate fields with an empty line javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD, "1"); // make all enum constants to be on separate lines javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); return javaCoreOptions; }From source file:org.eclipse.objectteams.otdt.ui.tests.util.TestOptions.java
License:Open Source License
private void setDefaultSettings() { this.align_type_members_on_columns = false; this.brace_position_for_anonymous_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE; this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE; this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE; this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE; //{ObjectTeams: according to code conventions of Fraunhofer FIRST this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.NEXT_LINE; //gbr}//from w w w. j ava 2 s . c o m this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE; this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE; this.continuation_indentation = 2; this.continuation_indentation_for_array_initializer = 2; this.blank_lines_after_imports = 0; this.blank_lines_after_package = 0; this.blank_lines_before_field = 0; this.blank_lines_before_first_class_body_declaration = 0; this.blank_lines_before_imports = 0; this.blank_lines_before_member_type = 0; this.blank_lines_before_method = 0; this.blank_lines_before_new_chunk = 0; this.blank_lines_before_package = 0; this.blank_lines_between_type_declarations = 0; this.blank_lines_at_beginning_of_method_body = 0; this.indent_statements_compare_to_block = true; this.indent_statements_compare_to_body = true; this.indent_body_declarations_compare_to_type_header = true; this.indent_breaks_compare_to_cases = true; this.indent_switchstatements_compare_to_cases = true; this.indent_switchstatements_compare_to_switch = true; this.insert_new_line_after_opening_brace_in_array_initializer = false; this.insert_new_line_before_catch_in_try_statement = false; this.insert_new_line_before_closing_brace_in_array_initializer = false; this.insert_new_line_before_else_in_if_statement = false; this.insert_new_line_before_finally_in_try_statement = false; this.insert_new_line_before_while_in_do_statement = false; this.insert_new_line_in_empty_anonymous_type_declaration = true; this.insert_new_line_in_empty_block = true; this.insert_new_line_in_empty_method_body = true; this.insert_new_line_in_empty_type_declaration = true; this.insert_space_after_assignment_operator = true; this.insert_space_after_binary_operator = true; this.insert_space_after_closing_paren_in_cast = true; this.insert_space_after_closing_brace_in_block = true; this.insert_space_after_colon_in_assert = true; this.insert_space_after_colon_in_case = true; this.insert_space_after_colon_in_conditional = true; this.insert_space_after_colon_in_labeled_statement = true; this.insert_space_after_comma_in_allocation_expression = true; this.insert_space_after_comma_in_array_initializer = true; this.insert_space_after_comma_in_constructor_declaration_parameters = true; this.insert_space_after_comma_in_constructor_declaration_throws = true; this.insert_space_after_comma_in_explicit_constructor_call_arguments = true; this.insert_space_after_comma_in_for_increments = true; this.insert_space_after_comma_in_for_inits = true; this.insert_space_after_comma_in_method_invocation_arguments = true; this.insert_space_after_comma_in_method_declaration_parameters = true; this.insert_space_after_comma_in_method_declaration_throws = true; this.insert_space_after_comma_in_multiple_field_declarations = true; this.insert_space_after_comma_in_multiple_local_declarations = true; this.insert_space_after_comma_in_superinterfaces = true; this.insert_space_after_opening_bracket_in_array_allocation_expression = false; this.insert_space_after_opening_bracket_in_array_reference = false; this.insert_space_after_opening_brace_in_array_initializer = false; this.insert_space_after_opening_paren_in_cast = false; this.insert_space_after_opening_paren_in_catch = false; this.insert_space_after_opening_paren_in_constructor_declaration = false; this.insert_space_after_opening_paren_in_for = false; this.insert_space_after_opening_paren_in_if = false; this.insert_space_after_opening_paren_in_method_declaration = false; this.insert_space_after_opening_paren_in_method_invocation = false; this.insert_space_after_opening_paren_in_parenthesized_expression = false; this.insert_space_after_opening_paren_in_switch = false; this.insert_space_after_opening_paren_in_synchronized = false; this.insert_space_after_opening_paren_in_while = false; this.insert_space_after_postfix_operator = false; this.insert_space_after_prefix_operator = false; this.insert_space_after_question_in_conditional = true; this.insert_space_after_semicolon_in_for = true; this.insert_space_after_unary_operator = false; this.insert_space_before_assignment_operator = true; this.insert_space_before_binary_operator = true; this.insert_space_before_closing_brace_in_array_initializer = false; this.insert_space_before_closing_bracket_in_array_allocation_expression = false; this.insert_space_before_closing_bracket_in_array_reference = false; this.insert_space_before_closing_paren_in_cast = false; this.insert_space_before_closing_paren_in_catch = false; this.insert_space_before_closing_paren_in_constructor_declaration = false; this.insert_space_before_closing_paren_in_for = false; this.insert_space_before_closing_paren_in_if = false; this.insert_space_before_closing_paren_in_method_declaration = false; this.insert_space_before_closing_paren_in_method_invocation = false; this.insert_space_before_closing_paren_in_parenthesized_expression = false; this.insert_space_before_closing_paren_in_switch = false; this.insert_space_before_closing_paren_in_synchronized = false; this.insert_space_before_closing_paren_in_while = false; this.insert_space_before_colon_in_assert = true; this.insert_space_before_colon_in_case = true; this.insert_space_before_colon_in_conditional = true; this.insert_space_before_colon_in_default = true; this.insert_space_before_colon_in_labeled_statement = true; this.insert_space_before_comma_in_allocation_expression = false; this.insert_space_before_comma_in_array_initializer = false; this.insert_space_before_comma_in_constructor_declaration_parameters = false; this.insert_space_before_comma_in_constructor_declaration_throws = false; this.insert_space_before_comma_in_explicit_constructor_call_arguments = false; this.insert_space_before_comma_in_for_increments = false; this.insert_space_before_comma_in_for_inits = false; this.insert_space_before_comma_in_method_invocation_arguments = false; this.insert_space_before_comma_in_method_declaration_parameters = false; this.insert_space_before_comma_in_method_declaration_throws = false; this.insert_space_before_comma_in_multiple_field_declarations = false; this.insert_space_before_comma_in_multiple_local_declarations = false; this.insert_space_before_comma_in_superinterfaces = false; this.insert_space_before_opening_brace_in_anonymous_type_declaration = true; this.insert_space_before_opening_brace_in_array_initializer = false; this.insert_space_before_opening_brace_in_block = true; this.insert_space_before_opening_brace_in_constructor_declaration = true; this.insert_space_before_opening_brace_in_method_declaration = true; this.insert_space_before_opening_brace_in_switch = true; this.insert_space_before_opening_brace_in_type_declaration = true; this.insert_space_before_opening_bracket_in_array_allocation_expression = false; this.insert_space_before_opening_bracket_in_array_reference = false; this.insert_space_before_opening_bracket_in_array_type_reference = false; this.insert_space_before_opening_paren_in_catch = true; this.insert_space_before_opening_paren_in_constructor_declaration = false; this.insert_space_before_opening_paren_in_for = true; this.insert_space_before_opening_paren_in_if = true; this.insert_space_before_opening_paren_in_method_invocation = false; this.insert_space_before_opening_paren_in_method_declaration = false; this.insert_space_before_opening_paren_in_switch = true; this.insert_space_before_opening_paren_in_synchronized = true; this.insert_space_before_opening_paren_in_parenthesized_expression = false; this.insert_space_before_opening_paren_in_while = true; this.insert_space_before_postfix_operator = false; this.insert_space_before_prefix_operator = false; this.insert_space_before_question_in_conditional = true; this.insert_space_before_semicolon = false; this.insert_space_before_semicolon_in_for = false; this.insert_space_before_unary_operator = false; this.insert_space_between_brackets_in_array_type_reference = false; this.insert_space_between_empty_braces_in_array_initializer = false; this.insert_space_between_empty_brackets_in_array_allocation_expression = false; this.insert_space_between_empty_parens_in_constructor_declaration = false; this.insert_space_between_empty_parens_in_method_declaration = false; this.insert_space_between_empty_parens_in_method_invocation = false; this.compact_else_if = true; this.keep_guardian_clause_on_one_line = false; this.keep_else_statement_on_same_line = false; this.keep_empty_array_initializer_on_one_line = false; this.keep_simple_if_on_one_line = false; this.keep_then_statement_on_same_line = false; this.number_of_empty_lines_to_preserve = 1; this.put_empty_statement_on_new_line = false; this.tab_size = 4; this.page_width = 80; this.use_tab = true; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49081 }From source file:org.eclipse.ocl.examples.build.utilities.StandaloneASTFacadeHelper.java
License:Open Source License
/** * Gets JavaCore options from JavaCore and updates tab and indentation * settings from ControlModel.//from w w w . j a va 2s. c o m * * @return map of options * * @see #getJavaCoreOptions() * @see JavaCore#getOptions() * @see JControlModel#getLeadingTabReplacement() */ @SuppressWarnings("unchecked") private Map<?, ?> getDefaultJavaCoreOptions() { String compilerCompliance = JavaCore.VERSION_1_5; Map<Object, String> javaCoreOptions = JavaCore.getOptions(); // Set of options that we want to copy from the current definition javaCoreOptions.put(JavaCore.COMPILER_COMPLIANCE, compilerCompliance); javaCoreOptions.put(JavaCore.COMPILER_SOURCE, compilerCompliance); javaCoreOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, compilerCompliance); useCurrentOption(javaCoreOptions, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); useCurrentOption(javaCoreOptions, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "2"); useCurrentOption(javaCoreOptions, DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, "2"); if (getControlModel() != null) { String indent = getControlModel().getLeadingTabReplacement(); if (indent != null && indent.length() > 0) { String size = Integer.toString(indent.length()); if (indent.charAt(0) == '\t') { javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, size); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, size); } else if (indent.charAt(0) == ' ') { javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, size); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, size); } else { if (DEBUG) { logInfo("Unable to recognize indent string, using java core options."); } } } else { if (DEBUG) { logInfo("Indent is not set, using java core options."); } } } if (DEBUG) { logInfo("Tab char: " + javaCoreOptions.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR) + ", Indent size: " + javaCoreOptions.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE) + ", Tab size: " + javaCoreOptions.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE)); } // Set of options that we want to control javaCoreOptions.put("org.eclipse.jdt.core.incompleteClasspath", "warning"); javaCoreOptions.put("org.eclipse.jdt.core.circularClasspath", "warning"); // javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); // separate fields with an empty line javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD, "1"); // make all enum constants to be on separate lines javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE, DefaultCodeFormatterConstants.INDENT_DEFAULT)); return javaCoreOptions; }From source file:org.eclipse.wb.internal.core.utils.ast.AstCodeGeneration.java
License:Open Source License
/** * Return <code>true</code> if the user wants to have an end-of-line marker inserted before each * opening brace./* ww w .j a va2s . co m*/ * * @return <code>true</code> if an end-of-line marker should be inserted before each opening brace */ public boolean getInsertEndOfLineBeforeOpeningBrace() { Map<String, String> javaOptions = getJavaOptions(); String value = javaOptions .get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION); return value != null && value.equals(DefaultCodeFormatterConstants.NEXT_LINE); }From source file:org.eclipse.wb.tests.designer.core.util.ast.AstEditorTest.java
License:Open Source License
public void test_ASTCG_getMethodBraceSeparator() throws Exception { createTypeDeclaration_TestC(""); AstCodeGeneration generation = m_lastEditor.getGeneration(); //// ww w . j a v a 2 s.com assertSame(" ", generation.getMethodBraceSeparator("\t\t")); // IJavaProject javaProject = m_lastEditor.getModelUnit().getJavaProject(); javaProject.setOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE); assertEquals(Expectations.get("\r\n\t", new StrValue("flanker-desktop", "\n\t"), new StrValue("scheglov-macpro", "\n\t")), generation.getMethodBraceSeparator("\t")); assertEquals(Expectations.get("\r\n\t\t", new StrValue("flanker-desktop", "\n\t\t"), new StrValue("scheglov-macpro", "\n\t\t")), generation.getMethodBraceSeparator("\t\t")); }