KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > javadoc > JavadocLinkTypeCompletionProposal


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.javadoc;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.jface.text.IDocument;
16
17 import org.eclipse.jdt.core.CompletionProposal;
18
19
20 import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
21
22 import org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal;
23
24 /**
25  * Types directly completed to {@link Type}. See {@link CompletionProposal#JAVADOC_TYPE_REF}.
26  *
27  * @since 3.2
28  */

29 public final class JavadocLinkTypeCompletionProposal extends LazyJavaTypeCompletionProposal {
30
31     public JavadocLinkTypeCompletionProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context) {
32         super(proposal, context);
33         Assert.isTrue(isInJavadoc());
34     }
35     
36     /*
37      * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal#computeReplacementString()
38      */

39     protected String JavaDoc computeReplacementString() {
40         String JavaDoc typeReplacement= super.computeReplacementString();
41         // TODO respect the auto-close preference, but do so consistently with method completions
42
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
43
// if (autocloseBrackets())
44
if (true)
45             return "{@link " + typeReplacement + "}"; //$NON-NLS-1$ //$NON-NLS-2$
46
else
47             return "{@link " + typeReplacement; //$NON-NLS-1$
48
}
49     
50     /*
51      * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal#apply(org.eclipse.jface.text.IDocument, char, int)
52      */

53     public void apply(IDocument document, char trigger, int offset) {
54         // convert . to #
55
if (trigger == '.')
56             trigger= '#';
57         // TODO respect the auto-close preference, but do so consistently with method completions
58
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
59
// boolean continueWithMember= trigger == '#' && autocloseBrackets();
60
boolean continueWithMember= trigger == '#';
61         if (continueWithMember)
62             setCursorPosition(getCursorPosition() - 1); // before the closing curly brace
63

64         super.apply(document, trigger, offset);
65
66         if (continueWithMember)
67             setUpLinkedMode(document, '}');
68     }
69 }
70
Popular Tags