KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > template > contentassist > VariablePosition


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.text.template.contentassist;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.jface.text.IDocument;
16 import org.eclipse.jface.text.contentassist.ICompletionProposal;
17 import org.eclipse.jface.text.link.LinkedPositionGroup;
18 import org.eclipse.jface.text.link.ProposalPosition;
19
20
21 /**
22  *
23  */

24 public class VariablePosition extends ProposalPosition {
25
26     private MultiVariableGuess fGuess;
27     private MultiVariable fVariable;
28
29     public VariablePosition(IDocument document, int offset, int length, MultiVariableGuess guess, MultiVariable variable) {
30         this(document, offset, length, LinkedPositionGroup.NO_STOP, guess, variable);
31     }
32
33     public VariablePosition(IDocument document, int offset, int length, int sequence, MultiVariableGuess guess, MultiVariable variable) {
34         super(document, offset, length, sequence, null);
35         Assert.isNotNull(guess);
36         Assert.isNotNull(variable);
37         fVariable= variable;
38         fGuess= guess;
39     }
40
41
42     /*
43      * @see org.eclipse.jface.text.link.ProposalPosition#equals(java.lang.Object)
44      */

45     public boolean equals(Object JavaDoc o) {
46         if (o instanceof VariablePosition && super.equals(o)) {
47             return fGuess.equals(((VariablePosition) o).fGuess);
48         }
49         return false;
50     }
51
52     /*
53      * @see org.eclipse.jface.text.link.ProposalPosition#hashCode()
54      */

55     public int hashCode() {
56         return super.hashCode() | fGuess.hashCode();
57     }
58
59     /*
60      * @see org.eclipse.jface.text.link.ProposalPosition#getChoices()
61      */

62     public ICompletionProposal[] getChoices() {
63         return fGuess.getProposals(fVariable, offset, length);
64     }
65
66     /**
67      * Returns the variable.
68      *
69      * @return the variable.
70      */

71     public MultiVariable getVariable() {
72         return fVariable;
73     }
74
75 }
76
Popular Tags