Java 类org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants 实例源码

项目:eclipse.jdt.ls    文件:TestOptions.java   
public static Hashtable<String, String> getDefaultOptions() {
    Hashtable<String, String> result = JavaCore.getDefaultOptions();
    result.put(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_FIELD_HIDING, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.IGNORE);
    result.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.ERROR);

    result.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
    result.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

    JavaCore.setComplianceOptions("1.8", result);

    return result;
}
项目:che    文件:AbstractRefactoringTestSetup.java   
protected void setUp() throws Exception {
  //        super.setUp();
  //        fWasAutobuild= CoreUtility.setAutoBuilding(false);
  //        if (JavaPlugin.getActivePage() != null)
  //            JavaPlugin.getActivePage().close();

  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
  options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0");
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(9999));

  JavaCore.setOptions(options);
  TestOptions.initializeCodeGenerationOptions();
  JavaPlugin.getDefault().getCodeTemplateStore().load();

  StringBuffer comment = new StringBuffer();
  comment.append("/**\n");
  comment.append(" * ${tags}\n");
  comment.append(" */");
  StubUtility.setCodeTemplate(
      CodeTemplateContextType.CONSTRUCTORCOMMENT_ID, comment.toString(), null);
}
项目:che    文件:UnresolvedTypesQuickFixTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = ProjectTestSetup.getProject();

  String newFileTemplate = "${package_declaration}\n\n${type_declaration}";
  StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID, newFileTemplate, null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:AdvancedQuickAssistTest18.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  fJProject1 = Java18ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:ConvertForLoopQuickFixTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
  fConvertLoopProposal = null;
}
项目:che    文件:ModifierCorrectionsQuickFixTest17.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE,
      JavaCore.DO_NOT_INSERT);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = Java17ProjectTestSetup.getProject();

  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:TypeMismatchQuickFixTests.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE,
      String.valueOf(99));
  options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
  options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:ModifierCorrectionsQuickFixTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE,
      JavaCore.DO_NOT_INSERT);
  options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
  options.put(JavaCore.COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, JavaCore.ERROR);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = ProjectTestSetup.getProject();

  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:AssistQuickFixTest18.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  fJProject1 = Java18ProjectTestSetup.getProject();
  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:ReturnTypeQuickFixTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:ReorgQuickFixTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.ERROR);
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:ConvertIterableLoopQuickFixTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fProject = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fProject, "src");
  fConvertLoopProposal = null;
}
项目:che    文件:AdvancedQuickAssistTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  //        Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences();
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:AdvancedQuickAssistTest17.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  //        Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences();
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

  fJProject1 = Java17ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:AssistQuickFixTest17.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  //        Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences();
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

  fJProject1 = Java17ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:CodeFormatterUtil.java   
/**
 * Gets the current tab width.
 *
 * @param project The project where the source is used, used for project specific options or
 *     <code>null</code> if the project is unknown and the workspace default should be used
 * @return The tab width
 */
