• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TemplateTranslator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
	// test that all variables are defined
	Iterator<TemplateVariableResolver> iterator= getContextType().resolvers();
	while (iterator.hasNext()) {
		TemplateVariableResolver var= iterator.next();
		if (var instanceof CodeTemplateContextType.CodeTemplateVariableResolver) {
			Assert.isNotNull(getVariable(var.getType()), "Variable " + var.getType() + "not defined"); //$NON-NLS-1$ //$NON-NLS-2$
		}
	}

	if (!canEvaluate(template)) {
		return null;
	}

	String pattern= changeLineDelimiter(template.getPattern(), fLineDelimiter);

	TemplateTranslator translator= new TemplateTranslator();
	TemplateBuffer buffer= translator.translate(pattern);
	getContextType().resolve(buffer, this);
	return buffer;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:CodeTemplateContext.java


示例2: createTemplateTranslator

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
protected TemplateTranslator createTemplateTranslator() {
	try {
		int offset = getStart();
		IRegion lineRegion = getDocument().getLineInformationOfOffset(offset);
		String line = getDocument().get(lineRegion.getOffset(), lineRegion.getLength());
		int i = 0;
		while(i < line.length() && Character.isWhitespace(line.charAt(i))) {
			i++;
		}
		if (i != 0)
			return new IndentationAwareTemplateTranslator(line.substring(0, i));
		return new TemplateTranslator();
	} catch(BadLocationException ex) {
		return new TemplateTranslator();
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:XtextTemplateContext.java


示例3: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
  // test that all variables are defined
  Iterator<TemplateVariableResolver> iterator = getContextType().resolvers();
  while (iterator.hasNext()) {
    TemplateVariableResolver var = iterator.next();
    if (var instanceof CodeTemplateContextType.CodeTemplateVariableResolver) {
      Assert.isNotNull(
          getVariable(var.getType()),
          "Variable " + var.getType() + "not defined"); // $NON-NLS-1$ //$NON-NLS-2$
    }
  }

  if (!canEvaluate(template)) return null;

  String pattern = changeLineDelimiter(template.getPattern(), fLineDelimiter);

  TemplateTranslator translator = new TemplateTranslator();
  TemplateBuffer buffer = translator.translate(pattern);
  getContextType().resolve(buffer, this);
  return buffer;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:CodeTemplateContext.java


示例4: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
  TemplateTranslator translator = new TemplateTranslator();
  TemplateBuffer buffer = translator.translate(template);

  getContextType().resolve(buffer, this);

  //		IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore();
  boolean useCodeFormatter =
      true; // prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);

  IJavaProject project = getJavaProject();
  JavaFormatter formatter =
      new JavaFormatter(
          TextUtilities.getDefaultLineDelimiter(getDocument()),
          getIndentation(),
          useCodeFormatter,
          project);
  formatter.format(buffer, this);

  return buffer;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:JavaDocContext.java


示例5: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException
{
	if (!canEvaluate(template))
		return null;

	try
	{
		this.template = template;

		TemplateTranslator translator = new SnippetTemplateTranslator();
		TemplateBuffer buffer = translator.translate(template);

		getContextType().resolve(buffer, this);

		return buffer;
	}
	finally
	{
		this.template = null;
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:22,代码来源:DocumentSnippetTemplateContext.java


示例6: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
	// test that all variables are defined
	Iterator<TemplateVariableResolver> iterator= getContextType().resolvers();
	while (iterator.hasNext()) {
		TemplateVariableResolver var= iterator.next();
		if (var instanceof CodeTemplateContextType.CodeTemplateVariableResolver) {
			Assert.isNotNull(getVariable(var.getType()), "Variable " + var.getType() + "not defined"); //$NON-NLS-1$ //$NON-NLS-2$
		}
	}

	if (!canEvaluate(template))
		return null;

	String pattern= changeLineDelimiter(template.getPattern(), fLineDelimiter);

	TemplateTranslator translator= new TemplateTranslator();
	TemplateBuffer buffer= translator.translate(pattern);
	getContextType().resolve(buffer, this);
	return buffer;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:CodeTemplateContext.java


示例7: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
	TemplateTranslator translator= new TemplateTranslator();
	TemplateBuffer buffer= translator.translate(template);

	getContextType().resolve(buffer, this);

	IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore();
	boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);

	IJavaProject project= getJavaProject();
	JavaFormatter formatter= new JavaFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), getIndentation(), useCodeFormatter, project);
	formatter.format(buffer, this);

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


示例8: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
	if (!canEvaluate(template))
		return null;

	TemplateTranslator translator= createTemplateTranslator();
	TemplateBuffer buffer= translator.translate(template);

	getContextType().resolve(buffer, this);

	return buffer;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:13,代码来源:XtextTemplateContext.java


示例9: evaluateForDisplay

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
/**
 * @since 2.3
 */
public TemplateBuffer evaluateForDisplay(Template template) throws BadLocationException, TemplateException {
	if (!canEvaluate(template))
		return null;
	
	TemplateTranslator translator= new TemplateTranslator();
	TemplateBuffer buffer= translator.translate(template);
	
	getContextType().resolve(buffer, this);
	
	return buffer;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:XtextTemplateContext.java


示例10: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
    if (!canEvaluate(template))
        return null;

    TemplateTranslator translator = createTemplateTranslator();
    TemplateBuffer buffer = translator.translate(template);

    getContextType().resolve(buffer, this);

    return buffer;
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:13,代码来源:SwaggerTemplateContext.java


示例11: evaluateForDisplay

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
/**
 * @since 2.3
 */
public TemplateBuffer evaluateForDisplay(Template template) throws BadLocationException, TemplateException {
    if (!canEvaluate(template))
        return null;

    TemplateTranslator translator = new TemplateTranslator();
    TemplateBuffer buffer = translator.translate(template);

    getContextType().resolve(buffer, this);

    return buffer;
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:15,代码来源:SwaggerTemplateContext.java


示例12: createTemplateTranslator

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
protected TemplateTranslator createTemplateTranslator() {
    try {
        int offset = getStart();
        IRegion lineRegion = getDocument().getLineInformationOfOffset(offset);
        String line = getDocument().get(lineRegion.getOffset(), lineRegion.getLength());
        int i = 0;
        // support for array items
        StringBuilder indentation = new StringBuilder();
        while (i < line.length()) {
            char indentSymbol = line.charAt(i);
            if (Character.isWhitespace(indentSymbol)) {
                indentation.append(indentSymbol);
                i++;
            } else if ('-' == indentSymbol) {// array item
                indentation.append(' ');
                i++;
            } else {
                break;
            }
        }
        if (i != 0)
            return new IndentationAwareTemplateTranslator(indentation.toString());
        return new TemplateTranslator();
    } catch (BadLocationException ex) {
        return new TemplateTranslator();
    }
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:28,代码来源:SwaggerTemplateContext.java


示例13: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
	public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
		clear();

		if (!canEvaluate(template))
			throw new TemplateException(JavaTemplateMessages.Context_error_cannot_evaluate);

		TemplateTranslator translator= new TemplateTranslator() {
			@Override
			protected TemplateVariable createVariable(TemplateVariableType type, String name, int[] offsets) {
//				TemplateVariableResolver resolver= getContextType().getResolver(type.getName());
//				return resolver.createVariable();

				MultiVariable variable= new JavaVariable(type, name, offsets);
				fVariables.put(name, variable);
				return variable;
			}
		};
		TemplateBuffer buffer= translator.translate(template);

		getContextType().resolve(buffer, this);

		rewriteImports();

		IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore();
		boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);

		IJavaProject project= getJavaProject();
		JavaFormatter formatter= new JavaFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), getIndentation(), useCodeFormatter, project);
		formatter.format(buffer, this);

		clear();

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


示例14: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
public TemplateBuffer evaluate(Template template, boolean fixIndentation) 
			throws BadLocationException, TemplateException {
		if (!canEvaluate(template))
			return null;
		
		TemplateTranslator translator= new TemplateTranslator();
		
		String pattern = template.getPattern();
//		if(fixIndentation) {
//			pattern = fixIndentation(pattern);
//		}
		TemplateBuffer buffer = translator.translate(pattern);
		
		getContextType().resolve(buffer, this);
		
		if(fixIndentation) {
			String delimiter = TextUtilities.getDefaultLineDelimiter(getDocument());
			JavaFormatter formatter = new JavaFormatter(delimiter) {
				@Override
				protected void indent(IDocument document) throws BadLocationException, MalformedTreeException {
					simpleIndent(document);
				}
			};
			formatter.format(buffer, this);
		}
		
		return buffer;
	}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:29,代码来源:LangContext.java


示例15: evaluate

import org.eclipse.jface.text.templates.TemplateTranslator; //导入依赖的package包/类
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
  clear();

  if (!canEvaluate(template))
    throw new TemplateException(JavaTemplateMessages.Context_error_cannot_evaluate);

  TemplateTranslator translator =
      new TemplateTranslator() {
        @Override
        protected TemplateVariable createVariable(
            TemplateVariableType type, String name, int[] offsets) {
          //				TemplateVariableResolver resolver= getContextType().getResolver(type.getName());
          //				return resolver.createVariable();

          MultiVariable variable = new JavaVariable(type, name, offsets);
          fVariables.put(name, variable);
          return variable;
        }
      };
  TemplateBuffer buffer = translator.translate(template);

  getContextType().resolve(buffer, this);

  rewriteImports();

  //		IPreferenceStore prefs = JavaPlugin.getDefault().getPreferenceStore();
  boolean useCodeFormatter =
      true; // prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);

  IJavaProject project = getJavaProject();
  JavaFormatter formatter =
      new JavaFormatter(
          TextUtilities.getDefaultLineDelimiter(getDocument()),
          getIndentation(),
          useCodeFormatter,
          project);
  formatter.format(buffer, this);

  clear();

  return buffer;
}
 
开发者ID:eclipse,项目名称:che,代码行数:44,代码来源:JavaContext.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DoubleLiteralExpr类代码示例发布时间:2022-05-22
下一篇:
Java SelectByExampleWithoutBLOBsMethodGenerator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap