diff --git a/.idea/libraries/bouncy_castle.xml b/.idea/libraries/bouncy_castle.xml new file mode 100644 index 000000000000..4e4673aa939e --- /dev/null +++ b/.idea/libraries/bouncy_castle.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/builder_model.xml b/.idea/libraries/builder_model.xml index 232e3ef09430..34a541dc26d5 100644 --- a/.idea/libraries/builder_model.xml +++ b/.idea/libraries/builder_model.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/libraries/commons_compress.xml b/.idea/libraries/commons_compress.xml new file mode 100644 index 000000000000..7d2018ea643a --- /dev/null +++ b/.idea/libraries/commons_compress.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/jgraphx_3_4_0_1.xml b/.idea/libraries/jgraphx_3_4_0_1.xml new file mode 100644 index 000000000000..a648030d9c93 --- /dev/null +++ b/.idea/libraries/jgraphx_3_4_0_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/truth.xml b/.idea/libraries/truth.xml new file mode 100644 index 000000000000..c9d61aa7a54f --- /dev/null +++ b/.idea/libraries/truth.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 1e07d739f243..4ceca82dd5bb 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -113,6 +113,10 @@ + + + + @@ -218,6 +222,7 @@ + diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant index 28e9c5776f4e..7b87103e70db 100644 --- a/build/scripts/layouts.gant +++ b/build/scripts/layouts.gant @@ -843,6 +843,9 @@ def layoutAndroid(String androidHome, String androidToolsBaseHome) { jar("manifest-merger.jar") { module("manifest-merger") } + jar("repository.jar") { + module("repository") + } jar("sdk-tools.jar") { module("assetstudio") module("ddmlib") @@ -856,6 +859,9 @@ def layoutAndroid(String androidHome, String androidToolsBaseHome) { module("chartlib") module("builder-model") module("builder-test-api") + module("instant-run-common") + module("instant-run-client") + module("instant-run-runtime") } jar("androidAnnotations.jar") { fileset(dir: "$androidHome/android/annotations") diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index 597590909bc1..e7d1bd41f2a3 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -186,6 +186,7 @@ libraryLicense(name: "coverage.py", attachedTo: "python-helpers", version: "3.7. libraryLicense(name: "Cucumber-Core", libraryName: "cucumber-core", version: "1.2.4", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") libraryLicense(name: "Cucumber-Groovy", libraryName: "cucumber-groovy", version: "1.2.4", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") libraryLicense(name: "Cucumber-Java", libraryName: "cucumber-java", version: "1.2.4", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") +libraryLicense(name: "data-binding", libraryName: "data-binding.jar", license: "Apache 2.0", url: "http://source.android.com/") libraryLicense(name: "Diffutils", libraryName: "Diffutils", version: "1.2.1", license: "The Apache Software License, Version 2.0", url: "https://code.google.com/archive/p/java-diff-utils/", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0") libraryLicense(name: "docutils", attachedTo: "python-helpers", version: "0.8", license: "BSD", url: "http://docutils.sourceforge.net/") libraryLicense(name: "DTDParser", version: "1.13", license: "LGPL", url: "http://sourceforge.net/projects/dtdparser/", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1") @@ -233,6 +234,7 @@ libraryLicense(name: "JGit", libraryName: "jgit", version: "4.0", license: "Ecli libraryLicense(name: "JGoodies Common", libraryName: "jgoodies-common", version: "1.2.1", license: "BSD ", url: "http://www.jgoodies.com/freeware/libraries/looks/", licenseUrl: "https://opensource.org/licenses/bsd-license.html") libraryLicense(name: "JGoodies Forms", libraryName: "jgoodies-forms", version: "1.1-preview 2006-05-04 11:55:37", license: "BSD ", url: "http://www.jgoodies.com/freeware/libraries/forms/", licenseUrl: "https://opensource.org/licenses/bsd-license.html") libraryLicense(name: "JGoodies Looks", libraryName: "jgoodies-looks", version: "2.4.2", license: "BSD ", url: "http://www.jgoodies.com/freeware/libraries/looks/", licenseUrl: "https://opensource.org/licenses/bsd-license.html") +libraryLicense(name: "jgraphx", libraryName: "jgraphx-3.4.0.1", version: "3.4.0.1", license: "BSD", url: "https://github.com/jgraph/jgraphx") libraryLicense(name: "JNA", libraryName: "jna", version: "4.1.0", license: "LGPL 2.1", url: "https://github.com/java-native-access/jna", licenseUrl: "http://www.opensource.org/licenses/lgpl-2.1.php") libraryLicense(name: "jsch-agent-proxy for svnkit trilead", libraryName: "jsch.agentproxy.svnkit-trilead-ssh2.jar", version: "0.0.7", license: "BSD", url: "https://github.com/ymnk/jsch-agent-proxy", licenseUrl: "https://github.com/ymnk/jsch-agent-proxy/blob/master/LICENSE.txt") libraryLicense(name: "jsch-agent-proxy", libraryName: "jsch-agent-proxy", version: "0.0.7", license: "BSD", url: "https://github.com/ymnk/jsch-agent-proxy", licenseUrl: "https://github.com/ymnk/jsch-agent-proxy/blob/master/LICENSE.txt") diff --git a/community-tests/src/tests/testGroups.properties b/community-tests/src/tests/testGroups.properties index 943213f21675..3fe83738e2fe 100644 --- a/community-tests/src/tests/testGroups.properties +++ b/community-tests/src/tests/testGroups.properties @@ -33,6 +33,11 @@ org.jetbrains.android.sdk.AndroidSdkUtilsTest org.jetbrains.android.sdk.AndroidSdkDataTest com.android.tools.idea.gradle.AndroidGradleModelTest com.android.tools.idea.gradle.InternalAndroidModelViewTest +com.android.tools.idea.gradle.invoker.GradleInvokerWithArtifactTest +com.android.tools.idea.gradle.structure.configurables.editor.dependencies.AndroidSdkRepositorySearchTest +com.android.tools.idea.gradle.testing.* +com.android.tools.idea.gradle.util.UpdateGradlePluginVersionTest +com.android.tools.idea.javadoc.AndroidJavaDocWithGradleTest com.android.tools.idea.gradle.project.GradleProjectImporterTest com.android.tools.idea.gradle.compiler.AndroidGradleBuildProcessParametersProviderTest com.android.tools.idea.sdk.JdksTest @@ -55,6 +60,7 @@ com.android.tools.idea.wizard.NewTemplateObjectWizardTest org.jetbrains.android.run.AndroidRunConfigurationTest com.android.tools.idea.run.GradleApkProviderTest com.android.tools.idea.run.LaunchUtilsTest +com.android.tools.idea.run.AndroidTestConfigurationProducerTest org.jetbrains.android.facet.IdeaSourceProviderTest com.android.tools.idea.gradle.service.resolve.AndroidResolveTest com.android.tools.idea.gradle.service.resolve.AndroidDslContributorTest @@ -66,6 +72,7 @@ com.android.tools.idea.navigator.packageview.AndroidPackageViewTest com.android.tools.idea.gradle.project.AndroidGradleProjectDataTest com.android.tools.idea.exportSignedPackage.ExportSignedPackageTest com.android.tools.idea.avdmanager.AvdManagerConnectionTest +com.android.tools.idea.avdmanager.AvdDisplayListTest com.android.tools.idea.ddms.adb.AdbServiceTest com.android.tools.idea.navigator.AndroidProjectViewTest com.android.navigation.NavigationEditorTest @@ -78,6 +85,7 @@ com.android.tools.idea.wizard.ConfigureAndroidModuleStepDynamicTest com.android.tools.idea.editors.AndroidGeneratedSourcesFilterTest com.android.tools.idea.editors.theme.ThemeEditorStyleTest com.android.tools.idea.editors.theme.ThemeEditorUtilsTest +com.android.tools.idea.editors.theme.ConfiguredThemeEditorStyleTest com.android.tools.idea.editors.theme.qualifiers.QualifierUtilsTest com.android.tools.idea.gradle.IdeaAndroidProjectTest com.android.tools.idea.gradle.project.AndroidGradleProjectImportingTest @@ -116,6 +124,8 @@ com.android.tools.idea.editors.strings.StringResourceDataTest com.android.tools.idea.rendering.ClassConverterTest com.android.tools.idea.gradle.service.notification.errors.UnknownHostErrorHandlerTest com.android.tools.idea.wizard.AsyncValidatorTest +org.jetbrains.jps.android.AndroidBuilderTest +com.android.tools.idea.gradle.service.notification.hyperlink.CustomNotificationListenerTest [GRADLE_INTEGRATION_TESTS] org.jetbrains.plugins.gradle.importing.* @@ -124,4 +134,6 @@ org.jetbrains.plugins.gradle.tooling.builder.* [MAVEN_INTEGRATION_TESTS] org.jetbrains.idea.maven.importing.* +org.jetbrains.idea.maven.project.importing.* org.jetbrains.idea.maven.compiler.* +org.jetbrains.idea.maven.dom.* diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java index ace1ce1e15d8..4a879da56235 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java @@ -632,7 +632,9 @@ public class DebuggerSession implements AbstractDebuggerSession { final DebuggerContextImpl debuggerContext = DebuggerContextImpl.createDebuggerContext(DebuggerSession.this, suspendContext, currentThread, null); - debuggerContext.setPositionCache(position); + if (suspendContext.getThread() == currentThread) { + debuggerContext.setPositionCache(position); + } DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() { @Override diff --git a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java index e1374f446c7e..21131e5882e9 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java +++ b/java/idea-ui/src/com/intellij/platform/templates/SaveProjectAsTemplateAction.java @@ -25,6 +25,7 @@ import com.intellij.ide.util.projectWizard.ProjectTemplateParameterFactory; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; @@ -122,16 +123,8 @@ public class SaveProjectAsTemplateAction extends AnAction { final Map parameters = computeParameters(project, replaceParameters); indicator.setText("Saving project..."); - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - project.save(); - } - }); - } - }); + ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(project::save), + indicator.getModalityState()); indicator.setText("Processing project files..."); ZipOutputStream stream = null; try { @@ -139,10 +132,10 @@ public class SaveProjectAsTemplateAction extends AnAction { stream = new ZipOutputStream(new FileOutputStream(zipFile)); final VirtualFile dir = getDirectoryToSave(project, moduleToSave); - writeFile(LocalArchivedTemplate.DESCRIPTION_PATH, description, project, dir, stream, true); + writeFile(LocalArchivedTemplate.DESCRIPTION_PATH, description, project, dir, stream, true, indicator); if (replaceParameters) { String text = getInputFieldsText(parameters); - writeFile(LocalArchivedTemplate.TEMPLATE_DESCRIPTOR, text, project, dir, stream, false); + writeFile(LocalArchivedTemplate.TEMPLATE_DESCRIPTOR, text, project, dir, stream, false, indicator); } FileIndex index = moduleToSave == null @@ -205,7 +198,7 @@ public class SaveProjectAsTemplateAction extends AnAction { private static void writeFile(String path, final String text, - Project project, VirtualFile dir, ZipOutputStream stream, boolean overwrite) throws IOException { + Project project, VirtualFile dir, ZipOutputStream stream, boolean overwrite, ProgressIndicator indicator) throws IOException { final VirtualFile descriptionFile = getDescriptionFile(project, path); if (descriptionFile == null) { stream.putNextEntry(new ZipEntry(dir.getName() + "/" + path)); @@ -213,21 +206,14 @@ public class SaveProjectAsTemplateAction extends AnAction { stream.closeEntry(); } else if (overwrite) { - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - try { - VfsUtil.saveText(descriptionFile, text); - } - catch (IOException e) { - LOG.error(e); - } - } - }); + ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(() -> { + try { + VfsUtil.saveText(descriptionFile, text); } - }); + catch (IOException e) { + LOG.error(e); + } + }), indicator.getModalityState()); } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index 18b0516e2960..673598bde8fc 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -1272,7 +1272,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh myHolder.add(info); } else { final TextAttributesScheme colorsScheme = myHolder.getColorsScheme(); - if (method instanceof PsiMethod) { + if (method instanceof PsiMethod && !expression.isConstructor()) { final PsiElement methodNameElement = expression.getReferenceNameElement(); myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod)method, methodNameElement, false, colorsScheme)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java index 6b5103040a9d..30e9efeaa5b4 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateParameterFromUsageFix.java @@ -97,19 +97,19 @@ public class CreateParameterFromUsageFix extends CreateVarFromUsageFix { } final Application application = ApplicationManager.getApplication(); - if (application.isUnitTestMode()) { - ParameterInfoImpl[] array = parameterInfos.toArray(new ParameterInfoImpl[parameterInfos.size()]); - String modifier = PsiUtil.getAccessModifier(PsiUtil.getAccessLevel(method.getModifierList())); - ChangeSignatureProcessor processor = - new ChangeSignatureProcessor(project, method, false, modifier, method.getName(), method.getReturnType(), array); - processor.run(); - } - else { - final PsiMethod finalMethod = method; - application.invokeLater(new Runnable() { - @Override - public void run() { - if (project.isDisposed()) return; + final PsiMethod finalMethod = method; + application.invokeLater(new Runnable() { + @Override + public void run() { + if (project.isDisposed()) return; + if (application.isUnitTestMode()) { + ParameterInfoImpl[] array = parameterInfos.toArray(new ParameterInfoImpl[parameterInfos.size()]); + String modifier = PsiUtil.getAccessModifier(PsiUtil.getAccessLevel(finalMethod.getModifierList())); + ChangeSignatureProcessor processor = + new ChangeSignatureProcessor(project, finalMethod, false, modifier, finalMethod.getName(), finalMethod.getReturnType(), array); + processor.run(); + } + else { try { JavaChangeSignatureDialog dialog = JavaChangeSignatureDialog.createAndPreselectNew(project, finalMethod, parameterInfos, true, myReferenceExpression); @@ -141,8 +141,8 @@ public class CreateParameterFromUsageFix extends CreateVarFromUsageFix { throw new RuntimeException(e); } } - }); - } + } + }); } @Override diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java index 45fd55ff4ac0..afc0bbb0df36 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java @@ -1140,7 +1140,8 @@ public class ExtractMethodProcessor implements MatchProvider { } } PsiDeclarationStatement statement = myElementFactory.createVariableDeclarationStatement(name, type, myMethodCall); - statement = (PsiDeclarationStatement)addToMethodCallLocation(statement); + statement = + (PsiDeclarationStatement)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(addToMethodCallLocation(statement)); PsiVariable var = (PsiVariable)statement.getDeclaredElements()[0]; myMethodCall = (PsiMethodCallExpression)var.getInitializer(); if (myOutputVariable != null) { @@ -1228,8 +1229,12 @@ public class ExtractMethodProcessor implements MatchProvider { return result; } - public PsiElement processMatch(Match match) throws IncorrectOperationException { + @Override + public void prepareSignature(Match match) { MatchUtil.changeSignature(match, myExtractedMethod); + } + + public PsiElement processMatch(Match match) throws IncorrectOperationException { if (RefactoringUtil.isInStaticContext(match.getMatchStart(), myExtractedMethod.getContainingClass())) { PsiUtil.setModifierProperty(myExtractedMethod, PsiModifier.STATIC, true); } diff --git a/java/java-impl/src/com/intellij/refactoring/memberPushDown/JavaPushDownDelegate.java b/java/java-impl/src/com/intellij/refactoring/memberPushDown/JavaPushDownDelegate.java index c344f6df60a1..f103485b083e 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPushDown/JavaPushDownDelegate.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPushDown/JavaPushDownDelegate.java @@ -217,31 +217,32 @@ public class JavaPushDownDelegate extends PushDownDelegate replacement = new LinkedHashMap(); for (PsiTypeParameter parameter : parametersIterable) { - PsiType substitutedType = substitutor.substitute(parameter); - if (substitutedType == null) { - substitutedType = TypeConversionUtil.erasure(factory.createType(parameter)); - } + final PsiType substitutedType = substitutor.substitute(parameter); + final PsiType erasedType = substitutedType == null ? TypeConversionUtil.erasure(factory.createType(parameter)) + : substitutedType; for (PsiReference reference : ReferencesSearch.search(parameter, new LocalSearchScope(member))) { final PsiElement element = reference.getElement(); final PsiElement parent = element.getParent(); if (parent instanceof PsiTypeElement) { - replacement.put(parent, factory.createTypeElement(substitutedType)); - } else if (element instanceof PsiJavaCodeReferenceElement && substitutedType instanceof PsiClassType) { - replacement.put(element, factory.createReferenceElementByType((PsiClassType)substitutedType)); + if (substitutedType == null) { + //extends/implements list of type parameters: S extends List + final PsiJavaCodeReferenceElement codeReferenceElement = PsiTreeUtil.getTopmostParentOfType(parent, PsiJavaCodeReferenceElement.class); + if (codeReferenceElement != null) { + final PsiJavaCodeReferenceElement copy = (PsiJavaCodeReferenceElement)codeReferenceElement.copy(); + final PsiReferenceParameterList parameterList = copy.getParameterList(); + if (parameterList != null) { + parameterList.delete(); + } + replacement.put(codeReferenceElement, copy); + } + else { + //nested types List listOfLists; + PsiTypeElement topPsiTypeElement = PsiTreeUtil.getTopmostParentOfType(parent, PsiTypeElement.class); + if (topPsiTypeElement == null) { + topPsiTypeElement = (PsiTypeElement)parent; + } + replacement.put(topPsiTypeElement, factory.createTypeElement(TypeConversionUtil.erasure(topPsiTypeElement.getType()))); + } + } + else { + replacement.put(parent, factory.createTypeElement(substitutedType)); + } + } + else if (element instanceof PsiJavaCodeReferenceElement && erasedType instanceof PsiClassType) { + replacement.put(element, factory.createReferenceElementByType((PsiClassType)erasedType)); } } } diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ConstantMatchProvider.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/ConstantMatchProvider.java index 7c66aaebcf03..21f8cf5ba50a 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/ConstantMatchProvider.java +++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/ConstantMatchProvider.java @@ -40,6 +40,9 @@ class ConstantMatchProvider implements MatchProvider { myMatches = matches; } + @Override + public void prepareSignature(Match match) {} + @Override public PsiElement processMatch(Match match) throws IncorrectOperationException { final PsiClass containingClass = myField.getContainingClass(); diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java index 3b08eef16b75..54658db14ed1 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java +++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java @@ -140,6 +140,9 @@ public class DuplicatesImpl { HighlightManager.getInstance(project).removeSegmentHighlighter(editor, highlighters.get(0)); } + // call change signature when needed + provider.prepareSignature(match); + new WriteCommandAction(project, MethodDuplicatesHandler.REFACTORING_NAME, MethodDuplicatesHandler.REFACTORING_NAME) { @Override protected void run(@NotNull Result result) throws Throwable { diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MatchProvider.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MatchProvider.java index 8c067a215ef3..7f8b6fe1aa0f 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MatchProvider.java +++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MatchProvider.java @@ -17,7 +17,6 @@ package com.intellij.refactoring.util.duplicates; import com.intellij.psi.PsiElement; import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -26,6 +25,12 @@ import java.util.List; * @author dsl */ public interface MatchProvider { + /** + * Call change signature here to avoid refactoring under write action + * @param match match which requires signature to be changed e.g. due to stronger expected type, etc + */ + void prepareSignature(Match match); + PsiElement processMatch(Match match) throws IncorrectOperationException; List getDuplicates(); diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java index 2da15dbc7450..2b1cd58890f7 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java +++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java @@ -47,8 +47,12 @@ class MethodDuplicatesMatchProvider implements MatchProvider { } @Override - public PsiElement processMatch(Match match) throws IncorrectOperationException { + public void prepareSignature(Match match) { MatchUtil.changeSignature(match, myMethod); + } + + @Override + public PsiElement processMatch(Match match) throws IncorrectOperationException { final PsiClass containingClass = myMethod.getContainingClass(); if (isEssentialStaticContextAbsent(match)) { PsiUtil.setModifierProperty(myMethod, PsiModifier.STATIC, true); diff --git a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java index f0a0e0f6968d..e44c963c76d4 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java +++ b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureBackedByPsiMethod.java @@ -84,7 +84,7 @@ public class MethodSignatureBackedByPsiMethod extends MethodSignatureBase { PsiParameter parameter = parameters[i]; PsiType type = parameter.getType(); parameterTypes[i] = isRaw ? TypeConversionUtil.erasure(substitutor.substitute(type)) : type; - if (!parameterTypes[i].isValid()) { + if (parameterTypes[i] != null && !parameterTypes[i].isValid()) { PsiUtil.ensureValidType(parameterTypes[i], "Method " + method + " of " + method.getClass() + "; param " + parameter + " of " + parameter.getClass()); } } diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java index 8ccab9517a7b..99e2a24aa5fc 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java @@ -33,10 +33,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; +import java.util.*; import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; @@ -839,7 +836,7 @@ public class TypeConversionUtil { return false; // must be TypeCook's PsiTypeVariable } if (left instanceof PsiPrimitiveType) { - return isUnboxable((PsiPrimitiveType)left, (PsiClassType)right); + return isUnboxable((PsiPrimitiveType)left, (PsiClassType)right, new HashSet()); } final PsiClassType.ClassResolveResult leftResult = PsiUtil.resolveGenericsClassInType(left); final PsiClassType.ClassResolveResult rightResult = PsiUtil.resolveGenericsClassInType(right); @@ -880,7 +877,20 @@ public class TypeConversionUtil { return isAssignable(wildcardType.getExtendsBound(), right); } - private static boolean isUnboxable(@NotNull PsiPrimitiveType left, @NotNull PsiClassType right) { + private static boolean isUnboxable(@NotNull PsiPrimitiveType left, @NotNull PsiClassType right, @NotNull Set types) { + if (!right.getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) return false; + final PsiClass psiClass = right.resolve(); + if (psiClass == null) return false; + + if (psiClass instanceof PsiTypeParameter) { + for (PsiClassType bound : psiClass.getExtendsListTypes()) { + if (types.add(bound) && isUnboxable(left, bound, types)) { + return true; + } + } + return false; + } + final PsiPrimitiveType rightUnboxedType = PsiPrimitiveType.getUnboxedType(right); return rightUnboxedType != null && isAssignable(left, rightUnboxedType); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java index fba9855a7229..83ca4fc4b781 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java @@ -38,6 +38,7 @@ public class JavaResolveUtil { PsiElement prev = element; PsiElement scope = element.getContext(); while (scope != null) { + // skip the class if coming from its extends/implements list: those references only rely on the outer context for resolve if (scope instanceof PsiClass && (prev instanceof PsiMember || prev instanceof PsiDocComment)) { return (PsiClass)scope; } @@ -115,6 +116,7 @@ public class JavaResolveUtil { if (memberClass == null) { return false; } + // if resolving supertype reference, skip its containing class with getContextClass PsiClass contextClass = member instanceof PsiClass ? getContextClass(place) : PsiTreeUtil.getContextOfType(place, PsiClass.class, false); while (contextClass != null) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/UnboxingFromTypeParameter.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/UnboxingFromTypeParameter.java new file mode 100644 index 000000000000..b757661e275d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/UnboxingFromTypeParameter.java @@ -0,0 +1,7 @@ +class Test { + void method1(T param, S param1, K param2) { + long l = param; + long l1 = param1; + long l2 = param2; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractMethod/ShortenClassRefsInNewReturnType.java b/java/java-tests/testData/refactoring/extractMethod/ShortenClassRefsInNewReturnType.java new file mode 100644 index 000000000000..80fc8ee5008d --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethod/ShortenClassRefsInNewReturnType.java @@ -0,0 +1,8 @@ +import java.util.ArrayList; + +class Test { + Object foo() { + Object list = new ArrayList(); + return list; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractMethod/ShortenClassRefsInNewReturnType_after.java b/java/java-tests/testData/refactoring/extractMethod/ShortenClassRefsInNewReturnType_after.java new file mode 100644 index 000000000000..9dd120ab2db4 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractMethod/ShortenClassRefsInNewReturnType_after.java @@ -0,0 +1,16 @@ +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collection; + +class Test { + Object foo() { + Object list = newMethod(); + return list; + } + + @NotNull + private Collection newMethod() { + return new ArrayList(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/AlreadyContainsMethodWithTheSignatureForGenericsSuperclass.java b/java/java-tests/testData/refactoring/pushDown/AlreadyContainsMethodWithTheSignatureForGenericsSuperclass.java new file mode 100644 index 000000000000..3a0cb001fc6d --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/AlreadyContainsMethodWithTheSignatureForGenericsSuperclass.java @@ -0,0 +1,11 @@ +class Parent { + public void foo(T p) { + System.out.println("a"); + } +} + +class Child extends Parent { + public void foo(Object p) { + System.out.println("b"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/AlreadyContainsMethodWithTheSignatureForGenericsSuperclass_after.java b/java/java-tests/testData/refactoring/pushDown/AlreadyContainsMethodWithTheSignatureForGenericsSuperclass_after.java new file mode 100644 index 000000000000..4ea9146dd967 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/AlreadyContainsMethodWithTheSignatureForGenericsSuperclass_after.java @@ -0,0 +1,8 @@ +class Parent { +} + +class Child extends Parent { + public void foo(Object p) { + System.out.println("b"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClass.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClass.java new file mode 100644 index 000000000000..b10bb9893838 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClass.java @@ -0,0 +1,7 @@ +interface A { + default void foo() { + System.out.println(); + } +} + +class B implements A {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClassKeepAbstract.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClassKeepAbstract.java new file mode 100644 index 000000000000..b14b4aeda3fc --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClassKeepAbstract.java @@ -0,0 +1,7 @@ +interface Test { + default void foo() { + System.out.println(); + } +} + +class B implements Test {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClassKeepAbstract_after.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClassKeepAbstract_after.java new file mode 100644 index 000000000000..b37b46e898cb --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClassKeepAbstract_after.java @@ -0,0 +1,10 @@ +interface Test { + void foo(); +} + +class B implements Test { + @Override + public void foo() { + System.out.println(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClass_after.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClass_after.java new file mode 100644 index 000000000000..bfe226a1029f --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToClass_after.java @@ -0,0 +1,8 @@ +interface A { +} + +class B implements A { + public void foo() { + System.out.println(); +} +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterface.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterface.java new file mode 100644 index 000000000000..662e2ed39b04 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterface.java @@ -0,0 +1,7 @@ +interface A { + default void foo() { + System.out.println(""); + } +} + +interface B extends A {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterfaceKeepAbstract.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterfaceKeepAbstract.java new file mode 100644 index 000000000000..9b970560fee4 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterfaceKeepAbstract.java @@ -0,0 +1,7 @@ +interface Test { + default void foo() { + System.out.println(); + } +} + +interface A extends Test {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterfaceKeepAbstract_after.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterfaceKeepAbstract_after.java new file mode 100644 index 000000000000..f91d7573bece --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterfaceKeepAbstract_after.java @@ -0,0 +1,10 @@ +interface Test { + void foo(); +} + +interface A extends Test { + @Override + default void foo() { + System.out.println(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterface_after.java b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterface_after.java new file mode 100644 index 000000000000..f283994face2 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/DefaultMethodToInterface_after.java @@ -0,0 +1,8 @@ +interface A { +} + +interface B extends A { + default void foo() { + System.out.println(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/ErasureIfInheritsWithRawSubstitution.java b/java/java-tests/testData/refactoring/pushDown/ErasureIfInheritsWithRawSubstitution.java new file mode 100644 index 000000000000..d392c9a3faf9 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/ErasureIfInheritsWithRawSubstitution.java @@ -0,0 +1,9 @@ +import java.util.*; + +class A { + >> foo(List l1, List l2, List l3, S s, K k, T t) { + Collections.emptyList(); + } +} + +class B extends A {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/ErasureIfInheritsWithRawSubstitution_after.java b/java/java-tests/testData/refactoring/pushDown/ErasureIfInheritsWithRawSubstitution_after.java new file mode 100644 index 000000000000..72bf6001c127 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/ErasureIfInheritsWithRawSubstitution_after.java @@ -0,0 +1,10 @@ +import java.util.*; + +class A { +} + +class B extends A { + B(List l1, List l2, List l3, S s, K k, Object t) { + Collections.emptyList(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/FunctionalInterface_after.java b/java/java-tests/testData/refactoring/pushDown/FunctionalInterface_after.java index e83436078bb7..40fe6ec59439 100644 --- a/java/java-tests/testData/refactoring/pushDown/FunctionalInterface_after.java +++ b/java/java-tests/testData/refactoring/pushDown/FunctionalInterface_after.java @@ -5,6 +5,6 @@ interface Base { } } -class Child implements Base { +abstract class Child implements Base { public abstract void bar(); } diff --git a/java/java-tests/testData/refactoring/pushDown/InsertOverrideWhenKeepAbstract_after.java b/java/java-tests/testData/refactoring/pushDown/InsertOverrideWhenKeepAbstract_after.java index 592f48687ff0..115dc0759543 100644 --- a/java/java-tests/testData/refactoring/pushDown/InsertOverrideWhenKeepAbstract_after.java +++ b/java/java-tests/testData/refactoring/pushDown/InsertOverrideWhenKeepAbstract_after.java @@ -2,7 +2,7 @@ interface Test { void bar(); } -class Child implements Test { +abstract class Child implements Test { @Override public abstract void bar(); } diff --git a/java/java-tests/testData/refactoring/pushDown/InterfaceMethodToClass.java b/java/java-tests/testData/refactoring/pushDown/InterfaceMethodToClass.java new file mode 100644 index 000000000000..276c96ba9e72 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/InterfaceMethodToClass.java @@ -0,0 +1,4 @@ +interface A { + void foo(); +} +class B implements A {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/InterfaceMethodToClass_after.java b/java/java-tests/testData/refactoring/pushDown/InterfaceMethodToClass_after.java new file mode 100644 index 000000000000..87798bb11e8f --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/InterfaceMethodToClass_after.java @@ -0,0 +1,5 @@ +interface A { +} +abstract class B implements A { + public abstract void foo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToClass.java b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToClass.java new file mode 100644 index 000000000000..23480f8edb8a --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToClass.java @@ -0,0 +1,7 @@ +interface A { + static void foo() { + System.out.println(); + } +} + +class B implements A {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToClass_after.java b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToClass_after.java new file mode 100644 index 000000000000..371e551db7d2 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToClass_after.java @@ -0,0 +1,8 @@ +interface A { +} + +class B implements A { + public static void foo() { + System.out.println(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToInterface.java b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToInterface.java new file mode 100644 index 000000000000..efe3b5869dad --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToInterface.java @@ -0,0 +1,7 @@ +interface A { + static void foo() { + System.out.println(); + } +} + +interface B extends A {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToInterface_after.java b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToInterface_after.java new file mode 100644 index 000000000000..76d30b143e62 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/InterfaceStaticMethodToInterface_after.java @@ -0,0 +1,8 @@ +interface A { +} + +interface B extends A { + static void foo() { + System.out.println(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractClass.java b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractClass.java new file mode 100644 index 000000000000..32325db34872 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractClass.java @@ -0,0 +1,8 @@ +abstract class Test { + /** + * foo's javadoc + */ + abstract void foo(); +} + +abstract class B extends Test {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractClass_after.java b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractClass_after.java new file mode 100644 index 000000000000..55cce0d3edc6 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractClass_after.java @@ -0,0 +1,11 @@ +abstract class Test { + /** + * foo's javadoc + */ + abstract void foo(); +} + +abstract class B extends Test { + @Override + abstract void foo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractInterface.java b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractInterface.java new file mode 100644 index 000000000000..28c4029f9d93 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractInterface.java @@ -0,0 +1,8 @@ +interface Test { + /** + * foo's javadoc + */ + void foo(); +} + +interface B extends Test {} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractInterface_after.java b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractInterface_after.java new file mode 100644 index 000000000000..51c58e13503b --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/JavadocWhenKeepAsAbstractInterface_after.java @@ -0,0 +1,11 @@ +interface Test { + /** + * foo's javadoc + */ + void foo(); +} + +interface B extends Test { + @Override + void foo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/PreserveOverrideAnnotationAfterConflict.java b/java/java-tests/testData/refactoring/pushDown/PreserveOverrideAnnotationAfterConflict.java new file mode 100644 index 000000000000..c73853adc807 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/PreserveOverrideAnnotationAfterConflict.java @@ -0,0 +1,18 @@ +interface Test { + /** + * some javadoc + */ + default void foo() { + System.out.println("I"); + } +} + +class C implements Test { + /** + * another javadoc + */ + @Override + public void foo() { + System.out.println("C"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/pushDown/PreserveOverrideAnnotationAfterConflict_after.java b/java/java-tests/testData/refactoring/pushDown/PreserveOverrideAnnotationAfterConflict_after.java new file mode 100644 index 000000000000..bb0fcb1116e4 --- /dev/null +++ b/java/java-tests/testData/refactoring/pushDown/PreserveOverrideAnnotationAfterConflict_after.java @@ -0,0 +1,16 @@ +interface Test { + /** + * some javadoc + */ + void foo(); +} + +class C implements Test { + /** + * another javadoc + */ + @Override + public void foo() { + System.out.println("C"); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 90a76764c9c0..2b10c698a0c4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -575,6 +575,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } + public void testUnboxingFromTypeParameter() throws Exception { + doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); + } + public void testLeastUpperBoundWithRecursiveTypes() throws Exception { final PsiManager manager = getPsiManager(); final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); diff --git a/java/java-tests/testSrc/com/intellij/lang/spi/SPICompletionTest.java b/java/java-tests/testSrc/com/intellij/lang/spi/SPICompletionTest.java index 3ad0ea4abee1..ab2bc385ab8a 100644 --- a/java/java-tests/testSrc/com/intellij/lang/spi/SPICompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/spi/SPICompletionTest.java @@ -15,8 +15,14 @@ */ package com.intellij.lang.spi; +import com.intellij.codeInsight.lookup.LookupManager; +import com.intellij.openapi.command.WriteCommandAction; +import com.intellij.openapi.util.ThrowableComputable; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import java.io.IOException; + /** * @author peter */ @@ -31,4 +37,19 @@ public class SPICompletionTest extends LightCodeInsightFixtureTestCase { myFixture.checkResult("com.foo.Implementation"); } + public void testCompletionAfterRenaming() throws IOException { + VirtualFile file = myFixture.addFileToProject("META-INF/services/aaa", "").getVirtualFile(); + myFixture.configureFromExistingVirtualFile(file); + assertEmpty(myFixture.completeBasic()); + LookupManager.getInstance(getProject()).hideActiveLookup(); + + WriteCommandAction.runWriteCommandAction(getProject(), (ThrowableComputable)() -> { + file.rename(this, "java.lang.Runnable"); + return null; + }); + + myFixture.completeBasic(); + myFixture.assertPreferredCompletionItems(0, "java.lang.Thread"); + } + } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java index 0b24abbce618..b5ee7c877183 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java @@ -165,7 +165,7 @@ public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase { public void testOffsetsAtCallSite() throws Exception { doTest("map.entrySet().stream().filter((a) -> (a.getKey()>0));", - "java.util.stream.Stream> result = new Test(map).invoke();", + "Stream> result = new Test(map).invoke();", "public class Test {\n" + " private Map map;\n" + "\n" + diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java index 35946793c3a8..eb8a1492e366 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodTest.java @@ -744,6 +744,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase { doTestReturnTypeChanged(PsiType.INT); } + public void testShortenClassRefsInNewReturnType() throws Exception { + doTestReturnTypeChanged(PsiType.getTypeByName(CommonClassNames.JAVA_UTIL_COLLECTION, getProject(), GlobalSearchScope.allScope(getProject()))); + } + public void testPassFieldAsParameterAndMakeStatic() throws Exception { doTestPassFieldsAsParams(); } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java b/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java index 92a85d51c9e0..84648a70edbc 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/PushDownTest.java @@ -64,11 +64,41 @@ public class PushDownTest extends LightRefactoringTestCase { public void testInterfaceConstants() { doTest();} public void testReferenceForMovedInnerClass() { doTest();} - + + public void testDefaultMethodToInterface() {doTest();} + public void testDefaultMethodToInterfaceKeepAbstract() {doTestImplements(true);} + public void testDefaultMethodToClass() {doTest();} + public void testDefaultMethodToClassKeepAbstract() { doTestImplements(true); } + + public void testInterfaceStaticMethodToInterface() { doTest(); } + public void testInterfaceStaticMethodToClass() { doTest(); } + + public void testInterfaceMethodToClass() { doTest();} + public void testInsertOverrideWhenKeepAbstract() throws Exception { doTestImplements(true); } + public void testErasureIfInheritsWithRawSubstitution() throws Exception { + doTest(); + } + + public void testAlreadyContainsMethodWithTheSignatureForGenericsSuperclass() throws Exception { + doTest(true); + } + + public void testJavadocWhenKeepAsAbstractInterface() throws Exception { + doTestImplements(true); + } + + public void testJavadocWhenKeepAsAbstractClass() throws Exception { + doTestImplements(true); + } + + public void testPreserveOverrideAnnotationAfterConflict() throws Exception { + doTestImplements(true, true); + } + private void doTest() { doTest(false); } @@ -109,7 +139,7 @@ public class PushDownTest extends LightRefactoringTestCase { new DocCommentPolicy(DocCommentPolicy.ASIS)) { @Override protected boolean showConflicts(@NotNull MultiMap conflicts, UsageInfo[] usages) { - if (failure ? conflicts.isEmpty() : !conflicts.isEmpty()) { + if (failure == conflicts.isEmpty()) { fail(failure ? "Conflict was not detected" : "False conflict was detected"); } return true; @@ -124,6 +154,10 @@ public class PushDownTest extends LightRefactoringTestCase { } private void doTestImplements(boolean toAbstract) { + doTestImplements(toAbstract, false); + } + + private void doTestImplements(boolean toAbstract, boolean failure) { configureByFile(BASE_PATH + getTestName(false) + ".java"); PsiClass currentClass = JavaPsiFacade.getInstance(getProject()).findClass("Test", GlobalSearchScope.projectScope(getProject())); @@ -140,6 +174,9 @@ public class PushDownTest extends LightRefactoringTestCase { new DocCommentPolicy(DocCommentPolicy.ASIS)) { @Override protected boolean showConflicts(@NotNull MultiMap conflicts, UsageInfo[] usages) { + if (failure == conflicts.isEmpty()) { + fail(failure ? "Conflict was not detected" : "False conflict was detected"); + } return true; } }.run(); diff --git a/lib/commons-compress-1.10.jar b/lib/commons-compress-1.10.jar new file mode 100644 index 000000000000..75ced20e1774 Binary files /dev/null and b/lib/commons-compress-1.10.jar differ diff --git a/lib/org.eclipse.wst.xml.xpath2.processor_1.1.0.jar b/lib/org.eclipse.wst.xml.xpath2.processor_1.1.0.jar new file mode 100644 index 000000000000..a688d18ea74d Binary files /dev/null and b/lib/org.eclipse.wst.xml.xpath2.processor_1.1.0.jar differ diff --git a/lib/src/commons-compress-1.10-src.zip b/lib/src/commons-compress-1.10-src.zip new file mode 100644 index 000000000000..f061a2bd5c6f Binary files /dev/null and b/lib/src/commons-compress-1.10-src.zip differ diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java index 96e28efe6421..76f001af5404 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java @@ -32,7 +32,6 @@ import com.intellij.diff.util.DiffUserDataKeysEx; import com.intellij.diff.util.DiffUserDataKeysEx.ScrollToPolicy; import com.intellij.diff.util.DiffUtil; import com.intellij.diff.util.LineRange; -import com.intellij.ide.DataManager; import com.intellij.ide.impl.DataManagerImpl; import com.intellij.internal.statistic.UsageTrigger; import com.intellij.internal.statistic.beans.ConvertUsagesUtil; @@ -88,12 +87,13 @@ public abstract class DiffRequestProcessor implements Disposable { @NotNull private final List myToolOrder; @NotNull private final OpenInEditorAction myOpenInEditorAction; - @Nullable private DefaultActionGroup myPopupActionGroup; + @NotNull private final DefaultActionGroup myToolbarGroup; + @NotNull private final DefaultActionGroup myPopupActionGroup; @NotNull private final JPanel myPanel; @NotNull private final MyPanel myMainPanel; @NotNull private final Wrapper myContentPanel; - @NotNull private final Wrapper myToolbarPanel; // TODO: allow to call 'updateToolbar' from Viewer ? + @NotNull private final ActionToolbar myToolbar; @NotNull private final Wrapper myToolbarStatusPanel; @NotNull private final MyProgressBar myProgressBar; @@ -120,19 +120,23 @@ public abstract class DiffRequestProcessor implements Disposable { myAvailableTools = DiffManagerEx.getInstance().getDiffTools(); myToolOrder = new ArrayList<>(getToolOrderFromSettings(myAvailableTools)); + myToolbarGroup = new DefaultActionGroup(); + myPopupActionGroup = new DefaultActionGroup(); + // UI myMainPanel = new MyPanel(); myContentPanel = new Wrapper(); - myToolbarPanel = new Wrapper(); - myToolbarPanel.setFocusable(true); myToolbarStatusPanel = new Wrapper(); myProgressBar = new MyProgressBar(); + myToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.DIFF_TOOLBAR, myToolbarGroup, true); + myToolbar.setTargetComponent(myMainPanel); + myPanel = JBUI.Panels.simplePanel(myMainPanel); JPanel statusPanel = JBUI.Panels.simplePanel(myToolbarStatusPanel).addToLeft(myProgressBar); - JPanel topPanel = JBUI.Panels.simplePanel(myToolbarPanel).addToRight(statusPanel); + JPanel topPanel = JBUI.Panels.simplePanel(myToolbar.getComponent()).addToRight(statusPanel); myMainPanel.add(topPanel, BorderLayout.NORTH); myMainPanel.add(myContentPanel, BorderLayout.CENTER); @@ -269,8 +273,10 @@ public abstract class DiffRequestProcessor implements Disposable { myState.destroy(); myToolbarStatusPanel.setContent(null); - myToolbarPanel.setContent(null); myContentPanel.setContent(null); + + myToolbarGroup.removeAll(); + myPopupActionGroup.removeAll(); ActionUtil.clearActions(myMainPanel); myActiveRequest.onAssigned(false); @@ -377,9 +383,12 @@ public abstract class DiffRequestProcessor implements Disposable { myState.destroy(); myToolbarStatusPanel.setContent(null); - myToolbarPanel.setContent(null); myContentPanel.setContent(null); + myToolbarGroup.removeAll(); + myPopupActionGroup.removeAll(); + ActionUtil.clearActions(myMainPanel); + myActiveRequest.onAssigned(false); myState = EmptyState.INSTANCE; @@ -387,67 +396,58 @@ public abstract class DiffRequestProcessor implements Disposable { }); } - @NotNull - protected DefaultActionGroup collectToolbarActions(@Nullable List viewerActions) { - DefaultActionGroup group = new DefaultActionGroup(); + protected void collectToolbarActions(@Nullable List viewerActions) { + myToolbarGroup.removeAll(); List navigationActions = new ArrayList<>(); navigationActions.addAll(getNavigationActions()); navigationActions.add(myOpenInEditorAction); navigationActions.add(new MyChangeDiffToolAction()); - DiffUtil.addActionBlock(group, + DiffUtil.addActionBlock(myToolbarGroup, navigationActions); - DiffUtil.addActionBlock(group, viewerActions); + DiffUtil.addActionBlock(myToolbarGroup, viewerActions); List requestContextActions = myActiveRequest.getUserData(DiffUserDataKeys.CONTEXT_ACTIONS); - DiffUtil.addActionBlock(group, requestContextActions); + DiffUtil.addActionBlock(myToolbarGroup, requestContextActions); List contextActions = myContext.getUserData(DiffUserDataKeys.CONTEXT_ACTIONS); - DiffUtil.addActionBlock(group, contextActions); + DiffUtil.addActionBlock(myToolbarGroup, contextActions); - DiffUtil.addActionBlock(group, + DiffUtil.addActionBlock(myToolbarGroup, new ShowInExternalToolAction(), new ShowOldDiffAction(), ActionManager.getInstance().getAction(IdeActions.ACTION_CONTEXT_HELP)); - - return group; } - @NotNull - protected DefaultActionGroup collectPopupActions(@Nullable List viewerActions) { - DefaultActionGroup group = new DefaultActionGroup(); + protected void collectPopupActions(@Nullable List viewerActions) { + myPopupActionGroup.removeAll(); List selectToolActions = new ArrayList<>(); for (DiffTool tool : getAvailableFittedTools()) { if (tool == myState.getActiveTool()) continue; selectToolActions.add(new DiffToolToggleAction(tool)); } - DiffUtil.addActionBlock(group, selectToolActions); + DiffUtil.addActionBlock(myPopupActionGroup, selectToolActions); - DiffUtil.addActionBlock(group, viewerActions); - - return group; + DiffUtil.addActionBlock(myPopupActionGroup, viewerActions); } protected void buildToolbar(@Nullable List viewerActions) { - ActionGroup group = collectToolbarActions(viewerActions); - ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.DIFF_TOOLBAR, group, true); + collectToolbarActions(viewerActions); - DataManager.registerDataProvider(toolbar.getComponent(), myMainPanel); - toolbar.setTargetComponent(toolbar.getComponent()); + myToolbar.updateActionsImmediately(); - myToolbarPanel.setContent(toolbar.getComponent()); - for (AnAction action : group.getChildren(null)) { + for (AnAction action : myToolbarGroup.getChildren(null)) { DiffUtil.registerAction(action, myMainPanel); } } protected void buildActionPopup(@Nullable List viewerActions) { + collectPopupActions(viewerActions); + ShowActionGroupPopupAction action = new ShowActionGroupPopupAction(); DiffUtil.registerAction(action, myMainPanel); - - myPopupActionGroup = collectPopupActions(viewerActions); } private void setTitle(@Nullable String title) { @@ -468,7 +468,7 @@ public abstract class DiffRequestProcessor implements Disposable { @Nullable public JComponent getPreferredFocusedComponent() { JComponent component = myState.getPreferredFocusedComponent(); - return component != null ? component : myToolbarPanel.getTargetComponent(); + return component != null ? component : myToolbar.getComponent(); } @Nullable @@ -586,12 +586,11 @@ public abstract class DiffRequestProcessor implements Disposable { @Override public void update(AnActionEvent e) { - e.getPresentation().setEnabled(myPopupActionGroup != null && myPopupActionGroup.getChildrenCount() > 0); + e.getPresentation().setEnabled(myPopupActionGroup.getChildrenCount() > 0); } @Override public void actionPerformed(AnActionEvent e) { - assert myPopupActionGroup != null; ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Diff Actions", myPopupActionGroup, e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); popup.showInCenterOf(myPanel); diff --git a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java index 70399b13db58..a33904386bab 100644 --- a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java @@ -411,6 +411,10 @@ public class TextMergeViewer implements MergeTool.MergeViewer { myInnerDiffWorker.onSettingsChanged(); myInitialRediffFinished = true; + + if (myViewer.getTextSettings().isAutoApplyNonConflictedChanges()) { + DiffUtil.performAction(new ApplyNonConflictsAction(), null); + } }; } @@ -1237,10 +1241,6 @@ public class TextMergeViewer implements MergeTool.MergeViewer { } public abstract class ApplyNonConflictsActionBase extends DumbAwareAction { - public ApplyNonConflictsActionBase(@Nullable String text, @Nullable String description, @Nullable Icon icon) { - super(text, description, icon); - } - @Override public void actionPerformed(AnActionEvent e) { executeMergeCommand("Apply Non Conflicted Changes", true, null, () -> { @@ -1257,7 +1257,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer { public class ApplyNonConflictsAction extends ApplyNonConflictsActionBase { public ApplyNonConflictsAction() { - super(DiffBundle.message("merge.dialog.apply.all.non.conflicting.changes.action.name"), null, AllIcons.Diff.ApplyNotConflicts); + ActionUtil.copyFrom(this, "Diff.ApplyNonConflicts"); } @Override @@ -1281,10 +1281,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer { @NotNull private final Side mySide; public ApplySideNonConflictsAction(@NotNull Side side) { - super(side.select(DiffBundle.message("merge.dialog.apply.left.non.conflicting.changes.action.name"), - DiffBundle.message("merge.dialog.apply.right.non.conflicting.changes.action.name")), - null, - side.select(AllIcons.Diff.ApplyNotConflictsLeft, AllIcons.Diff.ApplyNotConflictsRight)); + ActionUtil.copyFrom(this, side.select("Diff.ApplyNonConflicts.Left", "Diff.ApplyNonConflicts.Right")); mySide = side; } diff --git a/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsConfigurable.java b/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsConfigurable.java index 6563e8df3d88..6f49489401fc 100644 --- a/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsConfigurable.java +++ b/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsConfigurable.java @@ -41,7 +41,7 @@ public class DiffSettingsConfigurable implements SearchableConfigurable { @Nls @Override public String getDisplayName() { - return "Diff"; + return "Diff & Merge"; } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.form b/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.form index 19bc78619665..22cf5e191612 100644 --- a/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.form +++ b/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.form @@ -1,6 +1,6 @@
- + @@ -10,7 +10,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -43,6 +43,22 @@ + + + + + + + + + + + + + + + + diff --git a/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.java b/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.java index e466b7de9366..309e629c61a7 100644 --- a/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.java +++ b/platform/diff-impl/src/com/intellij/diff/settings/DiffSettingsPanel.java @@ -29,6 +29,7 @@ public class DiffSettingsPanel { private JPanel myPane; private ContextRangePanel myContextRangeComponent; private JCheckBox myGoToNextFileOnNextDifferenceCheckbox; + private JCheckBox myAutoApplyNonConflictedChangesCheckbox; @NotNull private TextDiffSettings myTextSettings = TextDiffSettings.getSettings(); @NotNull private DiffSettings myDiffSettings = DiffSettings.getSettings(); @@ -41,17 +42,20 @@ public class DiffSettingsPanel { public boolean isModified() { if (myContextRangeComponent.isModified()) return true; if (myGoToNextFileOnNextDifferenceCheckbox.isSelected() != myDiffSettings.isGoToNextFileOnNextDifference()) return true; + if (myAutoApplyNonConflictedChangesCheckbox.isSelected() != myTextSettings.isAutoApplyNonConflictedChanges()) return true; return false; } public void apply() { myContextRangeComponent.apply(); myDiffSettings.setGoToNextFileOnNextDifference(myGoToNextFileOnNextDifferenceCheckbox.isSelected()); + myTextSettings.setAutoApplyNonConflictedChanges(myAutoApplyNonConflictedChangesCheckbox.isSelected()); } public void reset() { myContextRangeComponent.reset(); myGoToNextFileOnNextDifferenceCheckbox.setSelected(myDiffSettings.isGoToNextFileOnNextDifference()); + myAutoApplyNonConflictedChangesCheckbox.setSelected(myTextSettings.isAutoApplyNonConflictedChanges()); } private void createUIComponents() { diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.java b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.java index 19c184ee9339..8d9944a2306c 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/TextDiffSettingsHolder.java @@ -42,6 +42,8 @@ public class TextDiffSettingsHolder implements PersistentStateComponent extends Listen @NotNull protected final ThreeSide mySide2; public ShowPartialDiffAction(@NotNull PartialDiffMode mode) { - String text; - Icon icon; + String id; switch (mode) { case LEFT_BASE: mySide1 = ThreeSide.LEFT; mySide2 = ThreeSide.BASE; - text = DiffBundle.message("merge.partial.diff.action.name.0.1"); - icon = AllIcons.Diff.LeftDiff; + id = "Diff.ComparePartial.Base.Left"; break; case BASE_RIGHT: mySide1 = ThreeSide.BASE; mySide2 = ThreeSide.RIGHT; - text = DiffBundle.message("merge.partial.diff.action.name.1.2"); - icon = AllIcons.Diff.RightDiff; + id = "Diff.ComparePartial.Base.Right"; break; case LEFT_RIGHT: mySide1 = ThreeSide.LEFT; mySide2 = ThreeSide.RIGHT; - text = DiffBundle.message("merge.partial.diff.action.name"); - icon = AllIcons.Diff.BranchDiff; + id = "Diff.ComparePartial.Left.Right"; break; default: throw new IllegalArgumentException(); } - getTemplatePresentation().setText(text); - getTemplatePresentation().setIcon(icon); + ActionUtil.copyFrom(this, id); } @Override diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index 4180e08119be..a17d91f3e92a 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -38,11 +38,9 @@ import com.intellij.diff.tools.util.base.HighlightPolicy; import com.intellij.diff.tools.util.base.IgnorePolicy; import com.intellij.diff.tools.util.base.TextDiffViewerUtil; import com.intellij.icons.AllIcons; +import com.intellij.ide.DataManager; import com.intellij.lang.Language; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.DataKey; -import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.impl.LaterInvocator; import com.intellij.openapi.command.CommandProcessor; @@ -359,6 +357,15 @@ public class DiffUtil { return result.toString(); } + public static void performAction(@NotNull AnAction action, @Nullable JComponent contextComponent) { + DataContext context = DataManager.getInstance().getDataContext(contextComponent); + AnActionEvent actionEvent = AnActionEvent.createFromAnAction(action, null, ActionPlaces.UNKNOWN, context); + action.update(actionEvent); + if (actionEvent.getPresentation().isEnabledAndVisible()) { + action.actionPerformed(actionEvent); + } + } + // // Titles // diff --git a/platform/diff-impl/tests/com/intellij/diff/merge/MergeTest.kt b/platform/diff-impl/tests/com/intellij/diff/merge/MergeTest.kt index 36e35fd8d862..47ea9c20fd62 100644 --- a/platform/diff-impl/tests/com/intellij/diff/merge/MergeTest.kt +++ b/platform/diff-impl/tests/com/intellij/diff/merge/MergeTest.kt @@ -18,7 +18,7 @@ package com.intellij.diff.merge import com.intellij.diff.merge.MergeTestBase.SidesState.* import com.intellij.diff.util.Side import com.intellij.diff.util.TextDiffType.* -import com.intellij.openapi.diff.DiffBundle +import com.intellij.idea.ActionsBundle class MergeTest : MergeTestBase() { fun testChangeTypes() { @@ -500,9 +500,9 @@ class MergeTest : MergeTestBase() { } fun testNonConflictsActions() { - val applyAllTitle = DiffBundle.message("merge.dialog.apply.all.non.conflicting.changes.action.name") - val applyLeftTitle = DiffBundle.message("merge.dialog.apply.left.non.conflicting.changes.action.name") - val applyRightTitle = DiffBundle.message("merge.dialog.apply.right.non.conflicting.changes.action.name") + val applyAllTitle = ActionsBundle.actionText("Diff.ApplyNonConflicts") + val applyLeftTitle = ActionsBundle.actionText("Diff.ApplyNonConflicts.Left") + val applyRightTitle = ActionsBundle.actionText("Diff.ApplyNonConflicts.Right") val text1 = "1 ======\n" + diff --git a/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/id/PlatformIdTableBuilding.java b/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/id/PlatformIdTableBuilding.java index ea5df187df58..05be97ecfb98 100644 --- a/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/id/PlatformIdTableBuilding.java +++ b/platform/editor-ui-ex/src/com/intellij/psi/impl/cache/impl/id/PlatformIdTableBuilding.java @@ -50,27 +50,18 @@ import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Author: dmitrylomov */ public abstract class PlatformIdTableBuilding { public static final Key EDITOR_HIGHLIGHTER = new Key("Editor"); - private static final Map> ourTodoIndexers = new HashMap>(); private static final TokenSet ABSTRACT_FILE_COMMENT_TOKENS = TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT, CustomHighlighterTokenType.MULTI_LINE_COMMENT); private PlatformIdTableBuilding() {} @Nullable public static DataIndexer getTodoIndexer(FileType fileType, final VirtualFile virtualFile) { - final DataIndexer indexer = ourTodoIndexers.get(fileType); - - if (indexer != null) { - return indexer; - } - final DataIndexer extIndexer; if (fileType instanceof SubstitutedFileType && !((SubstitutedFileType)fileType).isSameFileType()) { SubstitutedFileType sft = (SubstitutedFileType)fileType; @@ -110,13 +101,8 @@ public abstract class PlatformIdTableBuilding { return b; } - @Deprecated - public static void registerTodoIndexer(@NotNull FileType fileType, DataIndexer indexer) { - ourTodoIndexers.put(fileType, indexer); - } - public static boolean isTodoIndexerRegistered(@NotNull FileType fileType) { - return ourTodoIndexers.containsKey(fileType) || TodoIndexers.INSTANCE.forFileType(fileType) != null || fileType instanceof InternalFileType; + return TodoIndexers.INSTANCE.forFileType(fileType) != null || fileType instanceof InternalFileType; } private static class CompositeTodoIndexer extends VersionedTodoIndexer { diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/todo/TodoIndexers.java b/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/todo/TodoIndexers.java index a7e6c73ef104..a90b890532d1 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/todo/TodoIndexers.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/cache/impl/todo/TodoIndexers.java @@ -24,7 +24,7 @@ import com.intellij.util.indexing.FileContent; * @author yole */ public class TodoIndexers extends FileTypeExtension> { - public static TodoIndexers INSTANCE = new TodoIndexers(); + public static final TodoIndexers INSTANCE = new TodoIndexers(); private TodoIndexers() { super("com.intellij.todoIndexer"); diff --git a/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java b/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java index 9c5e7f9613ae..3ead8069b323 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/ModuleBasedConfiguration.java @@ -80,6 +80,10 @@ public abstract class ModuleBasedConfiguration configuration = (ModuleBasedConfiguration)getFactory().createTemplateConfiguration(getProject()); @@ -92,11 +96,11 @@ public abstract class ModuleBasedConfiguration>> FILE_COPY_KEY = Key.create("CompletionFileCopy"); - private static boolean isCopyUpToDate(Document document, @NotNull PsiFile file) { - if (!file.isValid()) { + private static boolean isCopyUpToDate(Document document, @NotNull PsiFile copyFile, @NotNull PsiFile originalFile) { + if (!copyFile.getClass().equals(originalFile.getClass()) || + !copyFile.isValid() || + !copyFile.getName().equals(originalFile.getName())) { return false; } // the psi file cache might have been cleared by some external activity, // in which case PSI-document sync may stop working - PsiFile current = PsiDocumentManager.getInstance(file.getProject()).getPsiFile(document); - return current != null && current.getViewProvider().getPsi(file.getLanguage()) == file; + PsiFile current = PsiDocumentManager.getInstance(copyFile.getProject()).getPsiFile(document); + return current != null && current.getViewProvider().getPsi(copyFile.getLanguage()) == copyFile; } private static PsiFile createFileCopy(PsiFile file) { @@ -740,7 +742,7 @@ public class CodeCompletionHandlerBase { virtualFile != null && virtualFile.isInLocalFileSystem(); if (mayCacheCopy) { final Pair cached = SoftReference.dereference(file.getUserData(FILE_COPY_KEY)); - if (cached != null && cached.first.getClass().equals(file.getClass()) && isCopyUpToDate(cached.second, cached.first)) { + if (cached != null && isCopyUpToDate(cached.second, cached.first, file)) { final PsiFile copy = cached.first; final Document document = cached.second; Document originalDocument = file.getViewProvider().getDocument(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java index ef10996d924c..312a03f7758e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupCellRenderer.java @@ -45,7 +45,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; import java.awt.*; import java.util.HashMap; import java.util.Map; @@ -97,12 +96,12 @@ public class LookupCellRenderer implements ListCellRenderer { myNameComponent.setMyBorder(null); myTailComponent = new MySimpleColoredComponent(); - myTailComponent.setIpad(new Insets(0, 0, 0, 0)); - myTailComponent.setBorder(new EmptyBorder(0, 0, 0, JBUI.scale(10))); + myTailComponent.setIpad(JBUI.emptyInsets()); + myTailComponent.setBorder(JBUI.Borders.emptyRight(10)); myTypeLabel = new MySimpleColoredComponent(); - myTypeLabel.setIpad(new Insets(0, 0, 0, 0)); - myTypeLabel.setBorder(new EmptyBorder(0, 0, 0, JBUI.scale(6))); + myTypeLabel.setIpad(JBUI.emptyInsets()); + myTypeLabel.setBorder(JBUI.Borders.emptyRight(6)); myPanel = new LookupPanel(); myPanel.add(myNameComponent, BorderLayout.WEST); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java index d40bb736a36c..99cb84c70097 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java @@ -21,6 +21,7 @@ import com.intellij.execution.configurations.ConfigurationPerRunnerSettings; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.configurations.RunnerSettings; import com.intellij.execution.runners.ProgramRunner; +import com.intellij.execution.ui.AdjustingTabSettingsEditor; import com.intellij.openapi.options.*; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Disposer; @@ -31,6 +32,8 @@ import com.intellij.ui.ScrollingUtil; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; +import com.intellij.util.ui.update.Activatable; +import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -318,7 +321,36 @@ public class ConfigurationSettingsEditor extends CompositeSettingsEditor { - fun create(data: T, start: Int, end: Int, context: VariableContext): XValueGroup -} \ No newline at end of file +/** + * Marker interface for {@link SettingsEditor} inheritors. + * Allows to ignore this {@link SettingsEditor#getComponent()} when showing {@link javax.swing.JTabbedPane}, if tab + * represented by this {@code SettingsEditor} instance is not selected. + * As a result, no empty space or scrollbars when smaller tab component selected. + * + * @see {@link com.intellij.openapi.options.SettingsEditorGroup} + */ +public interface AdjustingTabSettingsEditor { +} diff --git a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java index 73ab3bbcd0f7..5faf9a315137 100644 --- a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java +++ b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java @@ -28,6 +28,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.KeyboardShortcut; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.TransactionGuard; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.editor.Document; @@ -219,7 +220,7 @@ public class ReplaceInProjectManager { @Override public void findingUsagesFinished(final UsageView usageView) { if (context[0] != null && findManager.getFindInProjectModel().isPromptOnReplace()) { - SwingUtilities.invokeLater(new Runnable() { + TransactionGuard.submitTransaction(myProject, new Runnable() { @Override public void run() { replaceWithPrompt(context[0]); diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java index 3af57b7d2b4e..510b7471a6bc 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/BookmarkManager.java @@ -569,10 +569,20 @@ public class BookmarkManager extends AbstractProjectComponent implements Persist if (document.getLineCount() <= line) { continue; } - int start = document.getLineStartOffset(line); - int end = document.getLineEndOffset(line); - String lineContent = document.getText(new TextRange(start, end)); - if (entry.getKey().third.equals(lineContent) && findEditorBookmark(document, line) == null) { + + String lineContent = getLineContent(document, line); + + String bookmarkedText = entry.getKey().third; + //'move statement up' action kills line bookmark: fix for single line movement up/down + if (!bookmarkedText.equals(lineContent) + && line > 1 + && (bookmarkedText.equals(StringUtil.trimEnd(e.getNewFragment().toString(), "\n")) + || + bookmarkedText.equals(StringUtil.trimEnd(e.getOldFragment().toString(), "\n")))) { + line -= 2; + lineContent = getLineContent(document, line); + } + if (bookmarkedText.equals(lineContent) && findEditorBookmark(document, line) == null) { Bookmark restored = addTextBookmark(bookmark.getFile(), line, bookmark.getDescription()); if (bookmark.getMnemonic() != 0) { setMnemonic(restored, bookmark.getMnemonic()); @@ -581,6 +591,12 @@ public class BookmarkManager extends AbstractProjectComponent implements Persist } } } + + private String getLineContent(Document document, int line) { + int start = document.getLineStartOffset(line); + int end = document.getLineEndOffset(line); + return document.getText(new TextRange(start, end)); + } } } diff --git a/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java b/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java index 001b9414c2f5..705c80888091 100644 --- a/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java +++ b/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java @@ -473,6 +473,7 @@ public class GeneratedParserUtilBase { if (((frame.modifiers & _AND_) | (frame.modifiers & _NOT_)) != 0) { close_marker_impl_(frame, marker, null, false); + replace_variants_with_name_(state, frame, builder, result, pinned); state.predicateCount--; if ((frame.modifiers & _NOT_) != 0) state.predicateSign = !state.predicateSign; } @@ -492,11 +493,7 @@ public class GeneratedParserUtilBase { @Nullable Parser eatMore) { int initialPos = builder.rawTokenIndex(); boolean willFail = !result && !pinned; - if (willFail && initialPos == frame.position && state.lastExpectedVariantPos == frame.position && - frame.name != null && state.variants.size() - frame.variantCount > 1) { - state.clearVariants(true, frame.variantCount); - addVariantInner(state, initialPos, frame.name); - } + replace_variants_with_name_(state, frame, builder, result, pinned); int lastErrorPos = getLastVariantPos(state, initialPos); if (!state.suppressErrors && eatMore != null) { state.suppressErrors = true; @@ -652,6 +649,20 @@ public class GeneratedParserUtilBase { } } + private static void replace_variants_with_name_(ErrorState state, + Frame frame, + PsiBuilder builder, + boolean result, + boolean pinned) { + int initialPos = builder.rawTokenIndex(); + boolean willFail = !result && !pinned; + if (willFail && initialPos == frame.position && state.lastExpectedVariantPos == frame.position && + frame.name != null && state.variants.size() - frame.variantCount > 1) { + state.clearVariants(true, frame.variantCount); + addVariantInner(state, initialPos, frame.name); + } + } + public static boolean report_error_(PsiBuilder builder, boolean result) { if (!result) report_error_(builder, ErrorState.get(builder), false); return result; diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java index 8fd182909247..4e59e6b6d1e1 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -509,10 +509,12 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe indicesToDrop.remove(key.toString()); } - LOG.info("Dropping indices:" + StringUtil.join(indicesToDrop, ",")); + if (!indicesToDrop.isEmpty()) { + LOG.info("Dropping indices:" + StringUtil.join(indicesToDrop, ",")); - for (String s : indicesToDrop) { - FileUtil.delete(IndexInfrastructure.getIndexRootDir(StubIndexKey.createIndexKey(s))); + for (String s : indicesToDrop) { + FileUtil.delete(IndexInfrastructure.getIndexRootDir(StubIndexKey.createIndexKey(s))); + } } } diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 8c3250b6e3c2..b6ab68e58bf5 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -442,9 +442,11 @@ public class FileBasedIndexImpl extends FileBasedIndex { for (ID key : ids) { indicesToDrop.remove(key.toString()); } - LOG.info("Dropping indices:" + StringUtil.join(indicesToDrop, ",")); - for (String s : indicesToDrop) { - FileUtil.deleteWithRenaming(IndexInfrastructure.getIndexRootDir(ID.create(s))); + if (!indicesToDrop.isEmpty()) { + LOG.info("Dropping indices:" + StringUtil.join(indicesToDrop, ",")); + for (String s : indicesToDrop) { + FileUtil.deleteWithRenaming(IndexInfrastructure.getIndexRootDir(ID.create(s))); + } } try { diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java b/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java index 4a790facf2ee..601881fb4df1 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/ActionLink.java @@ -22,6 +22,7 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import javax.swing.*; import java.awt.*; @@ -119,4 +120,9 @@ public class ActionLink extends LinkLabel implements DataProvider { return null; } + + @TestOnly + public AnAction getAction() { + return myAction; + } } diff --git a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java index e19bc46abb53..c5e28131e8b4 100644 --- a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java +++ b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java @@ -40,6 +40,8 @@ import com.intellij.util.WaitForProgressToShow; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.proxy.CommonProxy; import com.intellij.util.proxy.JavaProxyProperty; +import com.intellij.util.proxy.SharedProxyConfig; +import com.intellij.util.xmlb.SkipDefaultsSerializationFilter; import com.intellij.util.xmlb.XmlSerializer; import com.intellij.util.xmlb.XmlSerializerUtil; import com.intellij.util.xmlb.annotations.Transient; @@ -129,6 +131,32 @@ public class HttpConfigurable implements PersistentStateComponent> 24)& 0xFF); + data[1] = (byte)((length >> 16)& 0xFF); + data[2] = (byte)((length >> 8)& 0xFF); + data[3] = (byte)(length & 0xFF); + + System.arraycopy(iv, 0, data, 4, iv.length); + System.arraycopy(body, 0, data, 4 + iv.length, body.length); + return data; + } + + private static byte[] decrypt(byte[] data, Key key) throws Exception { + int bodyLength = data[0] & 0xFF; + bodyLength = (bodyLength << 8) + data[1] & 0xFF; + bodyLength = (bodyLength << 8) + data[2] & 0xFF; + bodyLength = (bodyLength << 8) + data[3] & 0xFF; + + final int ivlength = data.length - 4 - bodyLength; + + final Cipher ciph = Cipher.getInstance("AES/CBC/PKCS5Padding"); + ciph.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(data, 4, ivlength)); + return ciph.doFinal(data, 4 + ivlength, bodyLength); + } + +} diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java index 63cd9a010f02..1711138a4bda 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaButtonUI.java @@ -16,6 +16,7 @@ package com.intellij.ide.ui.laf.darcula.ui; import com.intellij.icons.AllIcons; +import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.laf.darcula.DarculaLaf; import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.openapi.util.SystemInfo; @@ -101,6 +102,8 @@ public class DarculaButtonUI extends BasicButtonUI { } g.setColor(fg); + UISettings.setupAntialiasing(g); + FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g); int mnemonicIndex = DarculaLaf.isAltPressed() ? button.getDisplayedMnemonicIndex() : -1; if (model.isEnabled()) { diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaMenuItemUIBase.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaMenuItemUIBase.java index fef7715f0b2d..084e46d7ad90 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaMenuItemUIBase.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaMenuItemUIBase.java @@ -15,6 +15,7 @@ */ package com.intellij.ide.ui.laf.darcula.ui; +import com.intellij.ide.ui.UISettings; import com.intellij.util.ui.JBInsets; import sun.swing.MenuItemLayoutHelper; import sun.swing.SwingUtilities2; @@ -78,6 +79,7 @@ public class DarculaMenuItemUIBase extends BasicMenuItemUI { paintCheckIcon(g, lh, lr, holdc, foreground); paintIcon(g, lh, lr, holdc); g.setColor(foreground); + UISettings.setupAntialiasing(g); paintText(g, lh, lr); paintAccText(g, lh, lr); paintArrowIcon(g, lh, lr, foreground); @@ -177,6 +179,7 @@ public class DarculaMenuItemUIBase extends BasicMenuItemUI { lh.getHtmlView().paint(g, lr.getTextRect()); } else { // Text isn't HTML + UISettings.setupAntialiasing(g); paintText(g, lh.getMenuItem(), lr.getTextRect(), lh.getText()); } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJButtonUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJButtonUI.java index 5f4312e10f27..c4415ef06a4a 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJButtonUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacIntelliJButtonUI.java @@ -15,6 +15,7 @@ */ package com.intellij.ide.ui.laf.intellij; +import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI; import com.intellij.ui.Gray; import sun.swing.SwingUtilities2; @@ -95,6 +96,7 @@ public class MacIntelliJButtonUI extends DarculaButtonUI { if (v != null) { v.paint(g, textRect); } else { + UISettings.setupAntialiasing(g); paintText(g, b, textRect, text); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/ApplyNonConflicts.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/ApplyNonConflicts.java index 57b2eddf19aa..6f43f9375e5a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/ApplyNonConflicts.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/ApplyNonConflicts.java @@ -15,9 +15,9 @@ */ package com.intellij.openapi.diff.impl.incrementalMerge.ui; -import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.ex.ActionUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diff.DiffBundle; @@ -38,7 +38,7 @@ public class ApplyNonConflicts extends AnAction implements DumbAware { @Nullable private final DiffPanelOuterComponent myDiffPanel; public ApplyNonConflicts(@Nullable DiffPanelOuterComponent diffPanel) { - super(DiffBundle.message("merge.dialog.apply.all.non.conflicting.changes.action.name"), null, AllIcons.Diff.ApplyNotConflicts); + ActionUtil.copyFrom(this, "Diff.ApplyNonConflicts"); myDiffPanel = diffPanel; } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/OpenPartialDiffAction.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/OpenPartialDiffAction.java index 3193b0972d49..3950424c61ce 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/OpenPartialDiffAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/incrementalMerge/ui/OpenPartialDiffAction.java @@ -15,7 +15,9 @@ */ package com.intellij.openapi.diff.impl.incrementalMerge.ui; +import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.ex.ActionUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.DiffBundle; import com.intellij.openapi.diff.DocumentContent; @@ -77,13 +79,13 @@ class OpenPartialDiffAction extends AnAction implements DumbAware { private String composeName() { if (myLeftIndex == 0 && myRightIndex == 1) { - return DiffBundle.message("merge.partial.diff.action.name.0.1"); + return ActionsBundle.actionText("Diff.ComparePartial.Base.Left"); } if (myLeftIndex == 1 && myRightIndex == 2) { - return DiffBundle.message("merge.partial.diff.action.name.1.2"); + return ActionsBundle.actionText("Diff.ComparePartial.Base.Right"); } - return DiffBundle.message("merge.partial.diff.action.name"); + return ActionsBundle.actionText("Diff.ComparePartial.Left.Right"); } @Nullable diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java index e832caae4775..51ae40d45995 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeyProcessorContext.java @@ -98,6 +98,5 @@ public class KeyProcessorContext { myActions.clear(); myFocusOwner = null; myDataContext = null; - myFoundComponent = null; } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java index 3a2aaa82eaca..e81264ebef8b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java @@ -111,7 +111,7 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr }) { @Override protected boolean isActive() { - return isFocused(); + return myToolWindow.isActive(); } @Override diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 52e8e9c195cb..686ab725b0d6 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -1279,6 +1279,12 @@ action.Diff.AppendLeftSide.text=Append Left Side action.Diff.AppendRightSide.text=Append Right Side action.Diff.IgnoreLeftSide.text=Ignore Left Side action.Diff.IgnoreRightSide.text=Ignore Right Side +action.Diff.ApplyNonConflicts.text=Apply All Non-Conflicting Changes +action.Diff.ApplyNonConflicts.Left.text=Apply Non-Conflicting Changes from the Left Side +action.Diff.ApplyNonConflicts.Right.text=Apply Non-Conflicting Changes from the Right Side +action.Diff.ComparePartial.Base.Left.text=Compare Left and Middle Contents +action.Diff.ComparePartial.Base.Right.text=Compare Middle and Right Contents +action.Diff.ComparePartial.Left.Right.text=Compare Left and Right Contents action.FileChooser.ShowHiddens.text=Show Hidden Files and Directories action.FileChooser.ShowHiddens.description=Show hidden files and directories diff --git a/platform/platform-resources-en/src/messages/DiffBundle.properties b/platform/platform-resources-en/src/messages/DiffBundle.properties index 2e0e43b4d350..e16b96a9fdeb 100644 --- a/platform/platform-resources-en/src/messages/DiffBundle.properties +++ b/platform/platform-resources-en/src/messages/DiffBundle.properties @@ -65,15 +65,9 @@ no.differences.dialog.title=No Differences merge.dialog.apply.change.action.name=Accept merge.dialog.append.change.action.name=Apply selected change side merge.dialog.ignore.change.action.name=Ignore -merge.dialog.apply.all.non.conflicting.changes.action.name=Apply all non-conflicting changes -merge.dialog.apply.left.non.conflicting.changes.action.name=Apply non-conflicting changes from left side -merge.dialog.apply.right.non.conflicting.changes.action.name=Apply non-conflicting changes from right side merge.dialog.all.conflicts.resolved.message.text=All conflicts resolved #0 - changes count, 1 - conflicts count merge.statistics.message={0, choice, 0#No changes|1#One change|2#{0, number} changes}. {1, choice, 0#No conflicts|1#One conflict|2#{0, number} conflicts} -merge.partial.diff.action.name=Compare left and right panel contents -merge.partial.diff.action.name.0.1=Compare left and middle panel contents -merge.partial.diff.action.name.1.2=Compare middle and right panel contents merge.dialog.exit.without.applying.changes.confirmation.message=Are you sure you want to exit without applying changes? cancel.visual.merge.dialog.title=Cancel Visual Merge apply.somehow.status.message.already.applied={0, number} {0, choice, 1#hunk is|2#hunks are} already applied diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 69282be30501..b2b8bc6e6c89 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -98,7 +98,7 @@ serviceImplementation="com.intellij.diff.tools.util.base.TextDiffSettingsHolder"/> - diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 9b9e0b8cc56d..1886ef2e9dba 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -202,6 +202,15 @@ + + + + + + + + + diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ObjectValue.kt b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ObjectValue.kt index f96a55dad535..b0dafeec3eef 100755 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ObjectValue.kt +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ObjectValue.kt @@ -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. @@ -39,7 +39,7 @@ interface ObjectValue : Value { * "to" could be -1 (sometimes length is unknown, so, you can pass -1 instead of actual elements size) */ - fun getIndexedProperties(from: Int, to: Int, bucketThreshold: Int, consumer: IndexedVariablesConsumer, componentType: ValueType?): Promise<*> + fun getIndexedProperties(from: Int, to: Int, bucketThreshold: Int, consumer: IndexedVariablesConsumer, componentType: ValueType? = null): Promise<*> /** * It must return quickly. Return [com.intellij.util.ThreeState.UNSURE] otherwise. diff --git a/platform/script-debugger/debugger-ui/src/VariableView.kt b/platform/script-debugger/debugger-ui/src/VariableView.kt index b48f32562890..4bffc4914cce 100644 --- a/platform/script-debugger/debugger-ui/src/VariableView.kt +++ b/platform/script-debugger/debugger-ui/src/VariableView.kt @@ -198,18 +198,18 @@ class VariableView(override val variableName: String, private val variable: Vari override fun consumeRanges(ranges: IntArray?) { if (ranges == null) { val groupList = XValueChildrenList() - LazyVariablesGroup.addGroups(value, LazyVariablesGroup.GROUP_FACTORY, groupList, 0, value.length, XCompositeNode.MAX_CHILDREN_TO_SHOW, this@VariableView) + addGroups(value, ::lazyVariablesGroup, groupList, 0, value.length, XCompositeNode.MAX_CHILDREN_TO_SHOW, this@VariableView) node.addChildren(groupList, isLastChildren) } else { - LazyVariablesGroup.addRanges(value, ranges, node, this@VariableView, isLastChildren) + addRanges(value, ranges, node, this@VariableView, isLastChildren) } } override fun consumeVariables(variables: List) { node.addChildren(createVariablesList(variables, this@VariableView, null), isLastChildren) } - }, null) + }) } private fun computeNamedProperties(value: ObjectValue, node: XCompositeNode, isLastChildren: Boolean) = processVariables(this, value.properties, node) { memberFilter, variables -> @@ -254,7 +254,7 @@ class VariableView(override val variableName: String, private val variable: Vari val groupList = XValueChildrenList() if (count > 0) { - LazyVariablesGroup.addGroups(variables, GROUP_FACTORY, groupList, 0, count, bucketSize, this) + addGroups(variables, ::createArrayRangeGroup, groupList, 0, count, bucketSize, this) } var notGroupedVariablesOffset: Int @@ -268,7 +268,7 @@ class VariableView(override val variableName: String, private val variable: Vari } if (notGroupedVariablesOffset > 0) { - LazyVariablesGroup.addGroups(variables, GROUP_FACTORY, groupList, count, notGroupedVariablesOffset, bucketSize, this) + addGroups(variables, ::createArrayRangeGroup, groupList, count, notGroupedVariablesOffset, bucketSize, this) } } else { diff --git a/platform/script-debugger/debugger-ui/src/VariablesGroup.kt b/platform/script-debugger/debugger-ui/src/VariablesGroup.kt index 6f802713ce92..357e4b8d7a69 100644 --- a/platform/script-debugger/debugger-ui/src/VariablesGroup.kt +++ b/platform/script-debugger/debugger-ui/src/VariablesGroup.kt @@ -28,13 +28,7 @@ internal class VariablesGroup(private val start: Int, private val end: Int, priv } } -internal val GROUP_FACTORY: ValueGroupFactory> = object : ValueGroupFactory> { - override fun create(data: List, start: Int, end: Int, context: VariableContext): XValueGroup { - return createArrayRangeGroup(start, end, data, context) - } -} - -private fun createArrayRangeGroup(start: Int, end: Int, variables: List, variableContext: VariableContext): VariablesGroup { +internal fun createArrayRangeGroup(variables: List, start: Int, end: Int, variableContext: VariableContext): VariablesGroup { val name = "[" + variables[start].name + " \u2026 " + variables[end - 1].name + "]" return VariablesGroup(start, end, variables, variableContext, name) } diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/LazyVariablesGroup.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/LazyVariablesGroup.java deleted file mode 100644 index 4ef75f6029d4..000000000000 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/LazyVariablesGroup.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.debugger; - -import com.intellij.xdebugger.frame.XCompositeNode; -import com.intellij.xdebugger.frame.XValueChildrenList; -import com.intellij.xdebugger.frame.XValueGroup; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.debugger.values.ObjectValue; -import org.jetbrains.debugger.values.ValueType; - -import java.util.ArrayList; -import java.util.List; - -public final class LazyVariablesGroup extends XValueGroup { - public static final ValueGroupFactory GROUP_FACTORY = new ValueGroupFactory() { - @Override - public XValueGroup create(@NotNull ObjectValue value, int start, int end, @NotNull VariableContext context) { - return new LazyVariablesGroup(value, start, end, context); - } - }; - - private final ObjectValue value; - - private final int startInclusive; - private final int endInclusive; - private final VariableContext context; - - private final ValueType componentType; - private final boolean sparse; - - public LazyVariablesGroup(@NotNull ObjectValue value, int startInclusive, int endInclusive, @NotNull VariableContext context) { - this(value, startInclusive, endInclusive, context, null, true); - } - - public LazyVariablesGroup(@NotNull ObjectValue value, int startInclusive, int endInclusive, @NotNull VariableContext context, @Nullable ValueType componentType, boolean sparse) { - super(String.format("[%,d \u2026 %,d]", startInclusive, endInclusive)); - - this.value = value; - - this.startInclusive = startInclusive; - this.endInclusive = endInclusive; - - this.context = context; - - this.componentType = componentType; - this.sparse = sparse; - } - - @Override - public void computeChildren(@NotNull XCompositeNode node) { - node.setAlreadySorted(true); - - int bucketThreshold = XCompositeNode.MAX_CHILDREN_TO_SHOW; - if (!sparse && (endInclusive - startInclusive) > bucketThreshold) { - node.addChildren(XValueChildrenList.topGroups(computeNotSparseGroups(value, context, startInclusive, endInclusive + 1, bucketThreshold)), true); - return; - } - - value.getIndexedProperties(startInclusive, endInclusive + 1, bucketThreshold, new VariableView.ObsolescentIndexedVariablesConsumer(node) { - @Override - public void consumeRanges(@Nullable int[] ranges) { - if (ranges == null) { - XValueChildrenList groupList = new XValueChildrenList(); - addGroups(value, GROUP_FACTORY, groupList, startInclusive, endInclusive, XCompositeNode.MAX_CHILDREN_TO_SHOW, context); - getNode().addChildren(groupList, true); - } - else { - addRanges(value, ranges, getNode(), context, true); - } - } - - @Override - public void consumeVariables(@NotNull List variables) { - getNode().addChildren(VariablesKt.createVariablesList(variables, context, null), true); - } - }, componentType); - } - - @NotNull - public static List computeNotSparseGroups(@NotNull ObjectValue value, @NotNull VariableContext context, int fromInclusive, int toExclusive, int bucketThreshold) { - int size = toExclusive - fromInclusive; - int bucketSize = (int)Math.pow(bucketThreshold, Math.ceil(Math.log(size) / Math.log(bucketThreshold)) - 1); - List groupList = new ArrayList((int)Math.ceil(size / bucketSize)); - for (; fromInclusive < toExclusive; fromInclusive += bucketSize) { - groupList.add(new LazyVariablesGroup(value, fromInclusive, fromInclusive + (Math.min(bucketSize, toExclusive - fromInclusive) - 1), context, ValueType.NUMBER, false)); - } - return groupList; - } - - public static void addRanges(@NotNull ObjectValue value, int[] ranges, @NotNull XCompositeNode node, @NotNull VariableContext context, boolean isLast) { - XValueChildrenList groupList = new XValueChildrenList(ranges.length / 2); - for (int i = 0, n = ranges.length; i < n; i += 2) { - groupList.addTopGroup(new LazyVariablesGroup(value, ranges[i], ranges[i + 1], context)); - } - node.addChildren(groupList, isLast); - } - - public static void addGroups(@NotNull T data, - @NotNull ValueGroupFactory groupFactory, - @NotNull XValueChildrenList groupList, - int from, - int limit, - int bucketSize, - @NotNull VariableContext context) { - int to = Math.min(bucketSize, limit); - boolean done = false; - do { - int groupFrom = from; - int groupTo = to; - - from += bucketSize; - to = from + Math.min(bucketSize, limit - from); - - // don't create group for only one member - if (to - from == 1) { - groupTo++; - done = true; - } - groupList.addTopGroup(groupFactory.create(data, groupFrom, groupTo, context)); - if (from >= limit) { - break; - } - } - while (!done); - } -} \ No newline at end of file diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/LazyVariablesGroup.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/LazyVariablesGroup.kt new file mode 100644 index 000000000000..52ec2cfbbf20 --- /dev/null +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/LazyVariablesGroup.kt @@ -0,0 +1,107 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.debugger + +import com.intellij.xdebugger.frame.XCompositeNode +import com.intellij.xdebugger.frame.XValueChildrenList +import com.intellij.xdebugger.frame.XValueGroup +import org.jetbrains.debugger.values.ObjectValue +import org.jetbrains.debugger.values.ValueType +import java.util.* + +internal fun lazyVariablesGroup(variables: ObjectValue, start: Int, end: Int, context: VariableContext) = LazyVariablesGroup(variables, start, end, context) + +class LazyVariablesGroup(private val value: ObjectValue, private val startInclusive: Int, private val endInclusive: Int, private val context: VariableContext, private val componentType: ValueType? = null, private val sparse: Boolean = true) : XValueGroup(String.format("[%,d \u2026 %,d]", startInclusive, endInclusive)) { + override fun computeChildren(node: XCompositeNode) { + node.setAlreadySorted(true) + + val bucketThreshold = XCompositeNode.MAX_CHILDREN_TO_SHOW + if (!sparse && endInclusive - startInclusive > bucketThreshold) { + node.addChildren(XValueChildrenList.topGroups(computeNotSparseGroups(value, context, startInclusive, endInclusive + 1, bucketThreshold)), true) + return + } + + value.getIndexedProperties(startInclusive, endInclusive + 1, bucketThreshold, object : VariableView.ObsolescentIndexedVariablesConsumer(node) { + override fun consumeRanges(ranges: IntArray?) { + if (ranges == null) { + val groupList = XValueChildrenList() + addGroups(value, ::lazyVariablesGroup, groupList, startInclusive, endInclusive, XCompositeNode.MAX_CHILDREN_TO_SHOW, context) + node.addChildren(groupList, true) + } + else { + addRanges(value, ranges, node, context, true) + } + } + + override fun consumeVariables(variables: List) { + node.addChildren(createVariablesList(variables, context, null), true) + } + }, componentType) + } +} + +fun computeNotSparseGroups(value: ObjectValue, context: VariableContext, _fromInclusive: Int, toExclusive: Int, bucketThreshold: Int): List { + var fromInclusive = _fromInclusive + val size = toExclusive - fromInclusive + val bucketSize = Math.pow(bucketThreshold.toDouble(), Math.ceil(Math.log(size.toDouble()) / Math.log(bucketThreshold.toDouble())) - 1).toInt() + val groupList = ArrayList(Math.ceil((size / bucketSize).toDouble()).toInt()) + while (fromInclusive < toExclusive) { + groupList.add(LazyVariablesGroup(value, fromInclusive, fromInclusive + (Math.min(bucketSize, toExclusive - fromInclusive) - 1), context, ValueType.NUMBER, false)) + fromInclusive += bucketSize + } + return groupList +} + +fun addRanges(value: ObjectValue, ranges: IntArray, node: XCompositeNode, context: VariableContext, isLast: Boolean) { + val groupList = XValueChildrenList(ranges.size / 2) + var i = 0 + val n = ranges.size + while (i < n) { + groupList.addTopGroup(LazyVariablesGroup(value, ranges[i], ranges[i + 1], context)) + i += 2 + } + node.addChildren(groupList, isLast) +} + +internal fun addGroups(data: T, + groupFactory: (data: T, start: Int, end: Int, context: VariableContext) -> XValueGroup, + groupList: XValueChildrenList, + _from: Int, + limit: Int, + bucketSize: Int, + context: VariableContext) { + var from = _from + var to = Math.min(bucketSize, limit) + var done = false + do { + val groupFrom = from + var groupTo = to + + from += bucketSize + to = from + Math.min(bucketSize, limit - from) + + // don't create group for only one member + if (to - from == 1) { + groupTo++ + done = true + } + groupList.addTopGroup(groupFactory(data, groupFrom, groupTo, context)) + if (from >= limit) { + break + } + } + while (!done) +} \ No newline at end of file diff --git a/platform/testFramework/src/com/intellij/testFramework/EdtTestUtil.kt b/platform/testFramework/src/com/intellij/testFramework/EdtTestUtil.kt index 5cea358ef6cf..6944559a04a5 100644 --- a/platform/testFramework/src/com/intellij/testFramework/EdtTestUtil.kt +++ b/platform/testFramework/src/com/intellij/testFramework/EdtTestUtil.kt @@ -17,6 +17,7 @@ package com.intellij.testFramework import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ModalityState +import com.intellij.openapi.application.impl.ApplicationImpl import com.intellij.util.ThrowableRunnable import org.jetbrains.annotations.TestOnly import java.lang.reflect.InvocationTargetException @@ -37,7 +38,7 @@ class EdtTestUtil { @TestOnly fun runInEdtAndWait(runnable: () -> Unit) { val application = ApplicationManager.getApplication() - if (application != null) { + if (application is ApplicationImpl) { application.invokeAndWait(runnable, ModalityState.defaultModalityState()) return } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java index 6c64a7bdf392..a421c078f493 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java @@ -533,6 +533,8 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture { void testFolding(@NotNull String fileName); + void testFoldingWithCollapseStatus(@NotNull final String verificationFileName, @Nullable String destinationFileName); + void testFoldingWithCollapseStatus(@NotNull String fileName); void assertPreferredCompletionItems(int selected, @NotNull String... expected); 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 75c5530092cc..7d07c15d161f 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1822,7 +1822,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig return result.toString(); } - private void testFoldingRegions(@NotNull String verificationFileName, boolean doCheckCollapseStatus) { + private void testFoldingRegions(@NotNull String verificationFileName, @Nullable String destinationFileName, boolean doCheckCollapseStatus) { String expectedContent; try { expectedContent = FileUtil.loadFile(new File(verificationFileName)); @@ -1834,21 +1834,35 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig expectedContent = StringUtil.replace(expectedContent, "\r", ""); final String cleanContent = expectedContent.replaceAll(START_FOLD, "").replaceAll(END_FOLD, ""); - - configureByText(FileTypeManager.getInstance().getFileTypeByFileName(verificationFileName), cleanContent); + if (destinationFileName == null) { + configureByText(FileTypeManager.getInstance().getFileTypeByFileName(verificationFileName), cleanContent); + } + else { + try { + FileUtil.writeToFile(new File(destinationFileName), cleanContent); + configureFromExistingVirtualFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(destinationFileName)); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } final String actual = getFoldingDescription(doCheckCollapseStatus); - Assert.assertEquals(expectedContent, actual); } @Override public void testFoldingWithCollapseStatus(@NotNull final String verificationFileName) { - testFoldingRegions(verificationFileName, true); + testFoldingRegions(verificationFileName, null, true); + } + + @Override + public void testFoldingWithCollapseStatus(@NotNull final String verificationFileName, @Nullable String destinationFileName) { + testFoldingRegions(verificationFileName, destinationFileName, true); } @Override public void testFolding(@NotNull final String verificationFileName) { - testFoldingRegions(verificationFileName, false); + testFoldingRegions(verificationFileName, null, false); } @Override diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index 0bc898a367e0..4c14009aff0f 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -1360,7 +1360,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra if (usage instanceof UsageInFile) { UsageInFile usageInFile = (UsageInFile)usage; VirtualFile file = usageInFile.getFile(); - if (file != null) result.add(file); + if (file != null && file.isValid()) result.add(file); } if (usage instanceof UsageInFiles) { diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index c405e8694dee..9f16ebcf57ef 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -547,7 +547,6 @@ spy.js.realtime.evaluation.description=Enables spy-js autocomplete and realtime js.debugger.step.over.skip.same.line=true js.debugger.skip.native.scripts=true js.debugger.trace.resume=false -js.debugger.v8.lazy.compilation=true js.debugger.v8.use.any.breakpoint=true js.debugger.chrome.use.any.breakpoint=true nodejs.debugger.use.jb.support=true diff --git a/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java b/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java index 7cafbe9a159e..d0626cfb6b44 100644 --- a/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java +++ b/platform/util/src/com/intellij/util/concurrency/SchedulingWrapper.java @@ -322,7 +322,7 @@ class SchedulingWrapper implements ScheduledExecutorService { long initialDelay, long period, @NotNull TimeUnit unit) { - throw new IncorrectOperationException("Not supported because it's bad for hibernation; use scheduleWithFixedDelay() instead."); + throw new IncorrectOperationException("Not supported because it's bad for hibernation; use scheduleWithFixedDelay() with the same parameters instead."); } @NotNull diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index f1942b61464e..732782186ea2 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -3272,7 +3272,7 @@ public class UIUtil { // Evaluate the value depending on our current theme if (lcdContrastValue == 0) { if (SystemInfo.isMacIntel64) { - lcdContrastValue = isUnderDarcula() ? 140 : 200; + lcdContrastValue = isUnderDarcula() ? 140 : 230; } else { Map map = (Map)Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java index 5523f992d3c0..dd7d8507803f 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java @@ -19,7 +19,7 @@ import com.intellij.CommonBundle; import com.intellij.dvcs.DvcsCommitAdditionalComponent; import com.intellij.dvcs.DvcsUtil; import com.intellij.dvcs.push.ui.VcsPushDialog; -import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -227,8 +227,9 @@ public class GitCheckinEnvironment implements CheckinEnvironment { GitRepositoryManager manager = GitUtil.getRepositoryManager(myProject); Collection repositories = GitUtil.getRepositoriesFromRoots(manager, sortedChanges.keySet()); final List preselectedRepositories = ContainerUtil.newArrayList(repositories); - ApplicationManager.getApplication().invokeLater(() -> - new VcsPushDialog(myProject, preselectedRepositories, GitBranchUtil.getCurrentRepository(myProject)).show()); + GuiUtils.invokeLaterIfNeeded(() -> + new VcsPushDialog(myProject, preselectedRepositories, GitBranchUtil.getCurrentRepository(myProject)).show(), + ModalityState.defaultModalityState()); } return exceptions; } diff --git a/plugins/git4idea/src/git4idea/commands/GitTask.java b/plugins/git4idea/src/git4idea/commands/GitTask.java index bac23f90a71a..633e4e6db058 100644 --- a/plugins/git4idea/src/git4idea/commands/GitTask.java +++ b/plugins/git4idea/src/git4idea/commands/GitTask.java @@ -39,11 +39,13 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; /** - * @deprecated All Git commands are cancellable when called via {@link GitHandler}.
+ * All Git commands are cancellable when called via {@link GitHandler}.
* To execute the command synchronously, call {@link GitHandler#runInCurrentThread(Runnable)} * or better {@link Git#runCommand(Computable)}.
* To execute in the background or under a modal progress, use the standard {@link Task}.
* To watch the progress, call {@link GitStandardProgressAnalyzer#createListener(ProgressIndicator)}. + * + * @deprecated To remove in IDEA 2017. */ @Deprecated public class GitTask { @@ -66,18 +68,11 @@ public class GitTask { * Executes this task synchronously, with a modal progress dialog. * @return Result of the task execution. */ + @SuppressWarnings("unused") public GitTaskResult executeModal() { return execute(true); } - /** - * Executes the task synchronously, with a modal progress dialog. - * @param resultHandler callback which will be called after task execution. - */ - public void executeModal(GitTaskResultHandler resultHandler) { - execute(true, true, resultHandler); - } - /** * Executes this task asynchronously, in background. Calls the resultHandler when finished. * @param resultHandler callback called after the task has finished or was cancelled by user or automatically. diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java index 87de91e4b1aa..b50ac70b3cea 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrApplicationStatementImpl.java @@ -41,10 +41,9 @@ public class GrApplicationStatementImpl extends GrMethodCallImpl implements GrAp return "Call expression"; } - @NotNull @Override public GrCommandArgumentList getArgumentList() { - return findNotNullChildByClass(GrCommandArgumentList.class); + return findChildByClass(GrCommandArgumentList.class); } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonRunConfiguration.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonRunConfiguration.java index d5f14e4e3b01..64781af2557a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonRunConfiguration.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonRunConfiguration.java @@ -17,7 +17,6 @@ package org.jetbrains.plugins.groovy.griffon; import com.intellij.execution.configurations.ConfigurationFactory; -import com.intellij.execution.configurations.ModuleBasedConfiguration; import com.intellij.execution.configurations.RunConfigurationModule; import com.intellij.openapi.project.Project; import org.jetbrains.plugins.groovy.mvc.MvcRunConfiguration; @@ -35,13 +34,4 @@ public class GriffonRunConfiguration extends MvcRunConfiguration { protected String getNoSdkMessage() { return "Griffon SDK is not configured"; } - - @Override - protected ModuleBasedConfiguration createInstance() { - GriffonRunConfiguration res = new GriffonRunConfiguration(myFactory, getConfigurationModule().getProject(), getName(), cmdLine); - res.envs.putAll(envs); - res.passParentEnv = passParentEnv; - return res; - } - } \ No newline at end of file diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxImportClassFix.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxImportClassFix.java index a49c247fe755..c1bd42111bb0 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxImportClassFix.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxImportClassFix.java @@ -20,6 +20,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; +import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil; @@ -71,7 +72,8 @@ abstract class JavaFxImportClassFix extends ImportClassFixBase consumer) { - class StopException extends RuntimeException { - } - try { - file.accept(new XmlRecursiveElementVisitor() { - @Override - public void visitXmlAttribute(XmlAttribute attribute) { - final PsiReference[] references = attribute.getReferences(); - for (PsiReference reference : references) { - if ((reference instanceof JavaFxStaticPropertyReference || reference instanceof JavaFxEventHandlerReference) && - reference.isReferenceTo(psiMethod)) { - if (!consumer.process(reference)) { - throw new StopException(); - } + final Ref stopped = new Ref<>(false); + file.accept(new XmlRecursiveElementVisitor() { + @Override + public void visitXmlElement(XmlElement element) { + if (stopped.get()) return; + super.visitXmlElement(element); + } + + @Override + public void visitXmlAttribute(XmlAttribute attribute) { + if (stopped.get()) return; + final PsiReference[] references = attribute.getReferences(); + for (PsiReference reference : references) { + if ((reference instanceof JavaFxStaticPropertyReference || reference instanceof JavaFxEventHandlerReference) && + reference.isReferenceTo(psiMethod)) { + if (!consumer.process(reference)) { + stopped.set(true); + return; } } } - }); - return true; - } - catch (StopException unused) { - return false; - } + } + }); + return !stopped.get(); } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/refactoring/JavaFxPropertyRenameHandler.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/refactoring/JavaFxPropertyRenameHandler.java index 6e7b0a972de6..803088749d67 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/refactoring/JavaFxPropertyRenameHandler.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/refactoring/JavaFxPropertyRenameHandler.java @@ -138,17 +138,17 @@ public class JavaFxPropertyRenameHandler implements RenameHandler { @NotNull private static Map getElementsToRename(@NotNull JavaFxPropertyReference reference, @NotNull String newPropertyName) { final Map rename = new THashMap<>(); - putIfKeyNotNull(rename, reference.getGetter(), () -> PropertyUtil.suggestGetterName(newPropertyName, reference.getType())); - putIfKeyNotNull(rename, reference.getField(), () -> newPropertyName); - putIfKeyNotNull(rename, reference.getSetter(), () -> PropertyUtil.suggestSetterName(newPropertyName)); - putIfKeyNotNull(rename, reference.getObservableGetter(), () -> newPropertyName + JavaFxCommonNames.PROPERTY_METHOD_SUFFIX); - putIfKeyNotNull(rename, reference.getStaticSetter(), () -> PropertyUtil.suggestSetterName(newPropertyName)); + putIfKeyNotNull(rename, reference.getGetter(), PropertyUtil.suggestGetterName(newPropertyName, reference.getType())); + putIfKeyNotNull(rename, reference.getField(), newPropertyName); + putIfKeyNotNull(rename, reference.getSetter(), PropertyUtil.suggestSetterName(newPropertyName)); + putIfKeyNotNull(rename, reference.getObservableGetter(), newPropertyName + JavaFxCommonNames.PROPERTY_METHOD_SUFFIX); + putIfKeyNotNull(rename, reference.getStaticSetter(), PropertyUtil.suggestSetterName(newPropertyName)); //TODO add "name" parameter of the observable property constructor (like new SimpleObjectProperty(this, "name", null); return rename; } - private static void putIfKeyNotNull(Map map, K key, NotNullProducer valueProducer) { - if (key != null) map.put(key, valueProducer.produce()); + private static void putIfKeyNotNull(@NotNull Map map, @Nullable K key, @NotNull V value) { + if (key != null) map.put(key, value); } private static class PropertyRenameDialog extends RenameDialog { diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java index 6da637dd5210..21568c6702d8 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java @@ -188,11 +188,6 @@ public class JUnitConfiguration extends JavaTestConfigurationBase { return JavaRunConfigurationModule.getModulesForClass(getProject(), myData.getMainClassName()); } - @Override - protected ModuleBasedConfiguration createInstance() { - return new JUnitConfiguration(getName(), getProject(), myData.clone(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);// throw new RuntimeException("Should not call"); - } - @Override public String suggestedName() { return myData.getGeneratedName(getConfigurationModule()); diff --git a/plugins/junit/src/com/intellij/execution/junit/testDiscovery/JUnitTestDiscoveryConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/testDiscovery/JUnitTestDiscoveryConfiguration.java index 70460e4ca74c..dddbc7f1e081 100644 --- a/plugins/junit/src/com/intellij/execution/junit/testDiscovery/JUnitTestDiscoveryConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/testDiscovery/JUnitTestDiscoveryConfiguration.java @@ -45,14 +45,6 @@ public class JUnitTestDiscoveryConfiguration extends TestDiscoveryConfiguration new JUnitConfiguration("", project, JUnitConfigurationType.getInstance().getConfigurationFactories()[0])); } - @Override - protected ModuleBasedConfiguration createInstance() { - final JUnitTestDiscoveryConfigurationType configurationType = - ConfigurationTypeUtil.findConfigurationType(JUnitTestDiscoveryConfigurationType.class); - final ConfigurationFactory[] factories = configurationType.getConfigurationFactories(); - return new JUnitTestDiscoveryConfiguration(getName(), getProject(), factories[0]); - } - @Nullable @Override public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.groovy index b302075062a6..54f61353f3d6 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.groovy +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomPathWithPropertyTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -15,7 +15,6 @@ */ package org.jetbrains.idea.maven.dom -import com.intellij.openapi.vfs.VfsUtil import com.intellij.psi.PsiManager /** diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenEmbeddersManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenEmbeddersManagerTest.java index 2618c358a2eb..0530b211dd9f 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenEmbeddersManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenEmbeddersManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -29,8 +29,12 @@ public class MavenEmbeddersManagerTest extends MavenTestCase { @Override protected void tearDown() throws Exception { - myManager.releaseForcefullyInTests(); - super.tearDown(); + try { + myManager.releaseForcefullyInTests(); + } + finally { + super.tearDown(); + } } public void testBasics() throws Exception { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenFoldersImporterTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenFoldersImporterTest.java similarity index 99% rename from plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenFoldersImporterTest.java rename to plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenFoldersImporterTest.java index 8ad2fb98fb1b..e541d227818e 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenFoldersImporterTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenFoldersImporterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.idea.maven.project; +package org.jetbrains.idea.maven.project.importing; import com.intellij.ProjectTopics; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; import org.jetbrains.idea.maven.MavenImportingTestCase; -import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl; import org.jetbrains.idea.maven.importing.MavenFoldersImporter; import org.jetbrains.idea.maven.importing.MavenRootModelAdapter; import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectTest.java similarity index 99% rename from plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectTest.java rename to plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectTest.java index 544cacf64f5e..daee60f59752 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jetbrains.idea.maven.project; +package org.jetbrains.idea.maven.project.importing; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -22,6 +22,7 @@ import org.jetbrains.idea.maven.MavenImportingTestCase; import org.jetbrains.idea.maven.model.MavenArtifactNode; import org.jetbrains.idea.maven.model.MavenPlugin; import org.jetbrains.idea.maven.model.MavenRemoteRepository; +import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.utils.MavenJDOMUtil; import java.io.File; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java similarity index 99% rename from plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsManagerTest.java rename to plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java index d4d5a495bfa1..1e62108ccbc2 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsManagerTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.idea.maven.project; +package org.jetbrains.idea.maven.project.importing; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.WriteCommandAction; @@ -30,6 +30,7 @@ import com.intellij.util.FileContentUtil; import org.jetbrains.idea.maven.MavenImportingTestCase; import org.jetbrains.idea.maven.importing.MavenRootModelAdapter; import org.jetbrains.idea.maven.model.MavenExplicitProfiles; +import org.jetbrains.idea.maven.project.*; import org.jetbrains.idea.maven.server.NativeMavenProjectHolder; import java.io.File; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeIgnoresTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java similarity index 94% rename from plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeIgnoresTest.java rename to plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java index 32174d244fd6..3fcebb675e8d 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeIgnoresTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeIgnoresTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -13,11 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.idea.maven.project; +package org.jetbrains.idea.maven.project.importing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Function; +import org.jetbrains.idea.maven.project.MavenProject; +import org.jetbrains.idea.maven.project.MavenProjectsTree; import java.util.Collections; import java.util.List; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java similarity index 99% rename from plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java rename to plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java index cced8263b261..85662f0be765 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeReadingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.idea.maven.project; +package org.jetbrains.idea.maven.project.importing; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.util.Pair; @@ -23,6 +23,10 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.util.Function; import org.jetbrains.idea.maven.model.MavenExplicitProfiles; +import org.jetbrains.idea.maven.project.MavenEmbeddersManager; +import org.jetbrains.idea.maven.project.MavenProject; +import org.jetbrains.idea.maven.project.MavenProjectChanges; +import org.jetbrains.idea.maven.project.MavenProjectsTree; import org.jetbrains.idea.maven.server.MavenServerManager; import org.jetbrains.idea.maven.server.NativeMavenProjectHolder; import org.jetbrains.idea.maven.utils.MavenUtil; diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeTestCase.java similarity index 93% rename from plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeTestCase.java rename to plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeTestCase.java index 7f4debf12394..08e9c90c90eb 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/importing/MavenProjectsTreeTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.idea.maven.project; +package org.jetbrains.idea.maven.project.importing; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; @@ -21,6 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.maven.MavenImportingTestCase; import org.jetbrains.idea.maven.model.MavenExplicitProfiles; +import org.jetbrains.idea.maven.project.MavenProjectsTree; import org.jetbrains.idea.maven.utils.MavenProcessCanceledException; import java.io.IOException; diff --git a/plugins/properties/src/com/intellij/lang/properties/parsing/idea-skeleton b/plugins/properties/src/com/intellij/lang/properties/parsing/idea-skeleton deleted file mode 100644 index 0866f9f0c7b6..000000000000 --- a/plugins/properties/src/com/intellij/lang/properties/parsing/idea-skeleton +++ /dev/null @@ -1,262 +0,0 @@ - /** initial size of the lookahead buffer */ ---- private static final int ZZ_BUFFERSIZE = ...; - - /** lexical states */ ---- lexical states, charmap - - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; - private static final char[] EMPTY_BUFFER = new char[0]; - private static final int YYEOF = -1; - - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - ---- isFinal list - /** the current state of the DFA */ - private int zzState; - - /** the current lexical state */ - private int zzLexicalState = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char zzBuffer[] = EMPTY_BUFFER; - - /** the textposition at the last accepting state */ - private int zzMarkedPos; - - /** the textposition at the last state to be included in yytext */ - private int zzPushbackPos; - - /** the current text position in the buffer */ - private int zzCurrentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int zzStartRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int zzEndRead; - - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; - - /** zzAtEOF == true <=> the scanner is at the EOF */ - private boolean zzAtEOF; - ---- user class code - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ ---- constructor declaration - - - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { - return true; - } - - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - } - - - /** - * Resets the scanner to read from a new input stream. - * Does not close the old reader. - * - * All internal variables are reset, the old input stream - * cannot be reused (internal buffer is discarded and lost). - * Lexical state is set to ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzAtBOL = true; - zzAtEOF = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = zzPushbackPos = 0; - zzLexicalState = YYINITIAL; - } - - - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); - } - - - /** - * Returns the character at position pos from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead+pos]; - } - - - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos-zzStartRead; - } - - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ ---- zzScanError declaration - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; - } - ---- throws clause - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ ---- yypushback decl (contains zzScanError exception) - if ( number > yylength() ) - zzScanError(ZZ_PUSHBACK_2BIG); - - zzMarkedPos -= number; - } - - ---- zzDoEOF - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ ---- yylex declaration - int zzInput; - int zzAction; - - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char [] zzBufferL = zzBuffer; - char [] zzCMapL = ZZ_CMAP; - ---- local declarations - - while (true) { - zzMarkedPosL = zzMarkedPos; - ---- start admin (line, char, col count) - zzAction = -1; - - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - ---- start admin (lexstate etc) - - zzForAction: { - while (true) { - ---- next input, line, col, char count, next transition, isFinal action - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; ---- line count update - } - - } - } - - // store back cached position - zzMarkedPos = zzMarkedPosL; ---- char count update - ---- actions - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; ---- eofvalue - } - else { ---- no match - } - } - } - } - ---- main - -} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java index c1394c50503b..d2f2f0719692 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java @@ -17,7 +17,6 @@ package org.jetbrains.idea.svn.actions; import com.intellij.diff.DiffManager; import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.PerformInBackgroundOption; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -141,33 +140,34 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen // gets exactly WORKING revision property myAfterContent = getPropertyList(vcs, myChange.getAfterRevision(), myAfterRevision); } - catch(SVNException exc) { + catch (SVNException exc) { myException = exc; } catch (VcsException exc) { myException = exc; } + } - ApplicationManager.getApplication().invokeLater(() -> { - if (myException != null) { - Messages.showErrorDialog(myException.getMessage(), myErrorTitle); - return; + @Override + public void onSuccess() { + if (myException != null) { + Messages.showErrorDialog(myException.getMessage(), myErrorTitle); + return; + } + if (myBeforeContent != null && myAfterContent != null && myBeforeRevisionValue != null && myAfterRevision != null) { + SvnPropertiesDiffRequest diffRequest; + if (compareRevisions(myBeforeRevisionValue, myAfterRevision) > 0) { + diffRequest = new SvnPropertiesDiffRequest(getDiffWindowTitle(myChange), + new PropertyContent(myAfterContent), new PropertyContent(myBeforeContent), + revisionToString(myAfterRevision), revisionToString(myBeforeRevisionValue)); } - if (myBeforeContent != null && myAfterContent != null && myBeforeRevisionValue != null && myAfterRevision != null) { - SvnPropertiesDiffRequest diffRequest; - if (compareRevisions(myBeforeRevisionValue, myAfterRevision) > 0) { - diffRequest = new SvnPropertiesDiffRequest(getDiffWindowTitle(myChange), - new PropertyContent(myAfterContent), new PropertyContent(myBeforeContent), - revisionToString(myAfterRevision), revisionToString(myBeforeRevisionValue)); - } - else { - diffRequest = new SvnPropertiesDiffRequest(getDiffWindowTitle(myChange), - new PropertyContent(myBeforeContent), new PropertyContent(myAfterContent), - revisionToString(myBeforeRevisionValue), revisionToString(myAfterRevision)); - } - DiffManager.getInstance().showDiff(myProject, diffRequest); + else { + diffRequest = new SvnPropertiesDiffRequest(getDiffWindowTitle(myChange), + new PropertyContent(myBeforeContent), new PropertyContent(myAfterContent), + revisionToString(myBeforeRevisionValue), revisionToString(myAfterRevision)); } - }); + DiffManager.getInstance().showDiff(myProject, diffRequest); + } } } diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSchemeColorPalette.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSchemeColorPalette.java index 4803140d23c2..340668a237da 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSchemeColorPalette.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSchemeColorPalette.java @@ -38,8 +38,8 @@ public class JBTerminalSchemeColorPalette extends ColorPalette { @Override public Color[] getIndexColors() { - Color[] result = XTERM_PALETTE.getIndexColors(); - for (int i = 1; i < 7; i++) { + Color[] result = new Color[ 16 ]; + for (int i = 0; i < result.length; i++) { result[i] = myColorsScheme.getAttributes(ColoredOutputTypeRegistry.getAnsiColorKey(i)).getForegroundColor(); } return result; diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java index f10fab50855a..bf27fb5c4622 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java @@ -128,12 +128,6 @@ public class TestNGConfiguration extends JavaTestConfigurationBase { return data; } - @Override - protected ModuleBasedConfiguration createInstance() { - return new TestNGConfiguration(getName(), getProject(), data.clone(), - TestNGConfigurationType.getInstance().getConfigurationFactories()[0]); - } - @Override public Collection getValidModules() { //TODO add handling for package diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/testDiscovery/TestNGTestDiscoveryConfiguration.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/testDiscovery/TestNGTestDiscoveryConfiguration.java index 09efc7ef06aa..9ecb0d556213 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/testDiscovery/TestNGTestDiscoveryConfiguration.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/testDiscovery/TestNGTestDiscoveryConfiguration.java @@ -45,14 +45,6 @@ public class TestNGTestDiscoveryConfiguration extends TestDiscoveryConfiguration new TestNGConfiguration("", project, TestNGConfigurationType.getInstance().getConfigurationFactories()[0])); } - @Override - protected ModuleBasedConfiguration createInstance() { - final TestNGTestDiscoveryConfigurationType configurationType = - ConfigurationTypeUtil.findConfigurationType(TestNGTestDiscoveryConfigurationType.class); - final ConfigurationFactory[] factories = configurationType.getConfigurationFactories(); - return new TestNGTestDiscoveryConfiguration(getName(), getProject(), factories[0]); - } - @Nullable @Override public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException { diff --git a/python/src/com/jetbrains/python/codeInsight/imports/AddImportHelper.java b/python/src/com/jetbrains/python/codeInsight/imports/AddImportHelper.java index 1f5bbbe3511d..8534a2c900aa 100644 --- a/python/src/com/jetbrains/python/codeInsight/imports/AddImportHelper.java +++ b/python/src/com/jetbrains/python/codeInsight/imports/AddImportHelper.java @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -263,7 +264,8 @@ public class AddImportHelper { return UNRESOLVED_SYMBOL_PRIORITY; } final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(toImport.getProject()); - if (projectRootManager.getFileIndex().isInContent(vFile)) { + final ProjectFileIndex fileIndex = projectRootManager.getFileIndex(); + if (fileIndex.isInContent(vFile) && !fileIndex.isInLibraryClasses(vFile)) { return ImportPriority.PROJECT; } final Module module = ModuleUtilCore.findModuleForPsiElement(importLocation); diff --git a/python/testData/optimizeImports/libraryRootInsideProject/a.py b/python/testData/optimizeImports/libraryRootInsideProject/a.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testData/optimizeImports/libraryRootInsideProject/lib/b.py b/python/testData/optimizeImports/libraryRootInsideProject/lib/b.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/testData/optimizeImports/libraryRootInsideProject/main.after.py b/python/testData/optimizeImports/libraryRootInsideProject/main.after.py new file mode 100644 index 000000000000..f69993a00d48 --- /dev/null +++ b/python/testData/optimizeImports/libraryRootInsideProject/main.after.py @@ -0,0 +1,5 @@ +import b + +import a + +print(a, b) diff --git a/python/testData/optimizeImports/libraryRootInsideProject/main.py b/python/testData/optimizeImports/libraryRootInsideProject/main.py new file mode 100644 index 000000000000..8a707f2b825d --- /dev/null +++ b/python/testData/optimizeImports/libraryRootInsideProject/main.py @@ -0,0 +1,4 @@ +import a +import b + +print(a, b) diff --git a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java index 668b53d84186..c812c354c016 100644 --- a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java +++ b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java @@ -17,7 +17,13 @@ package com.jetbrains.python; import com.intellij.codeInsight.actions.OptimizeImportsAction; import com.intellij.ide.DataManager; +import com.intellij.openapi.application.WriteAction; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.SdkModificator; +import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.vfs.VirtualFile; import com.jetbrains.python.fixtures.PyTestCase; +import com.jetbrains.python.sdk.PythonSdkType; /** * @author yole @@ -95,6 +101,38 @@ public class PyOptimizeImportsTest extends PyTestCase { doTest(); } + // PY-18970 + public void testLibraryRootInsideProject() { + final String testName = getTestName(true); + myFixture.copyDirectoryToProject(testName, ""); + final VirtualFile libDir = myFixture.findFileInTempDir("lib"); + assertNotNull(libDir); + + final Sdk sdk = PythonSdkType.findPythonSdk(myFixture.getModule()); + assertNotNull(sdk); + WriteAction.run(() -> { + final SdkModificator modificator = sdk.getSdkModificator(); + assertNotNull(modificator); + modificator.addRoot(libDir, OrderRootType.CLASSES); + modificator.commitChanges(); + }); + + try { + myFixture.configureByFile("main.py"); + OptimizeImportsAction.actionPerformedImpl(DataManager.getInstance().getDataContext(myFixture.getEditor().getContentComponent())); + myFixture.checkResultByFile(testName + "/main.after.py"); + } + finally { + //noinspection ThrowFromFinallyBlock + WriteAction.run(() -> { + final SdkModificator modificator = sdk.getSdkModificator(); + assertNotNull(modificator); + modificator.removeRoot(libDir, OrderRootType.CLASSES); + modificator.commitChanges(); + }); + } + } + private void doTest() { myFixture.configureByFile(getTestName(true) + ".py"); OptimizeImportsAction.actionPerformedImpl(DataManager.getInstance().getDataContext(myFixture.getEditor().getContentComponent()));