use of org.eclipse.jdt.core.dom.ITypeBinding in project j2objc by google.
the class JdtExecutableElement method getTypeParameters.
@Override
public List<? extends TypeParameterElement> getTypeParameters() {
List<TypeParameterElement> typeParams = new ArrayList<>();
for (ITypeBinding tp : ((IMethodBinding) binding).getTypeParameters()) {
Element tpe = BindingConverter.getElement(tp);
assert tpe instanceof TypeParameterElement;
typeParams.add((TypeParameterElement) tpe);
}
return typeParams;
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project j2objc by google.
the class JdtIntersectionType method fromJdtIntersection.
static JdtIntersectionType fromJdtIntersection(ITypeBinding t) {
List<TypeMirror> bounds = new ArrayList<>();
ITypeBinding superclass = t.getSuperclass();
if (superclass != null) {
bounds.add(BindingConverter.getType(superclass));
}
for (ITypeBinding intrface : t.getInterfaces()) {
bounds.add(BindingConverter.getType(intrface));
}
return new JdtIntersectionType(t, bounds);
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project j2objc by google.
the class JdtTypeElement method getTypeParameters.
@Override
public List<? extends TypeParameterElement> getTypeParameters() {
List<TypeParameterElement> typeParams = new ArrayList<>();
for (ITypeBinding typeParam : ((ITypeBinding) binding).getTypeParameters()) {
TypeParameterElement tpe = (TypeParameterElement) BindingConverter.getElement(typeParam);
typeParams.add(tpe);
}
return typeParams;
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project j2objc by google.
the class TreeConverter method convertAbstractTypeDeclaration.
private static TreeNode convertAbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration node, AbstractTypeDeclaration newNode) {
convertBodyDeclaration(node, newNode);
ITypeBinding typeBinding = node.resolveBinding();
Set<IMethodBinding> declaredInAst = new HashSet<>();
for (Object bodyDecl : node.bodyDeclarations()) {
if (bodyDecl instanceof org.eclipse.jdt.core.dom.MethodDeclaration) {
declaredInAst.add(((org.eclipse.jdt.core.dom.MethodDeclaration) bodyDecl).resolveBinding());
}
newNode.addBodyDeclaration((BodyDeclaration) convert(bodyDecl));
}
for (IMethodBinding method : typeBinding.getDeclaredMethods()) {
if (method.isConstructor() && method.getParameterTypes().length == 0 && !declaredInAst.contains(method)) {
MethodDeclaration defaultConstructor = new MethodDeclaration(BindingConverter.getExecutableElement(method)).setBody(new Block());
addImplicitSuperCall(defaultConstructor);
newNode.addBodyDeclaration(0, defaultConstructor);
break;
}
}
return newNode.setName((SimpleName) convert(node.getName())).setTypeElement(BindingConverter.getTypeElement(typeBinding));
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project flux by eclipse.
the class ContextSensitiveImportRewriteContext method findInContext.
@Override
public int findInContext(String qualifier, String name, int kind) {
IBinding[] declarationsInScope = getDeclarationsInScope();
for (int i = 0; i < declarationsInScope.length; i++) {
if (declarationsInScope[i] instanceof ITypeBinding) {
ITypeBinding typeBinding = (ITypeBinding) declarationsInScope[i];
if (isSameType(typeBinding, qualifier, name)) {
return RES_NAME_FOUND;
} else if (isConflicting(typeBinding, name)) {
return RES_NAME_CONFLICT;
}
} else if (declarationsInScope[i] != null) {
if (isConflicting(declarationsInScope[i], name)) {
return RES_NAME_CONFLICT;
}
}
}
Name[] names = getImportedNames();
for (int i = 0; i < names.length; i++) {
IBinding binding = names[i].resolveBinding();
if (binding instanceof ITypeBinding && !binding.isRecovered()) {
ITypeBinding typeBinding = (ITypeBinding) binding;
if (isConflictingType(typeBinding, qualifier, name)) {
return RES_NAME_CONFLICT;
}
}
}
List<AbstractTypeDeclaration> list = fCompilationUnit.types();
for (Iterator<AbstractTypeDeclaration> iter = list.iterator(); iter.hasNext(); ) {
AbstractTypeDeclaration type = iter.next();
ITypeBinding binding = type.resolveBinding();
if (binding != null) {
if (isSameType(binding, qualifier, name)) {
return RES_NAME_FOUND;
} else {
ITypeBinding decl = containingDeclaration(binding, qualifier, name);
while (decl != null && !decl.equals(binding)) {
int modifiers = decl.getModifiers();
if (Modifier.isPrivate(modifiers))
return RES_NAME_CONFLICT;
decl = decl.getDeclaringClass();
}
}
}
}
String[] addedImports = fImportRewrite.getAddedImports();
String qualifiedName = JavaModelUtil.concatenateName(qualifier, name);
for (int i = 0; i < addedImports.length; i++) {
String addedImport = addedImports[i];
if (qualifiedName.equals(addedImport)) {
return RES_NAME_FOUND;
} else {
if (isConflicting(name, addedImport))
return RES_NAME_CONFLICT;
}
}
if (qualifier.equals("java.lang")) {
//$NON-NLS-1$
//No explicit import statement required
ITypeRoot typeRoot = fCompilationUnit.getTypeRoot();
if (typeRoot != null) {
IPackageFragment packageFragment = (IPackageFragment) typeRoot.getParent();
try {
ICompilationUnit[] compilationUnits = packageFragment.getCompilationUnits();
for (int i = 0; i < compilationUnits.length; i++) {
ICompilationUnit cu = compilationUnits[i];
IType[] allTypes = cu.getAllTypes();
for (int j = 0; j < allTypes.length; j++) {
IType type = allTypes[j];
String packageTypeName = type.getFullyQualifiedName();
if (isConflicting(name, packageTypeName))
return RES_NAME_CONFLICT;
}
}
} catch (JavaModelException e) {
}
}
}
return fImportRewrite.getDefaultImportRewriteContext().findInContext(qualifier, name, kind);
}
Aggregations