From: khartlage "); //$NON-NLS-1$
+ buffer.append(paragraph);
+ }
+ }
+
+ public static void addParagraph(StringBuffer buffer, Reader paragraphReader) {
+ if (paragraphReader != null)
+ addParagraph(buffer, read(paragraphReader));
+ }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaAnnotationHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaAnnotationHover.java
index 9f6f980..c57a86d 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaAnnotationHover.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaAnnotationHover.java
@@ -26,7 +26,6 @@ import org.eclipse.jface.text.source.Annotation;
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 !
/**
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaProblemHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaProblemHover.java
index 1ca1d0b..9b019ef 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaProblemHover.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaProblemHover.java
@@ -13,6 +13,7 @@ package net.sourceforge.phpdt.internal.ui.text.java.hover;
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;
@@ -25,7 +26,6 @@ import org.eclipse.jface.text.Position;
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;
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaSourceHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaSourceHover.java
index 786076f..4754b2b 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaSourceHover.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/JavaSourceHover.java
@@ -17,13 +17,13 @@ import net.sourceforge.phpdt.core.IJavaElement;
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.
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/ILinkedPositionListener.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/ILinkedPositionListener.java
new file mode 100644
index 0000000..1f79b44
--- /dev/null
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/ILinkedPositionListener.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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);
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionManager.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionManager.java
index 0745ef7..11403b2 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionManager.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionManager.java
@@ -1,13 +1,13 @@
-/**********************************************************************
-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;
@@ -18,6 +18,7 @@ import java.util.Map;
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;
@@ -29,7 +30,7 @@ import org.eclipse.jface.text.IDocumentListener;
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;
/**
@@ -99,35 +100,55 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
}
}
- 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
+ * There are the following constraints for linked positions:
+ *
+ * "); //$NON-NLS-1$
+ }
+
+ public static void endBulletList(StringBuffer buffer) {
+ buffer.append("
"); //$NON-NLS-1$
+ }
+
+ public static void addBullet(StringBuffer buffer, String bullet) {
+ if (bullet != null) {
+ buffer.append(""); //$NON-NLS-1$
+ buffer.append(header);
+ buffer.append("
"); //$NON-NLS-1$
+ }
+ }
+
+ public static void addParagraph(StringBuffer buffer, String paragraph) {
+ if (paragraph != null) {
+ buffer.append("LinkedPositionManager
for a IDocument
.
*
* @param document the document to use with linked positions.
+ * @param canCoexist true
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 LinkedPositionManager
for a IDocument
.
+ *
+ * @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:
*
*
@@ -141,6 +162,26 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
* @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:
+ *
+ *
+ *
+ *
+ * @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) {
@@ -149,69 +190,158 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
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.
+ *
+ *
+ *
+ * It is usually best to set the first item in additionalChoices
to be equal with
+ * the text inserted at the current position.
+ *
type
.
+ */
+ 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:
+ *
+ * additionalChoices
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 type
.
+ */
+ 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);
+ }
}
+
}
/**
@@ -240,6 +370,22 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
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 offset
.
@@ -287,22 +433,28 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
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);
}
@@ -331,10 +483,23 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
}
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
}
/*
@@ -342,6 +507,11 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
*/
public void documentAboutToBeChanged(DocumentEvent event) {
+ if (fMustLeave) {
+ event.getDocument().removeDocumentListener(this);
+ return;
+ }
+
IDocument document= event.getDocument();
Position[] positions= getPositions(document);
@@ -351,7 +521,7 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
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);
@@ -409,37 +579,54 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
* @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) {
@@ -477,10 +664,31 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
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) {
@@ -514,11 +722,11 @@ public class LinkedPositionManager implements IDocumentListener, IPositionUpdate
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
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java
index d02d674..7f455fe 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/LinkedPositionUI.java
@@ -1,7 +1,13 @@
-/*
- * (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;
@@ -14,12 +20,14 @@ import org.eclipse.core.runtime.CoreException;
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;
@@ -29,7 +37,8 @@ import org.eclipse.jface.text.ITextViewerExtension3;
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;
@@ -50,10 +59,12 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+
+
/**
* A user interface for LinkedPositionManager
, using ITextViewer
.
*/
-public class LinkedPositionUI implements LinkedPositionListener,
+public class LinkedPositionUI implements ILinkedPositionListener,
ITextInputListener, ITextListener, ModifyListener, VerifyListener, VerifyKeyListener, PaintListener, IPropertyChangeListener, ShellListener {
/**
@@ -82,15 +93,19 @@ public class LinkedPositionUI implements LinkedPositionListener,
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;
@@ -102,6 +117,15 @@ public class LinkedPositionUI implements LinkedPositionListener,
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 LinkedPositionManager
.
@@ -116,6 +140,9 @@ public class LinkedPositionUI implements LinkedPositionListener,
fViewer= viewer;
fManager= manager;
+ fPositionCategoryName= CARET_POSITION_PREFIX + (fgCounter++);
+ fUpdater= new DefaultPositionUpdater(fPositionCategoryName);
+
fManager.setLinkedPositionListener(this);
initializeHighlightColor(viewer);
@@ -176,6 +203,8 @@ public class LinkedPositionUI implements LinkedPositionListener,
/**
* 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
+ * LinkedPositionManager
.
*/
public void setFinalCaretOffset(int offset) {
fFinalCaretOffset= offset;
@@ -201,6 +230,9 @@ public class LinkedPositionUI implements LinkedPositionListener,
* @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;
@@ -216,20 +248,29 @@ public class LinkedPositionUI implements LinkedPositionListener,
* @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);
}
@@ -247,7 +288,7 @@ public class LinkedPositionUI implements LinkedPositionListener,
Shell shell= text.getShell();
shell.addShellListener(this);
-
+
fFramePosition= (fInitialOffset == -1) ? fManager.getFirstPosition() : fManager.getPosition(fInitialOffset);
if (fFramePosition == null) {
leave(UNINSTALL | COMMIT | UPDATE_CARET);
@@ -256,25 +297,37 @@ public class LinkedPositionUI implements LinkedPositionListener,
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);
}
/**
@@ -282,6 +335,9 @@ public class LinkedPositionUI implements LinkedPositionListener,
* enter()
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
@@ -289,6 +345,13 @@ public class LinkedPositionUI implements LinkedPositionListener,
}
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;
@@ -302,16 +365,38 @@ public class LinkedPositionUI implements LinkedPositionListener,
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);
@@ -327,7 +412,7 @@ public class LinkedPositionUI implements LinkedPositionListener,
((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) {
@@ -345,8 +430,8 @@ public class LinkedPositionUI implements LinkedPositionListener,
}
}
- document.removePositionUpdater(fgUpdater);
- document.removePositionCategory(CARET_POSITION);
+ document.removePositionUpdater(fUpdater);
+ document.removePositionCategory(fPositionCategoryName);
if (fExitListener != null)
fExitListener.exit(
@@ -354,7 +439,7 @@ public class LinkedPositionUI implements LinkedPositionListener,
((flags & DOCUMENT_CHANGED) != 0));
} catch (BadPositionCategoryException e) {
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
Assert.isTrue(false);
}
@@ -363,36 +448,83 @@ public class LinkedPositionUI implements LinkedPositionListener,
}
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();
@@ -426,7 +558,23 @@ public class LinkedPositionUI implements LinkedPositionListener,
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;
@@ -436,17 +584,47 @@ public class LinkedPositionUI implements LinkedPositionListener,
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;
@@ -606,7 +784,7 @@ public class LinkedPositionUI implements LinkedPositionListener,
ExceptionHandler.handle((InvocationTargetException)e, shell, title, null);
else {
MessageDialog.openError(shell, title, e.getMessage());
- PHPeclipsePlugin.log(e);
+ PHPeclipsePlugin.log(e);
}
}
@@ -659,7 +837,42 @@ public class LinkedPositionUI implements LinkedPositionListener,
* @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);
+ }
+ }
+ });
+ }
}
/*
@@ -675,4 +888,4 @@ public class LinkedPositionUI implements LinkedPositionListener,
leave(UNINSTALL | COMMIT | DOCUMENT_CHANGED);
}
-}
\ No newline at end of file
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/ProposalPosition.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/ProposalPosition.java
new file mode 100644
index 0000000..46ddd75
--- /dev/null
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/link/ProposalPosition.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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);
+ }
+ }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java
index 65bc255..5110243 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/NewElementWizard.java
@@ -30,105 +30,109 @@ import org.eclipse.ui.INewWizard;
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());
+ }
}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
index 8c9a4f0..0f29b99 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
@@ -5,7 +5,7 @@ import org.eclipse.swt.SWT;
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 {
@@ -31,9 +31,9 @@ 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(
@@ -47,9 +47,9 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory {
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);
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
index fe4136e..735cda1 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
@@ -75,6 +75,7 @@ import org.eclipse.ui.IWorkbench;
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;
@@ -609,7 +610,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
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
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java
index f12aa38..72fb11f 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java
@@ -37,10 +37,8 @@ import org.eclipse.ui.IWorkbenchPage;
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;
@@ -85,9 +83,12 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
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 {
@@ -130,7 +131,7 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
store = PHPeclipsePlugin.getDefault().getPreferenceStore();
}
- // IPath path = file.getFullPath();
+ // IPath path = file.getFullPath();
String localhostURL = file.getLocation().toString();
String lowerCaseFileName = localhostURL.toLowerCase();
@@ -144,30 +145,30 @@ public class PHPEclipseShowAction implements IObjectActionDelegate {
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$
}
}
+ // }
}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathDirectory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathDirectory.java
deleted file mode 100644
index 8448fb7..0000000
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathDirectory.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * 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$
-}
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathLocation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathLocation.java
deleted file mode 100644
index e96c467..0000000
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathLocation.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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() {
-}
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathMultiDirectory.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathMultiDirectory.java
deleted file mode 100644
index ad76fe2..0000000
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/ClasspathMultiDirectory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * 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$
-}
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/PHPBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/PHPBuilder.java
deleted file mode 100644
index a4a7be9..0000000
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/PHPBuilder.java
+++ /dev/null
@@ -1,242 +0,0 @@
-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 FULL_BUILD
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.
- *
- * This method is part of the IExecutableExtension
- * interface.
- *
- * Subclasses are free to extend this method to pick up
- * initialization parameters from the plug-in plug-in manifest
- * (plugin.xml
) file,
- * but should be sure to invoke this method on their superclass.
- *
- * For example, the following method looks for a boolean-valued - * parameter named "trace": - *
- * 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")); - * } - * } - *- * - */ - 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
setInitializationData
has been called.
- * The default implementation should be called by all overriding methods.
- *
- * @see #setInitializationData
- */
- protected void startupOnInitialize() {
- // traceMsg("Parse Builder Initialize - startupOnInitialize()");
- }
-
- /**
- * Write trace statements.
- * System.out.println with prefix tagging used for simplicity.
- */
- // private void traceMsg(String msg) {
- // if (PHPeclipsePlugin.DEBUG | traceEnabled)
- // System.out.println(
- // buildMode
- // + "<"
- // + getProject()
- // + "> "
- // + "\t\t\t"
- // + buildMark
- // + msg);
- // }
-
-}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/State.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/State.java
deleted file mode 100644
index 754ecbe..0000000
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/State.java
+++ /dev/null
@@ -1,612 +0,0 @@
-/*******************************************************************************
- * 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(" true
if it is a problem annotation
*/
boolean isProblem();
-}
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java
index 98681fa..b6d1eb1 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/JavaOutlinePage.java
@@ -30,6 +30,8 @@ import net.sourceforge.phpdt.core.IType;
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;
@@ -46,8 +48,6 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin;
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;
@@ -87,8 +87,8 @@ import org.eclipse.swt.widgets.Widget;
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;
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java
index fb4f623..5751336 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPDocumentProvider.java
@@ -71,6 +71,8 @@ import org.eclipse.ui.IFileEditorInput;
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;
@@ -142,7 +144,7 @@ public class PHPDocumentProvider extends FileDocumentProvider {
/*
* @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);
@@ -185,65 +187,128 @@ public class PHPDocumentProvider extends FileDocumentProvider {
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);
@@ -470,30 +535,55 @@ public class PHPDocumentProvider extends FileDocumentProvider {
/**
* Annotation representating an IProblem
.
*/
- 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
@@ -562,11 +652,17 @@ public class PHPDocumentProvider extends FileDocumentProvider {
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);
}
/*
@@ -612,8 +708,48 @@ public class PHPDocumentProvider extends FileDocumentProvider {
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;
}
};
/**
@@ -1120,60 +1256,116 @@ public class PHPDocumentProvider extends FileDocumentProvider {
}
/*
- * @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.
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java
index 8134b38..1fdfc76 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParserAction.java
@@ -19,11 +19,10 @@ import java.util.ArrayList;
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;
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxParserThread.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxParserThread.java
deleted file mode 100644
index b04c4f3..0000000
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxParserThread.java
+++ /dev/null
@@ -1,421 +0,0 @@
-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