• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java XtextTemplateContextType类的典型用法和代码示例

java 1次浏览

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

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

示例1: applyTemplateAtTheEnd

点赞 3

import org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType; //导入依赖的package包/类
/**
 * @see msi.gama.lang.gaml.ui.editor.IGamlEditor#applyTemplate(org.eclipse.jface.text.templates.Template)
 */

public void applyTemplateAtTheEnd(final Template t) {

	try {
		final IDocument doc = getDocument();
		int offset = doc.getLineOffset(doc.getNumberOfLines() - 1);
		doc.replace(offset, 0, "\n\n");
		offset += 2;
		final int length = 0;
		final Position pos = new Position(offset, length);
		final XtextTemplateContextType ct = new XtextTemplateContextType();
		final DocumentTemplateContext dtc = new DocumentTemplateContext(ct, doc, pos);
		final IRegion r = new Region(offset, length);
		final TemplateProposal tp = new TemplateProposal(t, dtc, r, null);
		tp.apply(getInternalSourceViewer(), (char) 0, 0, offset);
	} catch (final BadLocationException e) {
		e.printStackTrace();
	}
}
 

开发者ID:gama-platform,
项目名称:gama,
代码行数:23,
代码来源:GamlEditor.java

示例2: applyTemplate

点赞 2

import org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType; //导入依赖的package包/类
public void applyTemplate(final Template t) {
	// TODO Create a specific context type (with GAML specific variables ??)
	final XtextTemplateContextType ct = new XtextTemplateContextType();
	final IDocument doc = getDocument();
	final ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
	final int offset = selection.getOffset();
	final int length = selection.getLength();
	final Position pos = new Position(offset, length);
	final DocumentTemplateContext dtc = new DocumentTemplateContext(ct, doc, pos);
	final IRegion r = new Region(offset, length);
	final TemplateProposal tp = new TemplateProposal(t, dtc, r, null);
	tp.apply(getInternalSourceViewer(), (char) 0, 0, offset);
}
 

开发者ID:gama-platform,
项目名称:gama,
代码行数:14,
代码来源:GamlEditor.java

示例3: createTemplateProposal

点赞 2

import org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType; //导入依赖的package包/类
protected ICompletionProposal createTemplateProposal(
		TemplateIssueResolution res) {
	try {
		TemplateContextSupplier fac = res.getContextFactory();
		IDocument doc = XtextDocumentUtil.get(qaCtx.getSourceViewer());
		Position pos = fac.getPosition(doc, qaCtx);
		String prefix = fac.getPrefix(doc, qaCtx);
		String postfix = fac.getPostfix(doc, qaCtx);
		Map<String, String> vars = fac.getVariables(doc, qaCtx);
		Region r = new Region(pos.getOffset(), pos.getLength());
		ContentAssistContext cactx = builderProvider.get()
				.setOffset(pos.getOffset()).setPrefix(prefix)
				.setViewer(qaCtx.getSourceViewer()).toContext();

		// create a TemplateProposalContext
		Image i = ((DefaultTemplateProposalProvider) templatePP)
				.getImage(res.getTemplate());
		XtextTemplateContextType type = templateCtxTypeProvider.get();
		XtextTemplateContext tplctx = new QuickfixTemplateContext(type,
				doc, pos, cactx, scopeProvider, prefix, postfix);
		for (Map.Entry<String, String> e : vars.entrySet())
			tplctx.setVariable(e.getKey(), e.getValue());

		// create a TemplateProposal
		XtextTemplateProposal proposal = new XtextTemplateProposal(
				res.getTemplate(), tplctx, r, i);
		return proposal;
	} catch (RuntimeException e1) {
		throw e1;
	} catch (Exception e2) {
		throw new WrappedException(e2);
	}
}
 

开发者ID:crapo,
项目名称:sadlos2,
代码行数:34,
代码来源:TemplateQuickAssistProcessor.java

示例4: bindXtextTemplateContextType

点赞 2

import org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType; //导入依赖的package包/类
@Override
public Class<? extends XtextTemplateContextType> bindXtextTemplateContextType() {
  return CheckTemplateContextType.class;
}
 

开发者ID:dsldevkit,
项目名称:dsl-devkit,
代码行数:5,
代码来源:CheckUiModule.java

示例5: bindTemplateContextType

点赞 2

import org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType; //导入依赖的package包/类
public Class<? extends XtextTemplateContextType> bindTemplateContextType() {
	return SadlTemplateContextType.class;
}
 

开发者ID:crapo,
项目名称:sadlos2,
代码行数:4,
代码来源:SadlUiModule.java

示例6: TerminalRuleAwareTemplateContextTypeRegistry

点赞 2

import org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType; //导入依赖的package包/类
@Inject
public TerminalRuleAwareTemplateContextTypeRegistry(final IGrammarAccess grammarAccess, final Provider<XtextTemplateContextType> ctxTypeProvider, final ContextTypeIdHelper helper) {
  super(grammarAccess, ctxTypeProvider, helper);
}
 

开发者ID:RobertWalter83,
项目名称:DialogScriptDSL,
代码行数:5,
代码来源:TerminalRuleAwareTemplateContextTypeRegistry.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)