mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 239923 - No Template proposals within doxygen comments
This commit is contained in:
parent
41798922e2
commit
88c2f4a063
5 changed files with 54 additions and 4 deletions
|
@ -396,6 +396,7 @@ asmCompareFontDefinition.description= The Assembly compare text font is used by
|
|||
#--- templates
|
||||
c.contextType.name = C/C++
|
||||
comment.contextType.name = Comment
|
||||
doccomment.contextType.name = Doc Comment
|
||||
|
||||
# completion
|
||||
completionContributors=Content Assist Completion Contributor
|
||||
|
|
|
@ -2416,15 +2416,24 @@
|
|||
<!--- Template extension for the editor -->
|
||||
<extension
|
||||
point="org.eclipse.ui.editors.templates">
|
||||
<contextTypeRegistry id="org.eclipse.cdt.ui.editor.CEditor"/>
|
||||
<contextType
|
||||
name="%c.contextType.name"
|
||||
class="org.eclipse.cdt.internal.corext.template.c.CContextType"
|
||||
id="org.eclipse.cdt.ui.text.templates.c">
|
||||
id="org.eclipse.cdt.ui.text.templates.c"
|
||||
registryId="org.eclipse.cdt.ui.editor.CEditor">
|
||||
</contextType>
|
||||
<contextType
|
||||
class="org.eclipse.cdt.internal.corext.template.c.CommentContextType"
|
||||
id="org.eclipse.cdt.ui.text.templates.comment"
|
||||
name="%comment.contextType.name">
|
||||
name="%comment.contextType.name"
|
||||
registryId="org.eclipse.cdt.ui.editor.CEditor">
|
||||
</contextType>
|
||||
<contextType
|
||||
class="org.eclipse.cdt.internal.corext.template.c.DocCommentContextType"
|
||||
id="org.eclipse.cdt.ui.text.templates.doccomment"
|
||||
name="%doccomment.contextType.name"
|
||||
registryId="org.eclipse.cdt.ui.editor.CEditor">
|
||||
</contextType>
|
||||
<include
|
||||
file="templates/default-templates.xml"
|
||||
|
@ -2542,6 +2551,8 @@
|
|||
<partition type="__dftl_partition_content_type"/>
|
||||
<partition type="__c_multiline_comment"/>
|
||||
<partition type="__c_singleline_comment"/>
|
||||
<partition type="__c_multiline_doc_comment"/>
|
||||
<partition type="__c_singleline_doc_comment"/>
|
||||
</completionProposalComputer>
|
||||
</extension>
|
||||
<!-- help provider proposals -->
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.corext.template.c;
|
||||
|
||||
/**
|
||||
* A context type for documentation comments.
|
||||
*
|
||||
* @since 5.1
|
||||
*/
|
||||
public class DocCommentContextType extends CommentContextType {
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
public static final String ID= "org.eclipse.cdt.ui.text.templates.doccomment"; //$NON-NLS-1$
|
||||
|
||||
public DocCommentContextType() {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
|
|||
|
||||
import org.eclipse.cdt.internal.corext.template.c.CContextType;
|
||||
import org.eclipse.cdt.internal.corext.template.c.CommentContextType;
|
||||
import org.eclipse.cdt.internal.corext.template.c.DocCommentContextType;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
|
||||
import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
|
||||
|
@ -43,6 +44,7 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
|
|||
|
||||
private final TemplateEngine fCTemplateEngine;
|
||||
private final TemplateEngine fCommentTemplateEngine;
|
||||
private final TemplateEngine fDocCommentTemplateEngine;
|
||||
|
||||
/**
|
||||
* Default constructor is required (executable extension).
|
||||
|
@ -60,6 +62,12 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
|
|||
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
|
||||
}
|
||||
fCommentTemplateEngine= new TemplateEngine(contextType);
|
||||
contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(DocCommentContextType.ID);
|
||||
if (contextType == null) {
|
||||
contextType= new DocCommentContextType();
|
||||
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
|
||||
}
|
||||
fDocCommentTemplateEngine= new TemplateEngine(contextType);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -73,6 +81,8 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
|
|||
String partition= TextUtilities.getContentType(viewer.getDocument(), ICPartitions.C_PARTITIONING, offset, true);
|
||||
if (partition.equals(ICPartitions.C_MULTI_LINE_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
|
||||
engine= fCommentTemplateEngine;
|
||||
} else if (partition.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_DOC_COMMENT)) {
|
||||
engine= fDocCommentTemplateEngine;
|
||||
} else {
|
||||
if (isValidContext(context)) {
|
||||
engine= fCTemplateEngine;
|
||||
|
|
|
@ -75,6 +75,7 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
|||
import org.eclipse.cdt.internal.corext.template.c.CContextType;
|
||||
import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
|
||||
import org.eclipse.cdt.internal.corext.template.c.CommentContextType;
|
||||
import org.eclipse.cdt.internal.corext.template.c.DocCommentContextType;
|
||||
import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
|
||||
|
@ -872,9 +873,10 @@ public class CUIPlugin extends AbstractUIPlugin {
|
|||
*/
|
||||
public ContextTypeRegistry getTemplateContextRegistry() {
|
||||
if (fContextTypeRegistry == null) {
|
||||
fContextTypeRegistry= new ContributionContextTypeRegistry();
|
||||
fContextTypeRegistry= new ContributionContextTypeRegistry(EDITOR_ID);
|
||||
fContextTypeRegistry.addContextType(CContextType.ID);
|
||||
fContextTypeRegistry.addContextType(CommentContextType.ID);
|
||||
fContextTypeRegistry.addContextType(DocCommentContextType.ID);
|
||||
}
|
||||
return fContextTypeRegistry;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue