misc changes
authorkhartlage <khartlage>
Sat, 8 May 2004 19:26:32 +0000 (19:26 +0000)
committerkhartlage <khartlage>
Sat, 8 May 2004 19:26:32 +0000 (19:26 +0000)
18 files changed:
net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java [new file with mode: 0644]
net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/tests/parser/PHPManualTestCase.java
net.sourceforge.phpeclipse/icons/obj16/template_obj.gif [new file with mode: 0644]
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/ParserVisitor.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ParserVisitor.java with 92% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PHPEditorPreferencePage.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/actions/PHPdtActionConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/IdentifierIndexManager.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ParserBuilder.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BasicEditorActionContributor.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaSourceViewer.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor_DeleteIt.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java with 98% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties

diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/IdentifierIndexManagerTest.java
new file mode 100644 (file)
index 0000000..f3969a7
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Created on 08.05.2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package net.sourceforge.phpeclipse.phpeditor.php.test;
+
+import java.io.StringBufferInputStream;
+
+import org.eclipse.core.runtime.CoreException;
+
+import junit.framework.TestCase;
+import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
+
+/**
+ * 
+ */
+public class IdentifierIndexManagerTest extends TestCase {
+  IdentifierIndexManager fManager; 
+  
+  public void testManager() {
+    System.out.println("----- testManager -----");
+    String testString = "<?php if ((eregi(\"<[^>]*script*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"<[^>]*object*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"<[^>]*iframe*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"<[^>]*applet*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"<[^>]*meta*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"<[^>]*style*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"<[^>]*form*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"\\([^>]*\\\"?[^)]*\\)\", $secvalue)) ||\r\n" + 
+       "       (eregi(\"\\\"\", $secvalue))) {\r\n" + 
+       "   die (\"<center><img src=images/logo.gif><br><br><b>The html tags you attempted to use are not allowed</b><br><br>[ <a href=\\\"javascript:history.go(-1)\\\"><b>Go Back</b></a> ]\");\r\n" + 
+       "    } ?>";
+    IdentifierIndexManager.LineCreator lineCreator =  fManager.createLineCreator();
+    try {
+      fManager.addInputStream(new StringBufferInputStream(testString), "test", lineCreator);
+    } catch (CoreException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+  }
+  /* (non-Javadoc)
+   * @see junit.framework.TestCase#setUp()
+   */
+  protected void setUp() throws Exception {
+    fManager = new IdentifierIndexManager("c:\\temp\\test");
+  }
+}
index fb231ff..c89fc35 100644 (file)
@@ -19,6 +19,17 @@ public class PHPManualTestCase extends AbstractCompilerTest {
    * Test the PHP Parser with different PHP snippets
    */
   public void testPHPParser() {
+    checkPHP("if ((eregi(\"<[^>]*script*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"<[^>]*object*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"<[^>]*iframe*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"<[^>]*applet*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"<[^>]*meta*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"<[^>]*style*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"<[^>]*form*\\\"?[^>]*>\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"\\([^>]*\\\"?[^)]*\\)\", $secvalue)) ||\r\n" + 
+               "       (eregi(\"\\\"\", $secvalue))) {\r\n" + 
+               "   die (\"<center><img src=images/logo.gif><br><br><b>The html tags you attempted to use are not allowed</b><br><br>[ <a href=\\\"javascript:history.go(-1)\\\"><b>Go Back</b></a> ]\");\r\n" + 
+               "    }");
     checkPHP("function foo()" + "{" + "    echo \"In foo()<br>\\n\";" + "}"
         + "" + "function bar($arg = '')" + "{"
         + "    echo \"In bar(); argument was '$arg'.<br>\\n\";" + "}" + ""
diff --git a/net.sourceforge.phpeclipse/icons/obj16/template_obj.gif b/net.sourceforge.phpeclipse/icons/obj16/template_obj.gif
new file mode 100644 (file)
index 0000000..65c2632
Binary files /dev/null and b/net.sourceforge.phpeclipse/icons/obj16/template_obj.gif differ
index 16b1068..a8abba9 100644 (file)
@@ -77,6 +77,8 @@ CommentAction.label= Co&mment@Ctrl+/
 
 UncommentAction.label= &Uncomment@Ctrl+\\
 
+ToggleCommentAction.label= Togg&le Comment
+
 ShiftRightAction.label= Sh&ift Right
 
 ShiftLeftAction.label= S&hift Left
@@ -168,6 +170,15 @@ ActionDefinition.comment.description= Turn the selected lines into PHP comments
 ActionDefinition.uncomment.name= Uncomment
 ActionDefinition.uncomment.description= Uncomment the selected PHP comment lines
 
+ActionDefinition.toggleComment.name= Toggle Comment
+ActionDefinition.toggleComment.description= Toggle comment the selected lines
+
+ActionDefinition.addBlockComment.name= Add Block Comment
+ActionDefinition.addBlockComment.description= Enclose the selection with a block comment
+
+ActionDefinition.removeBlockComment.name= Remove Block Comment
+ActionDefinition.removeBlockComment.description= Remove the block comment around the selection
+
 ActionDefinition.format.name= Format
 ActionDefinition.format.description= Format the selected text
 
@@ -349,4 +360,8 @@ PreferencePage.antRuntimePreferences = Runtime
 
 Program.externalTools = PHP Program
 
-OccurrenceAnnotation.label= PHP Marker Occurrences
\ No newline at end of file
+OccurrenceAnnotation.label= PHP Marker Occurrences
+
+
+phpEditorFontDefiniton.label= Java Editor Text Font
+phpEditorFontDefintion.description= The Java editor text font is used by Java editors.
index ac91d55..113bcbc 100644 (file)
             default="true"
             icon="icons/obj16/phpedit.gif"
             extensions="php"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             default="true"
             icon="icons/obj16/phpedit.gif"
             extensions="php3"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             default="true"
             icon="icons/obj16/phpedit.gif"
             extensions="php4"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             default="true"
             icon="icons/obj16/phpedit.gif"
             extensions="inc"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             default="true"
             icon="icons/obj16/phpedit.gif"
             extensions="phtml"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             name="%phpEditorName"
             default="true"
             icon="icons/obj16/htmledit.gif"
-            extensions="htm"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            extensions="htm" 
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             default="true"
             icon="icons/obj16/htmledit.gif"
             extensions="html"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             default="true"
             icon="icons/obj16/xmledit.gif"
             extensions="xml"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
       <editor
             default="true"
             icon="icons/obj16/htmledit.gif"
             extensions="tpl"
-            contributorClass="net.sourceforge.phpeclipse.phpeditor.PHPActionContributor"
+            contributorClass="net.sourceforge.phpeclipse.phpeditor.CompilationUnitEditorActionContributor"
             class="net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor"
+            symbolicFontName="net.sourceforge.phpdt.ui.editors.textfont"
             id="net.sourceforge.phpeclipse.PHPUnitEditor">
       </editor>
    </extension>
+      <extension
+         point="org.eclipse.ui.fontDefinitions">
+      <fontDefinition
+            label="%phpEditorFontDefiniton.label"
+            defaultsTo="org.eclipse.jface.textfont"
+            id="net.sourceforge.phpdt.ui.editors.textfont">
+         <description>
+            %phpEditorFontDefintion.description
+         </description>
+      </fontDefinition>
+   </extension>
    <extension
          point="org.eclipse.ui.editors.annotationTypes">
       <type
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
                id="net.sourceforge.phpeclipse.phpeditor.ShiftRight">
          </action>
-                  <action
+         <action
                definitionId="net.sourceforge.phpeclipse.remove.block.comment"
                label="%RemoveBlockCommentAction.label"
                retarget="true"
                retarget="true"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
                id="net.sourceforge.phpeclipse.ui.actions.AddBlockComment">
-         </action>
+         </action> 
          <action
-               definitionId="net.sourceforge.phpeclipse.toggle.comment"
+               definitionId="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
                label="%ToggleCommentAction.label"
                retarget="true"
                menubarPath="net.sourceforge.phpeclipse.ui.source.menu/editGroup"
 <!-- =========================================================================== -->
 <!-- PHP Editor Action Definition IDs -->
 <!-- =========================================================================== -->
-   <extension
+<!--   <extension
          point="org.eclipse.ui.actionDefinitions">
-<!-- edit -->
       <actionDefinition
             id="net.sourceforge.phpeclipse.phpeditor.ContentAssistProposal">
       </actionDefinition>
-<!-- source -->
       <actionDefinition
             id="net.sourceforge.phpeclipse.phpeditor.Comment">
       </actionDefinition>
       <actionDefinition
             id="net.sourceforge.phpeclipse.ui.edit.text.php.show.previous.problem">
       </actionDefinition>
-   </extension>
+   </extension> -->
 <!--   <extension
          point="org.eclipse.ui.acceleratorSets">
       <acceleratorSet
             name="%ActionDefinition.toggleComment.name"
             description="%ActionDefinition.toggleComment.description"
             category="net.sourceforge.phpeclipse.ui.category.source"
-            id="net.sourceforge.phpeclipse.toggle.comment">
+            id="net.sourceforge.phpeclipse.phpeditor.toggle.comment">
       </command>
       <keyBinding
             string="Ctrl+Shift+C"
             scope="net.sourceforge.phpdt.ui.phpEditorScope"
-            command="net.sourceforge.phpeclipse.toggle.comment"
+            command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
       <keyBinding
             platform="carbon"
             string="Command+Shift+C"
             scope="net.sourceforge.phpdt.ui.phpEditorScope"
-            command="net.sourceforge.phpeclipse.toggle.comment"
+            command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
       <keyBinding
       <keyBinding
             platform="gtk"
             string="Esc Ctrl+C"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope" 
+            command="net.sourceforge.phpeclipse.phpeditor.toggle.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <command
+            name="%ActionDefinition.addBlockComment.name"
+            description="%ActionDefinition.addBlockComment.description"
+            category="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpeclipse.phpeditor.add.block.comment">
+      </command>
+      <keyBinding
+            string="Ctrl+Shift+/"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.add.block.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Ctrl+Shift+/"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command=""
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Command+Shift+/"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.add.block.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <command
+            name="%ActionDefinition.removeBlockComment.name"
+            description="%ActionDefinition.removeBlockComment.description"
+            category="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpeclipse.phpeditor.remove.block.comment">
+      </command>
+      <keyBinding
+            string="Ctrl+Shift+\"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.remove.block.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Ctrl+Shift+\"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command=""
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <keyBinding
+            platform="carbon"
+            string="Command+Shift+\"
+            scope="net.sourceforge.phpdt.ui.phpEditorScope"
+            command="net.sourceforge.phpeclipse.phpeditor.remove.block.comment"
+            configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </keyBinding>
+      <command
+            name="%ActionDefinition.indent.name"
+            description="%ActionDefinition.indent.description"
+            category="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpeclipse.phpeditor.indent">
+      </command>
+      <keyBinding
+            string="Ctrl+I"
             scope="net.sourceforge.phpdt.ui.phpEditorScope"
-            command="net.sourceforge.phpeclipse.toggle.comment"
+            command="net.sourceforge.phpeclipse.phpeditor.indent"
             configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
       </keyBinding>
+       
       <command
             name="%ActionDefinition.format.name"
             description="%ActionDefinition.format.description"
index 8a7179b..5ff03b1 100644 (file)
@@ -42,6 +42,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
   // source
   public boolean tokenizeComments;
   public boolean tokenizeWhiteSpace;
+  public boolean tokenizeStrings;
   //source should be viewed as a window (aka a part)
   //of a entire very large stream
   public char source[];
@@ -131,7 +132,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
   public int[][] foundTaskPositions;
   public int foundTaskCount = 0;
   public char[][] taskTags = null;
-  public char[][] taskPriorities = null; 
+  public char[][] taskPriorities = null;
   public static final boolean DEBUG = false;
   public static final boolean TRACE = false;
   public Scanner() {
@@ -805,6 +806,294 @@ public class Scanner implements IScanner, ITerminalSymbols {
     currentPosition = tempPosition;
     return TokenNameLPAREN;
   }
+  public void consumeStringInterpolated() throws InvalidInputException {
+    try {
+      // consume next character
+      unicodeAsBackSlash = false;
+      currentCharacter = source[currentPosition++];
+      //                if (((currentCharacter = source[currentPosition++]) == '\\')
+      //                  && (source[currentPosition] == 'u')) {
+      //                  getNextUnicodeChar();
+      //                } else {
+      //                  if (withoutUnicodePtr != 0) {
+      //                    withoutUnicodeBuffer[++withoutUnicodePtr] =
+      //                      currentCharacter;
+      //                  }
+      //                }
+      while (currentCharacter != '`') {
+        /** ** in PHP \r and \n are valid in string literals *** */
+        //                if ((currentCharacter == '\n')
+        //                  || (currentCharacter == '\r')) {
+        //                  // relocate if finding another quote fairly close: thus unicode
+        // '/u000D' will be fully consumed
+        //                  for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+        //                    if (currentPosition + lookAhead == source.length)
+        //                      break;
+        //                    if (source[currentPosition + lookAhead] == '\n')
+        //                      break;
+        //                    if (source[currentPosition + lookAhead] == '\"') {
+        //                      currentPosition += lookAhead + 1;
+        //                      break;
+        //                    }
+        //                  }
+        //                  throw new InvalidInputException(INVALID_CHAR_IN_STRING);
+        //                }
+        if (currentCharacter == '\\') {
+          int escapeSize = currentPosition;
+          boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
+          //scanEscapeCharacter make a side effect on this value and we need
+          // the previous value few lines down this one
+          scanDoubleQuotedEscapeCharacter();
+          escapeSize = currentPosition - escapeSize;
+          if (withoutUnicodePtr == 0) {
+            //buffer all the entries that have been left aside....
+            withoutUnicodePtr = currentPosition - escapeSize - 1
+                - startPosition;
+            System.arraycopy(source, startPosition, withoutUnicodeBuffer, 1,
+                withoutUnicodePtr);
+            withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+          } else { //overwrite the / in the buffer
+            withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
+            if (backSlashAsUnicodeInString) { //there are TWO \ in the stream
+                                              // where only one is correct
+              withoutUnicodePtr--;
+            }
+          }
+        }
+        // consume next character
+        unicodeAsBackSlash = false;
+        currentCharacter = source[currentPosition++];
+        //                  if (((currentCharacter = source[currentPosition++]) == '\\')
+        //                    && (source[currentPosition] == 'u')) {
+        //                    getNextUnicodeChar();
+        //                  } else {
+        if (withoutUnicodePtr != 0) {
+          withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+        }
+        //                  }
+      }
+    } catch (IndexOutOfBoundsException e) {
+      throw new InvalidInputException(UNTERMINATED_STRING);
+    } catch (InvalidInputException e) {
+      if (e.getMessage().equals(INVALID_ESCAPE)) {
+        // relocate if finding another quote fairly close: thus unicode
+        // '/u000D' will be fully consumed
+        for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+          if (currentPosition + lookAhead == source.length)
+            break;
+          if (source[currentPosition + lookAhead] == '\n')
+            break;
+          if (source[currentPosition + lookAhead] == '`') {
+            currentPosition += lookAhead + 1;
+            break;
+          }
+        }
+      }
+      throw e; // rethrow
+    }
+    if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
+                                              // //$NON-NLS-?$ where ? is an
+                                              // int.
+      if (currentLine == null) {
+        currentLine = new NLSLine();
+        lines.add(currentLine);
+      }
+      currentLine.add(new StringLiteral(getCurrentTokenSourceString(),
+          startPosition, currentPosition - 1));
+    }
+  }
+  public void consumeStringConstant() throws InvalidInputException {
+    try {
+      // consume next character
+      unicodeAsBackSlash = false;
+      currentCharacter = source[currentPosition++];
+      //                if (((currentCharacter = source[currentPosition++]) == '\\')
+      //                  && (source[currentPosition] == 'u')) {
+      //                  getNextUnicodeChar();
+      //                } else {
+      //                  if (withoutUnicodePtr != 0) {
+      //                    withoutUnicodeBuffer[++withoutUnicodePtr] =
+      //                      currentCharacter;
+      //                  }
+      //                }
+      while (currentCharacter != '\'') {
+        /** ** in PHP \r and \n are valid in string literals *** */
+        //                  if ((currentCharacter == '\n')
+        //                    || (currentCharacter == '\r')) {
+        //                    // relocate if finding another quote fairly close: thus unicode
+        // '/u000D' will be fully consumed
+        //                    for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+        //                      if (currentPosition + lookAhead == source.length)
+        //                        break;
+        //                      if (source[currentPosition + lookAhead] == '\n')
+        //                        break;
+        //                      if (source[currentPosition + lookAhead] == '\"') {
+        //                        currentPosition += lookAhead + 1;
+        //                        break;
+        //                      }
+        //                    }
+        //                    throw new InvalidInputException(INVALID_CHAR_IN_STRING);
+        //                  }
+        if (currentCharacter == '\\') {
+          int escapeSize = currentPosition;
+          boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
+          //scanEscapeCharacter make a side effect on this value and we need
+          // the previous value few lines down this one
+          scanSingleQuotedEscapeCharacter();
+          escapeSize = currentPosition - escapeSize;
+          if (withoutUnicodePtr == 0) {
+            //buffer all the entries that have been left aside....
+            withoutUnicodePtr = currentPosition - escapeSize - 1
+                - startPosition;
+            System.arraycopy(source, startPosition, withoutUnicodeBuffer, 1,
+                withoutUnicodePtr);
+            withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+          } else { //overwrite the / in the buffer
+            withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
+            if (backSlashAsUnicodeInString) { //there are TWO \ in the stream
+                                              // where only one is correct
+              withoutUnicodePtr--;
+            }
+          }
+        }
+        // consume next character
+        unicodeAsBackSlash = false;
+        currentCharacter = source[currentPosition++];
+        //                  if (((currentCharacter = source[currentPosition++]) == '\\')
+        //                    && (source[currentPosition] == 'u')) {
+        //                    getNextUnicodeChar();
+        //                  } else {
+        if (withoutUnicodePtr != 0) {
+          withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+        }
+        //                  }
+      }
+    } catch (IndexOutOfBoundsException e) {
+      throw new InvalidInputException(UNTERMINATED_STRING);
+    } catch (InvalidInputException e) {
+      if (e.getMessage().equals(INVALID_ESCAPE)) {
+        // relocate if finding another quote fairly close: thus unicode
+        // '/u000D' will be fully consumed
+        for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+          if (currentPosition + lookAhead == source.length)
+            break;
+          if (source[currentPosition + lookAhead] == '\n')
+            break;
+          if (source[currentPosition + lookAhead] == '\'') {
+            currentPosition += lookAhead + 1;
+            break;
+          }
+        }
+      }
+      throw e; // rethrow
+    }
+    if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
+                                              // //$NON-NLS-?$ where ? is an
+                                              // int.
+      if (currentLine == null) {
+        currentLine = new NLSLine();
+        lines.add(currentLine);
+      }
+      currentLine.add(new StringLiteral(getCurrentTokenSourceString(),
+          startPosition, currentPosition - 1));
+    }
+  }
+  public void consumeStringLiteral() throws InvalidInputException {
+    try {
+      // consume next character
+      unicodeAsBackSlash = false;
+      currentCharacter = source[currentPosition++];
+      //                if (((currentCharacter = source[currentPosition++]) == '\\')
+      //                  && (source[currentPosition] == 'u')) {
+      //                  getNextUnicodeChar();
+      //                } else {
+      //                  if (withoutUnicodePtr != 0) {
+      //                    withoutUnicodeBuffer[++withoutUnicodePtr] =
+      //                      currentCharacter;
+      //                  }
+      //                }
+      while (currentCharacter != '"') {
+        /** ** in PHP \r and \n are valid in string literals *** */
+        //                  if ((currentCharacter == '\n')
+        //                    || (currentCharacter == '\r')) {
+        //                    // relocate if finding another quote fairly close: thus unicode
+        // '/u000D' will be fully consumed
+        //                    for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+        //                      if (currentPosition + lookAhead == source.length)
+        //                        break;
+        //                      if (source[currentPosition + lookAhead] == '\n')
+        //                        break;
+        //                      if (source[currentPosition + lookAhead] == '\"') {
+        //                        currentPosition += lookAhead + 1;
+        //                        break;
+        //                      }
+        //                    }
+        //                    throw new InvalidInputException(INVALID_CHAR_IN_STRING);
+        //                  }
+        if (currentCharacter == '\\') {
+          int escapeSize = currentPosition;
+          boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
+          //scanEscapeCharacter make a side effect on this value and we need
+          // the previous value few lines down this one
+          scanDoubleQuotedEscapeCharacter();
+          escapeSize = currentPosition - escapeSize;
+          if (withoutUnicodePtr == 0) {
+            //buffer all the entries that have been left aside....
+            withoutUnicodePtr = currentPosition - escapeSize - 1
+                - startPosition;
+            System.arraycopy(source, startPosition, withoutUnicodeBuffer, 1,
+                withoutUnicodePtr);
+            withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+          } else { //overwrite the / in the buffer
+            withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
+            if (backSlashAsUnicodeInString) { //there are TWO \ in the stream
+                                              // where only one is correct
+              withoutUnicodePtr--;
+            }
+          }
+        }
+        // consume next character
+        unicodeAsBackSlash = false;
+        currentCharacter = source[currentPosition++];
+        //                  if (((currentCharacter = source[currentPosition++]) == '\\')
+        //                    && (source[currentPosition] == 'u')) {
+        //                    getNextUnicodeChar();
+        //                  } else {
+        if (withoutUnicodePtr != 0) {
+          withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+        }
+        //                  }
+      }
+    } catch (IndexOutOfBoundsException e) {
+      throw new InvalidInputException(UNTERMINATED_STRING);
+    } catch (InvalidInputException e) {
+      if (e.getMessage().equals(INVALID_ESCAPE)) {
+        // relocate if finding another quote fairly close: thus unicode
+        // '/u000D' will be fully consumed
+        for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+          if (currentPosition + lookAhead == source.length)
+            break;
+          if (source[currentPosition + lookAhead] == '\n')
+            break;
+          if (source[currentPosition + lookAhead] == '\"') {
+            currentPosition += lookAhead + 1;
+            break;
+          }
+        }
+      }
+      throw e; // rethrow
+    }
+    if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags
+                                              // //$NON-NLS-?$ where ? is an
+                                              // int.
+      if (currentLine == null) {
+        currentLine = new NLSLine();
+        lines.add(currentLine);
+      }
+      currentLine.add(new StringLiteral(getCurrentTokenSourceString(),
+          startPosition, currentPosition - 1));
+    }
+  }
   public int getNextToken() throws InvalidInputException {
     if (!phpMode) {
       return getInlinedHTML(currentPosition);
@@ -908,10 +1197,18 @@ public class Scanner implements IScanner, ITerminalSymbols {
               case ']' :
                 return TokenNameRBRACKET;
               case '\'' :
+                if (tokenizeStrings) {
+                  consumeStringConstant();
+                  return TokenNameStringConstant;
+                }
                 return TokenNameEncapsedString1;
               case '"' :
                 return TokenNameEncapsedString2;
               case '`' :
+                if (tokenizeStrings) {
+                  consumeStringInterpolated();
+                  return TokenNameStringInterpolated;
+                }
                 return TokenNameEncapsedString0;
               case '-' :
                 if (getNextChar('>'))
@@ -943,9 +1240,9 @@ public class Scanner implements IScanner, ITerminalSymbols {
                 return TokenNameERROR;
             }
           }
-//          boolean isWhiteSpace;
+          //          boolean isWhiteSpace;
           while ((currentCharacter == ' ')
-                  || Character.isWhitespace(currentCharacter)) {
+              || Character.isWhitespace(currentCharacter)) {
             startPosition = currentPosition;
             currentCharacter = source[currentPosition++];
             //            if (((currentCharacter = source[currentPosition++]) == '\\')
@@ -960,10 +1257,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
                 currentLine = null;
               }
             }
-//            isWhiteSpace = (currentCharacter == ' ')
-//                || Character.isWhitespace(currentCharacter);
+            //            isWhiteSpace = (currentCharacter == ' ')
+            //                || Character.isWhitespace(currentCharacter);
             //            }
-          } 
+          }
           if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
             // reposition scanner in case we are interested by spaces as tokens
             currentPosition--;
