Example usage for com.google.common.collect ImmutableList of

List of usage examples for com.google.common.collect ImmutableList of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList of.

Prototype

public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12,
            E... others) 

Source Link

Usage

From source file:com.google.dart.java2dart.engine.MainAnalysisServer.java

public static void main(String[] args) throws Exception {
    if (args.length != 2) {
        System.out.println("Usage: java2dart <services-target-src-folder> <server-target-src-folder>");
        System.exit(0);/* w w w.  j a v a2s  .  c  o m*/
    }
    String targetFolderServices = args[0];
    String targetFolderServer = args[1];
    System.out.println("Generating files into\n\t" + targetFolderServices + "\n\t" + targetFolderServer);
    new File(targetFolderServer).mkdirs();
    //
    engineFolder = new File("../../../tools/plugins/com.google.dart.engine/src");
    serviceFolder = new File("../../../tools/plugins/com.google.dart.engine.services/src");
    serverFolder = new File("../../../tools/plugins/com.google.dart.server/src");
    engineFolder = engineFolder.getCanonicalFile();
    // configure Context
    context.addClasspathFile(new File("../../../../third_party/guava/r13/guava-13.0.1.jar"));
    context.addClasspathFile(new File("../../../../third_party/commons-lang/3.2.1/commons-lang3-3.2.1.jar"));
    context.addClasspathFile(new File("../../../../third_party/junit/v4_8_2/junit.jar"));
    context.addSourceFolder(engineFolder);
    context.addSourceFolder(serviceFolder);
    context.addSourceFolder(serverFolder);
    context.addSourceFiles(new File(engineFolder, "com/google/dart/engine/"));
    context.addSourceFiles(new File(serverFolder, "com/google/dart/server/"));
    context.removeSourceFiles(new File(serverFolder, "com/google/dart/server/internal/remote/"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/assist"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/change"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/completion"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/correction"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/internal/completion"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/internal/correction"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/internal/refactoring"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/internal/util"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/refactoring"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/status"));
    context.addSourceFiles(new File(serviceFolder, "com/google/dart/engine/services/util"));
    // translate into single CompilationUnit
    dartUnit = context.translate();
    // run processors
    {
        List<SemanticProcessor> PROCESSORS = ImmutableList.of(new TypeSemanticProcessor(context),
                new ObjectSemanticProcessor(context), new CollectionSemanticProcessor(context),
                new IOSemanticProcessor(context), new PropertySemanticProcessor(context),
                new GuavaSemanticProcessor(context), new JUnitSemanticProcessor(context),
                new EngineAnnotationProcessor(context), new UniqueMemberNamesSemanticProcessor(context),
                new RenameConstructorsSemanticProcessor(context), new EngineSemanticProcessor(context),
                new EngineInstanceOfProcessor(context), new BeautifySemanticProcessor(context));
        for (SemanticProcessor processor : PROCESSORS) {
            processor.process(dartUnit);
        }
    }
    // run this again, because we may introduce conflicts when convert methods to getters/setters
    context.ensureUniqueClassMemberNames();
    context.applyLocalVariableSemanticChanges(dartUnit);
    {
        CompilationUnit library = buildServiceInterfacesLibrary();
        Files.write(getFormattedSource(library), new File(targetFolderServer + "/service_interfaces.dart"),
                Charsets.UTF_8);
    }
    {
        CompilationUnit library = buildServiceComputersLibrary();
        Files.write(getFormattedSource(library), new File(targetFolderServer + "/service_computers.dart"),
                Charsets.UTF_8);
    }
    {
        CompilationUnit library = buildServicesLibrary_change();
        Files.write(getFormattedSource(library), new File(targetFolderServices + "/change.dart"),
                Charsets.UTF_8);
    }
    {
        CompilationUnit library = buildServicesLibrary_completion();
        String source = getFormattedSource(library);
        // TODO(scheglov) improve java2dart to make this translated correctly
        source = replaceSourceFragment(source,
                "new CompletionEngine_CommentReferenceCompleter(this, _completionNode)",
                "new CompletionEngine_CommentReferenceCompleter(CompletionEngine_this, _completionNode)");
        source = replaceSourceFragment(source,
                "new CompletionEngine_TypeNameCompleter(this, _completionNode, node)",
                "new CompletionEngine_TypeNameCompleter(CompletionEngine_this, _completionNode, node)");
        //      source = replaceSourceFragment(
        //          source,
        //          "new CompletionEngine_NameCollector(this)",
        //          "new CompletionEngine_NameCollector(CompletionEngine_this)");
        source = replaceSourceFragment(source, "new CompletionEngine_IdentifierCompleter(this, node)",
                "new CompletionEngine_IdentifierCompleter(CompletionEngine_this, node)");
        source = replaceSourceFragment(source, "new CompletionEngine_StringCompleter(this, node)",
                "new CompletionEngine_StringCompleter(CompletionEngine_this, node)");
        Files.write(source, new File(targetFolderServices + "/completion.dart"), Charsets.UTF_8);
    }
    {
        CompilationUnit library = buildServicesLibrary_status();
        Files.write(getFormattedSource(library), new File(targetFolderServices + "/status.dart"),
                Charsets.UTF_8);
    }
    {
        CompilationUnit library = buildServicesLibrary_proposal();
        Files.write(getFormattedSource(library), new File(targetFolderServices + "/proposal.dart"),
                Charsets.UTF_8);
    }
    {
        CompilationUnit library = buildServicesLibrary_util();
        Files.write(getFormattedSource(library), new File(targetFolderServices + "/util.dart"), Charsets.UTF_8);
    }
    // TODO(scheglov) restore to translate more
    //    {
    //      CompilationUnit library = buildServicesLibrary_assist();
    //      Files.write(getFormattedSource(library), new File(targetFolder2
    //          + "/service_correction.dart"), Charsets.UTF_8);
    //    }
    {
        CompilationUnit library = buildServicesLibrary_refactoring();
        Files.write(getFormattedSource(library), new File(targetFolderServices + "/refactoring.dart"),
                Charsets.UTF_8);
    }
    {
        String projectFolder = new File(targetFolderServices).getParentFile().getParentFile().getParent();
        fixUnnecessaryCastHints(projectFolder);
    }
    {
        String projectFolder = new File(targetFolderServer).getParentFile().getParentFile().getParent();
        fixUnnecessaryCastHints(projectFolder);
    }
    System.out.println("Translation complete");
}

From source file:ai.grakn.generator.MetasyntacticStrings.java

@Override
protected String generate() {
    return random.choose(ImmutableList.of("foo", "bar", "baz", "qux", "quux", "corge", "grault", "garply",
            "waldo", "fred", "plugh", "xyzzy", "thud"));
}