本文整理汇总了Java中org.eclipse.jface.text.templates.TemplateTranslator.translate方法的典型用法代码示例。如果您正苦于以下问题:Java TemplateTranslator.translate方法的具体用法?Java TemplateTranslator.translate怎么用?Java TemplateTranslator.translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.templates.TemplateTranslator
的用法示例。
在下文中一共展示了TemplateTranslator.translate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例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 =
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;
}