mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -61,6 +61,7 @@ class JavaInlayParameterHintsProvider : InlayParameterHintsProvider {
|
||||
|
||||
"*Exception",
|
||||
|
||||
"*.add(*)",
|
||||
"*.set(*,*)",
|
||||
"*.get(*)",
|
||||
"*.create(*)",
|
||||
|
||||
+3
-14
@@ -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<Boolean, QuickFix> 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<Boolean> 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;
|
||||
}
|
||||
|
||||
+8
@@ -86,6 +86,7 @@ public class InferenceSession {
|
||||
private List<String> 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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
private static List<Object> test(List<List> list) {
|
||||
return list.stream().flatMap(List::stream).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+1
@@ -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");
|
||||
|
||||
|
||||
+5
-4
@@ -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);
|
||||
}
|
||||
|
||||
+205
@@ -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 <warning descr="The class is not exported from the module">PackageLocal</warning> myVar;
|
||||
protected Highlighted() {}
|
||||
public Highlighted(<warning descr="The class is not exported from the module">PackageLocal</warning> var) {setVar(var);}
|
||||
public <warning descr="The class is not exported from the module">PackageLocal</warning> getVar() {return myVar;}
|
||||
protected void setVar(<warning descr="The class is not exported from the module">PackageLocal</warning> 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 <warning descr="The class is not exported from the module">PackageLocalNested</warning> myVar;
|
||||
protected Highlighted() {}
|
||||
public Highlighted(<warning descr="The class is not exported from the module">PackageLocalNested</warning> var) {setVar(var);}
|
||||
public <warning descr="The class is not exported from the module">PackageLocalNested</warning> getVar() {return myVar;}
|
||||
protected void setVar(<warning descr="The class is not exported from the module">PackageLocalNested</warning> var) {myVar = var;}
|
||||
}
|
||||
""")
|
||||
}
|
||||
|
||||
fun testPackageLocalInInterface() {
|
||||
highlight("""package apiPkg;
|
||||
public interface Highlighted {
|
||||
<warning descr="The class is not exported from the module">PackageLocal</warning> myVar = new PackageLocal();
|
||||
<warning descr="The class is not exported from the module">PackageLocal</warning> getVar();
|
||||
void setVar(<warning descr="The class is not exported from the module">PackageLocal</warning> 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 <warning descr="The class is not exported from the module">NotExported</warning> myVar;
|
||||
protected Highlighted() {}
|
||||
public Highlighted(<warning descr="The class is not exported from the module">NotExported</warning> var) {setVar(var);}
|
||||
public <warning descr="The class is not exported from the module">NotExported</warning> getVar() {return myVar;}
|
||||
protected void setVar(<warning descr="The class is not exported from the module">NotExported</warning> 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 <warning descr="The class is not exported from the module">PackageLocal.DoubleNested</warning> getVar() {return myVar;}
|
||||
protected void setVar(<warning descr="The class is not exported from the module">PackageLocal.DoubleNested</warning> 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()
|
||||
}
|
||||
}
|
||||
+181
@@ -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<String, Pair<ProjectSystemId, ExternalProjectSettings>> myExternalProjectsToRestore;
|
||||
@Nullable
|
||||
private Map<String, ProjectSystemId> 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<ProjectSystemId, ExternalProjectSettings> 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<String, ProjectSystemId> 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<String, Pair<ProjectSystemId, ExternalProjectSettings>> getLinkedProjects(Project project) {
|
||||
Map<String, Pair<ProjectSystemId, ExternalProjectSettings>> 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);
|
||||
}
|
||||
}
|
||||
-10
@@ -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<C extends AbstractImp
|
||||
if (ContainerUtil.list(committedModules).containsAll(modules)) {
|
||||
resolveDependenciesTask.run();
|
||||
}
|
||||
else {
|
||||
ExternalSystemApiUtil.getLocalSettings(project, myExternalSystemId).forgetExternalProjects(
|
||||
Collections.singleton(projectSettings.getExternalProjectPath()));
|
||||
ExternalSystemApiUtil.getSettings(project, myExternalSystemId).unlinkExternalProject(
|
||||
projectSettings.getExternalProjectPath());
|
||||
|
||||
ExternalProjectsManager.getInstance(project).forgetExternalProjectData(
|
||||
myExternalSystemId, projectSettings.getExternalProjectPath());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+12
-3
@@ -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.
|
||||
@@ -53,9 +53,18 @@ public class DefinitionsScopedSearch extends ExtensibleQueryFactory<PsiElement,
|
||||
public static Query<PsiElement> search(PsiElement definitionsOf) {
|
||||
return INSTANCE.createUniqueResultsQuery(new SearchParameters(definitionsOf));
|
||||
}
|
||||
|
||||
|
||||
public static Query<PsiElement> 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<PsiElement> search(PsiElement definitionsOf,
|
||||
SearchScope searchScope,
|
||||
final boolean checkDeep) {
|
||||
return INSTANCE.createUniqueResultsQuery(new SearchParameters(definitionsOf, searchScope, checkDeep));
|
||||
}
|
||||
|
||||
public static class SearchParameters {
|
||||
|
||||
@@ -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
|
||||
|
||||
+16
-2
@@ -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<ImplementationViewComponent> {
|
||||
protected boolean isSearchDeep() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private class ImplementationsUpdaterTask extends BackgroundUpdaterTask<ImplementationViewComponent> {
|
||||
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)) {
|
||||
|
||||
+13
-4
@@ -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<PsiElement> 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<Project>() {
|
||||
@Override
|
||||
@@ -148,7 +157,7 @@ public class ImplementationSearcher {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DefinitionsScopedSearch.search(element, getSearchScope(element, editor)).forEach(new PsiElementProcessorAdapter<PsiElement>(collectProcessor){
|
||||
search(element, editor).forEach(new PsiElementProcessorAdapter<PsiElement>(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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
<externalProjectDataService implementation="com.intellij.openapi.externalSystem.service.project.manage.ContentRootDataService"/>
|
||||
<externalProjectDataService implementation="com.intellij.openapi.externalSystem.service.project.manage.LibraryDependencyDataService"/>
|
||||
<externalProjectDataService implementation="com.intellij.openapi.externalSystem.service.project.manage.ModuleDependencyDataService"/>
|
||||
|
||||
<configuration.ModuleStructureExtension implementation="com.intellij.openapi.externalSystem.service.project.manage.ExternalModuleStructureExtension"/>
|
||||
|
||||
<!--Tool window services-->
|
||||
<externalProjectDataService implementation="com.intellij.openapi.externalSystem.service.task.ToolWindowModuleService"/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -510,7 +510,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
}
|
||||
|
||||
private static class DunderAllBuilder extends PyRecursiveElementVisitor {
|
||||
private List<String> myResult = null;
|
||||
private List<String> myResult = new ArrayList<>();
|
||||
private boolean myDynamic = false;
|
||||
private boolean myFoundDunderAll = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user