<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.core.resources_2.1.1/resources.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.resources_2.1.1/resourcessrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui_2.1.1/ui.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui_2.1.1/uisrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32_2.1.1/ws/win32/swt.jar" sourcepath="ORG_ECLIPSE_PLATFORM_WIN32_SOURCE_SRC/org.eclipse.swt.win32_2.1.1/ws/win32/swtsrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.text_2.1.0/text.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.text_2.1.0/textsrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.jface_2.1.1/jface.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface_2.1.1/jfacesrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.jface.text_2.1.0/jfacetext.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface.text_2.1.0/jfacetextsrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui.views_2.1.0/views.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.views_2.1.0/viewssrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench_2.1.1/workbench.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench_2.1.1/workbenchsrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui.win32_2.1.0/workbenchwin32.jar" sourcepath="ORG_ECLIPSE_PLATFORM_WIN32_SOURCE_SRC/org.eclipse.ui.win32_2.1.0/workbenchwin32src.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench.texteditor_2.1.0/texteditor.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench.texteditor_2.1.0/texteditorsrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui.editors_2.1.0/editors.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.editors_2.1.0/editorssrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.ui.externaltools_2.1.1/externaltools.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.externaltools_2.1.1/externaltoolssrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.help_2.1.1/help.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.help_2.1.1/helpsrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.debug.core_2.1.0/dtcore.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.debug.core_2.1.0/dtcoresrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.debug.ui_2.1.1/dtui.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.debug.ui_2.1.1/dtuisrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.search_2.1.1/search.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.search_2.1.1/searchsrc.zip"/>
- <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.13/xmlParserAPIs.jar"/>
- <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.13/xercesImpl.jar"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.update.ui_2.1.1/updateui.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.update.ui_2.1.1/updateuisrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.update.ui.win32_2.1.0/updateui32.jar" sourcepath="ORG_ECLIPSE_PLATFORM_WIN32_SOURCE_SRC/org.eclipse.update.ui.win32_2.1.0/updateui32src.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.core.boot_2.1.1/boot.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.boot_2.1.1/bootsrc.zip"/>
- <classpathentry kind="var"
- path="ECLIPSE_HOME/plugins/org.eclipse.core.runtime_2.1.1/runtime.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.runtime_2.1.1/runtimesrc.zip"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui_3.0.0/uisrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui_3.0.0/ui.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_WIN32_WIN32_X86_SRC/org.eclipse.swt.win32_3.0.0/ws/win32/swtsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32_3.0.0/ws/win32/swt.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface_3.0.0/jfacesrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.jface_3.0.0/jface.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench_3.0.0/workbenchsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench_3.0.0/workbench.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.console_3.0.0/consolesrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui.console_3.0.0/console.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.resources_3.0.0/resourcessrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.core.resources_3.0.0/resources.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.search_3.0.0/searchsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.search_3.0.0/search.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.debug.core_3.0.0/dtcoresrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.debug.core_3.0.0/dtcore.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.debug.ui_3.0.0/dtuisrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.debug.ui_3.0.0/dtui.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.compare_3.0.0/comparesrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.compare_3.0.0/compare.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.filebuffers_3.0.0/filebufferssrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.core.filebuffers_3.0.0/filebuffers.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface.text_3.0.0/jfacetextsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.jface.text_3.0.0/jfacetext.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.text_3.0.0/textsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.text_3.0.0/text.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench.texteditor_3.0.0/texteditorsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench.texteditor_3.0.0/texteditor.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.ide_3.0.0/idesrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui.ide_3.0.0/ide.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.views_3.0.0/viewssrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui.views_3.0.0/views.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.editors_3.0.0/editorssrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui.editors_3.0.0/editors.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.externaltools_3.0.0/externaltoolssrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.ui.externaltools_3.0.0/externaltools.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.help_3.0.0/helpsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.help_3.0.0/help.jar"/>
+ <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.13/xmlParserAPIs.jar"/>
+ <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.13/xercesImpl.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.update.ui_3.0.0/updateuisrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.update.ui_3.0.0/updateui.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.boot_3.0.0/bootsrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.core.boot_3.0.0/boot.jar"/>
+ <classpathentry sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.runtime_3.0.0/runtimesrc.zip" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.core.runtime_3.0.0/runtime.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
</classpath>
</library>
</runtime>
<requires>
- <import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.ui"/>
+ <import plugin="org.eclipse.ui.console"/>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.search"/>
+ <import plugin="org.eclipse.debug.core"/>
+ <import plugin="org.eclipse.debug.ui"/>
+ <import plugin="org.eclipse.compare"/>
+ <import plugin="org.eclipse.core.filebuffers"/>
+ <import plugin="org.eclipse.jface.text"/>
+ <import plugin="org.eclipse.ui.workbench.texteditor"/>
+ <import plugin="org.eclipse.ui.ide"/>
+ <import plugin="org.eclipse.ui.views"/>
+ <import plugin="org.eclipse.ui.editors"/>
<import plugin="org.eclipse.ui.externaltools"/>
<import plugin="org.eclipse.help"/>
<import plugin="org.eclipse.swt"/>
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.eclipse.debug.ui"/>
<import plugin="org.eclipse.search"/>
<import plugin="org.apache.xerces"/>
<import plugin="org.eclipse.update.ui"/>
class="net.sourceforge.phpdt.internal.core.JavaProject">
</run>
</runtime>
- <builder
- id="net.sourceforge.phpeclipse.parserbuilder">
- </builder>
</extension>
<extension
id="parserbuilder"
name="PHP Builder"
point="org.eclipse.core.resources.builders">
- <builder hasNature="true">
+ <builder>
<run
class="net.sourceforge.phpdt.internal.core.builder.PHPBuilder">
</run>
</builder>
</extension>
+
<extension-point name="%phpEditorTextHoversName" id="phpEditorTextHovers" schema="schema/phpEditorTextHovers.exsd"/>
<!-- =================================================================================== -->
<!-- Extension: PHP Markers -->
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
public class NewXarayaResourceWizard extends BasicNewResourceWizard {
-
- private XarayaModuleContainerPage mainPage; //get where to place resource and module name
- private XarayaModuleFilePage page1; //get first load of details author/email/which files
-
- private XarayaVersionModel xvm = new XarayaVersionModel(); //holder for details
-
-public NewXarayaResourceWizard() {
- super();
- //initialize static classes that are required..
- new XarayaModuleText();
- new XarayaModuleMessages();
-}
-
-public void addPages() {
- super.addPages();
- mainPage = new XarayaModuleContainerPage(XarayaModuleMessages.getString("Xaraya.label.container"), getSelection());
- addPage(mainPage);
- page1 = new XarayaModuleFilePage(XarayaModuleMessages.getString("Xaraya.label.container"));
- addPage(page1);
-}
-public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
- super.init(workbench, currentSelection);
- setWindowTitle(XarayaModuleMessages.getString("Xaraya.label.container"));
- setNeedsProgressMonitor(true);
-}
-
-public boolean performFinish() {
- page1.saveDataToModel();
- IFolder folder = mainPage.createNewModuleFolder(); //create the folder for the module
- if (folder == null)
- return false;
-
- Object[] files = mainPage.createNewModuleFiles(); //create the files
-
- selectAndReveal(folder);
-
- // Open editor on new xaraya init file.
- IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
- try {
- IWorkbenchPage page = dw.getActivePage();
- if (page != null)
- page.openEditor((IFile)files[0]);
- } catch (Exception e) {
- }
-
- return true;
-}
+ private XarayaModuleContainerPage mainPage; //get where to place resource and module name
+ private XarayaModuleFilePage page1; //get first load of details author/email/which files
+
+ private XarayaVersionModel xvm = new XarayaVersionModel(); //holder for details
+
+ public NewXarayaResourceWizard() {
+ super();
+ //initialize static classes that are required..
+ new XarayaModuleText();
+ new XarayaModuleMessages();
+ }
+
+ public void addPages() {
+ super.addPages();
+ mainPage = new XarayaModuleContainerPage(XarayaModuleMessages.getString("Xaraya.label.container"), getSelection());
+ addPage(mainPage);
+ page1 = new XarayaModuleFilePage(XarayaModuleMessages.getString("Xaraya.label.container"));
+ addPage(page1);
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ super.init(workbench, currentSelection);
+ setWindowTitle(XarayaModuleMessages.getString("Xaraya.label.container"));
+ setNeedsProgressMonitor(true);
+ }
+
+ public boolean performFinish() {
+ page1.saveDataToModel();
+ IFolder folder = mainPage.createNewModuleFolder(); //create the folder for the module
+ if (folder == null)
+ return false;
+
+ Object[] files = mainPage.createNewModuleFiles(); //create the files
+
+ selectAndReveal(folder);
+
+ // Open editor on new xaraya init file.
+ IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
+ try {
+ IWorkbenchPage page = dw.getActivePage();
+ if (page != null)
+ IDE.openEditor(page, (IFile) files[0], true);
+ } catch (Exception e) {
+ }
+
+ return true;
+ }
}
import org.eclipse.ui.internal.IHelpContextIds;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.misc.ResourceAndContainerGroup;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup;
public class XarayaModuleContainerPage extends WizardPage implements Listener {
private static final int SIZING_CONTAINER_GROUP_HEIGHT = 250;
}
protected IFolder createFolderHandle(IPath folderPath) {
- return WorkbenchPlugin.getPluginWorkspace().getRoot().getFolder(folderPath);
+ return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFolder(folderPath);
}
public IFolder createNewModuleFolder() {
}
protected IFile createFileHandle(IPath filePath) {
- return WorkbenchPlugin.getPluginWorkspace().getRoot().getFile(filePath);
+ return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFile(filePath);
}
public Object[] createNewModuleFiles(){
protected boolean validatePage() {
boolean valid = true;
String moduleName = new String();
- IWorkspace workspace = WorkbenchPlugin.getPluginWorkspace();
+ IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
IStatus nameStatus = null;
String folderName = resourceGroup.getResource();
moduleName = folderName;
public final static int TokenNameforeach = 1028;
public final static int TokenNameendforeach = 1029;
public final static int TokenNameextends = 1030;
- // public final static int TokenNameempty = 1031;
- // public final static int TokenNamearray = 1032;
+ public final static int TokenNameempty = 1031;
+ public final static int TokenNamearray = 1032;
public final static int TokenNameecho = 1033;
public final static int TokenNamevar = 1034;
public final static int TokenNameas = 1035;
public final static int TokenNameprint = 1036;
- // public final static int TokenNameunset = 1037;
- // public final static int TokenNameexit = 1038;
- // public final static int TokenNamedie = 1039;
+ public final static int TokenNameunset = 1037;
+ public final static int TokenNameexit = 1038;
+ public final static int TokenNamedie = 1039;
// public final static int TokenNameand = 1040;
// public final static int TokenNameor = 1041;
// public final static int TokenNamexor = 1042;
public final static int TokenNameinstanceof = 1059;
public final static int TokenNamesuper = 1060;
public final static int TokenNamethrow = 1061;
+
+ public final static int TokenNameconst = 1063;
+ public final static int TokenNamedeclare = 1064;
+ public final static int TokenNameenddeclare = 1065;
+ public final static int TokenNameeval = 1065;
+ public final static int TokenNameuse = 1066;
+ public final static int TokenNameisset = 1066;
+ public final static int TokenNamefinal = 1067;
}
ReferenceBinding type = environment().getType(JAVA_LANG_THROWABLE);
if (type != null) return type;
- problemReporter().isClassPathCorrect(JAVA_LANG_THROWABLE, referenceCompilationUnit());
+// problemReporter().isClassPathCorrect(JAVA_LANG_THROWABLE, referenceCompilationUnit());
return null; // will not get here since the above error aborts the compilation
}
public class Scanner implements IScanner, ITerminalSymbols {
- /* APIs ares
- - getNextToken() which return the current type of the token
- (this value is not memorized by the scanner)
- - getCurrentTokenSource() which provides with the token "REAL" source
- (aka all unicode have been transformed into a correct char)
- - sourceStart gives the position into the stream
- - currentPosition-1 gives the sourceEnd position into the stream
- */
-
- // 1.4 feature
+ /*
+ * APIs ares - getNextToken() which return the current type of the token (this value is not memorized by the scanner) -
+ * getCurrentTokenSource() which provides with the token "REAL" source (aka all unicode have been transformed into a correct
+ * char) - sourceStart gives the position into the stream - currentPosition-1 gives the sourceEnd position into the stream
+ */
+
+ // 1.4 feature
private boolean assertMode;
public boolean useAssertAsAnIndentifier = false;
- //flag indicating if processed source contains occurrences of keyword assert
+ //flag indicating if processed source contains occurrences of keyword assert
public boolean containsAssertKeyword = false;
public boolean recordLineSeparator;
//diet parsing support - jump over some method body when requested
public boolean diet = false;
- //support for the poor-line-debuggers ....
+ //support for the poor-line-debuggers ....
//remember the position of the cr/lf
public int[] lineEnds = new int[250];
public int linePtr = -1;
static final int TableSize = 30, InternalTableSize = 6;
//30*6 = 180 entries
public static final int OptimizedLength = 6;
- public /*static*/
+ public /* static */
final char[][][][] charArray_length = new char[OptimizedLength][TableSize][InternalTableSize][];
// support for detecting non-externalized string literals
int currentLineNr = -1;
public boolean checkNonExternalizedStringLiterals = true;
public boolean wasNonExternalizedStringLiteral = false;
- /*static*/ {
+ /* static */ {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < TableSize; j++) {
for (int k = 0; k < InternalTableSize; k++) {
public static final int SquareBracket = 1;
public static final int CurlyBracket = 2;
public static final int BracketKinds = 3;
-
- // task tag support
- public char[][] foundTaskTags = null;
- public char[][] foundTaskMessages;
- public char[][] foundTaskPriorities = null;
- public int[][] foundTaskPositions;
- public int foundTaskCount = 0;
- public char[][] taskTags = null;
- public char[][] taskPriorities = null;
-
+
+ // task tag support
+ public char[][] foundTaskTags = null;
+ public char[][] foundTaskMessages;
+ public char[][] foundTaskPriorities = null;
+ public int[][] foundTaskPositions;
+ public int foundTaskCount = 0;
+ public char[][] taskTags = null;
+ public char[][] taskPriorities = null;
+
public static final boolean DEBUG = false;
public Scanner() {
}
/**
- * Determines if the specified character is
- * permissible as the first character in a PHP identifier
+ * Determines if the specified character is permissible as the first character in a PHP identifier
*/
public static boolean isPHPIdentifierStart(char ch) {
return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
}
/**
- * Determines if the specified character may be part of a PHP identifier as
- * other than the first character
+ * Determines if the specified character may be part of a PHP identifier as other than the first character
*/
public static boolean isPHPIdentifierPart(char ch) {
return Character.isLetterOrDigit(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
}
public final boolean atEnd() {
- // This code is not relevant if source is
+ // This code is not relevant if source is
// Only a part of the real stream input
return source.length == currentPosition;
/*
* Search the source position corresponding to the end of a given line number
- *
- * Line numbers are 1-based, and relative to the scanner initialPosition.
- * Character positions are 0-based.
- *
+ *
+ * Line numbers are 1-based, and relative to the scanner initialPosition. Character positions are 0-based.
+ *
* In case the given line number is inconsistent, answers -1.
*/
public final int getLineEnd(int lineNumber) {
}
/**
* Search the source position corresponding to the beginning of a given line number
- *
- * Line numbers are 1-based, and relative to the scanner initialPosition.
- * Character positions are 0-based.
- *
- * e.g. getLineStart(1) --> 0 i.e. first line starts at character 0.
- *
+ *
+ * Line numbers are 1-based, and relative to the scanner initialPosition. Character positions are 0-based.
+ *
+ * e.g. getLineStart(1) --> 0 i.e. first line starts at character 0.
+ *
* In case the given line number is inconsistent, answers -1.
*/
public final int getLineStart(int lineNumber) {
//Both previous lines are true if the currentCharacter is == to the testedChar
//On false, no side effect has occured.
- //ALL getNextChar.... ARE OPTIMIZED COPIES
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
int temp = currentPosition;
try {
//Both previous lines are true if the currentCharacter is == to the testedChar1/2
//On false, no side effect has occured.
- //ALL getNextChar.... ARE OPTIMIZED COPIES
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
int temp = currentPosition;
try {
//Both previous lines are true if the currentCharacter is a digit
//On false, no side effect has occured.
- //ALL getNextChar.... ARE OPTIMIZED COPIES
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
int temp = currentPosition;
try {
//Both previous lines are true if the currentCharacter is a digit base on radix
//On false, no side effect has occured.
- //ALL getNextChar.... ARE OPTIMIZED COPIES
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
int temp = currentPosition;
try {
//Both previous lines are true if the currentCharacter is a JavaIdentifierPart
//On false, no side effect has occured.
- //ALL getNextChar.... ARE OPTIMIZED COPIES
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
int temp = currentPosition;
try {
if (test >= 0) {
test = getNextChar('P', 'p');
if (test >= 0) {
- // <?PHP <?php
+ // <?PHP <?php
startPosition = currentPosition;
phpMode = true;
// }
// }
// }
- // // if (getNextChar('\''))
- // // return TokenNameCharacterLiteral;
+ // // if (getNextChar('\''))
+ // // return TokenNameCharacterLiteral;
// // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
// for (int lookAhead = 0; lookAhead < 20; lookAhead++) {
// if (currentPosition + lookAhead == source.length)
while (currentCharacter != '\'') {
- /**** in PHP \r and \n are valid in string literals ****/
+ /** ** 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
}
throw e; // rethrow
}
- if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
+ if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
if (currentLine == null) {
currentLine = new NLSLine();
lines.add(currentLine);
while (currentCharacter != '"') {
- /**** in PHP \r and \n are valid in string literals ****/
+ /** ** 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
}
throw e; // rethrow
}
- if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
+ if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
if (currentLine == null) {
currentLine = new NLSLine();
lines.add(currentLine);
while (currentCharacter != '`') {
- /**** in PHP \r and \n are valid in string literals ****/
+ /** ** 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
}
throw e; // rethrow
}
- if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
+ if (checkNonExternalizedStringLiterals) { // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
if (currentLine == null) {
currentLine = new NLSLine();
lines.add(currentLine);
{
int test;
if ((currentCharacter == '#') || (test = getNextChar('/', '*')) == 0) {
- //line comment
+ //line comment
int endPositionForLineComment = 0;
- try { //get the next char
+ try { //get the next char
currentCharacter = source[currentPosition++];
// if (((currentCharacter = source[currentPosition++])
// == '\\')
currentLine = null;
}
}
- try { //get the next char
+ try { //get the next char
currentCharacter = source[currentPosition++];
// if (((currentCharacter = source[currentPosition++])
// == '\\')
// //At the end of this method currentCharacter holds the new visited char
// //and currentPosition points right next after it
//
- // //ALL getNextChar.... ARE OPTIMIZED COPIES
+ // //ALL getNextChar.... ARE OPTIMIZED COPIES
//
// int c1 = 0, c2 = 0, c3 = 0, c4 = 0, unicodeSize = 6;
// currentPosition++;
// }
// unicodeAsBackSlash = currentCharacter == '\\';
// }
- /* Tokenize a method body, assuming that curly brackets are properly balanced.
+ /*
+ * Tokenize a method body, assuming that curly brackets are properly balanced.
*/
public final void jumpOverMethodBody() {
{
int test;
if ((test = getNextChar('/', '*')) == 0) {
- //line comment
+ //line comment
try {
- //get the next char
+ //get the next char
currentCharacter = source[currentPosition++];
// if (((currentCharacter = source[currentPosition++]) == '\\')
// && (source[currentPosition] == 'u')) {
// }
while (currentCharacter != '\r' && currentCharacter != '\n') {
- //get the next char
+ //get the next char
currentCharacter = source[currentPosition++];
// if (((currentCharacter = source[currentPosition++])
// == '\\')
}
if (recordLineSeparator && ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
- try { //get the next char
+ try { //get the next char
currentCharacter = source[currentPosition++];
// if (((currentCharacter = source[currentPosition++]) == '\\')
// && (source[currentPosition] == 'u')) {
// (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
// }
// }
- //loop until end of comment */
+ //loop until end of comment */
while ((currentCharacter != '/') || (!star)) {
if (recordLineSeparator && ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
// }
// }
public final int[] getLineEnds() {
- //return a bounded copy of this.lineEnds
+ //return a bounded copy of this.lineEnds
int[] copy;
System.arraycopy(lineEnds, 0, copy = new int[linePtr + 1], 0, linePtr + 1);
// look-ahead for merged cr+lf
try {
if (source[currentPosition] == '\n') {
- //System.out.println("look-ahead LF-" + currentPosition);
+ //System.out.println("look-ahead LF-" + currentPosition);
lineEnds[linePtr] = currentPosition;
currentPosition++;
wasAcr = false;
if (currentCharacter == '\n') {
//must merge eventual cr followed by lf
if (wasAcr && (lineEnds[linePtr] == (currentPosition - 2))) {
- //System.out.println("merge LF-" + (currentPosition - 1));
+ //System.out.println("merge LF-" + (currentPosition - 1));
lineEnds[linePtr] = currentPosition - 1;
} else {
int separatorPos = currentPosition - 1;
if ((linePtr > 0) && (lineEnds[linePtr] >= separatorPos))
return;
- // System.out.println("LF-" + separatorPos);
+ // System.out.println("LF-" + separatorPos);
try {
lineEnds[++linePtr] = separatorPos;
} catch (IndexOutOfBoundsException e) {
}
// look-ahead for merged cr+lf
if (source[currentPosition] == '\n') {
- //System.out.println("look-ahead LF-" + currentPosition);
+ //System.out.println("look-ahead LF-" + currentPosition);
lineEnds[linePtr] = currentPosition;
currentPosition++;
wasAcr = false;
if (currentCharacter == '\n') {
//must merge eventual cr followed by lf
if (wasAcr && (lineEnds[linePtr] == (currentPosition - 7))) {
- //System.out.println("merge LF-" + (currentPosition - 1));
+ //System.out.println("merge LF-" + (currentPosition - 1));
lineEnds[linePtr] = currentPosition - 6;
} else {
int separatorPos = currentPosition - 6;
if ((linePtr > 0) && (lineEnds[linePtr] >= separatorPos))
return;
- // System.out.println("LF-" + separatorPos);
+ // System.out.println("LF-" + separatorPos);
try {
lineEnds[++linePtr] = separatorPos;
} catch (IndexOutOfBoundsException e) {
} else { // has read \OctalDigit NonDigit--> ignore last character
currentPosition--;
}
- } else { // has read \OctalDigit NonOctalDigit--> ignore last character
+ } else { // has read \OctalDigit NonOctalDigit--> ignore last character
currentPosition--;
}
} else { // has read \OctalDigit --> ignore last character
firstLetter = data[index];
switch (firstLetter) {
- case 'a' : // as and array
+ case 'a' : // as and array abstract
switch (length) {
case 2 : //as
if ((data[++index] == 's')) {
} else {
return TokenNameIdentifier;
}
- // case 5 :
- // if ((data[++index] == 'r') && (data[++index] == 'r') && (data[++index] == 'a') && (data[++index] == 'y'))
- // return TokenNamearray;
- // else
- // return TokenNameIdentifier;
+ case 5 : // array
+ if ((data[++index] == 'r') && (data[++index] == 'r') && (data[++index] == 'a') && (data[++index] == 'y'))
+ return TokenNamearray;
+ else
+ return TokenNameIdentifier;
+ case 8 :
+ if ((data[++index] == 'b')
+ && (data[++index] == 's')
+ && (data[++index] == 't')
+ && (data[++index] == 'r')
+ && (data[++index] == 'a')
+ && (data[++index] == 'c')
+ && (data[++index] == 't'))
+ return TokenNameabstract;
+ else
+ return TokenNameIdentifier;
default :
return TokenNameIdentifier;
}
return TokenNameIdentifier;
}
- case 'c' : //case class continue
+ case 'c' : //case catch class const continue
switch (length) {
case 4 :
if ((data[++index] == 'a') && (data[++index] == 's') && (data[++index] == 'e'))
else
return TokenNameIdentifier;
case 5 :
- if ((data[++index] == 'l') && (data[++index] == 'a') && (data[++index] == 's') && (data[++index] == 's'))
+ if ((data[++index] == 'a') && (data[++index] == 't') && (data[++index] == 'c') && (data[++index] == 'h'))
+ return TokenNamecatch;
+ if ((data[index] == 'l') && (data[++index] == 'a') && (data[++index] == 's') && (data[++index] == 's'))
return TokenNameclass;
+ if ((data[index] == 'o') && (data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 't'))
+ return TokenNameconst;
else
return TokenNameIdentifier;
case 8 :
return TokenNameIdentifier;
}
- case 'd' : //define default do
+ case 'd' : //define declare default do die
switch (length) {
case 2 :
if ((data[++index] == 'o'))
return TokenNamedo;
else
return TokenNameIdentifier;
+ case 3 :
+ if ((data[++index] == 'i') && (data[++index] == 'e'))
+ return TokenNamedie;
+ else
+ return TokenNameIdentifier;
case 6 :
if ((data[++index] == 'e')
&& (data[++index] == 'f')
return TokenNameIdentifier;
case 7 :
if ((data[++index] == 'e')
+ && (data[++index] == 'c')
+ && (data[++index] == 'l')
+ && (data[++index] == 'a')
+ && (data[++index] == 'r')
+ && (data[++index] == 'e'))
+ return TokenNamedeclare;
+ index = 0;
+ if ((data[++index] == 'e')
&& (data[++index] == 'f')
&& (data[++index] == 'a')
&& (data[++index] == 'u')
default :
return TokenNameIdentifier;
}
- case 'e' : //echo else elseif extends
+ case 'e' : //echo else exit elseif extends eval
switch (length) {
case 4 :
if ((data[++index] == 'c') && (data[++index] == 'h') && (data[++index] == 'o'))
return TokenNameecho;
else if ((data[index] == 'l') && (data[++index] == 's') && (data[++index] == 'e'))
return TokenNameelse;
+ else if ((data[index] == 'x') && (data[++index] == 'i') && (data[++index] == 't'))
+ return TokenNameexit;
+ else if ((data[index] == 'v') && (data[++index] == 'a') && (data[++index] == 'l'))
+ return TokenNameeval;
else
return TokenNameIdentifier;
- case 5 : // endif
+ case 5 : // endif empty
if ((data[++index] == 'n') && (data[++index] == 'd') && (data[++index] == 'i') && (data[++index] == 'f'))
return TokenNameendif;
+ if ((data[index] == 'm') && (data[++index] == 'p') && (data[++index] == 't') && (data[++index] == 'y'))
+ return TokenNameempty;
else
return TokenNameIdentifier;
case 6 : // endfor
return TokenNameendswitch;
else
return TokenNameIdentifier;
- case 10 : // endforeach
+ case 10 : // enddeclare
if ((data[++index] == 'n')
&& (data[++index] == 'd')
+ && (data[++index] == 'd')
+ && (data[++index] == 'e')
+ && (data[++index] == 'c')
+ && (data[++index] == 'l')
+ && (data[++index] == 'a')
+ && (data[++index] == 'r')
+ && (data[++index] == 'e'))
+ return TokenNameendforeach;
+ index = 0;
+ if ((data[++index] == 'n') // endforeach
+ && (data[++index] == 'd')
&& (data[++index] == 'f')
&& (data[++index] == 'o')
&& (data[++index] == 'r')
return TokenNameIdentifier;
}
- case 'f' : //for false function
+ case 'f' : //for false final function
switch (length) {
case 3 :
if ((data[++index] == 'o') && (data[++index] == 'r'))
case 5 :
if ((data[++index] == 'a') && (data[++index] == 'l') && (data[++index] == 's') && (data[++index] == 'e'))
return TokenNamefalse;
+ if ((data[index] == 'i') && (data[++index] == 'n') && (data[++index] == 'a') && (data[++index] == 'l'))
+ return TokenNamefinal;
else
return TokenNameIdentifier;
- case 7 : // function
+ case 7 : // foreach
if ((data[++index] == 'o')
&& (data[++index] == 'r')
&& (data[++index] == 'e')
}
return TokenNameIdentifier;
- case 'i' : //if int
+ case 'i' : //if int isset include include_once instanceof interface implements
switch (length) {
case 2 :
if (data[++index] == 'f')
// return TokenNameint;
// else
// return TokenNameIdentifier;
+ case 5 :
+ if ((data[++index] == 's') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 't'))
+ return TokenNameisset;
+ else
+ return TokenNameIdentifier;
case 7 :
if ((data[++index] == 'n')
&& (data[++index] == 'c')
return TokenNameinclude;
else
return TokenNameIdentifier;
+ case 9 : // interface
+ if ((data[++index] == 'n')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'r')
+ && (data[++index] == 'f')
+ && (data[++index] == 'a')
+ && (data[++index] == 'c')
+ && (data[++index] == 'e'))
+ return TokenNameinterface;
+ else
+ return TokenNameIdentifier;
+ case 10 : // instanceof
+ if ((data[++index] == 'n')
+ && (data[++index] == 's')
+ && (data[++index] == 't')
+ && (data[++index] == 'a')
+ && (data[++index] == 'n')
+ && (data[++index] == 'c')
+ && (data[++index] == 'e')
+ && (data[++index] == 'o')
+ && (data[++index] == 'f'))
+ return TokenNameinstanceof;
+ if ((data[index] == 'm')
+ && (data[++index] == 'p')
+ && (data[++index] == 'l')
+ && (data[++index] == 'e')
+ && (data[++index] == 'm')
+ && (data[++index] == 'e')
+ && (data[++index] == 'n')
+ && (data[++index] == 't')
+ && (data[++index] == 's'))
+ return TokenNameimplements;
+ else
+ return TokenNameIdentifier;
case 12 :
if ((data[++index] == 'n')
&& (data[++index] == 'c')
// }
return TokenNameIdentifier;
- case 'p' : // print
- if (length == 5) {
- if ((data[++index] == 'r') && (data[++index] == 'i') && (data[++index] == 'n') && (data[++index] == 't')) {
- return TokenNameprint;
- }
+ case 'p' : // print public private protected
+ switch (length) {
+ case 5 :
+ if ((data[++index] == 'r') && (data[++index] == 'i') && (data[++index] == 'n') && (data[++index] == 't')) {
+ return TokenNameprint;
+ } else
+ return TokenNameIdentifier;
+ case 6 :
+ if ((data[++index] == 'u')
+ && (data[++index] == 'b')
+ && (data[++index] == 'l')
+ && (data[++index] == 'i')
+ && (data[++index] == 'c')) {
+ return TokenNamepublic;
+ } else
+ return TokenNameIdentifier;
+ case 7 :
+ if ((data[++index] == 'r')
+ && (data[++index] == 'i')
+ && (data[++index] == 'v')
+ && (data[++index] == 'a')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')) {
+ return TokenNameprivate;
+ } else
+ return TokenNameIdentifier;
+ case 9 :
+ if ((data[++index] == 'r')
+ && (data[++index] == 'o')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'c')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'd')) {
+ return TokenNameprotected;
+ } else
+ return TokenNameIdentifier;
}
return TokenNameIdentifier;
case 'r' : //return require require_once
} else
return TokenNameIdentifier;
- case 's' : //static switch
+ case 's' : //static switch
switch (length) {
case 6 :
if (data[++index] == 't')
return TokenNameIdentifier;
}
- case 't' : // true
+ case 't' : // try true throw
switch (length) {
-
+ case 3 :
+ if ((data[++index] == 'r') && (data[++index] == 'y'))
+ return TokenNametry;
+ else
+ return TokenNameIdentifier;
case 4 :
if ((data[++index] == 'r') && (data[++index] == 'u') && (data[++index] == 'e'))
return TokenNametrue;
else
return TokenNameIdentifier;
- // if ((data[++index] == 'h') && (data[++index] == 'i') && (data[++index] == 's'))
- // return TokenNamethis;
+ case 5 :
+ if ((data[++index] == 'h') && (data[++index] == 'r') && (data[++index] == 'o') && (data[++index] == 'w'))
+ return TokenNamethrow;
+ else
+ return TokenNameIdentifier;
default :
return TokenNameIdentifier;
}
-
- case 'v' : //var
+ case 'u' : //use unset
+ switch (length) {
+ case 3 :
+ if ((data[++index] == 's') && (data[++index] == 'e'))
+ return TokenNameuse;
+ else
+ return TokenNameIdentifier;
+ case 5 :
+ if ((data[++index] == 'n') && (data[++index] == 's') && (data[++index] == 'e') && (data[++index] == 't'))
+ return TokenNameunset;
+ else
+ return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+ case 'v' : //var
switch (length) {
case 3 :
if ((data[++index] == 'a') && (data[++index] == 'r'))
return TokenNameIdentifier;
}
- case 'w' : //while
+ case 'w' : //while
switch (length) {
case 5 :
if ((data[++index] == 'h') && (data[++index] == 'i') && (data[++index] == 'l') && (data[++index] == 'e'))
return TokenNamewhile;
else
return TokenNameIdentifier;
- //case 6:if ( (data[++index] =='i') && (data[++index]=='d') && (data[++index]=='e') && (data[++index]=='f')&& (data[++index]=='p'))
+ //case 6:if ( (data[++index] =='i') && (data[++index]=='d') && (data[++index]=='e') && (data[++index]=='f')&&
+ // (data[++index]=='p'))
//return TokenNamewidefp ;
//else
//return TokenNameIdentifier;
}
/**
* Search the line number corresponding to a specific position
- *
+ *
*/
public final int getLineNumber(int position) {
}
currentLine = null;
}
-
-
- public final void scanEscapeCharacter() throws InvalidInputException {
- // the string with "\\u" is a legal string of two chars \ and u
- //thus we use a direct access to the source (for regular cases).
-
- if (unicodeAsBackSlash) {
- // consume next character
- unicodeAsBackSlash = false;
-// if (((currentCharacter = source[currentPosition++]) == '\\') && (source[currentPosition] == 'u')) {
-// getNextUnicodeChar();
-// } else {
- if (withoutUnicodePtr != 0) {
- withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
-// }
- }
- } else
- currentCharacter = source[currentPosition++];
- switch (currentCharacter) {
- case 'b' :
- currentCharacter = '\b';
- break;
- case 't' :
- currentCharacter = '\t';
- break;
- case 'n' :
- currentCharacter = '\n';
- break;
- case 'f' :
- currentCharacter = '\f';
- break;
- case 'r' :
- currentCharacter = '\r';
- break;
- case '\"' :
- currentCharacter = '\"';
- break;
- case '\'' :
- currentCharacter = '\'';
- break;
- case '\\' :
- currentCharacter = '\\';
- break;
- default :
- // -----------octal escape--------------
- // OctalDigit
- // OctalDigit OctalDigit
- // ZeroToThree OctalDigit OctalDigit
-
- int number = Character.getNumericValue(currentCharacter);
- if (number >= 0 && number <= 7) {
- boolean zeroToThreeNot = number > 3;
- if (Character.isDigit(currentCharacter = source[currentPosition++])) {
- int digit = Character.getNumericValue(currentCharacter);
- if (digit >= 0 && digit <= 7) {
- number = (number * 8) + digit;
- if (Character.isDigit(currentCharacter = source[currentPosition++])) {
- if (zeroToThreeNot) {// has read \NotZeroToThree OctalDigit Digit --> ignore last character
- currentPosition--;
- } else {
- digit = Character.getNumericValue(currentCharacter);
- if (digit >= 0 && digit <= 7){ // has read \ZeroToThree OctalDigit OctalDigit
- number = (number * 8) + digit;
- } else {// has read \ZeroToThree OctalDigit NonOctalDigit --> ignore last character
- currentPosition--;
- }
- }
- } else { // has read \OctalDigit NonDigit--> ignore last character
- currentPosition--;
- }
- } else { // has read \OctalDigit NonOctalDigit--> ignore last character
- currentPosition--;
- }
- } else { // has read \OctalDigit --> ignore last character
- currentPosition--;
- }
- if (number > 255)
- throw new InvalidInputException(INVALID_ESCAPE);
- currentCharacter = (char) number;
- } else
- throw new InvalidInputException(INVALID_ESCAPE);
- }
- }
-
-// chech presence of task: tags
-public void checkTaskTag(int commentStart, int commentEnd) {
-
- // only look for newer task: tags
- if (this.foundTaskCount > 0 && this.foundTaskPositions[this.foundTaskCount-1][0] >= commentStart) {
- return;
- }
- int foundTaskIndex = this.foundTaskCount;
- nextChar: for (int i = commentStart; i < commentEnd && i < this.eofPosition; i++) {
-
- char[] tag = null;
- char[] priority = null;
-
- // check for tag occurrence
- nextTag: for (int itag = 0; itag < this.taskTags.length; itag++){
- tag = this.taskTags[itag];
- priority =
- this.taskPriorities != null && itag < this.taskPriorities.length ?
- this.taskPriorities[itag] :
- null;
- int tagLength = tag.length;
- for (int t = 0; t < tagLength; t++){
- if (this.source[i+t] != tag[t]) continue nextTag;
- }
-
- if (this.foundTaskTags == null){
- this.foundTaskTags = new char[5][];
- this.foundTaskMessages = new char[5][];
- this.foundTaskPriorities = new char[5][];
- this.foundTaskPositions = new int[5][];
- } else if (this.foundTaskCount == this.foundTaskTags.length) {
- System.arraycopy(this.foundTaskTags, 0, this.foundTaskTags = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
- System.arraycopy(this.foundTaskMessages, 0, this.foundTaskMessages = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
- System.arraycopy(this.foundTaskPriorities, 0, this.foundTaskPriorities = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
- System.arraycopy(this.foundTaskPositions, 0, this.foundTaskPositions = new int[this.foundTaskCount*2][], 0, this.foundTaskCount);
- }
- this.foundTaskTags[this.foundTaskCount] = tag;
- this.foundTaskPriorities[this.foundTaskCount] = priority;
- this.foundTaskPositions[this.foundTaskCount] = new int[]{ i, i+tagLength-1 };
- this.foundTaskMessages[this.foundTaskCount] = CharOperation.NO_CHAR;
- this.foundTaskCount++;
-
- i += tagLength-1; // will be incremented when looping
- }
- }
-
- for (int i = foundTaskIndex; i < this.foundTaskCount; i++) {
- // retrieve message start and end positions
- int msgStart = this.foundTaskPositions[i][0] + this.foundTaskTags[i].length;
- int max_value = i + 1 < this.foundTaskCount ? this.foundTaskPositions[i + 1][0] - 1 : commentEnd-1; // at most beginning of next task
- if (max_value < msgStart) max_value = msgStart; // would only occur if tag is before EOF.
- int end = -1;
- char c;
-
- for (int j = msgStart; j < max_value; j++){
- if ((c = this.source[j]) == '\n' || c == '\r'){
- end = j-1;
- break;
- }
- }
-
- if (end == -1){
- for (int j = max_value; j > msgStart; j--){
- if ((c = this.source[j]) == '*') {
- end = j-1;
- break;
- }
- }
- if (end == -1) end = max_value;
- }
-
- if (msgStart == end) continue; // empty
-
- // trim the message
- while (CharOperation.isWhitespace(source[end]) && msgStart <= end) end--;
- while (CharOperation.isWhitespace(source[msgStart]) && msgStart <= end) msgStart++;
-
- // update the end position of the task
- this.foundTaskPositions[i][1] = end;
-
- // get the message source
- final int messageLength = end-msgStart+1;
- char[] message = new char[messageLength];
-
- System.arraycopy(source, msgStart, message, 0, messageLength);
- this.foundTaskMessages[i] = message;
- }
-}
+
+ public final void scanEscapeCharacter() throws InvalidInputException {
+ // the string with "\\u" is a legal string of two chars \ and u
+ //thus we use a direct access to the source (for regular cases).
+
+ if (unicodeAsBackSlash) {
+ // consume next character
+ unicodeAsBackSlash = false;
+ // if (((currentCharacter = source[currentPosition++]) == '\\') && (source[currentPosition] == 'u')) {
+ // getNextUnicodeChar();
+ // } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ // }
+ }
+ } else
+ currentCharacter = source[currentPosition++];
+ switch (currentCharacter) {
+ case 'b' :
+ currentCharacter = '\b';
+ break;
+ case 't' :
+ currentCharacter = '\t';
+ break;
+ case 'n' :
+ currentCharacter = '\n';
+ break;
+ case 'f' :
+ currentCharacter = '\f';
+ break;
+ case 'r' :
+ currentCharacter = '\r';
+ break;
+ case '\"' :
+ currentCharacter = '\"';
+ break;
+ case '\'' :
+ currentCharacter = '\'';
+ break;
+ case '\\' :
+ currentCharacter = '\\';
+ break;
+ default :
+ // -----------octal escape--------------
+ // OctalDigit
+ // OctalDigit OctalDigit
+ // ZeroToThree OctalDigit OctalDigit
+
+ int number = Character.getNumericValue(currentCharacter);
+ if (number >= 0 && number <= 7) {
+ boolean zeroToThreeNot = number > 3;
+ if (Character.isDigit(currentCharacter = source[currentPosition++])) {
+ int digit = Character.getNumericValue(currentCharacter);
+ if (digit >= 0 && digit <= 7) {
+ number = (number * 8) + digit;
+ if (Character.isDigit(currentCharacter = source[currentPosition++])) {
+ if (zeroToThreeNot) { // has read \NotZeroToThree OctalDigit Digit --> ignore last character
+ currentPosition--;
+ } else {
+ digit = Character.getNumericValue(currentCharacter);
+ if (digit >= 0 && digit <= 7) { // has read \ZeroToThree OctalDigit OctalDigit
+ number = (number * 8) + digit;
+ } else { // has read \ZeroToThree OctalDigit NonOctalDigit --> ignore last character
+ currentPosition--;
+ }
+ }
+ } else { // has read \OctalDigit NonDigit--> ignore last character
+ currentPosition--;
+ }
+ } else { // has read \OctalDigit NonOctalDigit--> ignore last character
+ currentPosition--;
+ }
+ } else { // has read \OctalDigit --> ignore last character
+ currentPosition--;
+ }
+ if (number > 255)
+ throw new InvalidInputException(INVALID_ESCAPE);
+ currentCharacter = (char) number;
+ } else
+ throw new InvalidInputException(INVALID_ESCAPE);
+ }
+ }
+
+ // chech presence of task: tags
+ public void checkTaskTag(int commentStart, int commentEnd) {
+
+ // only look for newer task: tags
+ if (this.foundTaskCount > 0 && this.foundTaskPositions[this.foundTaskCount - 1][0] >= commentStart) {
+ return;
+ }
+ int foundTaskIndex = this.foundTaskCount;
+ nextChar : for (int i = commentStart; i < commentEnd && i < this.eofPosition; i++) {
+
+ char[] tag = null;
+ char[] priority = null;
+
+ // check for tag occurrence
+ nextTag : for (int itag = 0; itag < this.taskTags.length; itag++) {
+ tag = this.taskTags[itag];
+ priority = this.taskPriorities != null && itag < this.taskPriorities.length ? this.taskPriorities[itag] : null;
+ int tagLength = tag.length;
+ for (int t = 0; t < tagLength; t++) {
+ if (this.source[i + t] != tag[t])
+ continue nextTag;
+ }
+
+ if (this.foundTaskTags == null) {
+ this.foundTaskTags = new char[5][];
+ this.foundTaskMessages = new char[5][];
+ this.foundTaskPriorities = new char[5][];
+ this.foundTaskPositions = new int[5][];
+ } else if (this.foundTaskCount == this.foundTaskTags.length) {
+ System.arraycopy(this.foundTaskTags, 0, this.foundTaskTags = new char[this.foundTaskCount * 2][], 0, this.foundTaskCount);
+ System.arraycopy(
+ this.foundTaskMessages,
+ 0,
+ this.foundTaskMessages = new char[this.foundTaskCount * 2][],
+ 0,
+ this.foundTaskCount);
+ System.arraycopy(
+ this.foundTaskPriorities,
+ 0,
+ this.foundTaskPriorities = new char[this.foundTaskCount * 2][],
+ 0,
+ this.foundTaskCount);
+ System.arraycopy(
+ this.foundTaskPositions,
+ 0,
+ this.foundTaskPositions = new int[this.foundTaskCount * 2][],
+ 0,
+ this.foundTaskCount);
+ }
+ this.foundTaskTags[this.foundTaskCount] = tag;
+ this.foundTaskPriorities[this.foundTaskCount] = priority;
+ this.foundTaskPositions[this.foundTaskCount] = new int[] { i, i + tagLength - 1 };
+ this.foundTaskMessages[this.foundTaskCount] = CharOperation.NO_CHAR;
+ this.foundTaskCount++;
+
+ i += tagLength - 1; // will be incremented when looping
+ }
+ }
+
+ for (int i = foundTaskIndex; i < this.foundTaskCount; i++) {
+ // retrieve message start and end positions
+ int msgStart = this.foundTaskPositions[i][0] + this.foundTaskTags[i].length;
+ int max_value = i + 1 < this.foundTaskCount ? this.foundTaskPositions[i + 1][0] - 1 : commentEnd - 1;
+ // at most beginning of next task
+ if (max_value < msgStart)
+ max_value = msgStart; // would only occur if tag is before EOF.
+ int end = -1;
+ char c;
+
+ for (int j = msgStart; j < max_value; j++) {
+ if ((c = this.source[j]) == '\n' || c == '\r') {
+ end = j - 1;
+ break;
+ }
+ }
+
+ if (end == -1) {
+ for (int j = max_value; j > msgStart; j--) {
+ if ((c = this.source[j]) == '*') {
+ end = j - 1;
+ break;
+ }
+ }
+ if (end == -1)
+ end = max_value;
+ }
+
+ if (msgStart == end)
+ continue; // empty
+
+ // trim the message
+ while (CharOperation.isWhitespace(source[end]) && msgStart <= end)
+ end--;
+ while (CharOperation.isWhitespace(source[msgStart]) && msgStart <= end)
+ msgStart++;
+
+ // update the end position of the task
+ this.foundTaskPositions[i][1] = end;
+
+ // get the message source
+ final int messageLength = end - msgStart + 1;
+ char[] message = new char[messageLength];
+
+ System.arraycopy(source, msgStart, message, 0, messageLength);
+ this.foundTaskMessages[i] = message;
+ }
+ }
}
import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
import net.sourceforge.phpeclipse.PHPCore;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.builder.PHPBuilder;
+import net.sourceforge.phpdt.internal.core.builder.PHPBuilder;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
this.project = project;
}
}
- public static boolean VERBOSE = false;
+ public static boolean VERBOSE = true;
public static boolean CP_RESOLVE_VERBOSE = false;
public static boolean ZIP_ACCESS_VERBOSE = false;
throw new IOException(Util.bind("build.wrongFileFormat")); //$NON-NLS-1$
if (in.readBoolean())
return PHPBuilder.readState(project, in);
-// TODO khartlage temp-del
-// if (JavaBuilder.DEBUG)
-// System.out.println("Saved state thinks last build failed for " + project.getName()); //$NON-NLS-1$
+ if (PHPBuilder.DEBUG)
+ System.out.println("Saved state thinks last build failed for " + project.getName()); //$NON-NLS-1$
} finally {
in.close();
}
* Saves the built state for the project.
*/
private void saveBuiltState(PerProjectInfo info) throws CoreException {
-// if (JavaBuilder.DEBUG)
-// System.out.println(Util.bind("build.saveStateProgress", info.project.getName())); //$NON-NLS-1$
+ if (PHPBuilder.DEBUG)
+ System.out.println(Util.bind("build.saveStateProgress", info.project.getName())); //$NON-NLS-1$
File file = getSerializationFile(info.project);
if (file == null) return;
long t = System.currentTimeMillis();
new Status(IStatus.ERROR, PHPCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
Util.bind("build.cannotSaveState", info.project.getName()), e)); //$NON-NLS-1$
}
-// if (JavaBuilder.DEBUG) {
-// t = System.currentTimeMillis() - t;
-// System.out.println(Util.bind("build.saveStateComplete", String.valueOf(t))); //$NON-NLS-1$
-// }
+ if (PHPBuilder.DEBUG) {
+ t = System.currentTimeMillis() - t;
+ System.out.println(Util.bind("build.saveStateComplete", String.valueOf(t))); //$NON-NLS-1$
+ }
}
/**
if (externalPath == null)
return null;
-// if (JavaModelManager.VERBOSE) {
-// System.out.println("JAVA MODEL - Canonicalizing " + externalPath.toString()); //$NON-NLS-1$
-// }
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("JAVA MODEL - Canonicalizing " + externalPath.toString()); //$NON-NLS-1$
+ }
if (IS_CASE_SENSITIVE) {
-// if (JavaModelManager.VERBOSE) {
-// System.out.println("JAVA MODEL - Canonical path is original path (file system is case sensitive)"); //$NON-NLS-1$
-// }
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("JAVA MODEL - Canonical path is original path (file system is case sensitive)"); //$NON-NLS-1$
+ }
return externalPath;
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace == null) return externalPath; // protection during shutdown (30487)
if (workspace.getRoot().findMember(externalPath) != null) {
-// if (JavaModelManager.VERBOSE) {
-// System.out.println("JAVA MODEL - Canonical path is original path (member of workspace)"); //$NON-NLS-1$
-// }
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("JAVA MODEL - Canonical path is original path (member of workspace)"); //$NON-NLS-1$
+ }
return externalPath;
}
new Path(new File(externalPath.toOSString()).getCanonicalPath());
} catch (IOException e) {
// default to original path
-// if (JavaModelManager.VERBOSE) {
-// System.out.println("JAVA MODEL - Canonical path is original path (IOException)"); //$NON-NLS-1$
-// }
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("JAVA MODEL - Canonical path is original path (IOException)"); //$NON-NLS-1$
+ }
return externalPath;
}
int canonicalLength = canonicalPath.segmentCount();
if (canonicalLength == 0) {
// the java.io.File canonicalization failed
-// if (JavaModelManager.VERBOSE) {
-// System.out.println("JAVA MODEL - Canonical path is original path (canonical path is empty)"); //$NON-NLS-1$
-// }
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("JAVA MODEL - Canonical path is original path (canonical path is empty)"); //$NON-NLS-1$
+ }
return externalPath;
} else if (externalPath.isAbsolute()) {
result = canonicalPath;
if (canonicalLength >= externalLength) {
result = canonicalPath.removeFirstSegments(canonicalLength - externalLength);
} else {
-// if (JavaModelManager.VERBOSE) {
-// System.out.println("JAVA MODEL - Canonical path is original path (canonical path is " + canonicalPath.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-// }
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("JAVA MODEL - Canonical path is original path (canonical path is " + canonicalPath.toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
return externalPath;
}
}
if (externalPath.getDevice() == null) {
result = result.setDevice(null);
}
-// if (JavaModelManager.VERBOSE) {
-// System.out.println("JAVA MODEL - Canonical path is " + result.toString()); //$NON-NLS-1$
-// }
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("JAVA MODEL - Canonical path is " + result.toString()); //$NON-NLS-1$
+ }
return result;
}
System.out.println("FULL build"); //$NON-NLS-1$
try {
-// notifier.subTask(Util.bind("build.cleaningOutput")); //$NON-NLS-1$
-// JavaModelManager.getJavaModelManager().deltaProcessor.addForRefresh(javaBuilder.javaProject);
-// PHPBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject);
+ notifier.subTask(Util.bind("build.cleaningOutput")); //$NON-NLS-1$
+ JavaModelManager.getJavaModelManager().deltaProcessor.addForRefresh(javaBuilder.javaProject);
+ PHPBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject);
// cleanOutputFolders();
notifier.updateProgressDelta(0.1f);
import net.sourceforge.phpdt.core.compiler.IProblem;
import net.sourceforge.phpdt.internal.compiler.problem.AbortCompilation;
-import net.sourceforge.phpdt.internal.compiler.util.Util;
+import net.sourceforge.phpdt.internal.core.Util;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
public class State {
-// NOTE: this state cannot contain types that are not defined in this project
-
-String javaProjectName;
-ClasspathMultiDirectory[] sourceLocations;
-//ClasspathLocation[] binaryLocations;
-// keyed by the project relative path of the type (ie. "src1/p1/p2/A.java"), value is a ReferenceCollection or an AdditionalTypeCollection
-SimpleLookupTable references;
-// keyed by qualified type name "p1/p2/A", value is the project relative path which defines this type "src1/p1/p2/A.java"
-SimpleLookupTable typeLocators;
-
-int buildNumber;
-long lastStructuralBuildTime;
-SimpleLookupTable structuralBuildTimes;
-
-private String[] knownPackageNames; // of the form "p1/p2"
-
-static final byte VERSION = 0x0007;
-
-static final byte SOURCE_FOLDER = 1;
-static final byte BINARY_FOLDER = 2;
-static final byte EXTERNAL_JAR = 3;
-static final byte INTERNAL_JAR = 4;
-
-State() {
-}
-
-protected State(PHPBuilder javaBuilder) {
- this.knownPackageNames = null;
- this.javaProjectName = javaBuilder.currentProject.getName();
- this.sourceLocations = javaBuilder.nameEnvironment.sourceLocations;
-// this.binaryLocations = javaBuilder.nameEnvironment.binaryLocations;
- this.references = new SimpleLookupTable(7);
- this.typeLocators = new SimpleLookupTable(7);
-
- this.buildNumber = 0; // indicates a full build
- this.lastStructuralBuildTime = System.currentTimeMillis();
- this.structuralBuildTimes = new SimpleLookupTable(3);
-}
-
-void copyFrom(State lastState) {
- try {
- this.knownPackageNames = null;
- this.buildNumber = lastState.buildNumber + 1;
- this.lastStructuralBuildTime = lastState.lastStructuralBuildTime;
- this.references = (SimpleLookupTable) lastState.references.clone();
- this.typeLocators = (SimpleLookupTable) lastState.typeLocators.clone();
- } catch (CloneNotSupportedException e) {
- this.references = new SimpleLookupTable(lastState.references.elementSize);
- Object[] keyTable = lastState.references.keyTable;
- Object[] valueTable = lastState.references.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- this.references.put(keyTable[i], valueTable[i]);
-
- this.typeLocators = new SimpleLookupTable(lastState.typeLocators.elementSize);
- keyTable = lastState.typeLocators.keyTable;
- valueTable = lastState.typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- this.typeLocators.put(keyTable[i], valueTable[i]);
- }
-}
-
-char[][] getDefinedTypeNamesFor(String typeLocator) {
- Object c = references.get(typeLocator);
- if (c instanceof AdditionalTypeCollection)
- return ((AdditionalTypeCollection) c).definedTypeNames;
- return null; // means only one type is defined with the same name as the file... saves space
-}
-
-boolean isDuplicateLocator(String qualifiedTypeName, String typeLocator) {
- String existing = (String) typeLocators.get(qualifiedTypeName);
- return existing != null && !existing.equals(typeLocator);
-}
-
-boolean isKnownPackage(String qualifiedPackageName) {
- if (knownPackageNames == null) {
- ArrayList names = new ArrayList(typeLocators.elementSize);
- Object[] keyTable = typeLocators.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- String packageName = (String) keyTable[i]; // is a type name of the form p1/p2/A
- int last = packageName.lastIndexOf('/');
- packageName = last == -1 ? null : packageName.substring(0, last);
- while (packageName != null && !names.contains(packageName)) {
- names.add(packageName);
- last = packageName.lastIndexOf('/');
- packageName = last == -1 ? null : packageName.substring(0, last);
- }
- }
- }
- knownPackageNames = new String[names.size()];
- names.toArray(knownPackageNames);
- }
- for (int i = 0, l = knownPackageNames.length; i < l; i++)
- if (knownPackageNames[i].equals(qualifiedPackageName))
- return true;
- return false;
-}
-
-void record(String typeLocator, char[][][] qualifiedRefs, char[][] simpleRefs, char[] mainTypeName, ArrayList typeNames) {
- if (typeNames.size() == 1 && CharOperation.equals(mainTypeName, (char[]) typeNames.get(0))) {
- references.put(typeLocator, new ReferenceCollection(qualifiedRefs, simpleRefs));
- } else {
- char[][] definedTypeNames = new char[typeNames.size()][]; // can be empty when no types are defined
- typeNames.toArray(definedTypeNames);
- references.put(typeLocator, new AdditionalTypeCollection(definedTypeNames, qualifiedRefs, simpleRefs));
- }
-}
-
-void recordLocatorForType(String qualifiedTypeName, String typeLocator) {
- this.knownPackageNames = null;
- typeLocators.put(qualifiedTypeName, typeLocator);
-}
-
-void recordStructuralDependency(IProject prereqProject, State prereqState) {
- if (prereqState != null)
- structuralBuildTimes.put(prereqProject.getName(), new Long(prereqState.lastStructuralBuildTime));
-}
-
-void removeLocator(String typeLocatorToRemove) {
- this.knownPackageNames = null;
- references.removeKey(typeLocatorToRemove);
- typeLocators.removeValue(typeLocatorToRemove);
-}
-
-void removePackage(IResourceDelta sourceDelta) {
- IResource resource = sourceDelta.getResource();
- switch(resource.getType()) {
- case IResource.FOLDER :
- IResourceDelta[] children = sourceDelta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- removePackage(children[i]);
- return;
- case IResource.FILE :
- IPath typeLocatorPath = resource.getProjectRelativePath();
- if (Util.isJavaFileName(typeLocatorPath.lastSegment()))
- removeLocator(typeLocatorPath.toString());
- }
-}
-
-void removeQualifiedTypeName(String qualifiedTypeNameToRemove) {
- this.knownPackageNames = null;
- typeLocators.removeKey(qualifiedTypeNameToRemove);
-}
-
-static State read(IProject project, DataInputStream in) throws IOException {
- if (PHPBuilder.DEBUG)
- System.out.println("About to read state..."); //$NON-NLS-1$
- if (VERSION != in.readByte()) {
- if (PHPBuilder.DEBUG)
- System.out.println("Found non-compatible state version... answered null"); //$NON-NLS-1$
- return null;
- }
-
- State newState = new State();
- newState.javaProjectName = in.readUTF();
- if (!project.getName().equals(newState.javaProjectName)) {
- if (PHPBuilder.DEBUG)
- System.out.println("Project's name does not match... answered null"); //$NON-NLS-1$
- return null;
- }
- newState.buildNumber = in.readInt();
- newState.lastStructuralBuildTime = in.readLong();
-
- int length = in.readInt();
- newState.sourceLocations = new ClasspathMultiDirectory[0];
-// newState.sourceLocations = new ClasspathMultiDirectory[length];
-// for (int i = 0; i < length; i++) {
-// IContainer sourceFolder = project, outputFolder = project;
-// String folderName;
-// if ((folderName = in.readUTF()).length() > 0) sourceFolder = project.getFolder(folderName);
-// if ((folderName = in.readUTF()).length() > 0) outputFolder = project.getFolder(folderName);
-// ClasspathMultiDirectory md =
-// (ClasspathMultiDirectory) ClasspathLocation.forSourceFolder(sourceFolder, outputFolder, readNames(in));
-// if (in.readBoolean())
-// md.hasIndependentOutputFolder = true;
-// newState.sourceLocations[i] = md;
-// }
-
- length = in.readInt();
-// newState.binaryLocations = new ClasspathLocation[length];
-// IWorkspaceRoot root = project.getWorkspace().getRoot();
-// for (int i = 0; i < length; i++) {
-// switch (in.readByte()) {
-// case SOURCE_FOLDER :
-// newState.binaryLocations[i] = newState.sourceLocations[in.readInt()];
-// break;
-// case BINARY_FOLDER :
-// IPath path = new Path(in.readUTF());
-// IContainer outputFolder = path.segmentCount() == 1
-// ? (IContainer) root.getProject(path.toString())
-// : (IContainer) root.getFolder(path);
-// newState.binaryLocations[i] = ClasspathLocation.forBinaryFolder(outputFolder, in.readBoolean());
-// break;
-// case EXTERNAL_JAR :
-// newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF());
-// break;
-// case INTERNAL_JAR :
-// newState.binaryLocations[i] = ClasspathLocation.forLibrary(root.getFile(new Path(in.readUTF())));
-// }
-// }
-
- newState.structuralBuildTimes = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++)
- newState.structuralBuildTimes.put(in.readUTF(), new Long(in.readLong()));
-
- String[] internedTypeLocators = new String[length = in.readInt()];
- for (int i = 0; i < length; i++)
- internedTypeLocators[i] = in.readUTF();
-
- newState.typeLocators = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++)
- newState.typeLocators.put(in.readUTF(), internedTypeLocators[in.readInt()]);
-
- char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(readNames(in), false);
- char[][][] internedQualifiedNames = new char[length = in.readInt()][][];
- for (int i = 0; i < length; i++) {
- int qLength = in.readInt();
- char[][] qName = new char[qLength][];
- for (int j = 0; j < qLength; j++)
- qName[j] = internedSimpleNames[in.readInt()];
- internedQualifiedNames[i] = qName;
- }
- internedQualifiedNames = ReferenceCollection.internQualifiedNames(internedQualifiedNames);
-
- newState.references = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++) {
- String typeLocator = internedTypeLocators[in.readInt()];
- ReferenceCollection collection = null;
- switch (in.readByte()) {
- case 1 :
- char[][] additionalTypeNames = readNames(in);
- char[][][] qualifiedNames = new char[in.readInt()][][];
- for (int j = 0, m = qualifiedNames.length; j < m; j++)
- qualifiedNames[j] = internedQualifiedNames[in.readInt()];
- char[][] simpleNames = new char[in.readInt()][];
- for (int j = 0, m = simpleNames.length; j < m; j++)
- simpleNames[j] = internedSimpleNames[in.readInt()];
- collection = new AdditionalTypeCollection(additionalTypeNames, qualifiedNames, simpleNames);
- break;
- case 2 :
- char[][][] qNames = new char[in.readInt()][][];
- for (int j = 0, m = qNames.length; j < m; j++)
- qNames[j] = internedQualifiedNames[in.readInt()];
- char[][] sNames = new char[in.readInt()][];
- for (int j = 0, m = sNames.length; j < m; j++)
- sNames[j] = internedSimpleNames[in.readInt()];
- collection = new ReferenceCollection(qNames, sNames);
- }
- newState.references.put(typeLocator, collection);
- }
- if (PHPBuilder.DEBUG)
- System.out.println("Successfully read state for " + newState.javaProjectName); //$NON-NLS-1$
- return newState;
-}
-
-private static char[][] readNames(DataInputStream in) throws IOException {
- int length = in.readInt();
- char[][] names = new char[length][];
- for (int i = 0; i < length; i++) {
- int nLength = in.readInt();
- char[] name = new char[nLength];
- for (int j = 0; j < nLength; j++)
- name[j] = in.readChar();
- names[i] = name;
- }
- return names;
-}
-
-void tagAsNoopBuild() {
- this.buildNumber = -1; // tag the project since it has no source folders and can be skipped
-}
-
-boolean wasNoopBuild() {
- return buildNumber == -1;
-}
-
-void tagAsStructurallyChanged() {
- this.lastStructuralBuildTime = System.currentTimeMillis();
-}
-
-boolean wasStructurallyChanged(IProject prereqProject, State prereqState) {
- if (prereqState != null) {
- Object o = structuralBuildTimes.get(prereqProject.getName());
- long previous = o == null ? 0 : ((Long) o).longValue();
- if (previous == prereqState.lastStructuralBuildTime) return false;
- }
- return true;
-}
-
-void write(DataOutputStream out) throws IOException {
- int length;
- Object[] keyTable;
- Object[] valueTable;
-
-/*
- * byte VERSION
- * String project name
- * int build number
- * int last structural build number
-*/
- out.writeByte(VERSION);
- out.writeUTF(javaProjectName);
- out.writeInt(buildNumber);
- out.writeLong(lastStructuralBuildTime);
-
-/*
- * ClasspathMultiDirectory[]
- * int id
- * String path(s)
-*/
- out.writeInt(length = sourceLocations.length);
- for (int i = 0; i < length; i++) {
- ClasspathMultiDirectory md = sourceLocations[i];
- out.writeUTF(md.sourceFolder.getProjectRelativePath().toString());
- out.writeUTF(md.binaryFolder.getProjectRelativePath().toString());
- writeNames(md.exclusionPatterns, out);
- out.writeBoolean(md.hasIndependentOutputFolder);
- }
-
-/*
- * ClasspathLocation[]
- * int id
- * String path(s)
-*/
-// out.writeInt(length = binaryLocations.length);
-// next : for (int i = 0; i < length; i++) {
-// ClasspathLocation c = binaryLocations[i];
-// if (c instanceof ClasspathMultiDirectory) {
-// out.writeByte(SOURCE_FOLDER);
-// for (int j = 0, m = sourceLocations.length; j < m; j++) {
-// if (sourceLocations[j] == c) {
-// out.writeInt(j);
-// continue next;
-// }
-// }
-// } else if (c instanceof ClasspathDirectory) {
-// out.writeByte(BINARY_FOLDER);
-// ClasspathDirectory cd = (ClasspathDirectory) c;
-// out.writeUTF(cd.binaryFolder.getFullPath().toString());
-// out.writeBoolean(cd.isOutputFolder);
-// } else {
-// ClasspathJar jar = (ClasspathJar) c;
-// if (jar.resource == null) {
-// out.writeByte(EXTERNAL_JAR);
-// out.writeUTF(jar.zipFilename);
-// } else {
-// out.writeByte(INTERNAL_JAR);
-// out.writeUTF(jar.resource.getFullPath().toString());
-// }
-// }
-// }
-
-/*
- * Structural build numbers table
- * String prereq project name
- * int last structural build number
-*/
- out.writeInt(length = structuralBuildTimes.elementSize);
- if (length > 0) {
- keyTable = structuralBuildTimes.keyTable;
- valueTable = structuralBuildTimes.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- out.writeUTF((String) keyTable[i]);
- out.writeLong(((Long) valueTable[i]).longValue());
- }
- }
- if (PHPBuilder.DEBUG && length != 0)
- System.out.println("structuralBuildNumbers table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * String[] Interned type locators
- */
- out.writeInt(length = references.elementSize);
- ArrayList internedTypeLocators = new ArrayList(length);
- if (length > 0) {
- keyTable = references.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- String key = (String) keyTable[i];
- out.writeUTF(key);
- internedTypeLocators.add(key);
- }
- }
- if (PHPBuilder.DEBUG && length != 0)
- System.out.println("references table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * Type locators table
- * String type name
- * int interned locator id
- */
- out.writeInt(length = typeLocators.elementSize);
- if (length > 0) {
- keyTable = typeLocators.keyTable;
- valueTable = typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- out.writeUTF((String) keyTable[i]);
- out.writeInt(internedTypeLocators.indexOf((String) valueTable[i]));
- }
- }
- if (PHPBuilder.DEBUG && length != 0)
- System.out.println("typeLocators table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * char[][][] Interned qualified names
- * char[][] Interned simple names
- */
- ArrayList internedQualifiedNames = new ArrayList(31);
- ArrayList internedSimpleNames = new ArrayList(31);
- valueTable = references.valueTable;
- for (int i = 0, l = valueTable.length; i < l; i++) {
- if (valueTable[i] != null) {
- ReferenceCollection collection = (ReferenceCollection) valueTable[i];
- char[][][] qNames = collection.qualifiedNameReferences;
- for (int j = 0, m = qNames.length; j < m; j++) {
- char[][] qName = qNames[j];
- if (!internedQualifiedNames.contains(qName)) { // remember the names have been interned
- internedQualifiedNames.add(qName);
- for (int k = 0, n = qName.length; k < n; k++) {
- char[] sName = qName[k];
- if (!internedSimpleNames.contains(sName)) // remember the names have been interned
- internedSimpleNames.add(sName);
- }
- }
- }
- char[][] sNames = collection.simpleNameReferences;
- for (int j = 0, m = sNames.length; j < m; j++) {
- char[] sName = sNames[j];
- if (!internedSimpleNames.contains(sName)) // remember the names have been interned
- internedSimpleNames.add(sName);
- }
- }
- }
- char[][] internedArray = new char[internedSimpleNames.size()][];
- internedSimpleNames.toArray(internedArray);
- writeNames(internedArray, out);
- // now write the interned qualified names as arrays of interned simple names
- out.writeInt(length = internedQualifiedNames.size());
- for (int i = 0; i < length; i++) {
- char[][] qName = (char[][]) internedQualifiedNames.get(i);
- int qLength = qName.length;
- out.writeInt(qLength);
- for (int j = 0; j < qLength; j++)
- out.writeInt(internedSimpleNames.indexOf(qName[j]));
- }
-
-/*
- * References table
- * int interned locator id
- * ReferenceCollection
-*/
- out.writeInt(length = references.elementSize);
- if (length > 0) {
- keyTable = references.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- out.writeInt(internedTypeLocators.indexOf((String) keyTable[i]));
- ReferenceCollection collection = (ReferenceCollection) valueTable[i];
- if (collection instanceof AdditionalTypeCollection) {
- out.writeByte(1);
- AdditionalTypeCollection atc = (AdditionalTypeCollection) collection;
- writeNames(atc.definedTypeNames, out);
- } else {
- out.writeByte(2);
- }
- char[][][] qNames = collection.qualifiedNameReferences;
- int qLength = qNames.length;
- out.writeInt(qLength);
- for (int j = 0; j < qLength; j++)
- out.writeInt(internedQualifiedNames.indexOf(qNames[j]));
- char[][] sNames = collection.simpleNameReferences;
- int sLength = sNames.length;
- out.writeInt(sLength);
- for (int j = 0; j < sLength; j++)
- out.writeInt(internedSimpleNames.indexOf(sNames[j]));
- }
- }
- if (PHPBuilder.DEBUG && length != 0)
- System.out.println("references table is inconsistent"); //$NON-NLS-1$
- }
-}
-
-private void writeNames(char[][] names, DataOutputStream out) throws IOException {
- int length = names == null ? 0 : names.length;
- out.writeInt(length);
- for (int i = 0; i < length; i++) {
- char[] name = names[i];
- int nLength = name.length;
- out.writeInt(nLength);
- for (int j = 0; j < nLength; j++)
- out.writeChar(name[j]);
- }
-}
-
-/**
- * Returns a string representation of the receiver.
- */
-public String toString() {
- return "State for " + javaProjectName //$NON-NLS-1$
- + " (#" + buildNumber //$NON-NLS-1$
- + " @ " + new Date(lastStructuralBuildTime) //$NON-NLS-1$
- + ")"; //$NON-NLS-1$
-}
-
-/* Debug helper
-void dump() {
- System.out.println("State for " + javaProjectName + " (" + buildNumber + " @ " + new Date(lastStructuralBuildTime) + ")");
- System.out.println("\tClass path source locations:");
- for (int i = 0, l = sourceLocations.length; i < l; i++)
- System.out.println("\t\t" + sourceLocations[i]);
- System.out.println("\tClass path binary locations:");
- for (int i = 0, l = binaryLocations.length; i < l; i++)
- System.out.println("\t\t" + binaryLocations[i]);
-
- System.out.print("\tStructural build numbers table:");
- if (structuralBuildTimes.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = structuralBuildTimes.keyTable;
- Object[] valueTable = structuralBuildTimes.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
- }
-
- System.out.print("\tType locators table:");
- if (typeLocators.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = typeLocators.keyTable;
- Object[] valueTable = typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
- }
-
- System.out.print("\n\tReferences table:");
- if (references.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = references.keyTable;
- Object[] valueTable = references.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- System.out.print("\n\t\t" + keyTable[i].toString());
- ReferenceCollection c = (ReferenceCollection) valueTable[i];
- char[][][] qRefs = c.qualifiedNameReferences;
- System.out.print("\n\t\t\tqualified:");
- if (qRefs.length == 0)
- System.out.print(" <empty>");
- else for (int j = 0, m = qRefs.length; j < m; j++)
- System.out.print(" '" + CharOperation.toString(qRefs[j]) + "'");
- char[][] sRefs = c.simpleNameReferences;
- System.out.print("\n\t\t\tsimple:");
- if (sRefs.length == 0)
- System.out.print(" <empty>");
- else for (int j = 0, m = sRefs.length; j < m; j++)
- System.out.print(" " + new String(sRefs[j]));
- if (c instanceof AdditionalTypeCollection) {
- char[][] names = ((AdditionalTypeCollection) c).definedTypeNames;
- System.out.print("\n\t\t\tadditional type names:");
- for (int j = 0, m = names.length; j < m; j++)
- System.out.print(" " + new String(names[j]));
- }
- }
- }
- }
- System.out.print("\n\n");
-}
-*/
+ // NOTE: this state cannot contain types that are not defined in this project
+
+ String javaProjectName;
+ ClasspathMultiDirectory[] sourceLocations;
+ //ClasspathLocation[] binaryLocations;
+ // keyed by the project relative path of the type (ie. "src1/p1/p2/A.java"), value is a ReferenceCollection or an
+ // AdditionalTypeCollection
+ SimpleLookupTable references;
+ // keyed by qualified type name "p1/p2/A", value is the project relative path which defines this type "src1/p1/p2/A.java"
+ SimpleLookupTable typeLocators;
+
+ int buildNumber;
+ long lastStructuralBuildTime;
+ SimpleLookupTable structuralBuildTimes;
+
+ private String[] knownPackageNames; // of the form "p1/p2"
+
+ static final byte VERSION = 0x0007;
+
+ static final byte SOURCE_FOLDER = 1;
+// static final byte BINARY_FOLDER = 2;
+// static final byte EXTERNAL_JAR = 3;
+// static final byte INTERNAL_JAR = 4;
+
+ State() {
+ }
+
+ protected State(PHPBuilder javaBuilder) {
+ this.knownPackageNames = null;
+ this.javaProjectName = javaBuilder.currentProject.getName();
+ this.sourceLocations = javaBuilder.nameEnvironment.sourceLocations;
+ // this.binaryLocations = javaBuilder.nameEnvironment.binaryLocations;
+ this.references = new SimpleLookupTable(7);
+ this.typeLocators = new SimpleLookupTable(7);
+
+ this.buildNumber = 0; // indicates a full build
+ this.lastStructuralBuildTime = System.currentTimeMillis();
+ this.structuralBuildTimes = new SimpleLookupTable(3);
+ }
+
+ void copyFrom(State lastState) {
+ try {
+ this.knownPackageNames = null;
+ this.buildNumber = lastState.buildNumber + 1;
+ this.lastStructuralBuildTime = lastState.lastStructuralBuildTime;
+ this.references = (SimpleLookupTable) lastState.references.clone();
+ this.typeLocators = (SimpleLookupTable) lastState.typeLocators.clone();
+ } catch (CloneNotSupportedException e) {
+ this.references = new SimpleLookupTable(lastState.references.elementSize);
+ Object[] keyTable = lastState.references.keyTable;
+ Object[] valueTable = lastState.references.valueTable;
+ for (int i = 0, l = keyTable.length; i < l; i++)
+ if (keyTable[i] != null)
+ this.references.put(keyTable[i], valueTable[i]);
+
+ this.typeLocators = new SimpleLookupTable(lastState.typeLocators.elementSize);
+ keyTable = lastState.typeLocators.keyTable;
+ valueTable = lastState.typeLocators.valueTable;
+ for (int i = 0, l = keyTable.length; i < l; i++)
+ if (keyTable[i] != null)
+ this.typeLocators.put(keyTable[i], valueTable[i]);
+ }
+ }
+
+ char[][] getDefinedTypeNamesFor(String typeLocator) {
+ Object c = references.get(typeLocator);
+ if (c instanceof AdditionalTypeCollection)
+ return ((AdditionalTypeCollection) c).definedTypeNames;
+ return null; // means only one type is defined with the same name as the file... saves space
+ }
+
+ boolean isDuplicateLocator(String qualifiedTypeName, String typeLocator) {
+ String existing = (String) typeLocators.get(qualifiedTypeName);
+ return existing != null && !existing.equals(typeLocator);
+ }
+
+ boolean isKnownPackage(String qualifiedPackageName) {
+ if (knownPackageNames == null) {
+ ArrayList names = new ArrayList(typeLocators.elementSize);
+ Object[] keyTable = typeLocators.keyTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ if (keyTable[i] != null) {
+ String packageName = (String) keyTable[i]; // is a type name of the form p1/p2/A
+ int last = packageName.lastIndexOf('/');
+ packageName = last == -1 ? null : packageName.substring(0, last);
+ while (packageName != null && !names.contains(packageName)) {
+ names.add(packageName);
+ last = packageName.lastIndexOf('/');
+ packageName = last == -1 ? null : packageName.substring(0, last);
+ }
+ }
+ }
+ knownPackageNames = new String[names.size()];
+ names.toArray(knownPackageNames);
+ }
+ for (int i = 0, l = knownPackageNames.length; i < l; i++)
+ if (knownPackageNames[i].equals(qualifiedPackageName))
+ return true;
+ return false;
+ }
+
+ void record(String typeLocator, char[][][] qualifiedRefs, char[][] simpleRefs, char[] mainTypeName, ArrayList typeNames) {
+ if (typeNames.size() == 1 && CharOperation.equals(mainTypeName, (char[]) typeNames.get(0))) {
+ references.put(typeLocator, new ReferenceCollection(qualifiedRefs, simpleRefs));
+ } else {
+ char[][] definedTypeNames = new char[typeNames.size()][]; // can be empty when no types are defined
+ typeNames.toArray(definedTypeNames);
+ references.put(typeLocator, new AdditionalTypeCollection(definedTypeNames, qualifiedRefs, simpleRefs));
+ }
+ }
+
+ void recordLocatorForType(String qualifiedTypeName, String typeLocator) {
+ this.knownPackageNames = null;
+ typeLocators.put(qualifiedTypeName, typeLocator);
+ }
+
+ void recordStructuralDependency(IProject prereqProject, State prereqState) {
+ if (prereqState != null)
+ structuralBuildTimes.put(prereqProject.getName(), new Long(prereqState.lastStructuralBuildTime));
+ }
+
+ void removeLocator(String typeLocatorToRemove) {
+ this.knownPackageNames = null;
+ references.removeKey(typeLocatorToRemove);
+ typeLocators.removeValue(typeLocatorToRemove);
+ }
+
+ void removePackage(IResourceDelta sourceDelta) {
+ IResource resource = sourceDelta.getResource();
+ switch (resource.getType()) {
+ case IResource.FOLDER :
+ IResourceDelta[] children = sourceDelta.getAffectedChildren();
+ for (int i = 0, l = children.length; i < l; i++)
+ removePackage(children[i]);
+ return;
+ case IResource.FILE :
+ IPath typeLocatorPath = resource.getProjectRelativePath();
+ if (Util.isJavaFileName(typeLocatorPath.lastSegment()))
+ removeLocator(typeLocatorPath.toString());
+ }
+ }
+
+ void removeQualifiedTypeName(String qualifiedTypeNameToRemove) {
+ this.knownPackageNames = null;
+ typeLocators.removeKey(qualifiedTypeNameToRemove);
+ }
+
+ static State read(IProject project, DataInputStream in) throws IOException {
+ if (PHPBuilder.DEBUG)
+ System.out.println("About to read state..."); //$NON-NLS-1$
+ if (VERSION != in.readByte()) {
+ if (PHPBuilder.DEBUG)
+ System.out.println("Found non-compatible state version... answered null"); //$NON-NLS-1$
+ return null;
+ }
+
+ State newState = new State();
+ newState.javaProjectName = in.readUTF();
+ if (!project.getName().equals(newState.javaProjectName)) {
+ if (PHPBuilder.DEBUG)
+ System.out.println("Project's name does not match... answered null"); //$NON-NLS-1$
+ return null;
+ }
+ newState.buildNumber = in.readInt();
+ newState.lastStructuralBuildTime = in.readLong();
+
+ int length = in.readInt();
+ newState.sourceLocations = new ClasspathMultiDirectory[0];
+ // newState.sourceLocations = new ClasspathMultiDirectory[length];
+ // for (int i = 0; i < length; i++) {
+ // IContainer sourceFolder = project, outputFolder = project;
+ // String folderName;
+ // if ((folderName = in.readUTF()).length() > 0) sourceFolder = project.getFolder(folderName);
+ // if ((folderName = in.readUTF()).length() > 0) outputFolder = project.getFolder(folderName);
+ // ClasspathMultiDirectory md =
+ // (ClasspathMultiDirectory) ClasspathLocation.forSourceFolder(sourceFolder, outputFolder, readNames(in));
+ // if (in.readBoolean())
+ // md.hasIndependentOutputFolder = true;
+ // newState.sourceLocations[i] = md;
+ // }
+
+ length = in.readInt();
+ // newState.binaryLocations = new ClasspathLocation[length];
+ // IWorkspaceRoot root = project.getWorkspace().getRoot();
+ // for (int i = 0; i < length; i++) {
+ // switch (in.readByte()) {
+ // case SOURCE_FOLDER :
+ // newState.binaryLocations[i] = newState.sourceLocations[in.readInt()];
+ // break;
+ // case BINARY_FOLDER :
+ // IPath path = new Path(in.readUTF());
+ // IContainer outputFolder = path.segmentCount() == 1
+ // ? (IContainer) root.getProject(path.toString())
+ // : (IContainer) root.getFolder(path);
+ // newState.binaryLocations[i] = ClasspathLocation.forBinaryFolder(outputFolder, in.readBoolean());
+ // break;
+ // case EXTERNAL_JAR :
+ // newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF());
+ // break;
+ // case INTERNAL_JAR :
+ // newState.binaryLocations[i] = ClasspathLocation.forLibrary(root.getFile(new Path(in.readUTF())));
+ // }
+ // }
+
+ newState.structuralBuildTimes = new SimpleLookupTable(length = in.readInt());
+ for (int i = 0; i < length; i++)
+ newState.structuralBuildTimes.put(in.readUTF(), new Long(in.readLong()));
+
+ String[] internedTypeLocators = new String[length = in.readInt()];
+ for (int i = 0; i < length; i++)
+ internedTypeLocators[i] = in.readUTF();
+
+ newState.typeLocators = new SimpleLookupTable(length = in.readInt());
+ for (int i = 0; i < length; i++)
+ newState.typeLocators.put(in.readUTF(), internedTypeLocators[in.readInt()]);
+
+ char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(readNames(in), false);
+ char[][][] internedQualifiedNames = new char[length = in.readInt()][][];
+ for (int i = 0; i < length; i++) {
+ int qLength = in.readInt();
+ char[][] qName = new char[qLength][];
+ for (int j = 0; j < qLength; j++)
+ qName[j] = internedSimpleNames[in.readInt()];
+ internedQualifiedNames[i] = qName;
+ }
+ internedQualifiedNames = ReferenceCollection.internQualifiedNames(internedQualifiedNames);
+
+ newState.references = new SimpleLookupTable(length = in.readInt());
+ for (int i = 0; i < length; i++) {
+ String typeLocator = internedTypeLocators[in.readInt()];
+ ReferenceCollection collection = null;
+ switch (in.readByte()) {
+ case 1 :
+ char[][] additionalTypeNames = readNames(in);
+ char[][][] qualifiedNames = new char[in.readInt()][][];
+ for (int j = 0, m = qualifiedNames.length; j < m; j++)
+ qualifiedNames[j] = internedQualifiedNames[in.readInt()];
+ char[][] simpleNames = new char[in.readInt()][];
+ for (int j = 0, m = simpleNames.length; j < m; j++)
+ simpleNames[j] = internedSimpleNames[in.readInt()];
+ collection = new AdditionalTypeCollection(additionalTypeNames, qualifiedNames, simpleNames);
+ break;
+ case 2 :
+ char[][][] qNames = new char[in.readInt()][][];
+ for (int j = 0, m = qNames.length; j < m; j++)
+ qNames[j] = internedQualifiedNames[in.readInt()];
+ char[][] sNames = new char[in.readInt()][];
+ for (int j = 0, m = sNames.length; j < m; j++)
+ sNames[j] = internedSimpleNames[in.readInt()];
+ collection = new ReferenceCollection(qNames, sNames);
+ }
+ newState.references.put(typeLocator, collection);
+ }
+ if (PHPBuilder.DEBUG)
+ System.out.println("Successfully read state for " + newState.javaProjectName); //$NON-NLS-1$
+ return newState;
+ }
+
+ private static char[][] readNames(DataInputStream in) throws IOException {
+ int length = in.readInt();
+ char[][] names = new char[length][];
+ for (int i = 0; i < length; i++) {
+ int nLength = in.readInt();
+ char[] name = new char[nLength];
+ for (int j = 0; j < nLength; j++)
+ name[j] = in.readChar();
+ names[i] = name;
+ }
+ return names;
+ }
+
+ void tagAsNoopBuild() {
+ this.buildNumber = -1; // tag the project since it has no source folders and can be skipped
+ }
+
+ boolean wasNoopBuild() {
+ return buildNumber == -1;
+ }
+
+ void tagAsStructurallyChanged() {
+ this.lastStructuralBuildTime = System.currentTimeMillis();
+ }
+
+ boolean wasStructurallyChanged(IProject prereqProject, State prereqState) {
+ if (prereqState != null) {
+ Object o = structuralBuildTimes.get(prereqProject.getName());
+ long previous = o == null ? 0 : ((Long) o).longValue();
+ if (previous == prereqState.lastStructuralBuildTime)
+ return false;
+ }
+ return true;
+ }
+
+ void write(DataOutputStream out) throws IOException {
+ int length;
+ Object[] keyTable;
+ Object[] valueTable;
+
+ /*
+ * byte VERSION String project name int build number int last structural build number
+ */
+ out.writeByte(VERSION);
+ out.writeUTF(javaProjectName);
+ out.writeInt(buildNumber);
+ out.writeLong(lastStructuralBuildTime);
+
+ /*
+ * ClasspathMultiDirectory[] int id String path(s)
+ */
+ out.writeInt(length = sourceLocations.length);
+ for (int i = 0; i < length; i++) {
+ ClasspathMultiDirectory md = sourceLocations[i];
+ out.writeUTF(md.sourceFolder.getProjectRelativePath().toString());
+ out.writeUTF(md.binaryFolder.getProjectRelativePath().toString());
+ writeNames(md.exclusionPatterns, out);
+ out.writeBoolean(md.hasIndependentOutputFolder);
+ }
+
+ /*
+ * ClasspathLocation[] int id String path(s)
+ */
+ // out.writeInt(length = binaryLocations.length);
+ // next : for (int i = 0; i < length; i++) {
+ // ClasspathLocation c = binaryLocations[i];
+ // if (c instanceof ClasspathMultiDirectory) {
+ // out.writeByte(SOURCE_FOLDER);
+ // for (int j = 0, m = sourceLocations.length; j < m; j++) {
+ // if (sourceLocations[j] == c) {
+ // out.writeInt(j);
+ // continue next;
+ // }
+ // }
+ // } else if (c instanceof ClasspathDirectory) {
+ // out.writeByte(BINARY_FOLDER);
+ // ClasspathDirectory cd = (ClasspathDirectory) c;
+ // out.writeUTF(cd.binaryFolder.getFullPath().toString());
+ // out.writeBoolean(cd.isOutputFolder);
+ // } else {
+ // ClasspathJar jar = (ClasspathJar) c;
+ // if (jar.resource == null) {
+ // out.writeByte(EXTERNAL_JAR);
+ // out.writeUTF(jar.zipFilename);
+ // } else {
+ // out.writeByte(INTERNAL_JAR);
+ // out.writeUTF(jar.resource.getFullPath().toString());
+ // }
+ // }
+ // }
+
+ /*
+ * Structural build numbers table String prereq project name int last structural build number
+ */
+ out.writeInt(length = structuralBuildTimes.elementSize);
+ if (length > 0) {
+ keyTable = structuralBuildTimes.keyTable;
+ valueTable = structuralBuildTimes.valueTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ if (keyTable[i] != null) {
+ length--;
+ out.writeUTF((String) keyTable[i]);
+ out.writeLong(((Long) valueTable[i]).longValue());
+ }
+ }
+ if (PHPBuilder.DEBUG && length != 0)
+ System.out.println("structuralBuildNumbers table is inconsistent"); //$NON-NLS-1$
+ }
+
+ /*
+ * String[] Interned type locators
+ */
+ out.writeInt(length = references.elementSize);
+ ArrayList internedTypeLocators = new ArrayList(length);
+ if (length > 0) {
+ keyTable = references.keyTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ if (keyTable[i] != null) {
+ length--;
+ String key = (String) keyTable[i];
+ out.writeUTF(key);
+ internedTypeLocators.add(key);
+ }
+ }
+ if (PHPBuilder.DEBUG && length != 0)
+ System.out.println("references table is inconsistent"); //$NON-NLS-1$
+ }
+
+ /*
+ * Type locators table String type name int interned locator id
+ */
+ out.writeInt(length = typeLocators.elementSize);
+ if (length > 0) {
+ keyTable = typeLocators.keyTable;
+ valueTable = typeLocators.valueTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ if (keyTable[i] != null) {
+ length--;
+ out.writeUTF((String) keyTable[i]);
+ out.writeInt(internedTypeLocators.indexOf((String) valueTable[i]));
+ }
+ }
+ if (PHPBuilder.DEBUG && length != 0)
+ System.out.println("typeLocators table is inconsistent"); //$NON-NLS-1$
+ }
+
+ /*
+ * char[][][] Interned qualified names char[][] Interned simple names
+ */
+ ArrayList internedQualifiedNames = new ArrayList(31);
+ ArrayList internedSimpleNames = new ArrayList(31);
+ valueTable = references.valueTable;
+ for (int i = 0, l = valueTable.length; i < l; i++) {
+ if (valueTable[i] != null) {
+ ReferenceCollection collection = (ReferenceCollection) valueTable[i];
+ char[][][] qNames = collection.qualifiedNameReferences;
+ for (int j = 0, m = qNames.length; j < m; j++) {
+ char[][] qName = qNames[j];
+ if (!internedQualifiedNames.contains(qName)) { // remember the names have been interned
+ internedQualifiedNames.add(qName);
+ for (int k = 0, n = qName.length; k < n; k++) {
+ char[] sName = qName[k];
+ if (!internedSimpleNames.contains(sName)) // remember the names have been interned
+ internedSimpleNames.add(sName);
+ }
+ }
+ }
+ char[][] sNames = collection.simpleNameReferences;
+ for (int j = 0, m = sNames.length; j < m; j++) {
+ char[] sName = sNames[j];
+ if (!internedSimpleNames.contains(sName)) // remember the names have been interned
+ internedSimpleNames.add(sName);
+ }
+ }
+ }
+ char[][] internedArray = new char[internedSimpleNames.size()][];
+ internedSimpleNames.toArray(internedArray);
+ writeNames(internedArray, out);
+ // now write the interned qualified names as arrays of interned simple names
+ out.writeInt(length = internedQualifiedNames.size());
+ for (int i = 0; i < length; i++) {
+ char[][] qName = (char[][]) internedQualifiedNames.get(i);
+ int qLength = qName.length;
+ out.writeInt(qLength);
+ for (int j = 0; j < qLength; j++)
+ out.writeInt(internedSimpleNames.indexOf(qName[j]));
+ }
+
+ /*
+ * References table int interned locator id ReferenceCollection
+ */
+ out.writeInt(length = references.elementSize);
+ if (length > 0) {
+ keyTable = references.keyTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ if (keyTable[i] != null) {
+ length--;
+ out.writeInt(internedTypeLocators.indexOf((String) keyTable[i]));
+ ReferenceCollection collection = (ReferenceCollection) valueTable[i];
+ if (collection instanceof AdditionalTypeCollection) {
+ out.writeByte(1);
+ AdditionalTypeCollection atc = (AdditionalTypeCollection) collection;
+ writeNames(atc.definedTypeNames, out);
+ } else {
+ out.writeByte(2);
+ }
+ char[][][] qNames = collection.qualifiedNameReferences;
+ int qLength = qNames.length;
+ out.writeInt(qLength);
+ for (int j = 0; j < qLength; j++)
+ out.writeInt(internedQualifiedNames.indexOf(qNames[j]));
+ char[][] sNames = collection.simpleNameReferences;
+ int sLength = sNames.length;
+ out.writeInt(sLength);
+ for (int j = 0; j < sLength; j++)
+ out.writeInt(internedSimpleNames.indexOf(sNames[j]));
+ }
+ }
+ if (PHPBuilder.DEBUG && length != 0)
+ System.out.println("references table is inconsistent"); //$NON-NLS-1$
+ }
+ }
+
+ private void writeNames(char[][] names, DataOutputStream out) throws IOException {
+ int length = names == null ? 0 : names.length;
+ out.writeInt(length);
+ for (int i = 0; i < length; i++) {
+ char[] name = names[i];
+ int nLength = name.length;
+ out.writeInt(nLength);
+ for (int j = 0; j < nLength; j++)
+ out.writeChar(name[j]);
+ }
+ }
+
+ /**
+ * Returns a string representation of the receiver.
+ */
+ public String toString() {
+ return "State for " + javaProjectName //$NON-NLS-1$
+ +" (#" + buildNumber //$NON-NLS-1$
+ +" @ " + new Date(lastStructuralBuildTime) //$NON-NLS-1$
+ +")"; //$NON-NLS-1$
+ }
+
+ /*
+ * Debug helper void dump() { System.out.println("State for " + javaProjectName + " (" + buildNumber + " @ " + new
+ * Date(lastStructuralBuildTime) + ")"); System.out.println("\tClass path source locations:"); for (int i = 0, l =
+ * sourceLocations.length; i < l; i++) System.out.println("\t\t" + sourceLocations[i]); System.out.println("\tClass path binary
+ * locations:"); for (int i = 0, l = binaryLocations.length; i < l; i++) System.out.println("\t\t" + binaryLocations[i]);
+ *
+ * System.out.print("\tStructural build numbers table:"); if (structuralBuildTimes.elementSize == 0) { System.out.print(" <empty>
+ * "); } else { Object[] keyTable = structuralBuildTimes.keyTable; Object[] valueTable = structuralBuildTimes.valueTable; for
+ * (int i = 0, l = keyTable.length; i < l; i++) if (keyTable[i] != null) System.out.print("\n\t\t" + keyTable[i].toString() + " -> " +
+ * valueTable[i].toString()); }
+ *
+ * System.out.print("\tType locators table:"); if (typeLocators.elementSize == 0) { System.out.print(" <empty> "); } else {
+ * Object[] keyTable = typeLocators.keyTable; Object[] valueTable = typeLocators.valueTable; for (int i = 0, l = keyTable.length;
+ * i < l; i++) if (keyTable[i] != null) System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString()); }
+ *
+ * System.out.print("\n\tReferences table:"); if (references.elementSize == 0) { System.out.print(" <empty> "); } else { Object[]
+ * keyTable = references.keyTable; Object[] valueTable = references.valueTable; for (int i = 0, l = keyTable.length; i
+ * < l; i++) { if (keyTable[i] != null) { System.out.print("\n\t\t" + keyTable[i].toString()); ReferenceCollection c =
+ * (ReferenceCollection) valueTable[i]; char[][][] qRefs = c.qualifiedNameReferences; System.out.print("\n\t\t\tqualified:"); if
+ * (qRefs.length == 0) System.out.print(" <empty> "); else for (int j = 0, m = qRefs.length; j < m; j++) System.out.print(" '" +
+ * CharOperation.toString(qRefs[j]) + "'"); char[][] sRefs = c.simpleNameReferences; System.out.print("\n\t\t\tsimple:"); if
+ * (sRefs.length == 0) System.out.print(" <empty> "); else for (int j = 0, m = sRefs.length; j < m; j++) System.out.print(" " +
+ * new String(sRefs[j])); if (c instanceof AdditionalTypeCollection) { char[][] names = ((AdditionalTypeCollection)
+ * c).definedTypeNames; System.out.print("\n\t\t\tadditional type names:"); for (int j = 0, m = names.length; j < m; j++)
+ * System.out.print(" " + new String(names[j])); } } } } System.out.print("\n\n"); }
+ */
}
--- /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.phpdt.internal.ui.text;
+
+
+import java.io.IOException;
+import java.io.Reader;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * Provides a set of convenience methods for creating HTML pages.
+ */
+public class HTMLPrinter {
+
+ private HTMLPrinter() {
+ }
+
+ private static String replace(String text, char c, String s) {
+
+ int previous= 0;
+ int current= text.indexOf(c, previous);
+
+ if (current == -1)
+ return text;
+
+ StringBuffer buffer= new StringBuffer();
+ while (current > -1) {
+ buffer.append(text.substring(previous, current));
+ buffer.append(s);
+ previous= current + 1;
+ current= text.indexOf(c, previous);
+ }
+ buffer.append(text.substring(previous));
+
+ return buffer.toString();
+ }
+
+ public static String convertToHTMLContent(String content) {
+ content= replace(content, '<', "<"); //$NON-NLS-1$
+ return replace(content, '>', ">"); //$NON-NLS-1$
+ }
+
+ public static String read(Reader rd) {
+
+ StringBuffer buffer= new StringBuffer();
+ char[] readBuffer= new char[2048];
+
+ try {
+ int n= rd.read(readBuffer);
+ while (n > 0) {
+ buffer.append(readBuffer, 0, n);
+ n= rd.read(readBuffer);
+ }
+ return buffer.toString();
+ } catch (IOException x) {
+ }
+
+ return null;
+ }
+
+ public static void insertPageProlog(StringBuffer buffer, int position, RGB bgRGB) {
+ if (bgRGB == null)
+ insertPageProlog(buffer, position);
+ else {
+ StringBuffer pageProlog= new StringBuffer(60);
+ pageProlog.append("<html><body text=\"#000000\" bgcolor=\""); //$NON-NLS-1$
+ appendColor(pageProlog, bgRGB);
+ pageProlog.append("\"><font size=-1>"); //$NON-NLS-1$
+ buffer.insert(position, pageProlog.toString());
+ }
+ }
+
+ private static void appendColor(StringBuffer buffer, RGB rgb) {
+ buffer.append('#');
+ buffer.append(Integer.toHexString(rgb.red));
+ buffer.append(Integer.toHexString(rgb.green));
+ buffer.append(Integer.toHexString(rgb.blue));
+ }
+
+ public static void insertPageProlog(StringBuffer buffer, int position) {
+ RGB bgColor= null;
+ IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ Display display= window.getShell().getDisplay();
+ if (display != null && !display.isDisposed())
+ bgColor= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
+ }
+ if (bgColor == null)
+ bgColor= new RGB(255,255, 225); // RGB value of info bg color on WindowsXP
+
+ insertPageProlog(buffer, position, bgColor); //$NON-NLS-1$
+ }
+
+ public static void addPageProlog(StringBuffer buffer) {
+ insertPageProlog(buffer, buffer.length());
+ }
+
+ public static void addPageEpilog(StringBuffer buffer) {
+ buffer.append("</font></body></html>"); //$NON-NLS-1$
+ }
+
+ public static void startBulletList(StringBuffer buffer) {
+ buffer.append("<ul>"); //$NON-NLS-1$
+ }
+
+ public static void endBulletList(StringBuffer buffer) {
+ buffer.append("</ul>"); //$NON-NLS-1$
+ }
+
+ public static void addBullet(StringBuffer buffer, String bullet) {
+ if (bullet != null) {
+ buffer.append("<li>"); //$NON-NLS-1$
+ buffer.append(bullet);
+ buffer.append("</li>"); //$NON-NLS-1$
+ }
+ }
+
+ public static void addSmallHeader(StringBuffer buffer, String header) {
+ if (header != null) {
+ buffer.append("<h5>"); //$NON-NLS-1$
+ buffer.append(header);
+ buffer.append("</h5>"); //$NON-NLS-1$
+ }
+ }
+
+ public static void addParagraph(StringBuffer buffer, String paragraph) {
+ if (paragraph != null) {
+ buffer.append("<p>"); //$NON-NLS-1$
+ buffer.append(paragraph);
+ }
+ }
+
+ public static void addParagraph(StringBuffer buffer, Reader paragraphReader) {
+ if (paragraphReader != null)
+ addParagraph(buffer, read(paragraphReader));
+ }
+}
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.ui.externaltools.internal.ant.editor.derived.HTMLPrinter;
// TODO: delete this class ? we use PHPAnnotationHover instead !
/**
import java.util.Iterator;
+import net.sourceforge.phpdt.internal.ui.text.HTMLPrinter;
import net.sourceforge.phpdt.ui.PreferenceConstants;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.phpeditor.IJavaAnnotation;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.externaltools.internal.ant.editor.derived.HTMLPrinter;
import org.eclipse.ui.texteditor.IDocumentProvider;
import net.sourceforge.phpdt.core.IMember;
import net.sourceforge.phpdt.core.ISourceReference;
import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.internal.ui.text.HTMLPrinter;
import net.sourceforge.phpdt.internal.ui.text.PHPCodeReader;
import net.sourceforge.phpdt.internal.ui.viewsupport.JavaElementLabels;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.externaltools.internal.ant.editor.derived.HTMLPrinter;
/**
* Provides source as hover info for Java elements.
--- /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.phpdt.internal.ui.text.link;
+
+import org.eclipse.jface.text.Position;
+
+/**
+ * A listener for highlight change notification and exititing linked mode.
+ */
+public interface ILinkedPositionListener {
+
+ /**
+ * Notifies that the linked mode has been left. On success, all changes are kept, otherwise all changes made to the linked
+ * positions are restored to the state before entering linked mode.
+ */
+ void exit(int flags);
+
+ /**
+ * Notifies the changed linked position. The listener is asked to reposition the caret at the given offset.
+ *
+ * @param position
+ * the linked position which initiated the change.
+ * @param caretOffset
+ * the caret offset relative to the position.
+ */
+ void setCurrentPosition(Position position, int caretOffset);
+
+}
-/**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. 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 implementation
-**********************************************************************/
+/*******************************************************************************
+ * 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.phpdt.internal.ui.text.link;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
/**
}
}
- private static final String LINKED_POSITION= "LinkedPositionManager.linked.position"; //$NON-NLS-1$
+ private static final String LINKED_POSITION_PREFIX= "LinkedPositionManager.linked.position"; //$NON-NLS-1$
private static final Comparator fgPositionComparator= new PositionComparator();
private static final Map fgActiveManagers= new HashMap();
+ private static int fgCounter= 0;
private IDocument fDocument;
-
- private LinkedPositionListener fListener;
+ private ILinkedPositionListener fListener;
+ private String fPositionCategoryName;
+ private boolean fMustLeave;
+ /**
+ * Flag that records the state of this manager. As there are many different entities that may
+ * call leave or exit, these cannot always be sure whether the linked position infrastructure is
+ * still active. This is especially true for multithreaded situations.
+ */
+ private boolean fIsActive= false;
+
/**
* Creates a <code>LinkedPositionManager</code> for a <code>IDocument</code>.
*
* @param document the document to use with linked positions.
+ * @param canCoexist <code>true</code> if this manager can coexist with an already existing one
*/
- public LinkedPositionManager(IDocument document) {
+ public LinkedPositionManager(IDocument document, boolean canCoexist) {
Assert.isNotNull(document);
-
- fDocument= document;
- install();
+ fDocument= document;
+ fPositionCategoryName= LINKED_POSITION_PREFIX + (fgCounter++);
+ install(canCoexist);
}
-
+
+ /**
+ * Creates a <code>LinkedPositionManager</code> for a <code>IDocument</code>.
+ *
+ * @param document the document to use with linked positions.
+ */
+ public LinkedPositionManager(IDocument document) {
+ this(document, false);
+ }
+
/**
* Sets a listener to notify changes of current linked position.
*/
- public void setLinkedPositionListener(LinkedPositionListener listener) {
+ public void setLinkedPositionListener(ILinkedPositionListener listener) {
fListener= listener;
}
/**
- * Adds a linked position to the manager.
+ * Adds a linked position to the manager with the type being the content of
+ * the document at the specified range.
* There are the following constraints for linked positions:
*
* <ul>
* @param length the length of the position.
*/
public void addPosition(int offset, int length) throws BadLocationException {
+ String type= fDocument.get(offset, length);
+ addPosition(offset, length, type);
+ }
+
+ /**
+ * Adds a linked position of the specified position type to the manager.
+ * There are the following constraints for linked positions:
+ *
+ * <ul>
+ * <li>Any two positions have spacing of at least one character.
+ * This implies that two positions must not overlap.</li>
+ *
+ * <li>The string at any position must not contain line delimiters.</li>
+ * </ul>
+ *
+ * @param offset the offset of the position.
+ * @param length the length of the position.
+ * @param type the position type name - any positions with the same type are linked.
+ */
+ public void addPosition(int offset, int length, String type) throws BadLocationException {
Position[] positions= getPositions(fDocument);
if (positions != null) {
throw new BadLocationException(LinkedPositionMessages.getString(("LinkedPositionManager.error.position.collision"))); //$NON-NLS-1$
}
- String type= fDocument.get(offset, length);
+ String content= fDocument.get(offset, length);
- if (containsLineDelimiters(type))
+ if (containsLineDelimiters(content))
throw new BadLocationException(LinkedPositionMessages.getString(("LinkedPositionManager.error.contains.line.delimiters"))); //$NON-NLS-1$
try {
- fDocument.addPosition(LINKED_POSITION, new TypedPosition(offset, length, type));
+ fDocument.addPosition(fPositionCategoryName, new TypedPosition(offset, length, type));
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
}
+
+ /**
+ * Adds a linked position to the manager. The current document content at the specified range is
+ * taken as the position type.
+ * <p>
+ * There are the following constraints for linked positions:
+ *
+ * <ul>
+ * <li>Any two positions have spacing of at least one character.
+ * This implies that two positions must not overlap.</li>
+ *
+ * <li>The string at any position must not contain line delimiters.</li>
+ * </ul>
+ *
+ * It is usually best to set the first item in <code>additionalChoices</code> to be equal with
+ * the text inserted at the current position.
+ * </p>
+ *
+ * @param offset the offset of the position.
+ * @param length the length of the position.
+ * @param additionalChoices a number of additional choices to be displayed when selecting
+ * a position of this <code>type</code>.
+ */
+ public void addPosition(int offset, int length, ICompletionProposal[] additionalChoices) throws BadLocationException {
+ String type= fDocument.get(offset, length);
+ addPosition(offset, length, type, additionalChoices);
+ }
+ /**
+ * Adds a linked position of the specified position type to the manager.
+ * There are the following constraints for linked positions:
+ *
+ * <ul>
+ * <li>Any two positions have spacing of at least one character.
+ * This implies that two positions must not overlap.</li>
+ *
+ * <li>The string at any position must not contain line delimiters.</li>
+ * </ul>
+ *
+ * It is usually best to set the first item in <code>additionalChoices</code> to be equal with
+ * the text inserted at the current position.
+ *
+ * @param offset the offset of the position.
+ * @param length the length of the position.
+ * @param type the position type name - any positions with the same type are linked.
+ * @param additionalChoices a number of additional choices to be displayed when selecting
+ * a position of this <code>type</code>.
+ */
+ public void addPosition(int offset, int length, String type, ICompletionProposal[] additionalChoices) throws BadLocationException {
+ Position[] positions= getPositions(fDocument);
+
+ if (positions != null) {
+ for (int i = 0; i < positions.length; i++)
+ if (collides(positions[i], offset, length))
+ throw new BadLocationException(LinkedPositionMessages.getString(("LinkedPositionManager.error.position.collision"))); //$NON-NLS-1$
+ }
+
+ String content= fDocument.get(offset, length);
+ if (containsLineDelimiters(content))
+ throw new BadLocationException(LinkedPositionMessages.getString(("LinkedPositionManager.error.contains.line.delimiters"))); //$NON-NLS-1$
+
+ try {
+ fDocument.addPosition(fPositionCategoryName, new ProposalPosition(offset, length, type, additionalChoices));
+ } catch (BadPositionCategoryException e) {
+ PHPeclipsePlugin.log(e);
+ Assert.isTrue(false);
+ }
+ }
+
/**
* Tests if a manager is already active for a document.
*/
public static boolean hasActiveManager(IDocument document) {
return fgActiveManagers.get(document) != null;
}
-
- private void install() {
- LinkedPositionManager manager= (LinkedPositionManager) fgActiveManagers.get(fDocument);
- if (manager != null)
- manager.leave(true);
-
- fgActiveManagers.put(fDocument, this);
+
+ private void install(boolean canCoexist) {
+
+ if (fIsActive)
+ ;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionManager is already active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+ else {
+ fIsActive= true;
+ //JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionManager activated: "+fPositionCategoryName, new Exception())); //$NON-NLS-1$
+ }
- fDocument.addPositionCategory(LINKED_POSITION);
+ if (!canCoexist) {
+ LinkedPositionManager manager= (LinkedPositionManager) fgActiveManagers.get(fDocument);
+ if (manager != null)
+ manager.leave(true);
+ }
+
+ fgActiveManagers.put(fDocument, this);
+ fDocument.addPositionCategory(fPositionCategoryName);
fDocument.addPositionUpdater(this);
fDocument.addDocumentListener(this);
+
+ fMustLeave= false;
}
/**
* Leaves the linked mode. If unsuccessful, the linked positions
* are restored to the values at the time they were added.
*/
- public void uninstall(boolean success) {
- fDocument.removeDocumentListener(this);
-
- try {
- Position[] positions= getPositions(fDocument);
- if ((!success) && (positions != null)) {
- // restore
- for (int i= 0; i != positions.length; i++) {
- TypedPosition position= (TypedPosition) positions[i];
- fDocument.replace(position.getOffset(), position.getLength(), position.getType());
- }
- }
+ public void uninstall(boolean success) {
+
+ if (!fIsActive)
+ // we migth also just return
+ ;//JavaPlugin(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionManager activated: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+ else {
+ fDocument.removeDocumentListener(this);
- fDocument.removePositionCategory(LINKED_POSITION);
-
- } catch (BadLocationException e) {
- PHPeclipsePlugin.log(e);
- Assert.isTrue(false);
-
- } catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
- Assert.isTrue(false);
-
- } finally {
- fDocument.removePositionUpdater(this);
- fgActiveManagers.remove(fDocument);
+ try {
+ Position[] positions= getPositions(fDocument);
+ if ((!success) && (positions != null)) {
+ // restore
+ for (int i= 0; i != positions.length; i++) {
+ TypedPosition position= (TypedPosition) positions[i];
+ fDocument.replace(position.getOffset(), position.getLength(), position.getType());
+ }
+ }
+
+ fDocument.removePositionCategory(fPositionCategoryName);
+
+ fIsActive= false;
+ // JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionManager deactivated: "+fPositionCategoryName, new Exception())); //$NON-NLS-1$
+
+ } catch (BadLocationException e) {
+ PHPeclipsePlugin.log(e);
+ Assert.isTrue(false);
+
+ } catch (BadPositionCategoryException e) {
+ PHPeclipsePlugin.log(e);
+ Assert.isTrue(false);
+
+ } finally {
+ fDocument.removePositionUpdater(this);
+ fgActiveManagers.remove(fDocument);
+ }
}
+
}
/**
public Position getFirstPosition() {
return getNextPosition(-1);
}
+
+ public Position getLastPosition() {
+ Position[] positions= getPositions(fDocument);
+ for (int i= positions.length - 1; i >= 0; i--) {
+ String type= ((TypedPosition) positions[i]).getType();
+ int j;
+ for (j = 0; j != i; j++)
+ if (((TypedPosition) positions[j]).getType().equals(type))
+ break;
+
+ if (j == i)
+ return positions[i];
+ }
+
+ return null;
+ }
/**
* Returns the next linked position with an offset greater than <code>offset</code>.
Position lastPosition= null;
Position position= getFirstPosition();
- while ((position != null) && (position.getOffset() < offset) && !((TypedPosition) position).getType().equals(currentType)) {
- lastPosition= position;
+ while (position != null && position.getOffset() < offset) {
+ if (!((TypedPosition) position).getType().equals(currentType))
+ lastPosition= position;
position= findNextPosition(positions, position.getOffset());
}
return lastPosition;
}
- private static Position[] getPositions(IDocument document) {
+ private Position[] getPositions(IDocument document) {
+
+ if (!fIsActive)
+ // we migth also just return an empty array
+ ;//JavaPlugin(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionManager is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+
try {
- Position[] positions= document.getPositions(LINKED_POSITION);
+ Position[] positions= document.getPositions(fPositionCategoryName);
Arrays.sort(positions, fgPositionComparator);
return positions;
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
}
private void leave(boolean success) {
- uninstall(success);
-
+ try {
+ uninstall(success);
+
+ if (fListener != null)
+ fListener.exit((success ? LinkedPositionUI.COMMIT : 0) | LinkedPositionUI.UPDATE_CARET);
+ } finally {
+ fMustLeave= false;
+ }
+ }
+
+ private void abort() {
+ uninstall(true); // don't revert anything
+
if (fListener != null)
- fListener.exit(success);
+ fListener.exit(LinkedPositionUI.COMMIT); // don't let the UI restore anything
+
+ // don't set fMustLeave, as we will get re-registered by a document event
}
/*
*/
public void documentAboutToBeChanged(DocumentEvent event) {
+ if (fMustLeave) {
+ event.getDocument().removeDocumentListener(this);
+ return;
+ }
+
IDocument document= event.getDocument();
Position[] positions= getPositions(document);
if (position == null) {
// check for destruction of constraints (spacing of at least 1)
if ((event.getText() == null || event.getText().length() == 0) &&
- (findCurrentPosition(positions, event.getOffset()) != null) &&
+ (findCurrentPosition(positions, event.getOffset()) != null) && // will never become true, see condition above
(findCurrentPosition(positions, event.getOffset() + event.getLength()) != null))
{
leave(true);
* @see IPositionUpdater#update(DocumentEvent)
*/
public void update(DocumentEvent event) {
- int deltaLength= (event.getText() == null ? 0 : event.getText().length()) - event.getLength();
+
+ int eventOffset= event.getOffset();
+ int eventOldLength= event.getLength();
+ int eventNewLength= event.getText() == null ? 0 : event.getText().length();
+ int deltaLength= eventNewLength - eventOldLength;
Position[] positions= getPositions(event.getDocument());
- TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, event.getOffset());
-
- // document change outside positions
- if (currentPosition == null) {
+
+
+ for (int i= 0; i != positions.length; i++) {
- for (int i= 0; i != positions.length; i++) {
- TypedPosition position= (TypedPosition) positions[i];
- int offset= position.getOffset();
-
- if (offset >= event.getOffset())
- position.setOffset(offset + deltaLength);
- }
+ Position position= positions[i];
- // document change within a position
- } else {
- int length= currentPosition.getLength();
-
- for (int i= 0; i != positions.length; i++) {
- TypedPosition position= (TypedPosition) positions[i];
- int offset= position.getOffset();
-
- if (position.equals(currentPosition)) {
- position.setLength(length + deltaLength);
- } else if (offset > currentPosition.getOffset()) {
- position.setOffset(offset + deltaLength);
- }
- }
+ if (position.isDeleted())
+ continue;
+
+ int offset= position.getOffset();
+ int length= position.getLength();
+ int end= offset + length;
+
+ if (offset > eventOffset + eventOldLength) // position comes way after change - shift
+ position.setOffset(offset + deltaLength);
+ else if (end < eventOffset) // position comes way before change - leave alone
+ ;
+ else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
+ // event completely internal to the position - adjust length
+ position.setLength(length + deltaLength);
+ } else if (offset < eventOffset) {
+ // event extends over end of position - adjust length
+ int newEnd= eventOffset + eventNewLength;
+ position.setLength(newEnd - offset);
+ } else if (end > eventOffset + eventOldLength) {
+ // event extends from before position into it - adjust offset and length
+ // offset becomes end of event, length ajusted acordingly
+ // we want to recycle the overlapping part
+ int newOffset = eventOffset + eventNewLength;
+ position.setOffset(newOffset);
+ position.setLength(length + deltaLength);
+ } else {
+ // event consumes the position - delete it
+ position.delete();
+// JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "linked position deleted -> must leave: "+fPositionCategoryName, null)); //$NON-NLS-1$
+ fMustLeave= true;
+ }
}
+
+ if (fMustLeave)
+ abort();
}
private static Position findCurrentPosition(Position[] positions, int offset) {
return includes(position, offset, length);
}
+ /**
+ * Returns the position that includes the given range.
+ * @param offset
+ * @param length
+ * @return position that includes the given range
+ */
+ public Position getEmbracingPosition(int offset, int length) {
+ Position[] positions= getPositions(fDocument);
+
+ Position position= findCurrentPosition(positions, offset);
+ if (position != null && includes(position, offset, length))
+ return position;
+
+ return null;
+ }
+
/*
* @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
*/
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+
+ if (fMustLeave) {
+ leave(true);
+ return;
+ }
// don't interfere with preceding auto edit strategies
if (command.getCommandCount() != 1) {
try {
if (position.getType().equals(currentPosition.getType()) && !position.equals(currentPosition))
- command.addCommand(position.getOffset() + deltaOffset, command.length, command.text, this);
+ command.addCommand(position.getOffset() + deltaOffset, command.length, command.text, true, this);
} catch (BadLocationException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
}
}
}
-}
\ No newline at end of file
+}
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/*******************************************************************************
+ * 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.phpdt.internal.ui.text.link;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.IRewriteTarget;
import org.eclipse.jface.text.ITextInputListener;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+
+
/**
* A user interface for <code>LinkedPositionManager</code>, using <code>ITextViewer</code>.
*/
-public class LinkedPositionUI implements LinkedPositionListener,
+public class LinkedPositionUI implements ILinkedPositionListener,
ITextInputListener, ITextListener, ModifyListener, VerifyListener, VerifyKeyListener, PaintListener, IPropertyChangeListener, ShellListener {
/**
private static final int DOCUMENT_CHANGED= 4; // document has changed
public static final int UPDATE_CARET= 8; // update caret
- private static final String CARET_POSITION= "LinkedPositionUI.caret.position"; //$NON-NLS-1$
- private static final IPositionUpdater fgUpdater= new DefaultPositionUpdater(CARET_POSITION);
private static final IPreferenceStore fgStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
+ private static final String CARET_POSITION_PREFIX= "LinkedPositionUI.caret.position"; //$NON-NLS-1$
+ private static int fgCounter= 0;
+
private final ITextViewer fViewer;
- private final LinkedPositionManager fManager;
+ private final LinkedPositionManager fManager;
+ private final IPositionUpdater fUpdater;
+ private final String fPositionCategoryName;
private Color fFrameColor;
private int fFinalCaretOffset= -1; // no final caret offset
+ private Position fFinalCaretPosition;
private Position fFramePosition;
private int fInitialOffset= -1;
private boolean fNeedRedraw;
private String fContentType;
+ private Position fPreviousPosition;
+// private ContentAssistant2 fAssistant;
+
+ /**
+ * Flag that records the state of this ui object. As there are many different entities that may
+ * call leave or exit, these cannot always be sure whether the linked position infrastructure is
+ * still active. This is especially true for multithreaded situations.
+ */
+ private boolean fIsActive= false;
/**
* Creates a user interface for <code>LinkedPositionManager</code>.
fViewer= viewer;
fManager= manager;
+ fPositionCategoryName= CARET_POSITION_PREFIX + (fgCounter++);
+ fUpdater= new DefaultPositionUpdater(fPositionCategoryName);
+
fManager.setLinkedPositionListener(this);
initializeHighlightColor(viewer);
/**
* Sets the final position of the caret when the linked mode is exited
* successfully by leaving the last linked position using TAB.
+ * The set position will be a TAB stop as well as the positions configured in the
+ * <code>LinkedPositionManager</code>.
*/
public void setFinalCaretOffset(int offset) {
fFinalCaretOffset= offset;
* @see LinkedPositionManager.LinkedPositionListener#setCurrentPositions(Position, int)
*/
public void setCurrentPosition(Position position, int caretOffset) {
+ if (!fIsActive)
+ ;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+
if (!fFramePosition.equals(position)) {
fNeedRedraw= true;
fFramePosition= position;
* @see #exit(boolean)
*/
public void enter() {
+ if (fIsActive)
+ ;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is already active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+ else {
+ fIsActive= true;
+ // JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI activated: "+fPositionCategoryName, new Exception())); //$NON-NLS-1$
+ }
+
// track final caret
IDocument document= fViewer.getDocument();
- document.addPositionCategory(CARET_POSITION);
- document.addPositionUpdater(fgUpdater);
+ document.addPositionCategory(fPositionCategoryName);
+ document.addPositionUpdater(fUpdater);
try {
- if (fFinalCaretOffset != -1)
- document.addPosition(CARET_POSITION, new Position(fFinalCaretOffset));
+ if (fFinalCaretOffset != -1) {
+ fFinalCaretPosition= new Position(fFinalCaretOffset);
+ document.addPosition(fPositionCategoryName, fFinalCaretPosition);
+ }
} catch (BadLocationException e) {
handleException(fViewer.getTextWidget().getShell(), e);
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
Shell shell= text.getShell();
shell.addShellListener(this);
-
+
fFramePosition= (fInitialOffset == -1) ? fManager.getFirstPosition() : fManager.getPosition(fInitialOffset);
if (fFramePosition == null) {
leave(UNINSTALL | COMMIT | UPDATE_CARET);
fgStore.addPropertyChangeListener(this);
+// try {
+// fContentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, fFramePosition.offset);
+// if (fViewer instanceof ITextViewerExtension2) {
+// ((ITextViewerExtension2) fViewer).prependAutoEditStrategy(fManager, fContentType);
+// } else {
+// Assert.isTrue(false);
+// }
+//
+// } catch (BadLocationException e) {
+// handleException(fViewer.getTextWidget().getShell(), e);
+// }
try {
- fContentType= document.getContentType(fFramePosition.offset);
- if (fViewer instanceof ITextViewerExtension2) {
- ((ITextViewerExtension2) fViewer).prependAutoEditStrategy(fManager, fContentType);
- } else {
- Assert.isTrue(false);
- }
+ fContentType= document.getContentType(fFramePosition.offset);
+ if (fViewer instanceof ITextViewerExtension2) {
+ ((ITextViewerExtension2) fViewer).prependAutoEditStrategy(fManager, fContentType);
+ } else {
+ Assert.isTrue(false);
+ }
} catch (BadLocationException e) {
- handleException(fViewer.getTextWidget().getShell(), e);
+ handleException(fViewer.getTextWidget().getShell(), e);
}
+ selectRegion();
+// triggerContentAssist();
}
/*
- * @see LinkedPositionManager.LinkedPositionListener#exit(boolean)
+ * @see org.eclipse.jdt.internal.ui.text.link.ILinkedPositionListener#exit(boolean)
*/
- public void exit(boolean success) {
- // no UNINSTALL since manager has already uninstalled itself
- leave((success ? COMMIT : 0) | UPDATE_CARET);
+ public void exit(int flags) {
+ leave(flags);
}
/**
* <code>enter()</code> must be called prior to a call to this method.
*/
public IRegion getSelectedRegion() {
+ if (!fIsActive)
+ ;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+
if (fFramePosition == null)
return new Region(fFinalCaretOffset, 0);
else
}
private void leave(int flags) {
+ if (!fIsActive)
+ ;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+ else {
+ fIsActive= false;
+ //JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI deactivated: "+fPositionCategoryName, new Exception())); //$NON-NLS-1$
+ }
+
fInitialOffset= -1;
fFrameColor= null;
}
- StyledText text= fViewer.getTextWidget();
+ StyledText text= fViewer.getTextWidget();
+ // bail out if the styled text is null, meaning the viewer has been disposed (-> document is null as well)
+ // see pr https://bugs.eclipse.org/bugs/show_bug.cgi?id=46821
+ if (text == null)
+ return;
+
text.removePaintListener(this);
text.removeModifyListener(this);
text.removeVerifyListener(this);
Shell shell= text.getShell();
shell.removeShellListener(this);
+
+// if (fAssistant != null) {
+// Display display= text.getDisplay();
+// if (display != null && !display.isDisposed()) {
+// display.asyncExec(new Runnable() {
+// public void run() {
+// if (fAssistant != null) {
+// fAssistant.uninstall();
+// fAssistant= null;
+// }
+// }
+// });
+// }
+// }
ITextViewerExtension extension= (ITextViewerExtension) fViewer;
extension.removeVerifyKeyListener(this);
+
+ IRewriteTarget target= extension.getRewriteTarget();
+ target.endCompoundChange();
if (fViewer instanceof ITextViewerExtension2 && fContentType != null)
((ITextViewerExtension2) fViewer).removeAutoEditStrategy(fManager, fContentType);
((flags & DOCUMENT_CHANGED) == 0) &&
((flags & UPDATE_CARET) != 0))
{
- Position[] positions= document.getPositions(CARET_POSITION);
+ Position[] positions= document.getPositions(fPositionCategoryName);
if ((positions != null) && (positions.length != 0)) {
if (fViewer instanceof ITextViewerExtension3) {
}
}
- document.removePositionUpdater(fgUpdater);
- document.removePositionCategory(CARET_POSITION);
+ document.removePositionUpdater(fUpdater);
+ document.removePositionCategory(fPositionCategoryName);
if (fExitListener != null)
fExitListener.exit(
((flags & DOCUMENT_CHANGED) != 0));
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
}
private void next() {
+ if (!fIsActive)
+ ;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+
redrawRegion();
- fFramePosition= fManager.getNextPosition(fFramePosition.getOffset());
+ if (fFramePosition == fFinalCaretPosition)
+ fFramePosition= fManager.getFirstPosition();
+ else
+ fFramePosition= fManager.getNextPosition(fFramePosition.getOffset());
+ if (fFramePosition == null) {
+ if (fFinalCaretPosition != null)
+ fFramePosition= fFinalCaretPosition;
+ else
+ fFramePosition= fManager.getFirstPosition();
+ }
if (fFramePosition == null) {
leave(UNINSTALL | COMMIT | UPDATE_CARET);
} else {
selectRegion();
+// triggerContentAssist();
redrawRegion();
}
}
private void previous() {
+ if (!fIsActive)
+ ;//JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, "LinkedPositionUI is not active: "+fPositionCategoryName, new IllegalStateException())); //$NON-NLS-1$
+
redrawRegion();
- Position position= fManager.getPreviousPosition(fFramePosition.getOffset());
- if (position == null) {
- fViewer.getTextWidget().getDisplay().beep();
+ fFramePosition= fManager.getPreviousPosition(fFramePosition.getOffset());
+ if (fFramePosition == null) {
+ if (fFinalCaretPosition != null)
+ fFramePosition= fFinalCaretPosition;
+ else
+ fFramePosition= fManager.getLastPosition();
+ }
+ if (fFramePosition == null) {
+ leave(UNINSTALL | COMMIT | UPDATE_CARET);
} else {
- fFramePosition= position;
selectRegion();
+// triggerContentAssist();
redrawRegion();
}
}
+ /** Trigger content assist on choice positions */
+// private void triggerContentAssist() {
+// if (fFramePosition instanceof ProposalPosition) {
+//
+// ProposalPosition pp= (ProposalPosition) fFramePosition;
+// initializeContentAssistant();
+// if (fAssistant == null)
+// return;
+// fAssistant.setCompletions(pp.getChoices());
+// fAssistant.showPossibleCompletions();
+// } else {
+// if (fAssistant != null)
+// fAssistant.setCompletions(new ICompletionProposal[0]);
+// }
+// }
+
+ /** Lazy initialize content assistant for this linked ui */
+// private void initializeContentAssistant() {
+// if (fAssistant != null)
+// return;
+// fAssistant= new ContentAssistant2();
+// fAssistant.setDocumentPartitioning(IJavaPartitions.JAVA_PARTITIONING);
+// fAssistant.install(fViewer);
+// }
+
/*
* @see VerifyKeyListener#verifyKey(VerifyEvent)
*/
public void verifyKey(VerifyEvent event) {
- if (!event.doit)
+ if (!event.doit || !fIsActive)
return;
Point selection= fViewer.getSelectedRange();
break;
// ENTER
+ case 0x0A: // Ctrl+Enter
case 0x0D:
+ {
+// if (fAssistant != null && fAssistant.wasProposalChosen()) {
+// next();
+// event.doit= false;
+// break;
+// }
+
+ // if enter was treated as a document change, would it exceed variable range?
+ if (!LinkedPositionManager.includes(fFramePosition, offset, length)
+ || (fFramePosition == fFinalCaretPosition)) {
+ leave(UNINSTALL | COMMIT);
+ return;
+ }
+ }
+
leave(UNINSTALL | COMMIT | UPDATE_CARET);
event.doit= false;
break;
leave(UNINSTALL | COMMIT);
event.doit= false;
break;
+
+ case ';':
+ leave(UNINSTALL | COMMIT);
+ event.doit= true;
+ break;
+
+ default:
+ if (event.character != 0) {
+ if (!controlUndoBehavior(offset, length) || fFramePosition == fFinalCaretPosition) {
+ leave(UNINSTALL | COMMIT);
+ break;
+ }
+ }
}
}
-
+
+ private boolean controlUndoBehavior(int offset, int length) {
+
+ Position position= fManager.getEmbracingPosition(offset, length);
+ if (position != null) {
+
+ ITextViewerExtension extension= (ITextViewerExtension) fViewer;
+ IRewriteTarget target= extension.getRewriteTarget();
+
+ if (fPreviousPosition != null && !fPreviousPosition.equals(position))
+ target.endCompoundChange();
+ target.beginCompoundChange();
+ }
+
+ fPreviousPosition= position;
+ return fPreviousPosition != null;
+ }
+
/*
* @see VerifyListener#verifyText(VerifyEvent)
*/
public void verifyText(VerifyEvent event) {
if (!event.doit)
return;
-
-
+
+
int offset= 0;
int length= 0;
ExceptionHandler.handle((InvocationTargetException)e, shell, title, null);
else {
MessageDialog.openError(shell, title, e.getMessage());
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
}
}
* @see org.eclipse.swt.events.ShellListener#shellDeactivated(org.eclipse.swt.events.ShellEvent)
*/
public void shellDeactivated(ShellEvent event) {
- leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
+ // don't deactivate on focus lost, since the proposal popups may take focus
+ // plus: it doesn't hurt if you can check with another window without losing linked mode
+ // since there is no intrusive popup sticking out.
+
+ // need to check first what happens on reentering based on an open action
+ // Seems to be no problem
+
+ // TODO check whether we can leave it or uncomment it after debugging
+ // PS: why DOCUMENT_CHANGED? We want to trigger a redraw! (Shell deactivated does not mean
+ // it is not visible any longer.
+// leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
+
+ // Better:
+ // Check with content assistant and only leave if its not the proposal shell that took the
+ // focus away.
+
+ StyledText text;
+ Display display;
+
+// if (fAssistant == null || fViewer == null || (text= fViewer.getTextWidget()) == null
+// || (display= text.getDisplay()) == null || display.isDisposed()) {
+ if ( fViewer == null || (text= fViewer.getTextWidget()) == null
+ || (display= text.getDisplay()) == null || display.isDisposed()) {
+ leave(UNINSTALL | COMMIT);
+ } else {
+ // Post in UI thread since the assistant popup will only get the focus after we lose it.
+ display.asyncExec(new Runnable() {
+ public void run() {
+ // TODO add isDisposed / isUninstalled / hasLeft check? for now: check for content type,
+ // since it gets nullified in leave()
+ if (fIsActive) {// && (fAssistant == null || !fAssistant.hasFocus())) {
+ leave(UNINSTALL | COMMIT);
+ }
+ }
+ });
+ }
}
/*
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
}
-}
\ 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.phpdt.internal.ui.text.link;
+
+import java.util.Arrays;
+
+//import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal;
+import org.eclipse.jface.text.TypedPosition;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+
+/**
+ *
+ */
+public class ProposalPosition extends TypedPosition {
+
+ /** The choices available for this position, fChoices[0] is the original type. */
+ private final ICompletionProposal[] fChoices;
+
+ /*
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ if (o instanceof ProposalPosition) {
+ if (super.equals(o)) {
+ return Arrays.equals(fChoices, ((ProposalPosition)o).fChoices);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param offset
+ * @param length
+ * @param type
+ */
+ public ProposalPosition(int offset, int length, String type, ICompletionProposal[] choices) {
+ super(offset, length, type);
+ fChoices= new ICompletionProposal[choices.length];
+ System.arraycopy(choices, 0, fChoices, 0, choices.length);
+ }
+
+ /**
+ *
+ * @return an array of choices, including the initial one. Clients must not modify it.
+ */
+ public ICompletionProposal[] getChoices() {
+ updateChoicePositions();
+ return fChoices;
+ }
+
+ /**
+ *
+ */
+ private void updateChoicePositions() {
+ for (int i= 0; i < fChoices.length; i++) {
+// if (fChoices[i] instanceof JavaCompletionProposal)
+// ((JavaCompletionProposal)fChoices[i]).setReplacementOffset(offset);
+ }
+ }
+}
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
-
public abstract class NewElementWizard extends Wizard implements INewWizard {
- private IWorkbench fWorkbench;
- private IStructuredSelection fSelection;
-
- public NewElementWizard() {
- setNeedsProgressMonitor(true);
- }
-
- protected void openResource(final IFile resource) {
- final IWorkbenchPage activePage= PHPeclipsePlugin.getActivePage();
- if (activePage != null) {
- final Display display= getShell().getDisplay();
- if (display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
- try {
- activePage.openEditor(resource);
- } catch (PartInitException e) {
- PHPeclipsePlugin.log(e);
- }
- }
- });
- }
- }
- }
-
- /**
- * Subclasses should override to perform the actions of the wizard.
- * This method is run in the wizard container's context as a workspace runnable.
- */
- protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
- }
-
- protected void handleFinishException(Shell shell, InvocationTargetException e) {
- String title= NewWizardMessages.getString("NewElementWizard.op_error.title"); //$NON-NLS-1$
- String message= NewWizardMessages.getString("NewElementWizard.op_error.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, shell, title, message);
- }
-
- /*
- * @see Wizard#performFinish
- */
- public boolean performFinish() {
- IWorkspaceRunnable op= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
- try {
- finishPage(monitor);
- } catch (InterruptedException e) {
- throw new OperationCanceledException(e.getMessage());
- }
- }
- };
- try {
- getContainer().run(false, true, new WorkbenchRunnableAdapter(op));
- } catch (InvocationTargetException e) {
- handleFinishException(getShell(), e);
- return false;
- } catch (InterruptedException e) {
- return false;
- }
- return true;
- }
-
-// protected void warnAboutTypeCommentDeprecation() {
-// String key= IUIConstants.DIALOGSTORE_TYPECOMMENT_DEPRECATED;
-// if (OptionalMessageDialog.isDialogEnabled(key)) {
-// Templates templates= Templates.getInstance();
-// boolean isOldWorkspace= templates.getTemplates("filecomment").length > 0 && templates.getTemplates("typecomment").length > 0; //$NON-NLS-1$ //$NON-NLS-2$
-// if (!isOldWorkspace) {
-// OptionalMessageDialog.setDialogEnabled(key, false);
-// }
-// String title= NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.title"); //$NON-NLS-1$
-// String message= NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.message"); //$NON-NLS-1$
-// OptionalMessageDialog.open(key, getShell(), title, OptionalMessageDialog.getDefaultImage(), message, OptionalMessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
-// }
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
- fWorkbench= workbench;
- fSelection= currentSelection;
- }
-
- public IStructuredSelection getSelection() {
- return fSelection;
- }
-
- public IWorkbench getWorkbench() {
- return fWorkbench;
- }
-
- protected void selectAndReveal(IResource newResource) {
- BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow());
- }
+ private IWorkbench fWorkbench;
+ private IStructuredSelection fSelection;
+
+ public NewElementWizard() {
+ setNeedsProgressMonitor(true);
+ }
+
+ protected void openResource(final IFile resource) {
+ final IWorkbenchPage activePage = PHPeclipsePlugin.getActivePage();
+ if (activePage != null) {
+ final Display display = getShell().getDisplay();
+ if (display != null) {
+ display.asyncExec(new Runnable() {
+ public void run() {
+ try {
+ IDE.openEditor(activePage, resource, true);
+ } catch (PartInitException e) {
+ PHPeclipsePlugin.log(e);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Subclasses should override to perform the actions of the wizard. This method is run in the wizard container's context as a
+ * workspace runnable.
+ */
+ protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
+ }
+
+ protected void handleFinishException(Shell shell, InvocationTargetException e) {
+ String title = NewWizardMessages.getString("NewElementWizard.op_error.title"); //$NON-NLS-1$
+ String message = NewWizardMessages.getString("NewElementWizard.op_error.message"); //$NON-NLS-1$
+ ExceptionHandler.handle(e, shell, title, message);
+ }
+
+ /*
+ * @see Wizard#performFinish
+ */
+ public boolean performFinish() {
+ IWorkspaceRunnable op = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
+ try {
+ finishPage(monitor);
+ } catch (InterruptedException e) {
+ throw new OperationCanceledException(e.getMessage());
+ }
+ }
+ };
+ try {
+ getContainer().run(false, true, new WorkbenchRunnableAdapter(op));
+ } catch (InvocationTargetException e) {
+ handleFinishException(getShell(), e);
+ return false;
+ } catch (InterruptedException e) {
+ return false;
+ }
+ return true;
+ }
+
+ // protected void warnAboutTypeCommentDeprecation() {
+ // String key= IUIConstants.DIALOGSTORE_TYPECOMMENT_DEPRECATED;
+ // if (OptionalMessageDialog.isDialogEnabled(key)) {
+ // Templates templates= Templates.getInstance();
+ // boolean isOldWorkspace= templates.getTemplates("filecomment").length > 0 && templates.getTemplates("typecomment").length > 0;
+ // //$NON-NLS-1$ //$NON-NLS-2$
+ // if (!isOldWorkspace) {
+ // OptionalMessageDialog.setDialogEnabled(key, false);
+ // }
+ // String title= NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.title"); //$NON-NLS-1$
+ // String message= NewWizardMessages.getString("NewElementWizard.typecomment.deprecated.message"); //$NON-NLS-1$
+ // OptionalMessageDialog.open(key, getShell(), title, OptionalMessageDialog.getDefaultImage(), message,
+ // OptionalMessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
+ // }
+ // }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ fWorkbench = workbench;
+ fSelection = currentSelection;
+ }
+
+ public IStructuredSelection getSelection() {
+ return fSelection;
+ }
+
+ public IWorkbench getWorkbench() {
+ return fWorkbench;
+ }
+
+ protected void selectAndReveal(IResource newResource) {
+ BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow());
+ }
}
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.update.internal.ui.UpdatePerspective;
+//import org.eclipse.update.internal.ui.UpdatePerspective;
public class PHPPerspectiveFactory implements IPerspectiveFactory {
consoleArea.addView(IPageLayout.ID_TASK_LIST);
consoleArea.addView(IDebugUIConstants.ID_CONSOLE_VIEW);
- if (SWT.getPlatform().equals("win32")) {
- consoleArea.addView(UpdatePerspective.ID_BROWSER);
- }
+// if (SWT.getPlatform().equals("win32")) {
+// consoleArea.addView(UpdatePerspective.ID_BROWSER);
+// }
consoleArea.addView(IPageLayout.ID_BOOKMARKS);
layout.addView(
layout.addActionSet(PHPeclipsePlugin.PHP_CODING_ACTION_SET_ID);
layout.addShowViewShortcut(IDebugUIConstants.ID_CONSOLE_VIEW);
- if (SWT.getPlatform().equals("win32")) {
- layout.addShowViewShortcut(UpdatePerspective.ID_BROWSER);
- }
+// if (SWT.getPlatform().equals("win32")) {
+// layout.addShowViewShortcut(UpdatePerspective.ID_BROWSER);
+// }
// layout.addShowViewShortcut(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
IEditorPart editor;
ITextEditor textEditor;
if (file != null && file.exists()) {
- editor = page.openEditor(file);
+ editor = IDE.openEditor(page, file, true);
textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
} else {
// Otherwise open the stream directly
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.update.internal.ui.UpdatePerspective;
-import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
-//import org.eclipse.jdt.internal.ui.actions.OpenBrowserUtil;
-// import org.eclipse.help.ui.browser.LaunchURL;
+//import org.eclipse.update.internal.ui.UpdatePerspective;
+//import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
public class PHPEclipseShowAction implements IObjectActionDelegate {
private IWorkbenchPart workbenchPart;
case IResource.FILE :
// single file:
IFile file = (IFile) resource;
- String localhostURL;
- if ((localhostURL=getLocalhostURL(store, (IFile) resource)) == null) {
- MessageDialog.openInformation(shell, "Couldn't create localhost URL", "Please configure your localhost and documentRoot");
+ String localhostURL;
+ if ((localhostURL = getLocalhostURL(store, (IFile) resource)) == null) {
+ MessageDialog.openInformation(
+ shell,
+ "Couldn't create localhost URL",
+ "Please configure your localhost and documentRoot");
return;
}
try {
store = PHPeclipsePlugin.getDefault().getPreferenceStore();
}
- // IPath path = file.getFullPath();
+ // IPath path = file.getFullPath();
String localhostURL = file.getLocation().toString();
String lowerCaseFileName = localhostURL.toLowerCase();
return null;
}
- return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
+ return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL;
}
public static void open(final URL url, final Shell shell, final String dialogTitle) {
- if (SWT.getPlatform().equals("win32")) {
- IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
- try {
- IViewPart part = page.findView(UpdatePerspective.ID_BROWSER);
- if (part == null) {
- part = page.showView(UpdatePerspective.ID_BROWSER);
- } else
- page.bringToTop(part);
- ((IEmbeddedWebBrowser) part).openTo(url.toExternalForm());
- } catch (PartInitException e) {
- PHPeclipsePlugin.log(e);
- }
+ // if (SWT.getPlatform().equals("win32")) {
+ // IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
+ // try {
+ // IViewPart part = page.findView(UpdatePerspective.ID_BROWSER);
+ // if (part == null) {
+ // part = page.showView(UpdatePerspective.ID_BROWSER);
+ // } else
+ // page.bringToTop(part);
+ // ((IEmbeddedWebBrowser) part).openTo(url.toExternalForm());
+ // } catch (PartInitException e) {
+ // PHPeclipsePlugin.log(e);
+ // }
+ // } else {
+ IHelp help = WorkbenchHelp.getHelpSupport();
+ if (help != null) {
+ WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
} else {
- IHelp help = WorkbenchHelp.getHelpSupport();
- if (help != null) {
- WorkbenchHelp.getHelpSupport().displayHelpResource(url.toExternalForm());
- } else {
- // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
- }
+ // showMessage(shell, dialogTitle, ActionMessages.getString("OpenBrowserUtil.help_not_available"), false); //$NON-NLS-1$
}
}
+ // }
}
+++ /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.builder;
-
-import net.sourceforge.phpdt.internal.compiler.env.NameEnvironmentAnswer;
-import net.sourceforge.phpdt.internal.core.Util;
-import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-class ClasspathDirectory extends ClasspathLocation {
-
-IContainer binaryFolder; // includes .class files for a single directory
-boolean isOutputFolder;
-String binaryLocation;
-SimpleLookupTable directoryCache;
-String[] missingPackageHolder = new String[1];
-
-ClasspathDirectory(IContainer binaryFolder, boolean isOutputFolder) {
- this.binaryFolder = binaryFolder;
- this.isOutputFolder = isOutputFolder;
- IPath location = binaryFolder.getLocation();
- this.binaryLocation = location != null ? location.addTrailingSeparator().toString() : ""; //$NON-NLS-1$
-
- this.directoryCache = new SimpleLookupTable(5);
-}
-
-public void cleanup() {
- this.directoryCache = null;
-}
-
-String[] directoryList(String qualifiedPackageName) {
- String[] dirList = (String[]) directoryCache.get(qualifiedPackageName);
- if (dirList == missingPackageHolder) return null; // package exists in another classpath directory or jar
- if (dirList != null) return dirList;
-
- try {
- IResource container = binaryFolder.findMember(qualifiedPackageName); // this is a case-sensitive check
- if (container instanceof IContainer) {
- IResource[] members = ((IContainer) container).members();
- dirList = new String[members.length];
- int index = 0;
-// for (int i = 0, l = members.length; i < l; i++) {
-// IResource m = members[i];
-// if (m.getType() == IResource.FILE && Util.isClassFileName(m.getName()))
-// // add exclusion pattern check here if we want to hide .class files
-// dirList[index++] = m.getName();
-// }
- if (index < dirList.length)
- System.arraycopy(dirList, 0, dirList = new String[index], 0, index);
- directoryCache.put(qualifiedPackageName, dirList);
- return dirList;
- }
- } catch(CoreException ignored) {
- }
- directoryCache.put(qualifiedPackageName, missingPackageHolder);
- return null;
-}
-
-boolean doesFileExist(String fileName, String qualifiedPackageName, String qualifiedFullName) {
- String[] dirList = directoryList(qualifiedPackageName);
- if (dirList == null) return false; // most common case
-
- for (int i = dirList.length; --i >= 0;)
- if (fileName.equals(dirList[i]))
- return true;
- return false;
-}
-
-public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ClasspathDirectory)) return false;
-
- return binaryFolder.equals(((ClasspathDirectory) o).binaryFolder);
-}
-
-//public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
-// if (!doesFileExist(binaryFileName, qualifiedPackageName, qualifiedBinaryFileName)) return null; // most common case
-
-// try {
-// ClassFileReader reader = ClassFileReader.read(binaryLocation + qualifiedBinaryFileName);
-// if (reader != null) return new NameEnvironmentAnswer(reader);
-// } catch (Exception e) {} // treat as if class file is missing
-// return null;
-//}
-
-public IPath getProjectRelativePath() {
- return binaryFolder.getProjectRelativePath();
-}
-
-public boolean isOutputFolder() {
- return isOutputFolder;
-}
-
-public boolean isPackage(String qualifiedPackageName) {
- return directoryList(qualifiedPackageName) != null;
-}
-
-public void reset() {
- this.directoryCache = new SimpleLookupTable(5);
-}
-
-public String toString() {
- return "Binary classpath directory " + binaryFolder.getFullPath().toString(); //$NON-NLS-1$
-}
-}
+++ /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.builder;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IPath;
-
-public abstract class ClasspathLocation {
-
-static ClasspathLocation forSourceFolder(IContainer sourceFolder, IContainer outputFolder, char[][] exclusionPatterns) {
- return new ClasspathMultiDirectory(sourceFolder, outputFolder, exclusionPatterns);
-}
-
-public static ClasspathLocation forBinaryFolder(IContainer binaryFolder, boolean isOutputFolder) {
- return new ClasspathDirectory(binaryFolder, isOutputFolder);
-}
-
-//static ClasspathLocation forLibrary(String libraryPathname) {
-// return new ClasspathJar(libraryPathname);
-//}
-
-//static ClasspathLocation forLibrary(IFile library) {
-// return new ClasspathJar(library);
-//}
-
-//public abstract NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName);
-
-public abstract IPath getProjectRelativePath();
-
-public boolean isOutputFolder() {
- return false;
-}
-
-public abstract boolean isPackage(String qualifiedPackageName);
-
-// free anything which is not required when the state is saved
-public void cleanup() {
-}
-// reset any internal caches before another compile loop starts
-public void reset() {
-}
-}
+++ /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.builder;
-
-import net.sourceforge.phpdt.core.compiler.CharOperation;
-
-import org.eclipse.core.resources.IContainer;
-
-class ClasspathMultiDirectory extends ClasspathDirectory {
-
-IContainer sourceFolder;
-char[][] exclusionPatterns; // used by builders when walking source folders
-boolean hasIndependentOutputFolder; // if output folder is not equal to any of the source folders
-
-ClasspathMultiDirectory(IContainer sourceFolder, IContainer binaryFolder, char[][] exclusionPatterns) {
- super(binaryFolder, true);
-
- this.sourceFolder = sourceFolder;
- this.exclusionPatterns = exclusionPatterns;
- this.hasIndependentOutputFolder = false;
-
- // handle the case when a state rebuilds a source folder
- if (this.exclusionPatterns != null && this.exclusionPatterns.length == 0)
- this.exclusionPatterns = null;
-}
-
-public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ClasspathMultiDirectory)) return false;
-
- ClasspathMultiDirectory md = (ClasspathMultiDirectory) o;
- return sourceFolder.equals(md.sourceFolder) && binaryFolder.equals(md.binaryFolder)
- && CharOperation.equals(exclusionPatterns, md.exclusionPatterns);
-}
-
-public String toString() {
- return "Source classpath directory " + sourceFolder.getFullPath().toString() + //$NON-NLS-1$
- " with binary directory " + binaryFolder.getFullPath().toString(); //$NON-NLS-1$
-}
-}
+++ /dev/null
-package net.sourceforge.phpeclipse.builder;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Map;
-
-import net.sourceforge.phpdt.core.IJavaModelMarker;
-import net.sourceforge.phpdt.internal.core.JavaProject;
-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.phpeditor.PHPParserAction;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-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.IWorkspaceRoot;
-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 PHPBuilder extends IncrementalProjectBuilder {
- IProject currentProject;
- JavaProject javaProject;
- IWorkspaceRoot workspaceRoot;
- // NameEnvironment nameEnvironment;
- SimpleLookupTable binaryLocationsPerProject;
- // maps a project to its binary resources (output folders, class folders, zip/jar files)
- State lastState;
-
-// BuildNotifier notifier;
-
- private final static int TOTAL_WORK = 100;
-
- public static IMarker[] getProblemsFor(IResource resource) {
- try {
- if (resource != null && resource.exists())
- return resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- } // assume there are no problems
- return new IMarker[0];
- }
-
- public static IMarker[] getTasksFor(IResource resource) {
- try {
- if (resource != null && resource.exists())
- return resource.findMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- } // assume there are no tasks
- return new IMarker[0];
- }
-
- // public static void finishedBuilding(IResourceChangeEvent event) {
- // BuildNotifier.resetProblemCounters();
- // }
-
- public static void removeProblemsFor(IResource resource) {
- try {
- if (resource != null && resource.exists())
- resource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- } // assume there were no problems
- }
-
- public static void removeTasksFor(IResource resource) {
- try {
- if (resource != null && resource.exists())
- resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
- } catch (CoreException e) {
- } // assume there were no problems
- }
-
- public static void removeProblemsAndTasksFor(IResource resource) {
- try {
- if (resource != null && resource.exists()) {
- resource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
- resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
- }
- } catch (CoreException e) {
- } // assume there were no problems
- }
- public static State readState(IProject project, DataInputStream in) throws IOException {
- return State.read(project, in);
- }
-
- public static void writeState(Object state, DataOutputStream out) throws IOException {
- ((State) state).write(out);
- }
-
- /**
- * Constructor
- */
- public PHPBuilder() {
- }
-
- /**
- *
- */
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("Parsing files", TOTAL_WORK);
- this.currentProject = getProject();
- if (currentProject == null || !currentProject.isAccessible())
- return new IProject[0];
-
- 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:
- JavaProject nature = (JavaProject) 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.builder;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-
-import net.sourceforge.phpdt.internal.core.Util;
-import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-public class State {
-// NOTE: this state cannot contain types that are not defined in this project
-
-String javaProjectName;
-ClasspathMultiDirectory[] sourceLocations;
-ClasspathLocation[] binaryLocations;
-// keyed by the project relative path of the type (ie. "src1/p1/p2/A.java"), value is a ReferenceCollection or an AdditionalTypeCollection
-SimpleLookupTable references;
-// keyed by qualified type name "p1/p2/A", value is the project relative path which defines this type "src1/p1/p2/A.java"
-SimpleLookupTable typeLocators;
-
-int buildNumber;
-long lastStructuralBuildTime;
-SimpleLookupTable structuralBuildTimes;
-
-private String[] knownPackageNames; // of the form "p1/p2"
-
-static final byte VERSION = 0x0007;
-
-static final byte SOURCE_FOLDER = 1;
-static final byte BINARY_FOLDER = 2;
-static final byte EXTERNAL_JAR = 3;
-static final byte INTERNAL_JAR = 4;
-
-State() {
-}
-
-protected State(PHPBuilder javaBuilder) {
- this.knownPackageNames = null;
- this.javaProjectName = javaBuilder.currentProject.getName();
-
-// this.sourceLocations = javaBuilder.nameEnvironment.sourceLocations;
-// this.binaryLocations = javaBuilder.nameEnvironment.binaryLocations;
- this.references = new SimpleLookupTable(7);
- this.typeLocators = new SimpleLookupTable(7);
-
- this.buildNumber = 0; // indicates a full build
- this.lastStructuralBuildTime = System.currentTimeMillis();
- this.structuralBuildTimes = new SimpleLookupTable(3);
-}
-
-void copyFrom(State lastState) {
- try {
- this.knownPackageNames = null;
- this.buildNumber = lastState.buildNumber + 1;
- this.lastStructuralBuildTime = lastState.lastStructuralBuildTime;
- this.references = (SimpleLookupTable) lastState.references.clone();
- this.typeLocators = (SimpleLookupTable) lastState.typeLocators.clone();
- } catch (CloneNotSupportedException e) {
- this.references = new SimpleLookupTable(lastState.references.elementSize);
- Object[] keyTable = lastState.references.keyTable;
- Object[] valueTable = lastState.references.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- this.references.put(keyTable[i], valueTable[i]);
-
- this.typeLocators = new SimpleLookupTable(lastState.typeLocators.elementSize);
- keyTable = lastState.typeLocators.keyTable;
- valueTable = lastState.typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- this.typeLocators.put(keyTable[i], valueTable[i]);
- }
-}
-
-char[][] getDefinedTypeNamesFor(String typeLocator) {
- Object c = references.get(typeLocator);
-// if (c instanceof AdditionalTypeCollection)
-// return ((AdditionalTypeCollection) c).definedTypeNames;
- return null; // means only one type is defined with the same name as the file... saves space
-}
-
-boolean isDuplicateLocator(String qualifiedTypeName, String typeLocator) {
- String existing = (String) typeLocators.get(qualifiedTypeName);
- return existing != null && !existing.equals(typeLocator);
-}
-
-boolean isKnownPackage(String qualifiedPackageName) {
- if (knownPackageNames == null) {
- ArrayList names = new ArrayList(typeLocators.elementSize);
- Object[] keyTable = typeLocators.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- String packageName = (String) keyTable[i]; // is a type name of the form p1/p2/A
- int last = packageName.lastIndexOf('/');
- packageName = last == -1 ? null : packageName.substring(0, last);
- while (packageName != null && !names.contains(packageName)) {
- names.add(packageName);
- last = packageName.lastIndexOf('/');
- packageName = last == -1 ? null : packageName.substring(0, last);
- }
- }
- }
- knownPackageNames = new String[names.size()];
- names.toArray(knownPackageNames);
- }
- for (int i = 0, l = knownPackageNames.length; i < l; i++)
- if (knownPackageNames[i].equals(qualifiedPackageName))
- return true;
- return false;
-}
-
-void record(String typeLocator, char[][][] qualifiedRefs, char[][] simpleRefs, char[] mainTypeName, ArrayList typeNames) {
-// if (typeNames.size() == 1 && CharOperation.equals(mainTypeName, (char[]) typeNames.get(0))) {
-// references.put(typeLocator, new ReferenceCollection(qualifiedRefs, simpleRefs));
-// } else {
-// char[][] definedTypeNames = new char[typeNames.size()][]; // can be empty when no types are defined
-// typeNames.toArray(definedTypeNames);
-// references.put(typeLocator, new AdditionalTypeCollection(definedTypeNames, qualifiedRefs, simpleRefs));
-// }
-}
-
-void recordLocatorForType(String qualifiedTypeName, String typeLocator) {
- this.knownPackageNames = null;
- typeLocators.put(qualifiedTypeName, typeLocator);
-}
-
-void recordStructuralDependency(IProject prereqProject, State prereqState) {
- if (prereqState != null)
- structuralBuildTimes.put(prereqProject.getName(), new Long(prereqState.lastStructuralBuildTime));
-}
-
-void removeLocator(String typeLocatorToRemove) {
- this.knownPackageNames = null;
- references.removeKey(typeLocatorToRemove);
- typeLocators.removeValue(typeLocatorToRemove);
-}
-
-void removePackage(IResourceDelta sourceDelta) {
- IResource resource = sourceDelta.getResource();
- switch(resource.getType()) {
- case IResource.FOLDER :
- IResourceDelta[] children = sourceDelta.getAffectedChildren();
- for (int i = 0, l = children.length; i < l; i++)
- removePackage(children[i]);
- return;
- case IResource.FILE :
- IPath typeLocatorPath = resource.getProjectRelativePath();
- if (Util.isJavaFileName(typeLocatorPath.lastSegment()))
- removeLocator(typeLocatorPath.toString());
- }
-}
-
-void removeQualifiedTypeName(String qualifiedTypeNameToRemove) {
- this.knownPackageNames = null;
- typeLocators.removeKey(qualifiedTypeNameToRemove);
-}
-
-static State read(IProject project, DataInputStream in) throws IOException {
-// if (JavaBuilder.DEBUG)
-// System.out.println("About to read state..."); //$NON-NLS-1$
- if (VERSION != in.readByte()) {
-// if (JavaBuilder.DEBUG)
-// System.out.println("Found non-compatible state version... answered null"); //$NON-NLS-1$
- return null;
- }
-
- State newState = new State();
- newState.javaProjectName = in.readUTF();
- if (!project.getName().equals(newState.javaProjectName)) {
-// if (JavaBuilder.DEBUG)
-// System.out.println("Project's name does not match... answered null"); //$NON-NLS-1$
- return null;
- }
- newState.buildNumber = in.readInt();
- newState.lastStructuralBuildTime = in.readLong();
-
- int length = in.readInt();
- newState.sourceLocations = new ClasspathMultiDirectory[length];
- for (int i = 0; i < length; i++) {
- IContainer sourceFolder = project, outputFolder = project;
- String folderName;
- if ((folderName = in.readUTF()).length() > 0) sourceFolder = project.getFolder(folderName);
- if ((folderName = in.readUTF()).length() > 0) outputFolder = project.getFolder(folderName);
- ClasspathMultiDirectory md =
- (ClasspathMultiDirectory) ClasspathLocation.forSourceFolder(sourceFolder, outputFolder, readNames(in));
- if (in.readBoolean())
- md.hasIndependentOutputFolder = true;
- newState.sourceLocations[i] = md;
- }
-
- length = in.readInt();
- newState.binaryLocations = new ClasspathLocation[length];
- IWorkspaceRoot root = project.getWorkspace().getRoot();
- for (int i = 0; i < length; i++) {
- switch (in.readByte()) {
- case SOURCE_FOLDER :
- newState.binaryLocations[i] = newState.sourceLocations[in.readInt()];
- break;
- case BINARY_FOLDER :
- IPath path = new Path(in.readUTF());
- IContainer outputFolder = path.segmentCount() == 1
- ? (IContainer) root.getProject(path.toString())
- : (IContainer) root.getFolder(path);
- newState.binaryLocations[i] = ClasspathLocation.forBinaryFolder(outputFolder, in.readBoolean());
- break;
-// case EXTERNAL_JAR :
-// newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF());
-// break;
-// case INTERNAL_JAR :
-// newState.binaryLocations[i] = ClasspathLocation.forLibrary(root.getFile(new Path(in.readUTF())));
- }
- }
-
- newState.structuralBuildTimes = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++)
- newState.structuralBuildTimes.put(in.readUTF(), new Long(in.readLong()));
-
- String[] internedTypeLocators = new String[length = in.readInt()];
- for (int i = 0; i < length; i++)
- internedTypeLocators[i] = in.readUTF();
-
- newState.typeLocators = new SimpleLookupTable(length = in.readInt());
- for (int i = 0; i < length; i++)
- newState.typeLocators.put(in.readUTF(), internedTypeLocators[in.readInt()]);
-
-// char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(readNames(in), false);
-// char[][][] internedQualifiedNames = new char[length = in.readInt()][][];
-// for (int i = 0; i < length; i++) {
-// int qLength = in.readInt();
-// char[][] qName = new char[qLength][];
-// for (int j = 0; j < qLength; j++)
-// qName[j] = internedSimpleNames[in.readInt()];
-// internedQualifiedNames[i] = qName;
-// }
-// internedQualifiedNames = ReferenceCollection.internQualifiedNames(internedQualifiedNames);
-
-// newState.references = new SimpleLookupTable(length = in.readInt());
-// for (int i = 0; i < length; i++) {
-// String typeLocator = internedTypeLocators[in.readInt()];
-// ReferenceCollection collection = null;
-// switch (in.readByte()) {
-// case 1 :
-// char[][] additionalTypeNames = readNames(in);
-// char[][][] qualifiedNames = new char[in.readInt()][][];
-// for (int j = 0, m = qualifiedNames.length; j < m; j++)
-// qualifiedNames[j] = internedQualifiedNames[in.readInt()];
-// char[][] simpleNames = new char[in.readInt()][];
-// for (int j = 0, m = simpleNames.length; j < m; j++)
-// simpleNames[j] = internedSimpleNames[in.readInt()];
-// collection = new AdditionalTypeCollection(additionalTypeNames, qualifiedNames, simpleNames);
-// break;
-// case 2 :
-// char[][][] qNames = new char[in.readInt()][][];
-// for (int j = 0, m = qNames.length; j < m; j++)
-// qNames[j] = internedQualifiedNames[in.readInt()];
-// char[][] sNames = new char[in.readInt()][];
-// for (int j = 0, m = sNames.length; j < m; j++)
-// sNames[j] = internedSimpleNames[in.readInt()];
-// collection = new ReferenceCollection(qNames, sNames);
-// }
-// newState.references.put(typeLocator, collection);
-// }
-// if (JavaBuilder.DEBUG)
-// System.out.println("Successfully read state for " + newState.javaProjectName); //$NON-NLS-1$
- return newState;
-}
-
-private static char[][] readNames(DataInputStream in) throws IOException {
- int length = in.readInt();
- char[][] names = new char[length][];
- for (int i = 0; i < length; i++) {
- int nLength = in.readInt();
- char[] name = new char[nLength];
- for (int j = 0; j < nLength; j++)
- name[j] = in.readChar();
- names[i] = name;
- }
- return names;
-}
-
-void tagAsNoopBuild() {
- this.buildNumber = -1; // tag the project since it has no source folders and can be skipped
-}
-
-boolean wasNoopBuild() {
- return buildNumber == -1;
-}
-
-void tagAsStructurallyChanged() {
- this.lastStructuralBuildTime = System.currentTimeMillis();
-}
-
-boolean wasStructurallyChanged(IProject prereqProject, State prereqState) {
- if (prereqState != null) {
- Object o = structuralBuildTimes.get(prereqProject.getName());
- long previous = o == null ? 0 : ((Long) o).longValue();
- if (previous == prereqState.lastStructuralBuildTime) return false;
- }
- return true;
-}
-
-void write(DataOutputStream out) throws IOException {
- int length;
- Object[] keyTable;
- Object[] valueTable;
-
-/*
- * byte VERSION
- * String project name
- * int build number
- * int last structural build number
-*/
- out.writeByte(VERSION);
- out.writeUTF(javaProjectName);
- out.writeInt(buildNumber);
- out.writeLong(lastStructuralBuildTime);
-
-/*
- * ClasspathMultiDirectory[]
- * int id
- * String path(s)
-*/
- out.writeInt(length = sourceLocations.length);
- for (int i = 0; i < length; i++) {
- ClasspathMultiDirectory md = sourceLocations[i];
- out.writeUTF(md.sourceFolder.getProjectRelativePath().toString());
- out.writeUTF(md.binaryFolder.getProjectRelativePath().toString());
- writeNames(md.exclusionPatterns, out);
- out.writeBoolean(md.hasIndependentOutputFolder);
- }
-
-/*
- * ClasspathLocation[]
- * int id
- * String path(s)
-*/
- out.writeInt(length = binaryLocations.length);
- next : for (int i = 0; i < length; i++) {
- ClasspathLocation c = binaryLocations[i];
- if (c instanceof ClasspathMultiDirectory) {
- out.writeByte(SOURCE_FOLDER);
- for (int j = 0, m = sourceLocations.length; j < m; j++) {
- if (sourceLocations[j] == c) {
- out.writeInt(j);
- continue next;
- }
- }
- } else if (c instanceof ClasspathDirectory) {
- out.writeByte(BINARY_FOLDER);
- ClasspathDirectory cd = (ClasspathDirectory) c;
- out.writeUTF(cd.binaryFolder.getFullPath().toString());
- out.writeBoolean(cd.isOutputFolder);
- } else {
-// ClasspathJar jar = (ClasspathJar) c;
-// if (jar.resource == null) {
-// out.writeByte(EXTERNAL_JAR);
-// out.writeUTF(jar.zipFilename);
-// } else {
-// out.writeByte(INTERNAL_JAR);
-// out.writeUTF(jar.resource.getFullPath().toString());
-// }
- }
- }
-
-/*
- * Structural build numbers table
- * String prereq project name
- * int last structural build number
-*/
- out.writeInt(length = structuralBuildTimes.elementSize);
- if (length > 0) {
- keyTable = structuralBuildTimes.keyTable;
- valueTable = structuralBuildTimes.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- out.writeUTF((String) keyTable[i]);
- out.writeLong(((Long) valueTable[i]).longValue());
- }
- }
-// if (JavaBuilder.DEBUG && length != 0)
-// System.out.println("structuralBuildNumbers table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * String[] Interned type locators
- */
- out.writeInt(length = references.elementSize);
- ArrayList internedTypeLocators = new ArrayList(length);
- if (length > 0) {
- keyTable = references.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- String key = (String) keyTable[i];
- out.writeUTF(key);
- internedTypeLocators.add(key);
- }
- }
-// if (JavaBuilder.DEBUG && length != 0)
-// System.out.println("references table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * Type locators table
- * String type name
- * int interned locator id
- */
- out.writeInt(length = typeLocators.elementSize);
- if (length > 0) {
- keyTable = typeLocators.keyTable;
- valueTable = typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- length--;
- out.writeUTF((String) keyTable[i]);
- out.writeInt(internedTypeLocators.indexOf((String) valueTable[i]));
- }
- }
-// if (JavaBuilder.DEBUG && length != 0)
-// System.out.println("typeLocators table is inconsistent"); //$NON-NLS-1$
- }
-
-/*
- * char[][][] Interned qualified names
- * char[][] Interned simple names
- */
- ArrayList internedQualifiedNames = new ArrayList(31);
- ArrayList internedSimpleNames = new ArrayList(31);
- valueTable = references.valueTable;
- for (int i = 0, l = valueTable.length; i < l; i++) {
-// if (valueTable[i] != null) {
-// ReferenceCollection collection = (ReferenceCollection) valueTable[i];
-// char[][][] qNames = collection.qualifiedNameReferences;
-// for (int j = 0, m = qNames.length; j < m; j++) {
-// char[][] qName = qNames[j];
-// if (!internedQualifiedNames.contains(qName)) { // remember the names have been interned
-// internedQualifiedNames.add(qName);
-// for (int k = 0, n = qName.length; k < n; k++) {
-// char[] sName = qName[k];
-// if (!internedSimpleNames.contains(sName)) // remember the names have been interned
-// internedSimpleNames.add(sName);
-// }
-// }
-// }
-// char[][] sNames = collection.simpleNameReferences;
-// for (int j = 0, m = sNames.length; j < m; j++) {
-// char[] sName = sNames[j];
-// if (!internedSimpleNames.contains(sName)) // remember the names have been interned
-// internedSimpleNames.add(sName);
-// }
-// }
- }
- char[][] internedArray = new char[internedSimpleNames.size()][];
- internedSimpleNames.toArray(internedArray);
- writeNames(internedArray, out);
- // now write the interned qualified names as arrays of interned simple names
- out.writeInt(length = internedQualifiedNames.size());
- for (int i = 0; i < length; i++) {
- char[][] qName = (char[][]) internedQualifiedNames.get(i);
- int qLength = qName.length;
- out.writeInt(qLength);
- for (int j = 0; j < qLength; j++)
- out.writeInt(internedSimpleNames.indexOf(qName[j]));
- }
-
-/*
- * References table
- * int interned locator id
- * ReferenceCollection
-*/
- out.writeInt(length = references.elementSize);
- if (length > 0) {
- keyTable = references.keyTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
-// if (keyTable[i] != null) {
-// length--;
-// out.writeInt(internedTypeLocators.indexOf((String) keyTable[i]));
-// ReferenceCollection collection = (ReferenceCollection) valueTable[i];
-// if (collection instanceof AdditionalTypeCollection) {
-// out.writeByte(1);
-// AdditionalTypeCollection atc = (AdditionalTypeCollection) collection;
-// writeNames(atc.definedTypeNames, out);
-// } else {
-// out.writeByte(2);
-// }
-// char[][][] qNames = collection.qualifiedNameReferences;
-// int qLength = qNames.length;
-// out.writeInt(qLength);
-// for (int j = 0; j < qLength; j++)
-// out.writeInt(internedQualifiedNames.indexOf(qNames[j]));
-// char[][] sNames = collection.simpleNameReferences;
-// int sLength = sNames.length;
-// out.writeInt(sLength);
-// for (int j = 0; j < sLength; j++)
-// out.writeInt(internedSimpleNames.indexOf(sNames[j]));
-// }
- }
-// if (JavaBuilder.DEBUG && length != 0)
-// System.out.println("references table is inconsistent"); //$NON-NLS-1$
- }
-}
-
-private void writeNames(char[][] names, DataOutputStream out) throws IOException {
- int length = names == null ? 0 : names.length;
- out.writeInt(length);
- for (int i = 0; i < length; i++) {
- char[] name = names[i];
- int nLength = name.length;
- out.writeInt(nLength);
- for (int j = 0; j < nLength; j++)
- out.writeChar(name[j]);
- }
-}
-
-/**
- * Returns a string representation of the receiver.
- */
-public String toString() {
- return "State for " + javaProjectName //$NON-NLS-1$
- + " (#" + buildNumber //$NON-NLS-1$
- + " @ " + new Date(lastStructuralBuildTime) //$NON-NLS-1$
- + ")"; //$NON-NLS-1$
-}
-
-/* Debug helper
-void dump() {
- System.out.println("State for " + javaProjectName + " (" + buildNumber + " @ " + new Date(lastStructuralBuildTime) + ")");
- System.out.println("\tClass path source locations:");
- for (int i = 0, l = sourceLocations.length; i < l; i++)
- System.out.println("\t\t" + sourceLocations[i]);
- System.out.println("\tClass path binary locations:");
- for (int i = 0, l = binaryLocations.length; i < l; i++)
- System.out.println("\t\t" + binaryLocations[i]);
-
- System.out.print("\tStructural build numbers table:");
- if (structuralBuildTimes.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = structuralBuildTimes.keyTable;
- Object[] valueTable = structuralBuildTimes.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
- }
-
- System.out.print("\tType locators table:");
- if (typeLocators.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = typeLocators.keyTable;
- Object[] valueTable = typeLocators.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++)
- if (keyTable[i] != null)
- System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
- }
-
- System.out.print("\n\tReferences table:");
- if (references.elementSize == 0) {
- System.out.print(" <empty>");
- } else {
- Object[] keyTable = references.keyTable;
- Object[] valueTable = references.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
- if (keyTable[i] != null) {
- System.out.print("\n\t\t" + keyTable[i].toString());
- ReferenceCollection c = (ReferenceCollection) valueTable[i];
- char[][][] qRefs = c.qualifiedNameReferences;
- System.out.print("\n\t\t\tqualified:");
- if (qRefs.length == 0)
- System.out.print(" <empty>");
- else for (int j = 0, m = qRefs.length; j < m; j++)
- System.out.print(" '" + CharOperation.toString(qRefs[j]) + "'");
- char[][] sRefs = c.simpleNameReferences;
- System.out.print("\n\t\t\tsimple:");
- if (sRefs.length == 0)
- System.out.print(" <empty>");
- else for (int j = 0, m = sRefs.length; j < m; j++)
- System.out.print(" " + new String(sRefs[j]));
- if (c instanceof AdditionalTypeCollection) {
- char[][] names = ((AdditionalTypeCollection) c).definedTypeNames;
- System.out.print("\n\t\t\tadditional type names:");
- for (int j = 0, m = names.length; j < m; j++)
- System.out.print(" " + new String(names[j]));
- }
- }
- }
- }
- System.out.print("\n\n");
-}
-*/
-}
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
}
private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
- if (file != null) {
- IWorkbenchPage p= PHPeclipsePlugin.getActivePage();
- if (p != null) {
- IEditorPart editorPart= p.openEditor(file, null, activate);
- initializeHighlightRange(editorPart);
- return editorPart;
- }
- }
- return null;
+ if (file != null) {
+ IWorkbenchPage p= PHPeclipsePlugin.getActivePage();
+ if (p != null) {
+ IEditorPart editorPart= IDE.openEditor(p, file, activate);
+ initializeHighlightRange(editorPart);
+ return editorPart;
+ }
+ }
+ return null;
}
private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
* @return <code>true</code> if it is a problem annotation
*/
boolean isProblem();
-}
+}
\ No newline at end of file
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.internal.ui.PHPUiImages;
import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
+import net.sourceforge.phpdt.internal.ui.dnd.JdtViewerDragAdapter;
+import net.sourceforge.phpdt.internal.ui.dnd.TransferDragSourceListener;
import net.sourceforge.phpdt.internal.ui.packageview.SelectionTransferDragAdapter;
import net.sourceforge.phpdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import net.sourceforge.phpdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
-import net.sourceforge.phpdt.internal.ui.dnd.JdtViewerDragAdapter;
-import net.sourceforge.phpdt.internal.ui.dnd.TransferDragSourceListener;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.internal.model.WorkbenchAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.WorkbenchAdapter;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.editors.text.FileDocumentProvider;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
+import org.eclipse.ui.texteditor.DefaultAnnotation;
+import org.eclipse.ui.texteditor.IAnnotationExtension;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
/*
* @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
*/
- protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) {
+ protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
super.addAnnotation(annotation, position, fireModelChanged);
Object cached = fReverseMap.get(position);
return new Position(start, length);
}
-
/*
* @see IProblemRequestor#endReporting()
*/
public void endReporting() {
if (!isActive())
return;
-
+
if (fProgressMonitor != null && fProgressMonitor.isCanceled())
return;
-
- boolean isCanceled = false;
- boolean temporaryProblemsChanged = false;
- fPreviouslyOverlaid = fCurrentlyOverlaid;
- fCurrentlyOverlaid = new ArrayList();
-
+
+
+ boolean isCanceled= false;
+ boolean temporaryProblemsChanged= false;
+
synchronized (fAnnotations) {
+
+ fPreviouslyOverlaid= fCurrentlyOverlaid;
+ fCurrentlyOverlaid= new ArrayList();
if (fGeneratedAnnotations.size() > 0) {
- temporaryProblemsChanged = true;
+ temporaryProblemsChanged= true;
removeAnnotations(fGeneratedAnnotations, false, true);
fGeneratedAnnotations.clear();
}
-
+
if (fCollectedProblems != null && fCollectedProblems.size() > 0) {
-
- Iterator e = fCollectedProblems.iterator();
+
+ ICompilationUnit cu= getWorkingCopy(fInput);
+ Iterator e= fCollectedProblems.iterator();
while (e.hasNext()) {
-
- IProblem problem = (IProblem) e.next();
-
+
+ IProblem problem= (IProblem) e.next();
+
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
- isCanceled = true;
+ isCanceled= true;
break;
}
-
- Position position = createPositionFromProblem(problem);
+
+ Position position= createPositionFromProblem(problem);
if (position != null) {
-
- ProblemAnnotation annotation = new ProblemAnnotation(problem);
- overlayMarkers(position, annotation);
- fGeneratedAnnotations.add(annotation);
- addAnnotation(annotation, position, false);
-
- temporaryProblemsChanged = true;
+ try {
+ ProblemAnnotation annotation= new ProblemAnnotation(problem, cu);
+ addAnnotation(annotation, position, false);
+ overlayMarkers(position, annotation);
+ fGeneratedAnnotations.add(annotation);
+
+ temporaryProblemsChanged= true;
+ } catch (BadLocationException x) {
+ // ignore invalid position
+ }
}
}
-
+
fCollectedProblems.clear();
}
-
+
removeMarkerOverlays(isCanceled);
fPreviouslyOverlaid.clear();
- fPreviouslyOverlaid = null;
+ fPreviouslyOverlaid= null;
}
-
+
if (temporaryProblemsChanged)
- fireModelChanged(new CompilationUnitAnnotationModelEvent(this, getResource(), false));
+ fireModelChanged();
}
+ /*
+ * @see IProblemRequestor#endReporting()
+ */
+// public void endReporting() {
+// if (!isActive())
+// return;
+//
+// if (fProgressMonitor != null && fProgressMonitor.isCanceled())
+// return;
+//
+// boolean isCanceled = false;
+// boolean temporaryProblemsChanged = false;
+// fPreviouslyOverlaid = fCurrentlyOverlaid;
+// fCurrentlyOverlaid = new ArrayList();
+//
+// synchronized (fAnnotations) {
+//
+// if (fGeneratedAnnotations.size() > 0) {
+// temporaryProblemsChanged = true;
+// removeAnnotations(fGeneratedAnnotations, false, true);
+// fGeneratedAnnotations.clear();
+// }
+//
+// if (fCollectedProblems != null && fCollectedProblems.size() > 0) {
+//
+// Iterator e = fCollectedProblems.iterator();
+// while (e.hasNext()) {
+//
+// IProblem problem = (IProblem) e.next();
+//
+// if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
+// isCanceled = true;
+// break;
+// }
+//
+// Position position = createPositionFromProblem(problem);
+// if (position != null) {
+//
+// ProblemAnnotation annotation = new ProblemAnnotation(problem);
+// overlayMarkers(position, annotation);
+// fGeneratedAnnotations.add(annotation);
+// addAnnotation(annotation, position, false);
+//
+// temporaryProblemsChanged = true;
+// }
+// }
+//
+// fCollectedProblems.clear();
+// }
+//
+// removeMarkerOverlays(isCanceled);
+// fPreviouslyOverlaid.clear();
+// fPreviouslyOverlaid = null;
+// }
+//
+// if (temporaryProblemsChanged)
+// fireModelChanged(new CompilationUnitAnnotationModelEvent(this, getResource(), false));
+// }
private Object getAnnotations(Position position) {
return fReverseMap.get(position);
/**
* Annotation representating an <code>IProblem</code>.
*/
- static protected class ProblemAnnotation extends Annotation implements IJavaAnnotation {
+ static protected class ProblemAnnotation extends Annotation implements IJavaAnnotation, IAnnotationExtension{
+ private static final String TASK_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
+ private static final String ERROR_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.error"; //$NON-NLS-1$
+ private static final String WARNING_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.warning"; //$NON-NLS-1$
+ private static final String INFO_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.info"; //$NON-NLS-1$
+
// private static Image fgQuickFixImage;
// private static Image fgQuickFixErrorImage;
// private static boolean fgQuickFixImagesInitialized = false;
+ private ICompilationUnit fCompilationUnit;
private List fOverlaids;
private IProblem fProblem;
private Image fImage;
// private boolean fQuickFixImagesInitialized = false;
- private AnnotationType fType;
-
- public ProblemAnnotation(IProblem problem) {
-
- fProblem = problem;
- setLayer(MarkerAnnotation.PROBLEM_LAYER + 1);
-
- if (IProblem.Task == fProblem.getID())
- fType = AnnotationType.TASK;
- else if (fProblem.isWarning())
- fType = AnnotationType.WARNING;
- else
- fType = AnnotationType.ERROR;
+// private AnnotationType fType;
+ private String fType;
+
+ public ProblemAnnotation(IProblem problem, ICompilationUnit cu) {
+ fProblem= problem;
+ fCompilationUnit= cu;
+
+ if (IProblem.Task == fProblem.getID()) {
+ fType= TASK_ANNOTATION_TYPE;
+ setLayer(DefaultAnnotation.TASK_LAYER + 1);
+ } else if (fProblem.isWarning()) {
+ fType= WARNING_ANNOTATION_TYPE;
+ setLayer(DefaultAnnotation.WARNING_LAYER + 1);
+ } else if (fProblem.isError()) {
+ fType= ERROR_ANNOTATION_TYPE;
+ setLayer(DefaultAnnotation.ERROR_LAYER + 1);
+ } else {
+ fType= INFO_ANNOTATION_TYPE;
+ setLayer(DefaultAnnotation.INFO_LAYER + 1);
+ }
}
+// public ProblemAnnotation(IProblem problem) {
+//
+// fProblem = problem;
+// setLayer(MarkerAnnotation.PROBLEM_LAYER + 1);
+//
+// if (IProblem.Task == fProblem.getID())
+// fType = AnnotationType.TASK;
+// else if (fProblem.isWarning())
+// fType = AnnotationType.WARNING;
+// else
+// fType = AnnotationType.ERROR;
+// }
private void initializeImages() {
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=18936
return isProblem() ? fProblem.getID() : -1;
}
+// /*
+// * @see IJavaAnnotation#isProblem()
+// */
+// public boolean isProblem() {
+// return fType == AnnotationType.WARNING || fType == AnnotationType.ERROR;
+// }
/*
* @see IJavaAnnotation#isProblem()
*/
public boolean isProblem() {
- return fType == AnnotationType.WARNING || fType == AnnotationType.ERROR;
+ return WARNING_ANNOTATION_TYPE.equals(fType) || ERROR_ANNOTATION_TYPE.equals(fType);
}
/*
return null;
}
+
public AnnotationType getAnnotationType() {
- return fType;
+ if (ERROR_ANNOTATION_TYPE.equals(fType)) {
+ return AnnotationType.ERROR;
+ }
+ if (WARNING_ANNOTATION_TYPE.equals(fType)) {
+ return AnnotationType.WARNING;
+ }
+ if (TASK_ANNOTATION_TYPE.equals(fType)) {
+ return AnnotationType.TASK;
+ }
+// if (INFO_ANNOTATION_TYPE.equals(fType)) {
+// return AnnotationType.INFO;
+// }
+ return AnnotationType.UNKNOWN;
+ }
+
+ /*
+ * @see IAnnotationExtension#getMarkerType()
+ */
+ public String getMarkerType() {
+ if (isProblem() || INFO_ANNOTATION_TYPE.equals(fType))
+ return IMarker.PROBLEM;
+ else
+ return IMarker.TASK;
+ }
+ /*
+ * @see IAnnotationExtension#getSeverity()
+ */
+ public int getSeverity() {
+ if (ERROR_ANNOTATION_TYPE.equals(fType))
+ return IMarker.SEVERITY_ERROR;
+ if (WARNING_ANNOTATION_TYPE.equals(fType))
+ return IMarker.SEVERITY_WARNING;
+ return IMarker.SEVERITY_INFO;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#getCompilationUnit()
+ */
+ public ICompilationUnit getCompilationUnit() {
+ return fCompilationUnit;
}
};
/**
}
/*
- * @see AbstractDocumentProvider#resetDocument(Object)
+ * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doResetDocument(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
*/
- public void resetDocument(Object element) throws CoreException {
+ protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException {
if (element == null)
return;
-
- ElementInfo elementInfo = getElementInfo(element);
+
+ ElementInfo elementInfo= getElementInfo(element);
if (elementInfo instanceof CompilationUnitInfo) {
- CompilationUnitInfo info = (CompilationUnitInfo) elementInfo;
-
+ CompilationUnitInfo info= (CompilationUnitInfo) elementInfo;
+
IDocument document;
- IStatus status = null;
-
+ IStatus status= null;
+
try {
-
- ICompilationUnit original = (ICompilationUnit) info.fCopy.getOriginalElement();
- IResource resource = original.getResource();
+
+ ICompilationUnit original= (ICompilationUnit) info.fCopy.getOriginalElement();
+ IResource resource= original.getResource();
if (resource instanceof IFile) {
-
- IFile file = (IFile) resource;
-
+
+ IFile file= (IFile) resource;
+
try {
- refreshFile(file);
+ refreshFile(file, monitor);
} catch (CoreException x) {
- handleCoreException(x, PHPEditorMessages.getString("PHPDocumentProvider.error.resetDocument")); //$NON-NLS-1$
+ handleCoreException(x, PHPEditorMessages.getString("CompilationUnitDocumentProvider.error.resetDocument")); //$NON-NLS-1$
}
-
- IFileEditorInput input = new FileEditorInput(file);
- document = super.createDocument(input);
-
+
+ IFileEditorInput input= new FileEditorInput(file);
+ document= super.createDocument(input);
+
} else {
- document = new Document();
+ document= createEmptyDocument();
}
-
+
} catch (CoreException x) {
- document = new Document();
- status = x.getStatus();
+ document= createEmptyDocument();
+ status= x.getStatus();
}
-
+
fireElementContentAboutToBeReplaced(element);
-
+
removeUnchangedElementListeners(element, info);
info.fDocument.set(document.get());
- info.fCanBeSaved = false;
- info.fStatus = status;
+ info.fCanBeSaved= false;
+ info.fStatus= status;
addUnchangedElementListeners(element, info);
-
+
fireElementContentReplaced(element);
fireElementDirtyStateChanged(element, false);
-
+
} else {
- super.resetDocument(element);
+ super.doResetDocument(element, monitor);
}
}
+
+ /*
+ * @see AbstractDocumentProvider#resetDocument(Object)
+ */
+// public void resetDocument(Object element) throws CoreException {
+// if (element == null)
+// return;
+//
+// ElementInfo elementInfo = getElementInfo(element);
+// if (elementInfo instanceof CompilationUnitInfo) {
+// CompilationUnitInfo info = (CompilationUnitInfo) elementInfo;
+//
+// IDocument document;
+// IStatus status = null;
+//
+// try {
+//
+// ICompilationUnit original = (ICompilationUnit) info.fCopy.getOriginalElement();
+// IResource resource = original.getResource();
+// if (resource instanceof IFile) {
+//
+// IFile file = (IFile) resource;
+//
+// try {
+// refreshFile(file);
+// } catch (CoreException x) {
+// handleCoreException(x, PHPEditorMessages.getString("PHPDocumentProvider.error.resetDocument")); //$NON-NLS-1$
+// }
+//
+// IFileEditorInput input = new FileEditorInput(file);
+// document = super.createDocument(input);
+//
+// } else {
+// document = new Document();
+// }
+//
+// } catch (CoreException x) {
+// document = new Document();
+// status = x.getStatus();
+// }
+//
+// fireElementContentAboutToBeReplaced(element);
+//
+// removeUnchangedElementListeners(element, info);
+// info.fDocument.set(document.get());
+// info.fCanBeSaved = false;
+// info.fStatus = status;
+// addUnchangedElementListeners(element, info);
+//
+// fireElementContentReplaced(element);
+// fireElementDirtyStateChanged(element, false);
+//
+// } else {
+// super.resetDocument(element);
+// }
+// }
/**
* Saves the content of the given document to the given element.
* This is only performed when this provider initiated the save.
import java.util.List;
import net.sourceforge.phpdt.internal.compiler.util.Util;
+import net.sourceforge.phpdt.internal.core.builder.PHPBuilder;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.builder.PHPBuilder;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IEditorInput;
+++ /dev/null
-package net.sourceforge.phpeclipse.phpeditor;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.builder.PHPBuilder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.editors.text.TextEditor;
-
-import test.PHPParserManager;
-import test.PHPParserSuperclass;
-
-
-public class PHPSyntaxParserThread extends Thread {
- private static String[] EXTENSIONS = { ".php", ".php3", ".php4", ".inc", ".phtml" };
-
- private String text = "";
- private String previousText = "";
-
- private boolean stopValidation = false;
- private boolean validationTerminated = false;
- private boolean isActive = false;
-
- private TextEditor fTextEditor;
- private ISourceViewer fSourceViewer;
-
- private int previousHashCode = 0;
- // Defaults
- private int validationInterval = 2000; //millis
- private int waitForTermination = 400; // millis
- private int maxErrorsShown = 10;
-
- public PHPSyntaxParserThread(
- TextEditor textEditor,
- ISourceViewer viewer) {
- super();
- fTextEditor = textEditor;
- fSourceViewer = viewer;
- }
-
- public void setText(String text) {
- if (!isActive)
- this.text = text;
- }
-
- public void setText(String text, boolean forceUpdate) {
- if (!isActive) {
- this.text = text;
- }
-
- if (forceUpdate) {
- this.previousText = "";
- this.previousHashCode = 0;
- }
- }
-
- public String getText() {
- return text;
- }
-
- public void setInterval(int millis) {
- this.validationInterval = millis;
- }
-
- public int getInterval() {
- return validationInterval;
- }
-
- public void setErrorsShown(int number) {
- this.maxErrorsShown = number;
- }
-
- public int getErrorsShown() {
- return maxErrorsShown;
- }
-
- public void dispose() {
- this.stopValidation = true;
-
- if (validationTerminated == false) {
-
- try {
- Thread.sleep(waitForTermination);
- } catch (Exception e) {
- }
- }
- }
-
- public void run() {
- while (stopValidation == false) {
- try {
-
- this.isActive = true;
- boolean ret = this.validateSyntax();
-
- this.previousText = this.text;
- this.isActive = false;
-
- Thread.sleep(validationInterval);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- this.validationTerminated = true;
- }
-
- public boolean validateSyntax() {
-
- boolean phpFlag = false;
- try {
- IFile fileToParse = getPHPFile(fTextEditor.getEditorInput());
- if (fileToParse == null) {
- // should never happen
- System.err.println("Error : no file in the editor");
- // should throw an exception
- return false;
- }
- String name = fileToParse.getName();
- for (int i = 0; i<EXTENSIONS.length; i++) {
- if (name.endsWith(EXTENSIONS[i])) {
- phpFlag = true; // php file extension
- break;
- }
- }
- if (phpFlag) {
- IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
- if (store.getString(PHPeclipsePlugin.PHP_PARSER_DEFAULT).equals(PHPeclipsePlugin.PHP_INTERNAL_PARSER)) {
- // first delete all the previous markers
-// fileToParse.deleteMarkers(IMarker.PROBLEM, false, 0);
- PHPBuilder.removeProblemsAndTasksFor(fileToParse);
- try {
- InputStream iStream = fileToParse.getContents();
- // int c = iStream.read();
- parse(fileToParse, iStream);
- iStream.close();
- } catch (IOException e) {
- }
- } else {
- PHPParserSuperclass.phpExternalParse(fileToParse);
- }
- }
- } catch (CoreException e) {
- }
-
-
-//
-// Process proc = null;
-//
-// if (this.previousText.equals(this.text)) {
-// return true;
-// }
-//
-// try {
-// IEditorInput input = fTextEditor.getEditorInput();
-// IResource resource =
-// (IResource) ((IAdaptable) input).getAdapter(IResource.class);
-//
-// // Write output file
-// FileOutputStream fos = new FileOutputStream(new File(tmpFileName));
-// fos.write(text.getBytes());
-// fos.flush();
-// fos.close();
-//
-// proc =
-// Runtime.getRuntime().exec(
-// PerlEditorPlugin
-// .getDefault()
-// .getExecutablePreference()
-// .trim()
-// + " "
-// + "-I"
-// + ((IFileEditorInput) this.fTextEditor.getEditorInput())
-// .getFile()
-// .getLocation()
-// .makeAbsolute()
-// .removeLastSegments(1)
-// + " "
-// + PERL_CMD_EXT
-// + " "
-// + tmpFileName);
-//
-// InputStream in = proc.getErrorStream();
-//
-// StringBuffer content = new StringBuffer();
-//
-// byte[] buffer = new byte[1];
-//
-// int read;
-// while ((read = in.read(buffer)) > 0) {
-// content.append(new String(buffer));
-// }
-// in.close();
-//
-// //jjjjjjj
-// // DEBUG start
-// System.out.println("-----------------------------------------");
-// System.out.println(" OUTPUT");
-// System.out.println("-----------------------------------------");
-// System.out.println(content);
-// System.out.println("-----------------------------------------");
-// // DEBUG END
-//
-// String line = null;
-// List lines = new ArrayList();
-// int index;
-//
-// // Compare checksums
-// int hashCode = content.toString().hashCode();
-//
-// if (previousHashCode == hashCode) {
-//
-// return true;
-// }
-//
-// previousHashCode = hashCode;
-//
-// StringTokenizer st = new StringTokenizer(content.toString(), "\n");
-//
-// int lineCount = 0;
-//
-// while (st.hasMoreTokens()) {
-// line = st.nextToken();
-// if (line.indexOf("\r") != -1) {
-// line = line.substring(0, line.indexOf("\r"));
-// }
-//
-// lines.add(line);
-// if (++lineCount >= maxErrorsShown) {
-// break;
-// }
-//
-// }
-//
-// //Delete markers
-// resource.deleteMarkers(IMarker.PROBLEM, true, 1);
-//
-// // Markers have to be added in reverse order
-// // Otherwise lower line number will appear at the end of the list
-// for (int i = lines.size() - 1; i >= 0; i--) {
-// line = (String) lines.get(i);
-//
-// // If error message is not from temporary file, skip
-// if (line.indexOf(tmpFileName) == -1) {
-// continue;
-// }
-//
-// // Delete filename from error message
-// StringBuffer lineSb = new StringBuffer(line);
-// replace(lineSb, tmpFileName + " ", "", true);
-// line = lineSb.toString();
-//
-// if ((index = line.indexOf(PERL_ERROR_INDICATOR)) != -1) {
-//
-// // truncatedLIne is the stripped error-line up to the next " " after the line number if present
-// // To avoid cluttering with other "." and "," which might occur in the error message
-// String truncatedLine = line;
-// if (truncatedLine
-// .indexOf(" ", index + PERL_ERROR_INDICATOR.length() + 1)
-// != -1) {
-// truncatedLine =
-// truncatedLine.substring(
-// 0,
-// truncatedLine.indexOf(
-// " ",
-// index + PERL_ERROR_INDICATOR.length() + 1));
-// }
-//
-// int endIndex;
-// if ((endIndex = truncatedLine.indexOf(".", index)) == -1) {
-// endIndex = truncatedLine.indexOf(",", index);
-// }
-//
-// if (endIndex == -1) {
-// continue;
-// }
-//
-// String lineNr =
-// truncatedLine.substring(
-// index + PERL_ERROR_INDICATOR.length(),
-// endIndex);
-//
-// // If there is an addition to the error message
-// if (i + 1 < lines.size()) {
-// if (((String) lines.get(i + 1)).startsWith(" ")) {
-// line += " " + (String) lines.get(i + 1);
-// }
-// }
-//
-// IMarker marker = resource.createMarker(IMarker.PROBLEM);
-//
-// // Check if it's a warning
-// boolean isWarning = false;
-//
-// for (int x = 0; x < WARNING_STRINGS.length; x++) {
-// if (truncatedLine.indexOf(WARNING_STRINGS[x]) != -1) {
-// isWarning = true;
-// }
-// }
-//
-// if (isWarning) {
-// marker.setAttribute(
-// IMarker.SEVERITY,
-// IMarker.SEVERITY_WARNING);
-// } else {
-// marker.setAttribute(
-// IMarker.SEVERITY,
-// IMarker.SEVERITY_ERROR);
-// }
-//
-// marker.setAttribute(IMarker.MESSAGE, line);
-//
-// marker.setAttribute(
-// IMarker.LINE_NUMBER,
-// Integer.parseInt(lineNr));
-//
-// Position pos =
-// new Position(
-// fSourceViewer.getDocument().getLineOffset(
-// Integer.parseInt(lineNr) - 1));
-// fSourceViewer.getAnnotationModel().addAnnotation(
-// new MarkerAnnotation(marker),
-// pos);
-//
-// }
-// }
-//
-// } catch (Exception e) {
-// e.printStackTrace();
-// if (proc != null) {
-// killProcess(proc);
-// }
-// return false;
-// } finally {
-// try {
-// // Delete tmp file
-// new File(tmpFileName).delete();
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// }
-// }
-
- return true;
-
- }
-
- /**
- * Finds the file that's currently opened in the PHP Text Editor
- */
- protected IFile getPHPFile(IEditorInput editorInput) {
- if (editorInput instanceof IFileEditorInput)
- return ((IFileEditorInput) editorInput).getFile();
-
- return null;
- }
-
- protected void parse(IFile fileToParse, InputStream iStream) {
-
- StringBuffer buf = new StringBuffer();
- int c0;
- try {
- while ((c0 = iStream.read()) != (-1)) {
- buf.append((char) c0);
- }
- } catch (IOException e) {
- return;
- }
- String input = buf.toString();
-
- PHPParserSuperclass parser = PHPParserManager.getParser(fileToParse);
- try {
- parser.parse(input);
- } catch (CoreException e) {
- }
- }
-
- private void killProcess(Process proc) {
- while (true) {
- try {
- proc.destroy();
- proc.exitValue();
- } catch (Exception ex) {
-
- continue;
- }
- break;
- }
- }
-
- // Replaces all instances of the String o with the String n in the
- // StringBuffer orig if all is true, or only the first instance if all is false.
- private static void replace(
- StringBuffer orig,
- String o,
- String n,
- boolean all) {
- if (orig == null || o == null || o.length() == 0 || n == null)
- throw new IllegalArgumentException("Null or zero-length String");
-
- int i = 0;
-
- while (i + o.length() <= orig.length()) {
- if (orig.substring(i, i + o.length()).equals(o)) {
- orig.replace(i, i + o.length(), n);
- if (!all)
- break;
- else
- i += n.length();
- } else
- i++;
- }
- }
-}
/*
* @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation, IProgressMonitor)
*/
- protected void performSaveOperation(WorkspaceModifyOperation operation, IProgressMonitor progressMonitor) {
- IDocumentProvider p = getDocumentProvider();
+// protected void performSaveOperation(WorkspaceModifyOperation operation, IProgressMonitor progressMonitor) {
+// IDocumentProvider p = getDocumentProvider();
+// if (p instanceof PHPDocumentProvider) {
+// PHPDocumentProvider cp = (PHPDocumentProvider) p;
+// cp.setSavePolicy(fSavePolicy);
+// }
+//
+// try {
+// super.performSaveOperation(operation, progressMonitor);
+// } finally {
+// if (p instanceof PHPDocumentProvider) {
+// PHPDocumentProvider cp = (PHPDocumentProvider) p;
+// cp.setSavePolicy(null);
+// }
+// }
+// }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
+ IDocumentProvider p= getDocumentProvider();
if (p instanceof PHPDocumentProvider) {
- PHPDocumentProvider cp = (PHPDocumentProvider) p;
+ PHPDocumentProvider cp= (PHPDocumentProvider) p;
cp.setSavePolicy(fSavePolicy);
}
-
try {
- super.performSaveOperation(operation, progressMonitor);
+ super.performSave(overwrite, progressMonitor);
} finally {
if (p instanceof PHPDocumentProvider) {
- PHPDocumentProvider cp = (PHPDocumentProvider) p;
+ PHPDocumentProvider cp= (PHPDocumentProvider) p;
cp.setSavePolicy(null);
}
}
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.update.internal.ui.UpdatePerspective;
-import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
+//import org.eclipse.update.internal.ui.UpdatePerspective;
+//import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser;
/**
* ClassDeclaration that defines the action for parsing the current PHP file
return;
}
- if (SWT.getPlatform().equals("win32")) {
- String localhostURL;
- if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, fileToParse)) == null) {
- return;
- }
- IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
- try {
- IViewPart part = page.findView(UpdatePerspective.ID_BROWSER);
- if (part == null) {
- part = page.showView(UpdatePerspective.ID_BROWSER);
- } else
- page.bringToTop(part);
- ((IEmbeddedWebBrowser) part).openTo(localhostURL);
- } catch (PartInitException e) {
- PHPeclipsePlugin.log(e);
- }
- }
+// if (SWT.getPlatform().equals("win32")) {
+// String localhostURL;
+// if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, fileToParse)) == null) {
+// return;
+// }
+// IWorkbenchPage page = PHPeclipsePlugin.getActivePage();
+// try {
+// IViewPart part = page.findView(UpdatePerspective.ID_BROWSER);
+// if (part == null) {
+// part = page.showView(UpdatePerspective.ID_BROWSER);
+// } else
+// page.bringToTop(part);
+// ((IEmbeddedWebBrowser) part).openTo(localhostURL);
+// } catch (PartInitException e) {
+// PHPeclipsePlugin.log(e);
+// }
+// }
}
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
/**
* This wizard creates one file with the extension
public void run() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
- page.openEditor(file);
+ IDE.openEditor(page,file,true);
} catch (PartInitException e) {
}
}
import net.sourceforge.phpdt.core.IJavaModelMarker;
import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo;
+import net.sourceforge.phpdt.internal.core.builder.PHPBuilder;
import net.sourceforge.phpdt.internal.ui.util.StringUtil;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
-import net.sourceforge.phpeclipse.builder.PHPBuilder;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;