01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.text.template.contentassist;
11:
12: import org.eclipse.core.runtime.Assert;
13:
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: public class VariablePosition extends ProposalPosition {
23:
24: private MultiVariableGuess fGuess;
25: private MultiVariable fVariable;
26:
27: public VariablePosition(IDocument document, int offset, int length,
28: MultiVariableGuess guess, MultiVariable variable) {
29: this (document, offset, length, LinkedPositionGroup.NO_STOP,
30: guess, variable);
31: }
32:
33: public VariablePosition(IDocument document, int offset, int length,
34: int sequence, MultiVariableGuess guess,
35: MultiVariable variable) {
36: super (document, offset, length, sequence, null);
37: Assert.isNotNull(guess);
38: Assert.isNotNull(variable);
39: fVariable = variable;
40: fGuess = guess;
41: }
42:
43: /*
44: * @see org.eclipse.jface.text.link.ProposalPosition#equals(java.lang.Object)
45: */
46: public boolean equals(Object o) {
47: if (o instanceof VariablePosition && super .equals(o)) {
48: return fGuess.equals(((VariablePosition) o).fGuess);
49: }
50: return false;
51: }
52:
53: /*
54: * @see org.eclipse.jface.text.link.ProposalPosition#hashCode()
55: */
56: public int hashCode() {
57: return super .hashCode() | fGuess.hashCode();
58: }
59:
60: /*
61: * @see org.eclipse.jface.text.link.ProposalPosition#getChoices()
62: */
63: public ICompletionProposal[] getChoices() {
64: return fGuess.getProposals(fVariable, offset, length);
65: }
66:
67: /**
68: * Returns the variable.
69: *
70: * @return the variable.
71: */
72: public MultiVariable getVariable() {
73: return fVariable;
74: }
75:
76: }
|