49964430d90ea91df68c42a2e2dac3dfb0e7137c
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / 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 org.eclipse.jface.text.TypedPosition;
16 import org.eclipse.jface.text.contentassist.ICompletionProposal;
17
18 /**
19  * 
20  */
21 public class ProposalPosition extends TypedPosition {
22
23         /**
24          * The choices available for this position, fChoices[0] is the original
25          * type.
26          */
27         private final ICompletionProposal[] fChoices;
28
29         /*
30          * @see java.lang.Object#equals(java.lang.Object)
31          */
32         public boolean equals(Object o) {
33                 if (o instanceof ProposalPosition) {
34                         if (super.equals(o)) {
35                                 return Arrays.equals(fChoices, ((ProposalPosition) o).fChoices);
36                         }
37                 }
38                 return false;
39         }
40
41         /**
42          * @param offset
43          * @param length
44          * @param type
45          */
46         public ProposalPosition(int offset, int length, String type,
47                         ICompletionProposal[] choices) {
48                 super(offset, length, type);
49                 fChoices = new ICompletionProposal[choices.length];
50                 System.arraycopy(choices, 0, fChoices, 0, choices.length);
51         }
52
53         /**
54          * 
55          * @return an array of choices, including the initial one. Clients must not
56          *         modify it.
57          */
58         public ICompletionProposal[] getChoices() {
59                 updateChoicePositions();
60                 return fChoices;
61         }
62
63         /**
64          * 
65          */
66         private void updateChoicePositions() {
67                 for (int i = 0; i < fChoices.length; i++) {
68                         // if (fChoices[i] instanceof JavaCompletionProposal)
69                         // ((JavaCompletionProposal)fChoices[i]).setReplacementOffset(offset);
70                 }
71         }
72 }