本文整理汇总了Java中org.eclipse.jdt.internal.corext.template.java.JavaContext类的典型用法代码示例。如果您正苦于以下问题:Java JavaContext类的具体用法?Java JavaContext怎么用?Java JavaContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaContext类属于org.eclipse.jdt.internal.corext.template.java包,在下文中一共展示了JavaContext类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import org.eclipse.jdt.internal.corext.template.java.JavaContext; //导入依赖的package包/类
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
List<String> params= variable.getVariableType().getParams();
if (params.size() != 0 && context instanceof JavaContext) {
String param = params.get(0);
JavaStatementPostfixContext jc = (JavaStatementPostfixContext) context;
TemplateVariable ref = jc.getTemplateVariable(param);
MultiVariable mv= (MultiVariable) variable;
if (ref instanceof JavaVariable) {
// Reference is another variable
JavaVariable refVar= (JavaVariable) ref;
jc.addDependency(refVar, mv);
param = refVar.getParamType();
if (param != null && "".equals(param) == false) {
String reference= jc.addImportGenericClass(param);
mv.setValue(reference);
mv.setUnambiguous(true);
mv.setResolved(true);
return;
}
}
}
super.resolve(variable, context);
}
示例2: resolve
import org.eclipse.jdt.internal.corext.template.java.JavaContext; //导入依赖的package包/类
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
List<String> params= variable.getVariableType().getParams();
if (params.size() != 0 && context instanceof JavaContext) {
String param = params.get(0);
JavaContext jc = (JavaContext) context;
TemplateVariable ref = jc.getTemplateVariable(param);
MultiVariable mv= (MultiVariable) variable;
if (ref instanceof JavaVariable) {
// Reference is another variable
JavaVariable refVar= (JavaVariable) ref;
jc.addDependency(refVar, mv);
param = refVar.getParamType();
if (param != null && "".equals(param) == false) {
String reference= jc.addImport(param);
mv.setValue(reference);
mv.setUnambiguous(true);
mv.setResolved(true);
return;
}
}
}
super.resolve(variable, context);
}
示例3: initializeContext
import org.eclipse.jdt.internal.corext.template.java.JavaContext; //导入依赖的package包/类
@Override
protected void initializeContext(JavaContext context) {
if (!getId().equals(JFaceContextType.ID_ALL)) { // a specific context must also allow the templates that work
// everywhere
context.addCompatibleContextType(JFaceContextType.ID_ALL);
}
}
示例4: resolve
import org.eclipse.jdt.internal.corext.template.java.JavaContext; //导入依赖的package包/类
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
List<String> params= variable.getVariableType().getParams();
if (params.size() > 0 && context instanceof JavaContext) {
String param = params.get(0);
JavaStatementPostfixContext jc = (JavaStatementPostfixContext) context;
TemplateVariable ref = jc.getTemplateVariable(param);
MultiVariable mv = (MultiVariable) variable;
if (ref instanceof JavaVariable) {
// Reference is another variable
JavaVariable refVar = (JavaVariable) ref;
jc.addDependency(refVar, mv);
param = refVar.getParamType();
if (param != null && "".equals(param) == false) {
param = param.replace("? extends ", "");
if (param.endsWith("[]")) { // In case of List<Integer[]> we must not remove []
// Variable is an array, i.e. String[] or List<String>[]
// Actual type is supposed to be:
// String[] => String
// List<String>[] => List<String>
// String[][] => String[]
param = param.substring(0, param.length() - 2);
} else if (param.endsWith(">")) { // Generic
// Actual type of a generic is supposed to be:
// List<Integer> => Integer
// List<List<Integer>> => List<Integer>
// List<Map<Integer,String>> => Map<Integer,String>
// Map<Integer,String>> => Integer
// Something<Integer,Float,String> => Integer
param = param.substring(param.indexOf("<") + 1, param.lastIndexOf(">"));
if (!param.contains("<") && param.contains(",")) {
param = param.substring(0, param.indexOf(","));
}
} else {
// The given parameter is already an actual type
}
String reference = jc.addImportGenericClass(param);
mv.setValue(reference);
mv.setUnambiguous(true);
mv.setResolved(true);
return;
}
}
}
super.resolve(variable, context);
}
示例5: initializeContext
import org.eclipse.jdt.internal.corext.template.java.JavaContext; //导入依赖的package包/类
@Override
protected void initializeContext(JavaContext context) {
if (!getId().equals(JavaStatementPostfixContextType.ID_ALL)) { // a specific context must also allow the templates that work everywhere
context.addCompatibleContextType(JavaStatementPostfixContextType.ID_ALL);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:JavaStatementPostfixContextType.java
示例6: resolve
import org.eclipse.jdt.internal.corext.template.java.JavaContext; //导入依赖的package包/类
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
List<String> params= variable.getVariableType().getParams();
if (params.size() > 0 && context instanceof JavaContext) {
String param = params.get(0);
JavaContext jc = (JavaContext) context;
TemplateVariable ref = jc.getTemplateVariable(param);
MultiVariable mv = (MultiVariable) variable;
if (ref instanceof JavaVariable) {
// Reference is another variable
JavaVariable refVar = (JavaVariable) ref;
jc.addDependency(refVar, mv);
param = refVar.getParamType();
if (param != null && "".equals(param) == false) {
if (param.endsWith("[]")) { // In case of List<Integer[]> we must not remove []
// Variable is an array, i.e. String[] or List<String>[]
// Actual type is supposed to be:
// String[] => String
// List<String>[] => List<String>
// String[][] => String[]
param = param.substring(0, param.length() - 2);
} else if (param.endsWith(">")) { // Generic
// Actual type of a generic is supposed to be:
// List<Integer> => Integer
// List<List<Integer>> => List<Integer>
// List<Map<Integer,String>> => Map<Integer,String>
// Map<Integer,String>> => Integer
// Something<Integer,Float,String> => Integer
param = param.substring(param.indexOf("<") + 1, param.lastIndexOf(">"));
if (param.contains(",")) {
param = param.substring(0, param.indexOf(","));
}
} else {
// The given parameter is already an actual type
}
// TODO Check if addImport(..) works correctly in cases of param == java.util.List<java.lang.String>?! No, it does not :(
// Will not work in the following scenarios:
// actual type is something like java.util.List<java.lang.String> will lead to an output of List<java.lang.String>
// We will have to analyze the param string for all types and call addImport(..) for each single type
// and then replace all the occurrences in the param string
String reference = jc.addImport(param);
mv.setValue(reference);
mv.setUnambiguous(true);
mv.setResolved(true);
return;
}
}
}
super.resolve(variable, context);
}