本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.enclosingType方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceBinding.enclosingType方法的具体用法?Java ReferenceBinding.enclosingType怎么用?Java ReferenceBinding.enclosingType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding
的用法示例。
在下文中一共展示了ReferenceBinding.enclosingType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEnclosingType
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public TypeMirror getEnclosingType() {
ReferenceBinding binding = (ReferenceBinding)_binding;
ReferenceBinding enclosingType = binding.enclosingType();
if (enclosingType != null) {
return _env.getFactory().newTypeMirror(enclosingType);
}
return _env.getFactory().getNoType(TypeKind.NONE);
}
示例2: getEnclosingElement
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
@Override
public Element getEnclosingElement() {
ReferenceBinding binding = (ReferenceBinding)_binding;
ReferenceBinding enclosingType = binding.enclosingType();
if (null == enclosingType) {
// this is a top level type; get its package
return _env.getFactory().newPackageElement(binding.fPackage);
}
else {
return _env.getFactory().newElement(binding.enclosingType());
}
}
示例3: canBeSeenByForCodeSnippet
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public final boolean canBeSeenByForCodeSnippet(ReferenceBinding referenceBinding, ReferenceBinding receiverType) {
if (referenceBinding.isPublic()) return true;
if (TypeBinding.equalsEquals(receiverType, referenceBinding)) return true;
if (referenceBinding.isProtected()) {
// answer true if the receiver (or its enclosing type) is the superclass
// of the receiverType or in the same package
return receiverType.fPackage == referenceBinding.fPackage
|| referenceBinding.isSuperclassOf(receiverType)
|| referenceBinding.enclosingType().isSuperclassOf(receiverType); // protected types always have an enclosing one
}
if (referenceBinding.isPrivate()) {
// answer true if the receiver and the receiverType have a common enclosingType
// already know they are not the identical type
ReferenceBinding outerInvocationType = receiverType;
ReferenceBinding temp = outerInvocationType.enclosingType();
while (temp != null) {
outerInvocationType = temp;
temp = temp.enclosingType();
}
ReferenceBinding outerDeclaringClass = referenceBinding;
temp = outerDeclaringClass.enclosingType();
while (temp != null) {
outerDeclaringClass = temp;
temp = temp.enclosingType();
}
return TypeBinding.equalsEquals(outerInvocationType, outerDeclaringClass);
}
// isDefault()
return receiverType.fPackage == referenceBinding.fPackage;
}
示例4: recordInnerClasses
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public void recordInnerClasses(TypeBinding binding) {
if (this.innerClassesBindings == null) {
this.innerClassesBindings = new HashSet(INNER_CLASSES_SIZE);
}
ReferenceBinding innerClass = (ReferenceBinding) binding;
this.innerClassesBindings.add(innerClass.erasure().unannotated()); // should not emit yet another inner class for [email protected] Inner.
ReferenceBinding enclosingType = innerClass.enclosingType();
while (enclosingType != null
&& enclosingType.isNestedType()) {
this.innerClassesBindings.add(enclosingType.erasure().unannotated());
enclosingType = enclosingType.enclosingType();
}
}
示例5: numberOfEnclosingFields
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
static int numberOfEnclosingFields(ReferenceBinding type){
int count = 0;
type = type.enclosingType();
while(type != null) {
count += type.fieldCount();
type = type.enclosingType();
}
return count;
}
示例6: canBeSeenByForCodeSnippet
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public final boolean canBeSeenByForCodeSnippet(ReferenceBinding referenceBinding, ReferenceBinding receiverType) {
if (referenceBinding.isPublic()) return true;
if (receiverType == referenceBinding) return true;
if (referenceBinding.isProtected()) {
// answer true if the receiver (or its enclosing type) is the superclass
// of the receiverType or in the same package
return receiverType.fPackage == referenceBinding.fPackage
|| referenceBinding.isSuperclassOf(receiverType)
|| referenceBinding.enclosingType().isSuperclassOf(receiverType); // protected types always have an enclosing one
}
if (referenceBinding.isPrivate()) {
// answer true if the receiver and the receiverType have a common enclosingType
// already know they are not the identical type
ReferenceBinding outerInvocationType = receiverType;
ReferenceBinding temp = outerInvocationType.enclosingType();
while (temp != null) {
outerInvocationType = temp;
temp = temp.enclosingType();
}
ReferenceBinding outerDeclaringClass = referenceBinding;
temp = outerDeclaringClass.enclosingType();
while (temp != null) {
outerDeclaringClass = temp;
temp = temp.enclosingType();
}
return outerInvocationType == outerDeclaringClass;
}
// isDefault()
return receiverType.fPackage == referenceBinding.fPackage;
}
示例7: recordInnerClasses
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; //导入方法依赖的package包/类
public void recordInnerClasses(TypeBinding binding) {
if (this.innerClassesBindings == null) {
this.innerClassesBindings = new HashSet(INNER_CLASSES_SIZE);
}
ReferenceBinding innerClass = (ReferenceBinding) binding;
this.innerClassesBindings.add(innerClass.erasure());
ReferenceBinding enclosingType = innerClass.enclosingType();
while (enclosingType != null
&& enclosingType.isNestedType()) {
this.innerClassesBindings.add(enclosingType.erasure());
enclosingType = enclosingType.enclosingType();
}
}
示例8: 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$
}