{
return aPopup.getListStep().getIconFor(value);
}
+ @Override
+ public Icon getSelectedIconFor(E value) {
+ return aPopup.getListStep().getSelectedIconFor(value);
+ }
+
@Override
public boolean hasSeparatorAboveOf(E value) {
return aPopup.getListModel().isSeparatorAboveOf(value);
diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml
index 499cd99cd8ea..ae273649247b 100644
--- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml
+++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml
@@ -152,6 +152,8 @@
+
+
-
-
diff --git a/platform/platform-resources/src/PrivacyPolicy.html b/platform/platform-resources/src/PrivacyPolicy.html
index c3fc6051e6fc..f89b18f35323 100644
--- a/platform/platform-resources/src/PrivacyPolicy.html
+++ b/platform/platform-resources/src/PrivacyPolicy.html
@@ -1,4 +1,4 @@
-
+
@@ -12,7 +12,7 @@
This Policy may be amended from time to time. The respective latest version of the policy at the
point of time of the purchase/registration of a JetBrains Software Product
(whichever occurs later) shall apply. The data controller is JetBrains s.r.o., Praha 4, Na hřebenech
- II 1718/10, PSČ 147 00, Česká republika
+ II 1718/10, PSČ 140 00, Česká republika
In this Privacy Policy, we describe the type of data, including personal data (collectively, “data”),
@@ -297,9 +297,6 @@
Website works
For security purposes
- Make sure you connect to the right service on our Website when we make any changes to the way the
- Website works
-
Accepting these cookies is a condition of using the Website, so if you prevent these cookies we can't
diff --git a/platform/platform-resources/src/consents.json b/platform/platform-resources/src/consents.json
new file mode 100644
index 000000000000..a44ef27787b9
--- /dev/null
+++ b/platform/platform-resources/src/consents.json
@@ -0,0 +1,9 @@
+[
+ {
+ "consentId": "rsch.send.usage.stat",
+ "version": "1.0",
+ "text": "I consent to submit anonymous usage statistics to help JetBrains improve their products. I agree that the following information will be sent to JetBrains and processed in accordance with JetBrains Privacy Policy https://www.jetbrains.com/company/privacy.html\n * Information about which product features are used\n * General statistics (number of files, file types) of the solutions I am working on\n * General information about my hardware configuration (for example, amount of RAM, CPU speed and number of cores)\n * General information about my software configuration (for example, OS version)\nI can revoke my consent at any time in this Data Sharing Options dialog available at Help | Data Sharing Options",
+ "printableName": "Send anonymous usage statistics to JetBrains",
+ "accepted": "false"
+ }
+]
\ No newline at end of file
diff --git a/platform/platform-resources/src/idea/PlatformLangXmlApplicationInfo.xml b/platform/platform-resources/src/idea/PlatformLangXmlApplicationInfo.xml
index 27f1a9225651..20ce569b7834 100644
--- a/platform/platform-resources/src/idea/PlatformLangXmlApplicationInfo.xml
+++ b/platform/platform-resources/src/idea/PlatformLangXmlApplicationInfo.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/platform/platform-tests/testSrc/com/intellij/module/GroupModulesByQualifiedNamesTest.kt b/platform/platform-tests/testSrc/com/intellij/module/GroupModulesByQualifiedNamesTest.kt
index 127d1bbc8231..6b4ed28aed56 100644
--- a/platform/platform-tests/testSrc/com/intellij/module/GroupModulesByQualifiedNamesTest.kt
+++ b/platform/platform-tests/testSrc/com/intellij/module/GroupModulesByQualifiedNamesTest.kt
@@ -57,6 +57,20 @@ class GroupModulesByQualifiedNamesTest : PlatformTestCase() {
assertEmpty(group.childGroups(grouper))
}
+ fun `test module as a group`() {
+ val module1 = createModule("a.foo")
+ val module2 = createModule("a.foo.bar")
+
+ assertEquals("foo", grouper.getShortenedName(module1))
+ assertEquals("bar", grouper.getShortenedName(module2))
+
+ val parentGroup = ModuleGroup(listOf("a"))
+ assertSameElements(parentGroup.modulesInGroup(grouper, false), module1, module2)
+ assertSameElements(parentGroup.modulesInGroup(grouper, true), module1, module2)
+
+ assertEmpty(parentGroup.childGroups(grouper))
+ }
+
private val grouper: ModuleGrouper
get() = getQualifiedNameModuleGrouper(myProject)
}
diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java
index c97a341efe92..83cd1ffe9799 100644
--- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java
@@ -109,8 +109,8 @@ public class FileTypesTest extends PlatformTestCase {
String name = String.valueOf(i % 10 * 10 + i * 100 + i + 1);
names[i] = name + name + name + name;
}
- PlatformTestUtil.startPerformanceTest("isFileIgnored", 150, () -> {
- for (int i=0;i<1000;i++) {
+ PlatformTestUtil.startPerformanceTest("isFileIgnored", 15_000, () -> {
+ for (int i = 0; i < 100_000; i++) {
for (String name : names) {
myFileTypeManager.isFileIgnored(name);
}
@@ -262,9 +262,9 @@ public class FileTypesTest extends PlatformTestCase {
public void test7BitIsText() throws IOException {
File d = createTempDirectory();
- File f = new File(d, "xx.asfdasdfas");
byte[] bytes = {9, 10, 13, 'x', 'a', 'b'};
assertEquals(CharsetToolkit.GuessedEncoding.SEVEN_BIT, new CharsetToolkit(bytes).guessFromContent(bytes.length));
+ File f = new File(d, "xx.asfdasdfas");
FileUtil.writeToFile(f, bytes);
VirtualFile vFile = getVirtualFile(f);
diff --git a/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiEventConsistencyTest.kt b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiEventConsistencyTest.kt
index 5e6e5b3e1ed7..e057ba0fab2a 100644
--- a/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiEventConsistencyTest.kt
+++ b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiEventConsistencyTest.kt
@@ -22,6 +22,21 @@ import one.util.streamex.IntStreamEx
*/
class PsiEventConsistencyTest : LightPlatformCodeInsightFixtureTestCase() {
+ fun `test replacing child after changing its subtree`() {
+ WriteCommandAction.runWriteCommandAction(project) {
+ // prepare
+ val root = createEmptyFile().node
+ root.replaceChild(root.firstChildNode, createComposite(compositeTypes[0], listOf(createLeaf(leafTypes[0], "d"))))
+
+ // actual composite change
+ ChangeUtil.prepareAndRunChangeAction(ChangeUtil.ChangeAction {
+ root.firstChildNode.removeChild(root.firstChildNode.firstChildNode) // remove "d" leaf
+ root.replaceChild(root.firstChildNode, createComposite(compositeTypes[0], listOf())) // replace now empty composite with another one
+ }, root as FileElement)
+ assertEquals("", root.text)
+ }
+ }
+
fun testPsiDocSynchronization() {
PropertyChecker.forAll(commands).shouldHold { cmd ->
runCommand(cmd)
@@ -30,7 +45,7 @@ class PsiEventConsistencyTest : LightPlatformCodeInsightFixtureTestCase() {
}
private fun runCommand(cmd: AstCommand) {
- val file = PsiFileFactory.getInstance(project).createFileFromText("a.txt", PlainTextLanguage.INSTANCE, "", true, false)
+ val file = createEmptyFile()
val document = file.viewProvider.document!!
WriteCommandAction.runWriteCommandAction(project) {
cmd.performChange(file)
@@ -39,6 +54,9 @@ class PsiEventConsistencyTest : LightPlatformCodeInsightFixtureTestCase() {
}
}
+ private fun createEmptyFile() : PsiFile =
+ PsiFileFactory.getInstance(project).createFileFromText("a.txt", PlainTextLanguage.INSTANCE, "", true, false)
+
private interface AstCommand {
fun performChange(file: PsiFile)
}
diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java
index 5b0517bfe523..ce90d3e7c031 100644
--- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.java
@@ -27,19 +27,14 @@ import com.intellij.testFramework.UsefulTestCase;
import com.intellij.ui.SpeedSearchComparator;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.Matcher;
+import junit.framework.TestCase;
import org.jetbrains.annotations.NonNls;
import org.junit.Assert;
import java.util.ArrayList;
import java.util.List;
-/**
- * @author max
- * @author peter
- * @author Konstantin Bulenkov
- */
-public class NameUtilMatchingTest extends UsefulTestCase {
-
+public class NameUtilMatchingTest extends TestCase {
public void testSimpleCases() {
assertMatches("N", "NameUtilTest");
assertMatches("NU", "NameUtilTest");
@@ -473,34 +468,34 @@ public class NameUtilMatchingTest extends UsefulTestCase {
public void testMatchingFragments() {
@NonNls String sample = "NoClassDefFoundException";
// 0 2 7 10 15 21
- assertOrderedEquals(NameUtil.buildMatcher("ncldfou*ion", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
- TextRange.from(0, 1), TextRange.from(2, 2), TextRange.from(7, 1), TextRange.from(10, 3), TextRange.from(21, 3));
+ UsefulTestCase.assertOrderedEquals(NameUtil.buildMatcher("ncldfou*ion", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
+ TextRange.from(0, 1), TextRange.from(2, 2), TextRange.from(7, 1), TextRange.from(10, 3), TextRange.from(21, 3));
sample = "doGet(HttpServletRequest, HttpServletResponse):void";
// 0 22
- assertOrderedEquals(NameUtil.buildMatcher("d*st", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
+ UsefulTestCase.assertOrderedEquals(NameUtil.buildMatcher("d*st", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
TextRange.from(0, 1), TextRange.from(22, 2));
- assertOrderedEquals(NameUtil.buildMatcher("doge*st", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
+ UsefulTestCase.assertOrderedEquals(NameUtil.buildMatcher("doge*st", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
TextRange.from(0, 4), TextRange.from(22, 2));
sample = "_test";
- assertOrderedEquals(NameUtil.buildMatcher("_", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
+ UsefulTestCase.assertOrderedEquals(NameUtil.buildMatcher("_", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
TextRange.from(0, 1));
- assertOrderedEquals(NameUtil.buildMatcher("_t", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
+ UsefulTestCase.assertOrderedEquals(NameUtil.buildMatcher("_t", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
TextRange.from(0, 2));
}
public void testMatchingFragmentsSorted() {
@NonNls String sample = "SWUPGRADEHDLRFSPR7TEST";
// 0 9 12
- assertOrderedEquals(NameUtil.buildMatcher("SWU*H*R", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
+ UsefulTestCase.assertOrderedEquals(NameUtil.buildMatcher("SWU*H*R", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
TextRange.from(0, 3), TextRange.from(9, 1), TextRange.from(12, 1));
}
public void testPreferCapsMatching() {
String sample = "getCurrentUser";
// 0 4 10
- assertOrderedEquals(NameUtil.buildMatcher("getCU", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
+ UsefulTestCase.assertOrderedEquals(NameUtil.buildMatcher("getCU", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments(sample),
TextRange.from(0, 4), TextRange.from(10, 1));
}
@@ -685,7 +680,7 @@ public class NameUtilMatchingTest extends UsefulTestCase {
}
public void testOnlyUnderscoresPerformance() {
- PlatformTestUtil.startPerformanceTest(getTestName(false), 120, () -> {
+ PlatformTestUtil.startPerformanceTest(getName(), 120, () -> {
String small = StringUtil.repeat("_", 50000);
String big = StringUtil.repeat("_", small.length() + 1);
assertMatches("*" + small, big);
@@ -694,7 +689,7 @@ public class NameUtilMatchingTest extends UsefulTestCase {
}
public void testRepeatedLetterPerformance() {
- PlatformTestUtil.startPerformanceTest(getTestName(false), 30, () -> {
+ PlatformTestUtil.startPerformanceTest(getName(), 30, () -> {
String big = StringUtil.repeat("Aaaaaa", 50000);
assertMatches("aaaaaaaaaaaaaaaaaaaaaaaa", big);
assertDoesntMatch("aaaaaaaaaaaaaaaaaaaaaaaab", big);
@@ -704,12 +699,12 @@ public class NameUtilMatchingTest extends UsefulTestCase {
public void testMatchingAllOccurrences() {
String text = "some text";
MinusculeMatcher matcher = new AllOccurrencesMatcher("*e", NameUtil.MatchingCaseSensitivity.NONE, "");
- assertOrderedEquals(matcher.matchingFragments(text),
+ UsefulTestCase.assertOrderedEquals(matcher.matchingFragments(text),
new TextRange(3, 4), new TextRange(6, 7));
}
public void testCamelHumpWinsOverConsecutiveCaseMismatch() {
- assertSize(3, NameUtil.buildMatcher("GEN", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments("GetExtendedName"));
+ UsefulTestCase.assertSize(3, NameUtil.buildMatcher("GEN", NameUtil.MatchingCaseSensitivity.NONE).matchingFragments("GetExtendedName"));
assertPreference("GEN", "GetName", "GetExtendedName");
assertPreference("*GEN", "GetName", "GetExtendedName");
@@ -720,5 +715,4 @@ public class NameUtilMatchingTest extends UsefulTestCase {
assertMatches("pl", "printlnFoo");
assertDoesntMatch("pl", "printlnx");
}
-
}
diff --git a/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTest.java b/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTest.java
index 14cb9f85209e..5f10b4de9fbb 100644
--- a/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTest.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2016 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl;
@@ -207,7 +195,7 @@ public class UsageViewTest extends LightPlatformCodeInsightFixtureTestCase {
assertEmpty(excluded);
- String text = new ExporterToTextFile(usageView).getReportText();
+ String text = new ExporterToTextFile(usageView, UsageViewSettings.getInstance()).getReportText();
assertEquals("Found usages (1 usage found)\n" +
" Unclassified usage (1 usage found)\n" +
" light_idea_test_case (1 usage found)\n" +
diff --git a/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTreeTest.java b/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTreeTest.java
index 2416f18b16e1..9d1927aaa7fd 100644
--- a/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTreeTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/usages/impl/UsageViewTreeTest.java
@@ -1,17 +1,5 @@
/*
- * 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl;
@@ -61,9 +49,9 @@ public class UsageViewTreeTest extends UsefulTestCase {
XmlSerializerUtil.copyBean(settings.getState(), oldSettingsState);
disposeOnTearDown(() -> settings.loadState(oldSettingsState));
- settings.GROUP_BY_FILE_STRUCTURE = false;
- settings.GROUP_BY_USAGE_TYPE = false;
- settings.GROUP_BY_PACKAGE = false;
+ settings.setGroupByFileStructure(false);
+ settings.setGroupByUsageType(false);
+ settings.setGroupByPackage(false);
}
public void testSimpleModule() throws Exception {
@@ -81,7 +69,7 @@ public class UsageViewTreeTest extends UsefulTestCase {
addModule("xxx.main");
PsiFile file = myFixture.addFileToProject("xxx.main/A.txt", "hello");
Usage[] usages = {new UsageInfo2UsageAdapter(new UsageInfo(file))};
- UsageViewSettings.getInstance().FLATTEN_MODULES = false;
+ UsageViewSettings.getInstance().setFlattenModules(false);
ModuleGroupTestsKt.runWithQualifiedModuleNamesEnabled(() -> {
assertUsageViewStructureEquals(usages, "Usage (1 usage)\n" +
" Non-code usages (1 usage)\n" +
diff --git a/platform/platform-tests/testSrc/com/intellij/util/AlarmTest.java b/platform/platform-tests/testSrc/com/intellij/util/AlarmTest.java
index bde2e349210f..f53953413f7b 100644
--- a/platform/platform-tests/testSrc/com/intellij/util/AlarmTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/util/AlarmTest.java
@@ -34,7 +34,7 @@ package com.intellij.util;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-public class AlarmTest extends PlatformTestCase {
+ public class AlarmTest extends PlatformTestCase {
public void testTwoAddsWithZeroDelayMustExecuteSequentially() throws Exception {
Alarm alarm = new Alarm(getTestRootDisposable());
assertRequestsExecuteSequentially(alarm);
@@ -85,37 +85,41 @@ public class AlarmTest extends PlatformTestCase {
public void testOneAlarmDoesNotStartTooManyThreads() {
Alarm alarm = new Alarm(getTestRootDisposable());
- Map before = Thread.getAllStackTraces();
AtomicInteger executed = new AtomicInteger();
int N = 100000;
- for (int i = 0; i < N; i++) {
- alarm.addRequest(executed::incrementAndGet, 10);
- }
- while (executed.get() != N) {
- UIUtil.dispatchAllInvocationEvents();
- }
+ checkNotTooManyThreadsCreatedIn(()->{
+ for (int i = 0; i < N; i++) {
+ alarm.addRequest(executed::incrementAndGet, 10);
+ }
+ while (executed.get() != N) {
+ UIUtil.dispatchAllInvocationEvents();
+ }
+ });
+ }
+
+ private static void checkNotTooManyThreadsCreatedIn(Runnable runnable) {
+ Map before = Thread.getAllStackTraces();
+ runnable.run();
Map after = Thread.getAllStackTraces();
Map> diff = new HashMap<>();
after.forEach((key, value) -> diff.put(key, Arrays.asList(value)));
- before.keySet().forEach(diff::remove);
+ diff.keySet().removeAll(before.keySet());
if (!(after.size() - before.size() < 10)) {
- fail("before: "+before.size()+"; after: "+after.size()+"Diff:\n"+diff);
+ fail("before: "+before.size()+"; after: "+after.size()+"; Diff:\n"+diff);
}
}
public void testManyAlarmsDoNotStartTooManyThreads() {
- Map before = Thread.getAllStackTraces();
- AtomicInteger executed = new AtomicInteger();
- int N = 100000;
- List alarms = Stream.generate(() -> new Alarm(getTestRootDisposable())).limit(N).collect(Collectors.toList());
- alarms.forEach(alarm -> alarm.addRequest(executed::incrementAndGet, 10));
+ checkNotTooManyThreadsCreatedIn(()->{
+ AtomicInteger executed = new AtomicInteger();
+ int N = 100000;
+ List alarms = Stream.generate(() -> new Alarm(getTestRootDisposable())).limit(N).collect(Collectors.toList());
+ alarms.forEach(alarm -> alarm.addRequest(executed::incrementAndGet, 10));
- while (executed.get() != N) {
- UIUtil.dispatchAllInvocationEvents();
- }
- Map after = Thread.getAllStackTraces();
- LOG.debug("before: "+before.size()+"; after: "+after.size());
- assertTrue(after.size() - before.size() < 10);
+ while (executed.get() != N) {
+ UIUtil.dispatchAllInvocationEvents();
+ }
+ });
}
public void testOrderIsPreservedAfterModalitySwitching() {
diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
index 4c103be48295..37252291a552 100644
--- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
+++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
@@ -54,6 +54,7 @@ import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
import com.intellij.ide.util.gotoByName.GotoClassModel2;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.injected.editor.EditorWindow;
+import com.intellij.injected.editor.VirtualFileWindow;
import com.intellij.internal.DumpLookupElementWeights;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageStructureViewBuilder;
@@ -1139,7 +1140,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
@Override
protected void run(@NotNull Result result) {
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
- EditorUtil.fillVirtualSpaceUntilCaret(myEditor);
+ EditorUtil.fillVirtualSpaceUntilCaret(getHostEditor());
checkResult("TEXT", stripTrailingSpaces, SelectionAndCaretMarkupLoader.fromText(text), getHostFile().getText());
}
}.execute();
@@ -1462,8 +1463,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
}
private PsiFile getHostFile() {
- PsiElement element = getFile();
- return InjectedLanguageManager.getInstance(element.getProject()).getTopLevelFile(element);
+ VirtualFile hostVFile = myFile instanceof VirtualFileWindow ? ((VirtualFileWindow)myFile).getDelegate() : myFile;
+ return ReadAction.compute(() -> PsiManager.getInstance(getProject()).findFile(hostVFile));
}
private long collectAndCheckHighlighting(@NotNull ExpectedHighlightingData data) {
diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt
index 5677d2724d24..2c7f77a9da9b 100644
--- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt
+++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt
@@ -149,7 +149,7 @@ open class GuiTestCase {
*/
fun chooseFileInFileChooser(path: String, timeout: Long = defaultTimeout) {
val macNativeFileChooser = SystemInfo.isMac() && (System.getProperty("ide.mac.file.chooser.native", "true").toLowerCase() == "true")
- if (macNativeFileChooser) {
+ if (!macNativeFileChooser) {
MacFileChooserDialogFixture(robot()).selectByPath(path)
}
else {
@@ -170,6 +170,7 @@ open class GuiTestCase {
}
val dialogFixture = JDialogFixture(robot(), fileChooserDialog)
with(dialogFixture) {
+ asyncProcessIcon().waitUntilStop(20)
textfield("")
invokeAction("\$SelectAll")
typeText(path)
diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/testCases/PluginTestCase.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/testCases/PluginTestCase.kt
index 107f17ee59c9..5354b530b5f5 100644
--- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/testCases/PluginTestCase.kt
+++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/testCases/PluginTestCase.kt
@@ -25,6 +25,7 @@ import com.intellij.testGuiFramework.launcher.system.SystemInfo
import com.intellij.testGuiFramework.remote.transport.MessageType
import com.intellij.testGuiFramework.remote.transport.TransportMessage
import org.fest.swing.exception.WaitTimedOutError
+import java.io.File
import javax.swing.JDialog
open class PluginTestCase : GuiTestCase() {
@@ -34,6 +35,23 @@ open class PluginTestCase : GuiTestCase() {
private val WIN_PLUGIN_HOME = "/Users/jetbrains/Documents/plugins/"
private val LINUX_PLUGIN_HOME = "/Users/jetbrains/Documents/plugins/"
+ private fun getPluginHomePath(): String {
+ return when {
+ SystemInfo.isMac() -> MAC_PLUGIN_HOME
+ SystemInfo.isWin() -> WIN_PLUGIN_HOME
+ else -> {
+ LINUX_PLUGIN_HOME
+ }
+ }
+ }
+
+ fun findPlugin(pluginName: String): String {
+ val f = File(getPluginHomePath())
+ return f.listFiles { _, name ->
+ name.startsWith(pluginName)
+ }[0].toString()
+ }
+
fun installPluginAndRestart(installPluginsFunction: () -> Unit) {
val PLUGINS_INSTALLED = "PLUGINS_INSTALLED"
if (guiTestRule.getTestName() == GuiTestOptions.getResumeTestName() &&
@@ -69,14 +87,7 @@ open class PluginTestCase : GuiTestCase() {
}
}
- fun installPluginFromDisk(pluginDir: String, pluginName: String) {
- var pluginPath: String = when {
- SystemInfo.isMac() -> MAC_PLUGIN_HOME
- SystemInfo.isWin() -> WIN_PLUGIN_HOME
- else -> {
- LINUX_PLUGIN_HOME
- }
- } + pluginDir
+ fun installPluginFromDisk(pluginPath: String, pluginName: String) {
welcomeFrame {
actionLink("Configure").click()
popupClick("Plugins")
diff --git a/platform/usageView/src/com/intellij/usages/ShowUsagesSettings.java b/platform/usageView/src/com/intellij/usages/ShowUsagesSettings.java
deleted file mode 100644
index d3e2ecbc4d3b..000000000000
--- a/platform/usageView/src/com/intellij/usages/ShowUsagesSettings.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-package com.intellij.usages;
-
-import com.intellij.openapi.components.PersistentStateComponent;
-import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.components.State;
-import com.intellij.openapi.components.Storage;
-import com.intellij.util.xmlb.XmlSerializerUtil;
-import org.jetbrains.annotations.Nullable;
-
-@State(
- name = "ShowUsagesSettings",
- storages = {
- @Storage("usageView.xml")
- }
-)
-public class ShowUsagesSettings implements PersistentStateComponent {
- private final UsageViewSettings myState = new UsageViewSettings();
-
- @Nullable
- @Override
- public UsageViewSettings getState() {
- return myState;
- }
-
- @Override
- public void loadState(UsageViewSettings state) {
- XmlSerializerUtil.copyBean(state, myState);
- }
-
- public static ShowUsagesSettings getInstance() {
- return ServiceManager.getService(ShowUsagesSettings.class);
- }
-
- public ShowUsagesSettings() {
- myState.GROUP_BY_FILE_STRUCTURE = false;
- myState.GROUP_BY_MODULE = false;
- myState.GROUP_BY_PACKAGE = false;
- myState.GROUP_BY_USAGE_TYPE = false;
- myState.GROUP_BY_SCOPE = false;
- }
-}
diff --git a/platform/usageView/src/com/intellij/usages/ShowUsagesSettings.kt b/platform/usageView/src/com/intellij/usages/ShowUsagesSettings.kt
new file mode 100644
index 000000000000..7f6996f33383
--- /dev/null
+++ b/platform/usageView/src/com/intellij/usages/ShowUsagesSettings.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+ */
+package com.intellij.usages
+
+import com.intellij.openapi.components.PersistentStateComponent
+import com.intellij.openapi.components.ServiceManager
+import com.intellij.openapi.components.State
+import com.intellij.openapi.components.Storage
+
+@State(name = "ShowUsagesSettings", storages = arrayOf(Storage("usageView.xml")))
+class ShowUsagesSettings : PersistentStateComponent {
+ companion object {
+ @JvmStatic
+ val instance: ShowUsagesSettings
+ get() = ServiceManager.getService(ShowUsagesSettings::class.java)
+ }
+
+ private var state = ShowUsageViewSettings()
+
+ override fun getState() = state
+
+ override fun loadState(state: ShowUsageViewSettings) {
+ this.state = state
+ }
+
+ fun applyUsageViewSettings(otherState: UsageViewSettings) {
+ state.copyFrom(otherState)
+ }
+}
+
+class ShowUsageViewSettings : UsageViewSettings(false, false, false, false, false)
diff --git a/platform/usageView/src/com/intellij/usages/UsageView.java b/platform/usageView/src/com/intellij/usages/UsageView.java
index b34a397609d5..0a1fefe24afb 100644
--- a/platform/usageView/src/com/intellij/usages/UsageView.java
+++ b/platform/usageView/src/com/intellij/usages/UsageView.java
@@ -1,17 +1,5 @@
/*
- * 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages;
@@ -61,7 +49,7 @@ public interface UsageView extends Disposable {
boolean isSearchInProgress();
/**
- * @deprecated please specify mnemonic by prefixing the mnenonic character with an ampersand (&& for Mac-specific ampersands)
+ * @deprecated please specify mnemonic by prefixing the mnemonic character with an ampersand (&& for Mac-specific ampersands)
*/
void addButtonToLowerPane(@NotNull Runnable runnable, @NotNull String text, char mnemonic);
void addButtonToLowerPane(@NotNull Runnable runnable, @NotNull String text);
diff --git a/platform/usageView/src/com/intellij/usages/UsageViewSettings.java b/platform/usageView/src/com/intellij/usages/UsageViewSettings.java
deleted file mode 100644
index 86485f594240..000000000000
--- a/platform/usageView/src/com/intellij/usages/UsageViewSettings.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2000-2016 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.usages;
-
-import com.intellij.openapi.components.PersistentStateComponent;
-import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.components.State;
-import com.intellij.openapi.components.Storage;
-import com.intellij.util.xmlb.XmlSerializerUtil;
-import com.intellij.util.xmlb.annotations.Transient;
-import org.jetbrains.annotations.NonNls;
-
-import java.io.File;
-
-@State(
- name = "UsageViewSettings",
- storages = {
- @Storage("usageView.xml"),
- @Storage(value = "other.xml", deprecated = true)
- }
-)
-public class UsageViewSettings implements PersistentStateComponent {
- @NonNls public String EXPORT_FILE_NAME = "report.txt";
- public boolean IS_EXPANDED;
- public boolean IS_SHOW_PACKAGES = true;
- public boolean IS_SHOW_METHODS;
- public boolean IS_AUTOSCROLL_TO_SOURCE;
- public boolean IS_FILTER_DUPLICATED_LINE = true;
- public boolean IS_SHOW_MODULES;
- public boolean IS_PREVIEW_USAGES;
- public boolean IS_SORT_MEMBERS_ALPHABETICALLY = true;
- public float PREVIEW_USAGES_SPLITTER_PROPORTIONS = 0.5f;
-
- public boolean GROUP_BY_USAGE_TYPE = true;
- public boolean GROUP_BY_MODULE = true;
- public boolean FLATTEN_MODULES = true;
- public boolean GROUP_BY_PACKAGE = true;
- public boolean GROUP_BY_FILE_STRUCTURE = true;
- public boolean GROUP_BY_SCOPE;
-
- public static UsageViewSettings getInstance() {
- return ServiceManager.getService(UsageViewSettings.class);
- }
-
- public boolean isExpanded() {
- return IS_EXPANDED;
- }
-
- public void setExpanded(boolean val) {
- IS_EXPANDED = val;
- }
-
- public boolean isShowPackages() {
- return IS_SHOW_PACKAGES;
- }
-
- public void setShowPackages(boolean val) {
- IS_SHOW_PACKAGES = val;
- }
-
- public boolean isShowMethods() {
- return IS_SHOW_METHODS;
- }
-
- public boolean isShowModules() {
- return IS_SHOW_MODULES;
- }
-
- public void setShowMethods(boolean val) {
- IS_SHOW_METHODS = val;
- }
-
- public void setShowModules(boolean val) {
- IS_SHOW_MODULES = val;
- }
-
- public boolean isFilterDuplicatedLine() {
- return IS_FILTER_DUPLICATED_LINE;
- }
-
- public void setFilterDuplicatedLine(boolean val) {
- IS_FILTER_DUPLICATED_LINE = val;
- }
-
- @Transient
- public String getExportFileName() {
- return EXPORT_FILE_NAME != null ? EXPORT_FILE_NAME.replace('/', File.separatorChar) : null;
- }
-
- public void setExportFileName(String s) {
- if (s != null){
- s = s.replace(File.separatorChar, '/');
- }
- EXPORT_FILE_NAME = s;
- }
-
- @Override
- public UsageViewSettings getState() {
- return this;
- }
-
- @Override
- public void loadState(final UsageViewSettings object) {
- XmlSerializerUtil.copyBean(object, this);
- }
-}
diff --git a/platform/usageView/src/com/intellij/usages/UsageViewSettings.kt b/platform/usageView/src/com/intellij/usages/UsageViewSettings.kt
new file mode 100644
index 000000000000..db5e6f5a7c7a
--- /dev/null
+++ b/platform/usageView/src/com/intellij/usages/UsageViewSettings.kt
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+ */
+package com.intellij.usages
+
+import com.intellij.openapi.components.*
+import com.intellij.util.PathUtil
+import com.intellij.util.xmlb.annotations.OptionTag
+import com.intellij.util.xmlb.annotations.Transient
+
+/**
+ * Passed params will be used as default values, so, do not use constructor if instance will be used as a state (unless you want to change defaults)
+ */
+@State(name = "UsageViewSettings", storages = arrayOf(Storage("usageView.xml"), Storage(value = "other.xml", deprecated = true)))
+open class UsageViewSettings(
+ isGroupByFileStructure: Boolean = true,
+ isGroupByModule: Boolean = true,
+ isGroupByPackage: Boolean = true,
+ isGroupByUsageType: Boolean = true,
+ isGroupByScope: Boolean = false
+) : BaseState(), PersistentStateComponent {
+ companion object {
+ @JvmStatic
+ val instance: UsageViewSettings
+ get() = ServiceManager.getService(UsageViewSettings::class.java)
+ }
+
+ @Suppress("unused")
+ @JvmField
+ @Transient
+ @Deprecated(message = "Use isGroupByModule")
+ var GROUP_BY_MODULE = isGroupByModule
+
+ @Suppress("unused")
+ @JvmField
+ @Transient
+ @Deprecated(message = "Use isGroupByUsageType")
+ var GROUP_BY_USAGE_TYPE = isGroupByUsageType
+
+ @Suppress("unused")
+ @JvmField
+ @Transient
+ @Deprecated(message = "Use isGroupByFileStructure")
+ var GROUP_BY_FILE_STRUCTURE = isGroupByFileStructure
+
+ @Suppress("unused")
+ @JvmField
+ @Transient
+ @Deprecated(message = "Use isGroupByScope")
+ var GROUP_BY_SCOPE = isGroupByScope
+
+ @Suppress("unused")
+ @JvmField
+ @Transient
+ @Deprecated(message = "Use isGroupByPackage")
+ var GROUP_BY_PACKAGE = isGroupByPackage
+
+ @Suppress("MemberVisibilityCanPrivate")
+ @get:OptionTag("EXPORT_FILE_NAME")
+ internal var EXPORT_FILE_NAME by property("report.txt")
+
+ @get:OptionTag("IS_EXPANDED")
+ var isExpanded by property(false)
+
+ @get:OptionTag("IS_AUTOSCROLL_TO_SOURCE")
+ var isAutoScrollToSource by property(false)
+
+ @get:OptionTag("IS_FILTER_DUPLICATED_LINE")
+ var isFilterDuplicatedLine by property(true)
+
+ @get:OptionTag("IS_SHOW_METHODS")
+ var isShowModules by property(false)
+
+ @get:OptionTag("IS_PREVIEW_USAGES")
+ var isPreviewUsages by property(false)
+
+ @get:OptionTag("IS_SORT_MEMBERS_ALPHABETICALLY")
+ var isSortAlphabetically by property(false)
+
+ @get:OptionTag("PREVIEW_USAGES_SPLITTER_PROPORTIONS")
+ var previewUsagesSplitterProportion by property(0.5f)
+
+ @get:OptionTag("GROUP_BY_USAGE_TYPE")
+ var isGroupByUsageType by property(isGroupByUsageType)
+
+ @get:OptionTag("GROUP_BY_MODULE")
+ var isGroupByModule by property(isGroupByModule)
+
+ @get:OptionTag("FLATTEN_MODULES")
+ var isFlattenModules by property(true)
+
+ @get:OptionTag("GROUP_BY_PACKAGE")
+ var isGroupByPackage by property(isGroupByPackage)
+
+ @get:OptionTag("GROUP_BY_FILE_STRUCTURE")
+ var isGroupByFileStructure by property(isGroupByFileStructure)
+
+ @get:OptionTag("GROUP_BY_SCOPE")
+ var isGroupByScope: Boolean by property(isGroupByScope)
+
+ var exportFileName: String?
+ @Transient
+ get() = PathUtil.toSystemDependentName(EXPORT_FILE_NAME)
+ set(value) {
+ EXPORT_FILE_NAME = PathUtil.toSystemIndependentName(value)
+ }
+
+ override fun getState() = this
+
+ @Suppress("DEPRECATION")
+ override fun loadState(state: UsageViewSettings) {
+ copyFrom(state)
+ GROUP_BY_MODULE = isGroupByModule
+ GROUP_BY_USAGE_TYPE = isGroupByUsageType
+ GROUP_BY_FILE_STRUCTURE = isGroupByFileStructure
+ GROUP_BY_SCOPE = isGroupByScope
+ GROUP_BY_PACKAGE = isGroupByPackage
+ }
+}
diff --git a/platform/usageView/src/com/intellij/usages/impl/ExporterToTextFile.java b/platform/usageView/src/com/intellij/usages/impl/ExporterToTextFile.java
index 84c3f171114c..165f68af86ee 100644
--- a/platform/usageView/src/com/intellij/usages/impl/ExporterToTextFile.java
+++ b/platform/usageView/src/com/intellij/usages/impl/ExporterToTextFile.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2013 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl;
@@ -22,33 +10,20 @@ import com.intellij.usages.UsageViewSettings;
import com.intellij.util.SystemProperties;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
-import javax.swing.event.ChangeListener;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Enumeration;
-import java.util.TooManyListenersException;
/**
* @author max
*/
public class ExporterToTextFile implements com.intellij.ide.ExporterToTextFile {
private final UsageViewImpl myUsageView;
+ @NotNull
+ private final UsageViewSettings myUsageViewSettings;
- public ExporterToTextFile(@NotNull UsageViewImpl usageView) {
+ public ExporterToTextFile(@NotNull UsageViewImpl usageView, @NotNull UsageViewSettings usageViewSettings) {
myUsageView = usageView;
- }
-
- @Override
- public JComponent getSettingsEditor() {
- return null;
- }
-
- @Override
- public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {
- }
-
- @Override
- public void removeSettingsChangedListener(ChangeListener listener) {
+ myUsageViewSettings = usageViewSettings;
}
@NotNull
@@ -114,12 +89,12 @@ public class ExporterToTextFile implements com.intellij.ide.ExporterToTextFile {
@NotNull
@Override
public String getDefaultFilePath() {
- return UsageViewSettings.getInstance().EXPORT_FILE_NAME;
+ return myUsageViewSettings.getExportFileName();
}
@Override
- public void exportedTo(String filePath) {
- UsageViewSettings.getInstance().EXPORT_FILE_NAME = filePath;
+ public void exportedTo(@NotNull String filePath) {
+ myUsageViewSettings.setExportFileName(filePath);
}
@Override
diff --git a/platform/usageView/src/com/intellij/usages/impl/FileStructureGroupRuleProvider.java b/platform/usageView/src/com/intellij/usages/impl/FileStructureGroupRuleProvider.java
index a39705c69320..fb52130e3f41 100644
--- a/platform/usageView/src/com/intellij/usages/impl/FileStructureGroupRuleProvider.java
+++ b/platform/usageView/src/com/intellij/usages/impl/FileStructureGroupRuleProvider.java
@@ -1,29 +1,22 @@
/*
- * Copyright 2000-2009 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
-
package com.intellij.usages.impl;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
+import com.intellij.usages.UsageViewSettings;
import com.intellij.usages.rules.UsageGroupingRule;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface FileStructureGroupRuleProvider {
ExtensionPointName EP_NAME = new ExtensionPointName<>("com.intellij.fileStructureGroupRuleProvider");
@Nullable
- UsageGroupingRule getUsageGroupingRule(final Project project);
+ UsageGroupingRule getUsageGroupingRule(@NotNull Project project);
+
+ default UsageGroupingRule getUsageGroupingRule(@NotNull Project project, @NotNull UsageViewSettings usageViewSettings) {
+ return getUsageGroupingRule(project);
+ }
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/PreviewUsageAction.java b/platform/usageView/src/com/intellij/usages/impl/PreviewUsageAction.java
index 107e1572578e..55a9681ed305 100644
--- a/platform/usageView/src/com/intellij/usages/impl/PreviewUsageAction.java
+++ b/platform/usageView/src/com/intellij/usages/impl/PreviewUsageAction.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2014 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl;
@@ -19,7 +7,6 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.usageView.UsageViewBundle;
import com.intellij.usages.UsageView;
-import com.intellij.usages.UsageViewSettings;
import org.jetbrains.annotations.NotNull;
/**
@@ -32,11 +19,11 @@ class PreviewUsageAction extends RuleAction {
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().IS_PREVIEW_USAGES;
+ return myView.getUsageViewSettings().isPreviewUsages();
}
@Override
protected void setOptionValue(final boolean value) {
- UsageViewSettings.getInstance().IS_PREVIEW_USAGES = value;
+ myView.getUsageViewSettings().setPreviewUsages(value);
}
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/RuleAction.java b/platform/usageView/src/com/intellij/usages/impl/RuleAction.java
index ce7ef7f933a7..fff032a7cd4c 100644
--- a/platform/usageView/src/com/intellij/usages/impl/RuleAction.java
+++ b/platform/usageView/src/com/intellij/usages/impl/RuleAction.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2016 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl;
@@ -29,7 +17,7 @@ import javax.swing.*;
* @author Eugene Zhuravlev
*/
abstract class RuleAction extends ToggleAction implements DumbAware {
- private final UsageViewImpl myView;
+ protected final UsageViewImpl myView;
private boolean myState;
RuleAction(@NotNull UsageView view, @NotNull String text, @NotNull Icon icon) {
diff --git a/platform/usageView/src/com/intellij/usages/impl/SortMembersAlphabeticallyAction.java b/platform/usageView/src/com/intellij/usages/impl/SortMembersAlphabeticallyAction.java
index 55907817eed9..9cb8854e9c00 100644
--- a/platform/usageView/src/com/intellij/usages/impl/SortMembersAlphabeticallyAction.java
+++ b/platform/usageView/src/com/intellij/usages/impl/SortMembersAlphabeticallyAction.java
@@ -1,40 +1,27 @@
/*
- * Copyright 2000-2009 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl;
import com.intellij.icons.AllIcons;
import com.intellij.usageView.UsageViewBundle;
-import com.intellij.usages.UsageViewSettings;
+import org.jetbrains.annotations.NotNull;
/**
* @author cdr
*/
class SortMembersAlphabeticallyAction extends RuleAction {
-
- SortMembersAlphabeticallyAction(UsageViewImpl usageView) {
+ SortMembersAlphabeticallyAction(@NotNull UsageViewImpl usageView) {
super(usageView, UsageViewBundle.message("sort.alphabetically.action.text"), AllIcons.ObjectBrowser.Sorted);
}
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY;
+ return myView.getUsageViewSettings().isSortAlphabetically();
}
@Override
protected void setOptionValue(final boolean value) {
- UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY = value;
+ myView.getUsageViewSettings().setSortAlphabetically(value);
}
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
index 391ff369cefa..d3e6bc3beca3 100644
--- a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
+++ b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2009 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl;
@@ -40,7 +28,6 @@ import java.util.List;
* @author max
*/
public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider {
-
protected boolean supportsNonCodeRule() {
return true;
}
@@ -53,29 +40,35 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
return true;
}
+ @NotNull
+ @Override
+ public UsageGroupingRule[] getActiveRules(@NotNull Project project) {
+ return getActiveRules(project, UsageViewSettings.getInstance());
+ }
+
@Override
@NotNull
- public UsageGroupingRule[] getActiveRules(Project project) {
+ public UsageGroupingRule[] getActiveRules(@NotNull Project project, @NotNull UsageViewSettings usageViewSettings) {
List rules = new ArrayList<>();
if (supportsNonCodeRule()) {
rules.add(new NonCodeUsageGroupingRule(project));
}
- if (supportsScopesRule() && UsageViewSettings.getInstance().GROUP_BY_SCOPE) {
+ if (supportsScopesRule() && usageViewSettings.isGroupByScope()) {
rules.add(new UsageScopeGroupingRule());
}
- if (UsageViewSettings.getInstance().GROUP_BY_USAGE_TYPE) {
+ if (usageViewSettings.isGroupByUsageType()) {
rules.add(new UsageTypeGroupingRule());
}
- if (supportsModuleRule() && UsageViewSettings.getInstance().GROUP_BY_MODULE) {
- rules.add(new ModuleGroupingRule(project, UsageViewSettings.getInstance().FLATTEN_MODULES));
+ if (supportsModuleRule() && usageViewSettings.isGroupByModule()) {
+ rules.add(new ModuleGroupingRule(project, usageViewSettings.isFlattenModules()));
}
- if (UsageViewSettings.getInstance().GROUP_BY_PACKAGE) {
+ if (usageViewSettings.isGroupByPackage()) {
rules.add(DirectoryGroupingRule.getInstance(project));
}
- if (UsageViewSettings.getInstance().GROUP_BY_FILE_STRUCTURE) {
+ if (usageViewSettings.isGroupByFileStructure()) {
FileStructureGroupRuleProvider[] providers = Extensions.getExtensions(FileStructureGroupRuleProvider.EP_NAME);
for (FileStructureGroupRuleProvider ruleProvider : providers) {
- ContainerUtil.addIfNotNull(rules, ruleProvider.getUsageGroupingRule(project));
+ ContainerUtil.addIfNotNull(rules, ruleProvider.getUsageGroupingRule(project, usageViewSettings));
}
}
else {
@@ -143,11 +136,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().GROUP_BY_USAGE_TYPE;
+ return myView.getUsageViewSettings().isGroupByUsageType();
}
@Override
protected void setOptionValue(boolean value) {
- UsageViewSettings.getInstance().GROUP_BY_USAGE_TYPE = value;
+ myView.getUsageViewSettings().setGroupByUsageType(value);
}
}
@@ -157,11 +150,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().GROUP_BY_SCOPE;
+ return myView.getUsageViewSettings().isGroupByScope();
}
@Override
protected void setOptionValue(boolean value) {
- UsageViewSettings.getInstance().GROUP_BY_SCOPE = value;
+ myView.getUsageViewSettings().setGroupByScope(value);
}
}
@@ -172,12 +165,12 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().GROUP_BY_MODULE;
+ return myView.getUsageViewSettings().isGroupByModule();
}
@Override
protected void setOptionValue(boolean value) {
- UsageViewSettings.getInstance().GROUP_BY_MODULE = value;
+ myView.getUsageViewSettings().setGroupByModule(value);
}
}
@@ -188,18 +181,18 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().FLATTEN_MODULES;
+ return myView.getUsageViewSettings().isFlattenModules();
}
@Override
protected void setOptionValue(boolean value) {
- UsageViewSettings.getInstance().FLATTEN_MODULES = value;
+ myView.getUsageViewSettings().setFlattenModules(value);
}
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
- e.getPresentation().setEnabled(UsageViewSettings.getInstance().GROUP_BY_MODULE);
+ e.getPresentation().setEnabled(myView.getUsageViewSettings().isGroupByModule());
}
}
@@ -209,11 +202,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().GROUP_BY_PACKAGE;
+ return myView.getUsageViewSettings().isGroupByPackage();
}
@Override
protected void setOptionValue(boolean value) {
- UsageViewSettings.getInstance().GROUP_BY_PACKAGE = value;
+ myView.getUsageViewSettings().setGroupByPackage(value);
}
}
@@ -223,11 +216,11 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
}
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().GROUP_BY_FILE_STRUCTURE;
+ return myView.getUsageViewSettings().isGroupByFileStructure();
}
@Override
protected void setOptionValue(boolean value) {
- UsageViewSettings.getInstance().GROUP_BY_FILE_STRUCTURE = value;
+ myView.getUsageViewSettings().setGroupByFileStructure(value);
}
}
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java
index bb2b6370aafc..52aa1eeda481 100644
--- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java
+++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java
@@ -103,7 +103,7 @@ public class UsageViewImpl implements UsageView {
private final Project myProject;
private volatile boolean mySearchInProgress = true;
- private final ExporterToTextFile myTextFileExporter = new ExporterToTextFile(this);
+ private final ExporterToTextFile myTextFileExporter = new ExporterToTextFile(this, getUsageViewSettings());
private final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
private final ExclusionHandler myExclusionHandler;
@@ -181,7 +181,7 @@ public class UsageViewImpl implements UsageView {
UsageModelTracker myModelTracker = new UsageModelTracker(project);
Disposer.register(this, myModelTracker);
- myBuilder = new UsageNodeTreeBuilder(myTargets, getActiveGroupingRules(project), getActiveFilteringRules(project), myRoot, myProject);
+ myBuilder = new UsageNodeTreeBuilder(myTargets, getActiveGroupingRules(project, getUsageViewSettings()), getActiveFilteringRules(project), myRoot, myProject);
final MessageBusConnection messageBusConnection = myProject.getMessageBus().connect(this);
messageBusConnection.subscribe(UsageFilteringRuleProvider.RULES_CHANGED, this::rulesChanged);
@@ -347,6 +347,10 @@ public class UsageViewImpl implements UsageView {
};
}
+ public UsageViewSettings getUsageViewSettings() {
+ return UsageViewSettings.getInstance();
+ }
+
// nodes just changed: parent node -> changed child
// this collection is needed for firing javax.swing.tree.DefaultTreeModel.nodesChanged() events in batch
// has to be linked because events for child nodes should be fired after events for parent nodes
@@ -504,8 +508,8 @@ public class UsageViewImpl implements UsageView {
myCentralPanel.add(myPreviewSplitter, BorderLayout.CENTER);
- if (UsageViewSettings.getInstance().IS_PREVIEW_USAGES) {
- myPreviewSplitter.setProportion(UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS);
+ if (getUsageViewSettings().isPreviewUsages()) {
+ myPreviewSplitter.setProportion(getUsageViewSettings().getPreviewUsagesSplitterProportion());
treePane.putClientProperty(UIUtil.KEEP_BORDER_SIDES, SideBorder.RIGHT);
final JBTabbedPane tabbedPane = new JBTabbedPane(SwingConstants.BOTTOM){
@NotNull
@@ -580,11 +584,11 @@ public class UsageViewImpl implements UsageView {
}
@NotNull
- private static UsageGroupingRule[] getActiveGroupingRules(@NotNull final Project project) {
+ private static UsageGroupingRule[] getActiveGroupingRules(@NotNull final Project project, @NotNull UsageViewSettings usageViewSettings) {
final UsageGroupingRuleProvider[] providers = Extensions.getExtensions(UsageGroupingRuleProvider.EP_NAME);
List list = new ArrayList<>(providers.length);
for (UsageGroupingRuleProvider provider : providers) {
- ContainerUtil.addAll(list, provider.getActiveRules(project));
+ ContainerUtil.addAll(list, provider.getActiveRules(project, usageViewSettings));
}
Collections.sort(list, Comparator.comparingInt(UsageGroupingRule::getRank));
@@ -740,7 +744,7 @@ public class UsageViewImpl implements UsageView {
@Override
public void expandAll() {
UsageViewImpl.this.expandAll();
- UsageViewSettings.getInstance().setExpanded(true);
+ getUsageViewSettings().setExpanded(true);
}
@Override
@@ -751,7 +755,7 @@ public class UsageViewImpl implements UsageView {
@Override
public void collapseAll() {
UsageViewImpl.this.collapseAll();
- UsageViewSettings.getInstance().setExpanded(false);
+ getUsageViewSettings().setExpanded(false);
}
@Override
@@ -783,7 +787,7 @@ public class UsageViewImpl implements UsageView {
collapseAllAction,
actionsManager.createPrevOccurenceAction(myRootPanel),
actionsManager.createNextOccurenceAction(myRootPanel),
- actionsManager.installAutoscrollToSourceHandler(myProject, myTree, new MyAutoScrollToSourceOptionProvider()),
+ actionsManager.installAutoscrollToSourceHandler(myProject, myTree, new MyAutoScrollToSourceOptionProvider(getUsageViewSettings())),
actionsManager.createExportToTextFileAction(myTextFileExporter)
};
}
@@ -892,7 +896,7 @@ public class UsageViewImpl implements UsageView {
Collections.sort(allUsages, USAGE_COMPARATOR);
final Set excludedUsages = getExcludedUsages();
reset();
- myBuilder.setGroupingRules(getActiveGroupingRules(myProject));
+ myBuilder.setGroupingRules(getActiveGroupingRules(myProject, getUsageViewSettings()));
myBuilder.setFilteringRules(getActiveFilteringRules(myProject));
ApplicationManager.getApplication().runReadAction(() -> {
for (Usage usage : allUsages) {
@@ -1038,12 +1042,12 @@ public class UsageViewImpl implements UsageView {
@Override
protected boolean getOptionValue() {
- return UsageViewSettings.getInstance().isFilterDuplicatedLine();
+ return getUsageViewSettings().isFilterDuplicatedLine();
}
@Override
protected void setOptionValue(boolean value) {
- UsageViewSettings.getInstance().setFilterDuplicatedLine(value);
+ getUsageViewSettings().setFilterDuplicatedLine(value);
}
}
@@ -1268,7 +1272,7 @@ public class UsageViewImpl implements UsageView {
}
private void saveSplitterProportions() {
- UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS = myPreviewSplitter.getProportion();
+ getUsageViewSettings().setPreviewUsagesSplitterProportion(myPreviewSplitter.getProportion());
}
@Override
@@ -1314,7 +1318,7 @@ public class UsageViewImpl implements UsageView {
return;
}
showNode(firstUsageNode);
- if (UsageViewSettings.getInstance().isExpanded() && myUsageNodes.size() < 10000) {
+ if (getUsageViewSettings().isExpanded() && myUsageNodes.size() < 10000) {
expandAll();
}
});
@@ -1765,14 +1769,20 @@ public class UsageViewImpl implements UsageView {
}
private static class MyAutoScrollToSourceOptionProvider implements AutoScrollToSourceOptionProvider {
+ @NotNull private final UsageViewSettings myUsageViewSettings;
+
+ public MyAutoScrollToSourceOptionProvider(@NotNull UsageViewSettings usageViewSettings) {
+ myUsageViewSettings = usageViewSettings;
+ }
+
@Override
public boolean isAutoScrollMode() {
- return UsageViewSettings.getInstance().IS_AUTOSCROLL_TO_SOURCE;
+ return myUsageViewSettings.isAutoScrollToSource();
}
@Override
public void setAutoScrollMode(boolean state) {
- UsageViewSettings.getInstance().IS_AUTOSCROLL_TO_SOURCE = state;
+ myUsageViewSettings.setAutoScrollToSource(state);
}
}
@@ -1940,7 +1950,7 @@ public class UsageViewImpl implements UsageView {
}
private boolean isFilterDuplicateLines() {
- return myPresentation.isMergeDupLinesAvailable() && UsageViewSettings.getInstance().isFilterDuplicatedLine();
+ return myPresentation.isMergeDupLinesAvailable() && getUsageViewSettings().isFilterDuplicatedLine();
}
public Usage getNextToSelect(@NotNull Usage toDelete) {
diff --git a/platform/usageView/src/com/intellij/usages/impl/rules/FileGroupingRuleProvider.java b/platform/usageView/src/com/intellij/usages/impl/rules/FileGroupingRuleProvider.java
index 0c8e53fff250..d9c779a19d43 100644
--- a/platform/usageView/src/com/intellij/usages/impl/rules/FileGroupingRuleProvider.java
+++ b/platform/usageView/src/com/intellij/usages/impl/rules/FileGroupingRuleProvider.java
@@ -1,30 +1,19 @@
/*
- * Copyright 2000-2011 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.impl.rules;
import com.intellij.openapi.project.Project;
import com.intellij.usages.impl.FileStructureGroupRuleProvider;
import com.intellij.usages.rules.UsageGroupingRule;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class FileGroupingRuleProvider implements FileStructureGroupRuleProvider {
@Override
- public UsageGroupingRule getUsageGroupingRule(Project project) {
+ public UsageGroupingRule getUsageGroupingRule(@NotNull Project project) {
return new FileGroupingRule(project);
}
}
diff --git a/platform/usageView/src/com/intellij/usages/rules/UsageGroupingRuleProvider.java b/platform/usageView/src/com/intellij/usages/rules/UsageGroupingRuleProvider.java
index 5ae0b562d012..90c58992210b 100644
--- a/platform/usageView/src/com/intellij/usages/rules/UsageGroupingRuleProvider.java
+++ b/platform/usageView/src/com/intellij/usages/rules/UsageGroupingRuleProvider.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2009 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.usages.rules;
@@ -19,6 +7,7 @@ import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.usages.UsageView;
+import com.intellij.usages.UsageViewSettings;
import org.jetbrains.annotations.NotNull;
/**
@@ -27,7 +16,11 @@ import org.jetbrains.annotations.NotNull;
public interface UsageGroupingRuleProvider {
ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.usageGroupingRuleProvider");
- @NotNull UsageGroupingRule[] getActiveRules(Project project);
+ @NotNull UsageGroupingRule[] getActiveRules(@NotNull Project project);
+
+ default @NotNull UsageGroupingRule[] getActiveRules(@NotNull Project project, @NotNull UsageViewSettings usageViewSettings) {
+ return getActiveRules(project);
+ }
@NotNull
AnAction[] createGroupingActions(UsageView view);
diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties
index 9577d9aba3c3..505e4895fa45 100644
--- a/platform/util/resources/misc/registry.properties
+++ b/platform/util/resources/misc/registry.properties
@@ -1401,5 +1401,8 @@ editor.show.right.margin.in.read.only.files.description=Show right margin for re
editor.text.fractional.metrics=false
editor.text.fractional.metrics.description=Do not round glyph advances to integer values
+editor.disable.drag.with.right.button=false
+editor.disable.drag.with.right.button.description=Disable any mouse drag processing in editor with right mouse button pressed
+
idea.invalidate.caches.invalidates.vfs=false
idea.invalidate.caches.invalidates.vfs.description=Invalidate caches tries to invalidate everything, including Local History
\ No newline at end of file
diff --git a/platform/util/src/com/intellij/openapi/util/TextRange.java b/platform/util/src/com/intellij/openapi/util/TextRange.java
index 83934550169c..c530101db6ff 100644
--- a/platform/util/src/com/intellij/openapi/util/TextRange.java
+++ b/platform/util/src/com/intellij/openapi/util/TextRange.java
@@ -226,7 +226,7 @@ public class TextRange implements Segment, Serializable {
public static void assertProperRange(int startOffset, int endOffset, @NotNull Object message) {
if (!isProperRange(startOffset, endOffset)) {
- LOG.error("Invalid range specified: (" + startOffset + "," + endOffset + "); " + message);
+ LOG.error("Invalid range specified: (" + startOffset + ", " + endOffset + "); " + message);
}
}
diff --git a/platform/util/src/com/intellij/util/ConcurrencyUtil.java b/platform/util/src/com/intellij/util/ConcurrencyUtil.java
index afa62163c846..b9d098cd5a08 100644
--- a/platform/util/src/com/intellij/util/ConcurrencyUtil.java
+++ b/platform/util/src/com/intellij/util/ConcurrencyUtil.java
@@ -15,6 +15,7 @@
*/
package com.intellij.util;
+import com.intellij.ReviseWhenPortedToJDK;
import com.intellij.diagnostic.ThreadDumper;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -92,6 +93,8 @@ public class ConcurrencyUtil {
/**
* @return defaultValue if the reference contains null (in that case defaultValue is placed there), or reference value otherwise.
*/
+ @ReviseWhenPortedToJDK("8") // todo "replace with return ref.updateAndGet(prev -> prev == null ? defaultValue : prev)"
+ @NotNull
public static T cacheOrGet(@NotNull AtomicReference ref, @NotNull T defaultValue) {
T value = ref.get();
while (value == null) {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java
index a1f199423bbc..2c7e7e66cdf6 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/BreakpointsFavoriteListProvider.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2016 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.xdebugger.impl.breakpoints;
@@ -138,13 +126,7 @@ public class BreakpointsFavoriteListProvider extends AbstractFavoritesListProvid
if (node.getValue() instanceof Navigatable && ((Navigatable)node.getValue()).canNavigate()) {
return true;
}
- Collection extends AbstractTreeNode> children = node.getChildren();
- for (AbstractTreeNode child : children) {
- if (checkNavigatable(child)) {
- return true;
- }
- }
- return false;
+ return node.getChildren().stream().anyMatch(BreakpointsFavoriteListProvider::checkNavigatable);
}
@Nullable
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java
index 1686f5b5bb6a..863ce5652cac 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspection.java
@@ -15,34 +15,119 @@
*/
package com.siyeh.ig.bugs;
+import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.javadoc.PsiDocComment;
+import com.intellij.psi.javadoc.PsiDocToken;
import com.intellij.psi.util.MethodSignatureUtil;
+import com.intellij.psi.util.PsiUtil;
import com.siyeh.HardcodedMethodConstants;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.psiutils.MethodUtils;
+import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.psiutils.ClassUtils;
+import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
public class ComparableImplementedButEqualsNotOverriddenInspection extends BaseInspection {
@Override
@NotNull
public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "comparable.implemented.but.equals.not.overridden.display.name");
+ return InspectionGadgetsBundle.message("comparable.implemented.but.equals.not.overridden.display.name");
}
@Override
@NotNull
protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "comparable.implemented.but.equals.not.overridden.problem.descriptor");
+ return InspectionGadgetsBundle.message("comparable.implemented.but.equals.not.overridden.problem.descriptor");
+ }
+
+ @NotNull
+ @Override
+ protected InspectionGadgetsFix[] buildFixes(Object... infos) {
+ return new InspectionGadgetsFix[] {
+ new GenerateEqualsMethodFix(),
+ new AddNoteFix()
+ };
+ }
+
+ private static class GenerateEqualsMethodFix extends InspectionGadgetsFix {
+ @Nls
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return "Generate 'equals()' method";
+ }
+
+ @Override
+ protected void doFix(Project project, ProblemDescriptor descriptor) {
+ final PsiClass aClass = (PsiClass)descriptor.getPsiElement().getParent();
+ final StringBuilder methodText = new StringBuilder();
+ if (PsiUtil.isLanguageLevel5OrHigher(aClass)) {
+ methodText.append("@java.lang.Override ");
+ }
+ methodText.append("public ");
+ methodText.append("boolean equals(Object o) {\n");
+ methodText.append("if (!(o instanceof ").append(aClass.getName()).append("))").append("return false;");
+ methodText.append("return compareTo((").append(aClass.getName()).append(")o)==0;\n");
+ methodText.append("}");
+ final PsiMethod method =
+ JavaPsiFacade.getElementFactory(project).createMethodFromText(methodText.toString(), aClass, PsiUtil.getLanguageLevel(aClass));
+ final PsiElement newMethod = aClass.add(method);
+ CodeStyleManager.getInstance(project).reformat(newMethod);
+ }
+ }
+
+ private static class AddNoteFix extends InspectionGadgetsFix {
+
+ private static final Pattern PARAM_PATTERN = Pattern.compile("\\*[ \t]+@");
+
+ @Nls
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return "Add 'ordering inconsistent with equals' JavaDoc note";
+ }
+
+ @Override
+ protected void doFix(Project project, ProblemDescriptor descriptor) {
+ final PsiClass aClass = (PsiClass)descriptor.getPsiElement().getParent();
+ final PsiDocComment comment = aClass.getDocComment();
+ final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
+ if (comment == null) {
+ final PsiDocComment newComment = factory.createDocCommentFromText(
+ "/**\n" +
+ "* Note: this class has a natural ordering that is inconsistent with equals.\n" +
+ "*/", aClass);
+ aClass.addBefore(newComment, aClass.getFirstChild());
+ }
+ else {
+ final String text = comment.getText();
+ final Matcher matcher = PARAM_PATTERN.matcher(text);
+ String newCommentText;
+ if (matcher.find()) {
+ newCommentText = text.substring(0, matcher.start()) +
+ " * Note: this class has a natural ordering that is inconsistent with equals.\n" +
+ text.substring(matcher.start());
+ }
+ else {
+ newCommentText = text.substring(0, text.length() - 2) +
+ " * Note: this class has a natural ordering that is inconsistent with equals.\n*/";
+ }
+ final PsiDocComment newComment = factory.createDocCommentFromText(newCommentText);
+ comment.replace(newComment);
+ }
+ }
}
@Override
@@ -56,43 +141,68 @@ public class ComparableImplementedButEqualsNotOverriddenInspection extends BaseI
public void visitClass(PsiClass aClass) {
super.visitClass(aClass);
if (aClass.isInterface()) {
+ // the problem can't be fixed for an interface, so let's not report it
return;
}
- final PsiMethod[] methods = aClass.findMethodsByName(HardcodedMethodConstants.COMPARE_TO, false);
- if (methods.length == 0) {
- return;
- }
- final Project project = aClass.getProject();
- final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
- final GlobalSearchScope scope = aClass.getResolveScope();
final PsiClass comparableClass =
- psiFacade.findClass(CommonClassNames.JAVA_LANG_COMPARABLE,
- scope);
- if (comparableClass == null) {
+ JavaPsiFacade.getInstance(aClass.getProject()).findClass(CommonClassNames.JAVA_LANG_COMPARABLE, aClass.getResolveScope());
+ if (comparableClass == null || !aClass.isInheritor(comparableClass, true)) {
return;
}
- if (!aClass.isInheritor(comparableClass, true)) {
+ final PsiMethod[] comparableMethods = comparableClass.getMethods();
+ if (comparableMethods.length != 1) { // incorrect/broken jdk
return;
}
- final PsiMethod compareToMethod = comparableClass.getMethods()[0];
- boolean foundCompareTo = false;
- for (PsiMethod method : methods) {
- if (MethodSignatureUtil.isSuperMethod(compareToMethod, method)) {
- foundCompareTo = true;
- break;
+ final PsiMethod comparableMethod = MethodSignatureUtil.findMethodBySuperMethod(aClass, comparableMethods[0], false);
+ if (comparableMethod == null || comparableMethod.hasModifierProperty(PsiModifier.ABSTRACT) ||
+ comparableMethod.getBody() == null) {
+ return;
+ }
+ final PsiClass objectClass = ClassUtils.findObjectClass(aClass);
+ if (objectClass == null) {
+ return;
+ }
+ final PsiMethod[] equalsMethods = objectClass.findMethodsByName(HardcodedMethodConstants.EQUALS, false);
+ if (equalsMethods.length != 1) { // incorrect/broken jdk
+ return;
+ }
+ final PsiMethod equalsMethod = MethodSignatureUtil.findMethodBySuperMethod(aClass, equalsMethods[0], false);
+ if (equalsMethod != null && !equalsMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
+ return;
+ }
+ final String docCommentText = collapseWhitespace(getActualCommentText(aClass.getDocComment()));
+ if (StringUtil.containsIgnoreCase(docCommentText, "this class has a natural ordering that is inconsistent with equals")) {
+ // see Comparable.compareTo() javadoc
+ return;
+ }
+ registerClassError(aClass, aClass);
+ }
+
+ private static String getActualCommentText(PsiDocComment comment) {
+ if (comment == null) return "";
+ return Arrays.stream(comment.getChildren())
+ .filter(e -> (e instanceof PsiDocToken) && ((PsiDocToken)e).getTokenType() == JavaDocTokenType.DOC_COMMENT_DATA)
+ .map(PsiElement::getText)
+ .collect(Collectors.joining());
+ }
+
+ private static String collapseWhitespace(String s) {
+ final StringBuilder result = new StringBuilder();
+ boolean space = false;
+ for (int i = 0, length = s.length(); i < length; i++) {
+ char ch = s.charAt(i);
+ if (StringUtil.isWhiteSpace(ch)) {
+ if (!space) {
+ result.append(' ');
+ space = true;
+ }
+ }
+ else {
+ result.append(ch);
+ space = false;
}
}
- if (!foundCompareTo) {
- return;
- }
- final PsiMethod[] equalsMethods = aClass.findMethodsByName(
- HardcodedMethodConstants.EQUALS, false);
- for (PsiMethod equalsMethod : equalsMethods) {
- if (MethodUtils.isEquals(equalsMethod)) {
- return;
- }
- }
- registerClassError(aClass);
+ return result.toString();
}
}
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/TypeMayBeWeakenedInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/TypeMayBeWeakenedInspection.java
index d1544ee92858..33b8e44f1eda 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/TypeMayBeWeakenedInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/TypeMayBeWeakenedInspection.java
@@ -76,7 +76,7 @@ public class TypeMayBeWeakenedInspection extends AbstractBaseJavaLocalInspection
public OrderedSet myStopClassSet = new OrderedSet<>();
- private ListWrappingTableModel myStopClassesModel = new ListWrappingTableModel(myStopClassSet, InspectionGadgetsBundle
+ private final ListWrappingTableModel myStopClassesModel = new ListWrappingTableModel(myStopClassSet, InspectionGadgetsBundle
.message("inspection.type.may.be.weakened.add.stop.class.selection.table"));
class AddStopWordQuickfix implements LowPriorityAction, LocalQuickFix {
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass1.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass1.java
new file mode 100644
index 000000000000..95bdc82ff4c6
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass1.java
@@ -0,0 +1,8 @@
+abstract class AbstractClass1 implements Comparable {
+
+ int field = 1;
+
+ public int compareTo(AbstractClass1 other) {
+ return field > other.field ? 1 : (field == other.field ? 0 : -1);
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass2.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass2.java
new file mode 100644
index 000000000000..7b99a07e178c
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass2.java
@@ -0,0 +1,4 @@
+abstract class AbstractClass2 implements Comparable {
+
+ public abstract int compareTo(AbstractClass2 other);
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass3.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass3.java
new file mode 100644
index 000000000000..9c9f5f9bfe83
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/AbstractClass3.java
@@ -0,0 +1,10 @@
+abstract class AbstractClass3 implements Comparable {
+
+ int field;
+
+ public int compareTo(AbstractClass3 other) {
+ return field > other.field ? 1 : (field == other.field ? 0 : -1);
+ }
+
+ public abstract boolean equals(Object other);
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/Note.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/Note.java
new file mode 100644
index 000000000000..ea8235218929
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/comparable_implemented_but_equals_not_overridden/Note.java
@@ -0,0 +1,11 @@
+/**
+ * Note: This class has a natural
+ * ordering that is INCONSISTENT with equals.
+ */
+class Note implements Comparable {
+
+ @Override
+ public int compareTo(Note other) {
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspectionTest.java
index 11f392fbfd32..c1ab7d827162 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ComparableImplementedButEqualsNotOverriddenInspectionTest.java
@@ -26,6 +26,10 @@ public class ComparableImplementedButEqualsNotOverriddenInspectionTest extends L
public void testInterfaceImplementingComparable() { doTest(); }
public void testSimple() { doTest(); }
+ public void testAbstractClass1() { doTest(); }
+ public void testAbstractClass2() { doTest(); }
+ public void testAbstractClass3() { doTest(); }
+ public void testNote() { doTest(); }
@Nullable
@Override
diff --git a/plugins/gradle/resources/i18n/GradleBundle.properties b/plugins/gradle/resources/i18n/GradleBundle.properties
index 5a409331efe9..4854aa1f017e 100644
--- a/plugins/gradle/resources/i18n/GradleBundle.properties
+++ b/plugins/gradle/resources/i18n/GradleBundle.properties
@@ -2,8 +2,8 @@ gradle.name=Gradle
gradle.settings.text.use.default_wrapper.configured=Use default gradle wrapper (recommended)
gradle.settings.text.use.default_wrapper.not_configured=Use default gradle wrapper (not configured for the current project)
-gradle.settings.text.use.customizable_wrapper=Use gradle wrapper task configuration
-gradle.settings.text.wrapper.customization.compatibility=Gradle wrapper customization in script, works with Gradle 1.7 or later
+gradle.settings.text.use.customizable_wrapper=Use gradle 'wrapper' task configuration
+gradle.settings.text.wrapper.customization.compatibility=Gradle wrapper customization in build script
gradle.settings.text.use.local.distribution=Use local gradle distribution
gradle.settings.text.use.bundled.distribution=Use bundled gradle distribution: ({0})
gradle.settings.text.create.module.per.sourceset=Create separate module per source set
diff --git a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java
index 2f90e88e033d..a910caaf60b9 100644
--- a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java
+++ b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java
@@ -152,7 +152,16 @@ public class PropertiesUtil {
final String language = splitRawLocale[1];
final String country = splitRawLocale.length > 2 ? splitRawLocale[2] : "";
final String variant = splitRawLocale.length > 3 ? splitRawLocale[3] : "";
- return Pair.create(new Locale(language, country, variant), language + "_" + country + "_" + variant);
+
+ StringBuilder trimmedSuffix = new StringBuilder(language);
+ if (!country.isEmpty()) {
+ trimmedSuffix.append("_").append(country);
+ }
+ if (!variant.isEmpty()) {
+ trimmedSuffix.append("_").append(variant);
+ }
+
+ return Pair.create(new Locale(language, country, variant), trimmedSuffix.toString());
}
}
return Pair.create(DEFAULT_LOCALE, "");
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java
index 715987c2d30a..427550bdf22e 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2016 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package org.jetbrains.idea.svn.dialogs;
@@ -154,9 +142,6 @@ public class RepositoryBrowserDialog extends DialogWrapper {
InputEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)), browser);
AnAction action = CommonActionsManager.getInstance().createCollapseAllAction(new TreeExpander() {
- public void expandAll() {
- }
-
public boolean canExpand() {
return false;
}
diff --git a/python/educational-python/resources/idea/PyCharmEduApplicationInfo.xml b/python/educational-python/resources/idea/PyCharmEduApplicationInfo.xml
index bb5b1da9297d..57146632e3cc 100644
--- a/python/educational-python/resources/idea/PyCharmEduApplicationInfo.xml
+++ b/python/educational-python/resources/idea/PyCharmEduApplicationInfo.xml
@@ -2,7 +2,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jetbrains.org/intellij/schema/application-info http://jetbrains.org/intellij/schema/ApplicationInfo.xsd">
-
+
+
diff --git a/python/helpers/pycharm_matplotlib_backend/backend_interagg.py b/python/helpers/pycharm_matplotlib_backend/backend_interagg.py
index 317d9b86d622..1c70df0ab5ad 100644
--- a/python/helpers/pycharm_matplotlib_backend/backend_interagg.py
+++ b/python/helpers/pycharm_matplotlib_backend/backend_interagg.py
@@ -86,7 +86,7 @@ class FigureCanvasInterAgg(FigureCanvasAgg):
sock.send(struct.pack('>i', plot_index))
sock.send(struct.pack('>i', len(buffer)))
sock.send(buffer)
- except ConnectionRefusedError as _:
+ except OSError as _:
# nothing bad. It just means, that our tool window doesn't run yet
pass
diff --git a/python/ide/src/META-INF/PyCharmCorePlugin.xml b/python/ide/src/META-INF/PyCharmCorePlugin.xml
index 3e1f95d0b15b..c60c1bcb06df 100644
--- a/python/ide/src/META-INF/PyCharmCorePlugin.xml
+++ b/python/ide/src/META-INF/PyCharmCorePlugin.xml
@@ -13,4 +13,10 @@
+
+
+
+
diff --git a/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml b/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml
index edcfd1d9c8c7..c6350af0bd84 100644
--- a/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml
+++ b/python/python-community-ide-resources/resources/idea/PyCharmCoreApplicationInfo.xml
@@ -2,7 +2,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jetbrains.org/intellij/schema/application-info http://jetbrains.org/intellij/schema/ApplicationInfo.xsd">
-
+
{
final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
progressIndicator.setText("Waiting for REPL response with " + (int)(TIMEOUT / 10e8) + "s timeout");
+ progressIndicator.setIndeterminate(false);
final long startTime = System.nanoTime();
while (nextResponse == null) {
if (progressIndicator.isCanceled()) {
diff --git a/python/src/com/jetbrains/python/findUsages/PyClassGroupingRuleProvider.java b/python/src/com/jetbrains/python/findUsages/PyClassGroupingRuleProvider.java
index dfd8a78659cb..64550fa1c8a7 100644
--- a/python/src/com/jetbrains/python/findUsages/PyClassGroupingRuleProvider.java
+++ b/python/src/com/jetbrains/python/findUsages/PyClassGroupingRuleProvider.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2014 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.jetbrains.python.findUsages;
@@ -34,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
* @author yole
*/
public class PyClassGroupingRuleProvider implements FileStructureGroupRuleProvider {
- public UsageGroupingRule getUsageGroupingRule(Project project) {
+ public UsageGroupingRule getUsageGroupingRule(@NotNull Project project) {
return new PyClassGroupingRule();
}
diff --git a/python/src/com/jetbrains/python/findUsages/PyFunctionGroupingRuleProvider.java b/python/src/com/jetbrains/python/findUsages/PyFunctionGroupingRuleProvider.java
index bb8c560f0749..2454d12f541c 100644
--- a/python/src/com/jetbrains/python/findUsages/PyFunctionGroupingRuleProvider.java
+++ b/python/src/com/jetbrains/python/findUsages/PyFunctionGroupingRuleProvider.java
@@ -1,17 +1,5 @@
/*
- * Copyright 2000-2014 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.
+ * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.jetbrains.python.findUsages;
@@ -35,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
* @author yole
*/
public class PyFunctionGroupingRuleProvider implements FileStructureGroupRuleProvider {
- public UsageGroupingRule getUsageGroupingRule(Project project) {
+ public UsageGroupingRule getUsageGroupingRule(@NotNull Project project) {
return new PyFunctionGroupingRule();
}
diff --git a/python/src/com/jetbrains/python/testing/PyTestSharedForm.form b/python/src/com/jetbrains/python/testing/PyTestSharedForm.form
index 022ca667b564..92bbf9d5898f 100644
--- a/python/src/com/jetbrains/python/testing/PyTestSharedForm.form
+++ b/python/src/com/jetbrains/python/testing/PyTestSharedForm.form
@@ -8,38 +8,32 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
@@ -56,10 +50,9 @@
-
-
+
-
+
diff --git a/python/src/com/jetbrains/python/testing/PyTestSharedForm.java b/python/src/com/jetbrains/python/testing/PyTestSharedForm.java
index f00a7bb10d18..b5f0e140dff1 100644
--- a/python/src/com/jetbrains/python/testing/PyTestSharedForm.java
+++ b/python/src/com/jetbrains/python/testing/PyTestSharedForm.java
@@ -25,13 +25,13 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.psi.PsiDirectory;
+import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.TextAccessor;
-import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBRadioButton;
import com.intellij.ui.components.JBTextField;
import com.intellij.uiDesigner.core.GridConstraints;
-import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.util.ThreeState;
+import com.intellij.util.ui.JBUI;
import com.jetbrains.PySymbolFieldWithBrowseButton;
import com.jetbrains.extenstions.ContextAnchor;
import com.jetbrains.extenstions.ModuleBasedContextAnchor;
@@ -78,10 +78,6 @@ public final class PyTestSharedForm implements SimplePropertiesProvider {
* Panel for environment options
*/
private JPanel myOptionsPanel;
- /**
- * Test label
- */
- private JBLabel myLabel;
/**
* Panel for custom options, specific for runner and for "Additional Arguments"al;sop
*/
@@ -143,6 +139,13 @@ public final class PyTestSharedForm implements SimplePropertiesProvider {
});
}
+ /**
+ * Titles border used among test run configurations
+ */
+ public static void setBorderToPanel(@NotNull final JPanel panel, @NotNull final String title) {
+ panel.setBorder(IdeBorderFactory.createTitledBorder(title, false));
+ }
+
/**
* @param configuration configuration to configure form on creation
* @param customOptions additional option names this form shall support. Make sure your configuration has appropriate properties.
@@ -153,7 +156,8 @@ public final class PyTestSharedForm implements SimplePropertiesProvider {
final PyTestSharedForm form = new PyTestSharedForm(configuration.getModule(), configuration);
for (final TestTargetType testTargetType : TestTargetType.values()) {
- final JBRadioButton button = new JBRadioButton(StringUtil.capitalize(testTargetType.getCustomName().toLowerCase(Locale.getDefault())));
+ final JBRadioButton button =
+ new JBRadioButton(StringUtil.capitalize(testTargetType.getCustomName().toLowerCase(Locale.getDefault())));
button.setActionCommand(testTargetType.name());
button.addActionListener(o -> form.onTargetTypeChanged());
form.myButtonGroup.add(button);
@@ -166,9 +170,7 @@ public final class PyTestSharedForm implements SimplePropertiesProvider {
constraints.setFill(GridConstraints.FILL_BOTH);
form.myOptionsPanel.add(form.myOptionsForm.getMainPanel(), constraints);
-
- form.myLabel.setText(configuration.getTestFrameworkName());
-
+ setBorderToPanel(form.myPanel, configuration.getTestFrameworkName());
form.addCustomOptions(
ObjectArrays.concat(customOptions, new CustomOption(PyTestsSharedKt.getAdditionalArgumentsPropertyName(), TestTargetType.values()))
@@ -186,29 +188,28 @@ public final class PyTestSharedForm implements SimplePropertiesProvider {
final JBTextField textField = new JBTextField();
optionValueFields.put(option.myName, textField);
}
- myCustomOptionsPanel.setLayout(new GridLayoutManager(customOptions.length, 2));
- for (int i = 0; i < customOptions.length; i++) {
- final CustomOption option = customOptions[i];
+ final GridBagConstraints constraints = new GridBagConstraints();
+ constraints.insets = JBUI.insets(3);
+ constraints.gridy = 0;
+ constraints.anchor = GridBagConstraints.LINE_START;
+
+ for (final CustomOption option : customOptions) {
final JBTextField textField = optionValueFields.get(option.myName);
-
- final GridConstraints labelConstraints = new GridConstraints();
- labelConstraints.setFill(GridConstraints.FILL_VERTICAL);
- labelConstraints.setRow(i);
- labelConstraints.setColumn(0);
- labelConstraints.setHSizePolicy(GridConstraints.SIZEPOLICY_CAN_SHRINK);
-
- final JLabel label = new JLabel(StringUtil.capitalize(CAPITAL_LETTER.matcher(option.myName).replaceAll(" ")));
+ final JLabel label = new JLabel(StringUtil.capitalize(CAPITAL_LETTER.matcher(option.myName).replaceAll(" ") + ':'));
label.setHorizontalAlignment(SwingConstants.LEFT);
- myCustomOptionsPanel.add(label, labelConstraints);
+ constraints.fill = GridBagConstraints.NONE;
+ constraints.gridx = 0;
+ constraints.weightx = 0;
+ myCustomOptionsPanel.add(label, constraints);
- final GridConstraints textConstraints = new GridConstraints();
- textConstraints.setFill(GridConstraints.FILL_BOTH);
- textConstraints.setRow(i);
- textConstraints.setColumn(1);
- textConstraints.setHSizePolicy(GridConstraints.SIZEPOLICY_CAN_GROW);
- myCustomOptionsPanel.add(textField, textConstraints);
+ constraints.gridx = 1;
+ constraints.weightx = 1.0;
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ myCustomOptionsPanel.add(textField, constraints);
+
+ constraints.gridy++;
myCustomOptions.put(option.myName, new OptionHolder(option, label, textField));
}
diff --git a/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfigurationForm.java b/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfigurationForm.java
index aab24dfcf210..e277624b0d03 100644
--- a/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfigurationForm.java
+++ b/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfigurationForm.java
@@ -18,10 +18,10 @@ package com.jetbrains.python.testing.doctest;
import com.intellij.openapi.project.Project;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.testing.AbstractPythonTestRunConfigurationParams;
+import com.jetbrains.python.testing.PyTestSharedForm;
import com.jetbrains.python.testing.PythonTestLegacyRunConfigurationForm;
import javax.swing.*;
-import javax.swing.border.TitledBorder;
import java.awt.*;
public class PythonDocTestRunConfigurationForm implements PythonDocTestRunConfigurationParams {
@@ -33,9 +33,7 @@ public class PythonDocTestRunConfigurationForm implements PythonDocTestRunConfig
public PythonDocTestRunConfigurationForm(final Project project, final PythonDocTestRunConfiguration configuration) {
myRootPanel = new JPanel(new BorderLayout());
myTestRunConfigurationForm = new PythonTestLegacyRunConfigurationForm(project, configuration);
- TitledBorder border = (TitledBorder)myTestRunConfigurationForm.getTestsPanel().getBorder();
- border.setTitle(PyBundle.message("runcfg.doctest.display_name"));
-
+ PyTestSharedForm.setBorderToPanel(myTestRunConfigurationForm.getTestsPanel(), PyBundle.message("runcfg.doctest.display_name"));
myRootPanel.add(myTestRunConfigurationForm.getPanel(), BorderLayout.CENTER);
}
diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection3K/typingGenericIndirectInheritorGetItem.py b/python/testData/inspections/PyUnresolvedReferencesInspection3K/typingGenericIndirectInheritorGetItem.py
new file mode 100644
index 000000000000..9ac4f278ea56
--- /dev/null
+++ b/python/testData/inspections/PyUnresolvedReferencesInspection3K/typingGenericIndirectInheritorGetItem.py
@@ -0,0 +1,19 @@
+import typing
+
+
+T = typing.TypeVar('T')
+
+
+class X(typing.Generic[T]):
+ pass
+
+
+class Y(X[T]):
+ pass
+
+
+class Z(Y[T]):
+ pass
+
+
+Z[int]
\ No newline at end of file
diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java
index a789363f4d20..e3d3a7763ce7 100644
--- a/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java
+++ b/python/testSrc/com/jetbrains/python/inspections/Py3UnresolvedReferencesInspectionTest.java
@@ -215,6 +215,11 @@ public class Py3UnresolvedReferencesInspectionTest extends PyInspectionTestCase
doTest();
}
+ // PY-27102
+ public void testTypingGenericIndirectInheritorGetItem() {
+ doTest();
+ }
+
// PY-21655
public void testUsageOfFunctionDecoratedWithAsyncioCoroutine() {
doMultiFileTest("a.py");
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index fdbe334a18b2..30ad551070ed 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -143,13 +143,14 @@
+
-
-