當前位置: 首頁>>代碼示例>>Java>>正文


Java TypeResolver類代碼示例

本文整理匯總了Java中lombok.core.TypeResolver的典型用法代碼示例。如果您正苦於以下問題:Java TypeResolver類的具體用法?Java TypeResolver怎麽用?Java TypeResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TypeResolver類屬於lombok.core包,在下文中一共展示了TypeResolver類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleAnnotation

import lombok.core.TypeResolver; //導入依賴的package包/類
/**
 * Handles the provided annotation node by first finding a qualifying instance of
 * {@link EclipseAnnotationHandler} and if one exists, calling it with a freshly cooked up
 * instance of {@link AnnotationValues}.
 * 
 * Note that depending on the printASTOnly flag, the {@link lombok.core.PrintAST} annotation
 * will either be silently skipped, or everything that isn't {@code PrintAST} will be skipped.
 * 
 * The HandlerLibrary will attempt to guess if the given annotation node represents a lombok annotation.
 * For example, if {@code lombok.*} is in the import list, then this method will guess that
 * {@code Getter} refers to {@code lombok.Getter}, presuming that {@link lombok.eclipse.handlers.HandleGetter}
 * has been loaded.
 * 
 * @param ast The Compilation Unit that contains the Annotation AST Node.
 * @param annotationNode The Lombok AST Node representing the Annotation AST Node.
 * @param annotation 'node.get()' - convenience parameter.
 */
public void handleAnnotation(CompilationUnitDeclaration ast, EclipseNode annotationNode, org.eclipse.jdt.internal.compiler.ast.Annotation annotation, long priority) {
	TypeResolver resolver = new TypeResolver(annotationNode.getImportList());
	TypeReference rawType = annotation.type;
	if (rawType == null) return;
	
	String fqn = resolver.typeRefToFullyQualifiedName(annotationNode, typeLibrary, toQualifiedName(annotation.type.getTypeName()));
	if (fqn == null) return;
	AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn);
	if (container == null) return;
	if (priority != container.getPriority()) return;
	
	if (!annotationNode.isCompleteParse() && container.deferUntilPostDiet()) {
		if (needsHandling(annotation)) container.preHandle(annotation, annotationNode);
		return;
	}
	
	try {
		if (checkAndSetHandled(annotation)) container.handle(annotation, annotationNode);
	} catch (AnnotationValueDecodeFail fail) {
		fail.owner.setError(fail.getMessage(), fail.idx);
	} catch (Throwable t) {
		error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
	}
}
 
開發者ID:git03394538,項目名稱:lombok-ianchiu,代碼行數:42,代碼來源:HandlerLibrary.java

示例2: handleAnnotation

import lombok.core.TypeResolver; //導入依賴的package包/類
/**
 * Handles the provided annotation node by first finding a qualifying instance of
 * {@link JavacAnnotationHandler} and if one exists, calling it with a freshly cooked up
 * instance of {@link lombok.core.AnnotationValues}.
 * 
 * Note that depending on the printASTOnly flag, the {@link lombok.core.PrintAST} annotation
 * will either be silently skipped, or everything that isn't {@code PrintAST} will be skipped.
 * 
 * The HandlerLibrary will attempt to guess if the given annotation node represents a lombok annotation.
 * For example, if {@code lombok.*} is in the import list, then this method will guess that
 * {@code Getter} refers to {@code lombok.Getter}, presuming that {@link lombok.javac.handlers.HandleGetter}
 * has been loaded.
 * 
 * @param unit The Compilation Unit that contains the Annotation AST Node.
 * @param node The Lombok AST Node representing the Annotation AST Node.
 * @param annotation 'node.get()' - convenience parameter.
 */
public void handleAnnotation(JCCompilationUnit unit, JavacNode node, JCAnnotation annotation, long priority) {
	TypeResolver resolver = new TypeResolver(node.getImportList());
	String rawType = annotation.annotationType.toString();
	String fqn = resolver.typeRefToFullyQualifiedName(node, typeLibrary, rawType);
	if (fqn == null) return;
	AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn);
	if (container == null) return;
	
	try {
		if (container.getPriority() == priority) {
			if (checkAndSetHandled(annotation)) container.handle(node);
		}
	} catch (AnnotationValueDecodeFail fail) {
		fail.owner.setError(fail.getMessage(), fail.idx);
	} catch (Throwable t) {
		String sourceName = "(unknown).java";
		if (unit != null && unit.sourcefile != null) sourceName = unit.sourcefile.getName();
		javacError(String.format("Lombok annotation handler %s failed on " + sourceName, container.handler.getClass()), t);
	}
}
 
