当前位置: 首页>>代码示例>>Java>>正文


Java TypeBinding类代码示例

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


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

示例1: failIfContainsAnnotation

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
private static void failIfContainsAnnotation(TypeBinding parent, Binding[] bindings) throws DelegateRecursion {
	if (bindings == null) return;
	
	for (Binding b : bindings) {
		AnnotationBinding[] anns = null;
		if (b instanceof MethodBinding) anns = ((MethodBinding) b).getAnnotations();
		if (b instanceof FieldBinding) anns = ((FieldBinding) b).getAnnotations();
		// anns = b.getAnnotations() would make a heck of a lot more sense, but that is a late addition to ecj, so would cause NoSuchMethodErrors! Don't use that!
		if (anns == null) continue;
		for (AnnotationBinding ann : anns) {
			char[][] name = null;
			try {
				name = ann.getAnnotationType().compoundName;
			} catch (Exception ignore) {}
			
			if (name == null || name.length < 2 || name.length > 3) continue;
			if (!Arrays.equals(STRING_LOMBOK, name[0])) continue;
			if (!Arrays.equals(STRING_DELEGATE, name[name.length - 1])) continue;
			if (name.length == 3 && !Arrays.equals(STRING_EXPERIMENTAL, name[1])) continue;
			
			throw new DelegateRecursion(parent.readableName(), b.readableName());
		}
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:25,代码来源:PatchDelegate.java

示例2: typeBindingToSignature

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
private static String typeBindingToSignature(TypeBinding binding) {
	binding = binding.erasure();
	if (binding != null && binding.isBaseType()) {
		return new String (binding.sourceName());
	} else if (binding instanceof ReferenceBinding) {
		String pkg = binding.qualifiedPackageName() == null ? "" : new String(binding.qualifiedPackageName());
		String qsn = binding.qualifiedSourceName() == null ? "" : new String(binding.qualifiedSourceName());
		return pkg.isEmpty() ? qsn : (pkg + "." + qsn);
	} else if (binding instanceof ArrayBinding) {
		StringBuilder out = new StringBuilder();
		out.append(typeBindingToSignature(binding.leafComponentType()));
		for (int i = 0; i < binding.dimensions(); i++) out.append("[]");
		return out.toString();
	}
	
	return "";
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:18,代码来源:PatchDelegate.java

示例3: getFirstParameterType

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的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

示例4: handleValForForEach

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
public static boolean handleValForForEach(ForeachStatement forEach, BlockScope scope) {
	if (forEach.elementVariable == null) return false;
	
	if (!isVal(forEach.elementVariable.type, scope)) return false;
	
	TypeBinding component = getForEachComponentType(forEach.collection, scope);
	if (component == null) return false;
	TypeReference replacement = makeType(component, forEach.elementVariable.type, false);
	
	forEach.elementVariable.modifiers |= ClassFileConstants.AccFinal;
	forEach.elementVariable.annotations = addValAnnotation(forEach.elementVariable.annotations, forEach.elementVariable.type, scope);
	forEach.elementVariable.type = replacement != null ? replacement :
			new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(forEach.elementVariable.type, 3));
	
	return false;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:17,代码来源:PatchVal.java

示例5: getApplicableExtensionMethods

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
static List<Extension> getApplicableExtensionMethods(EclipseNode typeNode, Annotation ann, TypeBinding receiverType) {
	List<Extension> extensions = new ArrayList<Extension>();
	if ((typeNode != null) && (ann != null) && (receiverType != null)) {
		BlockScope blockScope = ((TypeDeclaration) typeNode.get()).initializerScope;
		EclipseNode annotationNode = typeNode.getNodeFor(ann);
		AnnotationValues<ExtensionMethod> annotation = createAnnotation(ExtensionMethod.class, annotationNode);
		boolean suppressBaseMethods = false;
		try {
			suppressBaseMethods = annotation.getInstance().suppressBaseMethods();
		} catch (AnnotationValueDecodeFail fail) {
			fail.owner.setError(fail.getMessage(), fail.idx);
		}
		for (Object extensionMethodProvider : annotation.getActualExpressions("value")) {
			if (extensionMethodProvider instanceof ClassLiteralAccess) {
				TypeBinding binding = ((ClassLiteralAccess) extensionMethodProvider).type.resolveType(blockScope);
				if (binding == null) continue;
				if (!binding.isClass() && !binding.isEnum()) continue;
				Extension e = new Extension();
				e.extensionMethods = getApplicableExtensionMethodsDefinedInProvider(typeNode, (ReferenceBinding) binding, receiverType);
				e.suppressBaseMethods = suppressBaseMethods;
				extensions.add(e);
			}
		}
	}
	return extensions;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:27,代码来源:PatchExtensionMethod.java

示例6: getApplicableExtensionMethodsDefinedInProvider

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
private static List<MethodBinding> getApplicableExtensionMethodsDefinedInProvider(EclipseNode typeNode, ReferenceBinding extensionMethodProviderBinding,
		TypeBinding receiverType) {
	
	List<MethodBinding> extensionMethods = new ArrayList<MethodBinding>();
	CompilationUnitScope cuScope = ((CompilationUnitDeclaration) typeNode.top().get()).scope;
	for (MethodBinding method : extensionMethodProviderBinding.methods()) {
		if (!method.isStatic()) continue;
		if (!method.isPublic()) continue;
		if (method.parameters == null || method.parameters.length == 0) continue;
		TypeBinding firstArgType = method.parameters[0];
		if (receiverType.isProvablyDistinct(firstArgType) && !receiverType.isCompatibleWith(firstArgType.erasure())) continue;
		TypeBinding[] argumentTypes = Arrays.copyOfRange(method.parameters, 1, method.parameters.length);
		if ((receiverType instanceof ReferenceBinding) && ((ReferenceBinding) receiverType).getExactMethod(method.selector, argumentTypes, cuScope) != null) continue;
		extensionMethods.add(method);
	}
	return extensionMethods;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:18,代码来源:PatchExtensionMethod.java

示例7: createNameRef

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
private static NameReference createNameRef(TypeBinding typeBinding, ASTNode source) {
	long p = ((long) source.sourceStart << 32) | source.sourceEnd;
	char[] pkg = typeBinding.qualifiedPackageName();
	char[] basename = typeBinding.qualifiedSourceName();
	
	StringBuilder sb = new StringBuilder();
	if (pkg != null) sb.append(pkg);
	if (sb.length() > 0) sb.append(".");
	sb.append(basename);
	
	String tName = sb.toString();
	
	if (tName.indexOf('.') == -1) {
		return new SingleNameReference(basename, p);
	} else {
		char[][] sources;
		String[] in = tName.split("\\.");
		sources = new char[in.length][];
		for (int i = 0; i < in.length; i++) sources[i] = in[i].toCharArray();
		long[] poss = new long[in.length];
		Arrays.fill(poss, p);
		return new QualifiedNameReference(sources, poss, source.sourceStart, source.sourceEnd);
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:25,代码来源:PatchExtensionMethod.java

示例8: resolvesReferenceBindingTo

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
/**
 * This is a recursive method which performs a depth first search in the inheritance graph of the given {@link TypeBinding}.
 * 
 * @param sb a TypeBinding
 * @param signature a fully qualified type
 * @return true if the given TypeBinding itself or one of its superclass/superinterfaces resolves to the given signature. false otherwise.
 */
private boolean resolvesReferenceBindingTo(TypeBinding sb, String signature) {
	if (sb == null) {
		return false;
	}
	if (new String(sb.readableName()).startsWith(signature) || (sb instanceof ArrayBinding && "array".equals(signature))) {
		return true;
	}
	List<ReferenceBinding> bindings = new ArrayList<>();
	if (sb instanceof ReferenceBinding) {
		ReferenceBinding rb = (ReferenceBinding) sb;
		Collections.addAll(bindings, rb.superInterfaces());
		bindings.add(rb.superclass());
	}
	boolean result = false;
	Iterator<ReferenceBinding> it = bindings.iterator();
	while (it.hasNext() && result == false) {
		result = resolvesReferenceBindingTo(it.next(), signature);
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:28,代码来源:JavaStatementPostfixContext.java

示例9: invalidOperator

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
	String leftName = new String(leftType.readableName());
	String rightName = new String(rightType.readableName());
	String leftShortName = new String(leftType.shortReadableName());
	String rightShortName = new String(rightType.shortReadableName());
	if (leftShortName.equals(rightShortName)){
		leftShortName = leftName;
		rightShortName = rightName;
	}
	this.handle(
		IProblem.InvalidOperator,
		new String[] {
			assign.operatorToString(),
			leftName + ", " + rightName}, //$NON-NLS-1$
		new String[] {
			assign.operatorToString(),
			leftShortName + ", " + rightShortName}, //$NON-NLS-1$
		assign.sourceStart,
		assign.sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:ProblemReporter.java

示例10: parameterizedMemberTypeMissingArguments

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
public void parameterizedMemberTypeMissingArguments(ASTNode location, TypeBinding type, int index) {
	if (location == null) { // binary case
	    this.handle(
			IProblem.MissingArgumentsForParameterizedMemberType,
			new String[] {new String(type.readableName())},
			new String[] {new String(type.shortReadableName())},
			ProblemSeverities.AbortCompilation | ProblemSeverities.Error | ProblemSeverities.Fatal,
			0,
			0);
	    return;
	}
    this.handle(
		IProblem.MissingArgumentsForParameterizedMemberType,
		new String[] {new String(type.readableName())},
		new String[] {new String(type.shortReadableName())},
		location.sourceStart,
		nodeSourceEnd(null, location, index));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:ProblemReporter.java

示例11: missingDefaultCase

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
public void missingDefaultCase(SwitchStatement switchStatement, boolean isEnumSwitch, TypeBinding expressionType) {
	if (isEnumSwitch) {
		this.handle(
				IProblem.MissingEnumDefaultCase,
				new String[] {new String(expressionType.readableName())},
				new String[] {new String(expressionType.shortReadableName())},
				switchStatement.expression.sourceStart,
				switchStatement.expression.sourceEnd);
	} else {
		this.handle(
				IProblem.MissingDefaultCase,
				NoArgument,
				NoArgument,
				switchStatement.expression.sourceStart,
				switchStatement.expression.sourceEnd);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:ProblemReporter.java

示例12: generateElementValue

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
private void generateElementValue(
		Expression defaultValue,
		TypeBinding memberValuePairReturnType,
		int attributeOffset) {
	Constant constant = defaultValue.constant;
	TypeBinding defaultValueBinding = defaultValue.resolvedType;
	if (defaultValueBinding == null) {
		this.contentsOffset = attributeOffset;
	} else {
		if (memberValuePairReturnType.isArrayType() && !defaultValueBinding.isArrayType()) {
			// automatic wrapping
			if (this.contentsOffset + 3 >= this.contents.length) {
				resizeContents(3);
			}
			this.contents[this.contentsOffset++] = (byte) '[';
			this.contents[this.contentsOffset++] = (byte) 0;
			this.contents[this.contentsOffset++] = (byte) 1;
		}
		if (constant != null && constant != Constant.NotAConstant) {
			generateElementValue(attributeOffset, defaultValue, constant, memberValuePairReturnType.leafComponentType());
		} else {
			generateElementValueForNonConstantExpression(defaultValue, attributeOffset, defaultValueBinding);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:ClassFile.java

示例13: internalResolveType

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
protected TypeBinding internalResolveType(Scope scope) {

		if (this.token != null) {
			return super.internalResolveType(scope);
		}

		// Resolve only receiver
		if (this.receiver == null) {
			this.actualReceiverType = scope.enclosingSourceType();
		} else if (scope.kind == Scope.CLASS_SCOPE) {
			this.actualReceiverType = this.receiver.resolveType((ClassScope) scope);
		} else {
			this.actualReceiverType = this.receiver.resolveType((BlockScope)scope);
		}
		return null;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:CompletionOnJavadocFieldReference.java

示例14: areSameTypes

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
/** Are both types identical wrt the unannotated type and any null type annotations? Only unstructured types and captures are considered. */
protected static boolean areSameTypes(TypeBinding requiredType, TypeBinding providedType, TypeBinding providedSubstitute) {
	if (requiredType == providedType)  //$IDENTITY-COMPARISON$ // short cut for really-really-same types
		return true;
	if (requiredType.isParameterizedType() || requiredType.isArrayType())
		return false; // not analysing details here
	if (TypeBinding.notEquals(requiredType, providedType)) {
		if (requiredType instanceof CaptureBinding) {
			// when providing exactly the lower bound of the required type we're definitely fine:
			TypeBinding lowerBound = ((CaptureBinding)requiredType).lowerBound;
			if (lowerBound != null && areSameTypes(lowerBound, providedType, providedSubstitute))
				return true;
		} else if (requiredType.kind() == Binding.TYPE_PARAMETER && requiredType == providedSubstitute) { //$IDENTITY-COMPARISON$
			return true;
		} else if (providedType instanceof CaptureBinding) {
			// when requiring exactly the upper bound of the provided type we're fine, too:
			TypeBinding upperBound = ((CaptureBinding)providedType).upperBound();
			if (upperBound != null && areSameTypes(requiredType, upperBound, providedSubstitute))
				return true;
		}
		return false;
	}
	return (requiredType.tagBits & TagBits.AnnotationNullMASK) == (providedType.tagBits & TagBits.AnnotationNullMASK);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:NullAnnotationMatching.java

示例15: unhandledException

import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; //导入依赖的package包/类
public void unhandledException(TypeBinding exceptionType, ASTNode location) {

	boolean insideDefaultConstructor =
		(this.referenceContext instanceof ConstructorDeclaration)
			&& ((ConstructorDeclaration)this.referenceContext).isDefaultConstructor();
	boolean insideImplicitConstructorCall =
		(location instanceof ExplicitConstructorCall)
			&& (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);

	int sourceEnd = location.sourceEnd;
	if (location instanceof LocalDeclaration) {
		sourceEnd = ((LocalDeclaration) location).declarationEnd;
	}
	this.handle(
		insideDefaultConstructor
			? IProblem.UnhandledExceptionInDefaultConstructor
			: (insideImplicitConstructorCall
					? IProblem.UndefinedConstructorInImplicitConstructorCall
					: IProblem.UnhandledException),
		new String[] {new String(exceptionType.readableName())},
		new String[] {new String(exceptionType.shortReadableName())},
		location.sourceStart,
		sourceEnd);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:25,代码来源:ProblemReporter.java


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