diff --git a/java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java b/java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java index 937a27572eeb..a7c8780f95f3 100644 --- a/java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/hint/actions/ShowSiblingsAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * 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. @@ -73,6 +73,11 @@ public class ShowSiblingsAction extends ShowImplementationsAction { } } + @Override + protected boolean isSearchDeep() { + return true; + } + private void showSiblings(boolean invokedByShortcut, @NotNull Project project, Editor editor, diff --git a/java/java-impl/src/com/intellij/codeInsight/hints/JavaInlayParameterHintsProvider.kt b/java/java-impl/src/com/intellij/codeInsight/hints/JavaInlayParameterHintsProvider.kt index 4449482be0d6..8d05425af542 100644 --- a/java/java-impl/src/com/intellij/codeInsight/hints/JavaInlayParameterHintsProvider.kt +++ b/java/java-impl/src/com/intellij/codeInsight/hints/JavaInlayParameterHintsProvider.kt @@ -61,6 +61,7 @@ class JavaInlayParameterHintsProvider : InlayParameterHintsProvider { "*Exception", + "*.add(*)", "*.set(*,*)", "*.get(*)", "*.create(*)", diff --git a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java index 04a5dde2460d..447eb957a452 100644 --- a/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java @@ -37,7 +37,6 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; import com.intellij.refactoring.safeDelete.SafeDeleteHandler; import com.intellij.util.Query; -import com.intellij.util.containers.BidirectionalMap; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -56,8 +55,6 @@ public class EmptyMethodInspection extends GlobalJavaBatchInspectionTool { private static final String DISPLAY_NAME = InspectionsBundle.message("inspection.empty.method.display.name"); @NonNls private static final String SHORT_NAME = "EmptyMethod"; - private final BidirectionalMap myQuickFixes = new BidirectionalMap<>(); - public final JDOMExternalizableStringList EXCLUDE_ANNOS = new JDOMExternalizableStringList(); @SuppressWarnings("PublicField") public boolean commentsAreContent = false; @@ -263,21 +260,13 @@ public class EmptyMethodInspection extends GlobalJavaBatchInspectionTool { } private LocalQuickFix getFix(final ProblemDescriptionsProcessor processor, final boolean needToDeleteHierarchy) { - QuickFix fix = myQuickFixes.get(needToDeleteHierarchy); - if (fix == null) { - fix = new DeleteMethodQuickFix(processor, needToDeleteHierarchy); - myQuickFixes.put(needToDeleteHierarchy, fix); - return (LocalQuickFix)fix; - } - return (LocalQuickFix)fix; + return new DeleteMethodQuickFix(processor, needToDeleteHierarchy); } @Override public String getHint(@NotNull final QuickFix fix) { - final List list = myQuickFixes.getKeysByValue(fix); - if (list != null) { - LOG.assertTrue(list.size() == 1); - return String.valueOf(list.get(0)); + if (fix instanceof DeleteMethodQuickFix) { + return String.valueOf(((DeleteMethodQuickFix)fix).myNeedToDeleteHierarchy); } return null; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index 7fa5f60c7793..16f27712b838 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -86,6 +86,7 @@ public class InferenceSession { private List myErrorMessages; private boolean myErased; + private boolean myCheckApplicabilityPhase = true; public final InferenceIncorporationPhase myIncorporationPhase = new InferenceIncorporationPhase(this); @@ -374,6 +375,7 @@ public class InferenceSession { return; } + myCheckApplicabilityPhase = false; if (properties != null && !properties.isApplicabilityCheck()) { final PsiMethod method = properties.getMethod(); if (parent instanceof PsiCallExpression && PsiPolyExpressionUtil.isMethodCallPolyExpression((PsiExpression)parent, method)) { @@ -1669,6 +1671,12 @@ public class InferenceSession { return null; } + public void setErasedDuringApplicabilityCheck() { + if (myCheckApplicabilityPhase) { + myErased = true; + } + } + public void setErased() { myErased = true; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java index 368431f65696..6583588d8f90 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * 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. @@ -61,7 +61,7 @@ public class TypeCompatibilityConstraint implements ConstraintFormula { } if (isUncheckedConversion(myT, myS)) { - session.setErased(); + session.setErasedDuringApplicabilityCheck(); return true; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasureOfReturnTypeIffUncheckedConversionWasNecessaryDuringApplicabilityCheckOnly.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasureOfReturnTypeIffUncheckedConversionWasNecessaryDuringApplicabilityCheckOnly.java new file mode 100644 index 000000000000..bf2b1be69797 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasureOfReturnTypeIffUncheckedConversionWasNecessaryDuringApplicabilityCheckOnly.java @@ -0,0 +1,8 @@ +import java.util.List; +import java.util.stream.Collectors; + +class Test { + private static List test(List list) { + return list.stream().flatMap(List::stream).collect(Collectors.toList()); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt index 999db74d7f2d..d695a36345be 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/inlays/JavaParameterNameHintsTest.kt @@ -323,6 +323,7 @@ public class Test { System.out.println("A"); System.out.print("A"); + list.add("sss"); list.get(1); list.set(1, "sss"); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java index 73e49a51f6bd..f04d7a0690c6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -18,16 +18,13 @@ package com.intellij.codeInsight.daemon.lambda; import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; -import com.intellij.idea.Bombed; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.projectRoots.JavaSdkVersion; -import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.text.StringUtil; import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collection; import java.util.List; @@ -486,6 +483,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testErasureOfReturnTypeIffUncheckedConversionWasNecessaryDuringApplicabilityCheckOnly() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/Java9NonAccessibleTypeExposedTest.kt b/java/java-tests/testSrc/com/intellij/codeInspection/Java9NonAccessibleTypeExposedTest.kt new file mode 100644 index 000000000000..86965769e8b6 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInspection/Java9NonAccessibleTypeExposedTest.kt @@ -0,0 +1,205 @@ +/* + * 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.codeInspection + +import com.intellij.codeInspection.java19modules.Java9NonAccessibleTypeExposedInspection +import com.intellij.testFramework.fixtures.LightJava9ModulesCodeInsightFixtureTestCase +import com.intellij.testFramework.fixtures.MultiModuleJava9ProjectDescriptor.ModuleDescriptor.M2 +import com.intellij.testFramework.fixtures.MultiModuleJava9ProjectDescriptor.ModuleDescriptor.MAIN +import org.intellij.lang.annotations.Language +import org.jetbrains.annotations.NonNls +import org.jetbrains.annotations.NotNull + +/** + * @author Pavel.Dolgov + */ +class Java9NonAccessibleTypeExposedTest : LightJava9ModulesCodeInsightFixtureTestCase() { + override fun setUp() { + super.setUp() + myFixture.enableInspections(Java9NonAccessibleTypeExposedInspection()) + addFile("module-info.java", "module MAIN { exports apiPkg; exports otherPkg; requires M2; }", MAIN) + addFile("apiPkg/PublicApi.java", "package apiPkg; public class PublicApi {}", MAIN) + addFile("apiPkg/PackageLocal.java", "package apiPkg; class PackageLocal {}", MAIN) + addFile("otherPkg/PublicOther.java", "package otherPkg; public class PublicOther {}", MAIN) + } + + fun testPrimitives() { + highlight("""package apiPkg; +public class Highlighted { + public int i; + protected int getInt() {return 1;} + public void run() {} +}""") + } + + fun testImported() { + addFile("module-info.java", "module M2 { exports m2Pkg; }", M2) + addFile("m2Pkg/Exported.java", "package m2Pkg; public class Exported {}", M2) + + highlight("""package apiPkg; +import m2Pkg.Exported; +public class Highlighted { + public Exported myVar; + protected Highlighted() {} + public Highlighted(Exported var) {setVar(var);} + public Exported getVar() {return myVar;} + protected void setVar(Exported var) {myVar = var;} +}""") + } + + fun testPackageLocalExposed() { + highlight("""package apiPkg; +public class Highlighted { + public PackageLocal myVar; + protected Highlighted() {} + public Highlighted(PackageLocal var) {setVar(var);} + public PackageLocal getVar() {return myVar;} + protected void setVar(PackageLocal var) {myVar = var;} +} +""") + } + + fun testPackageLocalEncapsulated() { + highlight("""package apiPkg; +public class Highlighted { + private PackageLocal myVar; + private Highlighted() {} + Highlighted(PackageLocal var) {setVar(var);} + PackageLocal getVar() {return myVar;} + private void setVar(PackageLocal var) {myVar = var;} +} +""") + } + + fun testPackageLocalUsedLocally() { + highlight("""package apiPkg; +class Highlighted { + public PackageLocal myVar; + protected Highlighted() {} + public Highlighted(PackageLocal var) {setVar(var);} + public PackageLocal getVar() {return myVar;} + protected void setVar(PackageLocal var) {myVar = var;} +} +""") + } + + fun testPublicApi() { + highlight("""package apiPkg; +public class Highlighted { + public PublicApi myVar; + protected Highlighted() {} + public Highlighted(PublicApi var) {setVar(var);} + public PublicApi getVar() {return myVar;} + protected void setVar(PublicApi var) {myVar = var;} +} +""") + } + + fun testPublicOther() { + highlight("""package apiPkg; +import otherPkg.PublicOther; +public class Highlighted { + public PublicOther myVar; + protected Highlighted() {} + public Highlighted(PublicOther var) {setVar(var);} + public PublicOther getVar() {return myVar;} + protected void setVar(PublicOther var) {myVar = var;} +} +""") + } + + fun testPublicNested() { + highlight("""package apiPkg; +public class Highlighted { + public class PublicNested {} + public PublicNested myVar; + protected Highlighted() {} + public Highlighted(PublicNested var) {setVar(var);} + public PublicNested getVar() {return myVar;} + protected void setVar(PublicNested var) {myVar = var;} +} +""") + } + + fun testPackageLocalNested() { + highlight("""package apiPkg; +public class Highlighted { + class PackageLocalNested {} + public PackageLocalNested myVar; + protected Highlighted() {} + public Highlighted(PackageLocalNested var) {setVar(var);} + public PackageLocalNested getVar() {return myVar;} + protected void setVar(PackageLocalNested var) {myVar = var;} +} +""") + } + + fun testPackageLocalInInterface() { + highlight("""package apiPkg; +public interface Highlighted { + PackageLocal myVar = new PackageLocal(); + PackageLocal getVar(); + void setVar(PackageLocal var); +} +""") + } + + fun testPublicInInterface() { + highlight("""package apiPkg; +public interface Highlighted { + PublicApi myVar = new PublicApi(); + PublicApi getVar(); + void setVar(PublicApi var); +} +""") + } + + fun testNotExportedPackage() { + addFile("implPkg/NotExported.java", "package implPkg; public class NotExported {}", MAIN) + highlight("""package apiPkg; +import implPkg.NotExported; +public class Highlighted { + public NotExported myVar; + protected Highlighted() {} + public Highlighted(NotExported var) {setVar(var);} + public NotExported getVar() {return myVar;} + protected void setVar(NotExported var) {myVar = var;} +} +""") + } + + fun testDoubleNested() { + addFile("apiPkg/PublicOuter.java", """package apiPkg; public class PublicOuter { + static class PackageLocal { + public class DoubleNested {} + } +}""", MAIN) + highlight("""package apiPkg; +import apiPkg.PublicOuter.PackageLocal; +public class Highlighted { + private PackageLocal.DoubleNested myVar; + public PackageLocal.DoubleNested getVar() {return myVar;} + protected void setVar(PackageLocal.DoubleNested var) {myVar = var;} +} +""") + } + + private fun highlight(@Language("JAVA") @NotNull @NonNls text: String) { + val file = addFile("apiPkg/Highlighted.java", text, MAIN) + myFixture.configureFromExistingVirtualFile(file) + myFixture.checkHighlighting() + } +} diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalModuleStructureExtension.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalModuleStructureExtension.java new file mode 100644 index 000000000000..2d76753ee28b --- /dev/null +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalModuleStructureExtension.java @@ -0,0 +1,181 @@ +/* + * 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.openapi.externalSystem.service.project.manage; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.externalSystem.ExternalSystemManager; +import com.intellij.openapi.externalSystem.model.ProjectSystemId; +import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings; +import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings; +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil; +import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator; +import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; +import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureExtension; +import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; +import com.intellij.openapi.ui.MasterDetailsComponent; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Vladislav.Soroka + * @since 11/1/2016 + */ +public class ExternalModuleStructureExtension extends ModuleStructureExtension { + + private static final Logger LOG = Logger.getInstance(ExternalModuleStructureExtension.class); + @SuppressWarnings("StatefulEp") + @Nullable + private Project myProject; + private boolean isExternalSystemsInvolved; + @Nullable + private Map> myExternalProjectsToRestore; + @Nullable + private Map myOrphanProjectsCandidates; + + @Override + public void reset(Project project) { + if (project == null) return; + myProject = project; + isExternalSystemsInvolved = false; + myExternalProjectsToRestore = getLinkedProjects(project); + myOrphanProjectsCandidates = new HashMap<>(); + } + + @Override + public void disposeUIResources() { + try { + if (isExternalSystemsInvolved) { + assert myOrphanProjectsCandidates != null; + assert myProject != null; + if (myExternalProjectsToRestore != null) { + for (Pair settingsPair : myExternalProjectsToRestore.values()) { + AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(myProject, settingsPair.first); + String rootProjectPath = settingsPair.second.getExternalProjectPath(); + if (settings.getLinkedProjectSettings(rootProjectPath) == null) { + //noinspection unchecked + settings.linkProject(settingsPair.second); + } + myOrphanProjectsCandidates.remove(rootProjectPath); + } + } + + ModulesConfigurator modulesConfigurator = getModulesConfigurator(myProject); + if (modulesConfigurator != null) { + for (Map.Entry entry : myOrphanProjectsCandidates.entrySet()) { + String rootProjectPath = entry.getKey(); + if (StringUtil.isNotEmpty(rootProjectPath)) { + unlinkProject(myProject, entry.getValue(), rootProjectPath); + } + } + } + } + } + catch (Throwable e) { + LOG.warn(e); + } + finally { + myProject = null; + myExternalProjectsToRestore = null; + myOrphanProjectsCandidates = null; + } + } + + @Override + public boolean addModuleNodeChildren(Module module, MasterDetailsComponent.MyNode moduleNode, Runnable treeNodeNameUpdater) { + String systemIdString = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY); + if (StringUtil.isNotEmpty(systemIdString)) { + isExternalSystemsInvolved = true; + String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module); + if (myOrphanProjectsCandidates != null && StringUtil.isNotEmpty(rootProjectPath)) { + myOrphanProjectsCandidates.put(rootProjectPath, new ProjectSystemId(systemIdString)); + } + } + return false; + } + + @Override + public void moduleRemoved(Module module) { + String systemIdString = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY); + if (StringUtil.isEmpty(systemIdString)) return; + + String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module); + if (StringUtil.isEmpty(rootProjectPath)) return; + + Project project = module.getProject(); + ModulesConfigurator modulesConfigurator = getModulesConfigurator(project); + if (modulesConfigurator == null) return; + + for (Module m : modulesConfigurator.getModules()) { + if (m != module && rootProjectPath.equals(ExternalSystemApiUtil.getExternalRootProjectPath(m))) { + return; + } + } + + ProjectSystemId systemId = new ProjectSystemId(systemIdString); + ExternalSystemApiUtil.getSettings(project, systemId).unlinkExternalProject(rootProjectPath); + assert myOrphanProjectsCandidates != null; + myOrphanProjectsCandidates.put(rootProjectPath, systemId); + isExternalSystemsInvolved = true; + } + + @Override + public void afterModelCommit() { + if (myProject == null) return; + myExternalProjectsToRestore = getLinkedProjects(myProject); + } + + @Nullable + private static ModulesConfigurator getModulesConfigurator(Project project) { + if (ApplicationManager.getApplication().isHeadlessEnvironment()) return null; + final ProjectStructureConfigurable structureConfigurable = ProjectStructureConfigurable.getInstance(project); + StructureConfigurableContext context = structureConfigurable.isUiInitialized() ? structureConfigurable.getContext() : null; + return context != null ? context.getModulesConfigurator() : null; + } + + private static Map> getLinkedProjects(Project project) { + Map> result = new HashMap<>(); + for (ExternalSystemManager manager : ExternalSystemApiUtil.getAllManagers()) { + ProjectSystemId systemId = manager.getSystemId(); + AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, systemId); + Collection projectsSettings = systemSettings.getLinkedProjectsSettings(); + for (Object settings : projectsSettings) { + if (settings instanceof ExternalProjectSettings) { + ExternalProjectSettings projectSettings = (ExternalProjectSettings)settings; + result.put((projectSettings).getExternalProjectPath(), Pair.create(systemId, projectSettings)); + } + } + } + + return result; + } + + private static void unlinkProject(@NotNull Project project, ProjectSystemId systemId, String rootProjectPath) { + ExternalSystemApiUtil.getLocalSettings(project, systemId).forgetExternalProjects(Collections.singleton(rootProjectPath)); + ExternalSystemApiUtil.getSettings(project, systemId).unlinkExternalProject(rootProjectPath); + ExternalProjectsManager.getInstance(project).forgetExternalProjectData(systemId, rootProjectPath); + } +} diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java index 6071a2a8562e..d3ea32456322 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/wizard/AbstractExternalProjectImportBuilder.java @@ -17,7 +17,6 @@ import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefres import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider; import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl; import com.intellij.openapi.externalSystem.service.project.IdeUIModifiableModelsProvider; -import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager; import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager; import com.intellij.openapi.externalSystem.service.settings.AbstractImportFromExternalSystemControl; import com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog; @@ -206,15 +205,6 @@ public abstract class AbstractExternalProjectImportBuilder search(PsiElement definitionsOf) { return INSTANCE.createUniqueResultsQuery(new SearchParameters(definitionsOf)); } - + public static Query search(PsiElement definitionsOf, SearchScope searchScope) { - return INSTANCE.createUniqueResultsQuery(new SearchParameters(definitionsOf, searchScope, true)); + return search(definitionsOf, searchScope, true); + } + + /** + * @param checkDeep false for show implementations to present definition only + */ + public static Query search(PsiElement definitionsOf, + SearchScope searchScope, + final boolean checkDeep) { + return INSTANCE.createUniqueResultsQuery(new SearchParameters(definitionsOf, searchScope, checkDeep)); } public static class SearchParameters { diff --git a/platform/lang-api/src/com/intellij/execution/RunManager.java b/platform/lang-api/src/com/intellij/execution/RunManager.java index e7d708163abf..9dda643800d0 100644 --- a/platform/lang-api/src/com/intellij/execution/RunManager.java +++ b/platform/lang-api/src/com/intellij/execution/RunManager.java @@ -22,7 +22,6 @@ import com.intellij.execution.configurations.RunProfile; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -180,12 +179,12 @@ public abstract class RunManager { * {@link #addConfiguration(RunnerAndConfigurationSettings, boolean)} if you want the configuration to be persisted in the project. * * @param name the name of the configuration to create (should be unique and not equal to any other existing configuration) - * @param type the type of the configuration to create. + * @param factory the factory instance. * @return the configuration settings object. * @see RunManager#suggestUniqueName(String, Collection) */ @NotNull - public abstract RunnerAndConfigurationSettings createRunConfiguration(@NotNull String name, @NotNull ConfigurationFactory type); + public abstract RunnerAndConfigurationSettings createRunConfiguration(@NotNull String name, @NotNull ConfigurationFactory factory); /** * Creates a configuration settings object based on a specified {@link RunConfiguration}. Note that you need to call diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java index c5187394a745..8a727fe9f64d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/actions/ShowImplementationsAction.java @@ -199,7 +199,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { } @NotNull - static ImplementationSearcher createImplementationsSearcher() { + ImplementationSearcher createImplementationsSearcher() { if (ApplicationManager.getApplication().isUnitTestMode()) { return new ImplementationSearcher() { @Override @@ -213,6 +213,11 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { protected PsiElement[] filterElements(PsiElement element, PsiElement[] targetElements) { return ShowImplementationsAction.filterElements(targetElements); } + + @Override + protected boolean isSearchDeep() { + return ShowImplementationsAction.this.isSearchDeep(); + } }; } @@ -399,7 +404,11 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { return PsiUtilCore.toPsiElementArray(unique); } - private static class ImplementationsUpdaterTask extends BackgroundUpdaterTask { + protected boolean isSearchDeep() { + return false; + } + + private class ImplementationsUpdaterTask extends BackgroundUpdaterTask { private final String myCaption; private final Editor myEditor; @NotNull @@ -441,6 +450,11 @@ public class ShowImplementationsAction extends AnAction implements PopupAction { super.run(indicator); final ImplementationSearcher.BackgroundableImplementationSearcher implementationSearcher = new ImplementationSearcher.BackgroundableImplementationSearcher() { + @Override + protected boolean isSearchDeep() { + return ShowImplementationsAction.this.isSearchDeep(); + } + @Override protected void processElement(PsiElement element) { if (!updateComponent(element, null)) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java index 22536aa09383..6080b0721467 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/ImplementationSearcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * 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. @@ -33,6 +33,7 @@ import com.intellij.psi.search.PsiElementProcessorAdapter; import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.DefinitionsScopedSearch; import com.intellij.util.CommonProcessors; +import com.intellij.util.Query; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -104,7 +105,7 @@ public class ImplementationSearcher { final PsiElement[][] result = new PsiElement[1][]; if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { try { - result[0] = DefinitionsScopedSearch.search(element, getSearchScope(element, editor)).toArray(PsiElement.EMPTY_ARRAY); + result[0] = search(element, editor).toArray(PsiElement.EMPTY_ARRAY); } catch (IndexNotReadyException e) { dumbModeNotification(element); @@ -116,6 +117,14 @@ public class ImplementationSearcher { return result[0]; } + protected Query search(PsiElement element, Editor editor) { + return DefinitionsScopedSearch.search(element, getSearchScope(element, editor), isSearchDeep()); + } + + protected boolean isSearchDeep() { + return true; + } + private static void dumbModeNotification(@NotNull PsiElement element) { Project project = ApplicationManager.getApplication().runReadAction(new Computable() { @Override @@ -148,7 +157,7 @@ public class ImplementationSearcher { @Override public void run() { try { - DefinitionsScopedSearch.search(element, getSearchScope(element, editor)).forEach(new PsiElementProcessorAdapter(collectProcessor){ + search(element, editor).forEach(new PsiElementProcessorAdapter(collectProcessor){ @Override public boolean processInReadAction(PsiElement element) { return !accept(element) || super.processInReadAction(element); @@ -187,7 +196,7 @@ public class ImplementationSearcher { } }; try { - DefinitionsScopedSearch.search(element, getSearchScope(element, editor)).forEach(processor); + search(element, editor).forEach(processor); } catch (IndexNotReadyException e) { ImplementationSearcher.dumbModeNotification(element); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index a280727e8778..bb1670f60857 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -1032,8 +1032,8 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo @Override @NotNull - public RunnerAndConfigurationSettings createRunConfiguration(@NotNull String name, @NotNull ConfigurationFactory type) { - return createConfiguration(name, type); + public RunnerAndConfigurationSettings createRunConfiguration(@NotNull String name, @NotNull ConfigurationFactory factory) { + return createConfiguration(name, factory); } @Override diff --git a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml index d94df8f803e0..374d8c40b91e 100644 --- a/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml +++ b/platform/platform-resources/src/META-INF/ExternalSystemExtensions.xml @@ -28,6 +28,8 @@ + + diff --git a/python/helpers/conda_packaging_tool.py b/python/helpers/conda_packaging_tool.py index b4680b915e97..051848d23fd5 100644 --- a/python/helpers/conda_packaging_tool.py +++ b/python/helpers/conda_packaging_tool.py @@ -10,8 +10,13 @@ def usage(): exit(ERROR_WRONG_USAGE) def do_list_available_packages(): - from conda.cli.main_search import common - index = common.get_index_trap() + try: + from conda.cli.main_search import common + index = common.get_index_trap() + except ImportError: + from conda.cli.main_search import get_index + index = get_index() + for pkg in index.values(): sys.stdout.write("\t".join([pkg["name"], pkg["version"], ":".join(pkg["depends"])])+chr(10)) sys.stdout.flush() @@ -19,9 +24,15 @@ def do_list_available_packages(): def do_list_channels(): import conda.config as config - for channel in config.get_channel_urls(): - sys.stdout.write(channel+chr(10)) - sys.stdout.flush() + if hasattr(config, "get_channel_urls"): + channels = config.get_channel_urls() + else: + channels = config.context.channels + for channel in channels: + if channel != 'defaults': + sys.stdout.write(channel+chr(10)) + sys.stdout.flush() + def main(): retcode = 0 diff --git a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java index 294c92bbdcb4..0a543f1c255f 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyFileImpl.java @@ -510,7 +510,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { } private static class DunderAllBuilder extends PyRecursiveElementVisitor { - private List myResult = null; + private List myResult = new ArrayList<>(); private boolean myDynamic = false; private boolean myFoundDunderAll = false;