1) Added setting of syntax properties to italic, underline and strike through.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / php / PHPCodeScanner.java
index eaa7e44..70df0eb 100644 (file)
@@ -24,7 +24,9 @@ import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector;
 import net.sourceforge.phpeclipse.phpeditor.util.PHPWordDetector;
 
 import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.Assert;
+//incastrix
+//import org.eclipse.jface.text.Assert;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.jface.text.rules.ICharacterScanner;
 import org.eclipse.jface.text.rules.IRule;
 import org.eclipse.jface.text.rules.IToken;
@@ -47,8 +49,9 @@ public class PHPCodeScanner extends AbstractJavaScanner {
        protected class OperatorRule implements IRule {
 
                /** Java operators */
-               private final char[] PHP_OPERATORS = { ';', '(', ')', '.', '=', '/', '\\', '+', '-', '*', '[', ']', '<', '>', ':', '?', '!',
-                               ',', '|', '&', '^', '%', '~', '@' };
+               private final char[] PHP_OPERATORS = { ';', '(', ')', '.', '=', '/',
+                               '\\', '+', '-', '*', '[', ']', '<', '>', ':', '?', '!', ',',
+                               '|', '&', '^', '%', '~', '@' };
 
                /** Token to return for this rule */
                private final IToken fToken;
@@ -63,11 +66,12 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                 * Creates a new operator rule.
                 *
                 * @param token
-                *          Token to use for this rule
+                *            Token to use for this rule
                 * @param tokenHeredoc
-                *          TODO
+                *            TODO
                 */
-               public OperatorRule(IToken token, IToken tokenBraces, IToken tokenHeredoc) {
+               public OperatorRule(IToken token, IToken tokenBraces,
+                               IToken tokenHeredoc) {
                        fToken = token;
                        fTokenBraces = tokenBraces;
                        fTokenHeredoc = tokenHeredoc;
@@ -77,7 +81,7 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                 * Is this character an operator character?
                 *
                 * @param character
-                *          Character to determine whether it is an operator character
+                *            Character to determine whether it is an operator character
                 * @return <code>true</code> iff the character is an operator,
                 *         <code>false</code> otherwise.
                 */
@@ -101,7 +105,8 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                        if (isOperator((char) character)) {
                                int lastCharacter = character;
                                character = scanner.read();
-                               // the readHEREDOC(scanner) call doesn't work, if we have our own partitions for single quoted
+                               // the readHEREDOC(scanner) call doesn't work, if we have our
+                               // own partitions for single quoted
                                // or double quoted strings:
                                //
                                // if (lastCharacter == '<' && character == '<') {
@@ -185,15 +190,16 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                // }
 
                /**
-                * Check if lastCharacter/character are a PHP start or end token ( &lt;? ...
-                * ?&gt; )
+                * Check if lastCharacter/character are a PHP start or end token ( &lt;?
+                * ... ?&gt; )
                 *
                 * @param scanner
                 * @param lastCharacter
                 * @param character
                 * @return
                 */
-               private boolean checkPHPTag(ICharacterScanner scanner, int lastCharacter, int character) {
+               private boolean checkPHPTag(ICharacterScanner scanner,
+                               int lastCharacter, int character) {
                        if (lastCharacter == '<' && character == '?') {
                                scanner.unread();
                                scanner.unread();
@@ -261,10 +267,11 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                 * Adds a word and the token to be returned if it is detected.
                 *
                 * @param word
-                *          the word this rule will search for, may not be <code>null</code>
+                *            the word this rule will search for, may not be
+                *            <code>null</code>
                 * @param token
-                *          the token to be returned if the word has been found, may not be
-                *          <code>null</code>
+                *            the token to be returned if the word has been found, may
+                *            not be <code>null</code>
                 */
                public void addWordIgnoreCase(String word, IToken token) {
                        Assert.isNotNull(word);
@@ -325,7 +332,8 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                                if (c == '$') {
                                        isVariable = true;
                                }
-                               if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
+                               if (fColumn == UNDEFINED
+                                               || (fColumn == scanner.getColumn() - 1)) {
 
                                        fBuffer.setLength(0);
                                        fBuffer.append((char) c);
@@ -333,7 +341,8 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                                        if (c == '_') {
                                                isUnderscore = true;
                                        }
-                                       while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)) {
+                                       while (c != ICharacterScanner.EOF
+                                                       && fDetector.isWordPart((char) c)) {
                                                fBuffer.append((char) c);
                                                c = scanner.read();
                                        }
@@ -368,17 +377,28 @@ public class PHPCodeScanner extends AbstractJavaScanner {
 
        // private PHPColorProvider fColorProvider;
 
-       private static String[] fgTokenProperties = { IPreferenceConstants.PHP_MULTILINE_COMMENT,
-                       IPreferenceConstants.PHP_SINGLELINE_COMMENT, IPreferenceConstants.PHP_TAG, IPreferenceConstants.PHP_KEYWORD,
-                       IPreferenceConstants.PHP_FUNCTIONNAME, IPreferenceConstants.PHP_VARIABLE, IPreferenceConstants.PHP_VARIABLE_DOLLAR,
-                       IPreferenceConstants.PHP_STRING_DQ, IPreferenceConstants.PHP_STRING_SQ, IPreferenceConstants.PHP_TYPE,
-                       IPreferenceConstants.PHP_CONSTANT, IPreferenceConstants.PHP_DEFAULT, IPreferenceConstants.PHP_OPERATOR,
-                       IPreferenceConstants.PHP_BRACE_OPERATOR, IPreferenceConstants.PHP_KEYWORD_RETURN };
+       private static String[] fgTokenProperties = {
+                       IPreferenceConstants.PHP_MULTILINE_COMMENT,
+                       IPreferenceConstants.PHP_SINGLELINE_COMMENT,
+                       IPreferenceConstants.PHP_TAG,
+                       IPreferenceConstants.PHP_KEYWORD,
+                       IPreferenceConstants.PHP_FUNCTIONNAME,
+                       IPreferenceConstants.PHP_VARIABLE,
+                       IPreferenceConstants.PHP_VARIABLE_DOLLAR,
+                       IPreferenceConstants.PHP_STRING_DQ,
+                       IPreferenceConstants.PHP_STRING_SQ,
+                       IPreferenceConstants.PHP_TYPE,
+                       IPreferenceConstants.PHP_CONSTANT,
+                       IPreferenceConstants.PHP_DEFAULT,
+                       IPreferenceConstants.PHP_OPERATOR,
+                       IPreferenceConstants.PHP_BRACE_OPERATOR,
+                       IPreferenceConstants.PHP_KEYWORD_RETURN };
 
        /**
         * Creates a PHP code scanner
         */
-       // public PHPCodeScanner(JavaColorManager provider, IPreferenceStore store) {
+       // public PHPCodeScanner(JavaColorManager provider, IPreferenceStore store)
+       // {
        public PHPCodeScanner(IColorManager manager, IPreferenceStore store) {
                super(manager, store);
                initialize();
@@ -435,7 +455,8 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                                        wordRule.addWord(name, keyword);
                                }
                        } else if (elbuffer instanceof PHPFunction) {
-                               wordRule.addWordIgnoreCase(((PHPFunction) elbuffer).getName(), functionName);
+                               wordRule.addWordIgnoreCase(((PHPFunction) elbuffer).getName(),
+                                               functionName);
                        } else if (elbuffer instanceof PHPType) {
                                wordRule.addWord(elbuffer.getName(), type);
                        } else if (elbuffer instanceof PHPConstant) {
@@ -448,7 +469,8 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                wordRule.addWord("return", token);
 
                // Add rule for operators and brackets (at the end !)
-               rules.add(new OperatorRule(getToken(IPreferenceConstants.PHP_OPERATOR), getToken(IPreferenceConstants.PHP_BRACE_OPERATOR),
+               rules.add(new OperatorRule(getToken(IPreferenceConstants.PHP_OPERATOR),
+                               getToken(IPreferenceConstants.PHP_BRACE_OPERATOR),
                                getToken(IPreferenceConstants.PHP_STRING_DQ)));
 
                rules.add(wordRule);
@@ -456,4 +478,4 @@ public class PHPCodeScanner extends AbstractJavaScanner {
                setDefaultReturnToken(getToken(IPreferenceConstants.PHP_DEFAULT));
                return rules;
        }
-}
\ No newline at end of file
+}