From: jsurfer Date: Wed, 22 Sep 2004 18:57:42 +0000 (+0000) Subject: fixed "replace all" bug X-Git-Url: http://git.phpeclipse.com fixed "replace all" bug --- diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/AbstractTextTools.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/AbstractTextTools.java index 38a4f8b..8fbea65 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/AbstractTextTools.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/AbstractTextTools.java @@ -8,7 +8,7 @@ * Contributors: * Igor Malinin - initial contribution * - * $Id: AbstractTextTools.java,v 1.1 2004-09-02 18:26:49 jsurfer Exp $ + * $Id: AbstractTextTools.java,v 1.2 2004-09-22 18:51:51 jsurfer Exp $ */ package net.sourceforge.phpeclipse.ui.text; @@ -181,7 +181,7 @@ public class AbstractTextTools { * @param event * the event to whch to adapt */ - protected void adaptToPreferenceChange(PropertyChangeEvent event) { + public void adaptToPreferenceChange(PropertyChangeEvent event) { String property = event.getProperty(); Token token = getToken(property); diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/InnerDocumentView.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/InnerDocumentView.java index 70cb17e..f1b0ce2 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/InnerDocumentView.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/InnerDocumentView.java @@ -8,7 +8,7 @@ * Contributors: * Igor Malinin - initial contribution * - * $Id: InnerDocumentView.java,v 1.1 2004-09-02 18:26:29 jsurfer Exp $ + * $Id: InnerDocumentView.java,v 1.2 2004-09-22 18:51:51 jsurfer Exp $ */ package net.sourceforge.phpeclipse.ui.text.rules; @@ -25,128 +25,126 @@ import org.eclipse.jface.text.ITextStore; * * @author Igor Malinin */ -public class InnerDocumentView extends AbstractDocument implements - IDocumentView { - - /** - * Implements ITextStore based on IDocument. - */ - class TextStore implements ITextStore { - - /* - * @see ITextStore#set - */ - public void set(String txt) { - try { - parent.replace(range.offset, range.length, txt); - } catch (BadLocationException x) { - } - } - - /* - * @see ITextStore#replace - */ - public void replace(int offset, int length, String txt) { - try { - parent.replace(range.offset + offset, length, txt); - } catch (BadLocationException x) { - } - } - - /* - * @see ITextStore#getLength - */ - public int getLength() { - return range.length; - } - - /* - * @see ITextStore#get - */ - public String get(int offset, int length) { - try { - return parent.get(range.offset + offset, length); - } catch (BadLocationException x) { - } - - return null; - } - - /* - * @see ITextStore#get - */ - public char get(int offset) { - try { - return parent.getChar(range.offset + offset); - } catch (BadLocationException x) { - } - - return (char) 0; - } - } - - /** The parent document */ - IDocument parent; - - /** The section inside the parent document */ - ViewNode range; - - /** - * Constructs inner view to parent document. - * - * @param parent - * parent document - * @param range - */ - public InnerDocumentView(IDocument parent, ViewNode range) { - this.parent = parent; - this.range = range; - - setTextStore(new TextStore()); - setLineTracker(new DefaultLineTracker()); - getTracker().set(getStore().get(0, getLength())); - completeInitialization(); - } - - /* - * @see net.sourceforge.phpeclipse.text.rules.IDocumentView#getParentDocument() - */ - public IDocument getParentDocument() { - return parent; - } - - /* - * @see org.eclipse.jface.text.AbstractDocument#fireDocumentAboutToBeChanged(DocumentEvent) - */ - protected void fireDocumentAboutToBeChanged(DocumentEvent event) { - super.fireDocumentAboutToBeChanged(event); - } - - /* - * @see org.eclipse.jface.text.AbstractDocument#fireDocumentChanged(DocumentEvent) - */ - protected void fireDocumentChanged(DocumentEvent event) { - try { - // TODO: move to a better place - getTracker().replace(event.getOffset(), event.getLength(), - event.getText()); - } catch (BadLocationException x) { - } - - super.fireDocumentChanged(event); - } - - /* - * @see net.sf.wdte.text.rules.IDocumentView#getParentOffset(int) - */ - public int getParentOffset(int localOffset) { - return localOffset + range.offset; - } - - /* - * @see net.sf.wdte.text.rules.IDocumentView#getLocalOffset(int) - */ - public int getLocalOffset(int parentOffset) { - return parentOffset - range.offset; - } -} +public class InnerDocumentView extends AbstractDocument implements IDocumentView { + + /** + * Implements ITextStore based on IDocument. + */ + class TextStore implements ITextStore { + + /* + * @see ITextStore#set + */ + public void set(String txt) { + try { + parent.replace(range.offset, range.length, txt); + } catch (BadLocationException x) { + } + } + + /* + * @see ITextStore#replace + */ + public void replace(int offset, int length, String txt) { + try { + parent.replace(range.offset + offset, length, txt); + } catch (BadLocationException x) { + } + } + + /* + * @see ITextStore#getLength + */ + public int getLength() { + return range.length; + } + + /* + * @see ITextStore#get + */ + public String get(int offset, int length) { + try { + return parent.get(range.offset + offset, length); + } catch (BadLocationException x) { + } + + return null; + } + + /* + * @see ITextStore#get + */ + public char get(int offset) { + try { + return parent.getChar(range.offset + offset); + } catch (BadLocationException x) { + } + + return (char) 0; + } + } + + /** The parent document */ + IDocument parent; + + /** The section inside the parent document */ + ViewNode range; + + /** + * Constructs inner view to parent document. + * + * @param parent + * parent document + * @param range + */ + public InnerDocumentView(IDocument parent, ViewNode range) { + this.parent = parent; + this.range = range; + + setTextStore(new TextStore()); + setLineTracker(new DefaultLineTracker()); + getTracker().set(getStore().get(0, getLength())); + completeInitialization(); + } + + /* + * @see net.sourceforge.phpeclipse.text.rules.IDocumentView#getParentDocument() + */ + public IDocument getParentDocument() { + return parent; + } + + /* + * @see org.eclipse.jface.text.AbstractDocument#fireDocumentAboutToBeChanged(DocumentEvent) + */ + protected void fireDocumentAboutToBeChanged(DocumentEvent event) { + super.fireDocumentAboutToBeChanged(event); + } + + /* + * @see org.eclipse.jface.text.AbstractDocument#fireDocumentChanged(DocumentEvent) + */ + protected void fireDocumentChanged(DocumentEvent event) { + try { + // TODO: move to a better place + getTracker().replace(event.getOffset(), event.getLength(), event.getText()); + } catch (BadLocationException x) { + } + + super.fireDocumentChanged(event); + } + + /* + * @see net.sf.wdte.text.rules.IDocumentView#getParentOffset(int) + */ + public int getParentOffset(int localOffset) { + return localOffset + range.offset; + } + + /* + * @see net.sf.wdte.text.rules.IDocumentView#getLocalOffset(int) + */ + public int getLocalOffset(int parentOffset) { + return parentOffset - range.offset; + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/MultiViewPartitioner.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/MultiViewPartitioner.java index c5aa8ec..cc10e0d 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/MultiViewPartitioner.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/MultiViewPartitioner.java @@ -8,7 +8,7 @@ * Contributors: * Igor Malinin - initial contribution * - * $Id: MultiViewPartitioner.java,v 1.1 2004-09-02 18:26:29 jsurfer Exp $ + * $Id: MultiViewPartitioner.java,v 1.2 2004-09-22 18:51:51 jsurfer Exp $ */ package net.sourceforge.phpeclipse.ui.text.rules; @@ -320,7 +320,7 @@ public abstract class MultiViewPartitioner extends AbstractPartitioner { if (p instanceof ViewNode) { // TODO: revisit condition InnerDocumentView innerDocument = ((ViewNode) p).view; - if (innerDocument != null) { + if (innerDocument != null) { int start = innerDocument.getLocalOffset(offset); innerDocument.fireDocumentChanged(new DocumentEvent(innerDocument, start, length, text)); } diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/OuterDocumentView.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/OuterDocumentView.java index c438031..3202fe3 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/OuterDocumentView.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/text/rules/OuterDocumentView.java @@ -8,7 +8,7 @@ * Contributors: * Igor Malinin - initial contribution * - * $Id: OuterDocumentView.java,v 1.1 2004-09-02 18:26:29 jsurfer Exp $ + * $Id: OuterDocumentView.java,v 1.2 2004-09-22 18:51:51 jsurfer Exp $ */ package net.sourceforge.phpeclipse.ui.text.rules; @@ -148,8 +148,12 @@ public class OuterDocumentView extends AbstractDocument implements setTextStore(new TextStore()); setLineTracker(new DefaultLineTracker()); - getTracker().set(getStore().get(0, getLength())); - + int length = getLength(); + if (length<0) { + length = 0; + } + getTracker().set(getStore().get(0, length)); + completeInitialization(); } diff --git a/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditor.java b/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditor.java index e1eae82..282e5db 100644 --- a/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditor.java +++ b/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditor.java @@ -9,7 +9,7 @@ * Igor Malinin - initial contribution * Christopher Lenz - integrated outline page * - * $Id: XMLEditor.java,v 1.2 2004-09-03 17:29:08 jsurfer Exp $ + * $Id: XMLEditor.java,v 1.3 2004-09-22 18:57:42 jsurfer Exp $ */ package net.sourceforge.phpeclipse.xml.ui.internal.editor; @@ -25,7 +25,6 @@ import net.sourceforge.phpeclipse.xml.ui.internal.outline.XMLOutlinePage; import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration; import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.IRegion; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java index cb1a56d..57812ba 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/BufferedDocumentScanner.java @@ -71,7 +71,9 @@ public final class BufferedDocumentScanner implements ICharacterScanner { try { final String content= fDocument.get(fBufferOffset, fBufferLength); - content.getChars(0, fBufferLength, fBuffer, 0); + if (content!=null) { + content.getChars(0, fBufferLength, fBuffer, 0); + } } catch (BadLocationException e) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/ExternalPHPParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/ExternalPHPParser.java index 63704ad..17c7535 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/ExternalPHPParser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/ExternalPHPParser.java @@ -5,9 +5,7 @@ import java.io.InputStream; import java.text.MessageFormat; import java.util.Hashtable; -//import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; import net.sourceforge.phpdt.internal.ui.util.StringUtil; -import net.sourceforge.phpdt.ui.PreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.views.PHPConsole;