本文整理汇总了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());
}
}
}
});
}
示例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;
}
});
}
示例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");
}
}
}
示例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));
}
示例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");
}
示例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));
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
}
示例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;
}
});
}
示例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);
}