--- /dev/null
+/*
+ * 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");
+ }
+}
* 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\";" + "}" + ""
UncommentAction.label= &Uncomment@Ctrl+\\
+ToggleCommentAction.label= Togg&le Comment
+
ShiftRightAction.label= Sh&ift Right
ShiftLeftAction.label= S&hift Left
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
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.
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"
// 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[];
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() {
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);
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('>'))
return TokenNameERROR;
}
}
-// boolean isWhiteSpace;
+ // boolean isWhiteSpace;
while ((currentCharacter == ' ')
- || Character.isWhitespace(currentCharacter)) {
+ || Character.isWhitespace(currentCharacter)) {
startPosition = currentPosition;
currentCharacter = source[currentPosition++];
// if (((currentCharacter = source[currentPosition++]) == '\\')
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--;
//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) {
}
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;
*******************************************************************************/
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;
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;
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);
-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;
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);
}
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);
}
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,
// 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,
// 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[][]{
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,
}
}
});
- // 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();
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
* (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>).
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
return;
} catch (InvalidInputException e) {
// ignore errors
+ e.printStackTrace();
}
fToken = TokenNameERROR;
}
fToken = TokenNameEOF;
getNextToken();
try {
- while (fToken != TokenNameEOF && fToken != TokenNameERROR) {
+ while (fToken != TokenNameEOF) { // && fToken != TokenNameERROR) {
phpdocOffset = -1;
if (fToken == TokenNameCOMMENT_PHPDOC) {
phpdocOffset = fScanner.getCurrentTokenStartPosition();
}
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();
//
// } 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();
}
}
/**
+++ /dev/null
-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
--- /dev/null
+/*******************************************************************************
+ * 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);
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * 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$
+ }
+}
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;
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);
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;
/**
* Default constructor.
*/
- public PHPActionContributor() {
+ public PHPActionContributor_DeleteIt() {
super();
ResourceBundle b = PHPEditorMessages.getResourceBundle();
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