Example usage for org.eclipse.jdt.core.dom IPackageBinding isEqualTo

List of usage examples for org.eclipse.jdt.core.dom IPackageBinding isEqualTo

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom IPackageBinding isEqualTo.

Prototype

public boolean isEqualTo(IBinding binding);

Source Link

Document

Returns whether this binding has the same key as that of the given binding.

Usage

From source file:com.google.devtools.j2cpp.translate.Rewriter.java

License:Open Source License

private void addFields(ITypeBinding type, boolean includePrivate, boolean includeSuperclasses,
        Map<String, IVariableBinding> fields) {
    for (IVariableBinding field : type.getDeclaredFields()) {
        if (!fields.containsValue(field)) { // if not already renamed
            int mods = field.getModifiers();
            if (!Modifier.isStatic(mods)) {
                if (includePrivate) {
                    fields.put(field.getName(), field);
                } else if (Modifier.isPublic(mods) || Modifier.isProtected(mods)) {
                    fields.put(field.getName(), field);
                } else {
                    IPackageBinding typePackage = type.getPackage();
                    IPackageBinding fieldPackage = field.getDeclaringClass().getPackage();
                    if (typePackage.isEqualTo(fieldPackage)) {
                        fields.put(field.getName(), field);
                    }// ww  w .  j  a v  a 2  s .c o m
                }
            }
        }
    }
    ITypeBinding superclass = type.getSuperclass();
    if (includeSuperclasses && superclass != null) {
        addFields(superclass, false, true, fields);
    }
}