本文整理汇总了Java中org.eclipse.jdt.core.dom.PrimitiveType.toCode方法的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType.toCode方法的具体用法?Java PrimitiveType.toCode怎么用?Java PrimitiveType.toCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.PrimitiveType
的用法示例。
在下文中一共展示了PrimitiveType.toCode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isGeneralizeTypeAvailable
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
public static boolean isGeneralizeTypeAvailable(final IJavaElement element)
throws JavaModelException {
if (element != null && element.exists()) {
String type = null;
if (element instanceof IMethod) type = ((IMethod) element).getReturnType();
else if (element instanceof IField) {
final IField field = (IField) element;
if (JdtFlags.isEnum(field)) return false;
type = field.getTypeSignature();
} else if (element instanceof ILocalVariable) return true;
else if (element instanceof IType) {
final IType clazz = (IType) element;
if (JdtFlags.isEnum(clazz)) return false;
return true;
}
if (type == null || PrimitiveType.toCode(Signature.toString(type)) != null) return false;
return true;
}
return false;
}
示例2: isGeneralizeTypeAvailable
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
public static boolean isGeneralizeTypeAvailable(final IJavaElement element) throws JavaModelException {
if (element != null && element.exists()) {
String type= null;
if (element instanceof IMethod)
type= ((IMethod) element).getReturnType();
else if (element instanceof IField) {
final IField field= (IField) element;
if (JdtFlags.isEnum(field))
return false;
type= field.getTypeSignature();
} else if (element instanceof ILocalVariable)
return true;
else if (element instanceof IType) {
final IType clazz= (IType) element;
if (JdtFlags.isEnum(clazz))
return false;
return true;
}
if (type == null || PrimitiveType.toCode(Signature.toString(type)) != null)
return false;
return true;
}
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:RefactoringAvailabilityTester.java
示例3: getMember
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private static IMember getMember(IStructuredSelection selection) throws JavaModelException {
if (selection.size() != 1)
return null;
Object element= selection.getFirstElement();
if (!(element instanceof IMember))
return null;
if (element instanceof IMethod) {
IMethod method= (IMethod)element;
String returnType= method.getReturnType();
if (PrimitiveType.toCode(Signature.toString(returnType)) != null)
return null;
return method;
} else if (element instanceof IField && !JdtFlags.isEnum((IMember) element)) {
return (IField)element;
}
return null;
}
示例4: getPrimitiveTypeCode
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private PrimitiveType.Code getPrimitiveTypeCode(String type) {
PrimitiveType.Code code = PrimitiveType.toCode(type);
if (code != null) {
return code;
}
if (fEnclosingElement != null
&& JavaModelUtil.is50OrHigher(fEnclosingElement.getJavaProject())) {
if (code == PrimitiveType.SHORT) {
if ("java.lang.Short".equals(type)) { // $NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.INT) {
if ("java.lang.Integer".equals(type)) { // $NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.LONG) {
if ("java.lang.Long".equals(type)) { // $NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.FLOAT) {
if ("java.lang.Float".equals(type)) { // $NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.DOUBLE) {
if ("java.lang.Double".equals(type)) { // $NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.CHAR) {
if ("java.lang.Character".equals(type)) { // $NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.BYTE) {
if ("java.lang.Byte".equals(type)) { // $NON-NLS-1$
return code;
}
}
}
return null;
}
示例5: getPrimitiveTypeCode
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private PrimitiveType.Code getPrimitiveTypeCode(String type) {
PrimitiveType.Code code= PrimitiveType.toCode(type);
if (code != null) {
return code;
}
if (fEnclosingElement != null && JavaModelUtil.is50OrHigher(fEnclosingElement.getJavaProject())) {
if (code == PrimitiveType.SHORT) {
if ("java.lang.Short".equals(type)) { //$NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.INT) {
if ("java.lang.Integer".equals(type)) { //$NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.LONG) {
if ("java.lang.Long".equals(type)) { //$NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.FLOAT) {
if ("java.lang.Float".equals(type)) { //$NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.DOUBLE) {
if ("java.lang.Double".equals(type)) { //$NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.CHAR) {
if ("java.lang.Character".equals(type)) { //$NON-NLS-1$
return code;
}
} else if (code == PrimitiveType.BYTE) {
if ("java.lang.Byte".equals(type)) { //$NON-NLS-1$
return code;
}
}
}
return null;
}
示例6: getNarrowingTypes
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
public static ITypeBinding[] getNarrowingTypes(AST ast, ITypeBinding type) {
ArrayList<ITypeBinding> res= new ArrayList<ITypeBinding>();
res.add(type);
if (type.isPrimitive()) {
Code code= PrimitiveType.toCode(type.getName());
for (int i= 0; i < CODE_ORDER.length && code != CODE_ORDER[i]; i++) {
String typeName= CODE_ORDER[i].toString();
res.add(ast.resolveWellKnownType(typeName));
}
}
return res.toArray(new ITypeBinding[res.size()]);
}
示例7: getRelaxingTypes
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
public static ITypeBinding[] getRelaxingTypes(AST ast, ITypeBinding type) {
ArrayList<ITypeBinding> res= new ArrayList<ITypeBinding>();
res.add(type);
if (type.isArray()) {
res.add(ast.resolveWellKnownType("java.lang.Object")); //$NON-NLS-1$
// The following two types are not available in some j2me implementations, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=288060 :
ITypeBinding serializable= ast.resolveWellKnownType("java.io.Serializable"); //$NON-NLS-1$
if (serializable != null)
res.add(serializable);
ITypeBinding cloneable= ast.resolveWellKnownType("java.lang.Cloneable"); //$NON-NLS-1$
if (cloneable != null)
res.add(cloneable);
} else if (type.isPrimitive()) {
Code code= PrimitiveType.toCode(type.getName());
boolean found= false;
for (int i= 0; i < CODE_ORDER.length; i++) {
if (found) {
String typeName= CODE_ORDER[i].toString();
res.add(ast.resolveWellKnownType(typeName));
}
if (code == CODE_ORDER[i]) {
found= true;
}
}
} else {
collectRelaxingTypes(res, type);
}
return res.toArray(new ITypeBinding[res.size()]);
}
示例8: createSetValueMethodInvocation
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private MethodInvocation createSetValueMethodInvocation(IVariableBinding fieldBind, AST ast) {
MethodInvocation result = ast.newMethodInvocation();
ITypeBinding fieldType = fieldBind.getType();
if (fieldType.isPrimitive()) {
Code code = PrimitiveType.toCode(fieldType.getName());
if (PrimitiveType.BOOLEAN.equals(code)) {
result.setName(ast.newSimpleName("setBoolean")); //$NON-NLS-1$
} else if (PrimitiveType.BYTE.equals(code)) {
result.setName(ast.newSimpleName("setByte")); //$NON-NLS-1$
} else if (PrimitiveType.CHAR.equals(code)) {
result.setName(ast.newSimpleName("setChar")); //$NON-NLS-1$
} else if (PrimitiveType.DOUBLE.equals(code)) {
result.setName(ast.newSimpleName("setDouble")); //$NON-NLS-1$
} else if (PrimitiveType.FLOAT.equals(code)) {
result.setName(ast.newSimpleName("setFloat")); //$NON-NLS-1$
} else if (PrimitiveType.INT.equals(code)) {
result.setName(ast.newSimpleName("setInt")); //$NON-NLS-1$
} else if (PrimitiveType.LONG.equals(code)) {
result.setName(ast.newSimpleName("setLong")); //$NON-NLS-1$
} else if (PrimitiveType.SHORT.equals(code)) {
result.setName(ast.newSimpleName("setShort")); //$NON-NLS-1$
}
} else {
result.setName(ast.newSimpleName("set")); //$NON-NLS-1$
}
return result;
}
示例9: createGetFieldValueInvocation
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private MethodInvocation createGetFieldValueInvocation(IVariableBinding field, AST ast) {
MethodInvocation result = ast.newMethodInvocation();
ITypeBinding fieldType = field.getType();
if (fieldType.isPrimitive()) {
Code code = PrimitiveType.toCode(fieldType.getName());
if (PrimitiveType.BOOLEAN.equals(code)) {
result.setName(ast.newSimpleName("getBoolean")); //$NON-NLS-1$
} else if (PrimitiveType.BYTE.equals(code)) {
result.setName(ast.newSimpleName("getByte")); //$NON-NLS-1$
} else if (PrimitiveType.CHAR.equals(code)) {
result.setName(ast.newSimpleName("getChar")); //$NON-NLS-1$
} else if (PrimitiveType.DOUBLE.equals(code)) {
result.setName(ast.newSimpleName("getDouble")); //$NON-NLS-1$
} else if (PrimitiveType.FLOAT.equals(code)) {
result.setName(ast.newSimpleName("getFloat")); //$NON-NLS-1$
} else if (PrimitiveType.INT.equals(code)) {
result.setName(ast.newSimpleName("getInt")); //$NON-NLS-1$
} else if (PrimitiveType.LONG.equals(code)) {
result.setName(ast.newSimpleName("getLong")); //$NON-NLS-1$
} else if (PrimitiveType.SHORT.equals(code)) {
result.setName(ast.newSimpleName("getShort")); //$NON-NLS-1$
}
} else {
result.setName(ast.newSimpleName("get")); //$NON-NLS-1$
}
return result;
}
示例10: isPrimitiveType
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private boolean isPrimitiveType(String type) {
return PrimitiveType.toCode(type) != null;
}
示例11: isPrimitiveType
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private boolean isPrimitiveType(String type) {
return PrimitiveType.toCode(type) != null;
}