本文整理汇总了Java中org.eclipse.jface.text.templates.TemplateContext.getVariable方法的典型用法代码示例。如果您正苦于以下问题:Java TemplateContext.getVariable方法的具体用法?Java TemplateContext.getVariable怎么用?Java TemplateContext.getVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.templates.TemplateContext
的用法示例。
在下文中一共展示了TemplateContext.getVariable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateValue
import org.eclipse.jface.text.templates.TemplateContext; //导入方法依赖的package包/类
@Override
int calculateValue(TemplateContext context) {
String parseValue = null;
if (this.isVariable) {
parseValue = context.getVariable(this.value);
if (parseValue == null) {
String contextInfo = "";
if (context instanceof DocumentTemplateContext) {
contextInfo = ": '" + ((DocumentTemplateContext) context).getKey() + "'";
}
throw new VariableEvaluationException("Variable " + this.value + " is undefined in context"+ contextInfo);
}
parseValue = this.sign + parseValue;
}
else {
parseValue = this.value;
}
try {
return Integer.parseInt(parseValue);
}
catch (NumberFormatException ex) {
throw new VariableEvaluationException(ex.getMessage(), ex);
}
}
示例2: isSelectionBasedMatch
import org.eclipse.jface.text.templates.TemplateContext; //导入方法依赖的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: resolve
import org.eclipse.jface.text.templates.TemplateContext; //导入方法依赖的package包/类
@Override
protected String resolve(TemplateContext context) {
String selection =
context.getVariable(org.eclipse.jface.text.templates.GlobalTemplateVariables.SELECTION);
if (selection == null) return ""; // $NON-NLS-1$
return selection;
}
示例4: resolve
import org.eclipse.jface.text.templates.TemplateContext; //导入方法依赖的package包/类
@Override
protected String resolve(TemplateContext context) {
String selection= context.getVariable(org.eclipse.jface.text.templates.GlobalTemplateVariables.SELECTION);
if (selection == null)
return ""; //$NON-NLS-1$
return selection;
}
示例5: resolve
import org.eclipse.jface.text.templates.TemplateContext; //导入方法依赖的package包/类
@Override
protected String resolve(TemplateContext context) {
return context.getVariable(getType());
}
示例6: resolve
import org.eclipse.jface.text.templates.TemplateContext; //导入方法依赖的package包/类
@Override
protected String resolve(TemplateContext context) {
return context.getVariable(getType());
}
示例7: resolve
import org.eclipse.jface.text.templates.TemplateContext; //导入方法依赖的package包/类
@Override
protected final String resolve(TemplateContext context) {
return context.getVariable(this.getType());
}