diff --git a/.idea/externalDependencies.xml b/.idea/externalDependencies.xml
index 5fc34a223d8d..4c698556438e 100644
--- a/.idea/externalDependencies.xml
+++ b/.idea/externalDependencies.xml
@@ -9,6 +9,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 064010d8399b..44693dcf252d 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -238,7 +238,6 @@
-
diff --git a/build/scripts/download_kotlin.gant b/build/scripts/download_kotlin.gant
index 372dc3de7002..622ff8d0c852 100644
--- a/build/scripts/download_kotlin.gant
+++ b/build/scripts/download_kotlin.gant
@@ -18,7 +18,7 @@ import com.intellij.util.text.VersionComparatorUtil
import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
-String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_Beta3_Idea142branch150versionNoTests"
+String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_Beta4_Idea142branch150versionNoTests"
target('default': 'Ensures that build/kotlinc directory contains JARs from Kotlin plugin compatible with current IDEA sources. These JARs are used by build scripts.') {
def communityHome = guessHome(this)
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java
index 9d4c1b738ed6..c77b8529f482 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/concurrencyAnnotations/JCiPUtil.java
@@ -31,7 +31,7 @@ class JCiPUtil {
private static final String GUARDED_BY = "net.jcip.annotations.GuardedBy";
static boolean isJCiPAnnotation(String ref) {
- return "Immutable".equals(ref) || "GuardedBy".equals(ref) || "ThreadSafe".equals("ref");
+ return "Immutable".equals(ref) || "GuardedBy".equals(ref) || "ThreadSafe".equals(ref) || "NotThreadSafe".equals(ref);
}
private JCiPUtil() {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java
index 619a604dc8fc..ce827c34353c 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.CodeInsightUtil;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.actions.OptimizeImportsProcessor;
-import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.hint.QuestionAction;
import com.intellij.ide.util.DefaultPsiElementCellRenderer;
@@ -267,17 +266,6 @@ public class AddImportAction implements QuestionAction {
myEditor.getCaretModel().moveToLogicalPosition(new LogicalPosition(pos2.line, newCol));
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- @Override
- public void run() {
- if (!myProject.isDisposed() && myProject.isOpen()) {
- DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
- if (daemonCodeAnalyzer != null) {
- daemonCodeAnalyzer.updateVisibleHighlighters(myEditor);
- }
- }
- }
- });
}
protected void bindReference(PsiReference ref, PsiClass targetClass) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
index 2f0c016d0f75..4db2bbc90154 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
@@ -19,42 +19,32 @@ import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.JavaProjectCodeInsightSettings;
import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.actions.AddImportAction;
+import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass;
+import com.intellij.codeInsight.hint.HintManager;
import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction;
-import com.intellij.ide.util.MethodCellRenderer;
+import com.intellij.codeInspection.HintAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.popup.PopupStep;
-import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
+import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiShortNamesCache;
import com.intellij.psi.util.*;
import com.intellij.psi.util.proximity.PsiProximityComparator;
-import com.intellij.ui.popup.list.ListPopupImpl;
-import com.intellij.ui.popup.list.PopupListElementRenderer;
import com.intellij.util.ArrayUtilRt;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.ObjectUtils;
import com.intellij.util.Processor;
import com.intellij.util.containers.LinkedMultiMap;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
-import java.awt.*;
import java.util.*;
-import java.util.List;
-public class StaticImportMethodFix implements IntentionAction {
+public class StaticImportMethodFix implements IntentionAction, HintAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.StaticImportMethodFix");
private final SmartPsiElementPointer myMethodCall;
private List candidates;
@@ -68,9 +58,7 @@ public class StaticImportMethodFix implements IntentionAction {
public String getText() {
String text = QuickFixBundle.message("static.import.method.text");
if (candidates != null && candidates.size() == 1) {
- text += " '" + PsiFormatUtil.formatMethod(candidates.get(0), PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
- PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
- PsiFormatUtilBase.SHOW_FQ_NAME, 0)+"'";
+ text += " '" + getMethodPresentableText() + "'";
}
else {
text += "...";
@@ -78,6 +66,13 @@ public class StaticImportMethodFix implements IntentionAction {
return text;
}
+ @NotNull
+ private String getMethodPresentableText() {
+ return PsiFormatUtil.formatMethod(candidates.get(0), PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME |
+ PsiFormatUtilBase.SHOW_CONTAINING_CLASS |
+ PsiFormatUtilBase.SHOW_FQ_NAME, 0);
+ }
+
@Override
@NotNull
public String getFamilyName() {
@@ -91,6 +86,7 @@ public class StaticImportMethodFix implements IntentionAction {
&& myMethodCall.getElement() != null
&& myMethodCall.getElement().isValid()
&& myMethodCall.getElement().getMethodExpression().getQualifierExpression() == null
+ && myMethodCall.getElement().resolveMethod() == null
&& file.getManager().isInProject(file)
&& !(candidates == null ? candidates = getMethodsToImport() : candidates).isEmpty()
;
@@ -263,146 +259,61 @@ public class StaticImportMethodFix implements IntentionAction {
@Override
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) {
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
- if (candidates.size() == 1) {
- final PsiMethod toImport = candidates.get(0);
- doImport(toImport);
- }
- else {
- chooseAndImport(editor, project);
- }
- }
-
- private void doImport(final PsiMethod toImport) {
- CommandProcessor.getInstance().executeCommand(toImport.getProject(), new Runnable(){
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
- ApplicationManager.getApplication().runWriteAction(new Runnable() {
- @Override
- public void run() {
- try {
- PsiMethodCallExpression element = myMethodCall.getElement();
- if (element != null) {
- AddSingleMemberStaticImportAction.bindAllClassRefs(element.getContainingFile(), toImport, toImport.getName(), toImport.getContainingClass());
- }
- }
- catch (IncorrectOperationException e) {
- LOG.error(e);
- }
- }
- });
-
+ final List methodsToImport = getMethodsToImport();
+ if (methodsToImport.isEmpty()) return;
+ createQuestionAction(methodsToImport, project, editor).execute();
}
- }, getText(), this);
-
+ });
}
- private void chooseAndImport(Editor editor, final Project project) {
- if (ApplicationManager.getApplication().isUnitTestMode()) {
- doImport(candidates.get(0));
- return;
+ @NotNull
+ private StaticImportMethodQuestionAction createQuestionAction(List methodsToImport, @NotNull Project project, Editor editor) {
+ return new StaticImportMethodQuestionAction(project, editor, methodsToImport, myMethodCall);
+ }
+
+ private ImportClassFixBase.Result doFix(Editor editor) {
+ if (candidates.isEmpty()) {
+ return ImportClassFixBase.Result.POPUP_NOT_SHOWN;
}
- final BaseListPopupStep step =
- new BaseListPopupStep(QuickFixBundle.message("class.to.import.chooser.title"), candidates) {
-
+
+ final StaticImportMethodQuestionAction action = createQuestionAction(candidates, myMethodCall.getProject(), editor);
+
+ if (candidates.size() == 1) {
+ CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
- public PopupStep onChosen(PsiMethod selectedValue, boolean finalChoice) {
- if (selectedValue == null) {
- return FINAL_CHOICE;
- }
-
- if (finalChoice) {
- PsiDocumentManager.getInstance(project).commitAllDocuments();
- LOG.assertTrue(selectedValue.isValid());
- doImport(selectedValue);
- return FINAL_CHOICE;
- }
-
- String qname = PsiUtil.getMemberQualifiedName(selectedValue);
- if (qname == null) return FINAL_CHOICE;
- List excludableStrings = AddImportAction.getAllExcludableStrings(qname);
- return new BaseListPopupStep(null, excludableStrings) {
- @NotNull
- @Override
- public String getTextFor(String value) {
- return "Exclude '" + value + "' from auto-import";
- }
-
- @Override
- public PopupStep onChosen(String selectedValue, boolean finalChoice) {
- if (finalChoice) {
- AddImportAction.excludeFromImport(project, selectedValue);
- }
-
- return super.onChosen(selectedValue, finalChoice);
- }
- };
+ public void run() {
+ action.execute();
}
+ });
+ return ImportClassFixBase.Result.CLASS_AUTO_IMPORTED;
+ }
- @Override
- public boolean hasSubstep(PsiMethod selectedValue) {
- return true;
- }
-
- @NotNull
- @Override
- public String getTextFor(PsiMethod value) {
- return ObjectUtils.assertNotNull(value.getName());
- }
-
- @Override
- public Icon getIconFor(PsiMethod aValue) {
- return aValue.getIcon(0);
- }
- };
-
- final ListPopupImpl popup = new ListPopupImpl(step) {
- final PopupListElementRenderer rightArrow = new PopupListElementRenderer(this);
- @Override
- protected ListCellRenderer getListElementRenderer() {
- return new MethodCellRenderer(true, PsiFormatUtilBase.SHOW_NAME){
-
- @Nullable
- @Override
- protected TextAttributes getNavigationItemAttributes(Object value) {
- TextAttributes attrs = super.getNavigationItemAttributes(value);
- if (value instanceof PsiMethod && !((PsiMethod)value).isDeprecated()) {
- PsiClass psiClass = ((PsiMethod)value).getContainingClass();
- if (psiClass != null && psiClass.isDeprecated()) {
- return TextAttributes.merge(attrs, super.getNavigationItemAttributes(psiClass));
- }
- }
- return attrs;
- }
-
- @Override
- protected DefaultListCellRenderer getRightCellRenderer(final Object value) {
- final DefaultListCellRenderer moduleRenderer = super.getRightCellRenderer(value);
- return new DefaultListCellRenderer(){
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- JPanel panel = new JPanel(new BorderLayout());
- if (moduleRenderer != null) {
- Component moduleComponent = moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- if (!isSelected) {
- moduleComponent.setBackground(getBackgroundColor(value));
- }
- panel.add(moduleComponent, BorderLayout.CENTER);
- }
- rightArrow.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- Component rightArrowComponent = rightArrow.getNextStepLabel();
- panel.add(rightArrowComponent, BorderLayout.EAST);
- return panel;
- }
- };
- }
- };
- }
- };
- popup.showInBestPositionFor(editor);
+ String hintText = ShowAutoImportPass.getMessage(candidates.size() > 1, getMethodPresentableText());
+ if (!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)) {
+ final PsiMethodCallExpression element = myMethodCall.getElement();
+ final TextRange textRange = element.getTextRange();
+ HintManager.getInstance().showQuestionHint(editor, hintText,
+ textRange.getStartOffset(),
+ textRange.getEndOffset(), action);
+ }
+ return ImportClassFixBase.Result.POPUP_SHOWN;
}
@Override
public boolean startInWriteAction() {
- return true;
+ return false;
+ }
+
+ @Override
+ public boolean showHint(@NotNull Editor editor) {
+ final PsiMethodCallExpression callExpression = myMethodCall.getElement();
+ if (callExpression == null || callExpression.getMethodExpression().getQualifierExpression() != null) {
+ return false;
+ }
+ ImportClassFixBase.Result result = doFix(editor);
+ return result == ImportClassFixBase.Result.POPUP_SHOWN || result == ImportClassFixBase.Result.CLASS_AUTO_IMPORTED;
}
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodQuestionAction.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodQuestionAction.java
new file mode 100644
index 000000000000..4f83e31e79ed
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodQuestionAction.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.impl.quickfix;
+
+import com.intellij.codeInsight.daemon.QuickFixBundle;
+import com.intellij.codeInsight.daemon.impl.actions.AddImportAction;
+import com.intellij.codeInsight.hint.QuestionAction;
+import com.intellij.codeInsight.intention.impl.AddSingleMemberStaticImportAction;
+import com.intellij.ide.util.MethodCellRenderer;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.markup.TextAttributes;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.PopupStep;
+import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiFormatUtilBase;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.ui.popup.list.ListPopupImpl;
+import com.intellij.ui.popup.list.PopupListElementRenderer;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ObjectUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.List;
+
+public class StaticImportMethodQuestionAction implements QuestionAction {
+ private static final Logger LOG = Logger.getInstance("#" + StaticImportMethodQuestionAction.class.getName());
+ private final Project myProject;
+ private final Editor myEditor;
+ private List myCandidates;
+ private final SmartPsiElementPointer myMethodCall;
+
+ public StaticImportMethodQuestionAction(Project project,
+ Editor editor,
+ List candidates,
+ SmartPsiElementPointer methodCall) {
+ myProject = project;
+ myEditor = editor;
+ myCandidates = candidates;
+ myMethodCall = methodCall;
+ }
+
+ @Override
+ public boolean execute() {
+ PsiDocumentManager.getInstance(myProject).commitAllDocuments();
+
+ final PsiMethodCallExpression element = myMethodCall.getElement();
+ if (element == null || !element.isValid()){
+ return false;
+ }
+
+ for (PsiMethod targetMethod : myCandidates) {
+ if (!targetMethod.isValid()) {
+ return false;
+ }
+ }
+
+ if (myCandidates.size() == 1){
+ doImport(myCandidates.get(0));
+ }
+ else{
+ chooseAndImport(myEditor, myProject);
+ }
+ return true;
+ }
+
+ private void doImport(final PsiMethod toImport) {
+ final Project project = toImport.getProject();
+ CommandProcessor.getInstance().executeCommand(project, new Runnable(){
+ @Override
+ public void run() {
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ PsiMethodCallExpression element = myMethodCall.getElement();
+ if (element != null) {
+ AddSingleMemberStaticImportAction.bindAllClassRefs(element.getContainingFile(), toImport, toImport.getName(), toImport.getContainingClass());
+ }
+ }
+ catch (IncorrectOperationException e) {
+ LOG.error(e);
+ }
+ }
+ });
+
+ }
+ }, QuickFixBundle.message("add.import"), this);
+
+ }
+
+ private void chooseAndImport(final Editor editor, final Project project) {
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ doImport(myCandidates.get(0));
+ return;
+ }
+ final BaseListPopupStep step =
+ new BaseListPopupStep(QuickFixBundle.message("method.to.import.chooser.title"), myCandidates) {
+
+ @Override
+ public PopupStep onChosen(PsiMethod selectedValue, boolean finalChoice) {
+ if (selectedValue == null) {
+ return FINAL_CHOICE;
+ }
+
+ if (finalChoice) {
+ PsiDocumentManager.getInstance(project).commitAllDocuments();
+ LOG.assertTrue(selectedValue.isValid());
+ doImport(selectedValue);
+ return FINAL_CHOICE;
+ }
+
+ String qname = PsiUtil.getMemberQualifiedName(selectedValue);
+ if (qname == null) return FINAL_CHOICE;
+ List excludableStrings = AddImportAction.getAllExcludableStrings(qname);
+ return new BaseListPopupStep(null, excludableStrings) {
+ @NotNull
+ @Override
+ public String getTextFor(String value) {
+ return "Exclude '" + value + "' from auto-import";
+ }
+
+ @Override
+ public PopupStep onChosen(String selectedValue, boolean finalChoice) {
+ if (finalChoice) {
+ AddImportAction.excludeFromImport(project, selectedValue);
+ }
+
+ return super.onChosen(selectedValue, finalChoice);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasSubstep(PsiMethod selectedValue) {
+ return true;
+ }
+
+ @NotNull
+ @Override
+ public String getTextFor(PsiMethod value) {
+ return ObjectUtils.assertNotNull(value.getName());
+ }
+
+ @Override
+ public Icon getIconFor(PsiMethod aValue) {
+ return aValue.getIcon(0);
+ }
+ };
+
+ final ListPopupImpl popup = new ListPopupImpl(step) {
+ final PopupListElementRenderer rightArrow = new PopupListElementRenderer(this);
+ @Override
+ protected ListCellRenderer getListElementRenderer() {
+ return new MethodCellRenderer(true, PsiFormatUtilBase.SHOW_NAME){
+
+ @Nullable
+ @Override
+ protected TextAttributes getNavigationItemAttributes(Object value) {
+ TextAttributes attrs = super.getNavigationItemAttributes(value);
+ if (value instanceof PsiMethod && !((PsiMethod)value).isDeprecated()) {
+ PsiClass psiClass = ((PsiMethod)value).getContainingClass();
+ if (psiClass != null && psiClass.isDeprecated()) {
+ return TextAttributes.merge(attrs, super.getNavigationItemAttributes(psiClass));
+ }
+ }
+ return attrs;
+ }
+
+ @Override
+ protected DefaultListCellRenderer getRightCellRenderer(final Object value) {
+ final DefaultListCellRenderer moduleRenderer = super.getRightCellRenderer(value);
+ return new DefaultListCellRenderer(){
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ JPanel panel = new JPanel(new BorderLayout());
+ if (moduleRenderer != null) {
+ Component moduleComponent = moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ if (!isSelected) {
+ moduleComponent.setBackground(getBackgroundColor(value));
+ }
+ panel.add(moduleComponent, BorderLayout.CENTER);
+ }
+ rightArrow.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ Component rightArrowComponent = rightArrow.getNextStepLabel();
+ panel.add(rightArrowComponent, BorderLayout.EAST);
+ return panel;
+ }
+ };
+ }
+ };
+ }
+ };
+ popup.showInBestPositionFor(editor);
+ }
+}
+
+
diff --git a/platform/built-in-server/built-in-server-tests.iml b/platform/built-in-server/built-in-server-tests.iml
index af9d31a88f4a..1ee2004f04e2 100644
--- a/platform/built-in-server/built-in-server-tests.iml
+++ b/platform/built-in-server/built-in-server-tests.iml
@@ -22,6 +22,5 @@
-
\ No newline at end of file
diff --git a/platform/built-in-server/built-in-server.iml b/platform/built-in-server/built-in-server.iml
index 383652bc7ca0..a49a37419e3b 100644
--- a/platform/built-in-server/built-in-server.iml
+++ b/platform/built-in-server/built-in-server.iml
@@ -5,6 +5,7 @@
+
diff --git a/platform/built-in-server/client/.gitignore b/platform/built-in-server/client/.gitignore
index 40b878db5b1c..fee741232909 100644
--- a/platform/built-in-server/client/.gitignore
+++ b/platform/built-in-server/client/.gitignore
@@ -1 +1,3 @@
-node_modules/
\ No newline at end of file
+node_modules/
+npm-debug.log
+out/
\ No newline at end of file
diff --git a/platform/built-in-server/client/node-rpc-client/gulpfile.js b/platform/built-in-server/client/node-rpc-client/gulpfile.js
deleted file mode 100644
index ea4c5ed0e837..000000000000
--- a/platform/built-in-server/client/node-rpc-client/gulpfile.js
+++ /dev/null
@@ -1,42 +0,0 @@
-var gulp = require('gulp')
-var ts = require('gulp-typescript')
-var concat = require('gulp-concat')
-var uglify = require('gulp-uglify')
-var newer = require('gulp-newer')
-var sourcemaps = require('gulp-sourcemaps')
-var path = require('path')
-
-var outDir = 'out'
-var outFile = 'ij-rpc-client.js'
-var sources = "src/*.ts";
-
-var tsProject = ts.createProject({
- target: "ES5",
- noImplicitAny: true,
- removeComments: true,
- sortOutput: true,
- module: "commonjs"
-});
-
-gulp.task("compile", function () {
- var tsResult = gulp.src(sources)
- .pipe(sourcemaps.init())
- //.pipe(newer(outDir + '/' + outFile))
- .pipe(ts(tsProject));
-
- tsResult.js.pipe(concat(outFile))
- //.pipe(uglify({
- // output: {
- // beautify: true,
- // indent_level: 2
- // }
- // }))
- .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: path.resolve('testData')}))
- .pipe(gulp.dest(outDir))
-});
-
-gulp.task('watch', function () {
- gulp.watch(sources, ['compile']);
-});
-
-gulp.task('default', ['compile']);
\ No newline at end of file
diff --git a/platform/built-in-server/client/node-rpc-client/node-rpc-client.iml b/platform/built-in-server/client/node-rpc-client/node-rpc-client.iml
new file mode 100644
index 000000000000..80cc7391bd40
--- /dev/null
+++ b/platform/built-in-server/client/node-rpc-client/node-rpc-client.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/platform/built-in-server/client/node-rpc-client/package.json b/platform/built-in-server/client/node-rpc-client/package.json
index 862a64057dac..2f5c4fbc836d 100644
--- a/platform/built-in-server/client/node-rpc-client/package.json
+++ b/platform/built-in-server/client/node-rpc-client/package.json
@@ -2,16 +2,21 @@
"name": "ij-rpc-client",
"version": "0.0.1",
"description": "IntelliJ Platform RPC client",
+ "scripts": {
+ "compile": "rimraf app/out && tsconfig -i 2 && tsc",
+ "test": "mocha --harmony_default_parameters --harmony_rest_parameters"
+ },
"repository": {
"type": "git",
"url": "https://github.com/JetBrains/intellij-community.git"
},
"devDependencies": {
- "gulp": "^3.8.11",
- "gulp-concat": "^2.4.3",
- "gulp-newer": "^0.5.0",
- "gulp-sourcemaps": "^1.3.0",
- "gulp-typescript": "^2.4.2",
- "gulp-uglify": "^1.1.0"
+ "rimraf": "^2.5.0",
+ "should": "^8.0.2",
+ "tsconfig-glob": "^0.3.3",
+ "typescript": "^1.8.0-dev.20151231"
+ },
+ "dependencies": {
+ "bluebird": "^3.1.1"
}
}
diff --git a/platform/built-in-server/client/node-rpc-client/src/rpc-client.ts b/platform/built-in-server/client/node-rpc-client/src/rpc-client.ts
index b8425f3ee9d6..45343ddd758c 100644
--- a/platform/built-in-server/client/node-rpc-client/src/rpc-client.ts
+++ b/platform/built-in-server/client/node-rpc-client/src/rpc-client.ts
@@ -1,82 +1,98 @@
-"use strict"
-
-import net = require("net")
-import rpc = require("./rpc")
+import * as net from "net"
+import { JsonRpc, Transport } from "./rpc"
export class RpcClient {
- connect(port:Number = 63342) {
- var socket = net.connect({port: port}, function () {
- console.log('Connected to IJ RPC server localhost:' + port)
- });
+ connect(port: number = 63342) {
+ const socket = net.connect({port: port}, () => {
+ console.log("Connected to IJ RPC server localhost: " + port)
+ })
- var jsonRpc = new rpc.JsonRpc(new SocketTransport(socket))
- var decoder:MessageDecoder = new MessageDecoder(jsonRpc.messageReceived)
- socket.on('data', decoder.messageReceived)
+ const transport = new SocketTransport(socket)
+ const jsonRpc = new JsonRpc(transport)
+ const decoder = new MessageDecoder(jsonRpc.messageReceived)
+ socket.on("data", decoder.messageReceived)
}
}
const enum State {LENGTH, CONTENT}
-class SocketTransport implements rpc.Transport {
+export class SocketTransport implements Transport {
private headerBuffer = new Buffer(4)
- constructor(private socket:net.Socket) {
+ opened: () => void
+
+ constructor(private socket: net.Socket = new net.Socket()) {
}
- send(id:number, domain:string, command:string, params:any[] = null):void {
- var encodedParams = JSON.stringify(params)
- var header = (id == -1 ? '' : (id + ', ')) + '"' + domain + '", "' + command + '"';
- this.headerBuffer.writeUInt32BE(Buffer.byteLength(encodedParams) + header.length, 0)
+ connect(port: number = 63342) {
+ this.socket.connect(port, null, ()=> {
+ const opened = this.opened
+ if (opened != null) {
+ opened()
+ }
+ })
+ this.socket.on("error", (e: Error) => {
+ console.error(e)
+ })
+ this.socket.write(new Buffer([67, 72, 105, -107, 126, -21, -81, -72, 64, 54, -87, -88, 0, -46, -48, 34, -7, -67]))
+ }
+
+ send(id: number, domain: string, command: string, params: any[] = null): void {
+ const encodedParams = JSON.stringify(params)
+ const header = (id == -1 ? '' : (id + ', ')) + '"' + domain + '", "' + command + '"';
+ this.headerBuffer.writeUInt32BE(header.length + Buffer.byteLength(encodedParams), 0)
this.socket.write(this.headerBuffer)
- this.socket.write(encodedParams, 'utf-8')
+ this.socket.write(header)
+ this.socket.write(encodedParams)
}
- sendResult(id:number, result:any):void {
+ sendResult(id: number, result: any): void {
this.sendResultOrError(id, result, false)
}
- sendError(id:number, error:any):void {
+ sendError(id: number, error: any): void {
this.sendResultOrError(id, error, true)
}
- private sendResultOrError(id:number, result:any, isError:boolean):void {
+ private sendResultOrError(id: number, result: any, isError: boolean): void {
var encodedResult = JSON.stringify(result)
- var header = id + ', "' + (isError ? 'e': 'r') + '"';
+ var header = id + ', "' + (isError ? 'e' : 'r') + '"';
this.headerBuffer.writeUInt32BE(Buffer.byteLength(encodedResult) + header.length, 0)
this.socket.write(this.headerBuffer)
- this.socket.write(encodedResult, 'utf-8')
+ this.socket.write(encodedResult)
}
}
class MessageDecoder {
- private state:State = State.LENGTH
- private contentLength:number = 0
+ private state: State = State.LENGTH
+ private contentLength: number = 0
- private buffers:Array = []
- private totalBufferLength:number = 0
- private offset:number = 0
+ private buffers: Array = []
+ private totalBufferLength: number = 0
+ private offset: number = 0
- constructor(private messageProcessor:(message:any)=>void) {
+ constructor(private messageProcessor: (message: any)=>void) {
}
- private byteConsumed(count:number) {
+ private byteConsumed(count: number) {
this.offset += count
this.totalBufferLength -= count
}
- messageReceived(buffer:Buffer) {
+ messageReceived(buffer: Buffer) {
this.totalBufferLength += buffer.length
while (true) {
//noinspection FallThroughInSwitchStatementJS
switch (this.state) {
- case State.LENGTH: {
+ case State.LENGTH:
+ {
if (this.totalBufferLength < 4) {
this.buffers.push(buffer)
return
}
- var totalBuffer:Buffer
+ var totalBuffer: Buffer
if (this.buffers.length === 0) {
totalBuffer = buffer
}
@@ -92,13 +108,14 @@ class MessageDecoder {
buffer = totalBuffer
}
- case State.CONTENT: {
+ case State.CONTENT:
+ {
if (this.totalBufferLength < this.contentLength) {
this.buffers.push(buffer)
return
}
- var totalBuffer:Buffer
+ var totalBuffer: Buffer
if (this.buffers.length === 0) {
totalBuffer = buffer
}
diff --git a/platform/built-in-server/client/node-rpc-client/src/rpc.ts b/platform/built-in-server/client/node-rpc-client/src/rpc.ts
index c7a54193f663..7aba41a980da 100644
--- a/platform/built-in-server/client/node-rpc-client/src/rpc.ts
+++ b/platform/built-in-server/client/node-rpc-client/src/rpc.ts
@@ -1,39 +1,39 @@
-///
-///
-"use strict"
-
import Promise = require("bluebird")
class PromiseCallback {
- constructor(public resolve:(value?:any) => void, public reject:(error?:any) => void) {
+ constructor(public resolve: (value?: any) => void, public reject: (error?: any) => void) {
}
}
export interface Transport {
- send(id:number, domain:string, command:string, params:any[]):void
+ opened?: () => void
- sendResult(id:number, result:any):void
+ connect(port: number): void
- sendError(id:number, error:any):void
+ send(id: number, domain: string, command: string, params: any[]): void
+
+ sendResult(id: number, result: any):void
+
+ sendError(id: number, error: any):void
}
export class JsonRpc {
private messageIdCounter = 0
- private callbacks:Map = new Map()
- private domains:Map = new Map()
+ private callbacks: Map = new Map()
+ private domains: Map = new Map()
- constructor(private transport:Transport) {
+ constructor(private transport: Transport) {
}
- public call(domain:string, command:string, ...params: any[]):Promise {
- return new Promise((resolve:(value:T) => void, reject:(error?:any) => void) => {
+ public call(domain: string, command: string, ...params: any[]): Promise {
+ return new Promise((resolve: (value: T) => void, reject: (error?: any) => void) => {
var id = this.messageIdCounter++;
this.callbacks.set(id, new PromiseCallback(resolve, reject))
this.transport.send(id, domain, command, params)
})
}
- messageReceived(message:Array) {
+ messageReceived(message: Array) {
if (message.length === 1 || (message.length === 2 && !(typeof message[1] === 'string'))) {
var promiseCallback = this.callbacks.get(message[0])
var singletonArray = safeGet(message, 1)
@@ -45,8 +45,8 @@ export class JsonRpc {
}
}
else {
- var id:number
- var offset:number
+ var id: number
+ var offset: number
if (typeof message[0] === 'string') {
id = -1
offset = 0
@@ -56,11 +56,11 @@ export class JsonRpc {
offset = 1
}
- var onRejected = id === -1 ? null : (error:any) => this.transport.sendError(id, error)
+ var onRejected = id === -1 ? null : (error: any) => this.transport.sendError(id, error)
try {
var object = this.domains.get(message[offset])
var method = object[message[offset + 1]]
- var result:any
+ var result: any
var args = safeGet(message, offset + 2)
if (args === null) {
result = method.call(object)
@@ -70,7 +70,7 @@ export class JsonRpc {
}
if (id !== -1) {
- var onFulfilled = (result:any) => this.transport.sendResult(id, result)
+ var onFulfilled = (result: any) => this.transport.sendResult(id, result)
if (result instanceof Promise) {
(>result).done(onFulfilled, onRejected)
}
@@ -89,6 +89,6 @@ export class JsonRpc {
}
}
-function safeGet(a:any[], index:number):Array {
+function safeGet(a: any[], index: number): Array {
return index < a.length ? a[index] : null
}
\ No newline at end of file
diff --git a/platform/built-in-server/client/node-rpc-client/test/test.js b/platform/built-in-server/client/node-rpc-client/test/test.js
new file mode 100644
index 000000000000..5fa4efa3f6cc
--- /dev/null
+++ b/platform/built-in-server/client/node-rpc-client/test/test.js
@@ -0,0 +1,30 @@
+const should = require("should")
+const rpcClient = require("../out/rpc-client")
+const rpc = require("../out/rpc")
+
+describe("RPC", function () {
+ it("connect", function (done) {
+ const transport = new rpcClient.SocketTransport()
+ transport.opened = function () {
+ done()
+ }
+ transport.connect()
+ })
+ it("connect", function (done) {
+ this.timeout(5000000)
+
+ const transport = new rpcClient.SocketTransport()
+ transport.opened = function () {
+ }
+ transport.connect(63343)
+
+ const rpcServer = new rpc.JsonRpc(transport)
+ rpcServer.call("Ide", "about")
+ .then(function (r) {
+ console.log(r)
+ done()
+ }, function (e) {
+ throw e
+ })
+ })
+})
\ No newline at end of file
diff --git a/platform/built-in-server/client/node-rpc-client/tsconfig.json b/platform/built-in-server/client/node-rpc-client/tsconfig.json
new file mode 100644
index 000000000000..c7a0c1aa243f
--- /dev/null
+++ b/platform/built-in-server/client/node-rpc-client/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noImplicitAny": true,
+ "removeComments": true,
+ "outDir": "out",
+ "newLine": "LF",
+ "noResolve": true,
+ "noEmitOnError": true,
+ "inlineSources": true,
+ "sourceMap": true
+ },
+ "filesGlob": [
+ "src/*.ts",
+ "typings/**/*.d.ts"
+ ],
+ "files": [
+ "typings/bluebird/bluebird.d.ts",
+ "typings/node/node.d.ts",
+ "src/rpc-client.ts",
+ "src/rpc.ts"
+ ]
+}
diff --git a/platform/built-in-server/client/node-rpc-client/tsd.json b/platform/built-in-server/client/node-rpc-client/tsd.json
index c5e6b3b94da0..924203dfa87c 100644
--- a/platform/built-in-server/client/node-rpc-client/tsd.json
+++ b/platform/built-in-server/client/node-rpc-client/tsd.json
@@ -3,13 +3,12 @@
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
- "bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
- "commit": "35fffaa44bff5392741b3022d805fe3563023a3d"
+ "commit": "dc9dabe74a5be62613b17a3605309783a12ff28a"
},
"bluebird/bluebird.d.ts": {
- "commit": "cf7c97b2a68a385c98c75fb6edd81083c97c983c"
+ "commit": "dc9dabe74a5be62613b17a3605309783a12ff28a"
}
}
}
diff --git a/platform/built-in-server/client/node-rpc-client/typings/bluebird/bluebird.d.ts b/platform/built-in-server/client/node-rpc-client/typings/bluebird/bluebird.d.ts
index 93c81138a8ef..ea8bebe0c2b9 100644
--- a/platform/built-in-server/client/node-rpc-client/typings/bluebird/bluebird.d.ts
+++ b/platform/built-in-server/client/node-rpc-client/typings/bluebird/bluebird.d.ts
@@ -1,6 +1,6 @@
// Type definitions for bluebird 2.0.0
// Project: https://github.com/petkaantonov/bluebird
-// Definitions by: Bart van der Schoor
+// Definitions by: Bart van der Schoor , falsandtru
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
@@ -16,695 +16,766 @@
// TODO verify support to have no return statement in handlers to get a Promise (more overloads?)
-declare class Promise implements Promise.Thenable, Promise.Inspection {
- /**
- * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
- */
- constructor(callback: (resolve: (thenable: Promise.Thenable) => void, reject: (error: any) => void) => void);
- constructor(callback: (resolve: (result: R) => void, reject: (error: any) => void) => void);
-
- /**
- * Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
- */
- then(onFulfill: (value: R) => Promise.Thenable, onReject: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- then(onFulfill: (value: R) => Promise.Thenable, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise;
- then(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- then(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise;
-
- /**
- * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
- *
- * Alias `.caught();` for compatibility with earlier ECMAScript version.
- */
- catch(onReject?: (error: any) => Promise.Thenable): Promise;
- caught(onReject?: (error: any) => Promise.Thenable): Promise;
-
- catch(onReject?: (error: any) => U): Promise;
- caught(onReject?: (error: any) => U): Promise;
-
- /**
- * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
- *
- * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
- *
- * Alias `.caught();` for compatibility with earlier ECMAScript version.
- */
- catch(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise;
- caught(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise;
-
- catch(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise;
- caught(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise;
-
- catch(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise;
- caught(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise;
-
- catch(ErrorClass: Function, onReject: (error: any) => U): Promise;
- caught(ErrorClass: Function, onReject: (error: any) => U): Promise;
-
- /**
- * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
- */
- error(onReject: (reason: any) => Promise.Thenable): Promise;
- error(onReject: (reason: any) => U): Promise;
-
- /**
- * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
- *
- * Alias `.lastly();` for compatibility with earlier ECMAScript version.
- */
- finally(handler: () => Promise.Thenable): Promise;
- finally(handler: () => U): Promise;
-
- lastly(handler: () => Promise.Thenable): Promise;
- lastly(handler: () => U): Promise;
-
- /**
- * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
- */
- bind(thisArg: any): Promise;
-
- /**
- * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
- */
- done(onFulfilled: (value: R) => Promise.Thenable, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): void;
- done(onFulfilled: (value: R) => Promise.Thenable, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
- done(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): void;
- done(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
-
- /**
- * Like `.finally()`, but not called for rejections.
- */
- tap(onFulFill: (value: R) => Promise.Thenable): Promise;
- tap(onFulfill: (value: R) => U): Promise;
-
- /**
- * Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
- */
- progressed(handler: (note: any) => any): Promise;
-
- /**
- * Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
- */
- delay(ms: number): Promise;
-
- /**
- * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
- *
- * You may specify a custom error message with the `message` parameter.
- */
- timeout(ms: number, message?: string): Promise;
-
- /**
- * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
- * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
- */
- nodeify(callback: (err: any, value?: R) => void): Promise;
- nodeify(...sink: any[]): void;
-
- /**
- * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
- */
- cancellable(): Promise;
-
- /**
- * Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
- *
- * That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
- *
- * In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
- *
- * Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
- */
- // TODO what to do with this?
- cancel(): Promise;
-
- /**
- * Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
- */
- fork(onFulfilled: (value: R) => Promise.Thenable, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- fork(onFulfilled: (value: R) => Promise.Thenable, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise;
- fork(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise;
- fork(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise;
-
- /**
- * Create an uncancellable promise based on this promise.
- */
- uncancellable(): Promise;
-
- /**
- * See if this promise can be cancelled.
- */
- isCancellable(): boolean;
-
- /**
- * See if this `promise` has been fulfilled.
- */
- isFulfilled(): boolean;
-
- /**
- * See if this `promise` has been rejected.
- */
- isRejected(): boolean;
-
- /**
- * See if this `promise` is still defer.
- */
- isPending(): boolean;
-
- /**
- * See if this `promise` is resolved -> either fulfilled or rejected.
- */
- isResolved(): boolean;
-
- /**
- * Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.
- *
- * throws `TypeError`
- */
- value(): R;
-
- /**
- * Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.
- *
- * throws `TypeError`
- */
- reason(): any;
-
- /**
- * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
- */
- inspect(): Promise.Inspection;
-
- /**
- * This is a convenience method for doing:
- *
- *
- * promise.then(function(obj){
- * return obj[propertyName].call(obj, arg...);
- * });
- *
- */
- call(propertyName: string, ...args: any[]): Promise;
-
- /**
- * This is a convenience method for doing:
- *
- *
- * promise.then(function(obj){
- * return obj[propertyName];
- * });
- *
- */
- // TODO find way to fix get()
- // get(propertyName: string): Promise;
-
- /**
- * Convenience method for:
- *
- *
- * .then(function() {
- * return value;
- * });
- *
- *
- * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
- *
- * Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
- */
- return(): Promise;
- thenReturn(): Promise;
- return(value: U): Promise;
- thenReturn(value: U): Promise;
-
- /**
- * Convenience method for:
- *
- *
- * .then(function() {
- * throw reason;
- * });
- *
- * Same limitations apply as with `.return()`.
- *
- * Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
- */
- throw(reason: Error): Promise;
- thenThrow(reason: Error): Promise;
-
- /**
- * Convert to String.
- */
- toString(): string;
-
- /**
- * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
- */
- toJSON(): Object;
-
- /**
- * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
- */
- // TODO how to model instance.spread()? like Q?
- spread(onFulfill: Function, onReject?: (reason: any) => Promise.Thenable): Promise;
- spread(onFulfill: Function, onReject?: (reason: any) => U): Promise;
- /*
- // TODO or something like this?
- spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => Promise.Thenable): Promise;
- spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => U): Promise;
- spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable): Promise;
- spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise;
- */
- /**
- * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
- */
- // TODO type inference from array-resolving promise?
- all(): Promise;
-
- /**
- * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
- */
- // TODO how to model instance.props()?
- props(): Promise