From c2e642f7dbc8268d2be54ecdf1848b83b2de1460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= Date: Sun, 1 Oct 2023 23:04:07 +0200 Subject: [PATCH] Format java files in o.e.equinox.bidi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was achieved by running: eclipse -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \ -config .settings/org.eclipse.jdt.core.prefs . -data `mktemp -d` Signed-off-by: Torbjörn SVENSSON --- .../equinox/bidi/StructuredTextProcessor.java | 123 ++--- .../StructuredTextTypeHandlerFactory.java | 58 ++- .../bidi/advanced/IStructuredTextExpert.java | 332 ++++++------ .../advanced/StructuredTextEnvironment.java | 114 ++--- .../advanced/StructuredTextExpertFactory.java | 151 +++--- .../bidi/custom/StructuredTextCharTypes.java | 90 ++-- .../bidi/custom/StructuredTextOffsets.java | 26 +- .../custom/StructuredTextTypeHandler.java | 473 +++++++++--------- .../internal/StructuredTextActivator.java | 11 +- .../bidi/internal/StructuredTextDelims.java | 63 +-- .../internal/StructuredTextDelimsEsc.java | 40 +- .../bidi/internal/StructuredTextImpl.java | 96 ++-- .../bidi/internal/StructuredTextSingle.java | 46 +- .../internal/StructuredTextStringRecord.java | 192 +++---- .../StructuredTextTypesCollector.java | 12 +- .../consumable/StructuredTextComma.java | 7 +- .../consumable/StructuredTextEmail.java | 24 +- .../consumable/StructuredTextFile.java | 2 +- .../consumable/StructuredTextJava.java | 149 +++--- .../consumable/StructuredTextRegex.java | 230 +++++---- .../consumable/StructuredTextSql.java | 179 +++---- .../consumable/StructuredTextURL.java | 2 +- .../consumable/StructuredTextUnderscore.java | 11 +- .../consumable/StructuredTextXPath.java | 6 +- 24 files changed, 1254 insertions(+), 1183 deletions(-) diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextProcessor.java index 7330a018e06..0dfedb18633 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextProcessor.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextProcessor.java @@ -17,25 +17,25 @@ import org.eclipse.equinox.bidi.custom.StructuredTextTypeHandler; /** - * Provides methods to process bidirectional text with a specific - * structure. The methods in this class are the most straightforward - * way to add directional formatting characters to the source text to - * ensure correct presentation, or to remove those characters to - * restore the original text - * (for more explanations, please see the - * {@link org.eclipse.equinox.bidi package documentation}. + * Provides methods to process bidirectional text with a specific structure. The + * methods in this class are the most straightforward way to add directional + * formatting characters to the source text to ensure correct presentation, or + * to remove those characters to restore the original text (for more + * explanations, please see the {@link org.eclipse.equinox.bidi package + * documentation}. *

- * This class can be used without OSGi running (but only the structured text types declared - * in {@link StructuredTextTypeHandlerFactory} are available in that mode). + * This class can be used without OSGi running (but only the structured text + * types declared in {@link StructuredTextTypeHandlerFactory} are available in + * that mode). *

* - * @noinstantiate This class is not intended to be instantiated by clients. + * @noinstantiate This class is not intended to be instantiated by clients. */ public final class StructuredTextProcessor { /** - * The default set of separators used to segment a string: dot, - * colon, slash, backslash. + * The default set of separators used to segment a string: dot, colon, slash, + * backslash. */ private static final String defaultSeparators = ".:/\\"; //$NON-NLS-1$ @@ -60,23 +60,24 @@ private StructuredTextProcessor() { /** * Processes the given (lean) text and returns a string with appropriate - * directional formatting characters (full text). This is equivalent to - * calling {@link #process(String str, String separators)} with the default - * set of separators. + * directional formatting characters (full text). This is equivalent to + * calling {@link #process(String str, String separators)} with the default set + * of separators. *

- * The processing adds directional formatting characters so that presentation + * The processing adds directional formatting characters so that presentation * using the Unicode Bidirectional Algorithm will provide the expected result. - * The text is segmented according to the provided separators. - * Each segment has the Unicode Bidi Algorithm applied to it, - * but as a whole, the string is oriented left to right. - *

+ * The text is segmented according to the provided separators. Each segment has + * the Unicode Bidi Algorithm applied to it, but as a whole, the string is + * oriented left to right. + *

+ *

* For example, a file path such as d:\myfolder\FOLDER\MYFILE.java * (where capital letters indicate RTL text) should render as * d:\myfolder\REDLOF\ELIFYM.java. *

* * @param str the lean text to process - * + * * @return the processed string (full text) * * @see #deprocess(String) @@ -86,11 +87,11 @@ public static String process(String str) { } /** - * Processes a string that has a particular semantic meaning to render - * it correctly in bidi environments. - * For more details, see {@link #process(String)}. + * Processes a string that has a particular semantic meaning to render it + * correctly in bidi environments. For more details, see + * {@link #process(String)}. * - * @param str the lean text to process + * @param str the lean text to process * @param separators characters by which the string will be segmented * * @return the processed string (full text) @@ -105,11 +106,12 @@ public static String process(String str, String separators) { if (str.charAt(0) == LRE && str.charAt(str.length() - 1) == PDF) return str; - StructuredTextEnvironment env = new StructuredTextEnvironment(null, false, StructuredTextEnvironment.ORIENT_UNKNOWN); + StructuredTextEnvironment env = new StructuredTextEnvironment(null, false, + StructuredTextEnvironment.ORIENT_UNKNOWN); // do not process a string if all the following conditions are true: - // a) it has no RTL characters - // b) it starts with a LTR character - // c) it ends with a LTR character or a digit + // a) it has no RTL characters + // b) it starts with a LTR character + // c) it ends with a LTR character or a digit boolean isStringBidi = false; int strLength = str.length(); char c; @@ -139,17 +141,17 @@ public static String process(String str, String separators) { } /** - * Processes a string that has a particular semantic meaning to render - * it correctly in bidi environments. - * For more details, see {@link #process(String)}. + * Processes a string that has a particular semantic meaning to render it + * correctly in bidi environments. For more details, see + * {@link #process(String)}. + * + * @param str the lean text to process. + * @param textType an identifier for the structured text handler appropriate for + * the type of the text submitted. It may be one of the + * identifiers defined in + * {@link StructuredTextTypeHandlerFactory} or a type handler + * identifier registered by a plug-in. * - * @param str the lean text to process. - * @param textType an identifier for the structured text handler - * appropriate for the type of the text submitted. - * It may be one of the identifiers defined in - * {@link StructuredTextTypeHandlerFactory} or a type handler identifier - * registered by a plug-in. - * * @return the processed string (full text). * * @see #deprocessTyped @@ -164,7 +166,8 @@ public static String processTyped(String str, String textType) { return str; // make sure that LRE/PDF are added around the string - StructuredTextEnvironment env = new StructuredTextEnvironment(null, false, StructuredTextEnvironment.ORIENT_UNKNOWN); + StructuredTextEnvironment env = new StructuredTextEnvironment(null, false, + StructuredTextEnvironment.ORIENT_UNKNOWN); IStructuredTextExpert expert = StructuredTextExpertFactory.getExpert(textType, env); return expert.leanToFullText(str); } @@ -172,7 +175,7 @@ public static String processTyped(String str, String textType) { /** * Removes directional formatting characters in the given string. * - * @param str string with directional characters to remove (full text). + * @param str string with directional characters to remove (full text). * * @return string without directional formatting characters (lean text). */ @@ -185,14 +188,14 @@ public static String deprocess(String str) { for (int i = 0; i < strLen; i++) { char c = str.charAt(i); switch (c) { - case LRM : - continue; - case LRE : - continue; - case PDF : - continue; - default : - buf.append(c); + case LRM: + continue; + case LRE: + continue; + case PDF: + continue; + default: + buf.append(c); } } return buf.toString(); @@ -201,13 +204,14 @@ public static String deprocess(String str) { /** * Removes directional formatting characters in the given string. * - * @param str string with directional characters to remove (full text). - * @param textType an identifier for the structured text handler - * appropriate for the type of the text submitted. - * It may be one of the identifiers defined in - * {@link StructuredTextTypeHandlerFactory} or a type handler identifier - * registered by a plug-in. - * + * @param str string with directional characters to remove (full + * text). + * @param textType an identifier for the structured text handler appropriate for + * the type of the text submitted. It may be one of the + * identifiers defined in + * {@link StructuredTextTypeHandlerFactory} or a type handler + * identifier registered by a plug-in. + * * @return string without directional formatting characters (lean text). * * @see #processTyped(String, String) @@ -217,14 +221,15 @@ public static String deprocessTyped(String str, String textType) { return str; // make sure that LRE/PDF are removed from the string - StructuredTextEnvironment env = new StructuredTextEnvironment(null, false, StructuredTextEnvironment.ORIENT_UNKNOWN); + StructuredTextEnvironment env = new StructuredTextEnvironment(null, false, + StructuredTextEnvironment.ORIENT_UNKNOWN); IStructuredTextExpert expert = StructuredTextExpertFactory.getExpert(textType, env); return expert.fullToLeanText(str); } /** - * Returns a string containing all the default separator characters to be - * used to segment a given string. + * Returns a string containing all the default separator characters to be used + * to segment a given string. * * @return string containing all separators. */ diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextTypeHandlerFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextTypeHandlerFactory.java index da9bffcd1e6..4363c433a28 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextTypeHandlerFactory.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/StructuredTextTypeHandlerFactory.java @@ -24,28 +24,31 @@ * A structured text handler is a subclass of {@link StructuredTextTypeHandler} * adapted for a given type of structured text. *

- * The constants in this class are identifiers for structured text - * handlers which are defined and supported "out of the box" by this package. - * Text handler identifiers can be used when invoking {@link StructuredTextProcessor#processTyped(String, String)}, - * or when invoking getExpert methods in {@link StructuredTextExpertFactory}. + * The constants in this class are identifiers for structured text handlers + * which are defined and supported "out of the box" by this package. Text + * handler identifiers can be used when invoking + * {@link StructuredTextProcessor#processTyped(String, String)}, or when + * invoking getExpert methods in + * {@link StructuredTextExpertFactory}. *

- * The {@link #getHandler} method in this class can be used to get a - * structured text handler reference for one of the handlers defined in this - * package or for additional structured text handlers registered by plug-ins via - * the org.eclipse.equinox.bidi.bidiTypes extension point. - * Text handler references can be used when invoking + * The {@link #getHandler} method in this class can be used to get a structured + * text handler reference for one of the handlers defined in this package or for + * additional structured text handlers registered by plug-ins via the + * org.eclipse.equinox.bidi.bidiTypes extension point. Text handler + * references can be used when invoking * {@link StructuredTextExpertFactory#getStatefulExpert(StructuredTextTypeHandler, StructuredTextEnvironment)}. *

- * This class can be used without OSGi running, but only the structured text types declared - * as string constants in this class are available in that mode. + * This class can be used without OSGi running, but only the structured text + * types declared as string constants in this class are available in that mode. *

- * + * * @noinstantiate This class is not intended to be instantiated by clients. */ public final class StructuredTextTypeHandlerFactory { /** * Structured text handler identifier for comma-delimited lists, such as: + * *
 	 *  part1,part2,part3
 	 * 
@@ -63,28 +66,29 @@ public final class StructuredTextTypeHandlerFactory { public static final String FILE = "file"; //$NON-NLS-1$ /** - * Structured text handler identifier for Java code, - * possibly spanning multiple lines. + * Structured text handler identifier for Java code, possibly spanning multiple + * lines. */ public static final String JAVA = "java"; //$NON-NLS-1$ /** - * Structured text handler identifier for regular expressions, - * possibly spanning multiple lines. + * Structured text handler identifier for regular expressions, possibly spanning + * multiple lines. */ public static final String REGEX = "regex"; //$NON-NLS-1$ /** - * Structured text handler identifier for SQL statements, - * possibly spanning multiple lines. + * Structured text handler identifier for SQL statements, possibly spanning + * multiple lines. */ public static final String SQL = "sql"; //$NON-NLS-1$ /** - * Structured text handler identifier for compound names. It expects text to be made of one or more - * parts separated by underscores: + * Structured text handler identifier for compound names. It expects text to be + * made of one or more parts separated by underscores: + * *
-	 *  part1_part2_part3
+	 * part1_part2_part3
 	 * 
*/ public static final String UNDERSCORE = "underscore"; //$NON-NLS-1$ @@ -99,7 +103,8 @@ public final class StructuredTextTypeHandlerFactory { */ public static final String XPATH = "xpath"; //$NON-NLS-1$ - // *** New types must be added to StructuredTextTypesCollector#getDefaultTypeHandlers()! + // *** New types must be added to + // StructuredTextTypesCollector#getDefaultTypeHandlers()! /** * Prevents instantiation @@ -113,14 +118,15 @@ private StructuredTextTypeHandlerFactory() { * * Supported type ids are: * * * @param id the string identifying a structured text handler - * @return a handler of the required type, or null - * if the type is unknown + * @return a handler of the required type, or null if the type is + * unknown */ static public StructuredTextTypeHandler getHandler(String id) { return StructuredTextTypesCollector.getInstance().getHandler(id); diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/IStructuredTextExpert.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/IStructuredTextExpert.java index f5d62804202..04a9f48a801 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/IStructuredTextExpert.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/IStructuredTextExpert.java @@ -16,64 +16,72 @@ import org.eclipse.equinox.bidi.custom.StructuredTextTypeHandler; /** - * Provides advanced methods for processing bidirectional text with - * a specific structure to ensure proper presentation. - * For a general introduction to structured text, see the - * {@link org.eclipse.equinox.bidi - * package documentation}. - * For details about when the advanced methods are needed, see - * {@link org.eclipse.equinox.bidi.advanced this - * package documentation}. + * Provides advanced methods for processing bidirectional text with a specific + * structure to ensure proper presentation. For a general introduction to + * structured text, see the {@link org.eclipse.equinox.bidi package + * documentation}. For details about when the advanced methods are needed, see + * {@link org.eclipse.equinox.bidi.advanced this package documentation}. *

- * Identifiers for several common handlers are included in - * {@link org.eclipse.equinox.bidi.StructuredTextTypeHandlerFactory}. For handlers - * supplied by other packages, a handler instance can be obtained using the + * Identifiers for several common handlers are included in + * {@link org.eclipse.equinox.bidi.StructuredTextTypeHandlerFactory}. For + * handlers supplied by other packages, a handler instance can be obtained using + * the * {@link org.eclipse.equinox.bidi.StructuredTextTypeHandlerFactory#getHandler} * method for the registered handlers, or by instantiating a private handler. - *

- * Most of the methods in this interface have a text - * argument which may be just a part of a larger body of text. - * When it is the case that the text is submitted in parts with - * repeated calls, there may be a need to pass information from - * one invocation to the next one. For instance, one invocation - * may detect that a comment or a literal has been started but - * has not been completed. In such cases, the state must be managed - * by a {@link IStructuredTextExpert} instance obtained with the + *

+ *

+ * Most of the methods in this interface have a text argument which + * may be just a part of a larger body of text. When it is the case that the + * text is submitted in parts with repeated calls, there may be a need to pass + * information from one invocation to the next one. For instance, one invocation + * may detect that a comment or a literal has been started but has not been + * completed. In such cases, the state must be managed by a + * {@link IStructuredTextExpert} instance obtained with the * {@link StructuredTextExpertFactory#getStatefulExpert} method. - *

- * The state returned after processing a string - * can be retrieved, set and reset using the {@link #getState()}, - * {@link #setState(Object)} and {@link #clearState()} methods. - *

- * When submitting the initial part of a text, the state should be - * reset if it is not the first processing call for this - * {@link IStructuredTextExpert} instance. - *

- * Values returned by {@link #getState()} are opaque objects whose meaning - * is internal to the relevant structured type handler. These values can only - * be used in {@link #setState(Object)} calls to restore a state - * previously obtained after processing a given part of a text before - * processing the next part of the text. - *

- * Note that if the user does not modify the state, the state returned by - * a given processing call is automatically passed as initial state to the - * next processing call, provided that the expert is a stateful one. - *

+ *

+ *

+ * The state returned after processing a string can be retrieved, + * set and reset using the {@link #getState()}, {@link #setState(Object)} and + * {@link #clearState()} methods. + *

+ *

+ * When submitting the initial part of a text, the state should be reset if it + * is not the first processing call for this {@link IStructuredTextExpert} + * instance. + *

+ *

+ * Values returned by {@link #getState()} are opaque objects whose meaning is + * internal to the relevant structured type handler. These values can only be + * used in {@link #setState(Object)} calls to restore a state previously + * obtained after processing a given part of a text before processing the next + * part of the text. + *

+ *

+ * Note that if the user does not modify the state, the state returned by a + * given processing call is automatically passed as initial state to the next + * processing call, provided that the expert is a stateful one. + *

+ *

* Code Samples - *

+ *

+ *

* The following code shows how to transform a certain type of structured text - * (directory and file paths) in order to obtain the full - * text corresponding to the given lean text.

+ * (directory and file paths) in order to obtain the full text + * corresponding to the given lean text. + *

+ * *
- *   IStructuredTextExpert expert = StructuredTextExpertFactory.getExpert(StructuredTextTypeHandlerFactory.FILE);
- *   String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext";
- *   String fullText = expert.leanToFullText(leanText);
- *   System.out.println("full text = " + fullText);
+ * IStructuredTextExpert expert = StructuredTextExpertFactory.getExpert(StructuredTextTypeHandlerFactory.FILE);
+ * String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext";
+ * String fullText = expert.leanToFullText(leanText);
+ * System.out.println("full text = " + fullText);
  * 
*

- * The following code shows how to transform successive lines of Java - * code in order to obtain the full - * text corresponding to the lean text of each line.

+ * The following code shows how to transform successive lines of Java code in + * order to obtain the full text corresponding to the lean text of + * each line. + *

+ * *
  *   IStructuredTextExpert expert = StructuredTextExpertFactory.getStatefulExpert(StructuredTextTypeHandlerFactory.JAVA);
  *   String leanText = "int i = 3; // first Java statement";
@@ -88,27 +96,25 @@
 public interface IStructuredTextExpert {
 
 	/**
-	 *  Constant specifying that the base direction of a structured text is LTR.
-	 *  The base direction may depend on whether the GUI is
-	 *  {@link StructuredTextEnvironment#getMirrored mirrored} and
-	 *  may be different for Arabic and for Hebrew.
-	 *  This constant can appear as value returned by the
-	 *  {@link #getTextDirection} method.
+	 * Constant specifying that the base direction of a structured text is LTR. The
+	 * base direction may depend on whether the GUI is
+	 * {@link StructuredTextEnvironment#getMirrored mirrored} and may be different
+	 * for Arabic and for Hebrew. This constant can appear as value returned by the
+	 * {@link #getTextDirection} method.
 	 */
 	public static final int DIR_LTR = 0;
 
 	/**
-	 *  Constant specifying that the base direction of a structured text is RTL.
-	 *  The base direction may depend on whether the GUI is
-	 *  {@link StructuredTextEnvironment#getMirrored mirrored} and may
-	 *  may be different for Arabic and for Hebrew.
-	 *  This constant can appear as value returned by the
-	 *  {@link #getTextDirection} method.
+	 * Constant specifying that the base direction of a structured text is RTL. The
+	 * base direction may depend on whether the GUI is
+	 * {@link StructuredTextEnvironment#getMirrored mirrored} and may may be
+	 * different for Arabic and for Hebrew. This constant can appear as value
+	 * returned by the {@link #getTextDirection} method.
 	 */
 	public static final int DIR_RTL = 1;
 
 	/**
-	 * Obtains the structured type handler associated with this 
+	 * Obtains the structured type handler associated with this
 	 * IStructuredTextExpert instance.
 	 * 
 	 * @return the type handler instance.
@@ -116,153 +122,165 @@ public interface IStructuredTextExpert {
 	public StructuredTextTypeHandler getTypeHandler();
 
 	/**
-	 * Obtains the environment associated with this 
+	 * Obtains the environment associated with this
 	 * IStructuredTextExpert instance.
+	 * 
 	 * @return the environment instance.
 	 */
 	public StructuredTextEnvironment getEnvironment();
 
-	/** 
-	 * Adds directional formatting characters to a structured text
-	 * to ensure correct presentation.
+	/**
+	 * Adds directional formatting characters to a structured text to ensure correct
+	 * presentation.
 	 * 
 	 * @param text is the structured text string
 	 *
-	 * @return the structured text with directional formatting characters added to ensure 
-	 * correct presentation.
+	 * @return the structured text with directional formatting characters added to
+	 *         ensure correct presentation.
 	 */
 	public String leanToFullText(String text);
 
 	/**
-	 * Given a lean string, computes the positions of each of its
-	 * characters within the corresponding full string.
+	 * Given a lean string, computes the positions of each of its characters
+	 * within the corresponding full string.
 	 *
 	 * @param text is the structured text string.
 	 *
-	 * @return an array of integers with one element for each of the
-	 * characters in the text argument, equal to the offset
-	 * of the corresponding character in the full string.
+	 * @return an array of integers with one element for each of the characters in
+	 *         the text argument, equal to the offset of the
+	 *         corresponding character in the full string.
 	 */
 	public int[] leanToFullMap(String text);
 
 	/**
-	 * Given a lean string, computes the offsets of characters
-	 * before which directional formatting characters must be added
-	 * in order to ensure correct presentation.
+	 * Given a lean string, computes the offsets of characters before which
+	 * directional formatting characters must be added in order to ensure correct
+	 * presentation.
 	 * 

- * Only LRMs (for a string with LTR base direction) and RLMs (for - * a string with RTL base direction) are considered. Leading and - * trailing LRE, RLE and PDF which might be prefixed or suffixed - * depending on the {@link StructuredTextEnvironment#getOrientation orientation} of the - * GUI component used for display are not reflected in this method. + * Only LRMs (for a string with LTR base direction) and RLMs (for a string with + * RTL base direction) are considered. Leading and trailing LRE, RLE and PDF + * which might be prefixed or suffixed depending on the + * {@link StructuredTextEnvironment#getOrientation orientation} of the GUI + * component used for display are not reflected in this method. *

+ * * @param text is the structured text string * - * @return an array of offsets to the characters in the text argument - * before which directional marks must be added to ensure correct presentation. - * The offsets are sorted in ascending order. + * @return an array of offsets to the characters in the text + * argument before which directional marks must be added to ensure + * correct presentation. The offsets are sorted in ascending order. */ public int[] leanBidiCharOffsets(String text); /** - * Removes directional formatting characters which were added to a - * structured text string to ensure correct presentation. + * Removes directional formatting characters which were added to a structured + * text string to ensure correct presentation. * - * @param text is the structured text string including directional formatting characters. + * @param text is the structured text string including directional formatting + * characters. * - * @return the structured text string without directional formatting characters - * which might have been added by processing it with {@link #leanToFullText}. + * @return the structured text string without directional formatting characters + * which might have been added by processing it with + * {@link #leanToFullText}. * */ public String fullToLeanText(String text); /** - * Given a full string, computes the positions of each of its - * characters within the corresponding lean string. + * Given a full string, computes the positions of each of its characters + * within the corresponding lean string. * - * @param text is the structured text string including directional formatting characters. + * @param text is the structured text string including directional formatting + * characters. * - * @return an array of integers with one element for each of the - * characters in the text argument, equal to the offset - * of the corresponding character in the lean string. - * If there is no corresponding character in the lean string - * (because the specified character is a directional formatting character - * added when invoking {@link #leanToFullText}), - * the value returned for this character is -1. + * @return an array of integers with one element for each of the characters in + * the text argument, equal to the offset of the + * corresponding character in the lean string. If there is no + * corresponding character in the lean string (because the + * specified character is a directional formatting character added when + * invoking {@link #leanToFullText}), the value returned for this + * character is -1. */ public int[] fullToLeanMap(String text); /** - * Given a full string, returns the offsets of characters - * which are directional formatting characters that have been added - * in order to ensure correct presentation. + * Given a full string, returns the offsets of characters which are + * directional formatting characters that have been added in order to ensure + * correct presentation. *

- * LRMs (for a string with LTR base direction), RLMs (for a string with RTL base direction) - * are considered as well as leading and trailing LRE, RLE and PDF which might be prefixed - * or suffixed depending on the {@link StructuredTextEnvironment#getOrientation orientation} - * of the GUI component used for display. + * LRMs (for a string with LTR base direction), RLMs (for a string with RTL base + * direction) are considered as well as leading and trailing LRE, RLE and PDF + * which might be prefixed or suffixed depending on the + * {@link StructuredTextEnvironment#getOrientation orientation} of the GUI + * component used for display. *

- * @param text is the structured text string including directional formatting characters + * + * @param text is the structured text string including directional formatting + * characters * - * @return an array of offsets to the characters in the text argument which - * are directional formatting characters added to ensure correct presentation. The offsets - * are sorted in ascending order. + * @return an array of offsets to the characters in the text + * argument which are directional formatting characters added to ensure + * correct presentation. The offsets are sorted in ascending order. */ public int[] fullBidiCharOffsets(String text); - /** - * Adds directional marks to the given text before the characters - * specified in the given array of offsets. It can be used to add a prefix and/or - * a suffix of directional formatting characters. + /** + * Adds directional marks to the given text before the characters specified in + * the given array of offsets. It can be used to add a prefix and/or a suffix of + * directional formatting characters. *

- * The directional marks will be LRMs for structured text strings with LTR base + * The directional marks will be LRMs for structured text strings with LTR base * direction and RLMs for strings with RTL base direction. - *

- * If necessary, leading and trailing directional formatting characters - * (LRE, RLE and PDF) can be added depending on the value of the - * affix argument.

+ *

+ *

+ * If necessary, leading and trailing directional formatting characters (LRE, + * RLE and PDF) can be added depending on the value of the affix + * argument. + *

*
    - *
  • A value of 1 means that one LRM or RLM must be prefixed, depending - * on the direction. This is useful when the GUI component presenting - * this text has a contextual orientation.
  • - *
  • A value of 2 means that LRE+LRM or RLE+RLM must be prefixed, - * depending on the direction, and LRM+PDF or RLM+PDF must be - * suffixed, depending on the direction. - * This is useful if the GUI component presenting this text needs to - * have the text orientation explicitly specified.
  • - *
  • A value of 0 means that no prefix or suffix are needed.
  • + *
  • A value of 1 means that one LRM or RLM must be prefixed, depending on the + * direction. This is useful when the GUI component presenting this text has a + * contextual orientation.
  • + *
  • A value of 2 means that LRE+LRM or RLE+RLM must be prefixed, depending on + * the direction, and LRM+PDF or RLM+PDF must be suffixed, depending on the + * direction. This is useful if the GUI component presenting this text needs to + * have the text orientation explicitly specified.
  • + *
  • A value of 0 means that no prefix or suffix are needed.
  • *
+ * * @see IStructuredTextExpert#leanBidiCharOffsets(String) * - * @param text the structured text string - * @param offsets an array of offsets to characters in text - * before which an LRM or RLM will be inserted. - * The array must be sorted in ascending order without duplicates. - * This argument may be null if there are no marks to add. - * @param direction the base direction of the structured text. - * It must be one of the values {@link #DIR_LTR}, or - * {@link #DIR_RTL}. - * @param affixLength specifies the length of prefix and suffix - * which should be added to the result.
- * 0 means no prefix or suffix
- * 1 means one LRM or RLM as prefix and no suffix
- * 2 means 2 characters in both prefix and suffix. - * + * @param text the structured text string + * @param offsets an array of offsets to characters in text + * before which an LRM or RLM will be inserted. The array + * must be sorted in ascending order without duplicates. This + * argument may be null if there are no marks to + * add. + * @param direction the base direction of the structured text. It must be one + * of the values {@link #DIR_LTR}, or {@link #DIR_RTL}. + * @param affixLength specifies the length of prefix and suffix which should be + * added to the result.
+ * 0 means no prefix or suffix
+ * 1 means one LRM or RLM as prefix and no suffix
+ * 2 means 2 characters in both prefix and suffix. + * * @return a string corresponding to the source text with - * directional marks (LRMs or RLMs) added at the specified offsets, - * and directional formatting characters (LRE, RLE, PDF) added - * as prefix and suffix if so required. + * directional marks (LRMs or RLMs) added at the specified offsets, and + * directional formatting characters (LRE, RLE, PDF) added as prefix and + * suffix if so required. */ public String insertMarks(String text, int[] offsets, int direction, int affixLength); /** - * Get the base direction of a structured text. This base direction may depend on - * whether the text contains Arabic or Hebrew words. If the text contains both, - * the first Arabic or Hebrew letter in the text determines which is the governing script. + * Get the base direction of a structured text. This base direction may depend + * on whether the text contains Arabic or Hebrew words. If the text contains + * both, the first Arabic or Hebrew letter in the text determines which is the + * governing script. * - * @param text is the structured text string. + * @param text is the structured text string. * - * @return the base direction of the structured text, {@link #DIR_LTR} or {@link #DIR_RTL} + * @return the base direction of the structured text, {@link #DIR_LTR} or + * {@link #DIR_RTL} */ public int getTextDirection(String text); @@ -270,25 +288,25 @@ public interface IStructuredTextExpert { // Expert's state handling - can be used only for non-shared experts ////////////////////////////////////////////////////////////////////// /** - * Sets the state for the next text processing call. - * This method does nothing if the expert instance is not a stateful one. + * Sets the state for the next text processing call. This method does nothing if + * the expert instance is not a stateful one. * * @param state an object returned by a previous call to {@link #getState}. */ public void setState(Object state); /** - * Gets the state established by the last text processing call. - * This is null if the expert instance is not a stateful one, - * or if the last text processing call had nothing to pass to the next call. + * Gets the state established by the last text processing call. This is + * null if the expert instance is not a stateful one, or if the + * last text processing call had nothing to pass to the next call. * * @return the last established state. */ public Object getState(); /** - * Resets the state to initial. - * This method does nothing if the expert instance is not a stateful one. + * Resets the state to initial. This method does nothing if the expert instance + * is not a stateful one. */ public void clearState(); } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java index 001c315a6e8..df04f3207af 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextEnvironment.java @@ -17,23 +17,25 @@ import org.eclipse.equinox.bidi.internal.StructuredTextActivator; /** - * Describes the environment within which structured text strings are - * processed. It includes: - *
    - *
  • locale,
  • - *
  • desired orientation,
  • - *
  • text mirroring attributes.
  • - *
+ * Describes the environment within which structured text strings are processed. + * It includes: + *
    + *
  • locale,
  • + *
  • desired orientation,
  • + *
  • text mirroring attributes.
  • + *
*/ public class StructuredTextEnvironment { /** - * Specifies that a GUI component should display text Left-To-Right (value is 0). + * Specifies that a GUI component should display text Left-To-Right (value is + * 0). */ public static final int ORIENT_LTR = 0; /** - * Specifies that a GUI component should display text Right-To-Left (value is 1). + * Specifies that a GUI component should display text Right-To-Left (value is + * 1). */ public static final int ORIENT_RTL = 1; @@ -56,19 +58,19 @@ public class StructuredTextEnvironment { public static final int ORIENT_CONTEXTUAL_RTL = ORIENT_CONTEXTUAL | ORIENT_RTL; /** - * Used when the orientation of a GUI component is not known (value is 4). + * Used when the orientation of a GUI component is not known (value is 4). */ public static final int ORIENT_UNKNOWN = 1 << 2; /** - * Used to specify that no directional formatting characters - * should be added as prefix or suffix (value is 8). + * Used to specify that no directional formatting characters should be added as + * prefix or suffix (value is 8). */ public static final int ORIENT_IGNORE = 1 << 3; /** - * Pre-defined {@link StructuredTextEnvironment} instance which uses default locale, - * non-mirrored environment, and a Left-to-Right presentation component. + * Pre-defined {@link StructuredTextEnvironment} instance which uses default + * locale, non-mirrored environment, and a Left-to-Right presentation component. */ public static final StructuredTextEnvironment DEFAULT = new StructuredTextEnvironment(null, false, ORIENT_LTR); @@ -79,38 +81,36 @@ public class StructuredTextEnvironment { final private String language; /** - * Flag specifying that structured text processed under this environment - * should assume that the GUI is mirrored (globally going from right to left). + * Flag specifying that structured text processed under this environment should + * assume that the GUI is mirrored (globally going from right to left). */ final private boolean mirrored; /** - * Specify the orientation (a.k.a. base direction) of the GUI - * component in which the full structured text will - * be displayed. + * Specify the orientation (a.k.a. base direction) of the GUI component in which + * the full structured text will be displayed. */ final private int orientation; /** - * Cached value that determines if the Bidi processing is needed - * in this environment. + * Cached value that determines if the Bidi processing is needed in this + * environment. */ private Boolean processingNeeded; /** * Creates an instance of a structured text environment. * - * @param lang the language of the environment, encoded as specified - * in ISO-639. Might be null, in which case the default - * locale is used. - * @param mirrored specifies if the environment is mirrored. - * @param orientation the orientation of the GUI component, one of the values: - * {@link #ORIENT_LTR ORIENT_LTR}, - * {@link #ORIENT_LTR ORIENT_RTL}, - * {@link #ORIENT_CONTEXTUAL_LTR ORIENT_CONTEXTUAL_LTR}, - * {@link #ORIENT_CONTEXTUAL_RTL ORIENT_CONTEXTUAL_RTL}, - * {@link #ORIENT_UNKNOWN ORIENT_UNKNOWN}, or - * {@link #ORIENT_IGNORE ORIENT_IGNORE}. + * @param lang the language of the environment, encoded as specified in + * ISO-639. Might be null, in which case the + * default locale is used. + * @param mirrored specifies if the environment is mirrored. + * @param orientation the orientation of the GUI component, one of the values: + * {@link #ORIENT_LTR ORIENT_LTR}, {@link #ORIENT_LTR + * ORIENT_RTL}, {@link #ORIENT_CONTEXTUAL_LTR + * ORIENT_CONTEXTUAL_LTR}, {@link #ORIENT_CONTEXTUAL_RTL + * ORIENT_CONTEXTUAL_RTL}, {@link #ORIENT_UNKNOWN + * ORIENT_UNKNOWN}, or {@link #ORIENT_IGNORE ORIENT_IGNORE}. */ public StructuredTextEnvironment(String lang, boolean mirrored, int orientation) { if (lang != null) { @@ -119,7 +119,9 @@ public StructuredTextEnvironment(String lang, boolean mirrored, int orientation) else language = lang; } else { - Locale defaultLocale = StructuredTextActivator.getInstance() != null ? StructuredTextActivator.getInstance().getDefaultLocale() : Locale.getDefault(); + Locale defaultLocale = StructuredTextActivator.getInstance() != null + ? StructuredTextActivator.getInstance().getDefaultLocale() + : Locale.getDefault(); language = defaultLocale.getLanguage(); } this.mirrored = mirrored; @@ -127,8 +129,7 @@ public StructuredTextEnvironment(String lang, boolean mirrored, int orientation) } /** - * Returns a 2-letters code representing a language as defined by - * ISO-639. + * Returns a 2-letters code representing a language as defined by ISO-639. * * @return language of the environment */ @@ -137,20 +138,19 @@ public String getLanguage() { } /** - * Returns a flag indicating that structured text processed - * within this environment should assume that the GUI is mirrored - * (globally going from right to left). + * Returns a flag indicating that structured text processed within this + * environment should assume that the GUI is mirrored (globally going from right + * to left). * - * @return true if environment is mirrored + * @return true if environment is mirrored */ public boolean getMirrored() { return mirrored; } - /** - * Returns the orientation (a.k.a. base direction) of the GUI - * component in which the full structured text - * will be displayed. + /** + * Returns the orientation (a.k.a. base direction) of the GUI component in which + * the full structured text will be displayed. *

* The orientation value is one of the following: *

@@ -168,13 +168,13 @@ public int getOrientation() { } /** - * Checks if bidi processing is needed in this environment. The result - * depends on the operating system (must be supported by this package) - * and on the language supplied when constructing the instance (it - * must be a language using a bidirectional script). + * Checks if bidi processing is needed in this environment. The result depends + * on the operating system (must be supported by this package) and on the + * language supplied when constructing the instance (it must be a language using + * a bidirectional script). *

- * Note: This API is rarely used any more. E.g. in Eclipse/JFace, - * bidi support is typically controlled by the application via + * Note: This API is rarely used any more. E.g. in Eclipse/JFace, bidi support + * is typically controlled by the application via * {@code org.eclipse.jface.util.BidiUtils#setBidiSupport(boolean)}. *

* @@ -184,12 +184,14 @@ public int getOrientation() { */ public boolean isProcessingNeeded() { if (processingNeeded == null) { - String osName = StructuredTextActivator.getProperty("os.name"); //$NON-NLS-1$/ + String osName = StructuredTextActivator.getProperty("os.name"); //$NON-NLS-1$ / if (osName != null) osName = osName.toLowerCase(); - boolean supportedOS = osName.startsWith("windows") || osName.startsWith("linux") || osName.startsWith("mac"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + boolean supportedOS = osName.startsWith("windows") || osName.startsWith("linux") //$NON-NLS-1$ //$NON-NLS-2$ + || osName.startsWith("mac"); //$NON-NLS-1$ if (supportedOS) { - // Check whether the current language uses a bidi script (Arabic, Hebrew, Farsi or Urdu) + // Check whether the current language uses a bidi script (Arabic, Hebrew, Farsi + // or Urdu) boolean isBidi = "iw".equals(language) || //$NON-NLS-1$ "he".equals(language) || //$NON-NLS-1$ "ar".equals(language) || //$NON-NLS-1$ @@ -206,8 +208,8 @@ public boolean isProcessingNeeded() { /* * (non-Javadoc) * - * Computes the hashCode based on the values supplied when constructing - * the instance and on the result of {@link #isProcessingNeeded()}. + * Computes the hashCode based on the values supplied when constructing the + * instance and on the result of {@link #isProcessingNeeded()}. * * @return the hash code. */ @@ -225,8 +227,8 @@ public int hashCode() { /* * (non-Javadoc) * - * Compare 2 environment instances and returns true if both instances - * were constructed with the same arguments. + * Compare 2 environment instances and returns true if both instances were + * constructed with the same arguments. * * @return true if the 2 instances can be used interchangeably. */ diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextExpertFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextExpertFactory.java index f04915276d9..5fb722f9c4b 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextExpertFactory.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/StructuredTextExpertFactory.java @@ -21,38 +21,48 @@ import org.eclipse.equinox.bidi.internal.StructuredTextImpl; /** - * Obtains IStructuredTextExpert instances. - * An {@link IStructuredTextExpert} instance (called in short an "expert") provides - * the advanced methods to process a certain type of structured text, and - * is thus related to a specific - * {@link StructuredTextTypeHandler structured text type handler}. - * There are two kinds of experts: + * Obtains IStructuredTextExpert instances. An {@link IStructuredTextExpert} + * instance (called in short an "expert") provides the advanced methods to + * process a certain type of structured text, and is thus related to a specific + * {@link StructuredTextTypeHandler structured text type handler}. There are two + * kinds of experts: *
    - *
  • stateful, obtained by calling {@link #getStatefulExpert}.
  • - *
  • not stateful, obtained by calling {@link #getExpert}.
  • - *
- *

Only the stateful kind can remember the state established by a call to - * a text processing method and transmit it as initial state in the next call - * to a text processing method. - *

In other words, the methods - * {@link IStructuredTextExpert#getState()}, + *

  • stateful, obtained by calling {@link #getStatefulExpert}.
  • + *
  • not stateful, obtained by calling {@link #getExpert}.
  • + * + *

    + * Only the stateful kind can remember the state established by a call to a text + * processing method and transmit it as initial state in the next call to a text + * processing method. + *

    + * In other words, the methods {@link IStructuredTextExpert#getState()}, * {@link IStructuredTextExpert#setState} and - * {@link IStructuredTextExpert#clearState()} of - * {@link IStructuredTextExpert} are inoperative for experts which are not stateful. + * {@link IStructuredTextExpert#clearState()} of {@link IStructuredTextExpert} + * are inoperative for experts which are not stateful. *

    - * Using a stateful expert is more resource intensive, thus not stateful - * experts should be used when feasible. + * Using a stateful expert is more resource intensive, thus not stateful experts + * should be used when feasible. */ final public class StructuredTextExpertFactory { /** - * The default set of separators used to segment a string: dot, colon, slash, backslash. + * The default set of separators used to segment a string: dot, colon, slash, + * backslash. */ private static final String defaultSeparators = StructuredTextProcessor.getDefaultSeparators(); static private Map sharedDefaultExperts = new HashMap<>(); // String type -> expert - static private Map> sharedExperts = new HashMap<>(); // String type -> map of { environment -> expert } + static private Map> sharedExperts = new HashMap<>(); // String + // type + // -> + // map + // of + // { + // environment + // -> + // expert + // } static private IStructuredTextExpert defaultExpert; @@ -62,8 +72,9 @@ private StructuredTextExpertFactory() { /** * Obtains a IStructuredTextExpert instance for processing structured text with - * a default type handler segmenting the text according to default separators. - * This expert instance does not handle states. + * a default type handler segmenting the text according to default separators. + * This expert instance does not handle states. + * * @return the IStructuredTextExpert instance. * @see StructuredTextProcessor#getDefaultSeparators() */ @@ -77,15 +88,15 @@ static public IStructuredTextExpert getExpert() { /** * Obtains a IStructuredTextExpert instance for processing structured text with - * the specified type handler. - * This expert instance does not handle states. + * the specified type handler. This expert instance does not handle states. * - * @param type the identifier for the required type handler. This identifier - * may be one of those listed in {@link StructuredTextTypeHandlerFactory} - * or it may be have been registered by a plug-in. + * @param type the identifier for the required type handler. This identifier may + * be one of those listed in + * {@link StructuredTextTypeHandlerFactory} or it may be have been + * registered by a plug-in. * @return the IStructuredTextExpert instance. * @throws IllegalArgumentException if type is not a known type - * identifier. + * identifier. */ static public IStructuredTextExpert getExpert(String type) { IStructuredTextExpert expert; @@ -104,20 +115,21 @@ static public IStructuredTextExpert getExpert(String type) { /** * Obtains a IStructuredTextExpert instance for processing structured text with - * the specified type handler and the specified environment. - * This expert instance does not handle states. + * the specified type handler and the specified environment. This expert + * instance does not handle states. * - * @param type the identifier for the required type handler. This identifier - * may be one of those listed in {@link StructuredTextTypeHandlerFactory} - * or it may be have been registered by a plug-in. - * @param environment the current environment, which may affect the behavior of - * the expert. This parameter may be specified as - * null, in which case the - * {@link StructuredTextEnvironment#DEFAULT} - * environment should be assumed. + * @param type the identifier for the required type handler. This + * identifier may be one of those listed in + * {@link StructuredTextTypeHandlerFactory} or it may be have + * been registered by a plug-in. + * @param environment the current environment, which may affect the behavior of + * the expert. This parameter may be specified as + * null, in which case the + * {@link StructuredTextEnvironment#DEFAULT} environment + * should be assumed. * @return the IStructuredTextExpert instance. * @throws IllegalArgumentException if type is not a known type - * identifier. + * identifier. */ static public IStructuredTextExpert getExpert(String type, StructuredTextEnvironment environment) { IStructuredTextExpert expert; @@ -143,15 +155,15 @@ static public IStructuredTextExpert getExpert(String type, StructuredTextEnviron /** * Obtains a IStructuredTextExpert instance for processing structured text with - * the specified type handler. - * This expert instance can handle states. + * the specified type handler. This expert instance can handle states. * - * @param type the identifier for the required type handler. This identifier - * may be one of those listed in {@link StructuredTextTypeHandlerFactory} - * or it may be have been registered by a plug-in. + * @param type the identifier for the required type handler. This identifier may + * be one of those listed in + * {@link StructuredTextTypeHandlerFactory} or it may be have been + * registered by a plug-in. * @return the IStructuredTextExpert instance. * @throws IllegalArgumentException if type is not a known type - * identifier. + * identifier. */ static public IStructuredTextExpert getStatefulExpert(String type) { return getStatefulExpert(type, StructuredTextEnvironment.DEFAULT); @@ -159,20 +171,21 @@ static public IStructuredTextExpert getStatefulExpert(String type) { /** * Obtains a IStructuredTextExpert instance for processing structured text with - * the specified type handler and the specified environment. - * This expert instance can handle states. + * the specified type handler and the specified environment. This expert + * instance can handle states. * - * @param type the identifier for the required type handler. This identifier - * may be one of those listed in {@link StructuredTextTypeHandlerFactory} - * or it may be have been registered by a plug-in. - * @param environment the current environment, which may affect the behavior of - * the expert. This parameter may be specified as - * null, in which case the - * {@link StructuredTextEnvironment#DEFAULT} - * environment should be assumed. + * @param type the identifier for the required type handler. This + * identifier may be one of those listed in + * {@link StructuredTextTypeHandlerFactory} or it may be have + * been registered by a plug-in. + * @param environment the current environment, which may affect the behavior of + * the expert. This parameter may be specified as + * null, in which case the + * {@link StructuredTextEnvironment#DEFAULT} environment + * should be assumed. * @return the IStructuredTextExpert instance. * @throws IllegalArgumentException if type is not a known type - * identifier. + * identifier. */ static public IStructuredTextExpert getStatefulExpert(String type, StructuredTextEnvironment environment) { StructuredTextTypeHandler handler = StructuredTextTypeHandlerFactory.getHandler(type); @@ -183,21 +196,23 @@ static public IStructuredTextExpert getStatefulExpert(String type, StructuredTex /** * Obtains a IStructuredTextExpert instance for processing structured text with - * the specified type handler and the specified environment. - * This expert instance can handle states. + * the specified type handler and the specified environment. This expert + * instance can handle states. * - * @param handler the type handler instance. It may have been obtained using - * {@link StructuredTextTypeHandlerFactory#getHandler(String)} or - * by instantiating a type handler. - * @param environment the current environment, which may affect the behavior of - * the expert. This parameter may be specified as - * null, in which case the - * {@link StructuredTextEnvironment#DEFAULT} - * environment should be assumed. + * @param handler the type handler instance. It may have been obtained using + * {@link StructuredTextTypeHandlerFactory#getHandler(String)} + * or by instantiating a type handler. + * @param environment the current environment, which may affect the behavior of + * the expert. This parameter may be specified as + * null, in which case the + * {@link StructuredTextEnvironment#DEFAULT} environment + * should be assumed. * @return the IStructuredTextExpert instance - * @throws IllegalArgumentException if the handler is null + * @throws IllegalArgumentException if the handler is + * null */ - static public IStructuredTextExpert getStatefulExpert(StructuredTextTypeHandler handler, StructuredTextEnvironment environment) { + static public IStructuredTextExpert getStatefulExpert(StructuredTextTypeHandler handler, + StructuredTextEnvironment environment) { if (handler == null) throw new IllegalArgumentException("handler must not be null"); //$NON-NLS-1$ if (environment == null) diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextCharTypes.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextCharTypes.java index f8fa5a0f1af..11a1b32644e 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextCharTypes.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextCharTypes.java @@ -24,12 +24,12 @@ public class StructuredTextCharTypes { // In the following lines, B, L, R and AL represent bidi categories // as defined in the Unicode Bidirectional Algorithm // ( http://www.unicode.org/reports/tr9/ ). - // B represents the category Block Separator. - // L represents the category Left to Right character. - // R represents the category Right to Left character. + // B represents the category Block Separator. + // L represents the category Left to Right character. + // R represents the category Right to Left character. // AL represents the category Arabic Letter. // AN represents the category Arabic Number. - // EN represents the category European Number. + // EN represents the category European Number. static final byte B = Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR; static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT; static final byte R = Character.DIRECTIONALITY_RIGHT_TO_LEFT; @@ -59,18 +59,19 @@ public class StructuredTextCharTypes { // 1 byte for each char in text private byte[] types; - // structured text direction. -1 means not yet computed; -2 means within handler.getDirection + // structured text direction. -1 means not yet computed; -2 means within + // handler.getDirection private int direction = -1; /** - * Constructor - * - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. - * - * @param text is the text whose characters are analyzed. + * Constructor + * + * @param expert IStructuredTextExpert instance through which this handler is + * invoked. The handler can use IStructuredTextExpert methods to + * query items stored in the expert instance, like the current + * {@link StructuredTextEnvironment environment}. + * + * @param text is the text whose characters are analyzed. */ public StructuredTextCharTypes(IStructuredTextExpert expert, String text) { this.expert = expert; @@ -81,16 +82,14 @@ public StructuredTextCharTypes(IStructuredTextExpert expert, String text) { } /** - * Indicates the base text direction appropriate for an instance of - * structured text. + * Indicates the base text direction appropriate for an instance of structured + * text. * - * @return the base direction of the structured text. This direction - * may not be the same depending on the environment and on - * whether the structured text contains Arabic or Hebrew - * letters.
    - * The value returned is either - * {@link IStructuredTextExpert#DIR_LTR DIR_LTR} or - * {@link IStructuredTextExpert#DIR_RTL DIR_RTL}. + * @return the base direction of the structured text. This direction may not be + * the same depending on the environment and on whether the structured + * text contains Arabic or Hebrew letters.
    + * The value returned is either {@link IStructuredTextExpert#DIR_LTR + * DIR_LTR} or {@link IStructuredTextExpert#DIR_RTL DIR_RTL}. */ public int getDirection() { if (direction < 0) @@ -107,14 +106,13 @@ private boolean hasCachedTypeAt(int i) { } /** - * Gets the directionality of the character in the original string - * at the specified index. - * - * @param index position of the character in the lean text - * - * @return the bidi type of the character. It is one of the - * values which can be returned by - * {@link Character#getDirectionality(char)}. + * Gets the directionality of the character in the original string at the + * specified index. + * + * @param index position of the character in the lean text + * + * @return the bidi type of the character. It is one of the values which can be + * returned by {@link Character#getDirectionality(char)}. */ public byte getBidiTypeAt(int index) { if (hasCachedTypeAt(index)) @@ -134,27 +132,26 @@ public byte getBidiTypeAt(int index) { } /** - * Forces a bidi type on a character. - * - * @param index position of the character whose bidi type is set. - * - * @param charType bidirectional type of the character. It must be - * one of the values which can be returned by - * java.lang.Character.getDirectionality. + * Forces a bidi type on a character. + * + * @param index position of the character whose bidi type is set. + * + * @param charType bidirectional type of the character. It must be one of the + * values which can be returned by + * java.lang.Character.getDirectionality. */ public void setBidiTypeAt(int index, byte charType) { types[index] = (byte) (charType + CHARTYPES_ADD); } /** - * Gets the orientation of the component in which the text will - * be displayed. - * - * @return the orientation as either - * {@link StructuredTextEnvironment#ORIENT_LTR}, - * {@link StructuredTextEnvironment#ORIENT_RTL}, - * {@link StructuredTextEnvironment#ORIENT_UNKNOWN} or - * {@link StructuredTextEnvironment#ORIENT_IGNORE}. + * Gets the orientation of the component in which the text will be displayed. + * + * @return the orientation as either + * {@link StructuredTextEnvironment#ORIENT_LTR}, + * {@link StructuredTextEnvironment#ORIENT_RTL}, + * {@link StructuredTextEnvironment#ORIENT_UNKNOWN} or + * {@link StructuredTextEnvironment#ORIENT_IGNORE}. */ public int resolveOrientation() { int orient = environment.getOrientation(); @@ -162,7 +159,8 @@ public int resolveOrientation() { return orient; } // contextual orientation: - orient &= ~StructuredTextEnvironment.ORIENT_CONTEXTUAL; // initiate to the default orientation minus contextual bit + orient &= ~StructuredTextEnvironment.ORIENT_CONTEXTUAL; // initiate to the default orientation minus contextual + // bit int len = text.length(); byte charType; for (int i = 0; i < len; i++) { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextOffsets.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextOffsets.java index 14da221a060..1476693add3 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextOffsets.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextOffsets.java @@ -14,9 +14,8 @@ package org.eclipse.equinox.bidi.custom; /** - * Provides various services related to managing the array of - * offsets where directional formatting characters should be inserted - * in a source string. + * Provides various services related to managing the array of offsets where + * directional formatting characters should be inserted in a source string. */ public class StructuredTextOffsets { @@ -26,7 +25,7 @@ public class StructuredTextOffsets { private static final byte AN = Character.DIRECTIONALITY_ARABIC_NUMBER; private static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER; - private static final byte[] STRONGS = {L, R}; + private static final byte[] STRONGS = { L, R }; private static final int OFFSET_SIZE = 20; @@ -36,13 +35,13 @@ public class StructuredTextOffsets { private int prefixLength; /** - * Default constructor + * Default constructor */ public StructuredTextOffsets() { } /** - * @return the stored prefix length + * @return the stored prefix length */ public int getPrefixLength() { return prefixLength; @@ -76,7 +75,7 @@ public void clear() { /** * Gets the value of a specified entry in the offsets array. * - * @param index the index of the entry of interest. + * @param index the index of the entry of interest. * * @return the value of the specified entry. */ @@ -85,13 +84,12 @@ public int getOffset(int index) { } /** - * Inserts an offset value in the offset array so that the array - * stays in ascending order. + * Inserts an offset value in the offset array so that the array stays in + * ascending order. * - * @param charTypes an object whose methods can be useful to the - * handler. - * - * @param offset the value to insert. + * @param charTypes an object whose methods can be useful to the handler. + * + * @param offset the value to insert. */ public void insertOffset(StructuredTextCharTypes charTypes, int offset) { if (count >= offsets.length) { @@ -123,7 +121,7 @@ public void insertOffset(StructuredTextCharTypes charTypes, int offset) { byte charType = charTypes.getBidiTypeAt(offset); // if the current char is a strong one or a digit, we change the - // charType of the previous char to account for the inserted mark. + // charType of the previous char to account for the inserted mark. if (charType == L || charType == R || charType == AL || charType == EN || charType == AN) index = offset - 1; else diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextTypeHandler.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextTypeHandler.java index 53f4d9c3bab..2378b22cca4 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextTypeHandler.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/StructuredTextTypeHandler.java @@ -18,45 +18,43 @@ import org.eclipse.equinox.bidi.internal.StructuredTextImpl; /** - * Generic handler to be used as superclass (base class) - * for specific structured text handlers. - *

    - * Here are some guidelines about how to write structured text - * handlers. - *

      - *
    • Handler instances may be accessed simultaneously by - * several threads. They should have no instance variables.
    • - *
    • This class provides common logic in code which can be invoked - * by any {@link StructuredTextTypeHandler structured text handler}. - * This common logic uses handler methods to query the - * characteristics of the specific handler: - *
        - *
      • the separators which separate the structured text into - * tokens. See {@link #getSeparators}.
      • - *
      • the direction which governs the display of tokens - * one after the other. See {@link #getDirection}.
      • - *
      • the number of special cases which need to be handled by - * code specific to that handler. - * See {@link #getSpecialsCount}.
      • - *
    • - *
    • Before starting deeper analysis of the submitted text, the common - * logic gives to the handler a chance to shorten the process by - * invoking its {@link #skipProcessing} method.
    • - *
    • The common logic then analyzes the text to segment it into tokens - * according to the appearance of separators (as retrieved using - * {@link #getSeparators}).
    • - *
    • If the handler indicated a positive number of special cases as - * return value from its {@link #getSpecialsCount} - * method, the common logic will repeatedly invoke the handler's - * {@link #indexOfSpecial} method to let it signal the - * presence of special strings which may further delimit the source text.
    • - *
    • When such a special case is signaled by the handler, the common - * logic will call the handler's {@link #processSpecial} - * method to give it the opportunity to handle it as needed. Typical - * actions that the handler may perform are to add directional marks - * unconditionally (by calling {@link #insertMark} or - * conditionally (by calling {@link #processSeparator}).
    • - *
    + * Generic handler to be used as superclass (base class) for specific structured + * text handlers. + *

    + * Here are some guidelines about how to write structured text handlers. + *

      + *
    • Handler instances may be accessed simultaneously by several threads. They + * should have no instance variables.
    • + *
    • This class provides common logic in code which can be invoked by any + * {@link StructuredTextTypeHandler structured text handler}. This common logic + * uses handler methods to query the characteristics of the specific handler: + *
        + *
      • the separators which separate the structured text into tokens. See + * {@link #getSeparators}.
      • + *
      • the direction which governs the display of tokens one after the other. + * See {@link #getDirection}.
      • + *
      • the number of special cases which need to be handled by code specific to + * that handler. See {@link #getSpecialsCount}.
      • + *
      + *
    • + *
    • Before starting deeper analysis of the submitted text, the common logic + * gives to the handler a chance to shorten the process by invoking its + * {@link #skipProcessing} method.
    • + *
    • The common logic then analyzes the text to segment it into tokens + * according to the appearance of separators (as retrieved using + * {@link #getSeparators}).
    • + *
    • If the handler indicated a positive number of special cases as return + * value from its {@link #getSpecialsCount} method, the common logic will + * repeatedly invoke the handler's {@link #indexOfSpecial} method to let it + * signal the presence of special strings which may further delimit the source + * text.
    • + *
    • When such a special case is signaled by the handler, the common logic + * will call the handler's {@link #processSpecial} method to give it the + * opportunity to handle it as needed. Typical actions that the handler may + * perform are to add directional marks unconditionally (by calling + * {@link #insertMark} or conditionally (by calling + * {@link #processSeparator}).
    • + *
    */ public class StructuredTextTypeHandler { @@ -71,267 +69,274 @@ public StructuredTextTypeHandler() { /** * Creates a new instance of the StructuredTextTypeHandler class. - * @param separators string consisting of characters that split the text into fragments. + * + * @param separators string consisting of characters that split the text into + * fragments. */ public StructuredTextTypeHandler(String separators) { this.separators = separators; } /** - * Locates occurrences of special strings within a structured text - * and returns their indexes one after the other in successive calls. + * Locates occurrences of special strings within a structured text and returns + * their indexes one after the other in successive calls. + *

    + * This method is called repeatedly if the number of special cases returned by + * {@link #getSpecialsCount} is greater than zero. + *

    *

    - * This method is called repeatedly if the number of special cases - * returned by {@link #getSpecialsCount} is greater than zero. - *

    * A handler handling special cases must override this method. *

    - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. - * @param text the structured text string before - * addition of any directional formatting characters. - * @param charTypes an object whose methods can be useful to the - * handler. - * @param offsets an object whose methods can be useful to the - * handler. - * @param caseNumber number of the special case to locate. - * This number varies from 1 to the number of special cases - * returned by {@link #getSpecialsCount} - * for this handler. - * The meaning of this number is internal to the class - * implementing indexOfSpecial. - * @param fromIndex the index within text to start - * the search from. - * - * @return the position where the start of the special case - * corresponding to caseNumber was located. - * The method must return the first occurrence of whatever - * identifies the start of the special case starting from - * fromIndex. The method does not have to check if - * this occurrence appears within the scope of another special - * case (e.g. a comment starting delimiter within the scope of - * a literal or vice-versa). - *
    If no occurrence is found, the method must return -1. + * + * @param expert IStructuredTextExpert instance through which this handler + * is invoked. The handler can use IStructuredTextExpert + * methods to query items stored in the expert instance, like + * the current {@link StructuredTextEnvironment environment}. + * @param text the structured text string before addition of any + * directional formatting characters. + * @param charTypes an object whose methods can be useful to the handler. + * @param offsets an object whose methods can be useful to the handler. + * @param caseNumber number of the special case to locate. This number varies + * from 1 to the number of special cases returned by + * {@link #getSpecialsCount} for this handler. The meaning of + * this number is internal to the class implementing + * indexOfSpecial. + * @param fromIndex the index within text to start the search + * from. + * + * @return the position where the start of the special case corresponding to + * caseNumber was located. The method must return the first + * occurrence of whatever identifies the start of the special case + * starting from fromIndex. The method does not have to + * check if this occurrence appears within the scope of another special + * case (e.g. a comment starting delimiter within the scope of a literal + * or vice-versa).
    + * If no occurrence is found, the method must return -1. * * @throws IllegalStateException If not overridden, this method throws an - * IllegalStateException. This is appropriate behavior - * (and does not need to be overridden) for handlers whose - * number of special cases is zero, which means that - * indexOfSpecial should never be called for them. + * IllegalStateException. This is + * appropriate behavior (and does not need to be + * overridden) for handlers whose number of + * special cases is zero, which means that + * indexOfSpecial should never be + * called for them. */ - public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int fromIndex) { + public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int fromIndex) { // This method must be overridden by all subclasses with special cases. throw new IllegalStateException("A handler with specialsCount > 0 must have an indexOfSpecial() method."); //$NON-NLS-1$ } /** - * Handles special cases specific to this handler. - * It is called when a special case occurrence - * is located by {@link #indexOfSpecial}. + * Handles special cases specific to this handler. It is called when a special + * case occurrence is located by {@link #indexOfSpecial}. *

    * If a special processing cannot be completed within a current call to - * processSpecial (for instance, a comment has been started - * in the current line but its end appears in a following line), + * processSpecial (for instance, a comment has been started in the + * current line but its end appears in a following line), * processSpecial should specify a final state by calling - * {@link IStructuredTextExpert#setState(Object)}. - * The meaning of this state is internal to the handler. + * {@link IStructuredTextExpert#setState(Object)}. The meaning of this state is + * internal to the handler. *

    * On a later call, processSpecial will be called with * -1 for parameter separLocation. It should then - * retrieve the last state by calling {@link IStructuredTextExpert#getState()} and - * clear the state by calling {@link IStructuredTextExpert#clearState()}. After that, - * it should perform whatever initializations are required - * depending on the last state. - *

    - * A handler handling special cases (with a number of - * special cases greater than zero) must override this method. + * retrieve the last state by calling {@link IStructuredTextExpert#getState()} + * and clear the state by calling {@link IStructuredTextExpert#clearState()}. + * After that, it should perform whatever initializations are required depending + * on the last state. + *

    + *

    + * A handler handling special cases (with a number of special cases greater than + * zero) must override this method. *

    - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. - * @param text the structured text string before - * addition of any directional formatting characters. - * @param charTypes an object whose methods can be useful to the - * handler. - * @param offsets an object whose methods can be useful to the - * handler. - * @param caseNumber number of the special case to handle. - * @param separLocation the position returned by - * {@link #indexOfSpecial}. After calls to - * {@link IStructuredTextExpert#leanToFullText} and other - * methods of {@link IStructuredTextExpert} which set a non-null - * final state, processSpecial is - * called when initializing the processing with value of - * separLocation equal to -1. + * + * @param expert IStructuredTextExpert instance through which this + * handler is invoked. The handler can use + * IStructuredTextExpert methods to query items stored in + * the expert instance, like the current + * {@link StructuredTextEnvironment environment}. + * @param text the structured text string before addition of any + * directional formatting characters. + * @param charTypes an object whose methods can be useful to the handler. + * @param offsets an object whose methods can be useful to the handler. + * @param caseNumber number of the special case to handle. + * @param separLocation the position returned by {@link #indexOfSpecial}. After + * calls to {@link IStructuredTextExpert#leanToFullText} + * and other methods of {@link IStructuredTextExpert} which + * set a non-null final state, processSpecial + * is called when initializing the processing with value of + * separLocation equal to -1. * - * @return the position after the scope of the special case ends. - * For instance, the position after the end of a comment, - * the position after the end of a literal. - *
    A value greater or equal to the length of text - * means that there is no further occurrence of this case in the - * current structured text. + * @return the position after the scope of the special case ends. For instance, + * the position after the end of a comment, the position after the end + * of a literal.
    + * A value greater or equal to the length of text means + * that there is no further occurrence of this case in the current + * structured text. * * @throws IllegalStateException If not overridden, this method throws an - * IllegalStateException. This is appropriate behavior - * (and does not need to be overridden) for handlers whose - * number of special cases is zero, which means that - * processSpecial should never be called for them. + * IllegalStateException. This is + * appropriate behavior (and does not need to be + * overridden) for handlers whose number of + * special cases is zero, which means that + * processSpecial should never be + * called for them. */ - public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int separLocation) { + public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int separLocation) { // This method must be overridden by all subclasses with any special case. throw new IllegalStateException("A handler with specialsCount > 0 must have a processSpecial() method."); //$NON-NLS-1$ } /** - * Specifies that a mark character must be added before the character - * at the specified position of the lean text when generating the - * full text. This method can be called from within - * {@link #indexOfSpecial} or - * {@link #processSpecial} in extensions of - * StructuredTextTypeHandler. - * The mark character will be LRM for structured text - * with a LTR base direction, and RLM for structured text with RTL - * base direction. The mark character is not added physically by this - * method, but its position is noted and will be used when generating - * the full text. + * Specifies that a mark character must be added before the character at the + * specified position of the lean text when generating the full + * text. This method can be called from within {@link #indexOfSpecial} or + * {@link #processSpecial} in extensions of + * StructuredTextTypeHandler. The mark character will be LRM for + * structured text with a LTR base direction, and RLM for structured text with + * RTL base direction. The mark character is not added physically by this + * method, but its position is noted and will be used when generating the + * full text. * - * @param text is the structured text string received as - * parameter to indexOfSpecial or - * processSpecial. - * @param charTypes is a parameter received by indexOfSpecial - * or processSpecial. - * @param offsets is a parameter received by indexOfSpecial - * or processSpecial. - * @param offset position of the character in the lean text. - * It must be a non-negative number smaller than the length - * of the lean text. - * For the benefit of efficiency, it is better to insert - * multiple marks in ascending order of the offsets. + * @param text is the structured text string received as parameter to + * indexOfSpecial or processSpecial. + * @param charTypes is a parameter received by indexOfSpecial or + * processSpecial. + * @param offsets is a parameter received by indexOfSpecial or + * processSpecial. + * @param offset position of the character in the lean text. It must + * be a non-negative number smaller than the length of the + * lean text. For the benefit of efficiency, it is + * better to insert multiple marks in ascending order of the + * offsets. */ - public static final void insertMark(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int offset) { + public static final void insertMark(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, + int offset) { offsets.insertOffset(charTypes, offset); } /** - * Adds a directional mark before a separator if needed for correct - * display, depending on the base direction of the text and on the - * class of the characters in the lean text preceding and - * following the separator itself. This method - * can be called from within {@link #indexOfSpecial} or - * {@link #processSpecial} in extensions of - * StructuredTextTypeHandler. + * Adds a directional mark before a separator if needed for correct display, + * depending on the base direction of the text and on the class of the + * characters in the lean text preceding and following the separator + * itself. This method can be called from within {@link #indexOfSpecial} or + * {@link #processSpecial} in extensions of + * StructuredTextTypeHandler. *

    * The logic implemented in this method considers the text before - * separLocation and the text following it. If, and only if, - * a directional mark is needed to insure that the two parts of text - * will be laid out according to the base direction, a mark will be - * added when generating the full text. + * separLocation and the text following it. If, and only if, a + * directional mark is needed to insure that the two parts of text will be laid + * out according to the base direction, a mark will be added when generating the + * full text. *

    - * @param text is the structured text string received as - * parameter to indexOfSpecial or - * processSpecial. - * @param charTypes is a parameter received by indexOfSpecial - * or processSpecial. - * @param offsets is a parameter received by indexOfSpecial - * or processSpecial. - * @param separLocation offset of the separator in the lean text. - * It must be a non-negative number smaller than the length - * of the lean text. + * + * @param text is the structured text string received as parameter to + * indexOfSpecial or + * processSpecial. + * @param charTypes is a parameter received by indexOfSpecial + * or processSpecial. + * @param offsets is a parameter received by indexOfSpecial + * or processSpecial. + * @param separLocation offset of the separator in the lean text. It must + * be a non-negative number smaller than the length of the + * lean text. */ - public static final void processSeparator(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int separLocation) { + public static final void processSeparator(String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int separLocation) { StructuredTextImpl.processSeparator(text, charTypes, offsets, separLocation); } /** - * Indicates the separators to use for the current handler. - * This method is invoked before starting the processing. + * Indicates the separators to use for the current handler. This method is + * invoked before starting the processing. *

    * If no separators are specified, this method returns an empty string. *

    - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. + * + * @param expert IStructuredTextExpert instance through which this handler is + * invoked. The handler can use IStructuredTextExpert methods to + * query items stored in the expert instance, like the current + * {@link StructuredTextEnvironment environment}. * - * @return a string grouping one-character separators which separate - * the structured text into tokens. + * @return a string grouping one-character separators which separate the + * structured text into tokens. */ public String getSeparators(IStructuredTextExpert expert) { return separators; } /** - * Indicates the base text direction appropriate for an instance of - * structured text. This method is invoked before starting the processing. + * Indicates the base text direction appropriate for an instance of structured + * text. This method is invoked before starting the processing. *

    - * If not overridden, this method returns {@link IStructuredTextExpert#DIR_LTR DIR_LTR}. + * If not overridden, this method returns {@link IStructuredTextExpert#DIR_LTR + * DIR_LTR}. *

    - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. - * @param text the structured text string to process. + * + * @param expert IStructuredTextExpert instance through which this handler is + * invoked. The handler can use IStructuredTextExpert methods to + * query items stored in the expert instance, like the current + * {@link StructuredTextEnvironment environment}. + * @param text the structured text string to process. * - * @return the base direction of the structured text. This direction - * may not be the same depending on the environment and on - * whether the structured text contains Arabic or Hebrew - * letters.
    - * The value returned is either - * {@link IStructuredTextExpert#DIR_LTR DIR_LTR} or - * {@link IStructuredTextExpert#DIR_RTL DIR_RTL}. + * @return the base direction of the structured text. This direction may not be + * the same depending on the environment and on whether the structured + * text contains Arabic or Hebrew letters.
    + * The value returned is either {@link IStructuredTextExpert#DIR_LTR + * DIR_LTR} or {@link IStructuredTextExpert#DIR_RTL DIR_RTL}. */ public int getDirection(IStructuredTextExpert expert, String text) { return IStructuredTextExpert.DIR_LTR; } /** - * Indicates the base text direction appropriate for an instance of - * structured text. This method is invoked before starting the processing. + * Indicates the base text direction appropriate for an instance of structured + * text. This method is invoked before starting the processing. *

    - * If not overridden, this method returns {@link IStructuredTextExpert#DIR_LTR DIR_LTR}. + * If not overridden, this method returns {@link IStructuredTextExpert#DIR_LTR + * DIR_LTR}. *

    - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. - * @param text is the structured text string to process. - * @param charTypes is a parameter received by indexOfSpecial - * or processSpecial. + * + * @param expert IStructuredTextExpert instance through which this handler is + * invoked. The handler can use IStructuredTextExpert methods + * to query items stored in the expert instance, like the + * current {@link StructuredTextEnvironment environment}. + * @param text is the structured text string to process. + * @param charTypes is a parameter received by indexOfSpecial or + * processSpecial. * - * @return the base direction of the structured text. This direction - * may not be the same depending on the environment and on - * whether the structured text contains Arabic or Hebrew - * letters.
    - * The value returned is either - * {@link IStructuredTextExpert#DIR_LTR DIR_LTR} or {@link IStructuredTextExpert#DIR_RTL DIR_RTL}. + * @return the base direction of the structured text. This direction may not be + * the same depending on the environment and on whether the structured + * text contains Arabic or Hebrew letters.
    + * The value returned is either {@link IStructuredTextExpert#DIR_LTR + * DIR_LTR} or {@link IStructuredTextExpert#DIR_RTL DIR_RTL}. */ public int getDirection(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes) { return IStructuredTextExpert.DIR_LTR; } /** - * Indicates the number of special cases handled by the current handler. - * This method is invoked before starting the processing. - * If the number returned is zero, {@link #indexOfSpecial} - * and {@link #processSpecial} will not be invoked. + * Indicates the number of special cases handled by the current handler. This + * method is invoked before starting the processing. If the number returned is + * zero, {@link #indexOfSpecial} and {@link #processSpecial} will not be + * invoked. *

    * If not overridden, this method returns zero. *

    - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. + * + * @param expert IStructuredTextExpert instance through which this handler is + * invoked. The handler can use IStructuredTextExpert methods to + * query items stored in the expert instance, like the current + * {@link StructuredTextEnvironment environment}. * - * @return the number of special cases for the associated handler. - * Special cases exist for some types of structured text - * handlers. They are implemented by overriding methods + * @return the number of special cases for the associated handler. Special cases + * exist for some types of structured text handlers. They are + * implemented by overriding methods * {@link StructuredTextTypeHandler#indexOfSpecial} and - * {@link StructuredTextTypeHandler#processSpecial}. - * Examples of special cases are comments, literals, or - * anything which is not identified by a one-character separator. + * {@link StructuredTextTypeHandler#processSpecial}. Examples of special + * cases are comments, literals, or anything which is not identified by + * a one-character separator. * */ public int getSpecialsCount(IStructuredTextExpert expert) { @@ -339,24 +344,24 @@ public int getSpecialsCount(IStructuredTextExpert expert) { } /** - * Checks if there is a need for processing structured text. - * This method is invoked before starting the processing. If the - * handler returns true, no directional formatting - * characters are added to the lean text and the processing - * is shortened. + * Checks if there is a need for processing structured text. This method is + * invoked before starting the processing. If the handler returns + * true, no directional formatting characters are added to the + * lean text and the processing is shortened. *

    * If not overridden, this method returns false. *

    - * @param expert IStructuredTextExpert instance through which this handler - * is invoked. The handler can use IStructuredTextExpert methods to - * query items stored in the expert instance, like the current - * {@link StructuredTextEnvironment environment}. - * @param text is the structured text string to process. - * @param charTypes is a parameter received by indexOfSpecial - * or processSpecial. + * + * @param expert IStructuredTextExpert instance through which this handler is + * invoked. The handler can use IStructuredTextExpert methods + * to query items stored in the expert instance, like the + * current {@link StructuredTextEnvironment environment}. + * @param text is the structured text string to process. + * @param charTypes is a parameter received by indexOfSpecial or + * processSpecial. * - * @return a flag indicating if there is no need to process the structured - * text to add directional formatting characters. + * @return a flag indicating if there is no need to process the structured text + * to add directional formatting characters. * */ public boolean skipProcessing(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes) { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextActivator.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextActivator.java index b7b7ebdbe75..0e1553aa4cf 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextActivator.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextActivator.java @@ -54,14 +54,16 @@ public static StructuredTextActivator getInstance() { } /** - * Returns the value of the specified property. If OSGi is not running or the key is not found in - * the Framework properties, the system properties are then searched. + * Returns the value of the specified property. If OSGi is not running or the + * key is not found in the Framework properties, the system properties are then + * searched. *

    * This method can be used without OSGi running. *

    * * @param key the name of the requested property - * @return the value of the requested property, or {@code null} if the property is undefined + * @return the value of the requested property, or {@code null} if the property + * is undefined */ public static String getProperty(String key) { if (instance != null) @@ -102,7 +104,8 @@ static public void logError(String message, Exception e) { if (instance != null) { FrameworkLog frameworkLog = instance.getFrameworkLog(); if (frameworkLog != null) { - frameworkLog.log(new FrameworkLogEntry("org.eclipse.equinox.bidi", FrameworkLogEntry.ERROR, 1, message, 0, e, null)); //$NON-NLS-1$ + frameworkLog.log(new FrameworkLogEntry("org.eclipse.equinox.bidi", FrameworkLogEntry.ERROR, 1, message, //$NON-NLS-1$ + 0, e, null)); return; } } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelims.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelims.java index 34ad1684cec..fab018d81eb 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelims.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelims.java @@ -17,12 +17,12 @@ import org.eclipse.equinox.bidi.custom.*; /** - * A base handler for structured text composed of text segments separated - * by separators where the text segments may include delimited parts within - * which separators are treated like regular characters. - *

    - * A delimited part is bounded by a start delimiter and an end delimiter. - *

    + * A base handler for structured text composed of text segments separated by + * separators where the text segments may include delimited parts within which + * separators are treated like regular characters. + *

    + * A delimited part is bounded by a start delimiter and an end delimiter. + *

    */ public abstract class StructuredTextDelims extends StructuredTextTypeHandler { @@ -35,33 +35,35 @@ public StructuredTextDelims(String separators) { } /** - * Locates occurrences of start delimiters. + * Locates occurrences of start delimiters. * - * @return the position starting from offset fromIndex - * in text of the first occurrence of the - * start delimiter corresponding to caseNumber - * (first start delimiter if caseNumber equals 1, - * second delimiter if caseNumber equals 2, etc...). + * @return the position starting from offset fromIndex in + * text of the first occurrence of the start delimiter + * corresponding to caseNumber (first start delimiter if + * caseNumber equals 1, second delimiter if + * caseNumber equals 2, etc...). * - * @see #getDelimiters + * @see #getDelimiters */ @Override - public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int fromIndex) { + public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int fromIndex) { char delim = getDelimiters().charAt((caseNumber - 1) * 2); return text.indexOf(delim, fromIndex); } /** - * Handles the text between start and end delimiters as a token. - * This method inserts a directional mark if needed at position - * separLocation which corresponds to a start delimiter, - * and skips until after the matching end delimiter. + * Handles the text between start and end delimiters as a token. This method + * inserts a directional mark if needed at position separLocation + * which corresponds to a start delimiter, and skips until after the matching + * end delimiter. * - * @return the position after the matching end delimiter, or the length - * of text if no end delimiter is found. + * @return the position after the matching end delimiter, or the length of + * text if no end delimiter is found. */ @Override - public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int separLocation) { + public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int separLocation) { StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); int loc = separLocation + 1; char delim = getDelimiters().charAt((caseNumber * 2) - 1); @@ -72,16 +74,15 @@ public int processSpecial(IStructuredTextExpert expert, String text, StructuredT } /** - * @return a string containing the delimiters implemented in this class - * instance. This string must include an even - * number of characters. The first 2 characters of a string - * constitute a pair, the next 2 characters are a second pair, etc... - * In each pair, the first character is a start delimiter and - * the second character is an end delimiter. In the lean - * text, any part starting with a start delimiter and ending with - * the corresponding end delimiter is a delimited part. Within a - * delimited part, separators are treated like regular characters, - * which means that they do not define new segments. + * @return a string containing the delimiters implemented in this class + * instance. This string must include an even number of characters. The + * first 2 characters of a string constitute a pair, the next 2 + * characters are a second pair, etc... In each pair, the first + * character is a start delimiter and the second character is an end + * delimiter. In the lean text, any part starting with a start + * delimiter and ending with the corresponding end delimiter is a + * delimited part. Within a delimited part, separators are treated like + * regular characters, which means that they do not define new segments. */ protected abstract String getDelimiters(); diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelimsEsc.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelimsEsc.java index 79a581d8041..70a4806b18e 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelimsEsc.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextDelimsEsc.java @@ -17,20 +17,20 @@ import org.eclipse.equinox.bidi.custom.*; /** - * A base handler for structured text composed of text segments separated - * by separators where the text segments may include delimited parts within - * which separators are treated like regular characters and the delimiters - * may be escaped. - *

    - * This is similar to {@link StructuredTextDelims} except that delimiters can be escaped - * using the backslash character. - *

      - *
    • Two consecutive backslashes in a delimited part are treated like - * one regular character.
    • - *
    • An ending delimiter preceded by an odd number of backslashes is - * treated like a regular character within the delimited part.
    • - *
    - *

    + * A base handler for structured text composed of text segments separated by + * separators where the text segments may include delimited parts within which + * separators are treated like regular characters and the delimiters may be + * escaped. + *

    + * This is similar to {@link StructuredTextDelims} except that delimiters can be + * escaped using the backslash character. + *

      + *
    • Two consecutive backslashes in a delimited part are treated like one + * regular character.
    • + *
    • An ending delimiter preceded by an odd number of backslashes is treated + * like a regular character within the delimited part.
    • + *
    + *

    */ public abstract class StructuredTextDelimsEsc extends StructuredTextDelims { @@ -43,14 +43,14 @@ public StructuredTextDelimsEsc(String separator) { } /** - * Handles the text between start and end delimiters as a token. - * This method inserts a directional mark if needed at position - * separLocation which corresponds to a start delimiter, - * and skips until after the matching end delimiter, - * ignoring possibly escaped end delimiters. + * Handles the text between start and end delimiters as a token. This method + * inserts a directional mark if needed at position separLocation + * which corresponds to a start delimiter, and skips until after the matching + * end delimiter, ignoring possibly escaped end delimiters. */ @Override - public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int separLocation) { + public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int separLocation) { StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); int location = separLocation + 1; char delim = getDelimiters().charAt((caseNumber * 2) - 1); diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextImpl.java index e7fe08809ce..41097ab185f 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextImpl.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextImpl.java @@ -26,12 +26,12 @@ public class StructuredTextImpl implements IStructuredTextExpert { // In the following lines, B, L, R and AL represent bidi categories // as defined in the Unicode Bidirectional Algorithm // ( http://www.unicode.org/reports/tr9/ ). - // B represents the category Block Separator. - // L represents the category Left to Right character. - // R represents the category Right to Left character. + // B represents the category Block Separator. + // L represents the category Left to Right character. + // R represents the category Right to Left character. // AL represents the category Arabic Letter. // AN represents the category Arabic Number. - // EN represents the category European Number. + // EN represents the category European Number. static final byte B = Character.DIRECTIONALITY_PARAGRAPH_SEPARATOR; static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT; static final byte R = Character.DIRECTIONALITY_RIGHT_TO_LEFT; @@ -44,8 +44,8 @@ public class StructuredTextImpl implements IStructuredTextExpert { static final char LRE = 0x202A; static final char RLE = 0x202B; static final char PDF = 0x202C; - static final char[] MARKS = {LRM, RLM}; - static final char[] EMBEDS = {LRE, RLE}; + static final char[] MARKS = { LRM, RLM }; + static final char[] EMBEDS = { LRE, RLE }; static final int PREFIX_LENGTH = 2; static final int SUFFIX_LENGTH = 2; static final int FIXES_LENGTH = PREFIX_LENGTH + SUFFIX_LENGTH; @@ -72,10 +72,11 @@ public class StructuredTextImpl implements IStructuredTextExpert { * Constructor used in {@link StructuredTextExpertFactory}. * * @param structuredTextHandler the structured text handler used by this expert. - * @param environment the environment associated with this expert. - * @param shared flag which is true if the expert is stateful. + * @param environment the environment associated with this expert. + * @param shared flag which is true if the expert is stateful. */ - public StructuredTextImpl(StructuredTextTypeHandler structuredTextHandler, StructuredTextEnvironment environment, boolean shared) { + public StructuredTextImpl(StructuredTextTypeHandler structuredTextHandler, StructuredTextEnvironment environment, + boolean shared) { this.handler = structuredTextHandler; this.environment = environment; sharedExpert = shared; @@ -113,7 +114,8 @@ public Object getState() { return state; } - long computeNextLocation(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int[] locations, int curPos) { + long computeNextLocation(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, + int[] locations, int curPos) { String separators = handler.getSeparators(this); int separCount = separators.length(); int specialsCount = handler.getSpecialsCount(this); @@ -152,9 +154,11 @@ long computeNextLocation(String text, StructuredTextCharTypes charTypes, Structu } /** - * @see StructuredTextTypeHandler#processSeparator StructuredTextTypeHandler.processSeparator + * @see StructuredTextTypeHandler#processSeparator + * StructuredTextTypeHandler.processSeparator */ - static public void processSeparator(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int separLocation) { + static public void processSeparator(String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, + int separLocation) { int len = text.length(); int direction = charTypes.getDirection(); if (direction == DIR_RTL) { @@ -213,45 +217,42 @@ static public void processSeparator(String text, StructuredTextCharTypes charTyp } /** - * When the orientation is ORIENT_LTR and the - * structured text has a RTL base direction, - * {@link IStructuredTextExpert#leanToFullText leanToFullText} - * adds RLE+RLM at the head of the full text and RLM+PDF at its - * end. + * When the orientation is ORIENT_LTR and the structured text has a + * RTL base direction, {@link IStructuredTextExpert#leanToFullText + * leanToFullText} adds RLE+RLM at the head of the full text and RLM+PDF + * at its end. *

    - * When the orientation is ORIENT_RTL and the - * structured text has a LTR base direction, - * {@link IStructuredTextExpert#leanToFullText leanToFullText} - * adds LRE+LRM at the head of the full text and LRM+PDF at its - * end. + * When the orientation is ORIENT_RTL and the structured text has a + * LTR base direction, {@link IStructuredTextExpert#leanToFullText + * leanToFullText} adds LRE+LRM at the head of the full text and LRM+PDF + * at its end. *

    * When the orientation is ORIENT_CONTEXTUAL_LTR or - * ORIENT_CONTEXTUAL_RTL and the data content would resolve - * to a RTL orientation while the structured text has a LTR base - * direction, {@link IStructuredTextExpert#leanToFullText leanToFullText} - * adds LRM at the head of the full text. + * ORIENT_CONTEXTUAL_RTL and the data content would resolve to a + * RTL orientation while the structured text has a LTR base direction, + * {@link IStructuredTextExpert#leanToFullText leanToFullText} adds LRM at the + * head of the full text. *

    * When the orientation is ORIENT_CONTEXTUAL_LTR or - * ORIENT_CONTEXTUAL_RTL and the data content would resolve - * to a LTR orientation while the structured text has a RTL base - * direction, {@link IStructuredTextExpert#leanToFullText leanToFullText} - * adds RLM at the head of the full text. + * ORIENT_CONTEXTUAL_RTL and the data content would resolve to a + * LTR orientation while the structured text has a RTL base direction, + * {@link IStructuredTextExpert#leanToFullText leanToFullText} adds RLM at the + * head of the full text. *

    - * When the orientation is ORIENT_UNKNOWN and the - * structured text has a LTR base direction, - * {@link IStructuredTextExpert#leanToFullText leanToFullText} - * adds LRE+LRM at the head of the full text and LRM+PDF at its - * end. + * When the orientation is ORIENT_UNKNOWN and the structured text + * has a LTR base direction, {@link IStructuredTextExpert#leanToFullText + * leanToFullText} adds LRE+LRM at the head of the full text and LRM+PDF + * at its end. *

    - * When the orientation is ORIENT_UNKNOWN and the - * structured text has a RTL base direction, - * {@link IStructuredTextExpert#leanToFullText leanToFullText} - * adds RLE+RLM at the head of the full text and RLM+PDF at its - * end. + * When the orientation is ORIENT_UNKNOWN and the structured text + * has a RTL base direction, {@link IStructuredTextExpert#leanToFullText + * leanToFullText} adds RLE+RLM at the head of the full text and RLM+PDF + * at its end. *

    * When the orientation is ORIENT_IGNORE, - * {@link IStructuredTextExpert#leanToFullText leanToFullText} does not add any directional - * formatting characters as either prefix or suffix of the full text. + * {@link IStructuredTextExpert#leanToFullText leanToFullText} does not add any + * directional formatting characters as either prefix or suffix of the + * full text. *

    */ @Override @@ -316,7 +317,8 @@ private StructuredTextOffsets leanToFullCommon(String text, StructuredTextCharTy while (true) { // location of next token to handle int nextLocation; - // index of next token to handle (if < separCount, this is a separator; otherwise a special case + // index of next token to handle (if < separCount, this is a separator; + // otherwise a special case int idxLocation; long res = computeNextLocation(text, charTypes, offsets, locations, curPos); nextLocation = (int) (res & 0x00000000FFFFFFFF); /* low word */ @@ -448,8 +450,10 @@ else if (cnt > 0) // we should never get here (extra char which is not a Mark) throw new IllegalStateException("Internal error: extra character not a Mark."); //$NON-NLS-1$ } - if (idxFull < lenFull) /* full2 ended before full - this should never happen since - we removed all marks and PDFs at the end of full */ + if (idxFull < lenFull) /* + * full2 ended before full - this should never happen since we removed all marks + * and PDFs at the end of full + */ throw new IllegalStateException("Internal error: unexpected EOL."); //$NON-NLS-1$ lean = new String(newChars, 0, newCharsPos); @@ -546,7 +550,7 @@ else if (affixLength == 2) // When the orientation is RTL, we need to add EMBED at the // start of the text and PDF at its end. // However, because of a bug in Windows' handling of LRE/RLE/PDF, - // we add LRM or RLM (according to the direction) after the + // we add LRM or RLM (according to the direction) after the // LRE/RLE and again before the PDF. char curEmbed = EMBEDS[direction]; fullChars[0] = curEmbed; diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextSingle.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextSingle.java index 9976b10a32c..a29d9e5ebe7 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextSingle.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextSingle.java @@ -17,18 +17,20 @@ import org.eclipse.equinox.bidi.custom.*; /** - * A base handler for structured text composed of two parts separated by a separator. - * The first occurrence of the separator delimits the end of the first part - * and the start of the second part. Further occurrences of the separator, - * if any, are treated like regular characters of the second text part. - * The handler makes sure that the text be presented in the form - * (assuming that the equal sign is the separator): - *

    - *  part1=part2
    - *  
    - * The string returned by {@link StructuredTextTypeHandler#getSeparators getSeparators} - * for this handler should contain exactly one character. - * Additional characters will be ignored. + * A base handler for structured text composed of two parts separated by a + * separator. The first occurrence of the separator delimits the end of the + * first part and the start of the second part. Further occurrences of the + * separator, if any, are treated like regular characters of the second text + * part. The handler makes sure that the text be presented in the form (assuming + * that the equal sign is the separator): + * + *
    + * part1 = part2
    + * 
    + * + * The string returned by {@link StructuredTextTypeHandler#getSeparators + * getSeparators} for this handler should contain exactly one character. + * Additional characters will be ignored. */ public class StructuredTextSingle extends StructuredTextTypeHandler { @@ -37,31 +39,33 @@ public StructuredTextSingle(String separator) { } /** - * Locates occurrences of the separator. + * Locates occurrences of the separator. * - * @see #getSeparators getSeparators + * @see #getSeparators getSeparators */ @Override - public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int fromIndex) { + public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int fromIndex) { return text.indexOf(this.getSeparators(expert).charAt(0), fromIndex); } /** - * Inserts a mark before the separator if needed and - * skips to the end of the source string. + * Inserts a mark before the separator if needed and skips to the end of the + * source string. * - * @return the length of text. + * @return the length of text. */ @Override - public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int separLocation) { + public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int separLocation) { StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); return text.length(); } /** - * Returns 1 as number of special cases handled by this handler. + * Returns 1 as number of special cases handled by this handler. * - * @return 1. + * @return 1. */ @Override public int getSpecialsCount(IStructuredTextExpert expert) { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextStringRecord.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextStringRecord.java index e2dad2aba1f..20f59882229 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextStringRecord.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextStringRecord.java @@ -17,19 +17,21 @@ import org.eclipse.equinox.bidi.StructuredTextTypeHandlerFactory; /** - * Records strings which contain structured text. Several static - * methods in this class allow to record such strings in a pool, and to find if - * a given string is member of the pool. + * Records strings which contain structured text. Several static methods in this + * class allow to record such strings in a pool, and to find if a given string + * is member of the pool. *

    * Instances of this class are the records which are members of the pool. - *

    - * The pool is managed as a cyclic list. When the pool is full, - * each new element overrides the oldest element in the list. - *

    - * A string may be itself entirely a structured text, or it may contain - * segments each of which is a structured text of a given type. Each such - * segment is identified by its starting and ending offsets within the - * string, and by the handler which is appropriate to handle it. + *

    + *

    + * The pool is managed as a cyclic list. When the pool is full, each new element + * overrides the oldest element in the list. + *

    + *

    + * A string may be itself entirely a structured text, or it may contain segments + * each of which is a structured text of a given type. Each such segment is + * identified by its starting and ending offsets within the string, and by the + * handler which is appropriate to handle it. */ public class StructuredTextStringRecord { /** @@ -78,39 +80,43 @@ private StructuredTextStringRecord() { } /** - * Records a string in the pool. The caller must specify the number - * of segments in the record (at least 1), and the handler, starting - * and ending offsets for the first segment. + * Records a string in the pool. The caller must specify the number of segments + * in the record (at least 1), and the handler, starting and ending offsets for + * the first segment. * - * @param string the string to record. - * @param segmentCount number of segments allowed in this string. - * This number must be >= 1. - * @param handlerID identifier for the handler appropriate to handle - * the type of structured text present in the first segment. - * It may be one of the predefined identifiers in - * {@link StructuredTextTypeHandlerFactory}, or it may be an identifier - * for a type handler created by a plug-in or by the application. - * @param start offset in the string of the starting character of the first - * segment. It must be >= 0 and less than the length of the string. - * @param limit offset of the character following the first segment. It - * must be greater than the start argument and - * not greater than the length of the string. + * @param string the string to record. + * @param segmentCount number of segments allowed in this string. This number + * must be >= 1. + * @param handlerID identifier for the handler appropriate to handle the type + * of structured text present in the first segment. It may + * be one of the predefined identifiers in + * {@link StructuredTextTypeHandlerFactory}, or it may be an + * identifier for a type handler created by a plug-in or by + * the application. + * @param start offset in the string of the starting character of the + * first segment. It must be >= 0 and less than the length + * of the string. + * @param limit offset of the character following the first segment. It + * must be greater than the start argument and + * not greater than the length of the string. * - * @return an instance of StructuredTextRecordString which represents this record. - * This instance may be used to specify additional segments with + * @return an instance of StructuredTextRecordString which represents this + * record. This instance may be used to specify additional segments with * {@link #addSegment addSegment}. * - * @throws IllegalArgumentException if string is null or - * if segmentCount is less than 1. - * @throws IllegalArgumentException if handlerID is null, - * or if start or limit have invalid - * values. - * @throws IllegalStateException if the current segment exceeds the - * number of segments specified by segmentCount - * in the call to {@link #addRecord addRecord} which created - * the StructuredTextStringRecord instance. + * @throws IllegalArgumentException if string is null or if + * segmentCount is less than 1. + * @throws IllegalArgumentException if handlerID is null, or if + * start or limit + * have invalid values. + * @throws IllegalStateException if the current segment exceeds the number of + * segments specified by + * segmentCount in the call to + * {@link #addRecord addRecord} which created + * the StructuredTextStringRecord instance. */ - public static StructuredTextStringRecord addRecord(String string, int segmentCount, String handlerID, int start, int limit) { + public static StructuredTextStringRecord addRecord(String string, int segmentCount, String handlerID, int start, + int limit) { if (string == null) throw new IllegalArgumentException("The string argument must not be null!"); //$NON-NLS-1$ if (segmentCount < 1) @@ -147,32 +153,37 @@ record = new StructuredTextStringRecord(); /** * Adds a second or further segment to a record. * - * @param handlerID identifier for the handler appropriate to handle - * the type of structured text present in the first segment. - * It may be one of the predefined identifiers in - * {@link StructuredTextTypeHandlerFactory}, or it may be an identifier - * for a type handler created by a plug-in or by the application. - * @param start offset in the string of the starting character of the - * segment. It must be >= 0 and less than the length of the string. - * @param limit offset of the character following the segment. It must be - * greater than the start argument and not greater - * than the length of the string. + * @param handlerID identifier for the handler appropriate to handle the type of + * structured text present in the first segment. It may be one + * of the predefined identifiers in + * {@link StructuredTextTypeHandlerFactory}, or it may be an + * identifier for a type handler created by a plug-in or by the + * application. + * @param start offset in the string of the starting character of the + * segment. It must be >= 0 and less than the length of the + * string. + * @param limit offset of the character following the segment. It must be + * greater than the start argument and not greater + * than the length of the string. * - * @throws IllegalArgumentException if handlerID is null, - * or if start or limit have invalid - * values. - * @throws IllegalStateException if the current segment exceeds the - * number of segments specified by segmentCount - * in the call to {@link #addRecord addRecord} which created - * the StructuredTextStringRecord instance. + * @throws IllegalArgumentException if handlerID is null, or if + * start or limit + * have invalid values. + * @throws IllegalStateException if the current segment exceeds the number of + * segments specified by + * segmentCount in the call to + * {@link #addRecord addRecord} which created + * the StructuredTextStringRecord instance. */ public void addSegment(String handlerID, int start, int limit) { if (handlerID == null) throw new IllegalArgumentException("The handlerID argument must not be null!"); //$NON-NLS-1$ if (start < 0 || start >= string.length()) - throw new IllegalArgumentException("The start position must be at least 0 and less than the length of the string!"); //$NON-NLS-1$ + throw new IllegalArgumentException( + "The start position must be at least 0 and less than the length of the string!"); //$NON-NLS-1$ if (limit <= start || limit > string.length()) - throw new IllegalArgumentException("The limit position must be greater than the start position but no greater than the length of the string!"); //$NON-NLS-1$ + throw new IllegalArgumentException( + "The limit position must be greater than the start position but no greater than the length of the string!"); //$NON-NLS-1$ if (usedSegmentCount >= totalSegmentCount) throw new IllegalStateException("All segments of the record are already used!"); //$NON-NLS-1$ handlers[usedSegmentCount] = handlerID; @@ -184,19 +195,16 @@ public void addSegment(String handlerID, int start, int limit) { /** * Checks if a string is recorded and retrieves its record. * - * @param string the string to check. + * @param string the string to check. * * @return null if the string is not recorded in the pool; - * otherwise, return the StructuredTextStringRecord instance - * which records this string.
    - * Once a record has been found, the number of its segments can - * be retrieved using {@link #getSegmentCount getSegmentCount}, - * its handler ID can - * be retrieved using {@link #getHandler getHandler}, - * its starting offset can - * be retrieved using {@link #getStart getStart}, - * its ending offset can - * be retrieved using {@link #getLimit getLimit}, + * otherwise, return the StructuredTextStringRecord + * instance which records this string.
    + * Once a record has been found, the number of its segments can be + * retrieved using {@link #getSegmentCount getSegmentCount}, its handler + * ID can be retrieved using {@link #getHandler getHandler}, its + * starting offset can be retrieved using {@link #getStart getStart}, + * its ending offset can be retrieved using {@link #getLimit getLimit}, */ public static StructuredTextStringRecord getRecord(String string) { if (last < 0) // no records at all @@ -240,22 +248,22 @@ public int getSegmentCount() { private void checkSegmentNumber(int segmentNumber) { if (segmentNumber >= usedSegmentCount) - throw new IllegalArgumentException("The segment number " + segmentNumber + " is greater than the total number of segments = " + usedSegmentCount + "!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + throw new IllegalArgumentException("The segment number " + segmentNumber //$NON-NLS-1$ + + " is greater than the total number of segments = " + usedSegmentCount + "!"); //$NON-NLS-1$ //$NON-NLS-2$ } /** * Retrieves the handler ID of a given segment. * - * @param segmentNumber number of the segment about which information - * is required. It must be >= 0 and less than the number of - * segments returned by {@link #getSegmentCount}. + * @param segmentNumber number of the segment about which information is + * required. It must be >= 0 and less than the number of + * segments returned by {@link #getSegmentCount}. * - * @return the handler ID of the handler appropriate to - * process the structured text in the segment - * specified by segmentNumber. + * @return the handler ID of the handler appropriate to process the structured + * text in the segment specified by segmentNumber. * - * @throws IllegalArgumentException if segmentNumber - * has an invalid value. + * @throws IllegalArgumentException if segmentNumber has an invalid + * value. */ public String getHandler(int segmentNumber) { checkSegmentNumber(segmentNumber); @@ -265,15 +273,15 @@ public String getHandler(int segmentNumber) { /** * Retrieves the starting offset of a given segment. * - * @param segmentNumber number of the segment about which information - * is required. It must be >= 0 and less than the number of - * segments returned by {@link #getSegmentCount}. + * @param segmentNumber number of the segment about which information is + * required. It must be >= 0 and less than the number of + * segments returned by {@link #getSegmentCount}. * - * @return the starting offset within the string of the segment - * specified by segmentNumber. + * @return the starting offset within the string of the segment specified by + * segmentNumber. * - * @throws IllegalArgumentException if segmentNumber - * has an invalid value. + * @throws IllegalArgumentException if segmentNumber has an invalid + * value. */ public int getStart(int segmentNumber) { checkSegmentNumber(segmentNumber); @@ -283,15 +291,15 @@ public int getStart(int segmentNumber) { /** * Retrieves the ending offset of a given segment. * - * @param segmentNumber number of the segment about which information - * is required. It must be >= 0 and less than the number of - * segments returned by {@link #getSegmentCount}. + * @param segmentNumber number of the segment about which information is + * required. It must be >= 0 and less than the number of + * segments returned by {@link #getSegmentCount}. * - * @return the offset of the position following the segment - * specified by segmentNumber. + * @return the offset of the position following the segment specified by + * segmentNumber. * - * @throws IllegalArgumentException if segmentNumber - * has an invalid value. + * @throws IllegalArgumentException if segmentNumber has an invalid + * value. */ public int getLimit(int segmentNumber) { checkSegmentNumber(segmentNumber); diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java index 9f41103dd0c..6586586810d 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/StructuredTextTypesCollector.java @@ -96,7 +96,8 @@ private void read() { for (IExtension extension : extPoint.getExtensions()) { for (IConfigurationElement confElement : extension.getConfigurationElements()) { if (!CE_NAME.equals(confElement.getName())) - StructuredTextActivator.logError("BiDi types: unexpected element name " + confElement.getName(), new IllegalArgumentException()); //$NON-NLS-1$ + StructuredTextActivator.logError("BiDi types: unexpected element name " + confElement.getName(), //$NON-NLS-1$ + new IllegalArgumentException()); String type = confElement.getAttribute(ATTR_TYPE); Object handler; try { @@ -134,11 +135,12 @@ public void removed(IExtensionPoint[] extensionPoints) { } /** - * Returns the default structured text type handlers. These handlers are - * also supported without OSGi running. + * Returns the default structured text type handlers. These handlers are also + * supported without OSGi running. * - * @return a map from structured text type handler identifier (key type: {@link String}) - * to structured text type handler (value type: {@link StructuredTextTypeHandler}). + * @return a map from structured text type handler identifier (key type: + * {@link String}) to structured text type handler (value type: + * {@link StructuredTextTypeHandler}). */ public static Map getDefaultTypeHandlers() { Map types = new LinkedHashMap<>(); diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextComma.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextComma.java index f8a96aa3cb3..503f3946c03 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextComma.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextComma.java @@ -16,10 +16,11 @@ import org.eclipse.equinox.bidi.custom.StructuredTextTypeHandler; /** - * Handler adapted to processing comma-delimited lists, such as: - *

    + * Handler adapted to processing comma-delimited lists, such as:
    + * 
    + * 
      *    part1,part2,part3
    - *  
    + *
    */ public class StructuredTextComma extends StructuredTextTypeHandler { public StructuredTextComma() { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextEmail.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextEmail.java index 7e684509949..1f14b5c0ad7 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextEmail.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextEmail.java @@ -18,7 +18,7 @@ import org.eclipse.equinox.bidi.internal.StructuredTextDelimsEsc; /** - * Handler adapted to processing e-mail addresses. + * Handler adapted to processing e-mail addresses. */ public class StructuredTextEmail extends StructuredTextDelimsEsc { static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT; @@ -35,15 +35,15 @@ public int getDirection(IStructuredTextExpert expert, String text) { } /** - * @return {@link IStructuredTextExpert#DIR_RTL DIR_RTL} if the following - * conditions are satisfied: - *
      - *
    • The current locale (as expressed by the environment - * language) is Arabic.
    • - *
    • The domain part of the email address contains - * at least one RTL character.
    • - *
    - * Otherwise, returns {@link IStructuredTextExpert#DIR_LTR DIR_LTR}. + * @return {@link IStructuredTextExpert#DIR_RTL DIR_RTL} if the following + * conditions are satisfied: + *
      + *
    • The current locale (as expressed by the environment language) is + * Arabic.
    • + *
    • The domain part of the email address contains at least one RTL + * character.
    • + *
    + * Otherwise, returns {@link IStructuredTextExpert#DIR_LTR DIR_LTR}. */ @Override public int getDirection(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes) { @@ -63,7 +63,7 @@ public int getDirection(IStructuredTextExpert expert, String text, StructuredTex } /** - * @return 2 as number of special cases handled by this handler. + * @return 2 as number of special cases handled by this handler. */ @Override public int getSpecialsCount(IStructuredTextExpert expert) { @@ -71,7 +71,7 @@ public int getSpecialsCount(IStructuredTextExpert expert) { } /** - * @return parentheses and quotation marks as delimiters. + * @return parentheses and quotation marks as delimiters. */ @Override protected String getDelimiters() { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextFile.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextFile.java index fb6bc262800..9f5b4ea6163 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextFile.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextFile.java @@ -16,7 +16,7 @@ import org.eclipse.equinox.bidi.custom.StructuredTextTypeHandler; /** - * Handler adapted to processing directory and file paths. + * Handler adapted to processing directory and file paths. */ public class StructuredTextFile extends StructuredTextTypeHandler { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextJava.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextJava.java index 21cfc2b8cc4..6575a325ed6 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextJava.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextJava.java @@ -18,20 +18,19 @@ import org.eclipse.equinox.bidi.internal.StructuredTextActivator; /** - * Handler for structured text composed of Java statements. - * Such a structured text may span multiple lines. - *

    - * In applications like an editor where parts of the text might be modified - * while other parts are not, the user may want to call - * {@link IStructuredTextExpert#leanToFullText} - * separately on each line and save the initial state of each line (this is - * the final state of the previous line which can be retrieved using - * {@link IStructuredTextExpert#getState()}). - * If both the content - * of a line and its initial state have not changed, the user can be sure that - * the last full text computed for this line has not changed either. + * Handler for structured text composed of Java statements. Such a structured + * text may span multiple lines. + *

    + * In applications like an editor where parts of the text might be modified + * while other parts are not, the user may want to call + * {@link IStructuredTextExpert#leanToFullText} separately on each line and save + * the initial state of each line (this is the final state of the previous line + * which can be retrieved using {@link IStructuredTextExpert#getState()}). If + * both the content of a line and its initial state have not changed, the user + * can be sure that the last full text computed for this line has not + * changed either. * - * @see IStructuredTextExpert explanation of state + * @see IStructuredTextExpert explanation of state */ public class StructuredTextJava extends StructuredTextTypeHandler { private static final byte WS = Character.DIRECTIONALITY_WHITESPACE; @@ -43,7 +42,7 @@ public StructuredTextJava() { } /** - * @return 4 as the number of special cases handled by this handler. + * @return 4 as the number of special cases handled by this handler. */ @Override public int getSpecialsCount(IStructuredTextExpert expert) { @@ -51,41 +50,43 @@ public int getSpecialsCount(IStructuredTextExpert expert) { } /** - * Locates occurrences of 4 special strings: - *

      - *
    1. spaces
    2. - *
    3. literals starting with quotation mark
    4. - *
    5. comments starting with slash-asterisk
    6. - *
    7. comments starting with slash-slash
    8. - *
    + * Locates occurrences of 4 special strings: + *
      + *
    1. spaces
    2. + *
    3. literals starting with quotation mark
    4. + *
    5. comments starting with slash-asterisk
    6. + *
    7. comments starting with slash-slash
    8. + *
    */ @Override - public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int fromIndex) { + public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int fromIndex) { switch (caseNumber) { - case 1 : /* space */ - return text.indexOf(' ', fromIndex); - case 2 : /* literal */ - return text.indexOf('"', fromIndex); - case 3 : /* slash-aster comment */ - return text.indexOf("/*", fromIndex); //$NON-NLS-1$ - case 4 : /* slash-slash comment */ - return text.indexOf("//", fromIndex); //$NON-NLS-1$ + case 1: /* space */ + return text.indexOf(' ', fromIndex); + case 2: /* literal */ + return text.indexOf('"', fromIndex); + case 3: /* slash-aster comment */ + return text.indexOf("/*", fromIndex); //$NON-NLS-1$ + case 4: /* slash-slash comment */ + return text.indexOf("//", fromIndex); //$NON-NLS-1$ } // we should never get here return -1; } /** - * Processes the 4 special cases as follows. - *
      - *
    1. skip the run of spaces
    2. - *
    3. look for a matching quotation mark and skip until after it
    4. - *
    5. skip until after the closing asterisk-slash
    6. - *
    7. skip until after a line separator
    8. - *
    + * Processes the 4 special cases as follows. + *
      + *
    1. skip the run of spaces
    2. + *
    3. look for a matching quotation mark and skip until after it
    4. + *
    5. skip until after the closing asterisk-slash
    6. + *
    7. skip until after a line separator
    8. + *
    */ @Override - public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int separLocation) { + public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int separLocation) { int location, counter, i; StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); @@ -94,45 +95,45 @@ public int processSpecial(IStructuredTextExpert expert, String text, StructuredT expert.clearState(); } switch (caseNumber) { - case 1 : /* space */ + case 1: /* space */ + separLocation++; + while (separLocation < text.length() && text.charAt(separLocation) == ' ') { + charTypes.setBidiTypeAt(separLocation, WS); separLocation++; - while (separLocation < text.length() && text.charAt(separLocation) == ' ') { - charTypes.setBidiTypeAt(separLocation, WS); - separLocation++; - } - return separLocation; - case 2 : /* literal */ - location = separLocation + 1; - while (true) { - location = text.indexOf('"', location); - if (location < 0) - return text.length(); - for (counter = 0, i = location - 1; text.charAt(i) == '\\'; i--) { - counter++; - } - location++; - if ((counter & 1) == 0) - return location; - } - case 3 : /* slash-aster comment */ - if (separLocation < 0) { // continuation line - location = 0; - } else - location = separLocation + 2; // skip the opening slash-aster - location = text.indexOf("*/", location); //$NON-NLS-1$ - if (location < 0) { - expert.setState(STATE_SLASH_ASTER_COMMENT); - return text.length(); - } - // we need to call processSeparator since text may follow the - // end of comment immediately without even a space - StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, location); - return location + 2; - case 4 : /* slash-slash comment */ - location = text.indexOf(lineSep, separLocation + 2); + } + return separLocation; + case 2: /* literal */ + location = separLocation + 1; + while (true) { + location = text.indexOf('"', location); if (location < 0) return text.length(); - return location + lineSep.length(); + for (counter = 0, i = location - 1; text.charAt(i) == '\\'; i--) { + counter++; + } + location++; + if ((counter & 1) == 0) + return location; + } + case 3: /* slash-aster comment */ + if (separLocation < 0) { // continuation line + location = 0; + } else + location = separLocation + 2; // skip the opening slash-aster + location = text.indexOf("*/", location); //$NON-NLS-1$ + if (location < 0) { + expert.setState(STATE_SLASH_ASTER_COMMENT); + return text.length(); + } + // we need to call processSeparator since text may follow the + // end of comment immediately without even a space + StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, location); + return location + 2; + case 4: /* slash-slash comment */ + location = text.indexOf(lineSep, separLocation + 2); + if (location < 0) + return text.length(); + return location + lineSep.length(); } // we should never get here return text.length(); diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextRegex.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextRegex.java index b3404da8592..11d948002e1 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextRegex.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextRegex.java @@ -18,32 +18,30 @@ import org.eclipse.equinox.bidi.custom.*; /** - * Handler for regular expressions. - * Such expressions may span multiple lines. - *

    - * In applications like an editor where parts of the text might be modified - * while other parts are not, the user may want to call - * {@link IStructuredTextExpert#leanToFullText} - * separately on each line and save the initial state of each line (this is - * the final state of the previous line which can be retrieved using - * {@link IStructuredTextExpert#getState()}. - * If both the content - * of a line and its initial state have not changed, the user can be sure that - * the last full text computed for this line has not changed either. + * Handler for regular expressions. Such expressions may span multiple lines. + *

    + * In applications like an editor where parts of the text might be modified + * while other parts are not, the user may want to call + * {@link IStructuredTextExpert#leanToFullText} separately on each line and save + * the initial state of each line (this is the final state of the previous line + * which can be retrieved using {@link IStructuredTextExpert#getState()}. If + * both the content of a line and its initial state have not changed, the user + * can be sure that the last full text computed for this line has not + * changed either. * - * @see IStructuredTextExpert explanation of state + * @see IStructuredTextExpert explanation of state */ public class StructuredTextRegex extends StructuredTextTypeHandler { - static final String[] startStrings = {"", /* 0 *//* dummy *///$NON-NLS-1$ - "(?#", /* 1 *//* comment (?#...) *///$NON-NLS-1$ - "(?<", /* 2 *//* named group (? *///$NON-NLS-1$ - "(?'", /* 3 *//* named group (?'name' *///$NON-NLS-1$ - "(?(<", /* 4 *//* conditional named back reference (?() *///$NON-NLS-1$ - "(?('", /* 5 *//* conditional named back reference (?('name') *///$NON-NLS-1$ - "(?(", /* 6 *//* conditional named back reference (?(name) *///$NON-NLS-1$ - "(?&", /* 7 *//* named parentheses reference (?&name) *///$NON-NLS-1$ - "(?P<", /* 8 *//* named group (?P *///$NON-NLS-1$ - "\\k<", /* 9 *//* named back reference \k *///$NON-NLS-1$ + static final String[] startStrings = { "", /* 0 *//* dummy *///$NON-NLS-1$ + "(?#", /* 1 *//* comment (?#...) *///$NON-NLS-1$ + "(?<", /* 2 *//* named group (? *///$NON-NLS-1$ + "(?'", /* 3 *//* named group (?'name' *///$NON-NLS-1$ + "(?(<", /* 4 *//* conditional named back reference (?() *///$NON-NLS-1$ + "(?('", /* 5 *//* conditional named back reference (?('name') *///$NON-NLS-1$ + "(?(", /* 6 *//* conditional named back reference (?(name) *///$NON-NLS-1$ + "(?&", /* 7 *//* named parentheses reference (?&name) *///$NON-NLS-1$ + "(?P<", /* 8 *//* named group (?P *///$NON-NLS-1$ + "\\k<", /* 9 *//* named back reference \k *///$NON-NLS-1$ "\\k'", /* 10 *//* named back reference \k'name' *///$NON-NLS-1$ "\\k{", /* 11 *//* named back reference \k{name} *///$NON-NLS-1$ "(?P=", /* 12 *//* named back reference (?P=name) *///$NON-NLS-1$ @@ -54,8 +52,8 @@ public class StructuredTextRegex extends StructuredTextTypeHandler { "\\Q" /* 17 *//* quoted sequence \Q...\E *///$NON-NLS-1$ }; static final char[] endChars = { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 - '.', ')', '>', '\'', ')', ')', ')', ')', '>', '>', '\'', '}', ')', '}', '>', '\'', ')'}; + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + '.', ')', '>', '\'', ')', ')', ')', ')', '>', '>', '\'', '}', ')', '}', '>', '\'', ')' }; static final int numberOfStrings = startStrings.length; /* 18 */ static final int maxSpecial = numberOfStrings; static final byte L = Character.DIRECTIONALITY_LEFT_TO_RIGHT; @@ -67,9 +65,9 @@ public class StructuredTextRegex extends StructuredTextTypeHandler { private static final Integer STATE_QUOTED_SEQUENCE = Integer.valueOf(17); /** - * Retrieves the number of special cases handled by this handler. - * - * @return the number of special cases for this handler. + * Retrieves the number of special cases handled by this handler. + * + * @return the number of special cases for this handler. */ @Override public int getSpecialsCount(IStructuredTextExpert expert) { @@ -77,31 +75,31 @@ public int getSpecialsCount(IStructuredTextExpert expert) { } /** - * Locates occurrences of the syntactic strings and of - * R, AL, EN, AN characters. + * Locates occurrences of the syntactic strings and of R, AL, EN, AN characters. */ @Override - public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int fromIndex) { + public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int fromIndex) { // In this method, L, R, AL, AN and EN represent bidi categories // as defined in the Unicode Bidirectional Algorithm // ( http://www.unicode.org/reports/tr9/ ). - // L represents the category Left to Right character. - // R represents the category Right to Left character. + // L represents the category Left to Right character. + // R represents the category Right to Left character. // AL represents the category Arabic Letter. // AN represents the category Arabic Number. - // EN represents the category European Number. + // EN represents the category European Number. byte charType; if (caseNumber < numberOfStrings) { - /* 1 *//* comment (?#...) */ - /* 2 *//* named group (? */ - /* 3 *//* named group (?'name' */ - /* 4 *//* conditional named back reference (?(name) */ - /* 5 *//* conditional named back reference (?() */ - /* 6 *//* conditional named back reference (?('name') */ - /* 7 *//* named parentheses reference (?&name) */ - /* 8 *//* named group (?P */ - /* 9 *//* named back reference \k */ + /* 1 *//* comment (?#...) */ + /* 2 *//* named group (? */ + /* 3 *//* named group (?'name' */ + /* 4 *//* conditional named back reference (?(name) */ + /* 5 *//* conditional named back reference (?() */ + /* 6 *//* conditional named back reference (?('name') */ + /* 7 *//* named parentheses reference (?&name) */ + /* 8 *//* named group (?P */ + /* 9 *//* named back reference \k */ /* 10 *//* named back reference \k'name' */ /* 11 *//* named back reference \k{name} */ /* 12 *//* named back reference (?P=name) */ @@ -134,9 +132,9 @@ public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredT continue; // digit after R or AL or AN need a mark, except for EN - // following AN, but this is a contrived case, so we - // don't check for it (and calling processSeparator() - // for it will do no harm) + // following AN, but this is a contrived case, so we + // don't check for it (and calling processSeparator() + // for it will do no harm) if (charType == R || charType == AL || charType == AN) return fromIndex; } @@ -147,10 +145,11 @@ public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredT } /** - * Processes the special cases. + * Processes the special cases. */ @Override - public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int separLocation) { + public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int separLocation) { int location; if (separLocation < 0) { @@ -158,66 +157,66 @@ public int processSpecial(IStructuredTextExpert expert, String text, StructuredT expert.clearState(); } switch (caseNumber) { - case 1 : /* comment (?#...) */ - if (separLocation < 0) { - // initial state from previous line - location = 0; - } else { - StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); - // skip the opening "(?#" - location = separLocation + 3; - } - location = text.indexOf(')', location); - if (location < 0) { - expert.setState(STATE_COMMENT); - return text.length(); - } - return location + 1; - case 2 : /* named group (? */ - case 3 : /* named group (?'name' */ - case 4 : /* conditional named back reference (?(name) */ - case 5 : /* conditional named back reference (?() */ - case 6 : /* conditional named back reference (?('name') */ - case 7 : /* named parentheses reference (?&name) */ + case 1: /* comment (?#...) */ + if (separLocation < 0) { + // initial state from previous line + location = 0; + } else { StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); - // no need for calling processSeparator() for the following cases - // since the starting string contains a L char - case 8 : /* named group (?P */ - case 9 : /* named back reference \k */ - case 10 : /* named back reference \k'name' */ - case 11 : /* named back reference \k{name} */ - case 12 : /* named back reference (?P=name) */ - case 13 : /* named back reference \g{name} */ - case 14 : /* subroutine call \g */ - case 15 : /* subroutine call \g'name' */ - case 16 : /* named back reference recursion (?(R&name) */ - // skip the opening string - location = separLocation + startStrings[caseNumber].length(); - // look for ending character - location = text.indexOf(endChars[caseNumber], location); - if (location < 0) - return text.length(); - return location + 1; - case 17 : /* quoted sequence \Q...\E */ - if (separLocation < 0) { - // initial state from previous line - location = 0; - } else { - StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); - // skip the opening "\Q" - location = separLocation + 2; - } - location = text.indexOf("\\E", location); //$NON-NLS-1$ - if (location < 0) { - expert.setState(STATE_QUOTED_SEQUENCE); - return text.length(); - } - // set the charType for the "E" to L (Left to Right character) - charTypes.setBidiTypeAt(location + 1, L); - return location + 2; - case 18 : /* R, AL, AN, EN */ + // skip the opening "(?#" + location = separLocation + 3; + } + location = text.indexOf(')', location); + if (location < 0) { + expert.setState(STATE_COMMENT); + return text.length(); + } + return location + 1; + case 2: /* named group (? */ + case 3: /* named group (?'name' */ + case 4: /* conditional named back reference (?(name) */ + case 5: /* conditional named back reference (?() */ + case 6: /* conditional named back reference (?('name') */ + case 7: /* named parentheses reference (?&name) */ + StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); + // no need for calling processSeparator() for the following cases + // since the starting string contains a L char + case 8: /* named group (?P */ + case 9: /* named back reference \k */ + case 10: /* named back reference \k'name' */ + case 11: /* named back reference \k{name} */ + case 12: /* named back reference (?P=name) */ + case 13: /* named back reference \g{name} */ + case 14: /* subroutine call \g */ + case 15: /* subroutine call \g'name' */ + case 16: /* named back reference recursion (?(R&name) */ + // skip the opening string + location = separLocation + startStrings[caseNumber].length(); + // look for ending character + location = text.indexOf(endChars[caseNumber], location); + if (location < 0) + return text.length(); + return location + 1; + case 17: /* quoted sequence \Q...\E */ + if (separLocation < 0) { + // initial state from previous line + location = 0; + } else { StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); - return separLocation + 1; + // skip the opening "\Q" + location = separLocation + 2; + } + location = text.indexOf("\\E", location); //$NON-NLS-1$ + if (location < 0) { + expert.setState(STATE_QUOTED_SEQUENCE); + return text.length(); + } + // set the charType for the "E" to L (Left to Right character) + charTypes.setBidiTypeAt(location + 1, L); + return location + 2; + case 18: /* R, AL, AN, EN */ + StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); + return separLocation + 1; } // we should never get here @@ -230,16 +229,15 @@ public int getDirection(IStructuredTextExpert expert, String text) { } /** - * @return {@link IStructuredTextExpert#DIR_RTL DIR_RTL} if the following - * conditions are satisfied: - *

      - *
    • The current locale (as expressed by the environment - * language) is Arabic.
    • - *
    • The first strong character has an RTL direction.
    • - *
    • If there is no strong character in the text, the - * GUI is mirrored. - *
    - * Otherwise, returns {@link IStructuredTextExpert#DIR_LTR DIR_LTR}. + * @return {@link IStructuredTextExpert#DIR_RTL DIR_RTL} if the following + * conditions are satisfied: + *
      + *
    • The current locale (as expressed by the environment language) is + * Arabic.
    • + *
    • The first strong character has an RTL direction.
    • + *
    • If there is no strong character in the text, the GUI is mirrored. + *
    + * Otherwise, returns {@link IStructuredTextExpert#DIR_LTR DIR_LTR}. */ @Override public int getDirection(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes) { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextSql.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextSql.java index 611cb8411ca..be257b7bf20 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextSql.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextSql.java @@ -18,20 +18,19 @@ import org.eclipse.equinox.bidi.internal.StructuredTextActivator; /** - * Handler for structured text composed of SQL statements. - * Such a structured text may span multiple lines. - *

    - * In applications like an editor where parts of the text might be modified - * while other parts are not, the user may want to call - * {@link IStructuredTextExpert#leanToFullText} - * separately on each line and save the initial state of each line (this is - * the final state of the previous line which can be retrieved by calling - * {@link IStructuredTextExpert#getState()}. - * If both the content - * of a line and its initial state have not changed, the user can be sure that - * the last full text computed for this line has not changed either. + * Handler for structured text composed of SQL statements. Such a structured + * text may span multiple lines. + *

    + * In applications like an editor where parts of the text might be modified + * while other parts are not, the user may want to call + * {@link IStructuredTextExpert#leanToFullText} separately on each line and save + * the initial state of each line (this is the final state of the previous line + * which can be retrieved by calling {@link IStructuredTextExpert#getState()}. + * If both the content of a line and its initial state have not changed, the + * user can be sure that the last full text computed for this line has + * not changed either. * - * @see IStructuredTextExpert explanation of state + * @see IStructuredTextExpert explanation of state */ public class StructuredTextSql extends StructuredTextTypeHandler { private static final byte WS = Character.DIRECTIONALITY_WHITESPACE; @@ -44,7 +43,7 @@ public StructuredTextSql() { } /** - * @return 5 as the number of special cases handled by this handler. + * @return 5 as the number of special cases handled by this handler. */ @Override public int getSpecialsCount(IStructuredTextExpert expert) { @@ -52,45 +51,47 @@ public int getSpecialsCount(IStructuredTextExpert expert) { } /** - * Locates occurrences of 5 special strings: - *

      - *
    1. spaces
    2. - *
    3. literals starting with apostrophe
    4. - *
    5. identifiers starting with quotation mark
    6. - *
    7. comments starting with slash-asterisk
    8. - *
    9. comments starting with hyphen-hyphen
    10. - *
    + * Locates occurrences of 5 special strings: + *
      + *
    1. spaces
    2. + *
    3. literals starting with apostrophe
    4. + *
    5. identifiers starting with quotation mark
    6. + *
    7. comments starting with slash-asterisk
    8. + *
    9. comments starting with hyphen-hyphen
    10. + *
    */ @Override - public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int fromIndex) { + public int indexOfSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int fromIndex) { switch (caseNumber) { - case 1 : /* space */ - return text.indexOf(" ", fromIndex); //$NON-NLS-1$ - case 2 : /* literal */ - return text.indexOf('\'', fromIndex); - case 3 : /* delimited identifier */ - return text.indexOf('"', fromIndex); - case 4 : /* slash-aster comment */ - return text.indexOf("/*", fromIndex); //$NON-NLS-1$ - case 5 : /* hyphen-hyphen comment */ - return text.indexOf("--", fromIndex); //$NON-NLS-1$ + case 1: /* space */ + return text.indexOf(" ", fromIndex); //$NON-NLS-1$ + case 2: /* literal */ + return text.indexOf('\'', fromIndex); + case 3: /* delimited identifier */ + return text.indexOf('"', fromIndex); + case 4: /* slash-aster comment */ + return text.indexOf("/*", fromIndex); //$NON-NLS-1$ + case 5: /* hyphen-hyphen comment */ + return text.indexOf("--", fromIndex); //$NON-NLS-1$ } // we should never get here return -1; } /** - * Processes the 5 special cases as follows. - *
      - *
    1. skip the run of spaces
    2. - *
    3. look for a matching apostrophe and skip until after it
    4. - *
    5. look for a matching quotation mark and skip until after it
    6. - *
    7. skip until after the closing asterisk-slash
    8. - *
    9. skip until after a line separator
    10. - *
    + * Processes the 5 special cases as follows. + *
      + *
    1. skip the run of spaces
    2. + *
    3. look for a matching apostrophe and skip until after it
    4. + *
    5. look for a matching quotation mark and skip until after it
    6. + *
    7. skip until after the closing asterisk-slash
    8. + *
    9. skip until after a line separator
    10. + *
    */ @Override - public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, StructuredTextOffsets offsets, int caseNumber, int separLocation) { + public int processSpecial(IStructuredTextExpert expert, String text, StructuredTextCharTypes charTypes, + StructuredTextOffsets offsets, int caseNumber, int separLocation) { int location; StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, separLocation); @@ -99,59 +100,59 @@ public int processSpecial(IStructuredTextExpert expert, String text, StructuredT expert.clearState(); } switch (caseNumber) { - case 1 : /* space */ + case 1: /* space */ + separLocation++; + while (separLocation < text.length() && text.charAt(separLocation) == ' ') { + charTypes.setBidiTypeAt(separLocation, WS); separLocation++; - while (separLocation < text.length() && text.charAt(separLocation) == ' ') { - charTypes.setBidiTypeAt(separLocation, WS); - separLocation++; - } - return separLocation; - case 2 : /* literal */ - location = separLocation + 1; - while (true) { - location = text.indexOf('\'', location); - if (location < 0) { - expert.setState(STATE_LITERAL); - return text.length(); - } - if ((location + 1) < text.length() && text.charAt(location + 1) == '\'') { - location += 2; - continue; - } - return location + 1; - } - case 3 : /* delimited identifier */ - location = separLocation + 1; - while (true) { - location = text.indexOf('"', location); - if (location < 0) - return text.length(); - - if ((location + 1) < text.length() && text.charAt(location + 1) == '"') { - location += 2; - continue; - } - return location + 1; - } - case 4 : /* slash-aster comment */ - if (separLocation < 0) // continuation line - location = 0; - else - location = separLocation + 2; // skip the opening slash-aster - location = text.indexOf("*/", location); //$NON-NLS-1$ + } + return separLocation; + case 2: /* literal */ + location = separLocation + 1; + while (true) { + location = text.indexOf('\'', location); if (location < 0) { - expert.setState(STATE_SLASH_ASTER_COMMENT); + expert.setState(STATE_LITERAL); return text.length(); } - // we need to call processSeparator since text may follow the - // end of comment immediately without even a space - StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, location); - return location + 2; - case 5 : /* hyphen-hyphen comment */ - location = text.indexOf(lineSep, separLocation + 2); + if ((location + 1) < text.length() && text.charAt(location + 1) == '\'') { + location += 2; + continue; + } + return location + 1; + } + case 3: /* delimited identifier */ + location = separLocation + 1; + while (true) { + location = text.indexOf('"', location); if (location < 0) return text.length(); - return location + lineSep.length(); + + if ((location + 1) < text.length() && text.charAt(location + 1) == '"') { + location += 2; + continue; + } + return location + 1; + } + case 4: /* slash-aster comment */ + if (separLocation < 0) // continuation line + location = 0; + else + location = separLocation + 2; // skip the opening slash-aster + location = text.indexOf("*/", location); //$NON-NLS-1$ + if (location < 0) { + expert.setState(STATE_SLASH_ASTER_COMMENT); + return text.length(); + } + // we need to call processSeparator since text may follow the + // end of comment immediately without even a space + StructuredTextTypeHandler.processSeparator(text, charTypes, offsets, location); + return location + 2; + case 5: /* hyphen-hyphen comment */ + location = text.indexOf(lineSep, separLocation + 2); + if (location < 0) + return text.length(); + return location + lineSep.length(); } // we should never get here return text.length(); diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextURL.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextURL.java index 1d53bd8035f..b3057492653 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextURL.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextURL.java @@ -16,7 +16,7 @@ import org.eclipse.equinox.bidi.custom.StructuredTextTypeHandler; /** - * Handler adapted to processing URLs. + * Handler adapted to processing URLs. */ public class StructuredTextURL extends StructuredTextTypeHandler { public StructuredTextURL() { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextUnderscore.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextUnderscore.java index 22527543e3c..181efd2e7bd 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextUnderscore.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextUnderscore.java @@ -16,11 +16,12 @@ import org.eclipse.equinox.bidi.custom.StructuredTextTypeHandler; /** - * Handler adapted to processing compound names. - * This type covers names made of one or more parts, separated by underscores: - *
    - *    part1_part2_part3
    - *  
    + * Handler adapted to processing compound names. This type covers names made of + * one or more parts, separated by underscores: + * + *
    + * part1_part2_part3
    + * 
    */ public class StructuredTextUnderscore extends StructuredTextTypeHandler { diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextXPath.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextXPath.java index d470fe4fa01..862a471ba42 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextXPath.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/StructuredTextXPath.java @@ -17,7 +17,7 @@ import org.eclipse.equinox.bidi.internal.StructuredTextDelims; /** - * Handler adapted to processing XPath expressions. + * Handler adapted to processing XPath expressions. */ public class StructuredTextXPath extends StructuredTextDelims { @@ -26,7 +26,7 @@ public StructuredTextXPath() { } /** - * @return 2 as the number of special cases handled by this handler. + * @return 2 as the number of special cases handled by this handler. */ @Override public int getSpecialsCount(IStructuredTextExpert expert) { @@ -34,7 +34,7 @@ public int getSpecialsCount(IStructuredTextExpert expert) { } /** - * @return apostrophe and quotation mark as delimiters. + * @return apostrophe and quotation mark as delimiters. */ @Override protected String getDelimiters() {