public static int getTabWidth(IJavaProject project) {
  /*
   * If the tab-char is SPACE, FORMATTER_INDENTATION_SIZE is not used
   * by the core formatter.
   * We piggy back the visual tab length setting in that preference in
   * that case.
   */
  String key;
  if (JavaCore.SPACE.equals(
      getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
    key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
  else key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;

  return getCoreOption(project, key, 4);
}
项目:che    文件:RenameMethodProcessor.java   
protected final ReplaceEdit createReplaceEdit(SearchMatch searchResult, ICompilationUnit cu) {
  if (searchResult.isImplicit()) { // handle Annotation Element references, see bug 94062
    StringBuffer sb = new StringBuffer(getNewElementName());
    if (JavaCore.INSERT.equals(
        cu.getJavaProject()
            .getOption(
                DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR,
                true))) sb.append(' ');
    sb.append('=');
    if (JavaCore.INSERT.equals(
        cu.getJavaProject()
            .getOption(
                DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR,
                true))) sb.append(' ');
    return new ReplaceEdit(searchResult.getOffset(), 0, sb.toString());
  } else {
    return new ReplaceEdit(
        searchResult.getOffset(), searchResult.getLength(), getNewElementName());
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaSourceViewerConfiguration.java   
@Override
public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
        IJavaProject project= getProject();
    final int tabWidth= CodeFormatterUtil.getTabWidth(project);
    final int indentWidth= CodeFormatterUtil.getIndentWidth(project);
    boolean allowTabs= tabWidth <= indentWidth;

    String indentMode;
    if (project == null)
        indentMode= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
    else
        indentMode= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);

    boolean useSpaces= JavaCore.SPACE.equals(indentMode) || DefaultCodeFormatterConstants.MIXED.equals(indentMode);

    Assert.isLegal(allowTabs || useSpaces);

    if (!allowTabs) {
        char[] spaces= new char[indentWidth];
        Arrays.fill(spaces, ' ');
        return new String[] { new String(spaces), "" }; //$NON-NLS-1$
    } else if  (!useSpaces)
        return getIndentPrefixesForTab(tabWidth);
    else
        return getIndentPrefixesForSpaces(tabWidth);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BlankLinesTabPage.java   
@Override
protected void doCreatePreferences(Composite composite, int numColumns) {

    Group group;

    group= createGroup(numColumns, composite, FormatterMessages.BlankLinesTabPage_compilation_unit_group_title);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_before_package, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_after_package, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_before_import, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_IMPORTS);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_between_import_groups, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_IMPORT_GROUPS);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_after_import, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_compilation_unit_option_between_type_declarations, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS);

    group= createGroup(numColumns, composite, FormatterMessages.BlankLinesTabPage_class_group_title);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_first_decl, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_decls_of_same_kind, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_member_class_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_field_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_before_method_decls, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_METHOD);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_class_option_at_beginning_of_method_body, DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY);

    group= createGroup(numColumns, composite, FormatterMessages.BlankLinesTabPage_blank_lines_group_title);
    createBlankLineTextField(group, numColumns, FormatterMessages.BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve, DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE);
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
private void formatAnonymousTypeDeclaration(TypeDeclaration typeDeclaration) {
    /*
     * Type body
     */
    String anonymous_type_declaration_brace_position = this.preferences.brace_position_for_anonymous_type_declaration;

    formatTypeOpeningBrace(anonymous_type_declaration_brace_position, this.preferences.insert_space_before_opening_brace_in_anonymous_type_declaration, typeDeclaration);

    this.scribe.indent();

    formatTypeMembers(typeDeclaration);

    this.scribe.unIndent();
    if (this.preferences.insert_new_line_in_empty_anonymous_type_declaration) {
        this.scribe.printNewLine();
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE);
    if (anonymous_type_declaration_brace_position.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) {
        this.scribe.unIndent();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ProfileVersioner.java   
private static void version3to4(Map<String, String> oldSettings) {
    checkAndReplace(oldSettings,
        "org.eclipse.jdt.core.align_type_members_on_columns", //$NON-NLS-1$
        DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS);

    checkAndReplace(oldSettings,
        "org.eclipse.jdt.core.formatter.insert_space_after_comma__in_superinterfaces", //$NON-NLS-1$
        DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES);

    checkAndReplace(oldSettings,
        "org.eclipse.jdt.core.formatter.insert_space_before_comma__in_superinterfaces", //$NON-NLS-1$
        DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES);

    checkAndReplace(oldSettings,
        "org.eclipse.jdt.core.formatter.insert_space_between_empty_arguments_in_method_invocation", //$NON-NLS-1$
        DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaSourceViewerConfiguration.java   
@Override
public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
        IJavaProject project= getProject();
    final int tabWidth= CodeFormatterUtil.getTabWidth(project);
    final int indentWidth= CodeFormatterUtil.getIndentWidth(project);
    boolean allowTabs= tabWidth <= indentWidth;

    String indentMode;
    if (project == null)
        indentMode= JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
    else
        indentMode= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);

    boolean useSpaces= JavaCore.SPACE.equals(indentMode) || DefaultCodeFormatterConstants.MIXED.equals(indentMode);

    Assert.isLegal(allowTabs || useSpaces);

    if (!allowTabs) {
        char[] spaces= new char[indentWidth];
        Arrays.fill(spaces, ' ');
        return new String[] { new String(spaces), "" }; //$NON-NLS-1$
    } else if  (!useSpaces)
        return getIndentPrefixesForTab(tabWidth);
    else
        return getIndentPrefixesForSpaces(tabWidth);
}
项目:Eclipse-Postfix-Code-Completion    文件:WhiteSpaceOptions.java   
private void createBeforeOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {

        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_try, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY, TRY_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_synchronized, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);

        final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_member_function_declaration);
        createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
        createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);

        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);

        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_type_member, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, ANNOTATION_DECL_PREVIEW);

    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LineWrappingTabPage.java   
