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


Java IMethod.getDeclaringType方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IMethod.getDeclaringType方法的典型用法代码示例。如果您正苦于以下问题:Java IMethod.getDeclaringType方法的具体用法?Java IMethod.getDeclaringType怎么用?Java IMethod.getDeclaringType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.IMethod的用法示例。


在下文中一共展示了IMethod.getDeclaringType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveTypeParameter

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
private static final boolean resolveTypeParameter(final IMethod method,
    final String identifier, final StringBuilder result)
    throws JavaModelException {
  IType type = method.getDeclaringType();
  if (resolveTypeParameter(type, method.getTypeParameters(), identifier,
      result)) {
    return true;
  }
  while (type != null) {
    if (resolveTypeParameter(type, type.getTypeParameters(), identifier,
        result)) {
      return true;
    }
    type = type.getDeclaringType();
  }
  return false;
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:18,代码来源:SignatureResolver.java

示例2: sameParameters

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
private static boolean sameParameters(IMethodBinding method, IMethod candidate) throws JavaModelException {
	ITypeBinding[] methodParamters= method.getParameterTypes();
	String[] candidateParameters= candidate.getParameterTypes();
	if (methodParamters.length != candidateParameters.length) {
		return false;
	}
	IType scope= candidate.getDeclaringType();
	for (int i= 0; i < methodParamters.length; i++) {
		ITypeBinding methodParameter= methodParamters[i];
		String candidateParameter= candidateParameters[i];
		if (!sameParameter(methodParameter, candidateParameter, scope)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:17,代码来源:Bindings.java

示例3: findDocInHierarchy

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
private static Reader findDocInHierarchy(IMethod method, boolean useAttachedJavadoc) throws JavaModelException {
	/*
	 * Catch ExternalJavaProject in which case
	 * no hierarchy can be built.
	 */
	if (!method.getJavaProject().exists()) {
		return null;
	}

	IType type= method.getDeclaringType();
	ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null);

	MethodOverrideTester tester= new MethodOverrideTester(type, hierarchy);

	IType[] superTypes= hierarchy.getAllSupertypes(type);
	for (IType curr : superTypes) {
		IMethod overridden= tester.findOverriddenMethodInType(curr, method);
		if (overridden != null) {
			Reader reader = getHTMLContentReader(overridden, false, useAttachedJavadoc);
			if (reader != null) {
				return reader;
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:JavadocContentAccess.java

示例4: resolveTypeSignature

import org.eclipse.jdt.core.IMethod; //导入方法依赖的package包/类
/**
 * Returns the resolved type signature for the given signature in the given
 * method, or <code>null</code> if unable to resolve.
 *
 * @param method method containing the type signature
 * @param typeSignature the type signature to resolve
 * @return the resolved type signature
 * @throws JavaModelException
 */
private static String resolveTypeSignature(IMethod method, String typeSignature) throws JavaModelException {
	int count = Signature.getArrayCount(typeSignature);
	String elementTypeSignature = Signature.getElementType(typeSignature);
	if (elementTypeSignature.length() == 1) {
		// no need to resolve primitive types
		return typeSignature;
	}
	String elementTypeName = Signature.toString(elementTypeSignature);
	IType type = method.getDeclaringType();
	String[][] resolvedElementTypeNames = type.resolveType(elementTypeName);
	if (resolvedElementTypeNames == null || resolvedElementTypeNames.length != 1) {
		// check if type parameter
		ITypeParameter typeParameter = method.getTypeParameter(elementTypeName);
		if (!typeParameter.exists()) {
			typeParameter = type.getTypeParameter(elementTypeName);
		}
		if (typeParameter.exists()) {
			String[] bounds = typeParameter.getBounds();
			if (bounds.length == 0) {
				return "Ljava/lang/Object;"; //$NON-NLS-1$
			}
			String bound = Signature.createTypeSignature(bounds[0], false);
			return Signature.createArraySignature(resolveTypeSignature(method, bound), count);
		}
		// the type name cannot be resolved
		return null;
	}

	String[] types = resolvedElementTypeNames[0];
	types[1] = types[1].replace('.', '$');

	String resolvedElementTypeName = Signature.toQualifiedName(types);
	String resolvedElementTypeSignature = "";
	if(types[0].equals("")) {
		resolvedElementTypeName = resolvedElementTypeName.substring(1);
		resolvedElementTypeSignature = Signature.createTypeSignature(resolvedElementTypeName, true);
	}
	else {
		resolvedElementTypeSignature = Signature.createTypeSignature(resolvedElementTypeName, true).replace('.', '/');
	}

	return Signature.createArraySignature(resolvedElementTypeSignature, count);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:53,代码来源:BreakpointLocator.java


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