Organized imports
[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 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         /** The choices available for this position, fChoices[0] is the original type. */
24         private final ICompletionProposal[] fChoices;
25
26         /*
27          * @see java.lang.Object#equals(java.lang.Object)
28          */
29         public boolean equals(Object o) {
30                 if (o instanceof ProposalPosition) {
31                         if (super.equals(o)) {
32                                 return Arrays.equals(fChoices, ((ProposalPosition)o).fChoices);
33                         }
34                 }
35                 return false;
36         }
37         
38         /**
39          * @param offset
40          * @param length
41          * @param type
42          */
43         public ProposalPosition(int offset, int length, String type, ICompletionProposal[] choices) {
44                 super(offset, length, type);
45                 fChoices= new ICompletionProposal[choices.length]; 
46                 System.arraycopy(choices, 0, fChoices, 0, choices.length);
47         }
48         
49         /**
50          * 
51          * @return an array of choices, including the initial one. Clients must not modify it.
52          */
53         public ICompletionProposal[] getChoices() {
54                 updateChoicePositions();
55                 return fChoices;
56         }
57
58         /**
59          * 
60          */
61         private void updateChoicePositions() {
62                 for (int i= 0; i < fChoices.length; i++) {
63 //                      if (fChoices[i] instanceof JavaCompletionProposal)
64 //                              ((JavaCompletionProposal)fChoices[i]).setReplacementOffset(offset);
65                 }
66         }
67 }