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


Java Template.getContextTypeId方法代码示例

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


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

示例1: getSetterMethodBodyContent

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getSetterMethodBodyContent(IJavaProject project, String destTypeName, String methodName, String fieldName, String paramName, String lineDelimiter) throws CoreException {
	CodeGenerationTemplate templateSetting = CodeGenerationTemplate.SETTERBOY;
	Template template = templateSetting.createTemplate(project);
	if (template == null) {
		return null;
	}
	CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);

	context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
	context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
	context.setVariable(CodeTemplateContextType.FIELD, fieldName);
	context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldName);
	context.setVariable(CodeTemplateContextType.PARAM, paramName);

	return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:StubUtility.java

示例2: getSetterComment

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getSetterComment(ICompilationUnit cu, String typeName, String methodName, String fieldName, String fieldType, String paramName, String bareFieldName, String lineDelimiter) throws CoreException {
	CodeGenerationTemplate templateSetting = CodeGenerationTemplate.SETTERCOMMENT;
	Template template = templateSetting.createTemplate(cu.getJavaProject());
	if (template == null) {
		return null;
	}
	CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);

	context.setCompilationUnitVariables(cu);
	context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
	context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
	context.setVariable(CodeTemplateContextType.FIELD, fieldName);
	context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldType);
	context.setVariable(CodeTemplateContextType.BARE_FIELD_NAME, bareFieldName);
	context.setVariable(CodeTemplateContextType.PARAM, paramName);

	return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:19,代码来源:StubUtility.java

示例3: getGetterComment

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterComment(ICompilationUnit cu, String typeName, String methodName, String fieldName, String fieldType, String bareFieldName, String lineDelimiter) throws CoreException {
	CodeGenerationTemplate templateSetting = CodeGenerationTemplate.GETTERCOMMENT;
	Template template = templateSetting.createTemplate(cu.getJavaProject());
	if (template == null) {
		return null;
	}
	CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);

	context.setCompilationUnitVariables(cu);
	context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
	context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
	context.setVariable(CodeTemplateContextType.FIELD, fieldName);
	context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldType);
	context.setVariable(CodeTemplateContextType.BARE_FIELD_NAME, bareFieldName);

	return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:StubUtility.java

示例4: getColumnText

import org.eclipse.jface.text.templates.Template; //导入方法依赖的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: getGetterMethodBodyContent

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterMethodBodyContent(
    IJavaProject project,
    String destTypeName,
    String methodName,
    String fieldName,
    String lineDelimiter)
    throws CoreException {
  String templateName = CodeTemplateContextType.GETTERSTUB_ID;
  Template template = getCodeTemplate(templateName, project);
  if (template == null) {
    return null;
  }
  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
  context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
  context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
  context.setVariable(CodeTemplateContextType.FIELD, fieldName);

  return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:StubUtility.java

示例6: getSetterMethodBodyContent

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getSetterMethodBodyContent(
    IJavaProject project,
    String destTypeName,
    String methodName,
    String fieldName,
    String paramName,
    String lineDelimiter)
    throws CoreException {
  String templateName = CodeTemplateContextType.SETTERSTUB_ID;
  Template template = getCodeTemplate(templateName, project);
  if (template == null) {
    return null;
  }
  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
  context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
  context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
  context.setVariable(CodeTemplateContextType.FIELD, fieldName);
  context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldName);
  context.setVariable(CodeTemplateContextType.PARAM, paramName);

  return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:StubUtility.java

示例7: getCatchBodyContent

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getCatchBodyContent(
    ICompilationUnit cu,
    String exceptionType,
    String variableName,
    String enclosingType,
    String enclosingMethod,
    String lineDelimiter)
    throws CoreException {
  Template template = getCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, cu.getJavaProject());
  if (template == null) {
    return null;
  }

  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
  context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, enclosingType);
  context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, enclosingMethod);
  context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE, exceptionType);
  context.setVariable(CodeTemplateContextType.EXCEPTION_VAR, variableName);
  return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:StubUtility.java

示例8: getFileComment

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getFileComment(ICompilationUnit cu, String lineDelimiter)
    throws CoreException {
  Template template =
      getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, cu.getJavaProject());
  if (template == null) {
    return null;
  }

  IJavaProject project = cu.getJavaProject();
  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
  context.setCompilationUnitVariables(cu);
  context.setVariable(
      CodeTemplateContextType.TYPENAME, JavaCore.removeJavaLikeExtension(cu.getElementName()));
  return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:StubUtility.java

示例9: getTypeBody

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
/**
 * Don't use this method directly, use CodeGeneration.
 *
 * @param templateID the template id of the type body to get. Valid id's are {@link
 *     CodeTemplateContextType#CLASSBODY_ID}, {@link CodeTemplateContextType#INTERFACEBODY_ID},
 *     {@link CodeTemplateContextType#ENUMBODY_ID}, {@link
 *     CodeTemplateContextType#ANNOTATIONBODY_ID},
 * @param cu the compilation unit to which the template is added
 * @param typeName the type name
 * @param lineDelim the line delimiter to use
 * @return return the type body template or <code>null</code>
 * @throws CoreException thrown if the template could not be evaluated
 * @see org.eclipse.jdt.ui.CodeGeneration#getTypeBody(String, ICompilationUnit, String, String)
 */
