org.eclipse.jdt.internal.compiler.lookup.BlockScope.getStaticFactory()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(77)

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

BlockScope.getStaticFactory介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.jetty.orbit/org.eclipse.jdt.core

public TypeBinding[] inferElidedTypes(ReferenceBinding allocationType, ReferenceBinding enclosingType, TypeBinding[] argumentTypes, final BlockScope scope) {
  /* Given the allocation type and the arguments to the constructor, see if we can synthesize a generic static factory
    method that would, given the argument types and the invocation site, manufacture a parameterized object of type allocationType.
    If we are successful then by design and construction, the parameterization of the return type of the factory method is identical
    to the types elided in the <>.
   */   
  MethodBinding factory = scope.getStaticFactory(allocationType, enclosingType, argumentTypes, this);
  if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) {
    ParameterizedGenericMethodBinding genericFactory = (ParameterizedGenericMethodBinding) factory;
    this.inferredReturnType = genericFactory.inferredReturnType;
    return ((ParameterizedTypeBinding)factory.returnType).arguments;
  }
  return null;
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

public TypeBinding[] inferElidedTypes(ParameterizedTypeBinding allocationType, ReferenceBinding enclosingType, TypeBinding[] argumentTypes, final BlockScope scope) {
  /* Given the allocation type and the arguments to the constructor, see if we can synthesize a generic static factory
    method that would, given the argument types and the invocation site, manufacture a parameterized object of type allocationType.
    If we are successful then by design and construction, the parameterization of the return type of the factory method is identical
    to the types elided in the <>.
   */   
  MethodBinding factory = scope.getStaticFactory(allocationType, enclosingType, argumentTypes, this);
  if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) {
    ParameterizedGenericMethodBinding genericFactory = (ParameterizedGenericMethodBinding) factory;
    this.inferredReturnType = genericFactory.inferredReturnType;
    // this is our last chance to inspect the result of the inference that is connected to the throw-away factory binding
    InferenceContext18 infCtx18 = getInferenceContext(genericFactory);
    if (infCtx18 != null && infCtx18.stepCompleted == InferenceContext18.BINDINGS_UPDATED) {
      // refresh argumentTypes from updated bindings in arguments:
      // (this shouldn't be strictly necessary, as FunctionExpression.isCompatibleWith() should give the same result,
      //  but it's probably be a good idea to avoid the necessity to call isCompatibleWith() in the first place). 
      for (int i = 0; i < argumentTypes.length; i++) {
        if (argumentTypes[i] instanceof PolyTypeBinding)
          argumentTypes[i] = this.arguments[i].resolvedType;
      }
    }
    return ((ParameterizedTypeBinding)factory.returnType).arguments;
  }
  return null;
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

public TypeBinding[] inferElidedTypes(ParameterizedTypeBinding allocationType, ReferenceBinding enclosingType, TypeBinding[] argumentTypes, final BlockScope scope) {
  /* Given the allocation type and the arguments to the constructor, see if we can synthesize a generic static factory
    method that would, given the argument types and the invocation site, manufacture a parameterized object of type allocationType.
    If we are successful then by design and construction, the parameterization of the return type of the factory method is identical
    to the types elided in the <>.
   */   
  MethodBinding factory = scope.getStaticFactory(allocationType, enclosingType, argumentTypes, this);
  if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) {
    ParameterizedGenericMethodBinding genericFactory = (ParameterizedGenericMethodBinding) factory;
    this.inferredReturnType = genericFactory.inferredReturnType;
    // this is our last chance to inspect the result of the inference that is connected to the throw-away factory binding
    InferenceContext18 infCtx18 = getInferenceContext(genericFactory);
    if (infCtx18 != null && infCtx18.stepCompleted == InferenceContext18.BINDINGS_UPDATED) {
      // refresh argumentTypes from updated bindings in arguments:
      // (this shouldn't be strictly necessary, as FunctionExpression.isCompatibleWith() should give the same result,
      //  but it's probably be a good idea to avoid the necessity to call isCompatibleWith() in the first place). 
      for (int i = 0; i < argumentTypes.length; i++) {
        if (argumentTypes[i] instanceof PolyTypeBinding)
          argumentTypes[i] = this.arguments[i].resolvedType;
      }
    }
    return ((ParameterizedTypeBinding)factory.returnType).arguments;
  }
  return null;
}

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

public TypeBinding[] inferElidedTypes(ParameterizedTypeBinding allocationType, ReferenceBinding enclosingType, TypeBinding[] argumentTypes, final BlockScope scope) {
  /* Given the allocation type and the arguments to the constructor, see if we can synthesize a generic static factory
    method that would, given the argument types and the invocation site, manufacture a parameterized object of type allocationType.
    If we are successful then by design and construction, the parameterization of the return type of the factory method is identical
    to the types elided in the <>.
   */   
  MethodBinding factory = scope.getStaticFactory(allocationType, enclosingType, argumentTypes, this);
  if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) {
    ParameterizedGenericMethodBinding genericFactory = (ParameterizedGenericMethodBinding) factory;
    this.inferredReturnType = genericFactory.inferredReturnType;
    // this is our last chance to inspect the result of the inference that is connected to the throw-away factory binding
    InferenceContext18 infCtx18 = getInferenceContext(genericFactory);
    if (infCtx18 != null && infCtx18.stepCompleted == InferenceContext18.BINDINGS_UPDATED) {
      // refresh argumentTypes from updated bindings in arguments:
      // (this shouldn't be strictly necessary, as FunctionExpression.isCompatibleWith() should give the same result,
      //  but it's probably be a good idea to avoid the necessity to call isCompatibleWith() in the first place). 
      for (int i = 0; i < argumentTypes.length; i++) {
        if (argumentTypes[i] instanceof PolyTypeBinding)
          argumentTypes[i] = this.arguments[i].resolvedType;
      }
    }
    return ((ParameterizedTypeBinding)factory.returnType).arguments;
  }
  return null;
}

相关文章

微信公众号

最新文章

更多

BlockScope类方法