本文整理汇总了Java中org.eclipse.jface.text.templates.Template.getPattern方法的典型用法代码示例。如果您正苦于以下问题:Java Template.getPattern方法的具体用法?Java Template.getPattern怎么用?Java Template.getPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.templates.Template
的用法示例。
在下文中一共展示了Template.getPattern方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTemplates
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected Template[] getTemplates(String contextTypeId) {
if (contextType.getId().equals(contextTypeId)) {
Template[] computedTemplates = null;
if (templates != null) {
computedTemplates = templates.getTemplate().toArray(new Template[templates.getTemplate().size()]);
}
TemplateStore templateStore = CustomTemplateAccess.getInstance().getTemplateStore();
if (templateStore != null) {
Template[] customTemplates = templateStore.getTemplates(contextTypeId);
if (customTemplates != null && customTemplates.length > 0) {
if (computedTemplates == null) {
computedTemplates = customTemplates;
} else {
List<Template> allTempaltes = new ArrayList<Template>(
computedTemplates.length + customTemplates.length);
allTempaltes.addAll(Arrays.asList(computedTemplates));
allTempaltes.addAll(Arrays.asList(customTemplates));
computedTemplates = allTempaltes.toArray(new Template[allTempaltes.size()]);
}
}
}
if (computedTemplates != null) {
for (Template template : computedTemplates) {
String pattern = template.getPattern();
pattern = pattern.replace("\r\n", "\n");
pattern = pattern.replace("\n", Strings.EOL);
template.setPattern(pattern);
}
return computedTemplates;
}
}
return NO_TEMPLATES;
}
示例2: isSelectionBasedMatch
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
private boolean isSelectionBasedMatch(Template template, TemplateContext context) {
String pattern = template.getPattern();
Set<String> vars = new HashSet<String>();
Matcher matcher = VARIABLE_PATTERN.matcher(pattern);
while (matcher.find()) {
String variableName = matcher.group(1);
if (vars.add(variableName)) {
String variable = context.getVariable(variableName);
if (variable != null && variable.length() > 0) {
return true;
}
}
}
return false;
}
示例3: validate
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
protected boolean validate(Template template, ContentAssistContext context) {
boolean result = context.getMatcher().isCandidateMatchingPrefix(template.getName(), context.getPrefix());
if (result) {
try {
String pattern = template.getPattern();
if (proposalConflictHelper.existsConflict(pattern, context)) {
result = false;
}
} catch(Exception e) {
result = false;
}
}
return result;
}