use of org.eclipse.jdt.core.dom.PrimitiveType.Code in project che by eclipse.
the class ASTResolving method getNarrowingTypes.
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()]);
}
use of org.eclipse.jdt.core.dom.PrimitiveType.Code in project che by eclipse.
the class ParameterGuesser method evaluateVisibleMatches.
private List<Variable> evaluateVisibleMatches(String expectedType, IJavaElement[] suggestions) throws JavaModelException {
IType currentType = null;
if (fEnclosingElement != null) {
currentType = (IType) fEnclosingElement.getAncestor(IJavaElement.TYPE);
}
ArrayList<Variable> res = new ArrayList<Variable>();
for (int i = 0; i < suggestions.length; i++) {
Variable variable = createVariable(suggestions[i], currentType, expectedType, i);
if (variable != null) {
if (fAlreadyMatchedNames.contains(variable.name)) {
variable.alreadyMatched = true;
}
res.add(variable);
}
}
// add 'this'
if (currentType != null && !(fEnclosingElement instanceof IMethod && Flags.isStatic(((IMethod) fEnclosingElement).getFlags()))) {
String fullyQualifiedName = currentType.getFullyQualifiedName('.');
if (fullyQualifiedName.equals(expectedType)) {
ImageDescriptor desc = new JavaElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaElementImageDescriptor.FINAL | JavaElementImageDescriptor.STATIC);
res.add(new Variable(fullyQualifiedName, "this", Variable.LITERALS, false, res.size(), new char[] { '.' }, //$NON-NLS-1$
desc));
}
}
Code primitiveTypeCode = getPrimitiveTypeCode(expectedType);
if (primitiveTypeCode == null) {
// add 'null'
//$NON-NLS-1$
res.add(new Variable(expectedType, "null", Variable.LITERALS, false, res.size(), NO_TRIGGERS, null));
} else {
String typeName = primitiveTypeCode.toString();
boolean isAutoboxing = !typeName.equals(expectedType);
if (primitiveTypeCode == PrimitiveType.BOOLEAN) {
// add 'true', 'false'
//$NON-NLS-1$
res.add(new Variable(typeName, "true", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null));
//$NON-NLS-1$
res.add(new Variable(typeName, "false", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null));
} else {
// add 0
//$NON-NLS-1$
res.add(new Variable(typeName, "0", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null));
}
}
return res;
}
use of org.eclipse.jdt.core.dom.PrimitiveType.Code in project flux by eclipse.
the class ASTResolving method getNarrowingTypes.
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()]);
}
use of org.eclipse.jdt.core.dom.PrimitiveType.Code in project flux by eclipse.
the class ASTResolving method getRelaxingTypes.
public static ITypeBinding[] getRelaxingTypes(AST ast, ITypeBinding type) {
ArrayList<ITypeBinding> res = new ArrayList<ITypeBinding>();
res.add(type);
if (type.isArray()) {
//$NON-NLS-1$
res.add(ast.resolveWellKnownType("java.lang.Object"));
// The following two types are not available in some j2me implementations, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=288060 :
//$NON-NLS-1$
ITypeBinding serializable = ast.resolveWellKnownType("java.io.Serializable");
if (serializable != null)
res.add(serializable);
//$NON-NLS-1$
ITypeBinding cloneable = ast.resolveWellKnownType("java.lang.Cloneable");
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()]);
}
Aggregations