Java Code Examples for com.sun.tools.javac.util.List#from()

The following examples show how to use com.sun.tools.javac.util.List#from() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Template.java    From Refaster with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a list of the expected types of the expression arguments, in order. 
 * (This is equivalent to the list of argument types of the @BeforeTemplate method.)
 *
 * @throws CouldNotResolveImportException if a referenced type could not be resolved
 */
protected List<Type> expectedTypes(Inliner inliner) throws CouldNotResolveImportException {
  Type[] result = new Type[expressionArgumentTypes().size()];
  ImmutableList<UType> types = expressionArgumentTypes().values().asList();
  ImmutableList<String> argNames = expressionArgumentTypes().keySet().asList();
  for (int i = 0; i < result.length; i++) {
    String argName = argNames.get(i);
    Optional<JCExpression> singleBinding =
        inliner.getOptionalBinding(new UFreeIdent.Key(argName));
    if (!singleBinding.isPresent()) {
      Optional<java.util.List<JCExpression>> exprs =
          inliner.getOptionalBinding(new URepeated.Key(argName));
      if (!exprs.isPresent() || exprs.get().isEmpty()) {
        // It is a repeated template variable and matches no expressions.
        continue;
      }
    }
    result[i] = types.get(i).inline(inliner);
  }
  return List.from(result);
}
 
Example 2
Source File: Analyzer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method is used to parse the {@code find} option.
 * Possible modes are separated by colon; a mode can be excluded by
 * prepending '-' to its name. Finally, the special mode 'all' can be used to
 * add all modes to the resulting enum.
 */
static EnumSet<AnalyzerMode> getAnalyzerModes(String opt, Source source) {
    if (opt == null) {
        return EnumSet.noneOf(AnalyzerMode.class);
    }
    List<String> modes = List.from(opt.split(","));
    EnumSet<AnalyzerMode> res = EnumSet.noneOf(AnalyzerMode.class);
    if (modes.contains("all")) {
        res = EnumSet.allOf(AnalyzerMode.class);
    }
    for (AnalyzerMode mode : values()) {
        if (modes.contains(mode.opt)) {
            res.add(mode);
        } else if (modes.contains("-" + mode.opt) || !mode.sourceFilter.test(source)) {
            res.remove(mode);
        }
    }
    return res;
}
 
Example 3
Source File: StructuralTypeEraser.java    From manifold with Apache License 2.0 6 votes vote down vote up
@Override
public Type visitClassType( Type.ClassType t, Void s )
{
  boolean erased = false;
  Type erasure = _types.erasure( t );
  Type base = visitType( erasure, s );
  if( base != erasure )
  {
    erased = true;
  }
  ArrayList<Type> params = new ArrayList<>();
  for( Type arg : t.allparams() )
  {
    Type param = visit( arg );
    params.add( param );
    if( param != arg )
    {
      erased = true;
    }
  }
  if( erased )
  {
    return new Type.ClassType( t.getEnclosingType(), List.from( params ), base.tsym );
  }
  return t;
}
 
Example 4
Source File: FromArray.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void test(String... args) {
    List<String> ss = List.from(args);
    if (args != null) {
        for (String s : args) {
            if (s != ss.head)
                throw new AssertionError("s != ss.head (" + s + ", " + ss.head + ")");
            ss = ss.tail;
        }
    }
    if (!ss.isEmpty())
        throw new AssertionError("!ss.isEmpty (" + ss + ")");
}
 
Example 5
Source File: HandleToString.java    From EasyMPermission with MIT License 5 votes vote down vote up
@Override public void handle(AnnotationValues<ToString> annotation, JCAnnotation ast, JavacNode annotationNode) {
	handleFlagUsage(annotationNode, ConfigurationKeys.TO_STRING_FLAG_USAGE, "@ToString");
	
	deleteAnnotationIfNeccessary(annotationNode, ToString.class);
	
	ToString ann = annotation.getInstance();
	List<String> excludes = List.from(ann.exclude());
	List<String> includes = List.from(ann.of());
	JavacNode typeNode = annotationNode.up();
	
	checkForBogusFieldNames(typeNode, annotation);
	
	Boolean callSuper = ann.callSuper();
	
	if (!annotation.isExplicit("callSuper")) callSuper = null;
	if (!annotation.isExplicit("exclude")) excludes = null;
	if (!annotation.isExplicit("of")) includes = null;
	
	if (excludes != null && includes != null) {
		excludes = null;
		annotation.setWarning("exclude", "exclude and of are mutually exclusive; the 'exclude' parameter will be ignored.");
	}
	
	Boolean doNotUseGettersConfiguration = annotationNode.getAst().readConfiguration(ConfigurationKeys.TO_STRING_DO_NOT_USE_GETTERS);
	boolean doNotUseGetters = annotation.isExplicit("doNotUseGetters") || doNotUseGettersConfiguration == null ? ann.doNotUseGetters() : doNotUseGettersConfiguration;
	FieldAccess fieldAccess = doNotUseGetters ? FieldAccess.PREFER_FIELD : FieldAccess.GETTER;
	
	Boolean fieldNamesConfiguration = annotationNode.getAst().readConfiguration(ConfigurationKeys.TO_STRING_INCLUDE_FIELD_NAMES);
	boolean includeFieldNames = annotation.isExplicit("includeFieldNames") || fieldNamesConfiguration == null ? ann.includeFieldNames() : fieldNamesConfiguration;
	
	generateToString(typeNode, annotationNode, excludes, includes, includeFieldNames, callSuper, true, fieldAccess);
}
 
Example 6
Source File: Infer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Solve variables in a given inference context. The amount of variables
 * to be solved, and the way in which the underlying acyclic graph is explored
 * depends on the selected solver strategy.
 */
void solve(GraphStrategy sstrategy) {
    checkWithinBounds(inferenceContext, warn); //initial propagation of bounds
    InferenceGraph inferenceGraph = new InferenceGraph(stuckDeps);
    while (!sstrategy.done()) {
        InferenceGraph.Node nodeToSolve = sstrategy.pickNode(inferenceGraph);
        List<Type> varsToSolve = List.from(nodeToSolve.data);
        List<Type> saved_undet = inferenceContext.save();
        try {
            //repeat until all variables are solved
            outer: while (Type.containsAny(inferenceContext.restvars(), varsToSolve)) {
                //for each inference phase
                for (GraphInferenceSteps step : GraphInferenceSteps.values()) {
                    if (inferenceContext.solveBasic(varsToSolve, step.steps)) {
                        checkWithinBounds(inferenceContext, warn);
                        continue outer;
                    }
                }
                //no progress
                throw inferenceException.setMessage();
            }
        }
        catch (InferenceException ex) {
            //did we fail because of interdependent ivars?
            inferenceContext.rollback(saved_undet);
            instantiateAsUninferredVars(varsToSolve, inferenceContext);
            checkWithinBounds(inferenceContext, warn);
        }
        inferenceGraph.deleteNode(nodeToSolve);
    }
}
 
Example 7
Source File: FromArray.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void test(String... args) {
    List<String> ss = List.from(args);
    if (args != null) {
        for (String s : args) {
            if (s != ss.head)
                throw new AssertionError("s != ss.head (" + s + ", " + ss.head + ")");
            ss = ss.tail;
        }
    }
    if (!ss.isEmpty())
        throw new AssertionError("!ss.isEmpty (" + ss + ")");
}
 
Example 8
Source File: FromArray.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void test(String... args) {
    List<String> ss = List.from(args);
    if (args != null) {
        for (String s : args) {
            if (s != ss.head)
                throw new AssertionError("s != ss.head (" + s + ", " + ss.head + ")");
            ss = ss.tail;
        }
    }
    if (!ss.isEmpty())
        throw new AssertionError("!ss.isEmpty (" + ss + ")");
}
 
Example 9
Source File: T7042566.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private TypeConfiguration(TypeKind... typeKindList) {
    this.typeKindList = List.from(typeKindList);
    expressionListStr = asExpressionList();
    parameterListStr = asParameterList();
    bytecodeSigStr = asBytecodeString();
}
 
Example 10
Source File: T7042566.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private TypeConfiguration(TypeKind... typeKindList) {
    this.typeKindList = List.from(typeKindList);
    expressionListStr = asExpressionList();
    parameterListStr = asParameterList();
    bytecodeSigStr = asBytecodeString();
}
 
Example 11
Source File: T7042566.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
TypeConfiguration(TypeKind... typeKindList) {
    this.typeKindList = List.from(typeKindList);
    expressionListStr = asExpressionList();
    parameterListStr = asParameterList();
    bytecodeSigStr = asBytecodeString();
}
 
Example 12
Source File: IntersectionTypeCastTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
ClassKind(String typeStr, InterfaceKind... superInterfaces) {
    this.typeStr = typeStr;
    this.superInterfaces = List.from(superInterfaces);
}
 
Example 13
Source File: T7042566.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private TypeConfiguration(TypeKind... typeKindList) {
    this.typeKindList = List.from(typeKindList);
    expressionListStr = asExpressionList();
    parameterListStr = asParameterList();
    bytecodeSigStr = asBytecodeString();
}
 
Example 14
Source File: Attribute.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public List<Attribute> getValue() {
    return List.from(values);
}
 
Example 15
Source File: TypeHarness.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}
 
Example 16
Source File: T7042566.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private TypeConfiguration(TypeKind... typeKindList) {
    this.typeKindList = List.from(typeKindList);
    expressionListStr = asExpressionList();
    parameterListStr = asParameterList();
    bytecodeSigStr = asBytecodeString();
}
 
Example 17
Source File: TypeHarness.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Intersection(Type classBound, Type... intfBounds) {
    ClassType ct = Class(Flags.COMPOUND);
    ct.supertype_field = classBound;
    ct.interfaces_field = List.from(intfBounds);
    return ct;
}
 
Example 18
Source File: TypeHarness.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Intersection(Type classBound, Type... intfBounds) {
    ClassType ct = Class(Flags.COMPOUND);
    ct.supertype_field = classBound;
    ct.interfaces_field = List.from(intfBounds);
    return ct;
}
 
Example 19
Source File: T7042566.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private TypeConfiguration(TypeKind... typeKindList) {
    this.typeKindList = List.from(typeKindList);
    expressionListStr = asExpressionList();
    parameterListStr = asParameterList();
    bytecodeSigStr = asBytecodeString();
}
 
Example 20
Source File: IntersectionTypeCastTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
ClassKind(String declTemplate, String typeStr,
        InterfaceKind... superInterfaces) {
    this.declTemplate = declTemplate;
    this.typeStr = typeStr;
    this.superInterfaces = List.from(superInterfaces);
}