當前位置: 首頁>>代碼示例>>Java>>正文


Java IMethodBinding.isConstructor方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.dom.IMethodBinding.isConstructor方法的典型用法代碼示例。如果您正苦於以下問題:Java IMethodBinding.isConstructor方法的具體用法?Java IMethodBinding.isConstructor怎麽用?Java IMethodBinding.isConstructor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.dom.IMethodBinding的用法示例。


在下文中一共展示了IMethodBinding.isConstructor方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getKeyFromMethodBinding

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static String getKeyFromMethodBinding(IMethodBinding binding) {
	StringBuilder sb = new StringBuilder();
	String className = binding.getDeclaringClass().getErasure().getQualifiedName();
	sb.append(className);
	sb.append('.');
	String methodName = binding.isConstructor() ? "" : binding.getName();
	sb.append(methodName);
	//if (methodName.equals("allObjectsSorted")) {
	//	System.out.println();
	//}
	sb.append('(');
	ITypeBinding[] parameters = binding.getParameterTypes();
	for (int i = 0; i < parameters.length; i++) {
		if (i > 0) {
			sb.append(", ");
		}
		ITypeBinding type = parameters[i];
		sb.append(type.getErasure().getName());
	}
	sb.append(')');
	return sb.toString();
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:23,代碼來源:AstUtils.java

示例2: getKeyFromMethodBinding

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static String getKeyFromMethodBinding(IMethodBinding binding) {
	StringBuilder sb = new StringBuilder();
	String className = binding.getDeclaringClass().getErasure().getQualifiedName();
	sb.append(className);
	sb.append('#');
	String methodName = binding.isConstructor() ? "" : binding.getName();
	sb.append(methodName);
	//if (methodName.equals("allObjectsSorted")) {
	//	System.out.println();
	//}
	sb.append('(');
	ITypeBinding[] parameters = binding.getParameterTypes();
	for (int i = 0; i < parameters.length; i++) {
		if (i > 0) {
			sb.append(", ");
		}
		ITypeBinding type = parameters[i];
		sb.append(type.getErasure().getName());
	}
	sb.append(')');
	return sb.toString();
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:23,代碼來源:AstUtils.java

示例3: getSimpleName

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static String getSimpleName(IMethodBinding imb) {
	try {
		// imb = imb.getMethodDeclaration();
		String name = imb.getName();
		if (imb.isConstructor())
			name = "<init>";
		String args = "";
		/*
		 * for (ITypeBinding itb : imb.getParameterTypes()) { if
		 * (args.length()>0) args+=","; args += getQualifiedName(itb); }
		 */
		args = "(" + args + ")";
		return name + args;
	} catch (NullPointerException e) {
		return "";
	}
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:18,代碼來源:ASTVisitorAtomicChange.java

示例4: isMethodCompatible

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
public static boolean isMethodCompatible(IMethodBinding methodBinding) {

	Options options = Options.getInstance();
	if (!options.includeConstructors()
			&& (methodBinding.isConstructor() || methodBinding
					.isDefaultConstructor())) {
		return false;
	}
	if (!options.includeStaticMethods()
			&& Modifier.isStatic(methodBinding.getModifiers())) {
		return false;
	}

	return true;

}
 
開發者ID:aroog,項目名稱:code,代碼行數:17,代碼來源:Utils.java

示例5: isSignatureEquivalentConstructor

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static boolean isSignatureEquivalentConstructor(IMethodBinding overridden, IMethodBinding overridable) {

		if (!overridden.isConstructor() || !overridable.isConstructor()) {
			return false;
		}

		if (overridden.isDefaultConstructor()) {
			return false;
		}

		return areSubTypeCompatible(overridden, overridable);
	}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:13,代碼來源:Bindings.java

示例6: getDeclaration

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
private static IBinding getDeclaration(IBinding binding) {
	if (binding instanceof ITypeBinding) {
		return ((ITypeBinding) binding).getTypeDeclaration();
	} else if (binding instanceof IMethodBinding) {
		IMethodBinding methodBinding= (IMethodBinding) binding;
		if (methodBinding.isConstructor()) { // link all constructors with their type
			return methodBinding.getDeclaringClass().getTypeDeclaration();
		} else {
			return methodBinding.getMethodDeclaration();
		}
	} else if (binding instanceof IVariableBinding) {
		return ((IVariableBinding) binding).getVariableDeclaration();
	}
	return binding;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:16,代碼來源:LinkedNodeFinder.java

示例7: checkMethodInType

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
 * Checks if the new method is already used in the given type.
 *
 * @param type
 * @param methodName
 * @param parameters
 * @return the status
 */
public static RefactoringStatus checkMethodInType(ITypeBinding type, String methodName, ITypeBinding[] parameters) {
	RefactoringStatus result = new RefactoringStatus();
	IMethodBinding method = org.eclipse.jdt.internal.corext.dom.Bindings.findMethodInType(type, methodName, parameters);
	if (method != null) {
		if (method.isConstructor()) {
			result.addWarning(Messages.format(RefactoringCoreMessages.Checks_methodName_constructor, new Object[] { BasicElementLabels.getJavaElementName(type.getName()) }));
		} else {
			result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_exists, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(type.getName()) }),
					JavaStatusContext.create(method));
		}
	}
	return result;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:22,代碼來源:Checks.java

示例8: checkMethodInHierarchy

import org.eclipse.jdt.core.dom.IMethodBinding; //導入方法依賴的package包/類
/**
 * Checks if the new method somehow conflicts with an already existing
 * method in the hierarchy. The following checks are done:
 * <ul>
 * <li>if the new method overrides a method defined in the given type or in
 * one of its super classes.</li>
 * </ul>
 *
 * @param type
 * @param methodName
 * @param returnType
 * @param parameters
 * @return the status
 */
public static RefactoringStatus checkMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding returnType, ITypeBinding[] parameters) {
	RefactoringStatus result = new RefactoringStatus();
	IMethodBinding method = Bindings.findMethodInHierarchy(type, methodName, parameters);
	if (method != null) {
		boolean returnTypeClash = false;
		ITypeBinding methodReturnType = method.getReturnType();
		if (returnType != null && methodReturnType != null) {
			String returnTypeKey = returnType.getKey();
			String methodReturnTypeKey = methodReturnType.getKey();
			if (returnTypeKey == null && methodReturnTypeKey == null) {
				returnTypeClash = returnType != methodReturnType;
			} else if (returnTypeKey != null && methodReturnTypeKey != null) {
				returnTypeClash = !returnTypeKey.equals(methodReturnTypeKey);
			}
		}
		ITypeBinding dc = method.getDeclaringClass();
		if (returnTypeClash) {
			result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_returnTypeClash, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName()) }),
					JavaStatusContext.create(method));
		} else {
			if (method.isConstructor()) {
				result.addWarning(Messages.format(RefactoringCoreMessages.Checks_methodName_constructor, new Object[] { BasicElementLabels.getJavaElementName(dc.getName()) }));
			} else {
				result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_overrides, new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName()) }),
						JavaStatusContext.create(method));
			}
		}
	}
	return result;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:45,代碼來源:Checks.java


注:本文中的org.eclipse.jdt.core.dom.IMethodBinding.isConstructor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。