本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.memberTypes方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceBinding.memberTypes方法的具体用法?Java ReferenceBinding.memberTypes怎么用?Java ReferenceBinding.memberTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
的用法示例。
在下文中一共展示了ReferenceBinding.memberTypes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEnclosedElements
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public List<? extends Element> getEnclosedElements() {
ReferenceBinding binding = (ReferenceBinding)_binding;
List<Element> enclosed = new ArrayList<Element>(binding.fieldCount() + binding.methods().length);
for (MethodBinding method : binding.methods()) {
ExecutableElement executable = new ExecutableElementImpl(_env, method);
enclosed.add(executable);
}
for (FieldBinding field : binding.fields()) {
// TODO no field should be excluded according to the JLS
if (!field.isSynthetic()) {
VariableElement variable = new VariableElementImpl(_env, field);
enclosed.add(variable);
}
}
for (ReferenceBinding memberType : binding.memberTypes()) {
TypeElement type = new TypeElementImpl(_env, memberType, null);
enclosed.add(type);
}
return Collections.unmodifiableList(enclosed);
}
示例2: addAnnotatedElements
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/**
* For every type in types that is a class and that is annotated with anno, either directly or by inheritance,
* add that type to result. Recursively descend on each types's child classes as well.
* @param anno the compiler binding for an annotation type
* @param type a type, not necessarily a class
* @param result must be a modifiable Set; will accumulate annotated classes
*/
private void addAnnotatedElements(ReferenceBinding anno, ReferenceBinding type, Set<Element> result) {
if (type.isClass()) {
if (inheritsAnno(type, anno)) {
result.add(_factory.newElement(type));
}
}
for (ReferenceBinding element : type.memberTypes()) {
addAnnotatedElements(anno, element, result);
}
}
示例3: getDeclaredTypes
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public synchronized ITypeBinding[] getDeclaredTypes() { // should not deflect to prototype.
if (this.members != null) {
return this.members;
}
try {
if (isClass() || isInterface() || isEnum()) {
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
ReferenceBinding[] internalMembers = referenceBinding.memberTypes();
int length = internalMembers.length;
if (length != 0) {
ITypeBinding[] newMembers = new ITypeBinding[length];
for (int i = 0; i < length; i++) {
ITypeBinding typeBinding = this.resolver.getTypeBinding(internalMembers[i]);
if (typeBinding == null) {
return this.members = NO_TYPE_BINDINGS;
}
newMembers[i] = typeBinding;
}
return this.members = newMembers;
}
}
} catch (RuntimeException e) {
/* in case a method cannot be resolvable due to missing jars on the classpath
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
*/
org.eclipse.jdt.internal.core.util.Util.log(e, "Could not retrieve declared methods"); //$NON-NLS-1$
}
return this.members = NO_TYPE_BINDINGS;
}
示例4: getDeclaredTypes
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public synchronized ITypeBinding[] getDeclaredTypes() {
if (this.members != null) {
return this.members;
}
try {
if (isClass() || isInterface() || isEnum()) {
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
ReferenceBinding[] internalMembers = referenceBinding.memberTypes();
int length = internalMembers.length;
if (length != 0) {
ITypeBinding[] newMembers = new ITypeBinding[length];
for (int i = 0; i < length; i++) {
ITypeBinding typeBinding = this.resolver.getTypeBinding(internalMembers[i]);
if (typeBinding == null) {
return this.members = NO_TYPE_BINDINGS;
}
newMembers[i] = typeBinding;
}
return this.members = newMembers;
}
}
} catch (RuntimeException e) {
/* in case a method cannot be resolvable due to missing jars on the classpath
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
*/
org.eclipse.jdt.internal.core.util.Util.log(e, "Could not retrieve declared methods"); //$NON-NLS-1$
}
return this.members = NO_TYPE_BINDINGS;
}
示例5: asMemberOf
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public TypeMirror asMemberOf(DeclaredType containing, Element element) {
// throw new UnsupportedOperationException("NYI: TypesImpl.asMemberOf(" + containing + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ElementImpl elementImpl = (ElementImpl) element;
DeclaredTypeImpl declaredTypeImpl = (DeclaredTypeImpl) containing;
ReferenceBinding referenceBinding = (ReferenceBinding) declaredTypeImpl._binding;
switch(element.getKind()) {
case CONSTRUCTOR :
case METHOD :
MethodBinding methodBinding = (MethodBinding) elementImpl._binding;
if (TypeBinding.notEquals(methodBinding.declaringClass, referenceBinding)) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (MethodBinding method : referenceBinding.methods()) {
if (CharOperation.equals(method.selector, methodBinding.selector)
&& method.areParameterErasuresEqual(methodBinding)) {
return this._env.getFactory().newTypeMirror(method);
}
}
break;
case FIELD :
case ENUM_CONSTANT:
FieldBinding fieldBinding = (FieldBinding) elementImpl._binding;
if (TypeBinding.notEquals(fieldBinding.declaringClass, referenceBinding)) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (FieldBinding field : referenceBinding.fields()) {
if (CharOperation.equals(field.name, fieldBinding.name)) {
return this._env.getFactory().newTypeMirror(field);
}
}
break;
case ENUM :
case ANNOTATION_TYPE :
case INTERFACE :
case CLASS :
ReferenceBinding referenceBinding2 = (ReferenceBinding) elementImpl._binding;
if (TypeBinding.notEquals(referenceBinding2.enclosingType(), referenceBinding)) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (ReferenceBinding referenceBinding3 : referenceBinding.memberTypes()) {
if (CharOperation.equals(referenceBinding3.compoundName, referenceBinding3.compoundName)) {
return this._env.getFactory().newTypeMirror(referenceBinding3);
}
}
break;
default:
break;
}
throw new IllegalArgumentException("element is not valid for the containing declared type: element kind " + element.getKind()); //$NON-NLS-1$
}
示例6: addMembers
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
/**
* Add the members of a type to the maps of subtypes, fields, and methods. Add only those
* which are non-private and which are not overridden by an already-discovered member.
* For fields, add them all; javac implementation does not take field hiding into account.
* @param binding the type whose members will be added to the lists
* @param ignoreVisibility if true, all members will be added regardless of whether they
* are private, overridden, etc.
* @param types a map of type simple name to type binding
* @param fields a list of field bindings
* @param methods a map of method simple name to set of method bindings with that name
*/
private void addMembers(ReferenceBinding binding, boolean ignoreVisibility, Map<String, ReferenceBinding> types,
List<FieldBinding> fields, Map<String, Set<MethodBinding>> methods)
{
for (ReferenceBinding subtype : binding.memberTypes()) {
if (ignoreVisibility || !subtype.isPrivate()) {
String name = new String(subtype.sourceName());
if (null == types.get(name)) {
types.put(name, subtype);
}
}
}
for (FieldBinding field : binding.fields()) {
if (ignoreVisibility || !field.isPrivate()) {
fields.add(field);
}
}
for (MethodBinding method : binding.methods()) {
if (!method.isSynthetic() && (ignoreVisibility || (!method.isPrivate() && !method.isConstructor()))) {
String methodName = new String(method.selector);
Set<MethodBinding> sameNamedMethods = methods.get(methodName);
if (null == sameNamedMethods) {
// New method name. Create a set for it and add it to the list.
// We don't expect many methods with same name, so only 4 slots:
sameNamedMethods = new HashSet<MethodBinding>(4);
methods.put(methodName, sameNamedMethods);
sameNamedMethods.add(method);
}
else {
// We already have a method with this name. Is this method overridden?
boolean unique = true;
if (!ignoreVisibility) {
for (MethodBinding existing : sameNamedMethods) {
MethodVerifier verifier = _env.getLookupEnvironment().methodVerifier();
if (verifier.doesMethodOverride(existing, method)) {
unique = false;
break;
}
}
}
if (unique) {
sameNamedMethods.add(method);
}
}
}
}
}
示例7: asMemberOf
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public TypeMirror asMemberOf(DeclaredType containing, Element element) {
// throw new UnsupportedOperationException("NYI: TypesImpl.asMemberOf(" + containing + ", " + element + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ElementImpl elementImpl = (ElementImpl) element;
DeclaredTypeImpl declaredTypeImpl = (DeclaredTypeImpl) containing;
ReferenceBinding referenceBinding = (ReferenceBinding) declaredTypeImpl._binding;
switch(element.getKind()) {
case CONSTRUCTOR :
case METHOD :
MethodBinding methodBinding = (MethodBinding) elementImpl._binding;
if (methodBinding.declaringClass != referenceBinding) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (MethodBinding method : referenceBinding.methods()) {
if (CharOperation.equals(method.selector, methodBinding.selector)
&& method.areParameterErasuresEqual(methodBinding)) {
return this._env.getFactory().newTypeMirror(method);
}
}
break;
case FIELD :
case ENUM_CONSTANT:
FieldBinding fieldBinding = (FieldBinding) elementImpl._binding;
if (fieldBinding.declaringClass != referenceBinding) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (FieldBinding field : referenceBinding.fields()) {
if (CharOperation.equals(field.name, fieldBinding.name)) {
return this._env.getFactory().newTypeMirror(field);
}
}
break;
case ENUM :
case ANNOTATION_TYPE :
case INTERFACE :
case CLASS :
ReferenceBinding referenceBinding2 = (ReferenceBinding) elementImpl._binding;
if (referenceBinding2.enclosingType() != referenceBinding) {
throw new IllegalArgumentException("element is not valid for the containing declared type"); //$NON-NLS-1$
}
for (ReferenceBinding referenceBinding3 : referenceBinding.memberTypes()) {
if (CharOperation.equals(referenceBinding3.compoundName, referenceBinding3.compoundName)) {
return this._env.getFactory().newTypeMirror(referenceBinding3);
}
}
break;
default:
break;
}
throw new IllegalArgumentException("element is not valid for the containing declared type: element kind " + element.getKind()); //$NON-NLS-1$
}