improved PHP parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / link / ProposalPosition.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.text.link;
12
13 import java.util.Arrays;
14
15 //import net.sourceforge.phpdt.internal.ui.text.java.JavaCompletionProposal;
16 import org.eclipse.jface.text.TypedPosition;
17 import org.eclipse.jface.text.contentassist.ICompletionProposal;
18
19 /**
20  * 
21  */
22 public class ProposalPosition extends TypedPosition {
23         
24         /** The choices available for this position, fChoices[0] is the original type. */
25         private final ICompletionProposal[] fChoices;
26
27         /*
28          * @see java.lang.Object#equals(java.lang.Object)
29          */
30         public boolean equals(Object o) {
31                 if (o instanceof ProposalPosition) {
32                         if (super.equals(o)) {
33                                 return Arrays.equals(fChoices, ((ProposalPosition)o).fChoices);
34                         }
35                 }
36                 return false;
37         }
38         
39         /**
40          * @param offset
41          * @param length
42          * @param type
43          */
44         public ProposalPosition(int offset, int length, String type, ICompletionProposal[] choices) {
45                 super(offset, length, type);
46                 fChoices= new ICompletionProposal[choices.length]; 
47                 System.arraycopy(choices, 0, fChoices, 0, choices.length);
48         }
49         
50         /**
51          * 
52          * @return an array of choices, including the initial one. Clients must not modify it.
53          */
54         public ICompletionProposal[] getChoices() {
55                 updateChoicePositions();
56                 return fChoices;
57         }
58
59         /**
60          * 
61          */
62         private void updateChoicePositions() {
63                 for (int i= 0; i < fChoices.length; i++) {
64 //                      if (fChoices[i] instanceof JavaCompletionProposal)
65 //                              ((JavaCompletionProposal)fChoices[i]).setReplacementOffset(offset);
66                 }
67         }
68 }