use of org.eclipse.jface.text.templates.TemplateContextType in project egit by eclipse.
the class Activator method registerTemplateVariableResolvers.
private void registerTemplateVariableResolvers() {
if (hasJavaPlugin()) {
final ContextTypeRegistry codeTemplateContextRegistry = JavaPlugin.getDefault().getCodeTemplateContextRegistry();
final Iterator<?> ctIter = codeTemplateContextRegistry.contextTypes();
while (ctIter.hasNext()) {
final TemplateContextType contextType = (TemplateContextType) ctIter.next();
contextType.addResolver(new GitTemplateVariableResolver(// $NON-NLS-1$
"git_config", UIText.GitTemplateVariableResolver_GitConfigDescription));
}
}
}
use of org.eclipse.jface.text.templates.TemplateContextType in project titan.EclipsePlug-ins by eclipse.
the class ContentAssistProcessor method computeCompletionProposals.
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
IDocument doc = viewer.getDocument();
IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
ASN1ReferenceParser refParser = new ASN1ReferenceParser();
Reference ref = refParser.findReferenceForCompletion(file, offset, doc);
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
TITANDebugConsole.println("parsed the reference: " + ref);
}
if (ref == null || ref.getSubreferences().isEmpty()) {
return new ICompletionProposal[] {};
}
Scope scope = null;
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
Module tempModule = projectSourceParser.containedModule(file);
if (tempModule != null) {
scope = tempModule.getSmallestEnclosingScope(refParser.getReplacementOffset());
ref.setMyScope(scope);
ref.detectModid();
}
TemplateContextType contextType = new TemplateContextType(ASN1CodeSkeletons.CONTEXT_IDENTIFIER, ASN1CodeSkeletons.CONTEXT_NAME);
ProposalCollector propCollector = new ProposalCollector(Identifier_type.ID_ASN, ASN1CodeSkeletons.CONTEXT_IDENTIFIER, contextType, doc, ref, refParser.getReplacementOffset());
if (scope != null) {
scope.addProposal(propCollector);
propCollector.sortTillMarked();
propCollector.markPosition();
}
if (ref.getSubreferences().size() != 1) {
return propCollector.getCompletitions();
}
if (scope == null) {
propCollector.addProposal(CodeScanner.TAGS, null, KEYWORD);
} else {
ASN1CodeSkeletons.addSkeletonProposals(doc, refParser.getReplacementOffset(), propCollector);
}
propCollector.sortTillMarked();
propCollector.markPosition();
propCollector.addProposal(CodeScanner.VERBS, null, KEYWORD);
propCollector.addProposal(CodeScanner.COMPARE_TYPES, null, KEYWORD);
propCollector.addProposal(CodeScanner.STATUS_TYPE, null, KEYWORD);
propCollector.addProposal(CodeScanner.KEYWORDS, null, KEYWORD);
propCollector.addProposal(CodeScanner.STORAGE, null, KEYWORD);
propCollector.addProposal(CodeScanner.MODIFIER, null, KEYWORD);
propCollector.addProposal(CodeScanner.ACCESS_TYPE, null, KEYWORD);
propCollector.sortTillMarked();
String sortingpolicy = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.CONTENTASSISTANT_PROPOSAL_SORTING);
if (PreferenceConstantValues.SORT_ALPHABETICALLY.equals(sortingpolicy)) {
propCollector.sortAll();
}
return propCollector.getCompletitions();
}
use of org.eclipse.jface.text.templates.TemplateContextType in project dsl-devkit by dsldevkit.
the class CheckCfgTemplateProposalProvider method createTemplates.
@Override
protected void createTemplates(final TemplateContext templateContext, final ContentAssistContext context, final ITemplateAcceptor acceptor) {
if (templateContext.getContextType().getId().equals("com.avaloq.tools.ddk.checkcfg.CheckCfg.ConfiguredCheck")) {
// $NON-NLS-1$
addConfiguredCheckTemplates(templateContext, context, acceptor);
return;
} else if (templateContext.getContextType().getId().equals("com.avaloq.tools.ddk.checkcfg.CheckCfg.kw_catalog")) {
// $NON-NLS-1$
addCatalogConfigurations(templateContext, context, acceptor);
}
TemplateContextType contextType = templateContext.getContextType();
Template[] templates = templateStore.getTemplates(contextType.getId());
for (Template template : templates) {
if (!acceptor.canAcceptMoreTemplates()) {
return;
}
if (validate(template, templateContext)) {
acceptor.accept(createProposal(template, templateContext, context, getImage(template), getRelevance(template)));
}
}
}
use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.
the class HTMLTemplateCompletionProcessor method getContextType.
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
TemplateContextType type = null;
ContextTypeRegistry registry = getTemplateContextRegistry();
if (registry != null)
type = registry.getContextType(fContextTypeId);
return type;
}
use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.
the class CSSTemplateCompletionProcessor method getContextType.
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
TemplateContextType type = null;
ContextTypeRegistry registry = getTemplateContextRegistry();
if (registry != null)
type = registry.getContextType(fContextTypeId);
return type;
}
Aggregations