private void insertIntoMap(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap, Map<Object, Integer> forceMap, Category category) {
         final String value= fWorkingValues.get(category.key);
         Integer wrappingStyle;
         Integer indentStyle;
         Boolean forceWrapping;

         try {
             wrappingStyle= new Integer(DefaultCodeFormatterConstants.getWrappingStyle(value));
             indentStyle= new Integer(DefaultCodeFormatterConstants.getIndentStyle(value));
             forceWrapping= new Boolean(DefaultCodeFormatterConstants.getForceWrapping(value));
         } catch (IllegalArgumentException e) {
    forceWrapping= new Boolean(false);
    indentStyle= new Integer(DefaultCodeFormatterConstants.INDENT_DEFAULT);
    wrappingStyle= new Integer(DefaultCodeFormatterConstants.WRAP_NO_SPLIT);
}

         increaseMapEntry(wrappingMap, wrappingStyle);
         increaseMapEntry(indentMap, indentStyle);
         increaseMapEntry(forceMap, forceWrapping);
     }
项目:Eclipse-Postfix-Code-Completion    文件:WhiteSpaceOptions.java   
private void createAfterOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_try, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_TRY, TRY_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_synchronized, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);

      final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_member_function_declaration); {
          createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
          createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
      }
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);

      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
      createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
  }
项目:Eclipse-Postfix-Code-Completion    文件:WhiteSpaceOptions.java   
private InnerNode createForStatementTree(Map<String, String> workingValues, InnerNode parent) {
    final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_for);

    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR, FOR_PREVIEW);
    createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR, FOR_PREVIEW);

    return root;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:WhiteSpaceOptions.java   
private void createBeforeOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {

        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_try, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_TRY, TRY_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_synchronized, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);

        final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_member_function_declaration);
        createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_constructor, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
        createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_method, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);

        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);

        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_enum_constant_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT, ENUM_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_modifier_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION, ANNOTATION_MODIFIER_PREVIEW);
        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_annotation_type_member, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION, ANNOTATION_DECL_PREVIEW);

    }
项目:gw4e.project    文件:JDTManager.java   
/**
 * Format a Unit Source Code
 * 
 * @param testInterface
 * @param monitor
 * @throws CoreException 
 */
@SuppressWarnings("unchecked")
public static void formatUnitSourceCode(IFile file, IProgressMonitor monitor) throws CoreException {
    @SuppressWarnings("rawtypes")
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
    ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file);
    subMonitor.split(50);
    ICompilationUnit workingCopy = unit.getWorkingCopy(monitor);

    Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();

    options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
    options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_7);
    options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7);

    options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
            DefaultCodeFormatterConstants.createAlignmentValue(true,
                    DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE,
                    DefaultCodeFormatterConstants.INDENT_ON_COLUMN));

    final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options);
    ISourceRange range = unit.getSourceRange();
    TextEdit formatEdit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, unit.getSource(),
            range.getOffset(), range.getLength(), 0, null);
    subMonitor.split(30);
    if (formatEdit != null /* && formatEdit.hasChildren()*/) {
        workingCopy.applyTextEdit(formatEdit, monitor);
        workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null);
        workingCopy.commitWorkingCopy(true, null);
        workingCopy.discardWorkingCopy();
    }
    file.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
    subMonitor.split(20);
}
项目:aws-sdk-java-samples    文件:SamplesGenerator.java   
/**
 * Ctor.
 *
 * @param model
 *            service intermediate model containing generic samples
 */
