本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}