public static String getTypeBody(
    String templateID, ICompilationUnit cu, String typeName, String lineDelim)
    throws CoreException {
  if (!VALID_TYPE_BODY_TEMPLATES.contains(templateID)) {
    throw new IllegalArgumentException("Invalid code template ID: " + templateID); // $NON-NLS-1$
  }

  Template template = getCodeTemplate(templateID, cu.getJavaProject());
  if (template == null) {
    return null;
  }
  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelim);
  context.setCompilationUnitVariables(cu);
  context.setVariable(CodeTemplateContextType.TYPENAME, typeName);

  return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:StubUtility.java

示例10: getFieldComment

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getFieldComment(
    ICompilationUnit cu, String typeName, String fieldName, String lineDelimiter)
    throws CoreException {
  Template template =
      getCodeTemplate(CodeTemplateContextType.FIELDCOMMENT_ID, cu.getJavaProject());
  if (template == null) {
    return null;
  }
  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
  context.setCompilationUnitVariables(cu);
  context.setVariable(CodeTemplateContextType.FIELD_TYPE, typeName);
  context.setVariable(CodeTemplateContextType.FIELD, fieldName);

  return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:StubUtility.java

示例11: getGetterComment

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterComment(
    ICompilationUnit cu,
    String typeName,
    String methodName,
    String fieldName,
    String fieldType,
    String bareFieldName,
    String lineDelimiter)
    throws CoreException {
  String templateName = CodeTemplateContextType.GETTERCOMMENT_ID;
  Template template = getCodeTemplate(templateName, cu.getJavaProject());
  if (template == null) {
    return null;
  }
  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
  context.setCompilationUnitVariables(cu);
  context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
  context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
  context.setVariable(CodeTemplateContextType.FIELD, fieldName);
  context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldType);
  context.setVariable(CodeTemplateContextType.BARE_FIELD_NAME, bareFieldName);

  return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:StubUtility.java

示例12: getOverridingMethodComment

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
private String getOverridingMethodComment() {
  String templateName = CodeTemplateContextType.OVERRIDECOMMENT_ID;

  Template template = getCodeTemplate(templateName);
  if (template == null) return ""; // $NON-NLS-1$

  CodeTemplateContext context =
      new CodeTemplateContext(template.getContextTypeId(), null, "\n"); // $NON-NLS-1$

  context.setVariable(CodeTemplateContextType.FILENAME, "Face.java"); // $NON-NLS-1$
  context.setVariable(CodeTemplateContextType.PACKAGENAME, "test"); // $NON-NLS-1$
  context.setVariable(CodeTemplateContextType.PROJECTNAME, "TestProject"); // $NON-NLS-1$
  context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, "Face"); // $NON-NLS-1$
  context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, "method"); // $NON-NLS-1$
  context.setVariable(CodeTemplateContextType.RETURN_TYPE, "void"); // $NON-NLS-1$
  context.setVariable(
      CodeTemplateContextType.SEE_TO_OVERRIDDEN_TAG, "test.IFace#foo()"); // $NON-NLS-1$

  return evaluateTemplate(template, context);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:UnimplementedCodeCleanUp.java

示例13: getGetterMethodBodyContent

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterMethodBodyContent(IJavaProject project, String destTypeName, String methodName, String fieldName, String lineDelimiter) throws CoreException {
	CodeGenerationTemplate templateSetting = CodeGenerationTemplate.GETTERBODY;
	Template template = templateSetting.createTemplate(project);
	if (template == null) {
		return null;
	}
	CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);

	context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
	context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
	context.setVariable(CodeTemplateContextType.FIELD, fieldName);

	return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:15,代码来源:StubUtility.java

示例14: getCatchBodyContent

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getCatchBodyContent(ICompilationUnit cu, String exceptionType, String variableName, String enclosingType, String enclosingMethod, String lineDelimiter) throws CoreException {
	// Template template = getCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, cu.getJavaProject());
	CodeGenerationTemplate templateSetting = CodeGenerationTemplate.CATCHBODY;
	Template template = templateSetting.createTemplate(cu.getJavaProject());
	if (template == null) {
		return null;
	}

	CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
	context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, enclosingType);
	context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, enclosingMethod);
	context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE, exceptionType);
	context.setVariable(CodeTemplateContextType.EXCEPTION_VAR, variableName);
	return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:StubUtility.java

示例15: getFieldComment

import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getFieldComment(ICompilationUnit cu, String typeName, String fieldName, String lineDelimiter) throws CoreException {
	Template template = CodeGenerationTemplate.FIELDCOMMENT.createTemplate(cu.getJavaProject());
	if (template == null) {
		return null;
	}
	CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
	context.setCompilationUnitVariables(cu);
	context.setVariable(CodeTemplateContextType.FIELD_TYPE, typeName);
	context.setVariable(CodeTemplateContextType.FIELD, fieldName);

	return evaluateTemplate(context, template);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:StubUtility.java


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