addedHints = new ArrayList<>(parametersCount);
+ for (int i = 0; i < parametersCount; i++) {
+ String key = getParameterKey(targetMethod, i);
+ String value = enteredParameters.getOrDefault(key, "");
+ if (value.isEmpty() && targetCaretPosition == -1) targetCaretPosition = offset;
+ if (i < parametersCount - 1) value += ", ";
+ editor.getDocument().insertString(offset, value);
+ String name = parameterList.getParameters()[i].getName();
+ if (name != null) {
+ addedHints.add(ParameterHintsPresentationManager.getInstance().addHint(editor, offset, name + ":", false, true));
+ }
+ offset += value.length();
+ }
+ if (targetCaretPosition == -1) targetCaretPosition = offset;
+ caret.moveToLogicalPosition(editor.offsetToLogicalPosition(targetCaretPosition).leanForward(true));
+ Disposer.register(controller, () -> {
+ for (Inlay hint : addedHints) {
+ if (hint != null) ParameterHintsPresentationManager.getInstance().unpin(hint);
+ }
+ });
+
+ PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
+ CompletionMemory.registerChosenMethod(targetMethod, (PsiCall)exprList.getParent());
+ controller.updateComponent(); // update popup immediately (otherwise, it will be updated only after delay)
+ }
+
+ private static String getParameterKey(PsiMethod method, int parameterIndex) {
+ PsiParameter parameter = method.getParameterList().getParameters()[parameterIndex];
+ return parameter.getName() + ":" + parameter.getType().getCanonicalText();
+ }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaMethodOverloadSwitchUpAction.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaMethodOverloadSwitchUpAction.java
new file mode 100644
index 000000000000..50ba335ad4c3
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaMethodOverloadSwitchUpAction.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2017 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.editorActions;
+
+import com.intellij.openapi.editor.actionSystem.EditorAction;
+
+public class JavaMethodOverloadSwitchUpAction extends EditorAction {
+ public JavaMethodOverloadSwitchUpAction() {
+ super(new JavaMethodOverloadSwitchHandler(true));
+ }
+}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
index 0ed2ffde8cdb..d1df957a9441 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
@@ -107,13 +107,6 @@ public class PsiMethodReferenceUtil {
return false;
}
- PsiClass qContainingClass = getQualifierResolveResult(expression).getContainingClass();
- if (qContainingClass != null && containingClass != null &&
- isReceiverType(getFirstParameterType(functionalInterfaceType, expression), qContainingClass, subst)) {
- subst = TypeConversionUtil.getClassSubstitutor(containingClass, qContainingClass, subst);
- LOG.assertTrue(subst != null);
- }
-
methodReturnType = subst.substitute(methodReturnType);
}
}
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/highlighting/JavaReadWriteAccessDetector.java b/java/java-psi-impl/src/com/intellij/codeInsight/highlighting/JavaReadWriteAccessDetector.java
index 542b65defc9f..3c93c6a1b1b3 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/highlighting/JavaReadWriteAccessDetector.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/highlighting/JavaReadWriteAccessDetector.java
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull;
public class JavaReadWriteAccessDetector extends ReadWriteAccessDetector {
@Override
public boolean isReadWriteAccessible(@NotNull final PsiElement element) {
- return element instanceof PsiVariable && !(element instanceof ImplicitVariable) || element instanceof PsiClass;
+ return element instanceof PsiVariable && !(element instanceof ImplicitVariable) || element instanceof PsiClass || element instanceof PsiAnnotationMethod && !(element instanceof PsiCompiledElement);
}
@Override
@@ -49,7 +49,12 @@ public class JavaReadWriteAccessDetector extends ReadWriteAccessDetector {
@NotNull
@Override
public Access getExpressionAccess(@NotNull final PsiElement expression) {
- if (!(expression instanceof PsiExpression)) return Access.Read;
+ if (!(expression instanceof PsiExpression)) {
+ if (expression instanceof PsiNameValuePair || expression instanceof PsiIdentifier) {
+ return Access.Write;
+ }
+ return Access.Read;
+ }
PsiExpression expr = (PsiExpression) expression;
boolean readAccess = PsiUtil.isAccessedForReading(expr);
boolean writeAccess = PsiUtil.isAccessedForWriting(expr);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index 2b2255f1ee22..284673d2d47d 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -1607,7 +1607,8 @@ public class InferenceSession {
if (receiverSubstitutor != null) {
if (!method.hasTypeParameters()) {
if (signature.getParameterTypes().length == 1 || PsiUtil.isRawSubstitutor(containingClass, receiverSubstitutor)) {
- return receiverSubstitutor;
+ return methodContainingClass != null ? JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), receiverSubstitutor)
+ : receiverSubstitutor;
}
}
mySiteSubstitutor = mySiteSubstitutor.putAll(receiverSubstitutor);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java
index 6bb3ba3ba570..3da15169078e 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java
@@ -185,6 +185,13 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
return true;
}
+ if (myT instanceof PsiCapturedWildcardType) {
+ PsiType lowerBound = ((PsiCapturedWildcardType)myT).getLowerBound();
+ if (lowerBound != PsiType.NULL) {
+ constraints.add(new StrictSubtypingConstraint(lowerBound, myS));
+ }
+ }
+
return true;
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/LowerBoundOfCapturedWildcardInSubtypingConstraint.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/LowerBoundOfCapturedWildcardInSubtypingConstraint.java
new file mode 100644
index 000000000000..02bf58cfa8df
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/LowerBoundOfCapturedWildcardInSubtypingConstraint.java
@@ -0,0 +1,17 @@
+
+import java.util.Collections;
+import java.util.List;
+
+interface Processor {
+ void process(P t);
+}
+
+class Test {
+ void foo(Processor super List> p) {
+ p.process(Collections.emptyList());
+ }
+
+ void bar(Processor extends List> p) {
+ p.process(Collections.emptyList());
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MethodInInheritorFoundBySecondSearch.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MethodInInheritorFoundBySecondSearch.java
new file mode 100644
index 000000000000..5ea4fc64d237
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/MethodInInheritorFoundBySecondSearch.java
@@ -0,0 +1,15 @@
+
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+class Test {
+ interface MyBaseStream> {
+ MyStream map(Function super T, ? extends R> mapper);
+ }
+
+ interface MyStream extends MyBaseStream> {}
+
+ {
+ BiFunction, Function, MyStream> streamMapper = MyStream::map;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/CompletionHintsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/CompletionHintsTest.java
new file mode 100644
index 000000000000..5644f3681518
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/CompletionHintsTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2000-2017 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.completion;
+
+import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager;
+import com.intellij.codeInsight.hint.ParameterInfoController;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.codeInsight.lookup.LookupElementPresentation;
+import com.intellij.ide.highlighter.JavaFileType;
+import com.intellij.openapi.util.registry.Registry;
+import com.intellij.openapi.util.registry.RegistryValue;
+import com.intellij.util.ui.UIUtil;
+
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+public class CompletionHintsTest extends LightFixtureCompletionTestCase {
+ private RegistryValue myRegistryValue = Registry.get("java.completion.argument.hints");
+ private boolean myStoredRegistryValue;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myStoredRegistryValue = myRegistryValue.asBoolean();
+ myRegistryValue.setValue(true);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ try {
+ myRegistryValue.setValue(myStoredRegistryValue);
+ }
+ finally {
+ super.tearDown();
+ }
+ }
+
+ public void testBasicScenario() throws Exception {
+ // check hints appearance on completion
+ myFixture.configureByText(JavaFileType.INSTANCE, "class C { void m() { System.setPro } }");
+ complete("setProperty");
+ myFixture.checkResultWithInlays("class C { void m() { System.setProperty(, ) } }");
+
+ // check that hints don't disappear after daemon highlighting passes
+ myFixture.doHighlighting();
+ myFixture.checkResultWithInlays("class C { void m() { System.setProperty(, ) } }");
+
+ // test Tab/Shift+Tab navigation
+ myFixture.checkResult("class C { void m() { System.setProperty(, ) } }");
+ assertTrue(myFixture.getEditor().getCaretModel().getLogicalPosition().leansForward);
+ myFixture.performEditorAction("NextParameter");
+ myFixture.checkResult("class C { void m() { System.setProperty(, ) } }");
+ assertTrue(myFixture.getEditor().getCaretModel().getLogicalPosition().leansForward);
+ myFixture.performEditorAction("PrevParameter");
+ myFixture.checkResult("class C { void m() { System.setProperty(, ) } }");
+ assertTrue(myFixture.getEditor().getCaretModel().getLogicalPosition().leansForward);
+
+ // test hints remain shown while entering parameter values
+ myFixture.type("\"a");
+ myFixture.performEditorAction("NextParameter");
+ myFixture.type("\"b");
+ myFixture.doHighlighting();
+ myFixture.checkResultWithInlays("class C { void m() { System.setProperty(\"a\", \"b\") } }");
+
+ // test hints disappearance when caret moves out of parameter list
+ myFixture.performEditorAction("EditorRight");
+ myFixture.performEditorAction("EditorRight");
+ ParameterInfoController.waitForDelayedActions(getEditor(), 10, TimeUnit.SECONDS);
+
+ myFixture.doHighlighting();
+ waitTillAnimationCompletes();
+ myFixture.checkResultWithInlays("class C { void m() { System.setProperty(\"a\", \"b\") } }");
+ }
+
+ public void testSwitchingOverloads() {
+ myFixture.configureByText(JavaFileType.INSTANCE, "class C { void m() { Character.to } }");
+ complete("toChars(int codePoint)");
+ myFixture.checkResultWithInlays("class C { void m() { Character.toChars() } }");
+ showParameterInfo();
+ myFixture.performEditorAction("MethodOverloadSwitchDown");
+ myFixture.checkResultWithInlays("class C { void m() { Character.toChars(, , ) } }");
+ }
+
+ public void testSwitchingOverloadsWithParameterFilled() {
+ myFixture.configureByText(JavaFileType.INSTANCE, "class C { void m() { Character.to } }");
+ complete("toChars(int codePoint)");
+ type("123");
+ myFixture.checkResultWithInlays("class C { void m() { Character.toChars(123) } }");
+ showParameterInfo();
+ myFixture.performEditorAction("MethodOverloadSwitchDown");
+ myFixture.checkResultWithInlays("class C { void m() { Character.toChars(123, , ) } }");
+ myFixture.checkResult("class C { void m() { Character.toChars(123, , ) } }");
+ }
+
+ private void showParameterInfo() {
+ myFixture.performEditorAction("ParameterInfo");
+ UIUtil.dispatchAllInvocationEvents();
+ }
+
+ private void complete(String partOfItemText) {
+ LookupElement[] elements = myFixture.completeBasic();
+ LookupElement element = Stream.of(elements).filter(e -> {
+ LookupElementPresentation p = new LookupElementPresentation();
+ e.renderElement(p);
+ return (p.getItemText() + p.getTailText()).contains(partOfItemText);
+ }).findAny().get();
+ selectItem(element);
+ }
+
+ private void waitTillAnimationCompletes() {
+ long deadline = System.currentTimeMillis() + 60_000;
+ while (ParameterHintsPresentationManager.getInstance().isAnimationInProgress(getEditor())) {
+ if (System.currentTimeMillis() > deadline) fail("Too long waiting for animation to finish");
+ UIUtil.dispatchAllInvocationEvents();
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
index 70a6e9d942a9..1447275e3aef 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
@@ -1005,6 +1005,10 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
doTest(true);
}
+ public void testLowerBoundOfCapturedWildcardInSubtypingConstraint() throws Exception {
+ doTest(true);
+ }
+
public void testMembersContainedInCapturedWildcardType() throws Exception {
doTest();
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
index af4633b87e9b..79a9e1db466c 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
@@ -537,6 +537,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
+ public void testMethodInInheritorFoundBySecondSearch() throws Exception {
+ doTest();
+ }
+
public void testNonExactMethodReferenceOnRawClassType() throws Exception {
doTest();
}
diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java b/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java
index ec1ea6798856..ffb9b2cff586 100644
--- a/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java
+++ b/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java
@@ -39,7 +39,7 @@ import java.util.*;
/**
* @author Irina.Chernushina on 8/31/2015.
*/
-class JsonBySchemaObjectAnnotator implements Annotator {
+public class JsonBySchemaObjectAnnotator implements Annotator {
private final static Logger LOG = Logger.getInstance("#com.jetbrains.jsonSchema.JsonBySchemaAnnotator");
private static final Key> ANNOTATED_PROPERTIES = Key.create("JsonSchema.Properties.Annotated");
@NotNull private final VirtualFile mySchemaFile;
diff --git a/platform/core-api/src/com/intellij/ide/HelpIdProvider.java b/platform/core-api/src/com/intellij/ide/HelpIdProvider.java
index 77dd11c91334..80329e1b53f4 100644
--- a/platform/core-api/src/com/intellij/ide/HelpIdProvider.java
+++ b/platform/core-api/src/com/intellij/ide/HelpIdProvider.java
@@ -15,8 +15,10 @@
*/
package com.intellij.ide;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
public interface HelpIdProvider {
- @Nullable String getHelpId();
+ @Nullable @NonNls
+ String getHelpId();
}
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt
index fc4d38632a27..494b0366d992 100644
--- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt
+++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt
@@ -53,7 +53,7 @@ class UISettings : BaseState(), PersistentStateComponent {
@get:Property(filter = FontFilter::class)
@get:OptionTag("FONT_SIZE")
- var fontSize by storedProperty(10)
+ var fontSize by storedProperty(12)
@get:Property(filter = FontFilter::class)
@get:OptionTag("FONT_SCALE")
diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
index 76cb55b0e6d4..8d5271faee51 100644
--- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
+++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
@@ -29,6 +29,9 @@ public interface FontPreferences {
int DEFAULT_FONT_SIZE = FontSize.SMALL.getSize();
float DEFAULT_LINE_SPACING = 1.0f;
+ String MAC_OS_DEFAULT_FONT_FAMILY = "Menlo";
+ String LINUX_DEFAULT_FONT_FAMILY = "DejaVu Sans Mono";
+ String WINDOWS_DEFAULT_FONT_FAMILY = "Monospaced";
@NotNull
List getEffectiveFontFamilies();
@@ -74,14 +77,14 @@ public interface FontPreferences {
}
static String getDefaultFontName() {
- if (SystemInfo.isMacOSSnowLeopard) return "Menlo";
+ if (SystemInfo.isMacOSSnowLeopard) return MAC_OS_DEFAULT_FONT_FAMILY;
if (SystemInfo.isXWindow && !GraphicsEnvironment.isHeadless()) {
for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
- if ("DejaVu Sans Mono".equals(font.getName())) {
+ if (LINUX_DEFAULT_FONT_FAMILY.equals(font.getName())) {
return font.getFontName();
}
}
}
- return "Monospaced";
+ return WINDOWS_DEFAULT_FONT_FAMILY;
}
}
diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
index 8350f2fd9e08..122cc01fe328 100644
--- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
+++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
@@ -35,7 +35,6 @@ import com.intellij.util.PlatformUtils;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.JBUI;
-import com.intellij.util.ui.UIUtil;
import gnu.trove.THashMap;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -54,6 +53,7 @@ import static com.intellij.openapi.editor.markup.TextAttributes.USE_INHERITED_MA
import static com.intellij.openapi.util.Couple.of;
import static com.intellij.ui.ColorUtil.fromHex;
+@SuppressWarnings("UseJBColor")
public abstract class AbstractColorsScheme implements EditorColorsScheme, SerializableScheme {
private static final int CURR_VERSION = 142;
@@ -422,10 +422,11 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme, Serial
}
continue;
}
-
TextAttributes attr = myValueReader.read(TextAttributes.class, valueElement);
- myAttributesMap.put(key, attr);
- migrateErrorStripeColorFrom14(key, attr);
+ if (attr != null) {
+ myAttributesMap.put(key, attr);
+ migrateErrorStripeColorFrom14(key, attr);
+ }
}
}
@@ -522,10 +523,11 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme, Serial
}
private int readFontSize(Element element, boolean isDefault, Float fontScale) {
- Float size = (float)myValueReader.read(Integer.class, element);
- if (size == null) {
+ Integer intSize = myValueReader.read(Integer.class, element);
+ if (intSize == null) {
return -1;
}
+ Float size = (float)intSize;
if (!isDefault) {
size = (fontScale != null) ? size / fontScale : DEFAULT_FONT_SIZE.getSize();
}
@@ -562,7 +564,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme, Serial
parentNode.setAttribute(NAME_ATTR, getName());
parentNode.setAttribute(VERSION_ATTR, Integer.toString(myVersion));
- /**
+ /*
* FONT_SCALE is used to correctly identify the font size in both the JRE-managed HiDPI mode and
* the IDE-managed HiDPI mode: {@link UIUtil#isJreHiDPIEnabled()}. Also, it helps to distinguish
* the "hidpi-aware" scheme version from the previous one. Namely, the absence of the FONT_SCALE
diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/ValueElementReader.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/ValueElementReader.java
index 791b622ec74b..bb686942f56c 100644
--- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/ValueElementReader.java
+++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/ValueElementReader.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.Nullable;
import java.awt.Color;
@@ -32,6 +33,7 @@ import java.awt.Color;
*
* @author Sergey.Malenkov
*/
+@SuppressWarnings("UseJBColor")
class ValueElementReader {
@NonNls private static final String VALUE = "value";
@NonNls private static final String MAC = "mac";
@@ -60,6 +62,7 @@ class ValueElementReader {
* @param the result type
* @return a value or {@code null} if it cannot be read
*/
+ @Nullable
public T read(Class type, Element element) {
T value = null;
if (element != null) {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemRunConfigurationProducer.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemRunConfigurationProducer.java
index 3dd8fbcb03ed..830893c5bc02 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemRunConfigurationProducer.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemRunConfigurationProducer.java
@@ -20,11 +20,12 @@ import com.intellij.execution.actions.ConfigurationContext;
import com.intellij.execution.actions.ConfigurationFromContext;
import com.intellij.execution.actions.RunConfigurationProducer;
import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings;
-import com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author Vladislav.Soroka
@@ -37,7 +38,7 @@ public abstract class AbstractExternalSystemRunConfigurationProducer extends Run
}
@Override
- public boolean shouldReplace(ConfigurationFromContext self, ConfigurationFromContext other) {
+ public boolean shouldReplace(@NotNull ConfigurationFromContext self, @NotNull ConfigurationFromContext other) {
return true;
}
@@ -45,34 +46,33 @@ public abstract class AbstractExternalSystemRunConfigurationProducer extends Run
protected boolean setupConfigurationFromContext(ExternalSystemRunConfiguration configuration,
ConfigurationContext context,
Ref sourceElement) {
- Location location = context.getLocation();
- if (!(location instanceof ExternalSystemTaskLocation)) {
+ Project project = getProjectFromContext(context);
+ if (project == null) return false;
+
+ ExternalSystemTaskExecutionSettings contextTaskExecutionSettings = getTaskSettingsFromContext(context);
+ if (contextTaskExecutionSettings == null) return false;
+
+ ExternalSystemTaskExecutionSettings taskExecutionSettings = configuration.getSettings();
+ if (!contextTaskExecutionSettings.getExternalSystemId().equals(taskExecutionSettings.getExternalSystemId())) {
return false;
}
- ExternalSystemTaskLocation taskLocation = (ExternalSystemTaskLocation)location;
- ExternalSystemTaskExecutionSettings taskExecutionSettings = configuration.getSettings();
- ExternalTaskExecutionInfo task = taskLocation.getTaskInfo();
- taskExecutionSettings.setExternalProjectPath(task.getSettings().getExternalProjectPath());
- taskExecutionSettings.setTaskNames(task.getSettings().getTaskNames());
- configuration.setName(AbstractExternalSystemTaskConfigurationType.generateName(location.getProject(), taskExecutionSettings));
+ taskExecutionSettings.setExternalProjectPath(contextTaskExecutionSettings.getExternalProjectPath());
+ taskExecutionSettings.setTaskNames(contextTaskExecutionSettings.getTaskNames());
+ configuration.setName(AbstractExternalSystemTaskConfigurationType.generateName(project, taskExecutionSettings));
return true;
}
@Override
public boolean isConfigurationFromContext(ExternalSystemRunConfiguration configuration, ConfigurationContext context) {
- final Location contextLocation = context.getLocation();
- if (contextLocation == null) return false;
+ Project project = getProjectFromContext(context);
+ if (project == null) return false;
- if (!(contextLocation instanceof ExternalSystemTaskLocation)) {
- return false;
- }
+ ExternalSystemTaskExecutionSettings contextTaskExecutionSettings = getTaskSettingsFromContext(context);
+ if (contextTaskExecutionSettings == null) return false;
- ExternalSystemTaskLocation taskLocation = (ExternalSystemTaskLocation)contextLocation;
- ExternalSystemTaskExecutionSettings contextTaskExecutionSettings = taskLocation.getTaskInfo().getSettings();
ExternalSystemTaskExecutionSettings taskExecutionSettings = configuration.getSettings();
-
- if(!contextTaskExecutionSettings.getExternalSystemId().equals(taskExecutionSettings.getExternalSystemId())) {
+ if (!contextTaskExecutionSettings.getExternalSystemId().equals(taskExecutionSettings.getExternalSystemId())) {
return false;
}
if (!StringUtil.equals(contextTaskExecutionSettings.getExternalProjectPath(), taskExecutionSettings.getExternalProjectPath())) {
@@ -81,4 +81,22 @@ public abstract class AbstractExternalSystemRunConfigurationProducer extends Run
if (!contextTaskExecutionSettings.getTaskNames().equals(taskExecutionSettings.getTaskNames())) return false;
return true;
}
+
+ @Nullable
+ private static ExternalSystemTaskExecutionSettings getTaskSettingsFromContext(ConfigurationContext context) {
+ final Location contextLocation = context.getLocation();
+ if (!(contextLocation instanceof ExternalSystemTaskLocation)) {
+ return null;
+ }
+ return ((ExternalSystemTaskLocation)contextLocation).getTaskInfo().getSettings();
+ }
+
+ @Nullable
+ private static Project getProjectFromContext(ConfigurationContext context) {
+ final Location contextLocation = context.getLocation();
+ if (!(contextLocation instanceof ExternalSystemTaskLocation)) {
+ return null;
+ }
+ return contextLocation.getProject();
+ }
}
\ No newline at end of file
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/IdeModelsProviderImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/IdeModelsProviderImpl.java
index 20e3e0193287..1ac5390e3ee1 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/IdeModelsProviderImpl.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/IdeModelsProviderImpl.java
@@ -15,7 +15,6 @@
*/
package com.intellij.openapi.externalSystem.service.project;
-import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
import com.intellij.openapi.externalSystem.model.project.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleGrouperKt;
@@ -103,11 +102,9 @@ public class IdeModelsProviderImpl implements IdeModelsProvider {
}
private static boolean isApplicableIdeModule(@NotNull ModuleData moduleData, @NotNull Module ideModule) {
- if (ideModule.getProject().getUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT) == Boolean.TRUE) {
- for (VirtualFile root : ModuleRootManager.getInstance(ideModule).getContentRoots()) {
- if (pathsEqual(root.getPath(), moduleData.getLinkedExternalProjectPath())) {
- return true;
- }
+ for (VirtualFile root : ModuleRootManager.getInstance(ideModule).getContentRoots()) {
+ if (pathsEqual(root.getPath(), moduleData.getLinkedExternalProjectPath())) {
+ return true;
}
}
return isExternalSystemAwareModule(moduleData.getOwner(), ideModule) &&
diff --git a/platform/indexing-api/src/com/intellij/lang/findUsages/FindUsagesProvider.java b/platform/indexing-api/src/com/intellij/lang/findUsages/FindUsagesProvider.java
index b4faf829c909..46319061e507 100644
--- a/platform/indexing-api/src/com/intellij/lang/findUsages/FindUsagesProvider.java
+++ b/platform/indexing-api/src/com/intellij/lang/findUsages/FindUsagesProvider.java
@@ -17,6 +17,7 @@ package com.intellij.lang.findUsages;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -54,7 +55,7 @@ public interface FindUsagesProvider {
* @param psiElement the element for which the help topic is requested.
* @return the help topic ID, or null if no help is available.
*/
- @Nullable
+ @Nullable @NonNls
String getHelpId(@NotNull PsiElement psiElement);
/**
diff --git a/platform/lang-api/src/com/intellij/ide/util/gotoByName/ChooseByNameModel.java b/platform/lang-api/src/com/intellij/ide/util/gotoByName/ChooseByNameModel.java
index 9497519d9809..a0a29b98f2a8 100644
--- a/platform/lang-api/src/com/intellij/ide/util/gotoByName/ChooseByNameModel.java
+++ b/platform/lang-api/src/com/intellij/ide/util/gotoByName/ChooseByNameModel.java
@@ -15,6 +15,7 @@
*/
package com.intellij.ide.util.gotoByName;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -59,7 +60,7 @@ public interface ChooseByNameModel {
@Nullable
String getFullName(Object element);
- @Nullable
+ @Nullable @NonNls
String getHelpId();
boolean willOpenEditor();
diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/InlineElementData.java b/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/InlineElementData.java
index 6f027c47346e..c73357770e53 100644
--- a/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/InlineElementData.java
+++ b/platform/lang-impl/src/com/intellij/application/options/colors/highlighting/InlineElementData.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -53,7 +53,7 @@ public class InlineElementData extends HighlightData {
@Override
public void addHighlToView(Editor view, EditorColorsScheme scheme, Map displayText) {
int offset = getStartOffset();
- ParameterHintsPresentationManager.getInstance().addHint(view, offset, myText, false);
+ ParameterHintsPresentationManager.getInstance().addHint(view, offset, myText, false, false);
List inlays = view.getInlayModel().getInlineElementsInRange(offset, offset);
for (Inlay inlay : inlays) {
EditorCustomElementRenderer renderer = inlay.getRenderer();
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
index 98015fc61b8b..6aec6f29809f 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
@@ -863,8 +863,12 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements Pers
public void run() {
ApplicationManager.getApplication().assertIsDispatchThread();
Project project = myProject;
- DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
- if (project == null || !project.isInitialized() || project.isDisposed() || PowerSaveMode.isEnabled() || daemonCodeAnalyzer.myDisposed) {
+ DaemonCodeAnalyzerImpl daemonCodeAnalyzer;
+ if (project == null ||
+ !project.isInitialized() ||
+ project.isDisposed() ||
+ PowerSaveMode.isEnabled() ||
+ (daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project)).myDisposed) {
return;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ParameterHintsPresentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ParameterHintsPresentationManager.java
index 32389bf0c34e..c1f2cb5d5c05 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ParameterHintsPresentationManager.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ParameterHintsPresentationManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -33,6 +33,7 @@ import com.intellij.util.Alarm;
import com.intellij.util.ui.GraphicsUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import java.awt.*;
@@ -42,6 +43,7 @@ import java.util.Iterator;
import java.util.Set;
public class ParameterHintsPresentationManager implements Disposable {
+ private static final Key PINNED = Key.create("parameter.hint.pinned");
private static final Key HINT_FONT_METRICS = Key.create("ParameterHintFontMetrics");
private static final Key ANIMATION_STEP = Key.create("ParameterHintAnimationStep");
@@ -62,17 +64,27 @@ public class ParameterHintsPresentationManager implements Disposable {
return inlay.getRenderer() instanceof MyRenderer;
}
+ public boolean isPinned(@NotNull Inlay inlay) {
+ return Boolean.TRUE.equals(inlay.getUserData(PINNED));
+ }
+
+ public void unpin(@NotNull Inlay inlay) {
+ inlay.putUserData(PINNED, null);
+ }
+
public String getHintText(@NotNull Inlay inlay) {
EditorCustomElementRenderer renderer = inlay.getRenderer();
return renderer instanceof MyRenderer ? ((MyRenderer)renderer).getText() : null;
}
- public void addHint(@NotNull Editor editor, int offset, @NotNull String hintText, boolean useAnimation) {
+ public Inlay addHint(@NotNull Editor editor, int offset, @NotNull String hintText, boolean useAnimation, boolean pinned) {
MyRenderer renderer = new MyRenderer(editor, hintText, useAnimation);
Inlay inlay = editor.getInlayModel().addInlineElement(offset, renderer);
- if (useAnimation && inlay != null) {
- scheduleRendererUpdate(editor, inlay);
+ if (inlay != null) {
+ if (pinned) inlay.putUserData(PINNED, Boolean.TRUE);
+ if (useAnimation) scheduleRendererUpdate(editor, inlay);
}
+ return inlay;
}
public void deleteHint(@NotNull Editor editor, @NotNull Inlay hint) {
@@ -109,6 +121,12 @@ public class ParameterHintsPresentationManager implements Disposable {
myAlarm.addRequest(step, ANIMATION_STEP_MS, ModalityState.any());
}
+ @TestOnly
+ public boolean isAnimationInProgress(@NotNull Editor editor) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
+ return editor.getUserData(ANIMATION_STEP) != null;
+ }
+
private static Font getFont(@NotNull Editor editor) {
return getFontMetrics(editor).getFont();
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java
index e2c530389028..d56e0ae0926f 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -140,10 +140,6 @@ public class ParameterInfoComponent extends JPanel {
return myHighlighted;
}
- public void setRequestFocus(boolean requestFocus) {
- myRequestFocus = requestFocus;
- }
-
public boolean isRequestFocus() {
return myRequestFocus;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java
index 10220feb168b..c0b39419367e 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java
@@ -16,18 +16,19 @@
package com.intellij.codeInsight.hint;
+import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.ide.IdeTooltip;
+import com.intellij.injected.editor.EditorWindow;
import com.intellij.lang.parameterInfo.ParameterInfoHandler;
import com.intellij.lang.parameterInfo.ParameterInfoHandlerWithTabActionSupport;
import com.intellij.lang.parameterInfo.ParameterInfoUtils;
import com.intellij.lang.parameterInfo.UpdateParameterInfoContext;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.RangeMarker;
-import com.intellij.openapi.editor.ScrollType;
+import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.event.*;
import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.project.DumbService;
@@ -36,19 +37,21 @@ import com.intellij.openapi.ui.popup.Balloon.Position;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
-import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.TokenType;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.ui.HintHint;
import com.intellij.ui.LightweightHint;
import com.intellij.util.Alarm;
import com.intellij.util.containers.JBIterable;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.text.CharArrayUtil;
+import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import java.awt.*;
@@ -56,6 +59,8 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
public class ParameterInfoController implements Disposable {
private final Project myProject;
@@ -64,15 +69,16 @@ public class ParameterInfoController implements Disposable {
private final RangeMarker myLbraceMarker;
private final LightweightHint myHint;
private final ParameterInfoComponent myComponent;
+ private final boolean myKeepOnHintHidden;
private final CaretListener myEditorCaretListener;
@NotNull private final ParameterInfoHandler