01: /*******************************************************************************
02: * Copyright (c) 2005, 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.javadoc;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: import org.eclipse.jface.text.IDocument;
15:
16: import org.eclipse.jdt.core.CompletionProposal;
17:
18: import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
19:
20: import org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal;
21:
22: /**
23: * Types directly completed to {@link Type}. See {@link CompletionProposal#JAVADOC_TYPE_REF}.
24: *
25: * @since 3.2
26: */
27: public final class JavadocLinkTypeCompletionProposal extends
28: LazyJavaTypeCompletionProposal {
29:
30: public JavadocLinkTypeCompletionProposal(
31: CompletionProposal proposal,
32: JavaContentAssistInvocationContext context) {
33: super (proposal, context);
34: Assert.isTrue(isInJavadoc());
35: }
36:
37: /*
38: * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal#computeReplacementString()
39: */
40: protected String computeReplacementString() {
41: String typeReplacement = super .computeReplacementString();
42: // TODO respect the auto-close preference, but do so consistently with method completions
43: // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
44: // if (autocloseBrackets())
45: if (true)
46: return "{@link " + typeReplacement + "}"; //$NON-NLS-1$ //$NON-NLS-2$
47: else
48: return "{@link " + typeReplacement; //$NON-NLS-1$
49: }
50:
51: /*
52: * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal#apply(org.eclipse.jface.text.IDocument, char, int)
53: */
54: public void apply(IDocument document, char trigger, int offset) {
55: // convert . to #
56: if (trigger == '.')
57: trigger = '#';
58: // TODO respect the auto-close preference, but do so consistently with method completions
59: // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
60: // boolean continueWithMember= trigger == '#' && autocloseBrackets();
61: boolean continueWithMember = trigger == '#';
62: if (continueWithMember)
63: setCursorPosition(getCursorPosition() - 1); // before the closing curly brace
64:
65: super .apply(document, trigger, offset);
66:
67: if (continueWithMember)
68: setUpLinkedMode(document, '}');
69: }
70: }
|