public SamplesGenerator(final IntermediateModel model) {
    if (model == null) {
        throw new IllegalArgumentException("Intermediate model must be provided");
    }

    this.model = model;
    this.sb = new StringBuilder();

    Map formatterOptions = new HashMap();
    formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, false);
    this.formatter = new JavaCodeFormatter(formatterOptions);
}
项目:eclipse.jdt.ls    文件:FormatterHandler.java   
private static Map<String, String> getOptions(FormattingOptions options, ICompilationUnit cu) {
    Map<String, String> eclipseOptions = cu.getJavaProject().getOptions(true);
    Integer tabSize = options.getTabSize();
    if (tabSize != null) {
        int tSize = tabSize.intValue();
        if (tSize > 0) {
            eclipseOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, Integer.toString(tSize));
        }
    }
    boolean insertSpaces = options.isInsertSpaces();
    if (insertSpaces) {
        eclipseOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, insertSpaces ? JavaCore.SPACE : JavaCore.TAB);
    }
    return eclipseOptions;
}
项目:eclipse.jdt.ls    文件:PreferenceManager.java   
/**
 * Initialize default preference values of used bundles to match server
 * functionality.
 */
public void initialize() {
    // Update JavaCore options
    Hashtable<String, String> javaCoreOptions = JavaCore.getOptions();
    javaCoreOptions.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
    javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE);
    JavaCore.setOptions(javaCoreOptions);
}
项目:eclipse.jdt.ls    文件:TypeMismatchQuickFixTest.java   
@Before
public void setup() throws Exception {
    fJProject1 = newEmptyProject();
    Hashtable<String, String> options = TestOptions.getDefaultOptions();
    options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99));
    options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
    options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);
    fJProject1.setOptions(options);

    fSourceFolder = fJProject1.getPackageFragmentRoot(fJProject1.getProject().getFolder("src"));
}
项目:che    文件:ImportOrganizeTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  fJProject1 = ProjectTestSetup.getProject();

  Hashtable options = TestOptions.getDefaultOptions();
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE,
      String.valueOf(99));
  JavaCore.setOptions(options);
}
项目:che    文件:LocalCorrectionsQuickFixTest17.java   
@Before
@Override
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE,
      String.valueOf(99));
  options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
  options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);
  options.put(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD, JavaCore.WARNING);
  options.put(JavaCore.COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS, JavaCore.WARNING);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);

  fJProject1 = Java17ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:LocalCorrectionsQuickFixTest.java   
@Override
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE,
      String.valueOf(99));
  options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
  options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);
  options.put(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD, JavaCore.WARNING);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:AssistQuickFixTest.java   
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
  options.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
  options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
  options.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  //        Preferences corePrefs= JavaPlugin.getJavaCorePluginPreferences();
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
  //        corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
  new org.eclipse.jdt.core.JavaCore();
}
项目:che    文件:LocalCorrectionsQuickFixTest18.java   
@Override
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE,
      String.valueOf(99));
  options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
  options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);
  options.put(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD, JavaCore.WARNING);
  options.put(JavaCore.COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS, JavaCore.WARNING);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);

  fJProject1 = Java18ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
项目:che    文件:CheCodeFormatterOptions.java   
public static Map<String, String> getDefaultFormatSettings() {
  if (formatSettings != null && !formatSettings.isEmpty()) {
    return formatSettings;
  }

  formatSettings = new CheCodeFormatterOptions().getCheDefaultSettings();
  if (formatSettings != null && !formatSettings.isEmpty()) {
    return formatSettings;
  }
  return DefaultCodeFormatterConstants.getEclipseDefaultSettings();
}
项目:che    文件:CodeFormatterUtil.java   
/**
 * Returns the current indent width.
 *
 * @param project the project where the source is used or, <code>null</code> if the project is
 *     unknown and the workspace default should be used
 * @return the indent width
 * @since 3.1
 */
public static int getIndentWidth(IJavaProject project) {
  String key;
  if (DefaultCodeFormatterConstants.MIXED.equals(
      getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
    key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
  else key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;

  return getCoreOption(project, key, 4);
}
项目:che    文件:JavaIndenter.java   
private int prefArrayIndent() {
  String option =
      getCoreFormatterOption(
          DefaultCodeFormatterConstants
              .FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
  try {
    if (DefaultCodeFormatterConstants.getIndentStyle(option)
        == DefaultCodeFormatterConstants.INDENT_BY_ONE) return 1;
  } catch (IllegalArgumentException e) {
    // ignore and return default
  }

  return prefContinuationIndent(); // default
}