当前位置: 首页>>代码示例>>Java>>正文


Java TemplateContextType类代码示例

本文整理汇总了Java中org.eclipse.jface.text.templates.TemplateContextType的典型用法代码示例。如果您正苦于以下问题:Java TemplateContextType类的具体用法?Java TemplateContextType怎么用?Java TemplateContextType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TemplateContextType类属于org.eclipse.jface.text.templates包,在下文中一共展示了TemplateContextType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContextTypes

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
private static List<TemplateContextType> getContextTypes() {
	List<TemplateContextType> contextTypes = new ArrayList<>();
	contextTypes.add(new CodeTemplateContextType(CATCHBLOCK_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(METHODBODY_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(CONSTRUCTORBODY_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(GETTERBODY_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(SETTERBODY_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(NEWTYPE_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(CLASSBODY_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(INTERFACEBODY_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(ENUMBODY_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(ANNOTATIONBODY_CONTEXTTYPE));

	contextTypes.add(new CodeTemplateContextType(FILECOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(TYPECOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(FIELDCOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(METHODCOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(CONSTRUCTORCOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(OVERRIDECOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(DELEGATECOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(GETTERCOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(SETTERCOMMENT_CONTEXTTYPE));
	contextTypes.add(new CodeTemplateContextType(CATCHBODY_CONTEXTTYPE));
	return contextTypes;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:CodeTemplateContextType.java

示例2: createTemplates

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
@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)));
    }
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:21,代码来源:CheckCfgTemplateProposalProvider.java

示例3: getHoverInfo

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
public String getHoverInfo(ITextViewer textViewer, IRegion subject) {
	try {
		IDocument doc= textViewer.getDocument();
		int offset= subject.getOffset();
		if (offset >= 2 && "${".equals(doc.get(offset-2, 2))) { //$NON-NLS-1$
			String varName= doc.get(offset, subject.getLength());
			TemplateContextType contextType= fProcessor.getContextType();
			if (contextType != null) {
				Iterator iter= contextType.resolvers();
				while (iter.hasNext()) {
					TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
					if (varName.equals(var.getType())) {
						return var.getDescription();
					}
				}
			}
		}				
	} catch (BadLocationException e) {
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:22,代码来源:CodeTemplateSourceViewerConfiguration.java

示例4: getColumnText

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
public String getColumnText(Object element, int columnIndex) {
	TemplatePersistenceData data = (TemplatePersistenceData) element;
	Template template= data.getTemplate();

	switch (columnIndex) {
		case 0:
			return template.getName();
		case 1:
			TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
			if (type != null)
				return type.getName();
			return template.getContextTypeId();
		case 2:
			return template.getDescription();
		case 3:
			return template.isAutoInsertable() ? TemplatesMessages.TemplatePreferencePage_on : "";  //$NON-NLS-1$
		default:
			return ""; //$NON-NLS-1$
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:21,代码来源:E4TemplatePreferencePage.java

示例5: add

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
private void add() {

		Iterator it= fContextTypeRegistry.contextTypes();
		if (it.hasNext()) {
			Template template= new Template("", "", ((TemplateContextType) it.next()).getId(), "", true);   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

			Template newTemplate= editTemplate(template, false, true);
			if (newTemplate != null) {
				TemplatePersistenceData data= new TemplatePersistenceData(newTemplate, true);
				fTemplateStore.add(data);
				fTableViewer.refresh();
				fTableViewer.setChecked(data, true);
				fTableViewer.setSelection(new StructuredSelection(data));
			}
		}
	}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:E4TemplatePreferencePage.java

示例6: getTemplateContextRegistry

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
/**
 * Returns the template context type registry for the java plug-in.
 *
 * @return the template context type registry for the java plug-in
 * @since 3.0
 */
public synchronized ContextTypeRegistry getTemplateContextRegistry() {
  if (fContextTypeRegistry == null) {
    ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(ID_CU_EDITOR);

    TemplateContextType all_contextType = registry.getContextType(JavaContextType.ID_ALL);
    ((AbstractJavaContextType) all_contextType).initializeContextTypeResolvers();

    registerJavaContext(registry, JavaContextType.ID_MEMBERS, all_contextType);
    registerJavaContext(registry, JavaContextType.ID_STATEMENTS, all_contextType);

    //            registerJavaContext(registry, SWTContextType.ID_ALL, all_contextType);
    //            all_contextType= registry.getContextType(SWTContextType.ID_ALL);
    //
    //            registerJavaContext(registry, SWTContextType.ID_MEMBERS, all_contextType);
    //            registerJavaContext(registry, SWTContextType.ID_STATEMENTS, all_contextType);

    fContextTypeRegistry = registry;
  }

  return fContextTypeRegistry;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:JavaPlugin.java

示例7: createContextType

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
/**
 * Tries to create a context type given an id. Contributions to the <code>
 * org.eclipse.ui.editors.templates</code> extension point are searched for the given identifier
 * and the specified context type instantiated if it is found. Any contributed {@link
 * org.eclipse.jface.text.templates.TemplateVariableResolver}s are also instantiated and added to
 * the context type.
 *
 * @param id the id for the context type as specified in XML
 * @return the instantiated and configured context type, or <code>null</code> if it is not found
 *     or cannot be instantiated
 */
public static TemplateContextType createContextType(String id) {
  Assert.isNotNull(id);

  IConfigurationElement[] extensions = getTemplateExtensions();
  TemplateContextType type;
  try {
    type = createContextType(extensions, id);
    if (type != null) {
      TemplateVariableResolver[] resolvers = createResolvers(extensions, id);
      for (int i = 0; i < resolvers.length; i++) type.addResolver(resolvers[i]);
    }
  } catch (CoreException e) {
    JavaPlugin.log(e);
    type = null;
  }

  return type;
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:ContributionContextTypeRegistry.java

示例8: getContextType

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
public TemplateContextType getContextType(final Model model, final String path) {
    if (OpenApi3ContextTypeProvider.RootContextType.isRoot(path)) {
        return new RootContextType();
    }
    return Iterables
            .getFirst(Iterables.filter(allContextTypes(), new Predicate<TemplateContextType>() {

                @Override
                public boolean apply(TemplateContextType input) {
                    if (input instanceof SchemaBasedTemplateContextType) {
                        return ((SchemaBasedTemplateContextType) input).matches(model, path);
                    }
                    return false;
                }

            }), null);
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:18,代码来源:OpenApi3ContextTypeProvider.java

示例9: getContextType

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
@Override
protected TemplateContextType getContextType(ITextViewer viewer,
		IRegion region) {
	try {
		String prefix = viewer.getDocument().get(region.getOffset(), region.getLength());
		int parameterCount = parseParameters(prefix).size();
		TemplateContextType type = ParametrizedTemplateTypeDescriptor.findTemplateType(parameterCount);
		if (type != null) {
			return type;
		}
	} 
	catch (BadLocationException ex) {
		BfActivator.getDefault().logError("Context type could not be evaluated", ex);
	}
	return ParametrizedTemplateTypeDescriptor.NoParameters.templateType;
}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:17,代码来源:BfTemplateCompletionProcessor.java

示例10: createContext

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
@Override
protected TemplateContext createContext(ITextViewer viewer, IRegion region) {
	TemplateContext context = null;
	TemplateContextType contextType= getContextType(viewer, region);
	if (contextType != null) {
		IDocument document= viewer.getDocument();
		context =  new BfTemplateContext(contextType, document, region.getOffset(), region.getLength());
	}
	if (context == null) {
		return null;
	}
	try {
		String prefix = viewer.getDocument().get(region.getOffset(), region.getLength());
		int i = 0;
		for (String param : parseParameters(prefix)) {
			context.setVariable("x" + (i++), param);
		}
	} 
	catch (BadLocationException ex) {
		BfActivator.getDefault().logError("Prefix for Template could not be computed", ex);
	}
	return context;
}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:24,代码来源:BfTemplateCompletionProcessor.java

示例11: evaluateTemplate

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
/**
 * Evaluates a 'java' template in the context of a compilation unit
 *
 * @param template the template to be evaluated
 * @param compilationUnit the compilation unit in which to evaluate the template
 * @param position the position inside the compilation unit for which to evaluate the template
 * @return the evaluated template
 * @throws CoreException in case the template is of an unknown context type
 * @throws BadLocationException in case the position is invalid in the compilation unit
 * @throws TemplateException in case the evaluation fails
 */
public static String evaluateTemplate(Template template, ICompilationUnit compilationUnit, int position) throws CoreException, BadLocationException, TemplateException {

	TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(template.getContextTypeId());
	if (!(contextType instanceof CompilationUnitContextType))
		throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, JavaTemplateMessages.JavaContext_error_message, null));

	IDocument document= new Document();
	if (compilationUnit != null && compilationUnit.exists())
		document.set(compilationUnit.getSource());

	CompilationUnitContext context= ((CompilationUnitContextType) contextType).createContext(document, position, 0, compilationUnit);
	context.setForceEvaluation(true);

	TemplateBuffer buffer= context.evaluate(template);
	if (buffer == null)
		return null;
	return buffer.getString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:JavaContext.java

示例12: getTemplateContextRegistry

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
/**
 * Returns the template context type registry for the java plug-in.
 *
 * @return the template context type registry for the java plug-in
 * @since 3.0
 */
public synchronized ContextTypeRegistry getTemplateContextRegistry() {
	if (fContextTypeRegistry == null) {
		ContributionContextTypeRegistry registry= new ContributionContextTypeRegistry(JavaUI.ID_CU_EDITOR);

		TemplateContextType all_contextType= registry.getContextType(JavaContextType.ID_ALL);
		((AbstractJavaContextType) all_contextType).initializeContextTypeResolvers();

		registerJavaContext(registry, JavaContextType.ID_MEMBERS, all_contextType);
		registerJavaContext(registry, JavaContextType.ID_STATEMENTS, all_contextType);

		registerJavaContext(registry, SWTContextType.ID_ALL, all_contextType);
		all_contextType= registry.getContextType(SWTContextType.ID_ALL);

		registerJavaContext(registry, SWTContextType.ID_MEMBERS, all_contextType);
		registerJavaContext(registry, SWTContextType.ID_STATEMENTS, all_contextType);

		fContextTypeRegistry= registry;
	}

	return fContextTypeRegistry;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:JavaPlugin.java

示例13: updatePatternViewer

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
@Override
protected void updatePatternViewer(Template template) {
	if (template == null) {
		getPatternViewer().getDocument().set(""); //$NON-NLS-1$
		return ;
	}
	String contextId= template.getContextTypeId();
	TemplateContextType type= getContextTypeRegistry().getContextType(contextId);
	fTemplateProcessor.setContextType(type);

	IDocument doc= getPatternViewer().getDocument();

	String start= null;
	if ("javadoc".equals(contextId)) { //$NON-NLS-1$
		start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
	} else
		start= ""; //$NON-NLS-1$

	doc.set(start + template.getPattern());
	int startLen= start.length();
	getPatternViewer().setDocument(doc, startLen, doc.getLength() - startLen);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaTemplatesPage.java

示例14: getHoverInfo

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
public String getHoverInfo(ITextViewer textViewer, IRegion subject) {
	try {
		IDocument doc= textViewer.getDocument();
		int offset= subject.getOffset();
		if (offset >= 2 && "${".equals(doc.get(offset-2, 2))) { //$NON-NLS-1$
			String varName= doc.get(offset, subject.getLength());
			TemplateContextType contextType= fProcessor.getContextType();
			if (contextType != null) {
				Iterator<TemplateVariableResolver> iter= contextType.resolvers();
				while (iter.hasNext()) {
					TemplateVariableResolver var= iter.next();
					if (varName.equals(var.getType())) {
						return var.getDescription();
					}
				}
			}
		}
	} catch (BadLocationException e) {
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:CodeTemplateSourceViewerConfiguration.java

示例15: JavaStatementPostfixContext

import org.eclipse.jface.text.templates.TemplateContextType; //导入依赖的package包/类
public JavaStatementPostfixContext(
		TemplateContextType type,
		IDocument document, int offset, int length,
		ICompilationUnit compilationUnit,
		ASTNode currentNode,
		ASTNode parentNode) {
	super(type, document, offset, length, compilationUnit);
	
	this.nodeRegions = new HashMap<>();
	
	this.currentCompletionNode = currentNode;
	nodeRegions.put(currentNode, calculateNodeRegion(currentNode));

	this.currentCompletionNodeParent = parentNode;
	nodeRegions.put(parentNode, calculateNodeRegion(parentNode));
	
	this.selectedNode = currentNode;
	
	outOfRangeOffsets = new HashMap<>();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:JavaStatementPostfixContext.java


注:本文中的org.eclipse.jface.text.templates.TemplateContextType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。