730d9112b2d232e3563d71dd67b13af5f5743bef
[phpeclipse.git] /
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.template.contentassist;
12
13 //incastrix
14 //import org.eclipse.jface.text.Assert;
15 import org.eclipse.core.runtime.Assert;
16 import org.eclipse.jface.text.IDocument;
17 import org.eclipse.jface.text.contentassist.ICompletionProposal;
18 import org.eclipse.jface.text.link.LinkedPositionGroup;
19 import org.eclipse.jface.text.link.ProposalPosition;
20
21 /**
22  * 
23  */
24 public class VariablePosition extends ProposalPosition {
25
26         private MultiVariableGuess fGuess;
27
28         private MultiVariable fVariable;
29
30         public VariablePosition(IDocument document, int offset, int length,
31                         MultiVariableGuess guess, MultiVariable variable) {
32                 this(document, offset, length, LinkedPositionGroup.NO_STOP, guess,
33                                 variable);
34         }
35
36         public VariablePosition(IDocument document, int offset, int length,
37                         int sequence, MultiVariableGuess guess, MultiVariable variable) {
38                 super(document, offset, length, sequence, null);
39                 Assert.isNotNull(guess);
40                 Assert.isNotNull(variable);
41                 fVariable = variable;
42                 fGuess = guess;
43         }
44
45         /*
46          * @see org.eclipse.jface.text.link.ProposalPosition#equals(java.lang.Object)
47          */
48         public boolean equals(Object o) {
49                 if (o instanceof VariablePosition && super.equals(o)) {
50                         return fGuess.equals(((VariablePosition) o).fGuess);
51                 }
52                 return false;
53         }
54
55         /*
56          * @see org.eclipse.jface.text.link.ProposalPosition#hashCode()
57          */
58         public int hashCode() {
59                 return super.hashCode() | fGuess.hashCode();
60         }
61
62         /*
63          * @see org.eclipse.jface.text.link.ProposalPosition#getChoices()
64          */
65         public ICompletionProposal[] getChoices() {
66                 return fGuess.getProposals(fVariable, offset, length);
67         }
68
69         /**
70          * @return
71          */
72         public MultiVariable getVariable() {
73                 return fVariable;
74         }
75
76 }