• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java VariableBinding类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.VariableBinding的典型用法代码示例。如果您正苦于以下问题:Java VariableBinding类的具体用法?Java VariableBinding怎么用?Java VariableBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VariableBinding类属于org.eclipse.jdt.internal.compiler.lookup包,在下文中一共展示了VariableBinding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getFirstParameterType

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
static TypeBinding getFirstParameterType(TypeDeclaration decl, CompletionProposalCollector completionProposalCollector) {
		TypeBinding firstParameterType = null;
		ASTNode node = getAssistNode(completionProposalCollector);
		if (node == null) return null;
		if (!(node instanceof CompletionOnQualifiedNameReference) && !(node instanceof CompletionOnSingleNameReference) && !(node instanceof CompletionOnMemberAccess)) return null;
		
		// Never offer on 'super.<autocomplete>'.
		if (node instanceof FieldReference && ((FieldReference)node).receiver instanceof SuperReference) return null;
		
		if (node instanceof NameReference) {
			Binding binding = ((NameReference) node).binding;
			// Unremark next block to allow a 'blank' autocomplete to list any extensions that apply to the current scope, but make sure we're not in a static context first, which this doesn't do.
			// Lacking good use cases, and having this particular concept be a little tricky on javac, means for now we don't support extension methods like this. this.X() will be fine, though.
			
/*			if ((node instanceof SingleNameReference) && (((SingleNameReference) node).token.length == 0)) {
				firstParameterType = decl.binding;
			} else */if (binding instanceof VariableBinding) {
				firstParameterType = ((VariableBinding) binding).type;
			}
		} else if (node instanceof FieldReference) {
			firstParameterType = ((FieldReference) node).actualReceiverType;
		}
		return firstParameterType;
	}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:25,代码来源:PatchExtensionMethodCompletionProposal.java