開發者ID:git03394538,項目名稱:lombok-ianchiu,代碼行數:38,代碼來源:HandlerLibrary.java

示例3: handleAnnotation

import lombok.core.TypeResolver; //導入依賴的package包/類
/**
 * Handles the provided annotation node by first finding a qualifying instance of
 * {@link EclipseAnnotationHandler} and if one exists, calling it with a freshly cooked up
 * instance of {@link AnnotationValues}.
 * 
 * Note that depending on the printASTOnly flag, the {@link lombok.core.PrintAST} annotation
 * will either be silently skipped, or everything that isn't {@code PrintAST} will be skipped.
 * 
 * The HandlerLibrary will attempt to guess if the given annotation node represents a lombok annotation.
 * For example, if {@code lombok.*} is in the import list, then this method will guess that
 * {@code Getter} refers to {@code lombok.Getter}, presuming that {@link lombok.eclipse.handlers.HandleGetter}
 * has been loaded.
 * 
 * @param ast The Compilation Unit that contains the Annotation AST Node.
 * @param annotationNode The Lombok AST Node representing the Annotation AST Node.
 * @param annotation 'node.get()' - convenience parameter.
 */
public void handleAnnotation(CompilationUnitDeclaration ast, EclipseNode annotationNode, org.eclipse.jdt.internal.compiler.ast.Annotation annotation, long priority) {
	TypeResolver resolver = new TypeResolver(annotationNode.getImportList());
	TypeReference rawType = annotation.type;
	if (rawType == null) return;
	
	String fqn = resolver.typeRefToFullyQualifiedName(annotationNode, typeLibrary, toQualifiedName(annotation.type.getTypeName()));
	if (fqn == null) return;
	AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn);
	if (container == null) return;
	if (priority != container.getPriority()) return;
	if (container.deferUntilBuildFieldsAndMethods()) return;
	
	if (!annotationNode.isCompleteParse() && container.deferUntilPostDiet()) {
		if (needsHandling(annotation)) container.preHandle(annotation, annotationNode);
		return;
	}
	
	try {
		if (checkAndSetHandled(annotation)) container.handle(annotation, annotationNode);
	} catch (AnnotationValueDecodeFail fail) {
		fail.owner.setError(fail.getMessage(), fail.idx);
	} catch (Throwable t) {
		error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
	}
}
 
開發者ID:redundent,項目名稱:lombok,代碼行數:43,代碼來源:HandlerLibrary.java

示例4: typeMatches

import lombok.core.TypeResolver; //導入依賴的package包/類
/**
 * Checks if the given TypeReference node is likely to be a reference to the provided class.
 * 
 * @param type An actual type. This method checks if {@code typeNode} is likely to be a reference to this type.
 * @param node A Lombok AST node. Any node in the appropriate compilation unit will do (used to get access to import statements).
 * @param typeRef A type reference to check.
 */
public static boolean typeMatches(Class<?> type, EclipseNode node, TypeReference typeRef) {
	if (typeRef == null || typeRef.getTypeName() == null || typeRef.getTypeName().length == 0) return false;
	String lastPartA = new String(typeRef.getTypeName()[typeRef.getTypeName().length -1]);
	String lastPartB = type.getSimpleName();
	if (!lastPartA.equals(lastPartB)) return false;
	String typeName = toQualifiedName(typeRef.getTypeName());
	
	TypeResolver resolver = new TypeResolver(node.getImportList());
	return resolver.typeMatches(node, type.getName(), typeName);
	
}
 
開發者ID:git03394538,項目名稱:lombok-ianchiu,代碼行數:19,代碼來源:EclipseHandlerUtil.java

示例5: typeMatches

import lombok.core.TypeResolver; //導入依賴的package包/類
/**
 * Checks if the given TypeReference node is likely to be a reference to the provided class.
 * 
 * @param type An actual type. This method checks if {@code typeNode} is likely to be a reference to this type.
 * @param node A Lombok AST node. Any node in the appropriate compilation unit will do (used to get access to import statements).
 * @param typeNode A type reference to check.
 */
public static boolean typeMatches(Class<?> type, JavacNode node, JCTree typeNode) {
	String typeName = typeNode.toString();
	
	TypeResolver resolver = new TypeResolver(node.getImportList());
	return resolver.typeMatches(node, type.getName(), typeName);
}
 
開發者ID:git03394538,項目名稱:lombok-ianchiu,代碼行數:14,代碼來源:JavacHandlerUtil.java


注:本文中的lombok.core.TypeResolver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。