@@ -973,559 +1270,465 @@ public class Scanner implements IScanner, ITerminalSymbols {
           //little trick to get out in the middle of a source compuation
           if (currentPosition > eofPosition)
             return TokenNameEOF;
-           
-            // ---------Identify the next token-------------
-            switch (currentCharacter) {
-              case '(' :
-                return getCastOrParen();
-              case ')' :
-                return TokenNameRPAREN;
-              case '{' :
-                return TokenNameLBRACE;
-              case '}' :
-                return TokenNameRBRACE;
-              case '[' :
-                return TokenNameLBRACKET;
-              case ']' :
-                return TokenNameRBRACKET;
-              case ';' :
-                return TokenNameSEMICOLON;
-              case ',' :
-                return TokenNameCOMMA;
-              case '.' :
-                if (getNextChar('='))
-                  return TokenNameDOT_EQUAL;
-                if (getNextCharAsDigit())
-                  return scanNumber(true);
-                return TokenNameDOT;
-              case '+' :
-                {
-                  int test;
-                  if ((test = getNextChar('+', '=')) == 0)
-                    return TokenNamePLUS_PLUS;
-                  if (test > 0)
-                    return TokenNamePLUS_EQUAL;
-                  return TokenNamePLUS;
-                }
-              case '-' :
+          // ---------Identify the next token-------------
+          switch (currentCharacter) {
+            case '(' :
+              return getCastOrParen();
+            case ')' :
+              return TokenNameRPAREN;
+            case '{' :
+              return TokenNameLBRACE;
+            case '}' :
+              return TokenNameRBRACE;
+            case '[' :
+              return TokenNameLBRACKET;
+            case ']' :
+              return TokenNameRBRACKET;
+            case ';' :
+              return TokenNameSEMICOLON;
+            case ',' :
+              return TokenNameCOMMA;
+            case '.' :
+              if (getNextChar('='))
+                return TokenNameDOT_EQUAL;
+              if (getNextCharAsDigit())
+                return scanNumber(true);
+              return TokenNameDOT;
+            case '+' :
+              {
+                int test;
+                if ((test = getNextChar('+', '=')) == 0)
+                  return TokenNamePLUS_PLUS;
+                if (test > 0)
+                  return TokenNamePLUS_EQUAL;
+                return TokenNamePLUS;
+              }
+            case '-' :
               {
-                  int test;
-                  if ((test = getNextChar('-', '=')) == 0)
-                    return TokenNameMINUS_MINUS;
-                  if (test > 0)
-                    return TokenNameMINUS_EQUAL;
-                  if (getNextChar('>'))
-                    return TokenNameMINUS_GREATER;
-                  return TokenNameMINUS;
-              } 
-              case '~' :
-                if (getNextChar('='))
-                  return TokenNameTWIDDLE_EQUAL;
-                return TokenNameTWIDDLE;
-              case '!' :
+                int test;
+                if ((test = getNextChar('-', '=')) == 0)
+                  return TokenNameMINUS_MINUS;
+                if (test > 0)
+                  return TokenNameMINUS_EQUAL;
+                if (getNextChar('>'))
+                  return TokenNameMINUS_GREATER;
+                return TokenNameMINUS;
+              }
+            case '~' :
+              if (getNextChar('='))
+                return TokenNameTWIDDLE_EQUAL;
+              return TokenNameTWIDDLE;
+            case '!' :
+              if (getNextChar('=')) {
                 if (getNextChar('=')) {
-                  if (getNextChar('=')) {
-                    return TokenNameNOT_EQUAL_EQUAL;
-                  }
-                  return TokenNameNOT_EQUAL;
+                  return TokenNameNOT_EQUAL_EQUAL;
                 }
-                return TokenNameNOT;
-              case '*' :
-                if (getNextChar('='))
-                  return TokenNameMULTIPLY_EQUAL;
-                return TokenNameMULTIPLY;
-              case '%' :
-                if (getNextChar('='))
-                  return TokenNameREMAINDER_EQUAL;
-                return TokenNameREMAINDER;
-              case '<' :
-                {
-                  int oldPosition = currentPosition;
-                  try {
-                    currentCharacter = source[currentPosition++];
-                  } catch (IndexOutOfBoundsException e) {
-                    currentPosition = oldPosition;
-                    return TokenNameLESS;
-                  }
-                  switch (currentCharacter) {
-                    case '=' :
-                      return TokenNameLESS_EQUAL;
-                    case '>' :
-                      return TokenNameNOT_EQUAL;
-                    case '<' :
-                      if (getNextChar('='))
-                        return TokenNameLEFT_SHIFT_EQUAL;
-                      if (getNextChar('<')) {
+                return TokenNameNOT_EQUAL;
+              }
+              return TokenNameNOT;
+            case '*' :
+              if (getNextChar('='))
+                return TokenNameMULTIPLY_EQUAL;
+              return TokenNameMULTIPLY;
+            case '%' :
+              if (getNextChar('='))
+                return TokenNameREMAINDER_EQUAL;
+              return TokenNameREMAINDER;
+            case '<' :
+              {
+                int oldPosition = currentPosition;
+                try {
+                  currentCharacter = source[currentPosition++];
+                } catch (IndexOutOfBoundsException e) {
+                  currentPosition = oldPosition;
+                  return TokenNameLESS;
+                }
+                switch (currentCharacter) {
+                  case '=' :
+                    return TokenNameLESS_EQUAL;
+                  case '>' :
+                    return TokenNameNOT_EQUAL;
+                  case '<' :
+                    if (getNextChar('='))
+                      return TokenNameLEFT_SHIFT_EQUAL;
+                    if (getNextChar('<')) {
+                      currentCharacter = source[currentPosition++];
+                      while (Character.isWhitespace(currentCharacter)) {
                         currentCharacter = source[currentPosition++];
-                        while (Character.isWhitespace(currentCharacter)) {
-                          currentCharacter = source[currentPosition++];
-                        }
-                        int heredocStart = currentPosition - 1;
-                        int heredocLength = 0;
-                        if (isPHPIdentifierStart(currentCharacter)) {
-                          currentCharacter = source[currentPosition++];
-                        } else {
-                          return TokenNameERROR;
-                        }
-                        while (isPHPIdentifierPart(currentCharacter)) {
-                          currentCharacter = source[currentPosition++];
-                        }
-                        heredocLength = currentPosition - heredocStart - 1;
-                        // heredoc end-tag determination
-                        boolean endTag = true;
-                        char ch;
-                        do {
-                          ch = source[currentPosition++];
-                          if (ch == '\r' || ch == '\n') {
-                            if (recordLineSeparator) {
-                              pushLineSeparator();
-                            } else {
-                              currentLine = null;
-                            }
-                            for (int i = 0; i < heredocLength; i++) {
-                              if (source[currentPosition + i] != source[heredocStart
-                                  + i]) {
-                                endTag = false;
-                                break;
-                              }
-                            }
-                            if (endTag) {
-                              currentPosition += heredocLength - 1;
-                              currentCharacter = source[currentPosition++];
-                              break; // do...while loop
-                            } else {
-                              endTag = true;
+                      }
+                      int heredocStart = currentPosition - 1;
+                      int heredocLength = 0;
+                      if (isPHPIdentifierStart(currentCharacter)) {
+                        currentCharacter = source[currentPosition++];
+                      } else {
+                        return TokenNameERROR;
+                      }
+                      while (isPHPIdentifierPart(currentCharacter)) {
+                        currentCharacter = source[currentPosition++];
+                      }
+                      heredocLength = currentPosition - heredocStart - 1;
+                      // heredoc end-tag determination
+                      boolean endTag = true;
+                      char ch;
+                      do {
+                        ch = source[currentPosition++];
+                        if (ch == '\r' || ch == '\n') {
+                          if (recordLineSeparator) {
+                            pushLineSeparator();
+                          } else {
+                            currentLine = null;
+                          }
+                          for (int i = 0; i < heredocLength; i++) {
+                            if (source[currentPosition + i] != source[heredocStart
+                                + i]) {
+                              endTag = false;
+                              break;
                             }
                           }
-                        } while (true);
-                        return TokenNameHEREDOC;
-                      }
-                      return TokenNameLEFT_SHIFT;
-                  }
-                  currentPosition = oldPosition;
-                  return TokenNameLESS;
+                          if (endTag) {
+                            currentPosition += heredocLength - 1;
+                            currentCharacter = source[currentPosition++];
+                            break; // do...while loop
+                          } else {
+                            endTag = true;
+                          }
+                        }
+                      } while (true);
+                      return TokenNameHEREDOC;
+                    }
+                    return TokenNameLEFT_SHIFT;
                 }
-              case '>' :
-                {
-                  int test;
+                currentPosition = oldPosition;
+                return TokenNameLESS;
+              }
+            case '>' :
+              {
+                int test;
+                if ((test = getNextChar('=', '>')) == 0)
+                  return TokenNameGREATER_EQUAL;
+                if (test > 0) {
                   if ((test = getNextChar('=', '>')) == 0)
-                    return TokenNameGREATER_EQUAL;
-                  if (test > 0) {
-                    if ((test = getNextChar('=', '>')) == 0)
-                      return TokenNameRIGHT_SHIFT_EQUAL;
-                    return TokenNameRIGHT_SHIFT;
-                  }
-                  return TokenNameGREATER;
+                    return TokenNameRIGHT_SHIFT_EQUAL;
+                  return TokenNameRIGHT_SHIFT;
                 }
-              case '=' :
+                return TokenNameGREATER;
+              }
+            case '=' :
+              if (getNextChar('=')) {
                 if (getNextChar('=')) {
-                  if (getNextChar('=')) {
-                    return TokenNameEQUAL_EQUAL_EQUAL;
-                  }
-                  return TokenNameEQUAL_EQUAL;
+                  return TokenNameEQUAL_EQUAL_EQUAL;
                 }
-                if (getNextChar('>'))
-                  return TokenNameEQUAL_GREATER;
-                return TokenNameEQUAL;
-              case '&' :
-                {
-                  int test;
-                  if ((test = getNextChar('&', '=')) == 0)
-                    return TokenNameAND_AND;
-                  if (test > 0)
-                    return TokenNameAND_EQUAL;
-                  return TokenNameAND;
-                }
-              case '|' :
-                {
-                  int test;
-                  if ((test = getNextChar('|', '=')) == 0)
-                    return TokenNameOR_OR;
-                  if (test > 0)
-                    return TokenNameOR_EQUAL;
-                  return TokenNameOR;
+                return TokenNameEQUAL_EQUAL;
+              }
+              if (getNextChar('>'))
+                return TokenNameEQUAL_GREATER;
+              return TokenNameEQUAL;
+            case '&' :
+              {
+                int test;
+                if ((test = getNextChar('&', '=')) == 0)
+                  return TokenNameAND_AND;
+                if (test > 0)
+                  return TokenNameAND_EQUAL;
+                return TokenNameAND;
+              }
+            case '|' :
+              {
+                int test;
+                if ((test = getNextChar('|', '=')) == 0)
+                  return TokenNameOR_OR;
+                if (test > 0)
+                  return TokenNameOR_EQUAL;
+                return TokenNameOR;
+              }
+            case '^' :
+              if (getNextChar('='))
+                return TokenNameXOR_EQUAL;
+              return TokenNameXOR;
+            case '?' :
+              if (getNextChar('>')) {
+                phpMode = false;
+                if (currentPosition == source.length) {
+                  phpMode = true;
+                  return TokenNameINLINE_HTML;
                 }
-              case '^' :
-                if (getNextChar('='))
-                  return TokenNameXOR_EQUAL;
-                return TokenNameXOR;
-              case '?' :
-                if (getNextChar('>')) {
-                  phpMode = false;
-                  if (currentPosition == source.length) {
-                    phpMode = true;
-                    return TokenNameINLINE_HTML;
-                  }
-                  return getInlinedHTML(currentPosition - 2);
+                return getInlinedHTML(currentPosition - 2);
+              }
+              return TokenNameQUESTION;
+            case ':' :
+              if (getNextChar(':'))
+                return TokenNamePAAMAYIM_NEKUDOTAYIM;
+              return TokenNameCOLON;
+            case '@' :
+              return TokenNameAT;
+            case '\'' :
+              consumeStringConstant();
+              return TokenNameStringConstant;
+            case '"' :
+              if (tokenizeStrings) {
+                consumeStringLiteral();
+                return TokenNameStringLiteral;
+              }
+              return TokenNameEncapsedString2;
+            case '`' :
+              if (tokenizeStrings) {
+                consumeStringInterpolated();
+                return TokenNameStringInterpolated;
+              }
+              return TokenNameEncapsedString0;
+            case '#' :
+            case '/' :
+              {
+                char startChar = currentCharacter;
+                if (getNextChar('=')) {
+                  return TokenNameDIVIDE_EQUAL;
                 }
-                return TokenNameQUESTION;
-              case ':' :
-                if (getNextChar(':'))
-                  return TokenNamePAAMAYIM_NEKUDOTAYIM;
-                return TokenNameCOLON;
-              case '@' :
-                return TokenNameAT;
-              case '\'' :
-//                return TokenNameEncapsedString1;
-                try {
-                  // consume next character
-                  unicodeAsBackSlash = false;
-                  currentCharacter = source[currentPosition++];
-                  //                if (((currentCharacter = source[currentPosition++]) == '\\')
-                  //                  && (source[currentPosition] == 'u')) {
-                  //                  getNextUnicodeChar();
-                  //                } else {
-                  //                  if (withoutUnicodePtr != 0) {
-                  //                    withoutUnicodeBuffer[++withoutUnicodePtr] =
-                  //                      currentCharacter;
-                  //                  }
-                  //                }
-                  while (currentCharacter != '\'') {
-                    /** ** in PHP \r and \n are valid in string literals *** */
-                    //                  if ((currentCharacter == '\n')
-                    //                    || (currentCharacter == '\r')) {
-                    //                    // relocate if finding another quote fairly close: thus
-                    // unicode '/u000D' will be fully consumed
-                    //                    for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
-                    //                      if (currentPosition + lookAhead == source.length)
-                    //                        break;
-                    //                      if (source[currentPosition + lookAhead] == '\n')
-                    //                        break;
-                    //                      if (source[currentPosition + lookAhead] == '\"') {
-                    //                        currentPosition += lookAhead + 1;
-                    //                        break;
+                int test;
+                if ((startChar == '#') || (test = getNextChar('/', '*')) == 0) {
+                  //line comment
+                  int endPositionForLineComment = 0;
+                  try { //get the next char
+                    currentCharacter = source[currentPosition++];
+                    //                    if (((currentCharacter = source[currentPosition++])
+                    //                      == '\\')
+                    //                      && (source[currentPosition] == 'u')) {
+                    //                      //-------------unicode traitement ------------
+                    //                      int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+                    //                      currentPosition++;
+                    //                      while (source[currentPosition] == 'u') {
+                    //                        currentPosition++;
+                    //                      }
+                    //                      if ((c1 =
+                    //                        Character.getNumericValue(source[currentPosition++]))
+                    //                        > 15
+                    //                        || c1 < 0
+                    //                        || (c2 =
+                    //                          Character.getNumericValue(source[currentPosition++]))
+                    //                          > 15
+                    //                        || c2 < 0
+                    //                        || (c3 =
+                    //                          Character.getNumericValue(source[currentPosition++]))
+                    //                          > 15
+                    //                        || c3 < 0
+                    //                        || (c4 =
+                    //                          Character.getNumericValue(source[currentPosition++]))
+                    //                          > 15
+                    //                        || c4 < 0) {
+                    //                        throw new
+                    // InvalidInputException(INVALID_UNICODE_ESCAPE);
+                    //                      } else {
+                    //                        currentCharacter =
+                    //                          (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
                     //                      }
                     //                    }
-                    //                    throw new InvalidInputException(INVALID_CHAR_IN_STRING);
-                    //                  }
-                    if (currentCharacter == '\\') {
-                      int escapeSize = currentPosition;
-                      boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
-                      //scanEscapeCharacter make a side effect on this value and
-                      // we need the previous value few lines down this one
-                      scanSingleQuotedEscapeCharacter();
-                      escapeSize = currentPosition - escapeSize;
-                      if (withoutUnicodePtr == 0) {
-                        //buffer all the entries that have been left aside....
-                        withoutUnicodePtr = currentPosition - escapeSize - 1
-                            - startPosition;
-                        System.arraycopy(source, startPosition,
-                            withoutUnicodeBuffer, 1, withoutUnicodePtr);
-                        withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
-                      } else { //overwrite the / in the buffer
-                        withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
-                        if (backSlashAsUnicodeInString) { //there are TWO \ in
-                          // the stream where
-                          // only one is correct
-                          withoutUnicodePtr--;
+                    //handle the \\u case manually into comment
+                    //                    if (currentCharacter == '\\') {
+                    //                      if (source[currentPosition] == '\\')
+                    //                        currentPosition++;
+                    //                    } //jump over the \\
+                    boolean isUnicode = false;
+                    while (currentCharacter != '\r' && currentCharacter != '\n') {
+                      if (currentCharacter == '?') {
+                        if (getNextChar('>')) {
+                          startPosition = currentPosition - 2;
+                          phpMode = false;
+                          return TokenNameINLINE_HTML;
                         }
                       }
-                    }
-                    // consume next character
-                    unicodeAsBackSlash = false;
-                    currentCharacter = source[currentPosition++];
-                    //                  if (((currentCharacter = source[currentPosition++]) ==
-                    // '\\')
-                    //                    && (source[currentPosition] == 'u')) {
-                    //                    getNextUnicodeChar();
-                    //                  } else {
-                    if (withoutUnicodePtr != 0) {
-                      withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
-                    }
-                    //                  }
-                  }
-                } catch (IndexOutOfBoundsException e) {
-                  throw new InvalidInputException(UNTERMINATED_STRING);
-                } catch (InvalidInputException e) {
-                  if (e.getMessage().equals(INVALID_ESCAPE)) {
-                    // relocate if finding another quote fairly close: thus
-                    // unicode '/u000D' will be fully consumed
-                    for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
-                      if (currentPosition + lookAhead == source.length)
-                        break;
-                      if (source[currentPosition + lookAhead] == '\n')
-                        break;
-                      if (source[currentPosition + lookAhead] == '\'') {
-                        currentPosition += lookAhead + 1;
-                        break;
-                      }
-                    }
-                  }
-                  throw e; // rethrow
-                }
-                if (checkNonExternalizedStringLiterals) { // check for presence
-                  // of NLS tags
-                  // //$NON-NLS-?$ where
-                  // ? is an int.
-                  if (currentLine == null) {
-                    currentLine = new NLSLine();
-                    lines.add(currentLine);
-                  }
-                  currentLine.add(new StringLiteral(
-                      getCurrentTokenSourceString(), startPosition,
-                      currentPosition - 1));
-                }
-                return TokenNameStringConstant;
-              case '"' :
-                return TokenNameEncapsedString2;
-              case '`' :
-                return TokenNameEncapsedString0;
-              case '#' :
-              case '/' :
-                {
-                  char startChar = currentCharacter;
-                  if (getNextChar('=')) {
-                    return TokenNameDIVIDE_EQUAL;
-                  }
-                  int test;
-                  if ((startChar == '#') || (test = getNextChar('/', '*')) == 0) {
-                    //line comment
-                    int endPositionForLineComment = 0;
-                    try { //get the next char
+                      //get the next char
+                      isUnicode = false;
                       currentCharacter = source[currentPosition++];
-                      //                    if (((currentCharacter = source[currentPosition++])
-                      //                      == '\\')
-                      //                      && (source[currentPosition] == 'u')) {
-                      //                      //-------------unicode traitement ------------
-                      //                      int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
-                      //                      currentPosition++;
-                      //                      while (source[currentPosition] == 'u') {
+                      //                      if (((currentCharacter = source[currentPosition++])
+                      //                        == '\\')
+                      //                        && (source[currentPosition] == 'u')) {
+                      //                        isUnicode = true;
+                      //                        //-------------unicode traitement ------------
+                      //                        int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
                       //                        currentPosition++;
-                      //                      }
-                      //                      if ((c1 =
-                      //                        Character.getNumericValue(source[currentPosition++]))
-                      //                        > 15
-                      //                        || c1 < 0
-                      //                        || (c2 =
-                      //                          Character.getNumericValue(source[currentPosition++]))
-                      //                          > 15
-                      //                        || c2 < 0
-                      //                        || (c3 =
-                      //                          Character.getNumericValue(source[currentPosition++]))
-                      //                          > 15
-                      //                        || c3 < 0
-                      //                        || (c4 =
+                      //                        while (source[currentPosition] == 'u') {
+                      //                          currentPosition++;
+                      //                        }
+                      //                        if ((c1 =
                       //                          Character.getNumericValue(source[currentPosition++]))
                       //                          > 15
-                      //                        || c4 < 0) {
-                      //                        throw new
+                      //                          || c1 < 0
+                      //                          || (c2 =
+                      //                            Character.getNumericValue(
+                      //                              source[currentPosition++]))
+                      //                            > 15
+                      //                          || c2 < 0
+                      //                          || (c3 =
+                      //                            Character.getNumericValue(
+                      //                              source[currentPosition++]))
+                      //                            > 15
+                      //                          || c3 < 0
+                      //                          || (c4 =
+                      //                            Character.getNumericValue(
+                      //                              source[currentPosition++]))
+                      //                            > 15
+                      //                          || c4 < 0) {
+                      //                          throw new
                       // InvalidInputException(INVALID_UNICODE_ESCAPE);
-                      //                      } else {
-                      //                        currentCharacter =
-                      //                          (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+                      //                        } else {
+                      //                          currentCharacter =
+                      //                            (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+                      //                        }
                       //                      }
-                      //                    }
                       //handle the \\u case manually into comment
-                      //                    if (currentCharacter == '\\') {
-                      //                      if (source[currentPosition] == '\\')
-                      //                        currentPosition++;
-                      //                    } //jump over the \\
-                      boolean isUnicode = false;
-                      while (currentCharacter != '\r'
-                          && currentCharacter != '\n') {
-                        if (currentCharacter == '?') {
-                          if (getNextChar('>')) {
-                            startPosition = currentPosition - 2;
-                            phpMode = false;
-                            return TokenNameINLINE_HTML;
-                          }
-                        }
-                        //get the next char
-                        isUnicode = false;
-                        currentCharacter = source[currentPosition++];
-                        //                      if (((currentCharacter = source[currentPosition++])
-                        //                        == '\\')
-                        //                        && (source[currentPosition] == 'u')) {
-                        //                        isUnicode = true;
-                        //                        //-------------unicode traitement ------------
-                        //                        int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
-                        //                        currentPosition++;
-                        //                        while (source[currentPosition] == 'u') {
-                        //                          currentPosition++;
-                        //                        }
-                        //                        if ((c1 =
-                        //                          Character.getNumericValue(source[currentPosition++]))
-                        //                          > 15
-                        //                          || c1 < 0
-                        //                          || (c2 =
-                        //                            Character.getNumericValue(
-                        //                              source[currentPosition++]))
-                        //                            > 15
-                        //                          || c2 < 0
-                        //                          || (c3 =
-                        //                            Character.getNumericValue(
-                        //                              source[currentPosition++]))
-                        //                            > 15
-                        //                          || c3 < 0
-                        //                          || (c4 =
-                        //                            Character.getNumericValue(
-                        //                              source[currentPosition++]))
-                        //                            > 15
-                        //                          || c4 < 0) {
-                        //                          throw new
-                        // InvalidInputException(INVALID_UNICODE_ESCAPE);
-                        //                        } else {
-                        //                          currentCharacter =
-                        //                            (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
-                        //                        }
-                        //                      }
-                        //handle the \\u case manually into comment
-                        //                      if (currentCharacter == '\\') {
-                        //                        if (source[currentPosition] == '\\')
-                        //                          currentPosition++;
-                        //                      } //jump over the \\
-                      }
-                      if (isUnicode) {
-                        endPositionForLineComment = currentPosition - 6;
-                      } else {
-                        endPositionForLineComment = currentPosition - 1;
-                      }
-                      recordComment(false);
-                      if ((currentCharacter == '\r')
-                          || (currentCharacter == '\n')) {
-                        checkNonExternalizeString();
-                        if (recordLineSeparator) {
-                          if (isUnicode) {
-                            pushUnicodeLineSeparator();
-                          } else {
-                            pushLineSeparator();
-                          }
-                        } else {
-                          currentLine = null;
-                        }
-                      }
-                      if (tokenizeComments) {
-                        if (!isUnicode) {
-                          currentPosition = endPositionForLineComment;
-                          // reset one character behind
-                        }
-                        return TokenNameCOMMENT_LINE;
-                      }
-                    } catch (IndexOutOfBoundsException e) { //an eof will them
-                      // be generated
-                      if (tokenizeComments) {
-                        currentPosition--;
-                        // reset one character behind
-                        return TokenNameCOMMENT_LINE;
-                      }
+                      //                      if (currentCharacter == '\\') {
+                      //                        if (source[currentPosition] == '\\')
+                      //                          currentPosition++;
+                      //                      } //jump over the \\
                     }
-                    break;
-                  }
-                  if (test > 0) {
-                    //traditional and annotation comment
-                    boolean isJavadoc = false, star = false;
-                    // consume next character
-                    unicodeAsBackSlash = false;
-                    currentCharacter = source[currentPosition++];
-                    //                  if (((currentCharacter = source[currentPosition++]) ==
-                    // '\\')
-                    //                    && (source[currentPosition] == 'u')) {
-                    //                    getNextUnicodeChar();
-                    //                  } else {
-                    //                    if (withoutUnicodePtr != 0) {
-                    //                      withoutUnicodeBuffer[++withoutUnicodePtr] =
-                    //                        currentCharacter;
-                    //                    }
-                    //                  }
-                    if (currentCharacter == '*') {
-                      isJavadoc = true;
-                      star = true;
+                    if (isUnicode) {
+                      endPositionForLineComment = currentPosition - 6;
+                    } else {
+                      endPositionForLineComment = currentPosition - 1;
                     }
+                    recordComment(false);
                     if ((currentCharacter == '\r')
                         || (currentCharacter == '\n')) {
                       checkNonExternalizeString();
                       if (recordLineSeparator) {
-                        pushLineSeparator();
+                        if (isUnicode) {
+                          pushUnicodeLineSeparator();
+                        } else {
+                          pushLineSeparator();
+                        }
                       } else {
                         currentLine = null;
                       }
                     }
-                    try { //get the next char
-                      currentCharacter = source[currentPosition++];
-                      //                    if (((currentCharacter = source[currentPosition++])
-                      //                      == '\\')
-                      //                      && (source[currentPosition] == 'u')) {
-                      //                      //-------------unicode traitement ------------
-                      //                      getNextUnicodeChar();
-                      //                    }
-                      //handle the \\u case manually into comment
-                      //                    if (currentCharacter == '\\') {
-                      //                      if (source[currentPosition] == '\\')
-                      //                        currentPosition++;
-                      //                      //jump over the \\
-                      //                    }
-                      // empty comment is not a javadoc /**/
-                      if (currentCharacter == '/') {
-                        isJavadoc = false;
-                      }
-                      //loop until end of comment */
-                      while ((currentCharacter != '/') || (!star)) {
-                        if ((currentCharacter == '\r')
-                            || (currentCharacter == '\n')) {
-                          checkNonExternalizeString();
-                          if (recordLineSeparator) {
-                            pushLineSeparator();
-                          } else {
-                            currentLine = null;
-                          }
-                        }
-                        star = currentCharacter == '*';
-                        //get next char
-                        currentCharacter = source[currentPosition++];
-                        //                      if (((currentCharacter = source[currentPosition++])
-                        //                        == '\\')
-                        //                        && (source[currentPosition] == 'u')) {
-                        //                        //-------------unicode traitement ------------
-                        //                        getNextUnicodeChar();
-                        //                      }
-                        //handle the \\u case manually into comment
-                        //                      if (currentCharacter == '\\') {
-                        //                        if (source[currentPosition] == '\\')
-                        //                          currentPosition++;
-                        //                      } //jump over the \\
-                      }
-                      recordComment(isJavadoc);
-                      if (tokenizeComments) {
-                        if (isJavadoc)
-                          return TokenNameCOMMENT_PHPDOC;
-                        return TokenNameCOMMENT_BLOCK;
+                    if (tokenizeComments) {
+                      if (!isUnicode) {
+                        currentPosition = endPositionForLineComment;
+                        // reset one character behind
                       }
-                    } catch (IndexOutOfBoundsException e) {
-                      throw new InvalidInputException(UNTERMINATED_COMMENT);
+                      return TokenNameCOMMENT_LINE;
+                    }
+                  } catch (IndexOutOfBoundsException e) { //an eof will them
+                    // be generated
+                    if (tokenizeComments) {
+                      currentPosition--;
+                      // reset one character behind
+                      return TokenNameCOMMENT_LINE;
                     }
-                    break;
                   }
-                  return TokenNameDIVIDE;
+                  break;
                 }
-              case '\u001a' :
-                if (atEnd())
-                  return TokenNameEOF;
-                //the atEnd may not be <currentPosition == source.length> if
-                // source is only some part of a real (external) stream
-                throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
-              default :
-                if (currentCharacter == '$') {
-                  int oldPosition = currentPosition;
-                  try {
-                    currentCharacter = source[currentPosition++];
-                    if (isPHPIdentifierStart(currentCharacter)) {
-                      return scanIdentifierOrKeyword(true);
+                if (test > 0) {
+                  //traditional and annotation comment
+                  boolean isJavadoc = false, star = false;
+                  // consume next character
+                  unicodeAsBackSlash = false;
+                  currentCharacter = source[currentPosition++];
+                  //                  if (((currentCharacter = source[currentPosition++]) ==
+                  // '\\')
+                  //                    && (source[currentPosition] == 'u')) {
+                  //                    getNextUnicodeChar();
+                  //                  } else {
+                  //                    if (withoutUnicodePtr != 0) {
+                  //                      withoutUnicodeBuffer[++withoutUnicodePtr] =
+                  //                        currentCharacter;
+                  //                    }
+                  //                  }
+                  if (currentCharacter == '*') {
+                    isJavadoc = true;
+                    star = true;
+                  }
+                  if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+                    checkNonExternalizeString();
+                    if (recordLineSeparator) {
+                      pushLineSeparator();
                     } else {
-                      currentPosition = oldPosition;
-                      return TokenNameDOLLAR;
+                      currentLine = null;
+                    }
+                  }
+                  try { //get the next char
+                    currentCharacter = source[currentPosition++];
+                    //                    if (((currentCharacter = source[currentPosition++])
+                    //                      == '\\')
+                    //                      && (source[currentPosition] == 'u')) {
+                    //                      //-------------unicode traitement ------------
+                    //                      getNextUnicodeChar();
+                    //                    }
+                    //handle the \\u case manually into comment
+                    //                    if (currentCharacter == '\\') {
+                    //                      if (source[currentPosition] == '\\')
+                    //                        currentPosition++;
+                    //                      //jump over the \\
+                    //                    }
+                    // empty comment is not a javadoc /**/
+                    if (currentCharacter == '/') {
+                      isJavadoc = false;
+                    }
+                    //loop until end of comment */
+                    while ((currentCharacter != '/') || (!star)) {
+                      if ((currentCharacter == '\r')
+                          || (currentCharacter == '\n')) {
+                        checkNonExternalizeString();
+                        if (recordLineSeparator) {
+                          pushLineSeparator();
+                        } else {
+                          currentLine = null;
+                        }
+                      }
+                      star = currentCharacter == '*';
+                      //get next char
+                      currentCharacter = source[currentPosition++];
+                      //                      if (((currentCharacter = source[currentPosition++])
+                      //                        == '\\')
+                      //                        && (source[currentPosition] == 'u')) {
+                      //                        //-------------unicode traitement ------------
+                      //                        getNextUnicodeChar();
+                      //                      }
+                      //handle the \\u case manually into comment
+                      //                      if (currentCharacter == '\\') {
+                      //                        if (source[currentPosition] == '\\')
+                      //                          currentPosition++;
+                      //                      } //jump over the \\
+                    }
+                    recordComment(isJavadoc);
+                    if (tokenizeComments) {
+                      if (isJavadoc)
+                        return TokenNameCOMMENT_PHPDOC;
+                      return TokenNameCOMMENT_BLOCK;
                     }
                   } catch (IndexOutOfBoundsException e) {
+                    throw new InvalidInputException(UNTERMINATED_COMMENT);
+                  }
+                  break;
+                }
+                return TokenNameDIVIDE;
+              }
+            case '\u001a' :
+              if (atEnd())
+                return TokenNameEOF;
+              //the atEnd may not be <currentPosition == source.length> if
+              // source is only some part of a real (external) stream
+              throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
+            default :
+              if (currentCharacter == '$') {
+                int oldPosition = currentPosition;
+                try {
+                  currentCharacter = source[currentPosition++];
+                  if (isPHPIdentifierStart(currentCharacter)) {
+                    return scanIdentifierOrKeyword(true);
+                  } else {
                     currentPosition = oldPosition;
                     return TokenNameDOLLAR;
                   }
+                } catch (IndexOutOfBoundsException e) {
+                  currentPosition = oldPosition;
+                  return TokenNameDOLLAR;
                 }
-                if (isPHPIdentifierStart(currentCharacter))
-                  return scanIdentifierOrKeyword(false);
-                if (Character.isDigit(currentCharacter))
-                  return scanNumber(false);
-                return TokenNameERROR;
-            }
-         
+              }
+              if (isPHPIdentifierStart(currentCharacter))
+                return scanIdentifierOrKeyword(false);
+              if (Character.isDigit(currentCharacter))
+                return scanNumber(false);
+              return TokenNameERROR;
+          }
         }
       } //-----------------end switch while try--------------------
       catch (IndexOutOfBoundsException e) {
@@ -3625,9 +3828,16 @@ public class Scanner implements IScanner, ITerminalSymbols {
   }
   public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
       boolean checkNonExternalizedStringLiterals, boolean assertMode) {
+    this(tokenizeComments, tokenizeWhiteSpace,
+        checkNonExternalizedStringLiterals, assertMode, false);
+  }
+  public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace,
+      boolean checkNonExternalizedStringLiterals, boolean assertMode,
+      boolean tokenizeStrings) {
     this.eofPosition = Integer.MAX_VALUE;
     this.tokenizeComments = tokenizeComments;
     this.tokenizeWhiteSpace = tokenizeWhiteSpace;
+    this.tokenizeStrings = tokenizeStrings;
     this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
     this.assertMode = assertMode;
     this.encapsedStringStack = null;
index 91e2b85..d7e0e9b 100644 (file)
@@ -10,7 +10,7 @@
  *******************************************************************************/
 package net.sourceforge.phpdt.internal.core.builder;
 import java.util.ArrayList;
-import net.sourceforge.phpdt.core.compiler.CharOperation;
+
 import net.sourceforge.phpdt.core.compiler.IProblem;
 import net.sourceforge.phpdt.internal.compiler.CompilationResult;
 import net.sourceforge.phpdt.internal.core.Util;
@@ -18,7 +18,7 @@ import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable;
 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
-import org.eclipse.core.resources.IContainer;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IMarker;
@@ -70,52 +70,55 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
       notifier.subTask(Util.bind("build.analyzingDeltas")); //$NON-NLS-1$
       IResourceDelta sourceDelta = (IResourceDelta) deltas
           .get(javaBuilder.currentProject);
-      if (sourceDelta != null)
+      if (sourceDelta != null) {
+        sourceDelta.accept(new ParserVisitor(javaBuilder.currentProject, notifier.monitor));
+        
         if (!findSourceFiles(sourceDelta))
           return false;
-      notifier.updateProgressDelta(0.10f);
-      Object[] keyTable = deltas.keyTable;
-      Object[] valueTable = deltas.valueTable;
-      final IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault()
-          .getIndexManager(javaBuilder.currentProject);
-      for (int i = 0, l = valueTable.length; i < l; i++) {
-        IResourceDelta delta = (IResourceDelta) valueTable[i];
-        if (delta != null) {
-          IResource resource = delta.getResource();
-          int resourceType = resource.getType();
-          if (resourceType == IResource.FILE) {
-            switch (delta.getKind()) {
-              case IResourceDelta.ADDED :
-                if ((resource.getFileExtension() != null)
-                    && PHPFileUtil.isPHPFile((IFile) resource)) {
-                  // update indexfile for the project:
-                  indexManager.addFile((IFile) resource);
-                }
-                break;
-              case IResourceDelta.CHANGED :
-                if ((resource.getFileExtension() != null)
-                    && PHPFileUtil.isPHPFile((IFile) resource)) {
-                  // update indexfile for the project:
-                  indexManager.changeFile((IFile) resource);
-                }
-                break;
-              case IResourceDelta.REMOVED :
-                if ((resource.getFileExtension() != null)
-                    && PHPFileUtil.isPHPFile((IFile) resource)) {
-                  // update indexfile for the project:
-                  indexManager.removeFile((IFile) resource);
-                }
-                break;
-            }
-          }
-          //                           ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[])
-          // javaBuilder.binaryLocationsPerProject.get(keyTable[i]);
-          //                           if (classFoldersAndJars != null)
-          //                                   if (!findAffectedSourceFiles(delta, classFoldersAndJars)) return
-          // false;
-        }
       }
       notifier.updateProgressDelta(0.10f);
+//      Object[] keyTable = deltas.keyTable;
+//      Object[] valueTable = deltas.valueTable;
+////      final IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault()
+////          .getIndexManager(javaBuilder.currentProject);
+//      for (int i = 0, l = valueTable.length; i < l; i++) {
+//        IResourceDelta delta = (IResourceDelta) valueTable[i];
+//        if (delta != null) {
+//          IResource resource = delta.getResource();
+//          int resourceType = resource.getType();
+//          if (resourceType == IResource.FILE) {
+//            switch (delta.getKind()) {
+//              case IResourceDelta.ADDED :
+//                if ((resource.getFileExtension() != null)
+//                    && PHPFileUtil.isPHPFile((IFile) resource)) {
+//                  // update indexfile for the project:
+////                  indexManager.addFile((IFile) resource);
+//                }
+//                break;
+//              case IResourceDelta.CHANGED :
+//                if ((resource.getFileExtension() != null)
+//                    && PHPFileUtil.isPHPFile((IFile) resource)) {
+//                  // update indexfile for the project:
+////                  indexManager.changeFile((IFile) resource);
+//                }
+//                break;
+//              case IResourceDelta.REMOVED :
+//                if ((resource.getFileExtension() != null)
+//                    && PHPFileUtil.isPHPFile((IFile) resource)) {
+//                  // update indexfile for the project:
+////                  indexManager.removeFile((IFile) resource);
+//                }
+//                break;
+//            }
+//          }
+//          //                         ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[])
+//          // javaBuilder.binaryLocationsPerProject.get(keyTable[i]);
+//          //                         if (classFoldersAndJars != null)
+//          //                                 if (!findAffectedSourceFiles(delta, classFoldersAndJars)) return
+//          // false;
+//        }
+//      }
+      notifier.updateProgressDelta(0.10f);
       notifier.subTask(Util.bind("build.analyzingSources")); //$NON-NLS-1$
       addAffectedSourceFiles();
       notifier.updateProgressDelta(0.05f);
@@ -1,8 +1,8 @@
-package net.sourceforge.phpeclipse.builder;
+package net.sourceforge.phpdt.internal.core.builder;
 
 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.PHPParserAction;
+import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -55,7 +55,7 @@ public class ParserVisitor implements IResourceDeltaVisitor {
             fMonitor.subTask("Adding: " + resource.getFullPath());
 
             // check for parsing errors
-            PHPParserAction.parseFile((IFile) resource);
+            //PHPParserAction.parseFile((IFile) resource);
             // update indexfile for the project:
             indexManager.addFile((IFile) resource);
           }
@@ -69,7 +69,7 @@ public class ParserVisitor implements IResourceDeltaVisitor {
             fMonitor.subTask("Changing: " + resource.getFullPath());
 
             //check for parsing errors
-            PHPParserAction.parseFile((IFile) resource);
+            //PHPParserAction.parseFile((IFile) resource);
             // update indexfile for the project:
             indexManager.changeFile((IFile) resource);
           }
index 4195eee..569458b 100644 (file)
@@ -80,8 +80,8 @@ public class PHPEditorPreferencePage extends PreferencePage
       IWorkbenchPreferencePage {
   private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX;
   private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
-  //  public final OverlayPreferenceStore.OverlayKey[] fKeys =
-  //    new OverlayPreferenceStore.OverlayKey[] {
+//    public final OverlayPreferenceStore.OverlayKey[] fKeys =
+//      new OverlayPreferenceStore.OverlayKey[] {
   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
   // PreferenceConstants.EDITOR_FOREGROUND_COLOR),
   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
@@ -225,47 +225,47 @@ public class PHPEditorPreferencePage extends PreferencePage
   // PreferenceConstants.EDITOR_LINE_NUMBER_RULER),
   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
   // PreferenceConstants.EDITOR_SPACES_FOR_TABS),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_AUTOACTIVATION),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
-  // PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_AUTOINSERT),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
-  // PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
-  // PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
-  // PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
-  // PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
-  // PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
-  // PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND),
-  //      new OverlayPreferenceStore.OverlayKey(
-  //        OverlayPreferenceStore.STRING,
-  //        PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA),
-  //      new OverlayPreferenceStore.OverlayKey(
-  //        OverlayPreferenceStore.STRING,
-  //        PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC),
-  //      new OverlayPreferenceStore.OverlayKey(
-  //        OverlayPreferenceStore.STRING,
-  //        PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_ORDER_PROPOSALS),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_CASE_SENSITIVITY),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_ADDIMPORT),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_INSERT_COMPLETION),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES),
-  //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
-  // PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_AUTOACTIVATION),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT,
+//   PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_AUTOINSERT),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+//   PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+//   PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+//   PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+//   PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+//   PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
+//   PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND),
+//        new OverlayPreferenceStore.OverlayKey(
+//          OverlayPreferenceStore.STRING,
+//          PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA),
+//        new OverlayPreferenceStore.OverlayKey(
+//          OverlayPreferenceStore.STRING,
+//          PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC),
+//        new OverlayPreferenceStore.OverlayKey(
+//          OverlayPreferenceStore.STRING,
+//          PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_ORDER_PROPOSALS),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_CASE_SENSITIVITY),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_ADDIMPORT),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_INSERT_COMPLETION),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES),
+//        new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+//   PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS),
   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
   // PreferenceConstants.EDITOR_SMART_PASTE),
   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
@@ -308,7 +308,7 @@ public class PHPEditorPreferencePage extends PreferencePage
   // PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER),
   //      new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
   // PreferenceConstants.EDITOR_ALT_SHIFT_HOVER),
-  //      };
+//        };
   /** The keys of the overlay store. */
   public final OverlayPreferenceStore.OverlayKey[] fKeys;
   private final String[][] fSyntaxColorListModel = new String[][]{
@@ -710,7 +710,7 @@ public class PHPEditorPreferencePage extends PreferencePage
         OverlayPreferenceStore.BOOLEAN,
         PreferenceConstants.CODEASSIST_AUTOINSERT));
     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
-        OverlayPreferenceStore.STRING,
+        OverlayPreferenceStore.STRING, 
         PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND));
     overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
         OverlayPreferenceStore.STRING,
@@ -1701,17 +1701,17 @@ public class PHPEditorPreferencePage extends PreferencePage
         }
       }
     });
-    // for (int i= 0; i < fContentAssistColorListModel.length; i++)
-    //         fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
-    // fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
-    //         public void run() {
-    //                 if (fContentAssistColorList != null &&
-    // !fContentAssistColorList.isDisposed()) {
-    //                         fContentAssistColorList.select(0);
-    //                         handleContentAssistColorListSelection();
-    //                 }
-    //         }
-    // });
+//     for (int i= 0; i < fContentAssistColorListModel.length; i++)
+//             fContentAssistColorList.add(fContentAssistColorListModel[i][0]);
+//     fContentAssistColorList.getDisplay().asyncExec(new Runnable() {
+//             public void run() {
+//                     if (fContentAssistColorList != null &&
+//     !fContentAssistColorList.isDisposed()) {
+//                             fContentAssistColorList.select(0);
+//                             handleContentAssistColorListSelection();
+//                     }
+//             }
+//     });
   }
   private void initializeFields() {
     Iterator e = fColorButtons.keySet().iterator();
index 75c3a01..d5f0188 100644 (file)
@@ -943,6 +943,14 @@ public class PreferenceConstants {
   public final static String EDITOR_MULTI_LINE_COMMENT_COLOR = IPreferenceConstants.PHP_MULTILINE_COMMENT;
 
   /**
+        * The symbolic font name for the Java editor text font 
+        * (value <code>"org.eclipse.jdt.ui.editors.textfont"</code>).
+        * 
+        * @since 2.1
+        */
+public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.textfont"; //$NON-NLS-1$
+
+  /**
    * A named preference that controls whether multi line comments are rendered in bold.
    * <p>
    * Value is of type <code>Boolean</code>. If <code>true</code> multi line comments are rendered
index 0a848b3..b9fc4d7 100644 (file)
@@ -48,6 +48,38 @@ public class PHPdtActionConstants {
    * (value <code>"net.sourceforge.phpdt.ui.actions.Uncomment"</code>).
    */
   public static final String UNCOMMENT = "net.sourceforge.phpeclipse.phpeditor.Uncomment"; //$NON-NLS-1$
+  
+  /**
+        * Source menu: name of standard ToggleComment global action
+        * (value <code>"org.eclipse.jdt.ui.actions.ToggleComment"</code>).
+        * @since 3.0
+        */
+       public static final String TOGGLE_COMMENT= "net.sourceforge.phpeclipse.ui.actions.ToggleComment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Comment global action
+        * (value <code>"org.eclipse.jdt.ui.actions.AddBlockComment"</code>).
+        * 
+        * @since 3.0
+        */
+       public static final String ADD_BLOCK_COMMENT= "net.sourceforge.phpeclipse.ui.actions.AddBlockComment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Uncomment global action
+        * (value <code>"org.eclipse.jdt.ui.actions.RemoveBlockComment"</code>).
+        * 
+        * @since 3.0
+        */
+       public static final String REMOVE_BLOCK_COMMENT= "net.sourceforge.phpeclipse.ui.actions.RemoveBlockComment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Indent global action
+        * (value <code>"org.eclipse.jdt.ui.actions.Indent"</code>).
+        * 
+        * @since 3.0
+        */
+       public static final String INDENT= "net.sourceforge.phpeclipse.ui.actions.Indent"; //$NON-NLS-1$
+       
   /**
         * Source menu: name of standard Shift Rightl action
         * (value <code>"net.sourceforge.phpeclipse.phpeditor.ShiftRight"</code>).
index fbabccb..c8c1a67 100644 (file)
@@ -32,7 +32,7 @@ public class IdentifierIndexManager {
     private Scanner fScanner;
     private int fToken;
     public LineCreator() {
-      fScanner = new Scanner(true, false);
+      fScanner = new Scanner(true, false, false, false, true);
     }
     /**
      * Add the information of the current identifier to the line
@@ -79,6 +79,7 @@ public class IdentifierIndexManager {
         return;
       } catch (InvalidInputException e) {
         // ignore errors
+        e.printStackTrace();
       }
       fToken = TokenNameERROR;
     }
@@ -201,7 +202,7 @@ public class IdentifierIndexManager {
       fToken = TokenNameEOF;
       getNextToken();
       try {
-        while (fToken != TokenNameEOF && fToken != TokenNameERROR) {
+        while (fToken != TokenNameEOF) { // && fToken != TokenNameERROR) {
           phpdocOffset = -1;
           if (fToken == TokenNameCOMMENT_PHPDOC) {
             phpdocOffset = fScanner.getCurrentTokenStartPosition();
@@ -307,13 +308,16 @@ public class IdentifierIndexManager {
     }
     return true;
   }
+  public LineCreator createLineCreator() {
+    return new LineCreator();
+  }
   /**
    * Add the information for a given IFile resource
    *  
    */
   public void addFile(IFile fileToParse) {
     //    InputStream iStream;
-    LineCreator lineCreator = new LineCreator();
+    LineCreator lineCreator = createLineCreator();
     try {
       //      iStream = fileToParse.getContents();
       //
@@ -326,32 +330,41 @@ public class IdentifierIndexManager {
       //      } catch (IOException e) {
       //        return;
       //      }
-      InputStream stream = null;
+      addInputStream(new BufferedInputStream(fileToParse.getContents()), fileToParse.getFullPath().toString(), lineCreator);
+    } catch (CoreException e1) {
+      // TODO Auto-generated catch block
+      e1.printStackTrace();
+    }
+  }
+  /**
+   * @param fileToParse
+   * @param lineCreator
+   * @throws CoreException
+   */
+  public void addInputStream(InputStream stream, String filePath, LineCreator lineCreator) throws CoreException {
+//    InputStream stream;
+    try {
+     // stream = new BufferedInputStream(fileToParse.getContents());
+      StringBuffer lineBuffer = new StringBuffer();
+      lineBuffer.append(filePath);
+      int lineLength = lineBuffer.length();
+      // lineCreator.parseIdentifiers(buf.toString().toCharArray(),
+      // lineBuffer);
+      lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1,
+          null), lineBuffer);
+      if (lineLength != lineBuffer.length()) {
+        addLine(lineBuffer.toString());
+      }
+    } catch (IOException e) {
+      e.printStackTrace();
+    } finally {
       try {
-        stream = new BufferedInputStream(fileToParse.getContents());
-        StringBuffer lineBuffer = new StringBuffer();
-        lineBuffer.append(fileToParse.getFullPath().toString());
-        int lineLength = lineBuffer.length();
-        // lineCreator.parseIdentifiers(buf.toString().toCharArray(),
-        // lineBuffer);
-        lineCreator.parseIdentifiers(Util.getInputStreamAsCharArray(stream, -1,
-            null), lineBuffer);
-        if (lineLength != lineBuffer.length()) {
-          addLine(lineBuffer.toString());
+        if (stream != null) {
+          stream.close();
         }
       } catch (IOException e) {
-        return;
-      } finally {
-        try {
-          if (stream != null) {
-            stream.close();
-          }
-        } catch (IOException e) {
-        }
       }
-    } catch (CoreException e1) {
-      // TODO Auto-generated catch block
-      e1.printStackTrace();
     }
   }
   /**
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ParserBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ParserBuilder.java
deleted file mode 100644 (file)
index d351132..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-package net.sourceforge.phpeclipse.builder;
-
-import java.util.Map;
-
-import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.PHPParserAction;
-import net.sourceforge.phpeclipse.resourcesview.PHPProject;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-/**
- * Builder for .php files. 
- * 
- * 
- * @see org.eclipse.core.resources.IncrementalProjectBuilder
- * @see org.eclipse.core.resources.IResourceDelta
- */
-public class ParserBuilder extends IncrementalProjectBuilder {
-  private final static int TOTAL_WORK = 100;
-
-  /**
-   * Constructor
-   */
-  public ParserBuilder() {
-  }
-
-  /**
-   * 
-   */
-  protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
-    monitor.beginTask("Parsing files", TOTAL_WORK);
-
-    if (kind == IncrementalProjectBuilder.FULL_BUILD) {
-      IResourceDelta delta = getDelta(getProject());
-
-      processFull(getProject(), monitor);
-
-    } else { // INCREMENTAL_BUILD or AUTO_BUILD
-
-      IResourceDelta delta = getDelta(getProject());
-      if (delta != null) {
-        delta.accept(new ParserVisitor(getProject(), monitor));
-      }
-
-    }
-    monitor.done();
-    return null;
-  }
-
-  /**
-   * Performs a <code>FULL_BUILD</code> by visiting all nodes in the resource
-   * tree under the specified project.  
-   * 
-   * @param iProject
-   */
-  public void processFull(final IProject iProject, final IProgressMonitor monitor) {
-               final IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault().getIndexManager(iProject);
-    // Create resource visitor logic
-    IResourceVisitor myVisitor = new IResourceVisitor() {
-      public boolean visit(IResource resource) throws CoreException {
-        if (resource.getType() == IResource.FILE) {
-          if (monitor.isCanceled()) {
-            throw new OperationCanceledException();
-          }
-          if ((resource.getFileExtension() != null) && PHPFileUtil.isPHPFile((IFile) resource)) {
-            monitor.worked(1);
-            monitor.subTask("Parsing: " + resource.getFullPath());
-            // check for parsing errors
-            PHPParserAction.parseFile((IFile) resource);
-            // update indexfile for the project:
-            PHPProject nature = (PHPProject) iProject.getNature(PHPeclipsePlugin.PHP_NATURE_ID);
-                                               indexManager.addFile((IFile) resource);
-          }
-        }
-
-        return true;
-      }
-    };
-
-    // Process the project using the visitor just created
-    try {
-
-//      if (iProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
-//        thePHPProject = new PHPProject();
-//        thePHPProject.setProject(iProject);
-//      }
-                       indexManager.initialize();
-      iProject.accept(myVisitor);
-                       indexManager.writeFile();
-    } catch (CoreException e) {
-      e.printStackTrace();
-    }
-
-  }
-
-  /** 
-   * Sets initialization data for this builder.
-   * <p>
-   * This method is part of the <code>IExecutableExtension</code>
-   * interface.
-   * </p>
-   * <p>
-   * Subclasses are free to extend this method to pick up 
-   * initialization parameters from the plug-in plug-in manifest 
-   * (<code>plugin.xml</code>) file,
-   * but should be sure to invoke this method on their superclass.
-   * <p>
-   * For example, the following method looks for a boolean-valued 
-   * parameter named "trace":
-   * <pre>
-   *     public void setInitializationData(IConfigurationElement cfig, 
-   *             String propertyName, Object data) 
-   *                   throws CoreException {
-   *         super.setInitializationData(cfig, propertyName, data);
-   *         if (data instanceof Hashtable) { 
-   *             Hashtable args = (Hashtable) data; 
-   *             String traceValue = (String) args.get("trace"); 
-   *             TRACING = (traceValue!=null && traceValue.equals("true"));
-   *         }
-   *     }
-   * </pre>
-   * </p>
-   */
-  public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
-    super.setInitializationData(config, propertyName, data);
-
-  }
-
-  /**
-   * Informs this builder that it is being started by the build management
-   * infrastructure.  By the time this method is run, the builder's project
-   * is available and <code>setInitializationData</code> has been called.
-   * The default implementation should be called by all overriding methods.
-   *
-   * @see #setInitializationData
-   */
-  protected void startupOnInitialize() {
-    //   traceMsg("Parse Builder Initialize - startupOnInitialize()");
-  }
-
-  /**
-  * Write trace statements.  
-  * System.out.println with prefix tagging used for simplicity.
-  */
-  //  private void traceMsg(String msg) {
-  //    if (PHPeclipsePlugin.DEBUG | traceEnabled)
-  //      System.out.println(
-  //        buildMode
-  //          + "<"
-  //          + getProject()
-  //          + "> "
-  //          + "\t\t\t"
-  //          + buildMark
-  //          + msg);
-  //  }
-}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BasicEditorActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/BasicEditorActionContributor.java
new file mode 100644 (file)
index 0000000..b106a93
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpeclipse.phpeditor;
+
+
+import net.sourceforge.phpdt.internal.ui.PHPUiImages;
+import net.sourceforge.phpdt.ui.IContextMenuConstants;
+import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.actions.RetargetAction;
+import org.eclipse.ui.editors.text.EncodingActionGroup;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.RetargetTextEditorAction;
+
+
+public class BasicEditorActionContributor extends BasicJavaEditorActionContributor {
+       
+       protected RetargetAction fRetargetContentAssist;
+       protected RetargetTextEditorAction fContentAssist;
+       protected RetargetTextEditorAction fContextInformation;
+//     protected RetargetTextEditorAction fCorrectionAssist;
+       private EncodingActionGroup fEncodingActionGroup;
+       
+       
+       public BasicEditorActionContributor() {
+               
+               fRetargetContentAssist= new RetargetAction(PHPdtActionConstants.CONTENT_ASSIST,  PHPEditorMessages.getString("ContentAssistProposal.label")); //$NON-NLS-1$
+               fRetargetContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+               markAsPartListener(fRetargetContentAssist);
+               
+               fContentAssist= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$
+               fContentAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); 
+               fContentAssist.setImageDescriptor(PHPUiImages.DESC_CLCL_CODE_ASSIST);
+               fContentAssist.setDisabledImageDescriptor(PHPUiImages.DESC_DLCL_CODE_ASSIST);
+               
+               fContextInformation= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistContextInformation."); //$NON-NLS-1$
+               fContextInformation.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+               
+//             fCorrectionAssist= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "CorrectionAssistProposal."); //$NON-NLS-1$
+//             fCorrectionAssist.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
+               
+               // character encoding
+               fEncodingActionGroup= new EncodingActionGroup();
+       }
+       
+       /*
+        * @see EditorActionBarContributor#contributeToMenu(IMenuManager)
+        */
+       public void contributeToMenu(IMenuManager menu) {
+               
+               super.contributeToMenu(menu);
+               
+               IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+               if (editMenu != null) {
+                       editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fRetargetContentAssist);
+//                     editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fCorrectionAssist);                        
+                       editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fContextInformation);
+               }               
+       }
+       
+       /*
+        * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
+        */
+       public void setActiveEditor(IEditorPart part) {
+               super.setActiveEditor(part);
+                               
+               ITextEditor textEditor= null;
+               if (part instanceof ITextEditor)
+                       textEditor= (ITextEditor) part;
+                       
+               fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
+               fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
+//             fCorrectionAssist.setAction(getAction(textEditor, "CorrectionAssistProposal")); //$NON-NLS-1$
+               
+               IActionBars actionBars= getActionBars();
+               actionBars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
+               actionBars.setGlobalActionHandler(PHPdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
+
+               actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId())); //$NON-NLS-1$
+               actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId())); //$NON-NLS-1$
+               
+               // character encoding
+               fEncodingActionGroup.retarget(textEditor);
+       }
+       
+       /*
+        * @see IEditorActionBarContributor#init(IActionBars, IWorkbenchPage)
+        */
+       public void init(IActionBars bars, IWorkbenchPage page) {
+               super.init(bars, page);
+               
+               // register actions that have a dynamic editor. 
+               bars.setGlobalActionHandler(PHPdtActionConstants.CONTENT_ASSIST, fContentAssist);
+               // character encoding
+               fEncodingActionGroup.fillActionBars(bars);
+       }       
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java
new file mode 100644 (file)
index 0000000..47829d8
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpeclipse.phpeditor;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
+
+public class CompilationUnitEditorActionContributor extends BasicEditorActionContributor {
+       
+       public CompilationUnitEditorActionContributor() {
+               super();                                
+       }
+
+       /*
+        * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
+        */
+       public void setActiveEditor(IEditorPart part) {
+               super.setActiveEditor(part);
+               
+               ITextEditor textEditor= null;
+               if (part instanceof ITextEditor)
+                       textEditor= (ITextEditor) part;
+                
+               // Source menu.
+               IActionBars bars= getActionBars();              
+               bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
+       }
+}
index 80e6949..2dae127 100644 (file)
 package net.sourceforge.phpeclipse.phpeditor;
 
 
-import org.eclipse.swt.widgets.Composite;
-
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.formatter.FormattingContextProperties;
+import org.eclipse.jface.text.formatter.IContentFormatterExtension2;
+import org.eclipse.jface.text.formatter.IFormattingContext;
 import org.eclipse.jface.text.information.IInformationPresenter;
 import org.eclipse.jface.text.source.IOverviewRuler;
 import org.eclipse.jface.text.source.IVerticalRuler;
 import org.eclipse.jface.text.source.SourceViewer;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
 
 //import net.sourceforge.phpdt.ui.text.JavaSourceViewerConfiguration;
 
@@ -58,6 +65,60 @@ public class JavaSourceViewer extends SourceViewer {
                        case OPEN_STRUCTURE:
                                fStructurePresenter.showInformation();
                                return;
+                       case FORMAT :
+                       {
+                               final Point selection= rememberSelection();
+
+                               final IDocument document= getDocument();
+                               IRegion region= new Region(selection.x, selection.y);
+                               if (region.getLength()==0) {
+                                 region = new Region(0, document.getLength());
+                               }
+                               final IRewriteTarget target= getRewriteTarget();
+                               final IFormattingContext context= createFormattingContext();
+
+                               if (selection.y == 0) {
+                                       context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE);
+                               } else {
+                                       context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE);
+                                       context.setProperty(FormattingContextProperties.CONTEXT_REGION, region);
+                               }
+                               try {
+                                       setRedraw(false);
+                                       startSequentialRewriteMode(false);
+                                       target.beginCompoundChange();
+
+                                       final String rememberedContents= document.get();
+                                       
+                                       try {
+                                               
+                                               if (fContentFormatter instanceof IContentFormatterExtension2) {
+                                                       
+                                                       final IContentFormatterExtension2 extension= (IContentFormatterExtension2)fContentFormatter;
+                                                       extension.format(document, context);
+                                                       
+                                               } else
+                                                       fContentFormatter.format(document, region);
+                                               
+                                       } catch (RuntimeException x) {
+                                               // firewall for https://bugs.eclipse.org/bugs/show_bug.cgi?id=47472
+                                               // if something went wrong we undo the changes we just did
+                                               // TODO to be removed
+                                               document.set(rememberedContents);
+                                               throw x;
+                                       }
+                                       
+                               } finally {
+
+                                       target.endCompoundChange();
+                                       stopSequentialRewriteMode();
+                                       setRedraw(true);
+
+                                       restoreSelection();
+                                       context.dispose();
+                               }
+                               return;
+                       }
                }
                
                super.doOperation(operation);