示例2: consumeAnnotation

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
public void consumeAnnotation() {
	int size = this.types.size();
	if (size == 0) return;
	Binding annotationType = ((BindingKeyResolver) this.types.get(size-1)).compilerBinding;
	AnnotationBinding[] annotationBindings;
	if (this.compilerBinding == null && this.typeBinding instanceof ReferenceBinding) {
		annotationBindings = ((ReferenceBinding) this.typeBinding).getAnnotations();
	} else if (this.compilerBinding instanceof MethodBinding) {
		annotationBindings = ((MethodBinding) this.compilerBinding).getAnnotations();
	} else if (this.compilerBinding instanceof VariableBinding) {
		annotationBindings = ((VariableBinding) this.compilerBinding).getAnnotations();
	} else {
		return;
	}
	for (int i = 0, length = annotationBindings.length; i < length; i++) {
		AnnotationBinding binding = annotationBindings[i];
		if (binding.getAnnotationType() == annotationType) {
			this.annotationBinding = binding;
			break;
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:BindingKeyResolver.java


示例3: recordFinalAssignment

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
protected boolean recordFinalAssignment(
	VariableBinding binding,
	Reference finalAssignment) {
	if (this.assignCount == 0) {
		this.finalAssignments = new Reference[5];
		this.finalVariables = new VariableBinding[5];
	} else {
		if (this.assignCount == this.finalAssignments.length)
			System.arraycopy(
				this.finalAssignments,
				0,
				(this.finalAssignments = new Reference[this.assignCount * 2]),
				0,
				this.assignCount);
		System.arraycopy(
			this.finalVariables,
			0,
			(this.finalVariables = new VariableBinding[this.assignCount * 2]),
			0,
			this.assignCount);
	}
	this.finalAssignments[this.assignCount] = finalAssignment;
	this.finalVariables[this.assignCount++] = binding;
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:FinallyFlowContext.java


示例4: newElement

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
/**
 * Create a new element that knows what kind it is even if the binding is unresolved.
 */
public Element newElement(Binding binding, ElementKind kindHint) {
	if (binding == null)
		return null;
	switch (binding.kind()) {
	case Binding.FIELD:
	case Binding.LOCAL:
	case Binding.VARIABLE:
		return new VariableElementImpl(_env, (VariableBinding) binding);
	case Binding.TYPE:
	case Binding.GENERIC_TYPE:
		ReferenceBinding referenceBinding = (ReferenceBinding)binding;
		if ((referenceBinding.tagBits & TagBits.HasMissingType) != 0) {
			return new ErrorTypeElement(this._env, referenceBinding);
		}
		if (CharOperation.equals(referenceBinding.sourceName, TypeConstants.PACKAGE_INFO_NAME)) {
			return new PackageElementImpl(_env, referenceBinding.fPackage);
		}
		return new TypeElementImpl(_env, referenceBinding, kindHint);
	case Binding.METHOD:
		return new ExecutableElementImpl(_env, (MethodBinding)binding);
	case Binding.RAW_TYPE:
	case Binding.PARAMETERIZED_TYPE:
		return new TypeElementImpl(_env, ((ParameterizedTypeBinding)binding).genericType(), kindHint);
	case Binding.PACKAGE:
		return new PackageElementImpl(_env, (PackageBinding)binding);
	case Binding.TYPE_PARAMETER:
		return new TypeParameterElementImpl(_env, (TypeVariableBinding)binding);
		// TODO: fill in the rest of these
	case Binding.IMPORT:
	case Binding.ARRAY_TYPE:
	case Binding.BASE_TYPE:
	case Binding.WILDCARD_TYPE:
	case Binding.INTERSECTION_TYPE:
		throw new UnsupportedOperationException("NYI: binding type " + binding.kind()); //$NON-NLS-1$
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:41,代码来源:Factory.java


示例5: getConstantValue

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
@Override
public Object getConstantValue() {
	VariableBinding variableBinding = (VariableBinding) _binding;
	Constant constant = variableBinding.constant();
	if (constant == null || constant == Constant.NotAConstant) return null;
	TypeBinding type = variableBinding.type;
	switch (type.id) {
		case TypeIds.T_boolean:
			return constant.booleanValue();
		case TypeIds.T_byte:
			return constant.byteValue();
		case TypeIds.T_char:
			return constant.charValue();
		case TypeIds.T_double:
			return constant.doubleValue();
		case TypeIds.T_float:
			return constant.floatValue();
		case TypeIds.T_int:
			return constant.intValue();
		case TypeIds.T_JavaLangString:
			return constant.stringValue();
		case TypeIds.T_long:
			return constant.longValue();
		case TypeIds.T_short:
			return constant.shortValue();
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:VariableElementImpl.java


示例6: getModifiers

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
@Override
public Set<Modifier> getModifiers()
{
	if (_binding instanceof VariableBinding) {
		return Factory.getModifiers(((VariableBinding)_binding).modifiers, getKind());
	}
	return Collections.emptySet();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:VariableElementImpl.java


示例7: recordSettingFinal

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
public void recordSettingFinal(VariableBinding variable, Reference finalReference, FlowInfo flowInfo) {
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0)	{
	// for initialization inside looping statement that effectively loops
	FlowContext context = this;
	while (context != null) {
		if (!context.recordFinalAssignment(variable, finalReference)) {
			break; // no need to keep going
		}
		context = context.getLocalParent();
	}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:FlowContext.java


示例8: complainOnDeferredFinalChecks

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
/**
 * Perform deferred checks relative to final variables duplicate initialization
 * of lack of initialization.
 * @param scope the scope to which this context is associated
 * @param flowInfo the flow info against which checks must be performed
 */
public void complainOnDeferredFinalChecks(BlockScope scope, FlowInfo flowInfo) {
	// complain on final assignments in loops
	for (int i = 0; i < this.assignCount; i++) {
		VariableBinding variable = this.finalVariables[i];
		if (variable == null) continue;
		boolean complained = false; // remember if have complained on this final assignment
		if (variable instanceof FieldBinding) {
			if (flowInfo.isPotentiallyAssigned((FieldBinding)variable)) {
				complained = true;
				scope.problemReporter().duplicateInitializationOfBlankFinalField(
					(FieldBinding) variable,
					this.finalAssignments[i]);
			}
		} else {
			if (flowInfo.isPotentiallyAssigned((LocalVariableBinding)variable)) {
				variable.tagBits &= ~TagBits.IsEffectivelyFinal;
				if (variable.isFinal()) {
					complained = true;
					scope.problemReporter().duplicateInitializationOfFinalLocal(
						(LocalVariableBinding) variable,
						this.finalAssignments[i]);
				}
			}
		}
		// any reference reported at this level is removed from the parent context where it
		// could also be reported again
		if (complained) {
			FlowContext context = this.getLocalParent();
			while (context != null) {
				context.removeFinalAssignmentIfAny(this.finalAssignments[i]);
				context = context.getLocalParent();
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:42,代码来源:LoopingFlowContext.java


示例9: recordFinalAssignment

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
protected boolean recordFinalAssignment(
	VariableBinding binding,
	Reference finalAssignment) {

	// do not consider variables which are defined inside this loop
	if (binding instanceof LocalVariableBinding) {
		Scope scope = ((LocalVariableBinding) binding).declaringScope;
		while ((scope = scope.parent) != null) {
			if (scope == this.associatedScope)
				return false;
		}
	}
	if (this.assignCount == 0) {
		this.finalAssignments = new Reference[5];
		this.finalVariables = new VariableBinding[5];
	} else {
		if (this.assignCount == this.finalAssignments.length)
			System.arraycopy(
				this.finalAssignments,
				0,
				(this.finalAssignments = new Reference[this.assignCount * 2]),
				0,
				this.assignCount);
		System.arraycopy(
			this.finalVariables,
			0,
			(this.finalVariables = new VariableBinding[this.assignCount * 2]),
			0,
			this.assignCount);
	}
	this.finalAssignments[this.assignCount] = finalAssignment;
	this.finalVariables[this.assignCount++] = binding;
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:LoopingFlowContext.java


示例10: checkAssignment

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
/** Check null-ness of 'var' against a possible null annotation */
public static int checkAssignment(BlockScope currentScope, FlowContext flowContext,
								   VariableBinding var, int nullStatus, Expression expression, TypeBinding providedType)
{
	long lhsTagBits = 0L;
	boolean hasReported = false;
	if (currentScope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_8) {
		lhsTagBits = var.tagBits & TagBits.AnnotationNullMASK;
	} else {
		if (expression instanceof ConditionalExpression && expression.isPolyExpression()) {
			// drill into both branches:
			ConditionalExpression ce = ((ConditionalExpression) expression);
			int status1 = NullAnnotationMatching.checkAssignment(currentScope, flowContext, var, ce.ifTrueNullStatus, ce.valueIfTrue, ce.valueIfTrue.resolvedType);
			int status2 = NullAnnotationMatching.checkAssignment(currentScope, flowContext, var, ce.ifFalseNullStatus, ce.valueIfFalse, ce.valueIfFalse.resolvedType);
			if (status1 == status2)
				return status1;
			return nullStatus; // if both branches disagree use the precomputed & merged nullStatus
		}
		lhsTagBits = var.type.tagBits & TagBits.AnnotationNullMASK;
		NullAnnotationMatching annotationStatus = analyse(var.type, providedType, nullStatus);
		if (annotationStatus.isDefiniteMismatch()) {
			currentScope.problemReporter().nullityMismatchingTypeAnnotation(expression, providedType, var.type, annotationStatus);
			hasReported = true;
		} else if (annotationStatus.isUnchecked()) {
			flowContext.recordNullityMismatch(currentScope, expression, providedType, var.type, nullStatus);
			hasReported = true;
		} else if (annotationStatus.nullStatus != FlowInfo.UNKNOWN) {
			return annotationStatus.nullStatus;
		}
	}
	if (lhsTagBits == TagBits.AnnotationNonNull && nullStatus != FlowInfo.NON_NULL) {
		if (!hasReported)
			flowContext.recordNullityMismatch(currentScope, expression, providedType, var.type, nullStatus);
		return FlowInfo.NON_NULL;
	} else if (lhsTagBits == TagBits.AnnotationNullable && nullStatus == FlowInfo.UNKNOWN) {	// provided a legacy type?
		return FlowInfo.POTENTIALLY_NULL;			// -> use more specific info from the annotation
	}
	return nullStatus;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:40,代码来源:NullAnnotationMatching.java


示例11: generateCode

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
	if (this.shouldCaptureInstance) {
		this.binding.modifiers &= ~ClassFileConstants.AccStatic;
	} else {
		this.binding.modifiers |= ClassFileConstants.AccStatic;
	}
	SourceTypeBinding sourceType = currentScope.enclosingSourceType();
	this.binding = sourceType.addSyntheticMethod(this);
	int pc = codeStream.position;
	StringBuffer signature = new StringBuffer();
	signature.append('(');
	if (this.shouldCaptureInstance) {
		codeStream.aload_0();
		signature.append(sourceType.signature());
	}
	for (int i = 0, length = this.outerLocalVariables == null ? 0 : this.outerLocalVariables.length; i < length; i++) {
		SyntheticArgumentBinding syntheticArgument = this.outerLocalVariables[i];
		if (this.shouldCaptureInstance) {
			syntheticArgument.resolvedPosition++;
		}
		signature.append(syntheticArgument.type.signature());
		LocalVariableBinding capturedOuterLocal = syntheticArgument.actualOuterLocalVariable;
		VariableBinding[] path = currentScope.getEmulationPath(capturedOuterLocal);
		codeStream.generateOuterAccess(path, this, capturedOuterLocal, currentScope);
	}
	signature.append(')');
	if (this.expectedType instanceof IntersectionCastTypeBinding) {
		signature.append(((IntersectionCastTypeBinding)this.expectedType).getSAMType(currentScope).signature());
	} else {
		signature.append(this.expectedType.signature());
	}
	int invokeDynamicNumber = codeStream.classFile.recordBootstrapMethod(this);
	codeStream.invokeDynamic(invokeDynamicNumber, (this.shouldCaptureInstance ? 1 : 0) + this.outerLocalVariablesSlotSize, 1, this.descriptor.selector, signature.toString().toCharArray());
	if (!valueRequired)
		codeStream.pop();
	codeStream.recordPositionsFrom(pc, this.sourceStart);		
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:38,代码来源:LambdaExpression.java


示例12: checkNPE

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
public boolean checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo) {
	if (!super.checkNPE(scope, flowContext, flowInfo)) {
		CompilerOptions compilerOptions = scope.compilerOptions();
		if (compilerOptions.isAnnotationBasedNullAnalysisEnabled) {
			VariableBinding var = nullAnnotatedVariableBinding(compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8);
			if (var instanceof FieldBinding) {
				checkNullableFieldDereference(scope, (FieldBinding) var, ((long)this.sourceStart<<32)+this.sourceEnd);
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:SingleNameReference.java


示例13: nullAnnotatedVariableBinding

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
public VariableBinding nullAnnotatedVariableBinding(boolean supportTypeAnnotations) {
	switch (this.bits & ASTNode.RestrictiveFlagMASK) {
		case Binding.FIELD : // reading a field
		case Binding.LOCAL : // reading a local variable
			if (supportTypeAnnotations 
					|| (((VariableBinding)this.binding).tagBits & TagBits.AnnotationNullMASK) != 0)
				return (VariableBinding) this.binding;
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:SingleNameReference.java


示例14: nullAnnotatedVariableBinding

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
public VariableBinding nullAnnotatedVariableBinding(boolean supportTypeAnnotations) {
	if (this.binding != null) {
		if (supportTypeAnnotations
				|| ((this.binding.tagBits & TagBits.AnnotationNullMASK) != 0)) {
			return this.binding;
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:FieldReference.java


示例15: getFinalReceiverType

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
/**
 * Returns the receiver type for the final field in sequence (i.e. the return type of the previous binding)
 * @return receiver type for the final field in sequence
 */
protected TypeBinding getFinalReceiverType() {
	int otherBindingsCount = this.otherBindings == null ? 0 : this.otherBindings.length;
	switch (otherBindingsCount) {
		case 0 :
			return this.actualReceiverType;
		case 1 :
			return this.genericCast != null ? this.genericCast : ((VariableBinding)this.binding).type;
		default:
			TypeBinding previousGenericCast = this.otherGenericCasts == null ? null : this.otherGenericCasts[otherBindingsCount-2];
			return previousGenericCast != null ? previousGenericCast : this.otherBindings[otherBindingsCount-2].type;
	}	
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:QualifiedNameReference.java


示例16: nullityMismatch

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
public void nullityMismatch(Expression expression, TypeBinding providedType, TypeBinding requiredType, int nullStatus, char[][] annotationName) {
	if ((nullStatus & FlowInfo.NULL) != 0) {
		nullityMismatchIsNull(expression, requiredType);
		return;
	}
	if (expression instanceof MessageSend) {
		if ((((MessageSend) expression).binding.tagBits & TagBits.AnnotationNullable) != 0) {
			nullityMismatchSpecdNullable(expression, requiredType, this.options.nonNullAnnotationName);
			return;
		}
	}
	if ((nullStatus & FlowInfo.POTENTIALLY_NULL) != 0) {
		VariableBinding var = expression.localVariableBinding();
		if (var == null && expression instanceof Reference) {
			var = ((Reference)expression).lastFieldBinding();
		}
		if (var != null && var.isNullable()) {
			nullityMismatchSpecdNullable(expression, requiredType, annotationName);
			return;
		}
		nullityMismatchPotentiallyNull(expression, requiredType, annotationName);
		return;
	}
	if (this.options.sourceLevel < ClassFileConstants.JDK1_8)
		nullityMismatchIsUnknown(expression, providedType, requiredType, annotationName);
	else
		nullityMismatchingTypeAnnotation(expression, providedType, requiredType, NullAnnotationMatching.NULL_ANNOTATIONS_UNCHECKED);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:ProblemReporter.java


示例17: resolveNodeToBinding

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
protected Binding resolveNodeToBinding(ASTNode node) {
	if (node instanceof NameReference) {
   		NameReference nr = (NameReference) node;
		if (nr.binding instanceof VariableBinding) {
			VariableBinding vb = (VariableBinding) nr.binding;
			return vb.type;
		}
	} else if (node instanceof FieldReference) {
   		FieldReference fr = (FieldReference) node;
		return fr.receiver.resolvedType;
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:JavaStatementPostfixContext.java


示例18: newElement

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
/**
 * Create a new element that knows what kind it is even if the binding is unresolved.
 */
public Element newElement(Binding binding, ElementKind kindHint) {
	switch (binding.kind()) {
	case Binding.FIELD:
	case Binding.LOCAL:
	case Binding.VARIABLE:
		return new VariableElementImpl(_env, (VariableBinding) binding);
	case Binding.TYPE:
	case Binding.GENERIC_TYPE:
		ReferenceBinding referenceBinding = (ReferenceBinding)binding;
		if ((referenceBinding.tagBits & TagBits.HasMissingType) != 0) {
			return new ErrorTypeElement(this._env, referenceBinding);
		}
		if (referenceBinding.sourceName == TypeConstants.PACKAGE_INFO_NAME) {
			return new PackageElementImpl(_env, referenceBinding.fPackage);
		}
		return new TypeElementImpl(_env, referenceBinding, kindHint);
	case Binding.METHOD:
		return new ExecutableElementImpl(_env, (MethodBinding)binding);
	case Binding.RAW_TYPE:
	case Binding.PARAMETERIZED_TYPE:
		return new TypeElementImpl(_env, ((ParameterizedTypeBinding)binding).genericType(), kindHint);
	case Binding.PACKAGE:
		return new PackageElementImpl(_env, (PackageBinding)binding);
	case Binding.TYPE_PARAMETER:
		return new TypeParameterElementImpl(_env, (TypeVariableBinding)binding);
		// TODO: fill in the rest of these
	case Binding.IMPORT:
	case Binding.ARRAY_TYPE:
	case Binding.BASE_TYPE:
	case Binding.WILDCARD_TYPE:
	case Binding.INTERSECTION_TYPE:
		throw new UnsupportedOperationException("NYI: binding type " + binding.kind()); //$NON-NLS-1$
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:39,代码来源:Factory.java


示例19: complainOnDeferredFinalChecks

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
/**
 * Perform deferred checks relative to final variables duplicate initialization
 * of lack of initialization.
 * @param scope the scope to which this context is associated
 * @param flowInfo the flow info against which checks must be performed
 */
public void complainOnDeferredFinalChecks(BlockScope scope, FlowInfo flowInfo) {
	// complain on final assignments in loops
	for (int i = 0; i < this.assignCount; i++) {
		VariableBinding variable = this.finalVariables[i];
		if (variable == null) continue;
		boolean complained = false; // remember if have complained on this final assignment
		if (variable instanceof FieldBinding) {
			if (flowInfo.isPotentiallyAssigned((FieldBinding)variable)) {
				complained = true;
				scope.problemReporter().duplicateInitializationOfBlankFinalField(
					(FieldBinding) variable,
					this.finalAssignments[i]);
			}
		} else {
			if (flowInfo.isPotentiallyAssigned((LocalVariableBinding)variable)) {
				complained = true;
				scope.problemReporter().duplicateInitializationOfFinalLocal(
					(LocalVariableBinding) variable,
					this.finalAssignments[i]);
			}
		}
		// any reference reported at this level is removed from the parent context where it
		// could also be reported again
		if (complained) {
			FlowContext context = this.getLocalParent();
			while (context != null) {
				context.removeFinalAssignmentIfAny(this.finalAssignments[i]);
				context = context.getLocalParent();
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:39,代码来源:LoopingFlowContext.java


示例20: newTypeMirror

import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; //导入依赖的package包/类
/**
 * Given a binding of uncertain type, try to create the right sort of TypeMirror for it.
 */
public TypeMirror newTypeMirror(Binding binding) {
	switch (binding.kind()) {
	case Binding.FIELD:
	case Binding.LOCAL:
	case Binding.VARIABLE:
		// For variables, return the type of the variable
		return newTypeMirror(((VariableBinding)binding).type);
		
	case Binding.PACKAGE:
		return getNoType(TypeKind.PACKAGE);
		
	case Binding.IMPORT:
		throw new UnsupportedOperationException("NYI: import type " + binding.kind()); //$NON-NLS-1$

	case Binding.METHOD:
		return new ExecutableTypeImpl(_env, (MethodBinding) binding);
		
	case Binding.TYPE:
	case Binding.RAW_TYPE:
	case Binding.GENERIC_TYPE:
	case Binding.PARAMETERIZED_TYPE:
		ReferenceBinding referenceBinding = (ReferenceBinding) binding;
		if ((referenceBinding.tagBits & TagBits.HasMissingType) != 0) {
			return getErrorType(referenceBinding);
		}
		return new DeclaredTypeImpl(_env, (ReferenceBinding)binding);
		
	case Binding.ARRAY_TYPE:
		return new ArrayTypeImpl(_env, (ArrayBinding)binding);
		
	case Binding.BASE_TYPE:
		BaseTypeBinding btb = (BaseTypeBinding)binding;
		switch (btb.id) {
			case TypeIds.T_void:
				return getNoType(TypeKind.VOID);
			case TypeIds.T_null:
				return getNullType();
			default:
				return getPrimitiveType(btb);
		}

	case Binding.WILDCARD_TYPE:
	case Binding.INTERSECTION_TYPE: // TODO compatible, but shouldn't it really be an intersection type?
		return new WildcardTypeImpl(_env, (WildcardBinding) binding);

	case Binding.TYPE_PARAMETER:
		return new TypeVariableImpl(_env, (TypeVariableBinding) binding);
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:54,代码来源:Factory.java



注:本文中的org.eclipse.jdt.internal.compiler.lookup.VariableBinding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OpenIdCredentialsAuthenticationHandler类代码示例发布时间:2022-05-22
下一篇:
Java Photoset类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap