当前位置: 首页>>代码示例>>Java>>正文


Java Promise类代码示例

本文整理汇总了Java中org.jetbrains.concurrency.Promise的典型用法代码示例。如果您正苦于以下问题:Java Promise类的具体用法?Java Promise怎么用?Java Promise使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Promise类属于org.jetbrains.concurrency包,在下文中一共展示了Promise类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluateExpression

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@NotNull
private static Promise<String> evaluateExpression(@NotNull EvaluateContext evaluateContext, @NotNull String expression) {
  return evaluateContext.evaluate(expression).then(new AsyncFunction<EvaluateResult, String>() {
    @NotNull
    @Override
    public Promise<String> fun(EvaluateResult result) {
      Value value = result.value;
      if (value == null) {
        return Promise.resolve("Log expression result doesn't have value");
      }
      else {
        if (value instanceof StringValue && ((StringValue)value).isTruncated()) {
          return ((StringValue)value).getFullString();
        }
        else {
          return Promise.resolve(value.getValueString());
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SuspendContextImpl.java

示例2: evaluateGet

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@NotNull
public static Promise<Value> evaluateGet(@NotNull final Variable variable,
                                         @NotNull Object host,
                                         @NotNull EvaluateContext evaluateContext,
                                         @NotNull String selfName) {
  StringBuilder builder = new StringBuilder(selfName);
  appendUnquotedName(builder, variable.getName());
  return evaluateContext.evaluate(builder.toString(), Collections.singletonMap(selfName, host), false)
    .then(new Function<EvaluateResult, Value>() {
      @Override
      public Value fun(EvaluateResult result) {
        variable.setValue(result.value);
        return result.value;
      }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ValueModifierUtil.java

示例3: download

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@NotNull
@Override
public Promise<VirtualFile> download() {
  synchronized (myLock) {
    switch (getState()) {
      case DOWNLOADING_NOT_STARTED:
        startDownloading();
        return createDownloadedCallback(this);
      case DOWNLOADING_IN_PROGRESS:
        return createDownloadedCallback(this);
      case DOWNLOADED:
        return Promise.resolve(myLocalVirtualFile);

      case ERROR_OCCURRED:
      default:
        return Promise.reject("errorOccured");
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:RemoteFileInfoImpl.java

示例4: changeLanguageLevel

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
public Promise<Void> changeLanguageLevel(@NotNull Module module, @NotNull final LanguageLevel level) {
  if (!myProjectsManager.isMavenizedModule(module)) return null;

  MavenProject mavenProject = myProjectsManager.findProject(module);
  if (mavenProject == null) return null;

  final MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(myProject, mavenProject.getFile());
  if (model == null) return null;

  new WriteCommandAction(myProject, "Add Maven Dependency", DomUtil.getFile(model)) {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      MavenDomConfiguration configuration = getCompilerPlugin(model).getConfiguration();
      XmlTag tag = configuration.ensureTagExists();
      setChildTagValue(tag, "source", level.getCompilerComplianceDefaultOption());
      setChildTagValue(tag, "target", level.getCompilerComplianceDefaultOption());
      Document document = PsiDocumentManager.getInstance(myProject).getDocument(DomUtil.getFile(model));
      if (document != null) {
        FileDocumentManager.getInstance().saveDocument(document);
      }
    }
  }.execute();
  return myProjectsManager.forceUpdateProjects(Collections.singleton(mavenProject));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MavenProjectModelModifier.java

示例5: testAddModuleDependency

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
public void testAddModuleDependency() throws IOException {
  createTwoModulesPom("m1", "m2");
  VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" +
                                         "<artifactId>m1</artifactId>" +
                                         "<version>1</version>");
  createModulePom("m2", "<groupId>test</groupId>" +
                        "<artifactId>m2</artifactId>" +
                        "<version>1</version>");
  importProject();

  Promise<Void> result = getExtension().addModuleDependency(getModule("m1"), getModule("m2"), DependencyScope.COMPILE);
  assertNotNull(result);
  assertHasDependency(m1, "test", "m2");
  waitUntilImported(result);
  assertModuleModuleDeps("m1", "m2");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MavenProjectModelModifierTest.java

示例6: testChangeLanguageLevel

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
public void testChangeLanguageLevel() throws IOException {
  importProject("<groupId>test</groupId>" +
                "<artifactId>project</artifactId>" +
                "<version>1</version>");

  Module module = getModule("project");
  assertEquals(LanguageLevel.JDK_1_5, EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module));
  Promise<Void> result = getExtension().changeLanguageLevel(module, LanguageLevel.JDK_1_8);
  assertNotNull(result);
  XmlTag tag = findTag("project.build.plugins.plugin");
  assertNotNull(tag);
  assertEquals("maven-compiler-plugin", tag.getSubTagText("artifactId"));
  XmlTag configuration = tag.findFirstSubTag("configuration");
  assertNotNull(configuration);
  assertEquals("1.8", configuration.getSubTagText("source"));
  assertEquals("1.8", configuration.getSubTagText("target"));

  waitUntilImported(result);
  assertEquals(LanguageLevel.JDK_1_8, EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MavenProjectModelModifierTest.java

示例7: stopAsync

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
@NotNull
public Promise stopAsync() {
    final Collection<XDebugProcess> values = debugProcesses.values();
    for (XDebugProcess value : values) {
        value.stopAsync();
    }
    return getDefaultDebugProcesses().stopAsync();
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:10,代码来源:ContextAwareDebugProcess.java

示例8: evaluate

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
public void evaluate(@NotNull String expression, @NotNull XEvaluationCallback callback,
                     @Nullable XSourcePosition expressionPosition) {
    log.debug("evaluating: " + expression);
    Promise<LuaDebugValue> promise = myController.execute("return " + expression);
    promise.done(callback::evaluated);
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:8,代码来源:LuaDebuggerEvaluator.java

示例9: addDependency

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
public Promise<Void> addDependency(@NotNull Module from, @NotNull Module to, @NotNull DependencyScope scope) {
  for (JavaProjectModelModifier modifier : getModelModifiers()) {
    Promise<Void> promise = modifier.addModuleDependency(from, to, scope);
    if (promise != null) {
      return promise;
    }
  }
  return Promise.REJECTED;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaProjectModelModificationServiceImpl.java

示例10: changeLanguageLevel

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
public Promise<Void> changeLanguageLevel(@NotNull Module module, @NotNull LanguageLevel languageLevel) {
  for (JavaProjectModelModifier modifier : getModelModifiers()) {
    Promise<Void> promise = modifier.changeLanguageLevel(module, languageLevel);
    if (promise != null) {
      return promise;
    }
  }
  return Promise.REJECTED;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaProjectModelModificationServiceImpl.java

示例11: addExternalLibraryDependency

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
public Promise<Void> addExternalLibraryDependency(@NotNull final Collection<Module> modules,
                                                  @NotNull final ExternalLibraryDescriptor descriptor,
                                                  @NotNull final DependencyScope scope) {
  List<String> defaultRoots = descriptor.getLibraryClassesRoots();
  Module firstModule = ContainerUtil.getFirstItem(modules);
  LOG.assertTrue(firstModule != null);
  LocateLibraryDialog dialog = new LocateLibraryDialog(firstModule, defaultRoots, descriptor.getPresentableName());
  List<String> classesRoots = dialog.showAndGetResult();
  if (!classesRoots.isEmpty()) {
    String libraryName = classesRoots.size() > 1 ? descriptor.getPresentableName() : null;
    final List<String> urls = OrderEntryFix.refreshAndConvertToUrls(classesRoots);
    if (modules.size() == 1) {
      ModuleRootModificationUtil.addModuleLibrary(firstModule, libraryName, urls, Collections.<String>emptyList(), scope);
    }
    else {
      new WriteAction() {
        protected void run(@NotNull Result result) {
          Library library =
            LibraryUtil.createLibrary(LibraryTablesRegistrar.getInstance().getLibraryTable(myProject), descriptor.getPresentableName());
          Library.ModifiableModel model = library.getModifiableModel();
          for (String url : urls) {
            model.addRoot(url, OrderRootType.CLASSES);
          }
          model.commit();
          for (Module module : modules) {
            ModuleRootModificationUtil.addDependency(module, library, scope, false);
          }
        }
      }.execute();
    }
  }
  return Promise.DONE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:IdeaProjectModelModifier.java

示例12: changeLanguageLevel

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
public Promise<Void> changeLanguageLevel(@NotNull Module module, @NotNull LanguageLevel level) {
  final LanguageLevel moduleLevel = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
  if (moduleLevel != null && JavaSdkUtil.isLanguageLevelAcceptable(myProject, module, level)) {
    final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
    rootModel.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(level);
    rootModel.commit();
  }
  else {
    LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(level);
    ProjectRootManagerEx.getInstanceEx(myProject).makeRootsChange(EmptyRunnable.INSTANCE, false, true);
  }
  return Promise.DONE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:IdeaProjectModelModifier.java

示例13: consume

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@Override
public void consume(Throwable error) {
  Promise.logError(CommandProcessorKt.getLOG(), error);
  if (error != AsyncPromise.OBSOLETE_ERROR) {
    session.reportError((description == null ? "" : description + ": ") + error.getMessage());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:RejectErrorReporter.java

示例14: loadChildren

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@NotNull
public Promise<Content> loadChildren(@NotNull XValue value) {
  TestCompositeNode childrenNode = new TestCompositeNode();
  value.computeChildren(childrenNode);
  return childrenNode.loadContent(Conditions.<XValueGroup>alwaysFalse(), Conditions.<VariableView>alwaysFalse())
    .done(new Consumer<Content>() {
      @Override
      public void consume(Content content) {
        children = content;
      }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:TestValueNode.java

示例15: getSource

import org.jetbrains.concurrency.Promise; //导入依赖的package包/类
@NotNull
@Override
public Promise<String> getSource(@NotNull Script script) {
  if (!containsScript(script)) {
    return Promise.reject("No Script");
  }
  //noinspection unchecked
  return scriptSourceLoader.get((SCRIPT)script);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ScriptManagerBase.java


注:本文中的org.jetbrains.concurrency.Promise类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。