@@ -34,14 +34,13 @@ import org.eclipse.ui.actions.RetargetAction;
 import org.eclipse.ui.editors.text.EncodingActionGroup;
 import org.eclipse.ui.ide.IDEActionFactory;
 import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
 import org.eclipse.ui.texteditor.ITextEditor;
 import org.eclipse.ui.texteditor.RetargetTextEditorAction;
 /**
  * Contributes interesting PHP actions to the desktop's Edit menu and the
  * toolbar.
  */
-public class PHPActionContributor extends BasicJavaEditorActionContributor {
+public class PHPActionContributor_DeleteIt extends BasicJavaEditorActionContributor {
 //  protected RetargetTextEditorAction fContentAssistTip;
   // protected TextEditorAction fTogglePresentation;
   protected RetargetAction fRetargetContentAssist;
@@ -56,7 +55,7 @@ public class PHPActionContributor extends BasicJavaEditorActionContributor {
   /**
    * Default constructor.
    */
-  public PHPActionContributor() {
+  public PHPActionContributor_DeleteIt() {
     super();
     ResourceBundle b = PHPEditorMessages.getResourceBundle();
     
index 5d40c35..6d131e9 100644 (file)
@@ -32,6 +32,13 @@ TogglePresentation.tooltip=Enable/Disable Segmented Source Viewer
 TogglePresentation.image=togglepresentation.gif
 TogglePresentation.description=Enable/Disable Segmented Source Viewer
 
+ToggleComment.label=Togg&le Comment
+ToggleComment.tooltip=Toggle Comment For the Selected Lines
+ToggleComment.description=Toggle comment for the selected lines
+
+ToggleComment.error.title=Toggle Comment
+ToggleComment.error.message=An error occurred while toggling comments.
+
 OutlinePage.segment.title_pattern=position {0}
 
 AutoIndent.error.bad_location_1=JavaAutoIndentStrategy.getAutoIndentString: BadLocationException