当前位置: 首页>>代码示例>>Java>>正文


Java JavaModelUtil.getResolvedTypeName方法代码示例

本文整理汇总了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;
}
 
开发者ID:iloveeclipse,项目名称:datahierarchy,代码行数:17,代码来源:FieldReferencesRequestor.java

示例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;
    }
}
 
开发者ID:iloveeclipse,项目名称:datahierarchy,代码行数:15,代码来源:SearchUtils.java

示例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;
}
 
开发者ID:iloveeclipse,项目名称:datahierarchy,代码行数:16,代码来源:FieldReferencesRequestor.java

示例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 ? '-' : ')');
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:41,代码来源:JavaDocLocations.java

示例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(')');
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:33,代码来源:JavaDocLocations.java

示例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$
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:49,代码来源:CustomBuilderGenerator.java


注:本文中的org.eclipse.jdt.internal.corext.util.JavaModelUtil.getResolvedTypeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。