Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Fusier2010-05-06 09:31:26 +0000
committerFrederic Fusier2010-05-06 09:31:26 +0000
commit58a21b3d2616d159f34221d665afa8558d85a20d (patch)
tree4991cfd93069f1b4f2a81eec18ec37ddae67b9c4
parent333cce3a474faccc4d17ef2a5b6d1bc5d2ebc390 (diff)
downloadeclipse.jdt.core-58a21b3d2616d159f34221d665afa8558d85a20d.tar.gz
eclipse.jdt.core-58a21b3d2616d159f34221d665afa8558d85a20d.tar.xz
eclipse.jdt.core-58a21b3d2616d159f34221d665afa8558d85a20d.zip
HEAD - 311582
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html4
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java21
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java8
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java39
4 files changed, 50 insertions, 22 deletions
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index bcce293270..504c13bac0 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -69,7 +69,9 @@ See bug <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=311582">311582</a
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=307040">307040</a>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=311582">311582</a>
+[formatter] Master switch to enable/disable on/off tags
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=307040">307040</a>
Search Job with HierarchyScope on Object does not cancel
<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=302295">302295</a>
After associating source folder with rt.jar project refresh takes exceedingly long time.
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
index 2206996de6..e3694c3395 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
@@ -860,15 +860,29 @@ public class DefaultCodeFormatterConstants {
public static final String FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.continuation_indentation_for_array_initializer"; //$NON-NLS-1$
/**
* <pre>
+ * FORMATTER / Option to use the disabling and enabling tags defined respectively by the {@link #FORMATTER_DISABLING_TAG} and the {@link #FORMATTER_ENABLING_TAG} options.
+ * - option id: "org.eclipse.jdt.core.formatter.use_on_off_tags"
+ * - possible values: TRUE / FALSE
+ * - default: FALSE
+ * </pre>
+ * @since 3.6
+ */
+ public static final String FORMATTER_USE_ON_OFF_TAGS = JavaCore.PLUGIN_ID + ".formatter.use_on_off_tags"; //$NON-NLS-1$
+ /**
+ * <pre>
* FORMATTER / Option to define the tag to put in a comment to disable the formatting.
- * See the {@link #FORMATTER_ENABLING_TAG} option to re-enable it.
+ * - option id: "org.eclipse.jdt.core.formatter.disabling_tag"
* - possible values: String, with constraints mentioned below
* - default: ""
+ *
+ * See the {@link #FORMATTER_ENABLING_TAG} option to re-enable it.
* </pre>
*
* <p>
* Note that:
* <ol>
+ * <li>This tag is used by the formatter only if the
+ * {@link #FORMATTER_USE_ON_OFF_TAGS} option is set to {@link #TRUE}.</li>
* <li>The tag name will be trimmed. Hence if it does contain white spaces
* at the beginning or at the end, they will not be taken into account while
* searching for the tag in the comments</li>
@@ -945,8 +959,7 @@ public class DefaultCodeFormatterConstants {
public static final String FORMATTER_DISABLING_TAG = JavaCore.PLUGIN_ID + ".formatter.disabling_tag"; //$NON-NLS-1$
/**
* <pre>
- * FORMATTER / Option to define the tag to put in a comment to re-enable the
- * formatting after it has been disabled (see {@link #FORMATTER_DISABLING_TAG})
+ * FORMATTER / Option to define the tag to put in a comment to re-enable the formatting after it has been disabled (see {@link #FORMATTER_DISABLING_TAG})
* - option id: "org.eclipse.jdt.core.formatter.enabling_tag"
* - possible values: String, with constraints mentioned below
* - default: ""
@@ -955,6 +968,8 @@ public class DefaultCodeFormatterConstants {
* <p>
* Note that:
* <ol>
+ * <li>This tag is used by the formatter only if the
+ * {@link #FORMATTER_USE_ON_OFF_TAGS} option is set to {@link #TRUE}.</li>
* <li>The tag name will be trimmed. Hence if it does contain white spaces
* at the beginning or at the end, they will not be taken into account while
* searching for the tag in the comments</li>
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
index 2ff67d833b..3f2c890f76 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
@@ -117,6 +117,7 @@ public class DefaultCodeFormatterOptions {
public boolean comment_insert_new_line_for_parameter;
public int comment_line_length;
+ public boolean use_tags;
public char[] disabling_tag;
public char[] enabling_tag;
@@ -618,6 +619,7 @@ public class DefaultCodeFormatterOptions {
options.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_BEFORE_BINARY_OPERATOR, this.wrap_before_binary_operator ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
options.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, this.disabling_tag == null ? Util.EMPTY_STRING : new String(this.disabling_tag));
options.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, this.enabling_tag == null ? Util.EMPTY_STRING : new String(this.enabling_tag));
+ options.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, this.use_tags ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
return options;
}
@@ -1955,6 +1957,10 @@ public class DefaultCodeFormatterOptions {
if (wrapBeforeBinaryOperatorOption != null) {
this.wrap_before_binary_operator = DefaultCodeFormatterConstants.TRUE.equals(wrapBeforeBinaryOperatorOption);
}
+ final Object useTags = settings.get(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS);
+ if (useTags != null) {
+ this.use_tags = DefaultCodeFormatterConstants.TRUE.equals(useTags);
+ }
final Object disableTagOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG);
if (disableTagOption != null) {
if (disableTagOption instanceof String) {
@@ -2299,6 +2305,7 @@ public class DefaultCodeFormatterOptions {
this.tab_char = TAB; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49081
this.use_tabs_only_for_leading_indentations = false;
this.wrap_before_binary_operator = true;
+ this.use_tags = false;
}
public void setEclipseDefaultSettings() {
@@ -2570,5 +2577,6 @@ public class DefaultCodeFormatterOptions {
this.tab_char = MIXED;
this.use_tabs_only_for_leading_indentations = false;
this.wrap_before_binary_operator = true;
+ this.use_tags = false;
}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
index 83ea953398..cbfc7fb41f 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
@@ -106,7 +106,8 @@ public class Scribe implements IJavaDocTagConstants {
int blank_lines_between_import_groups = -1;
/** disabling */
- boolean editsEnabled = true;
+ boolean editsEnabled;
+ boolean useTags;
/* Comments formatting */
private static final int INCLUDE_BLOCK_COMMENTS = CodeFormatter.F_INCLUDE_COMMENTS | CodeFormatter.K_MULTI_LINE_COMMENT;
@@ -1382,21 +1383,23 @@ public class Scribe implements IJavaDocTagConstants {
}
private void initializeScanner(long sourceLevel, DefaultCodeFormatterOptions preferences) {
- this.disablingTag = preferences.disabling_tag;
- this.enablingTag = preferences.enabling_tag;
- char[][] taskTags;
- if (this.disablingTag == null) {
- if (this.enablingTag == null) {
- taskTags = null;
+ this.useTags = preferences.use_tags;
+ char[][] taskTags = null;
+ if (this.useTags) {
+ this.disablingTag = preferences.disabling_tag;
+ this.enablingTag = preferences.enabling_tag;
+ if (this.disablingTag == null) {
+ if (this.enablingTag != null) {
+ taskTags = new char[][] { this.enablingTag };
+ }
+ } else if (this.enablingTag == null) {
+ taskTags = new char[][] { this.disablingTag };
} else {
- taskTags = new char[][] { this.enablingTag };
+ taskTags = new char[][] { this.disablingTag, this.enablingTag };
}
- } else if (this.enablingTag == null) {
- taskTags = new char[][] { this.disablingTag };
- } else {
- taskTags = new char[][] { this.disablingTag, this.enablingTag };
}
this.scanner = new Scanner(true, true, false/*nls*/, sourceLevel/*sourceLevel*/, taskTags, null/*taskPriorities*/, true/*taskCaseSensitive*/);
+ this.editsEnabled = true;
}
private void initFormatterCommentParser() {
@@ -2453,7 +2456,7 @@ public class Scribe implements IJavaDocTagConstants {
currentTokenStartPosition = this.scanner.currentPosition;
break;
case TerminalTokens.TokenNameCOMMENT_LINE :
- if (this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
+ if (this.useTags && this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
setEditsEnabled(foundTaskCount, previousFoundTaskCount);
if (!this.editsEnabled && this.editsIndex > 1) {
OptimizedReplaceEdit currentEdit = this.edits[this.editsIndex-1];
@@ -2478,12 +2481,12 @@ public class Scribe implements IJavaDocTagConstants {
currentTokenStartPosition = this.scanner.currentPosition;
hasLineComment = true;
lines = 0;
- if (!this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
+ if (this.useTags && !this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
setEditsEnabled(foundTaskCount, previousFoundTaskCount);
}
break;
case TerminalTokens.TokenNameCOMMENT_BLOCK :
- if (this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
+ if (this.useTags && this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
setEditsEnabled(foundTaskCount, previousFoundTaskCount);
if (!this.editsEnabled && this.editsIndex > 1) {
OptimizedReplaceEdit currentEdit = this.edits[this.editsIndex-1];
@@ -2515,12 +2518,12 @@ public class Scribe implements IJavaDocTagConstants {
hasLineComment = false;
hasComment = true;
lines = 0;
- if (!this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
+ if (this.useTags && !this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
setEditsEnabled(foundTaskCount, previousFoundTaskCount);
}
break;
case TerminalTokens.TokenNameCOMMENT_JAVADOC :
- if (this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
+ if (this.useTags && this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
setEditsEnabled(foundTaskCount, previousFoundTaskCount);
if (!this.editsEnabled && this.editsIndex > 1) {
OptimizedReplaceEdit currentEdit = this.edits[this.editsIndex-1];
@@ -2552,7 +2555,7 @@ public class Scribe implements IJavaDocTagConstants {
} else {
printBlockComment(true);
}
- if (!this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
+ if (this.useTags && !this.editsEnabled && foundTaskCount > previousFoundTaskCount) {
setEditsEnabled(foundTaskCount, previousFoundTaskCount);
}
printNewLine();

Back to the top