KickJava   Java API By Example, From Geeks To Geeks.

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


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.LazyJavaCompletionProposal;
23
24 /**
25  * Completions of inline tags such as {@link }. See {@link CompletionProposal#JAVADOC_INLINE_TAG}.
26  *
27  * @since 3.2
28  */

29 public final class JavadocInlineTagCompletionProposal extends LazyJavaCompletionProposal {
30     /** Triggers for types in javadoc. Do not modify. */
31     protected static final char[] JDOC_INLINE_TAG_TRIGGERS= new char[] { '#', '}', ' ' };
32
33     public JavadocInlineTagCompletionProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context) {
34         super(proposal, context);
35         Assert.isTrue(isInJavadoc());
36     }
37     
38     /*
39      * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal#computeReplacementString()
40      */

41     protected String JavaDoc computeReplacementString() {
42         String JavaDoc replacement= super.computeReplacementString();
43         // TODO respect the auto-close preference, but do so consistently with method completions
44
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
45
// if (!autocloseBrackets() && replacement.endsWith("}")) //$NON-NLS-1$
46
// return replacement.substring(0, replacement.length() - 1);
47
return replacement;
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         // TODO respect the auto-close preference, but do so consistently with method completions
55
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
56
// boolean needsLinkedMode= autocloseBrackets();
57
boolean needsLinkedMode= true;
58         if (needsLinkedMode)
59             setCursorPosition(getCursorPosition() - 1); // before the closing curly brace
60

61         super.apply(document, trigger, offset);
62
63         if (needsLinkedMode)
64             setUpLinkedMode(document, '}');
65     }
66 }
67
Popular Tags