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.LazyJavaCompletionProposal;
21:
22: /**
23: * Completions of inline tags such as {@link }. See {@link CompletionProposal#JAVADOC_INLINE_TAG}.
24: *
25: * @since 3.2
26: */
27: public final class JavadocInlineTagCompletionProposal extends
28: LazyJavaCompletionProposal {
29: /** Triggers for types in javadoc. Do not modify. */
30: protected static final char[] JDOC_INLINE_TAG_TRIGGERS = new char[] {
31: '#', '}', ' ' };
32:
33: public JavadocInlineTagCompletionProposal(
34: CompletionProposal proposal,
35: JavaContentAssistInvocationContext context) {
36: super (proposal, context);
37: Assert.isTrue(isInJavadoc());
38: }
39:
40: /*
41: * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal#computeReplacementString()
42: */
43: protected String computeReplacementString() {
44: String replacement = super .computeReplacementString();
45: // TODO respect the auto-close preference, but do so consistently with method completions
46: // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
47: // if (!autocloseBrackets() && replacement.endsWith("}")) //$NON-NLS-1$
48: // return replacement.substring(0, replacement.length() - 1);
49: return replacement;
50: }
51:
52: /*
53: * @see org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal#apply(org.eclipse.jface.text.IDocument, char, int)
54: */
55: public void apply(IDocument document, char trigger, int offset) {
56: // TODO respect the auto-close preference, but do so consistently with method completions
57: // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544
58: // boolean needsLinkedMode= autocloseBrackets();
59: boolean needsLinkedMode = true;
60: if (needsLinkedMode)
61: setCursorPosition(getCursorPosition() - 1); // before the closing curly brace
62:
63: super .apply(document, trigger, offset);
64:
65: if (needsLinkedMode)
66: setUpLinkedMode(document, '}');
67: }
68: }
|