Java Code Examples for org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#isMemberType()

The following examples show how to use org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#isMemberType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Factory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private AnnotationMirrorImpl createAnnotationMirror(String annoTypeName, AnnotationBinding annoInstance) {
	ReferenceBinding binding = annoInstance.getAnnotationType();
	if (binding != null && binding.isAnnotationType() ) {
		char[] qName;
		if (binding.isMemberType()) {
			annoTypeName = annoTypeName.replace('$', '.');
			qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.');
			CharOperation.replace(qName, '$', '.');
		} else {
			qName = CharOperation.concatWith(binding.compoundName, '.');
		}
		if(annoTypeName.equals(new String(qName)) ){
			return (AnnotationMirrorImpl)_env.getFactory().newAnnotationMirror(annoInstance);
		}
	}
	return null;
}
 
Example 2
Source File: TypeElementImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean hides(Element hidden)
{
	if (!(hidden instanceof TypeElementImpl)) {
		return false;
	}
	ReferenceBinding hiddenBinding = (ReferenceBinding)((TypeElementImpl)hidden)._binding;
	if (hiddenBinding.isPrivate()) {
		return false;
	}
	ReferenceBinding hiderBinding = (ReferenceBinding)_binding;
	if (TypeBinding.equalsEquals(hiddenBinding, hiderBinding)) {
		return false;
	}
	if (!hiddenBinding.isMemberType() || !hiderBinding.isMemberType()) {
		return false;
	}
	if (!CharOperation.equals(hiddenBinding.sourceName, hiderBinding.sourceName)) {
		return false;
	}
	return null != hiderBinding.enclosingType().findSuperTypeOriginatingFrom(hiddenBinding.enclosingType()); 
}
 
Example 3
Source File: TypeElementImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public NestingKind getNestingKind() {
	ReferenceBinding refBinding = (ReferenceBinding)_binding;
	if (refBinding.isAnonymousType()) {
		return NestingKind.ANONYMOUS;
	} else if (refBinding.isLocalType()) {
		return NestingKind.LOCAL;
	} else if (refBinding.isMemberType()) {
		return NestingKind.MEMBER;
	}
	return NestingKind.TOP_LEVEL;
}
 
Example 4
Source File: TypeElementImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Name getQualifiedName() {
	ReferenceBinding binding = (ReferenceBinding)_binding;
	char[] qName;
	if (binding.isMemberType()) {
		qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.');
		CharOperation.replace(qName, '$', '.');
	} else {
		qName = CharOperation.concatWith(binding.compoundName, '.');
	}
	return new NameImpl(qName);
}
 
Example 5
Source File: ErrorTypeElement.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Name getQualifiedName() {
	ReferenceBinding binding = (ReferenceBinding)_binding;
	char[] qName;
	if (binding.isMemberType()) {
		qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.');
		CharOperation.replace(qName, '$', '.');
	} else {
		qName = CharOperation.concatWith(binding.compoundName, '.');
	}
	return new NameImpl(qName);
}
 
Example 6
Source File: TypeBinding.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean isLocal() {
	if (isClass() || isInterface() || isEnum()) {
		ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
		return referenceBinding.isLocalType() && !referenceBinding.isMemberType();
	}
	return false;
}
 
Example 7
Source File: TypeBinding.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean isMember() {
	if (isClass() || isInterface() || isEnum()) {
		ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
		return referenceBinding.isMemberType();
	}
	return false;
}
 
Example 8
Source File: QualifiedAllocationExpression.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
	// analyse the enclosing instance
	if (this.enclosingInstance != null) {
		flowInfo = this.enclosingInstance.analyseCode(currentScope, flowContext, flowInfo);
	} else {
		if (this.binding != null && this.binding.declaringClass != null) {
			ReferenceBinding superclass = this.binding.declaringClass.superclass();
			if (superclass != null && superclass.isMemberType() && !superclass.isStatic()) {
				// creating an anonymous type of a non-static member type without an enclosing instance of parent type
				currentScope.tagAsAccessingEnclosingInstanceStateOf(superclass.enclosingType(), false /* type variable access */);
				// Reviewed for https://bugs.eclipse.org/bugs/show_bug.cgi?id=378674 :
				// The corresponding problem (when called from static) is not produced until during code generation
			}
		}
		
	}

	// check captured variables are initialized in current context (26134)
	checkCapturedLocalInitializationIfNecessary(
		(ReferenceBinding)(this.anonymousType == null
			? this.binding.declaringClass.erasure()
			: this.binding.declaringClass.superclass().erasure()),
		currentScope,
		flowInfo);

	// process arguments
	if (this.arguments != null) {
		boolean analyseResources = currentScope.compilerOptions().analyseResourceLeaks;
		boolean hasResourceWrapperType = analyseResources 
					&& this.resolvedType instanceof ReferenceBinding 
					&& ((ReferenceBinding)this.resolvedType).hasTypeBit(TypeIds.BitWrapperCloseable);
		for (int i = 0, count = this.arguments.length; i < count; i++) {
			flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo);
			if (analyseResources && !hasResourceWrapperType) { // allocation of wrapped closeables is analyzed specially
				// if argument is an AutoCloseable insert info that it *may* be closed (by the target method, i.e.)
				flowInfo = FakedTrackingVariable.markPassedToOutside(currentScope, this.arguments[i], flowInfo, flowContext, false);
			}
			this.arguments[i].checkNPEbyUnboxing(currentScope, flowContext, flowInfo);
		}
		analyseArguments(currentScope, flowContext, flowInfo, this.binding, this.arguments);
	}

	// analyse the anonymous nested type
	if (this.anonymousType != null) {
		flowInfo = this.anonymousType.analyseCode(currentScope, flowContext, flowInfo);
	}

	// record some dependency information for exception types
	ReferenceBinding[] thrownExceptions;
	if (((thrownExceptions = this.binding.thrownExceptions).length) != 0) {
		if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=277643, align with javac on JLS 15.12.2.6
			thrownExceptions = currentScope.environment().convertToRawTypes(this.binding.thrownExceptions, true, true);
		}			
		// check exception handling
		flowContext.checkExceptionHandlers(
			thrownExceptions,
			this,
			flowInfo.unconditionalCopy(),
			currentScope);
	}

	// after having analysed exceptions above start tracking newly allocated resource:
	if (currentScope.compilerOptions().analyseResourceLeaks && FakedTrackingVariable.isAnyCloseable(this.resolvedType)) {
		FakedTrackingVariable.analyseCloseableAllocation(currentScope, flowInfo, this);
	}

	manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
	manageSyntheticAccessIfNecessary(currentScope, flowInfo);

	// account for possible exceptions thrown by constructor execution:
	flowContext.recordAbruptExit();

	return flowInfo;
}