Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Batkovich
2016-05-05 09:31:35 +03:00
137 changed files with 1230 additions and 765 deletions
+10
View File
@@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="bouncy-castle">
<CLASSES>
<root url="jar://$PROJECT_DIR$/android/android/lib/bcpkix-jdk15on-1.48.jar!/" />
<root url="jar://$PROJECT_DIR$/android/android/lib/bcprov-jdk15on-1.48.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+1 -1
View File
@@ -1,7 +1,7 @@
<component name="libraryTable">
<library name="builder-model">
<CLASSES>
<root url="jar://$PROJECT_DIR$/android/android/lib/builder-model-1.4.0-beta2.jar!/" />
<root url="jar://$PROJECT_DIR$/android/android/lib/builder-model-2.0.0-alpha7.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
+12
View File
@@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="commons-compress">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/commons-compress-1.10.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/commons-compress-1.10-src.zip!/commons-compress-1.10-src/src/main/java" />
<root url="jar://$PROJECT_DIR$/lib/src/commons-compress-1.10-src.zip!/commons-compress-1.10-src/src/test/java" />
</SOURCES>
</library>
</component>
+9
View File
@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="jgraphx-3.4.0.1">
<CLASSES>
<root url="jar://$PROJECT_DIR$/android/android/lib/jgraphx-3.4.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+9
View File
@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="truth">
<CLASSES>
<root url="jar://$PROJECT_DIR$/android/android/lib/truth-0.28.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+5
View File
@@ -113,6 +113,10 @@
<module fileurl="file://$PROJECT_DIR$/images/images.iml" filepath="$PROJECT_DIR$/images/images.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/indexing-api/indexing-api.iml" filepath="$PROJECT_DIR$/platform/indexing-api/indexing-api.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/platform/indexing-impl/indexing-impl.iml" filepath="$PROJECT_DIR$/platform/indexing-impl/indexing-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/instant-run/instant-run-annotations/instant-run-annotations.iml" filepath="$PROJECT_DIR$/android/tools-base/instant-run/instant-run-annotations/instant-run-annotations.iml" group="android/sdktools/instant-run" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/instant-run/instant-run-client/instant-run-client.iml" filepath="$PROJECT_DIR$/android/tools-base/instant-run/instant-run-client/instant-run-client.iml" group="android/sdktools/instant-run" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/instant-run/instant-run-common/instant-run-common.iml" filepath="$PROJECT_DIR$/android/tools-base/instant-run/instant-run-common/instant-run-common.iml" group="android/sdktools/instant-run" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/instant-run/instant-run-runtime/instant-run-runtime.iml" filepath="$PROJECT_DIR$/android/tools-base/instant-run/instant-run-runtime/instant-run-runtime.iml" group="android/sdktools/instant-run" />
<module fileurl="file://$PROJECT_DIR$/java/compiler/instrumentation-util/instrumentation-util.iml" filepath="$PROJECT_DIR$/java/compiler/instrumentation-util/instrumentation-util.iml" group="java/compiler" />
<module fileurl="file://$PROJECT_DIR$/java/compiler/instrumentation-util-8/instrumentation-util-8.iml" filepath="$PROJECT_DIR$/java/compiler/instrumentation-util-8/instrumentation-util-8.iml" group="java/compiler" />
<module fileurl="file://$PROJECT_DIR$/plugins/IntelliLang/intellilang-jps-plugin/intellilang-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/IntelliLang/intellilang-jps-plugin/intellilang-jps-plugin.iml" group="jps" />
@@ -218,6 +222,7 @@
<module fileurl="file://$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" filepath="$PROJECT_DIR$/platform/remote-servers/impl/remote-servers-impl.iml" group="platform" />
<module fileurl="file://$PROJECT_DIR$/java/remote-servers/api/remote-servers-java-api.iml" filepath="$PROJECT_DIR$/java/remote-servers/api/remote-servers-java-api.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/java/remote-servers/impl/remote-servers-java-impl.iml" filepath="$PROJECT_DIR$/java/remote-servers/impl/remote-servers-java-impl.iml" group="java" />
<module fileurl="file://$PROJECT_DIR$/android/tools-base/repository/repository.iml" filepath="$PROJECT_DIR$/android/tools-base/repository/repository.iml" group="android/sdktools" />
<module fileurl="file://$PROJECT_DIR$/resources/resources.iml" filepath="$PROJECT_DIR$/resources/resources.iml" />
<module fileurl="file://$PROJECT_DIR$/resources-en/resources-en.iml" filepath="$PROJECT_DIR$/resources-en/resources-en.iml" />
<module fileurl="file://$PROJECT_DIR$/python/rest/rest.iml" filepath="$PROJECT_DIR$/python/rest/rest.iml" group="python" />
+6
View File
@@ -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")
+2
View File
@@ -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")
@@ -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.*
@@ -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
@@ -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<String, String> 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());
}
}
@@ -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));
}
@@ -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
@@ -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);
}
@@ -217,31 +217,32 @@ public class JavaPushDownDelegate extends PushDownDelegate<MemberInfo, PsiMember
PsiMethod methodBySignature = MethodSignatureUtil.findMethodBySuperSignature(targetClass, method.getSignature(substitutor), false);
if (methodBySignature == null) {
newMember = (PsiMethod)targetClass.add(method);
if (sourceClass.isInterface()) {
if (!targetClass.isInterface()) {
PsiUtil.setModifierProperty(newMember, PsiModifier.PUBLIC, true);
if (newMember.hasModifierProperty(PsiModifier.DEFAULT)) {
PsiUtil.setModifierProperty(newMember, PsiModifier.DEFAULT, false);
}
else {
PsiUtil.setModifierProperty(newMember, PsiModifier.ABSTRACT, true);
}
final PsiMethod oldMethod = (PsiMethod)memberInfo.getMember();
if (sourceClass.isInterface() && !targetClass.isInterface()) {
PsiUtil.setModifierProperty(newMember, PsiModifier.PUBLIC, true);
if (oldMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
RefactoringUtil.makeMethodAbstract(targetClass, (PsiMethod)newMember);
}
else {
PsiUtil.setModifierProperty(newMember, PsiModifier.DEFAULT, false);
}
}
else if (memberInfo.isToAbstract()) {
if (memberInfo.isToAbstract()) {
if (newMember.hasModifierProperty(PsiModifier.PRIVATE)) {
PsiUtil.setModifierProperty(newMember, PsiModifier.PROTECTED, true);
}
pushDownData.getCommentPolicy().processNewJavaDoc(((PsiMethod)newMember).getDocComment());
}
if (memberInfo.isToAbstract()) {
OverrideImplementUtil.annotateOnOverrideImplement((PsiMethod)newMember, targetClass, (PsiMethod)memberInfo.getMember());
}
}
else { //abstract method: remove @Override
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(methodBySignature, "java.lang.Override");
if (annotation != null && !leaveOverrideAnnotation(sourceClass, substitutor, method)) {
annotation.delete();
if (!memberInfo.isToAbstract()) {
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(methodBySignature, "java.lang.Override");
if (annotation != null && !leaveOverrideAnnotation(sourceClass, substitutor, method)) {
annotation.delete();
}
}
final PsiDocComment oldDocComment = method.getDocComment();
if (oldDocComment != null) {
@@ -309,6 +310,9 @@ public class JavaPushDownDelegate extends PushDownDelegate<MemberInfo, PsiMember
if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
PsiUtil.setModifierProperty(method, PsiModifier.PROTECTED, true);
}
if (method.hasModifierProperty(PsiModifier.DEFAULT)) {
PsiUtil.setModifierProperty(method, PsiModifier.DEFAULT, false);
}
RefactoringUtil.makeMethodAbstract((PsiClass)pushDownData.getSourceClass(), method);
pushDownData.getCommentPolicy().processOldJavaDoc(method.getDocComment());
}
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.MethodSignatureUtil;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.refactoring.util.RefactoringConflictsUtil;
@@ -157,7 +158,7 @@ public class PushDownConflicts {
assert modifierList != null;
if (!modifierList.hasModifierProperty(PsiModifier.ABSTRACT)) {
PsiMethod method = (PsiMethod)movedMember;
final PsiMethod overrider = targetClass.findMethodBySignature(method, false);
final PsiMethod overrider = MethodSignatureUtil.findMethodBySuperMethod(targetClass, method, false);
if (overrider != null) {
String message = RefactoringBundle.message("0.is.already.overridden.in.1",
RefactoringUIUtil.getDescription(method, true), RefactoringUIUtil.getDescription(targetClass, false));
@@ -803,17 +803,39 @@ public class RefactoringUtil {
final PsiElementFactory factory) {
final Map<PsiElement, PsiElement> replacement = new LinkedHashMap<PsiElement, PsiElement>();
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<T>
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<List<T> 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));
}
}
}
@@ -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();
@@ -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 {
@@ -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<Match> getDuplicates();
@@ -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);
@@ -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());
}
}
@@ -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<PsiClassType>());
}
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<PsiClassType> 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);
}
@@ -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) {
@@ -0,0 +1,7 @@
class Test {
<T extends S, S extends Long, K extends Long & Runnable> void method1(T param, S param1, K param2) {
long l = param;
long l1 = param1;
long l2 = param2;
}
}
@@ -0,0 +1,8 @@
import java.util.ArrayList;
class Test {
Object foo() {
Object list = <selection>new ArrayList<String>();</selection>
return list;
}
}
@@ -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<String>();
}
}
@@ -0,0 +1,11 @@
class Parent<T> {
public void fo<caret>o(T p) {
System.out.println("a");
}
}
class Child extends Parent {
public void foo(Object p) {
System.out.println("b");
}
}
@@ -0,0 +1,8 @@
class Parent<T> {
}
class Child extends Parent {
public void foo(Object p) {
System.out.println("b");
}
}
@@ -0,0 +1,7 @@
interface A {
default void fo<caret>o() {
System.out.println();
}
}
class B implements A {}
@@ -0,0 +1,7 @@
interface Test {
default void foo() {
System.out.println();
}
}
class B implements Test {}
@@ -0,0 +1,10 @@
interface Test {
void foo();
}
class B implements Test {
@Override
public void foo() {
System.out.println();
}
}
@@ -0,0 +1,8 @@
interface A {
}
class B implements A {
public void foo() {
System.out.println();
}
}
@@ -0,0 +1,7 @@
interface A {
default void f<caret>oo() {
System.out.println("");
}
}
interface B extends A {}
@@ -0,0 +1,7 @@
interface Test {
default void foo() {
System.out.println();
}
}
interface A extends Test {}
@@ -0,0 +1,10 @@
interface Test {
void foo();
}
interface A extends Test {
@Override
default void foo() {
System.out.println();
}
}
@@ -0,0 +1,8 @@
interface A {
}
interface B extends A {
default void foo() {
System.out.println("");
}
}
@@ -0,0 +1,9 @@
import java.util.*;
class A<T> {
<S extends T, K extends List<List<T>>> <caret>foo(List<? extends T> l1, List<? extends S> l2, List<? extends K> l3, S s, K k, T t) {
Collections.<T>emptyList();
}
}
class B extends A {}
@@ -0,0 +1,10 @@
import java.util.*;
class A<T> {
}
class B extends A {
<S extends Object, K extends List> B(List l1, List<? extends S> l2, List<? extends K> l3, S s, K k, Object t) {
Collections.emptyList();
}
}
@@ -5,6 +5,6 @@ interface Base {
}
}
class Child implements Base {
abstract class Child implements Base {
public abstract void bar();
}
@@ -2,7 +2,7 @@ interface Test {
void bar();
}
class Child implements Test {
abstract class Child implements Test {
@Override
public abstract void bar();
}
@@ -0,0 +1,4 @@
interface A {
void fo<caret>o();
}
class B implements A {}
@@ -0,0 +1,5 @@
interface A {
}
abstract class B implements A {
public abstract void foo();
}
@@ -0,0 +1,7 @@
interface A {
static void f<caret>oo() {
System.out.println();
}
}
class B implements A {}
@@ -0,0 +1,8 @@
interface A {
}
class B implements A {
public static void foo() {
System.out.println();
}
}
@@ -0,0 +1,7 @@
interface A {
static void f<caret>oo() {
System.out.println();
}
}
interface B extends A {}
@@ -0,0 +1,8 @@
interface A {
}
interface B extends A {
static void foo() {
System.out.println();
}
}
@@ -0,0 +1,8 @@
abstract class Test {
/**
* foo's javadoc
*/
abstract void foo();
}
abstract class B extends Test {}
@@ -0,0 +1,11 @@
abstract class Test {
/**
* foo's javadoc
*/
abstract void foo();
}
abstract class B extends Test {
@Override
abstract void foo();
}
@@ -0,0 +1,8 @@
interface Test {
/**
* foo's javadoc
*/
void foo();
}
interface B extends Test {}
@@ -0,0 +1,11 @@
interface Test {
/**
* foo's javadoc
*/
void foo();
}
interface B extends Test {
@Override
void foo();
}
@@ -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");
}
}
@@ -0,0 +1,16 @@
interface Test {
/**
* some javadoc
*/
void foo();
}
class C implements Test {
/**
* another javadoc
*/
@Override
public void foo() {
System.out.println("C");
}
}
@@ -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());
@@ -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", "<caret>").getVirtualFile();
myFixture.configureFromExistingVirtualFile(file);
assertEmpty(myFixture.completeBasic());
LookupManager.getInstance(getProject()).hideActiveLookup();
WriteCommandAction.runWriteCommandAction(getProject(), (ThrowableComputable<Void, IOException>)() -> {
file.rename(this, "java.lang.Runnable");
return null;
});
myFixture.completeBasic();
myFixture.assertPreferredCompletionItems(0, "java.lang.Thread");
}
}
@@ -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<Map.Entry<Integer,Integer>> result = new Test(map).invoke();",
"Stream<Map.Entry<Integer,Integer>> result = new Test(map).invoke();",
"public class Test {\n" +
" private Map<Integer, Integer> map;\n" +
"\n" +
@@ -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();
}
@@ -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<PsiElement, String> 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<PsiElement, String> conflicts, UsageInfo[] usages) {
if (failure == conflicts.isEmpty()) {
fail(failure ? "Conflict was not detected" : "False conflict was detected");
}
return true;
}
}.run();
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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<DiffTool> 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<AnAction> viewerActions) {
DefaultActionGroup group = new DefaultActionGroup();
protected void collectToolbarActions(@Nullable List<AnAction> viewerActions) {
myToolbarGroup.removeAll();
List<AnAction> 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<AnAction> requestContextActions = myActiveRequest.getUserData(DiffUserDataKeys.CONTEXT_ACTIONS);
DiffUtil.addActionBlock(group, requestContextActions);
DiffUtil.addActionBlock(myToolbarGroup, requestContextActions);
List<AnAction> 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<AnAction> viewerActions) {
DefaultActionGroup group = new DefaultActionGroup();
protected void collectPopupActions(@Nullable List<AnAction> viewerActions) {
myPopupActionGroup.removeAll();
List<AnAction> 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<AnAction> 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<AnAction> 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);
@@ -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;
}
@@ -41,7 +41,7 @@ public class DiffSettingsConfigurable implements SearchableConfigurable {
@Nls
@Override
public String getDisplayName() {
return "Diff";
return "Diff & Merge";
}
@NotNull
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.diff.settings.DiffSettingsPanel">
<grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPane" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
@@ -10,7 +10,7 @@
<children>
<vspacer id="925fa">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="ad85b" class="com.intellij.ui.TitledSeparator">
@@ -18,7 +18,7 @@
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Default parameters:"/>
<text value="Diff"/>
</properties>
</component>
<component id="2cf1f" class="com.intellij.ui.components.JBLabel">
@@ -43,6 +43,22 @@
<text value="Go to the next file after reaching last change"/>
</properties>
</component>
<component id="48f3f" class="com.intellij.ui.TitledSeparator">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Merge"/>
</properties>
</component>
<component id="33e75" class="javax.swing.JCheckBox" binding="myAutoApplyNonConflictedChangesCheckbox">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Automatically apply non-conflicting changes"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -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() {
@@ -42,6 +42,8 @@ public class TextDiffSettingsHolder implements PersistentStateComponent<TextDiff
private final static class SharedSettings {
// Fragments settings
public int CONTEXT_RANGE = 4;
public boolean MERGE_AUTO_APPLY_NON_CONFLICTED_CHANGES = false;
}
private static class PlaceSettings {
@@ -107,6 +109,18 @@ public class TextDiffSettingsHolder implements PersistentStateComponent<TextDiff
PLACE_SETTINGS.IGNORE_POLICY = policy;
}
//
// Merge
//
public boolean isAutoApplyNonConflictedChanges() {
return SHARED_SETTINGS.MERGE_AUTO_APPLY_NON_CONFLICTED_CHANGES;
}
public void setAutoApplyNonConflictedChanges(boolean value) {
SHARED_SETTINGS.MERGE_AUTO_APPLY_NON_CONFLICTED_CHANGES = value;
}
// Editor settings
public boolean isShowLineNumbers() {
@@ -30,10 +30,9 @@ import com.intellij.diff.tools.util.SimpleDiffPanel;
import com.intellij.diff.tools.util.base.ListenerDiffViewerBase;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.util.ThreeSide;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.util.Disposer;
@@ -201,32 +200,27 @@ public abstract class ThreesideDiffViewer<T extends EditorHolder> 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
@@ -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
//
@@ -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" +
@@ -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<EditorHighlighter> EDITOR_HIGHLIGHTER = new Key<EditorHighlighter>("Editor");
private static final Map<FileType, DataIndexer<TodoIndexEntry, Integer, FileContent>> ourTodoIndexers = new HashMap<FileType, DataIndexer<TodoIndexEntry, Integer, FileContent>>();
private static final TokenSet ABSTRACT_FILE_COMMENT_TOKENS = TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT, CustomHighlighterTokenType.MULTI_LINE_COMMENT);
private PlatformIdTableBuilding() {}
@Nullable
public static DataIndexer<TodoIndexEntry, Integer, FileContent> getTodoIndexer(FileType fileType, final VirtualFile virtualFile) {
final DataIndexer<TodoIndexEntry, Integer, FileContent> indexer = ourTodoIndexers.get(fileType);
if (indexer != null) {
return indexer;
}
final DataIndexer<TodoIndexEntry, Integer, FileContent> 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<TodoIndexEntry, Integer, FileContent> 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 {
@@ -24,7 +24,7 @@ import com.intellij.util.indexing.FileContent;
* @author yole
*/
public class TodoIndexers extends FileTypeExtension<DataIndexer<TodoIndexEntry, Integer, FileContent>> {
public static TodoIndexers INSTANCE = new TodoIndexers();
public static final TodoIndexers INSTANCE = new TodoIndexers();
private TodoIndexers() {
super("com.intellij.todoIndexer");
@@ -80,6 +80,10 @@ public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunCo
return Arrays.asList(ModuleManager.getInstance(getProject()).getModules());
}
/**
* @deprecated method {@link com.intellij.execution.configurations.ConfigurationFactory#createTemplateConfiguration(com.intellij.openapi.project.Project)}
* would be used instead to avoid wrong custom 'cloning'
*/
protected ModuleBasedConfiguration createInstance() {
ModuleBasedConfiguration<ConfigurationModule> configuration =
(ModuleBasedConfiguration<ConfigurationModule>)getFactory().createTemplateConfiguration(getProject());
@@ -92,11 +96,11 @@ public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunCo
final Element element = new Element(TO_CLONE_ELEMENT_NAME);
try {
writeExternal(element);
final ModuleBasedConfiguration configuration = createInstance();
RunConfiguration configuration = getFactory().createTemplateConfiguration(getProject());
configuration.setName(getName());
configuration.readExternal(element);
return configuration;
return (ModuleBasedConfiguration)configuration;
} catch (InvalidDataException e) {
LOG.error(e);
return null;
@@ -723,14 +723,16 @@ public class CodeCompletionHandlerBase {
private static final Key<SoftReference<Pair<PsiFile, Document>>> 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<PsiFile, Document> 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();
@@ -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);
@@ -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<RunnerA
@Override
@NotNull
public JComponent createEditor() {
return myConfigEditor.getComponent();
JComponent component = myConfigEditor.getComponent();
if (myConfigEditor instanceof AdjustingTabSettingsEditor) {
JPanel panel = new JPanel(new BorderLayout());
UiNotifyConnector connector = new UiNotifyConnector(panel, new Activatable() {
private boolean myIsEmpty = true;
@Override
public void showNotify() {
if (myIsEmpty) {
panel.add(component, BorderLayout.CENTER);
panel.revalidate();
panel.repaint();
myIsEmpty = false;
}
}
@Override
public void hideNotify() {
if (!myIsEmpty) {
panel.removeAll();
panel.revalidate();
panel.repaint();
myIsEmpty = true;
}
}
});
Disposer.register(this, connector);
return panel;
}
return component;
}
@Override
@@ -13,10 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.debugger
package com.intellij.execution.ui;
import com.intellij.xdebugger.frame.XValueGroup
import com.intellij.openapi.options.SettingsEditor;
internal interface ValueGroupFactory<T> {
fun create(data: T, start: Int, end: Int, context: VariableContext): XValueGroup
}
/**
* 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 {
}
@@ -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]);
@@ -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));
}
}
}
@@ -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;
@@ -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)));
}
}
}
@@ -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 {
@@ -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;
}
}
@@ -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<HttpConfigurab
@Override
public void initComponent() {
final HttpConfigurable currentState = getState();
if (currentState != null) {
final Element serialized = XmlSerializer.serializeIfNotDefault(currentState, new SkipDefaultsSerializationFilter());
if (serialized == null) {
// all settings are defaults
// trying user's proxy configuration entered while obtaining the license
final SharedProxyConfig.ProxyParameters cfg = SharedProxyConfig.load();
if (cfg != null) {
SharedProxyConfig.clear();
if (cfg.host != null) {
USE_HTTP_PROXY = true;
PROXY_HOST = cfg.host;
PROXY_PORT = cfg.port;
if (cfg.login != null) {
setPlainProxyPassword(new String(cfg.password));
PROXY_LOGIN = cfg.login;
PROXY_AUTHENTICATION = true;
KEEP_PROXY_PASSWORD = true;
}
}
}
}
}
mySelector = new IdeaWideProxySelector(this);
String name = getClass().getName();
CommonProxy.getInstance().setCustom(name, mySelector);
@@ -377,4 +377,8 @@ public class CommonProxy extends ProxySelector {
return result;
}
}
}
@@ -0,0 +1,155 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.util.proxy;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.security.Key;
import java.security.SecureRandom;
import java.util.Properties;
public class SharedProxyConfig {
private static final File CONFIG_FILE = new File(PathManager.getConfigPath(), "proxy_config");
private static final String HOST = "host";
private static final String PORT = "port";
private static final String LOGIN = "login";
private static final String PASSWORD = "password";
private static final Key ENCRYPTION_KEY; // the key is valid for the same session only
static {
final byte[] bytes = new byte[16];
new SecureRandom().nextBytes(bytes);
ENCRYPTION_KEY = new SecretKeySpec(bytes, "AES");
}
public static final class ProxyParameters {
@Nullable
public final String host;
public final int port;
@Nullable
public final String login;
@NotNull
public final char[] password;
public ProxyParameters(@Nullable String host, int port) {
this(host, port, null, new char[0]);
}
public ProxyParameters(@Nullable String host, int port, @Nullable String login, @NotNull char[] password) {
this.host = host;
this.port = port;
this.login = login;
this.password = password;
}
}
public static boolean clear() {
return FileUtil.delete(CONFIG_FILE);
}
@Nullable
public static ProxyParameters load() {
try {
final byte[] bytes = decrypt(FileUtil.loadFileBytes(CONFIG_FILE));
final Properties props = new Properties();
props.load(new ByteArrayInputStream(bytes));
final String password = props.getProperty(PASSWORD, "");
return new ProxyParameters(
props.getProperty(HOST, null),
Integer.parseInt(props.getProperty(PORT, "0")),
props.getProperty(LOGIN, null),
password.toCharArray()
);
}
catch (Exception ignored) {
}
return null;
}
public static boolean store(@NotNull ProxyParameters params) {
if (params.host != null) {
try {
final Properties props = new Properties();
props.setProperty(HOST, params.host);
props.setProperty(PORT, String.valueOf(params.port));
if (params.login != null) {
props.setProperty(LOGIN, params.login);
props.setProperty(PASSWORD, new String(params.password));
}
final ByteArrayOutputStream out = new ByteArrayOutputStream();
props.store(out, "Proxy Configuration");
out.close();
FileUtil.writeToFile(CONFIG_FILE, encrypt(out.toByteArray()));
return true;
}
catch (Exception ignored) {
}
}
else {
FileUtil.delete(CONFIG_FILE);
}
return false;
}
private static byte[] encrypt(byte[] bytes) throws Exception {
return encrypt(bytes, ENCRYPTION_KEY);
}
private static byte[] decrypt(byte[] bytes) throws Exception {
return decrypt(bytes, ENCRYPTION_KEY);
}
private static byte[] encrypt(byte[] msgBytes, Key key) throws Exception {
final Cipher ciph = Cipher.getInstance("AES/CBC/PKCS5Padding");
ciph.init(Cipher.ENCRYPT_MODE, key);
final byte[] body = ciph.doFinal(msgBytes);
final byte[] iv = ciph.getIV();
final byte[] data = new byte[4 + iv.length + body.length];
final int length = body.length;
data[0] = (byte)((length >> 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);
}
}
@@ -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()) {
@@ -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());
}
}
@@ -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);
}
}
@@ -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;
}
@@ -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
@@ -98,6 +98,5 @@ public class KeyProcessorContext {
myActions.clear();
myFocusOwner = null;
myDataContext = null;
myFoundComponent = null;
}
}
@@ -111,7 +111,7 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr
}) {
@Override
protected boolean isActive() {
return isFocused();
return myToolWindow.isActive();
}
@Override
@@ -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
@@ -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
@@ -98,7 +98,7 @@
serviceImplementation="com.intellij.diff.tools.util.base.TextDiffSettingsHolder"/>
<applicationService serviceInterface="com.intellij.diff.tools.external.ExternalDiffSettings"
serviceImplementation="com.intellij.diff.tools.external.ExternalDiffSettings"/>
<applicationConfigurable groupId="tools" id="diff.base" displayName="Diff"
<applicationConfigurable groupId="tools" id="diff.base" displayName="Diff &amp; Merge"
instance="com.intellij.diff.settings.DiffSettingsConfigurable">
<configurable id="diff.external" displayName="External Diff Tools"
instance="com.intellij.diff.settings.ExternalDiffSettingsConfigurable"/>
@@ -202,6 +202,15 @@
<action id="Diff.IgnoreRightSide" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Diff.Remove"/>
<separator/>
<action id="Diff.ApplyNonConflicts" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Diff.ApplyNotConflicts"/>
<action id="Diff.ApplyNonConflicts.Left" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Diff.ApplyNotConflictsLeft"/>
<action id="Diff.ApplyNonConflicts.Right" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Diff.ApplyNotConflictsRight"/>
<action id="Diff.ComparePartial.Base.Left" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Diff.LeftDiff"/>
<action id="Diff.ComparePartial.Base.Right" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Diff.RightDiff"/>
<action id="Diff.ComparePartial.Left.Right" class="com.intellij.openapi.actionSystem.EmptyAction" icon="AllIcons.Diff.BranchDiff"/>
<separator/>
<action id="CompareDirs" class="com.intellij.diff.actions.CompareFilesAction" text="Compare Directories" use-shortcut-of="CompareTwoFiles"/>
<separator/>
@@ -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.
@@ -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<Variable>) {
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 {
@@ -28,13 +28,7 @@ internal class VariablesGroup(private val start: Int, private val end: Int, priv
}
}
internal val GROUP_FACTORY: ValueGroupFactory<List<Variable>> = object : ValueGroupFactory<List<Variable>> {
override fun create(data: List<Variable>, start: Int, end: Int, context: VariableContext): XValueGroup {
return createArrayRangeGroup(start, end, data, context)
}
}
private fun createArrayRangeGroup(start: Int, end: Int, variables: List<Variable>, variableContext: VariableContext): VariablesGroup {
internal fun createArrayRangeGroup(variables: List<Variable>, start: Int, end: Int, variableContext: VariableContext): VariablesGroup {
val name = "[" + variables[start].name + " \u2026 " + variables[end - 1].name + "]"
return VariablesGroup(start, end, variables, variableContext, name)
}

Some files were not shown because too many files have changed in this diff Show More