Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatitiahu Allouche2011-08-15 15:21:00 +0000
committerOleg Besedin2011-08-15 15:21:00 +0000
commitd28ed57b11a0f78eb226df721e1f328e016b6ba3 (patch)
treee55683aaaf4664b5ed6832a82fcdeb45a7b0008f /bundles/org.eclipse.equinox.bidi
parent96133d5719013acd843bd601f78ba0d706de1d20 (diff)
downloadrt.equinox.bundles-d28ed57b11a0f78eb226df721e1f328e016b6ba3.tar.gz
rt.equinox.bundles-d28ed57b11a0f78eb226df721e1f328e016b6ba3.tar.xz
rt.equinox.bundles-d28ed57b11a0f78eb226df721e1f328e016b6ba3.zip
Bug 183164 - [Implementation for] Display of Complex Expressions
Containing Bidirectional Text
Diffstat (limited to 'bundles/org.eclipse.equinox.bidi')
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java3
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextState.java47
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java44
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java2
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java11
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java14
-rw-r--r--bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java14
12 files changed, 100 insertions, 49 deletions
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
index e1b986f9b..a5dfe98ac 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
@@ -61,8 +61,7 @@ package org.eclipse.equinox.bidi.advanced;
* code in order to obtain the <i>full</i>
* text corresponding to the <i>lean</i> text of each line.
* <pre>
- * int[] state = new int[1];
- * state[0] = STextEngine.STATE_INITIAL;
+ * Object state = STextState.createState();
* String leanText = "int i = 3; // first Java statement";
* String fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
* System.out.println("full text = " + fullText);
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java
index cebf2fd04..befbd206d 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpertStateful.java
@@ -12,9 +12,9 @@ package org.eclipse.equinox.bidi.advanced;
public interface ISTextExpertStateful extends ISTextExpert {
- public void setState(int state);
+ public void setState(Object state);
- public int getState();
+ public Object getState();
/**
* Resets non-shared expert state to initial.
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
index 220de732a..fdf6aaae9 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
@@ -77,7 +77,7 @@ final public class STextExpertFactory {
}
static public ISTextExpert getExpert(STextTypeHandler handler, STextEnvironment environment) {
- return new STextImpl(handler, environment, new int[1]);
+ return new STextImpl(handler, environment, STextState.createState());
}
static public ISTextExpertStateful getPrivateExpert(String type) {
@@ -88,7 +88,7 @@ final public class STextExpertFactory {
STextTypeHandler handler = STextTypeHandlerFactory.getHandler(type);
if (handler == null)
return null;
- return new STextImpl(handler, environment, new int[1]);
+ return new STextImpl(handler, environment, STextState.createState());
}
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextState.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextState.java
new file mode 100644
index 000000000..68ba497f5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextState.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.advanced;
+
+final public class STextState {
+
+ private STextState() {
+ // prevent instantiation
+ }
+
+ public static Object createState() {
+ return new Object[1];
+ }
+
+ public static Object getValueAndReset(Object state) {
+ if (state instanceof Object[]) {
+ Object[] values = (Object[]) state;
+ if (values.length > 0) {
+ Object value = values[0];
+ values[0] = null;
+ return value;
+ }
+ }
+ throw new IllegalArgumentException("Invalid state argument"); //$NON-NLS-1$
+ }
+
+ public static void setValue(Object state, Object value) {
+ if (state == null)
+ return;
+ if (state instanceof Object[]) {
+ Object[] values = (Object[]) state;
+ if (values.length > 0)
+ values[0] = value;
+ return;
+ }
+ throw new IllegalArgumentException("Invalid state argument"); //$NON-NLS-1$
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java
index 5715ea103..b63001509 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextTypeHandler.java
@@ -210,7 +210,7 @@ public class STextTypeHandler {
* number of special cases is zero, which means that
* <code>processSpecial</code> should never be called for them.
*/
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, Object state, 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$
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
index ce8662989..bcddf10cf 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java
@@ -58,7 +58,7 @@ public abstract class STextDelims extends STextTypeHandler {
* @return the position after the matching end delimiter, or the length
* of <code>text</code> if no end delimiter is found.
*/
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, Object state, int caseNumber, int separLocation) {
STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
int loc = separLocation + 1;
char delim = getDelimiters().charAt((caseNumber * 2) - 1);
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
index 3f8124295..49552f20d 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java
@@ -49,7 +49,7 @@ public abstract class STextDelimsEsc extends STextDelims {
* and skips until after the matching end delimiter,
* ignoring possibly escaped end delimiters.
*/
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, Object state, int caseNumber, int separLocation) {
STextTypeHandler.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/STextImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
index 1137826db..a004be198 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java
@@ -46,13 +46,12 @@ public class STextImpl implements ISTextExpertStateful {
static final int FIXES_LENGTH = PREFIX_LENGTH + SUFFIX_LENGTH;
static final int[] EMPTY_INT_ARRAY = new int[0];
static final STextEnvironment IGNORE_ENVIRONMENT = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE);
- static final int STATE_INITIAL = 0;
protected STextTypeHandler structuredTextHandler;
protected STextEnvironment environment;
- protected int[] state;
+ protected Object state;
- public STextImpl(STextTypeHandler structuredTextHandler, STextEnvironment environment, int[] state) {
+ public STextImpl(STextTypeHandler structuredTextHandler, STextEnvironment environment, Object state) {
this.structuredTextHandler = structuredTextHandler;
this.environment = environment;
this.state = state;
@@ -87,20 +86,21 @@ public class STextImpl implements ISTextExpertStateful {
}
public void resetState() {
- state[0] = STATE_INITIAL;
+ STextState.setValue(state, null);
}
- public void setState(int newState) {
- state[0] = newState;
+ public void setState(Object newState) {
+ STextState.setValue(state, newState);
}
- public static void setState(int[] state, int newState) {
- if (state != null)
- state[0] = newState;
+ public static void setState(Object state, Object newState) {
+ STextState.setValue(state, newState);
}
- public int getState() {
- return state[0];
+ public Object getState() {
+ Object value = STextState.getValueAndReset(state);
+ STextState.setValue(state, value);
+ return value;
}
static long computeNextLocation(STextTypeHandler handler, STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] locations, int curPos) {
@@ -243,7 +243,7 @@ public class STextImpl implements ISTextExpertStateful {
* <p>
* @see ISTextExpert#leanToFullText STextEngine.leanToFullText
*/
- public static String leanToFullText(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
+ public static String leanToFullText(STextTypeHandler handler, STextEnvironment environment, String text, Object state) {
int len = text.length();
if (len == 0)
return text;
@@ -290,7 +290,7 @@ public class STextImpl implements ISTextExpertStateful {
return new String(fullChars);
}
- public static int[] leanToFullMap(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanToFullMap(STextTypeHandler handler, STextEnvironment environment, String text, Object state) {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
@@ -310,7 +310,7 @@ public class STextImpl implements ISTextExpertStateful {
return map;
}
- public static int[] leanBidiCharOffsets(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
+ public static int[] leanBidiCharOffsets(STextTypeHandler handler, STextEnvironment environment, String text, Object state) {
int len = text.length();
if (len == 0)
return EMPTY_INT_ARRAY;
@@ -319,7 +319,7 @@ public class STextImpl implements ISTextExpertStateful {
return offsets.getArray();
}
- static STextOffsets leanToFullCommon(STextTypeHandler handler, STextEnvironment environment, String text, int[] state, STextCharTypes charTypes) {
+ static STextOffsets leanToFullCommon(STextTypeHandler handler, STextEnvironment environment, String text, Object state, STextCharTypes charTypes) {
if (environment == null)
environment = STextEnvironment.DEFAULT;
int len = text.length();
@@ -334,11 +334,11 @@ public class STextImpl implements ISTextExpertStateful {
}
// current position
int curPos = 0;
- if (state != null && state[0] > STATE_INITIAL) {
+ Object value;
+ if (state != null && (value = STextState.getValueAndReset(state)) != null) {
+ STextState.setValue(state, value); // restore the value
offsets.ensureRoom();
- int initState = state[0];
- state[0] = STATE_INITIAL;
- curPos = handler.processSpecial(environment, text, charTypes, offsets, state, initState, -1);
+ curPos = handler.processSpecial(environment, text, charTypes, offsets, state, 0, -1);
}
while (true) {
// location of next token to handle
@@ -379,7 +379,7 @@ public class STextImpl implements ISTextExpertStateful {
return offsets;
}
- public static String fullToLeanText(STextTypeHandler handler, STextEnvironment environment, String text, int[] state) {
+ public static String fullToLeanText(STextTypeHandler handler, STextEnvironment environment, String text, Object state) {
if (text.length() == 0)
return text;
if (environment == null)
@@ -467,7 +467,7 @@ public class STextImpl implements ISTextExpertStateful {
return lean;
}
- public static int[] fullToLeanMap(STextTypeHandler handler, STextEnvironment environment, String full, int[] state) {
+ public static int[] fullToLeanMap(STextTypeHandler handler, STextEnvironment environment, String full, Object state) {
int lenFull = full.length();
if (lenFull == 0)
return EMPTY_INT_ARRAY;
@@ -498,7 +498,7 @@ public class STextImpl implements ISTextExpertStateful {
return map;
}
- public static int[] fullBidiCharOffsets(STextTypeHandler handler, STextEnvironment environment, String full, int[] state) {
+ public static int[] fullBidiCharOffsets(STextTypeHandler handler, STextEnvironment environment, String full, Object state) {
int lenFull = full.length();
if (lenFull == 0)
return EMPTY_INT_ARRAY;
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
index 3ea4d4a69..d4ff00e18 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java
@@ -50,7 +50,7 @@ public class STextSingle extends STextTypeHandler {
*
* @return the length of <code>text</code>.
*/
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, Object state, int caseNumber, int separLocation) {
STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
return text.length();
}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
index 5e3d49c0e..fa8e702d4 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java
@@ -10,11 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.*;
import org.eclipse.equinox.bidi.custom.*;
import org.eclipse.equinox.bidi.internal.STextActivator;
-import org.eclipse.equinox.bidi.internal.STextImpl;
/**
* <code>STextJava</code> is a handler for structured text
@@ -38,6 +36,7 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
public class STextJava extends STextTypeHandler {
private static final byte WS = Character.DIRECTIONALITY_WHITESPACE;
static final String lineSep = STextActivator.getInstance().getProperty("line.separator"); //$NON-NLS-1$
+ private static final Integer INTEGER_3 = new Integer(3);
public STextJava() {
super("[](){}.+-<>=~!&*/%^|?:,;\t"); //$NON-NLS-1$
@@ -83,10 +82,12 @@ public class STextJava extends STextTypeHandler {
* <li>skip until after a line separator</li>
* </ol>
*/
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, Object state, int caseNumber, int separLocation) {
int location, counter, i;
STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
+ if (separLocation < 0)
+ caseNumber = ((Integer) STextState.getValueAndReset(state)).intValue();
switch (caseNumber) {
case 1 : /* space */
separLocation++;
@@ -115,7 +116,7 @@ public class STextJava extends STextTypeHandler {
location = separLocation + 2; // skip the opening slash-aster
location = text.indexOf("*/", location); //$NON-NLS-1$
if (location < 0) {
- STextImpl.setState(state, caseNumber);
+ STextState.setValue(state, INTEGER_3);
return text.length();
}
// we need to call processSeparator since text may follow the
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
index 4816d4e0d..93edff294 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java
@@ -11,10 +11,8 @@
package org.eclipse.equinox.bidi.internal.consumable;
import org.eclipse.equinox.bidi.STextDirection;
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.*;
import org.eclipse.equinox.bidi.custom.*;
-import org.eclipse.equinox.bidi.internal.STextImpl;
/**
* <code>STextRegex</code> is a handler for regular expressions.
@@ -64,6 +62,8 @@ public class STextRegex extends STextTypeHandler {
static final byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
static final byte AN = Character.DIRECTIONALITY_ARABIC_NUMBER;
static final byte EN = Character.DIRECTIONALITY_EUROPEAN_NUMBER;
+ private static final Integer INTEGER_1 = new Integer(1);
+ private static final Integer INTEGER_17 = new Integer(17);
/**
* This method retrieves the number of special cases handled by this handler.
@@ -146,9 +146,11 @@ public class STextRegex extends STextTypeHandler {
/**
* This method process the special cases.
*/
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, Object state, int caseNumber, int separLocation) {
int location;
+ if (separLocation < 0)
+ caseNumber = ((Integer) STextState.getValueAndReset(state)).intValue();
switch (caseNumber) {
case 1 : /* comment (?#...) */
if (separLocation < 0) {
@@ -161,7 +163,7 @@ public class STextRegex extends STextTypeHandler {
}
location = text.indexOf(')', location);
if (location < 0) {
- STextImpl.setState(state, caseNumber);
+ STextState.setValue(state, INTEGER_1);
return text.length();
}
return location + 1;
@@ -201,7 +203,7 @@ public class STextRegex extends STextTypeHandler {
}
location = text.indexOf("\\E", location); //$NON-NLS-1$
if (location < 0) {
- STextImpl.setState(state, caseNumber);
+ STextState.setValue(state, INTEGER_17);
return text.length();
}
// set the charType for the "E" to L (Left to Right character)
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
index 3b74b43a8..bee84c98b 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java
@@ -10,11 +10,9 @@
******************************************************************************/
package org.eclipse.equinox.bidi.internal.consumable;
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.*;
import org.eclipse.equinox.bidi.custom.*;
import org.eclipse.equinox.bidi.internal.STextActivator;
-import org.eclipse.equinox.bidi.internal.STextImpl;
/**
* <code>STextSql</code> is a handler for structured text
@@ -38,6 +36,8 @@ import org.eclipse.equinox.bidi.internal.STextImpl;
public class STextSql extends STextTypeHandler {
private static final byte WS = Character.DIRECTIONALITY_WHITESPACE;
static final String lineSep = STextActivator.getInstance().getProperty("line.separator"); //$NON-NLS-1$
+ private static final Integer INTEGER_2 = new Integer(2);
+ private static final Integer INTEGER_4 = new Integer(4);
public STextSql() {
super("\t!#%&()*+,-./:;<=>?|[]{}"); //$NON-NLS-1$
@@ -87,10 +87,12 @@ public class STextSql extends STextTypeHandler {
* <li>skip until after a line separator</li>
* </ol>
*/
- public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, int[] state, int caseNumber, int separLocation) {
+ public int processSpecial(STextEnvironment environment, String text, STextCharTypes charTypes, STextOffsets offsets, Object state, int caseNumber, int separLocation) {
int location;
STextTypeHandler.processSeparator(text, charTypes, offsets, separLocation);
+ if (separLocation < 0)
+ caseNumber = ((Integer) STextState.getValueAndReset(state)).intValue();
switch (caseNumber) {
case 1 : /* space */
separLocation++;
@@ -104,7 +106,7 @@ public class STextSql extends STextTypeHandler {
while (true) {
location = text.indexOf('\'', location);
if (location < 0) {
- STextImpl.setState(state, caseNumber);
+ STextState.setValue(state, INTEGER_2);
return text.length();
}
if ((location + 1) < text.length() && text.charAt(location + 1) == '\'') {
@@ -133,7 +135,7 @@ public class STextSql extends STextTypeHandler {
location = separLocation + 2; // skip the opening slash-aster
location = text.indexOf("*/", location); //$NON-NLS-1$
if (location < 0) {
- STextImpl.setState(state, caseNumber);
+ STextState.setValue(state, INTEGER_4);
return text.length();
}
// we need to call processSeparator since text may follow the

Back to the top