• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

PHP Code Formatter (concluded)


Commit MetaInfo

Revision2217ff195d898085919831f31316a217d6e5e32a (tree)
Time2014-08-27 13:01:54
AuthorHiroaki Kamei <kmtr@outl...>
CommiterHiroaki Kamei

Log Message

PHPDOC indent option

Change Summary

Incremental Difference

--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/OutputBuffer.java
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/OutputBuffer.java
@@ -77,6 +77,28 @@ public class OutputBuffer {
7777 return this;
7878 }
7979
80+ public OutputBuffer appendNoIndent(String str) {
81+ if (str.equals("")) {
82+ return this;
83+ }
84+ if (Utils.hasCrLf(str)) {
85+ str = Utils.convertCrLf(str);
86+ String[] strings = str.split("\\n");
87+ for (int i = 0; i < strings.length; i++) {
88+ append(strings[i]);
89+ if (i < strings.length - 1) {
90+ newLine();
91+ }
92+ }
93+ if (str.endsWith("\n")) {
94+ newLine();
95+ }
96+ } else {
97+ lineBuffer.append(str);
98+ }
99+ return this;
100+ }
101+
80102 public OutputBuffer appendRaw(String str, boolean head) {
81103 if (str.equals("")) {
82104 return this;
@@ -102,6 +124,29 @@ public class OutputBuffer {
102124 return this;
103125 }
104126
127+
128+ public OutputBuffer appendRawNoIndent(String str, boolean head) {
129+ if (str.equals("")) {
130+ return this;
131+ }
132+ if (Utils.hasCrLf(str)) {
133+ str = Utils.convertCrLf(str);
134+ String[] strings = str.split("\\n");
135+ for (int i = 0; i < strings.length; i++) {
136+ lineBuffer.append(strings[i]);
137+ if (i < strings.length - 1) {
138+ newLine(true);
139+ }
140+ }
141+ if (str.endsWith("\n")) {
142+ newLine(true);
143+ }
144+ } else {
145+ lineBuffer.append(str);
146+ }
147+ return this;
148+ }
149+
105150 public OutputBuffer join(String str) {
106151 if (lineBuffer.toString().trim().length() == 0) {
107152 int index = outputBuffer.size() - 1;
--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/core/ast/ASTFormatter.java
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/core/ast/ASTFormatter.java
@@ -280,9 +280,17 @@ public class ASTFormatter extends RunThroughVisitor {
280280 }
281281 }
282282 if (i > 0 && pos > 0) {
283- output.appendRaw(leader + s, false);
283+ if (options.indent_phpdoc_comment_indent) {
284+ output.appendRaw(leader + s, false);
285+ } else {
286+ output.appendRawNoIndent(s, false);
287+ }
284288 } else {
285- output.append(s);
289+ if (options.indent_phpdoc_comment_indent) {
290+ output.append(s);
291+ } else {
292+ output.appendNoIndent(s);
293+ }
286294 }
287295 if (i < strings.length - 1) {
288296 output.newLine(true);
--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/core/formatter/CodeFormatterConstants.java
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/core/formatter/CodeFormatterConstants.java
@@ -1488,6 +1488,20 @@ public class CodeFormatterConstants {
14881488
14891489 /**
14901490 * <pre>
1491+ * FORMATTER / Option to indent php doc comment
1492+ * - option id: "org.eclipse.jdt.core.formatter.indent_php_doc_comment_indent"
1493+ * - possible values: { TRUE, FALSE }
1494+ * - default: TRUE
1495+ * </pre>
1496+ * @see #TRUE
1497+ * @see #FALSE
1498+ * @since 3.0
1499+ */
1500+ public final static String FORMATTER_INDENT_PHPDOC_COMMENT_INDENT = FormatterPlugin.OPTION_ID
1501+ + ".formatter.indent_phpdoc_comment_indent"; //$NON-NLS-1$
1502+
1503+ /**
1504+ * <pre>
14911505 * FORMATTER / Option to specify the equivalent number of spaces that represents one indentation
14921506 * - option id: "org.eclipse.jdt.core.formatter.indentation.size"
14931507 * - possible values: "&lt;n&gt;", where n is zero or a positive integer
--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/core/formatter/CodeFormatterOptions.java
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/core/formatter/CodeFormatterOptions.java
@@ -102,6 +102,7 @@ public class CodeFormatterOptions {
102102 public boolean indent_body_declarations_compare_to_type_header;
103103 public boolean indent_breaks_compare_to_cases;
104104 public boolean indent_empty_lines;
105+ public boolean indent_phpdoc_comment_indent;
105106 public boolean indent_switchstatements_compare_to_cases;
106107 public boolean indent_switchstatements_compare_to_switch;
107108 public int indentation_size;
@@ -515,6 +516,9 @@ public class CodeFormatterOptions {
515516 options.put(CodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES,
516517 this.indent_empty_lines ? CodeFormatterConstants.TRUE
517518 : CodeFormatterConstants.FALSE);
519+ options.put(CodeFormatterConstants.FORMATTER_INDENT_PHPDOC_COMMENT_INDENT,
520+ this.indent_phpdoc_comment_indent ? CodeFormatterConstants.TRUE
521+ : CodeFormatterConstants.FALSE);
518522 options.put(
519523 CodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES,
520524 this.indent_switchstatements_compare_to_cases ? CodeFormatterConstants.TRUE
@@ -1869,6 +1873,12 @@ public class CodeFormatterOptions {
18691873 this.indent_breaks_compare_to_cases = CodeFormatterConstants.TRUE
18701874 .equals(indentBreaksCompareToCasesOption);
18711875 }
1876+ final Object indentCommentBlocksHasIndent = settings
1877+ .get(CodeFormatterConstants.FORMATTER_INDENT_PHPDOC_COMMENT_INDENT);
1878+ if (indentCommentBlocksHasIndent != null) {
1879+ this.indent_phpdoc_comment_indent = CodeFormatterConstants.TRUE
1880+ .equals(indentCommentBlocksHasIndent);
1881+ }
18721882 final Object indentEmptyLinesOption = settings
18731883 .get(CodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES);
18741884 if (indentEmptyLinesOption != null) {
@@ -3157,6 +3167,7 @@ public class CodeFormatterOptions {
31573167 this.blank_lines_before_imports = 1;
31583168 this.blank_lines_before_member_type = 1;
31593169 this.blank_lines_before_method = 0;
3170+ this.indent_phpdoc_comment_indent = true;
31603171 this.blank_lines_before_new_chunk = 1;
31613172 this.blank_lines_before_package = 0;
31623173 this.blank_lines_between_import_groups = 1;
--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/FormatterMessages.java
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/FormatterMessages.java
@@ -373,6 +373,7 @@ final class FormatterMessages extends NLS {
373373 public static String IndentationTabPage_switch_group_option_indent_break_statements;
374374 public static String IndentationTabPage_indent_empty_lines;
375375 public static String IndentationTabPage_use_tabs_only_for_leading_indentations;
376+ public static String IndentationTabPage_phpdoc_comment_indent;
376377
377378 public static String OffOnTagsTabPage_description;
378379 public static String OffOnTagsTabPage_enableOffOnTags;
--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/FormatterMessages.properties
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/FormatterMessages.properties
@@ -568,3 +568,5 @@ WhiteSpaceOptions_trait_use=Trait 'use'
568568 WhiteSpaceTabPage_trait_use=Trait 'use'
569569 WhiteSpaceTabPage_before_comma_in_trait_use=Before comma in trait 'use'
570570 WhiteSpaceTabPage_after_comma_in_trait_use=After comma in trait 'use'
571+
572+IndentationTabPage_phpdoc_comment_indent=Indent PHPDOC comment
--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/FormatterMessages_ja.properties
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/FormatterMessages_ja.properties
@@ -383,3 +383,5 @@ WhiteSpaceOptions_trait_use=Trait 'use'
383383 WhiteSpaceTabPage_trait_use=Trait 'use'
384384 WhiteSpaceTabPage_before_comma_in_trait_use=Trait\u306E'use'\u6587\u306E\u30AB\u30F3\u30DE\u306E\u524D
385385 WhiteSpaceTabPage_after_comma_in_trait_use=Trait\u306E'use'\u6587\u306E\u30AB\u30F3\u30DE\u306E\u5F8C
386+
387+IndentationTabPage_phpdoc_comment_indent=PHPDOC\u3092\u30a4\u30f3\u30c7\u30f3\u30c8\u3059\u308b
--- a/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/IndentationTabPage.java
+++ b/pdt_tools.formatter/src/jp/sourceforge/pdt_tools/formatter/internal/ui/preferences/formatter/IndentationTabPage.java
@@ -30,6 +30,9 @@ public class IndentationTabPage extends FormatterTabPage {
3030 "var $theInt=1;" + //$NON-NLS-1$
3131 "var $someString=\"Hello\";" + //$NON-NLS-1$
3232 "var $aDouble=3.0;\n\n" + //$NON-NLS-1$
33+ "/**\n" + //$NON-NLS-1$
34+ " * PHP DOC\n" + //$NON-NLS-1$
35+ " */\n" + //$NON-NLS-1$
3336 "function foo() {" + //$NON-NLS-1$
3437 "switch($a){" + //$NON-NLS-1$
3538 "case 0:" + //$NON-NLS-1$
@@ -177,6 +180,11 @@ public class IndentationTabPage extends FormatterTabPage {
177180 createCheckboxPref(classGroup, numColumns,
178181 FormatterMessages.IndentationTabPage_indent_empty_lines,
179182 CodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, FALSE_TRUE);
183+
184+ //with comment indent pref
185+ createCheckboxPref(classGroup, numColumns,
186+ FormatterMessages.IndentationTabPage_phpdoc_comment_indent,
187+ CodeFormatterConstants.FORMATTER_INDENT_PHPDOC_COMMENT_INDENT, FALSE_TRUE);
180188 }
181189
182190 public void initializePage() {