X-Git-Url: http://git.phpeclipse.com 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..4fb0216 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 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: * *