本文整理汇总了Java中org.eclipse.jdt.internal.corext.util.JavaModelUtil.getResolvedTypeName方法的典型用法代码示例。如果您正苦于以下问题:Java JavaModelUtil.getResolvedTypeName方法的具体用法?Java JavaModelUtil.getResolvedTypeName怎么用?Java JavaModelUtil.getResolvedTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.util.JavaModelUtil
的用法示例。
在下文中一共展示了JavaModelUtil.getResolvedTypeName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFieldTypeFiltered
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public IType getFieldTypeFiltered(IField field) {
String signature;
try {
signature = field.getTypeSignature();
IType primaryType = field.getTypeRoot().findPrimaryType();
String name = JavaModelUtil.getResolvedTypeName(signature, primaryType);
if (name == null || isFiltered(name)) {
return null;
}
return field.getJavaProject().findType(name);
} catch (JavaModelException e) {
DataHierarchyPlugin.logError("getUnfilteredFieldType() failed for field: " + field, e);
}
return null;
}
示例2: getResolvedType
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public static String getResolvedType(String signature, IField field) {
if (signature == null) {
return null;
}
// have to resolve types now...
IType primaryType = field.getTypeRoot().findPrimaryType();
try {
return JavaModelUtil.getResolvedTypeName(signature, primaryType);
} catch (JavaModelException e) {
DataHierarchyPlugin.logError("getResolvedTypeName() failed for field: " + field, e);
return null;
}
}
示例3: getFieldType
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
public static IType getFieldType(IField field) {
String signature;
try {
signature = field.getTypeSignature();
IType primaryType = field.getTypeRoot().findPrimaryType();
String name = JavaModelUtil.getResolvedTypeName(signature, primaryType);
if (name == null) {
return null;
}
return field.getJavaProject().findType(name);
} catch (JavaModelException e) {
DataHierarchyPlugin.logError("getFieldType() failed for field: " + field, e);
}
return null;
}
示例4: appendMethodReference
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private static void appendMethodReference(IMethod meth, StringBuffer buf) throws JavaModelException {
buf.append(meth.getElementName());
/*
* The Javadoc tool for Java SE 8 changed the anchor syntax and now tries to avoid "strange" characters in URLs.
* This breaks all clients that directly create such URLs.
* We can't know what format is required, so we just guess by the project's compiler compliance.
*/
boolean is18OrHigher= JavaModelUtil.is18OrHigher(meth.getJavaProject());
buf.append(is18OrHigher ? '-' : '(');
String[] params= meth.getParameterTypes();
IType declaringType= meth.getDeclaringType();
boolean isVararg= Flags.isVarargs(meth.getFlags());
int lastParam= params.length - 1;
for (int i= 0; i <= lastParam; i++) {
if (i != 0) {
buf.append(is18OrHigher ? "-" : ", "); //$NON-NLS-1$ //$NON-NLS-2$
}
String curr= Signature.getTypeErasure(params[i]);
String fullName= JavaModelUtil.getResolvedTypeName(curr, declaringType);
if (fullName == null) { // e.g. a type parameter "QE;"
fullName= Signature.toString(Signature.getElementType(curr));
}
if (fullName != null) {
buf.append(fullName);
int dim= Signature.getArrayCount(curr);
if (i == lastParam && isVararg) {
dim--;
}
while (dim > 0) {
buf.append(is18OrHigher ? ":A" : "[]"); //$NON-NLS-1$ //$NON-NLS-2$
dim--;
}
if (i == lastParam && isVararg) {
buf.append("..."); //$NON-NLS-1$
}
}
}
buf.append(is18OrHigher ? '-' : ')');
}
示例5: appendMethodReference
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private static void appendMethodReference(IMethod meth, StringBuffer buf) throws JavaModelException {
buf.append('#');
buf.append(meth.getElementName());
buf.append('(');
String[] params= meth.getParameterTypes();
IType declaringType= meth.getDeclaringType();
boolean isVararg= Flags.isVarargs(meth.getFlags());
int lastParam= params.length - 1;
for (int i= 0; i <= lastParam; i++) {
if (i != 0) {
buf.append(", "); //$NON-NLS-1$
}
String curr= Signature.getTypeErasure(params[i]);
String fullName= JavaModelUtil.getResolvedTypeName(curr, declaringType);
if (fullName != null) {
buf.append(fullName);
int dim= Signature.getArrayCount(curr);
if (i == lastParam && isVararg) {
dim--;
}
while (dim > 0) {
buf.append("[]"); //$NON-NLS-1$
dim--;
}
if (i == lastParam && isVararg) {
buf.append("..."); //$NON-NLS-1$
}
}
}
buf.append(')');
}
示例6: fillAppendMethodsMap
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
/**
* Searches through methods with proper name and for each argument type remembers the best
* option
*/
private void fillAppendMethodsMap() {
try {
IJavaProject javaProject= getContext().getTypeBinding().getJavaElement().getJavaProject();
IType type= javaProject.findType(getContext().getCustomBuilderClass());
IType[] types= type.newSupertypeHierarchy(null).getAllClasses();
for (int i= 0; i < types.length; i++) {
IMethod[] methods= types[i].getMethods();
for (int j= 0; j < methods.length; j++) {
if (!Flags.isPublic(methods[j].getFlags()) || !methods[j].getElementName().equals(getContext().getCustomBuilderAppendMethod()))
continue;
String[] parameterTypes= methods[j].getParameterTypes();
AppendMethodInformation appendMethodInformation= new AppendMethodInformation();
String specyficType;
if (parameterTypes.length == 1) {
specyficType= JavaModelUtil.getResolvedTypeName(parameterTypes[0], types[i]);
appendMethodInformation.methodType= 1;
} else if (parameterTypes.length == 2) {
String resolvedParameterTypeName1= JavaModelUtil.getResolvedTypeName(parameterTypes[0], types[i]);
String resolvedParameterTypeName2= JavaModelUtil.getResolvedTypeName(parameterTypes[1], types[i]);
if (resolvedParameterTypeName1.equals("java.lang.String")) {//$NON-NLS-1$
specyficType= resolvedParameterTypeName2;
appendMethodInformation.methodType= 3;
} else if (resolvedParameterTypeName2.equals("java.lang.String")) {//$NON-NLS-1$
specyficType= resolvedParameterTypeName1;
appendMethodInformation.methodType= 2;
} else
continue;
} else
continue;
String returnTypeName= JavaModelUtil.getResolvedTypeName(methods[j].getReturnType(), types[i]);
IType returnType= javaProject.findType(returnTypeName);
appendMethodInformation.returnsBuilder= (returnType != null) && returnType.newSupertypeHierarchy(null).contains(type);
AppendMethodInformation oldAMI= appendMethodSpecificTypes.get(specyficType);
if (oldAMI == null || oldAMI.methodType < appendMethodInformation.methodType) {
appendMethodSpecificTypes.put(specyficType, appendMethodInformation);
}
}
}
} catch (JavaModelException e) {
throw new RuntimeException("couldn't initialize custom toString() builder generator", e); //$NON-NLS-1$
}
}