本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getName方法的具體用法?Java ITypeBinding.getName怎麽用?Java ITypeBinding.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.getName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isIntegerType
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean isIntegerType(ITypeBinding binding) {
if (binding == null) {
return false;
}
if (!binding.isPrimitive()) {
return false;
}
String name= binding.getName();
if (isIntegerNumber(name)) {
return true;
}
return false;
}
示例2: getSimpleName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static String getSimpleName(ITypeBinding itb) {
if (itb.isNested()) {
if (itb.isAnonymous()) {
String binname = itb.getBinaryName();
int index = binname.indexOf('$');
String name = binname.substring(index + 1, binname.length());
return getSimpleName(itb.getDeclaringClass()) + "#" + name;
} else {
return getSimpleName(itb.getDeclaringClass()) + "#"
+ itb.getName();
}
} else {
return itb.getName();
}
}
示例3: getRawName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static String getRawName(ITypeBinding binding) {
String name= binding.getName();
if (binding.isParameterizedType() || binding.isGenericType()) {
int idx= name.indexOf('<');
if (idx != -1) {
return name.substring(0, idx);
}
}
return name;
}
示例4: newDefaultExpression
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Returns an expression that is assignable to the given type binding. <code>null</code> is
* returned if the type is the 'void' type.
*
* @param ast The AST to create the expression for
* @param type The type binding to which the returned expression is compatible to
* @return the Null-literal for reference types, a boolean-literal for a boolean type, a number
* literal for primitive types or <code>null</code> if the type is void.
*/
public static Expression newDefaultExpression(AST ast, ITypeBinding type) {
if (type.isPrimitive()) {
String name= type.getName();
if ("boolean".equals(name)) { //$NON-NLS-1$
return ast.newBooleanLiteral(false);
} else if ("void".equals(name)) { //$NON-NLS-1$
return null;
} else {
return ast.newNumberLiteral("0"); //$NON-NLS-1$
}
}
return ast.newNullLiteral();
}
示例5: getVariableNameSuggestions
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static String[] getVariableNameSuggestions(int variableKind, IJavaProject project, ITypeBinding expectedType, Expression assignedExpression, Collection<String> excluded) {
LinkedHashSet<String> res= new LinkedHashSet<>(); // avoid duplicates but keep order
if (assignedExpression != null) {
String nameFromExpression= getBaseNameFromExpression(project, assignedExpression, variableKind);
if (nameFromExpression != null) {
add(getVariableNameSuggestions(variableKind, project, nameFromExpression, 0, excluded, false), res); // pass 0 as dimension, base name already contains plural.
}
String nameFromParent= getBaseNameFromLocationInParent(assignedExpression);
if (nameFromParent != null) {
add(getVariableNameSuggestions(variableKind, project, nameFromParent, 0, excluded, false), res); // pass 0 as dimension, base name already contains plural.
}
}
if (expectedType != null) {
expectedType= Bindings.normalizeTypeBinding(expectedType);
if (expectedType != null) {
int dim= 0;
if (expectedType.isArray()) {
dim= expectedType.getDimensions();
expectedType= expectedType.getElementType();
}
if (expectedType.isParameterizedType()) {
expectedType= expectedType.getTypeDeclaration();
}
String typeName= expectedType.getName();
if (typeName.length() > 0) {
add(getVariableNameSuggestions(variableKind, project, typeName, dim, excluded, false), res);
}
}
}
if (res.isEmpty()) {
return getDefaultVariableNameSuggestions(variableKind, excluded);
}
return res.toArray(new String[res.size()]);
}