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