Search in sources :

Example 1 with BuckQueryCommandHandler

use of com.facebook.buck.intellij.ideabuck.build.BuckQueryCommandHandler in project buck by facebook.

the class BuckQueryAction method execute.

public static synchronized List<String> execute(final Project project, final String target, final Function<List<String>, Void> fillTextResults) {
    if (ongoingQuery.contains(target)) {
        return Collections.emptyList();
    }
    List<String> targetsInBuckFile = buckTargetCache.getIfPresent(target);
    if (targetsInBuckFile != null) {
        return targetsInBuckFile;
    }
    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {

        public void run() {
            ongoingQuery.add(target);
            BuckBuildManager buildManager = BuckBuildManager.getInstance(project);
            BuckCommandHandler handler = new BuckQueryCommandHandler(project, project.getBaseDir(), BuckCommand.QUERY, new Function<List<String>, Void>() {

                @Nullable
                @Override
                public Void apply(@Nullable List<String> strings) {
                    ongoingQuery.remove(target);
                    buckTargetCache.put(target, strings);
                    fillTextResults.apply(strings);
                    return null;
                }
            });
            handler.command().addParameter(target);
            buildManager.runBuckCommand(handler, ACTION_TITLE);
        }
    });
    return Collections.emptyList();
}
Also used : Function(com.google.common.base.Function) BuckQueryCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckQueryCommandHandler) BuckBuildManager(com.facebook.buck.intellij.ideabuck.build.BuckBuildManager) List(java.util.List) BuckCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckCommandHandler) Nullable(javax.annotation.Nullable)

Aggregations

BuckBuildManager (com.facebook.buck.intellij.ideabuck.build.BuckBuildManager)1 BuckCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckCommandHandler)1 BuckQueryCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckQueryCommandHandler)1 Function (com.google.common.base.Function)1 List (java.util.List)1 Nullable (javax.annotation.Nullable)1