javax.lang.model.util.Types.getNoType()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中javax.lang.model.util.Types.getNoType()方法的一些代码示例,展示了Types.getNoType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.getNoType()方法的具体详情如下:
包路径:javax.lang.model.util.Types
类名称:Types
方法名:getNoType

Types.getNoType介绍

[英]Returns a pseudo-type used where no actual type is appropriate. The kind of type to return may be either TypeKind#VOID or TypeKind#NONE. For packages, use Elements#getPackageElement(CharSequence) .asType()instead.
[中]返回在实际类型不合适的情况下使用的伪类型。返回的类型可以是TypeKind#VOID或TypeKind#NONE。对于包,使用元素#getPackageElement(CharSequence)。而不是asType()。

代码示例

代码示例来源:origin: org.jboss.logging/jboss-logging-processor

private VoidReturnType(final Types types) {
  voidType = types.getNoType(TypeKind.VOID);
  voidElement = types.asElement(voidType);
  hash = "void".hashCode();
}

代码示例来源:origin: neo4j/neo4j

private Stream<CompilationMessage> validateReturnType( ExecutableElement method )
{
  String streamClassName = Stream.class.getCanonicalName();
  TypeMirror streamType = typeUtils.erasure( elementUtils.getTypeElement( streamClassName ).asType() );
  TypeMirror returnType = method.getReturnType();
  TypeMirror erasedReturnType = typeUtils.erasure( returnType );
  TypeMirror voidType = typeUtils.getNoType( TypeKind.VOID );
  if ( typeUtils.isSameType( returnType, voidType ) )
  {
    return Stream.empty();
  }
  if ( !typeUtils.isSubtype( erasedReturnType, streamType ) )
  {
    return Stream.of( new ReturnTypeError( method, "Return type of %s#%s must be %s",
        method.getEnclosingElement().getSimpleName(), method.getSimpleName(), streamClassName ) );
  }
  return recordVisitor.visit( returnType );
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
 protected TypeMirror defaultAction(TypeMirror x, State state) {
  return state.types.getNoType(TypeKind.NONE);
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Utility method to convert a {@code Foo<BarProxy> -> BarDomain}. The
 * {@code param} parameter specifies the index of the type parameter to
 * extract.
 */
protected TypeMirror convertSingleParamType(DeclaredType x, DeclaredType convertTo, int param,
  State state) {
 DeclaredType converted = (DeclaredType) State.viewAs(convertTo, x, state);
 if (converted == null) {
  return state.types.getNoType(TypeKind.NONE);
 }
 if (converted.getTypeArguments().isEmpty()) {
  return defaultAction(x, state);
 }
 return converted.getTypeArguments().get(param).accept(this, state);
}

代码示例来源:origin: inferred/FreeBuilder

/** Returns a {@link TypeMirror} for the given class (raw T, not T&lt;?&gt;, if T is generic). */
public static TypeMirror typeMirror(
  Types typeUtils,
  Elements elementUtils,
  Class<?> cls) {
 if (cls.equals(void.class)) {
  return typeUtils.getNoType(TypeKind.VOID);
 } else if (cls.isPrimitive()) {
  return typeUtils.getPrimitiveType(TypeKind.valueOf(cls.getSimpleName().toUpperCase()));
 } else if (cls.isArray()) {
  return typeUtils.getArrayType(typeMirror(typeUtils, elementUtils, cls.getComponentType()));
 } else {
  return rawType(typeUtils, elementUtils, cls.getCanonicalName());
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

new MethodFinder(name, state.types.getNoType(TypeKind.VOID), lookFor, false, state).scan(
    domainElement, state);
if (domainMethod == null) {

代码示例来源:origin: org.revapi/revapi-java

@Override
public NoType getNoType(TypeKind kind) {
  return types.getNoType(kind);
}

代码示例来源:origin: org.checkerframework/dataflow

public MarkerNode(@Nullable Tree tree, String message, Types types) {
  super(types.getNoType(TypeKind.NONE));
  this.tree = tree;
  this.message = message;
}

代码示例来源:origin: org.checkerframework/dataflow

public SynchronizedNode(
    @Nullable Tree tree, Node expression, boolean startOfBlock, Types types) {
  super(types.getNoType(TypeKind.NONE));
  this.tree = tree;
  this.expression = expression;
  this.startOfBlock = startOfBlock;
}

代码示例来源:origin: com.github.wrdlbrnft/code-builder

public static TypeMirror get(ProcessingEnvironment processingEnvironment, Class<?> cls) {
    if (cls.isPrimitive()) {
      if(cls.equals(void.class)) {
        return processingEnvironment.getTypeUtils().getNoType(TypeKind.VOID);
      }
      final Class<?> boxedClass = PRIMITIVES_TO_WRAPPERS.get(cls);
      final TypeElement boxedElement = processingEnvironment.getElementUtils().getTypeElement(boxedClass.getName());
      return processingEnvironment.getTypeUtils().unboxedType(boxedElement.asType());
    }

    return processingEnvironment.getElementUtils().getTypeElement(cls.getName()).asType();
  }
}

代码示例来源:origin: stoicflame/enunciate

@Override
public TypeMirror getReceiverType() {
 return env.getTypeUtils().getNoType(TypeKind.NONE);
}

代码示例来源:origin: stoicflame/enunciate

@Override
public TypeMirror getReceiverType() {
 return env.getTypeUtils().getNoType(TypeKind.NONE);
}

代码示例来源:origin: stoicflame/enunciate

@Override
public TypeMirror getReceiverType() {
 return env.getTypeUtils().getNoType(TypeKind.NONE);
}

代码示例来源:origin: org.mapstruct/mapstruct-processor

/**
 * creates a void return type
 *
 * @return void type
 */
public Type createVoidType() {
  return getType( typeUtils.getNoType( TypeKind.VOID ) );
}

代码示例来源:origin: com.webcohesion.enunciate/enunciate-jackson

@Override
public TypeMirror getReceiverType() {
 return env.getTypeUtils().getNoType(TypeKind.NONE);
}

代码示例来源:origin: org.brightify.torch/torch-compiler

private boolean isGetter(ExecutableElement element) {
  return !types.isSameType(element.getReturnType(), types.getNoType(TypeKind.VOID)) &&
      element.getParameters().size() == 0;
}

代码示例来源:origin: org.brightify.torch/torch-compiler

private boolean isSetter(ExecutableElement element) {
  return types.isSameType(element.getReturnType(), types.getNoType(TypeKind.VOID)) &&
      element.getParameters().size() == 1;
}

代码示例来源:origin: com.moparisthebest.aptIn16/core

@Override
public VoidType getVoidType() {
  return ConvertTypeMirror.convert(internal.getNoType(TypeKind.VOID), VoidType.class);
}

代码示例来源:origin: org.checkerframework/dataflow

public CaseNode(CaseTree tree, Node switchExpr, Node caseExpr, Types types) {
  super(types.getNoType(TypeKind.NONE));
  assert tree.getKind().equals(Kind.CASE);
  this.tree = tree;
  this.switchExpr = switchExpr;
  this.caseExpr = caseExpr;
}

代码示例来源:origin: org.checkerframework/dataflow

public ReturnNode(ReturnTree t, @Nullable Node result, Types types, MethodTree methodTree) {
  super(types.getNoType(TypeKind.NONE));
  this.result = result;
  tree = t;
  result.setAssignmentContext(new MethodReturnContext(methodTree));
}

相关文章