From 8ebe9dd200a1cd9ca61e7615385f55912dec0cef Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 26 May 2014 16:26:16 +0200 Subject: [PATCH 1/8] IDEA-125258 ("Unnecessary boxing" inspection is triggered wrongly with overloaded constructors) --- .../UnnecessaryBoxingInspection.java | 21 ++++++++-------- .../unnecessary_boxing/UnnecessaryBoxing.java | 25 +++++++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java index 4c2c44bfc326..84d8144f841d 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/migration/UnnecessaryBoxingInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2014 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -294,34 +294,35 @@ public class UnnecessaryBoxingInspection extends BaseInspection { return unboxedType != null && unboxedType.isAssignableFrom(rhsType); } } - final PsiMethodCallExpression containingMethodCallExpression = getParentMethodCallExpression(expression); + final PsiCallExpression containingMethodCallExpression = getParentMethodCallExpression(expression); return containingMethodCallExpression == null || isSameMethodCalledWithoutBoxing(containingMethodCallExpression, expression); } @Nullable - private PsiMethodCallExpression getParentMethodCallExpression(@NotNull PsiElement expression) { + private PsiCallExpression getParentMethodCallExpression(@NotNull PsiElement expression) { final PsiElement parent = expression.getParent(); if (parent instanceof PsiParenthesizedExpression || parent instanceof PsiExpressionList) { return getParentMethodCallExpression(parent); } - else if (parent instanceof PsiMethodCallExpression) { - return (PsiMethodCallExpression)parent; + else if (parent instanceof PsiCallExpression) { + return (PsiCallExpression)parent; } else { return null; } } - private boolean isSameMethodCalledWithoutBoxing(@NotNull PsiMethodCallExpression methodCallExpression, + private boolean isSameMethodCalledWithoutBoxing(@NotNull PsiCallExpression methodCallExpression, @NotNull PsiExpression boxingExpression) { final PsiExpressionList argumentList = methodCallExpression.getArgumentList(); + if (argumentList == null) { + return false; + } final PsiExpression[] expressions = argumentList.getExpressions(); - final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); - final PsiElement element = methodExpression.resolve(); - if (!(element instanceof PsiMethod)) { + final PsiMethod originalMethod = methodCallExpression.resolveMethod(); + if (originalMethod == null) { return false; } - final PsiMethod originalMethod = (PsiMethod)element; final String name = originalMethod.getName(); final PsiClass containingClass = originalMethod.getContainingClass(); if (containingClass == null) { diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/unnecessary_boxing/UnnecessaryBoxing.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/unnecessary_boxing/UnnecessaryBoxing.java index a25f0bcdb679..e9dcd5439f3d 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/unnecessary_boxing/UnnecessaryBoxing.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/migration/unnecessary_boxing/UnnecessaryBoxing.java @@ -54,4 +54,29 @@ public class UnnecessaryBoxing { } return null; } +} +class IntIntegerTest { + public IntIntegerTest(Integer val) { + System.out.println("behavoiur 1"); + } + + public IntIntegerTest(int val) { + System.out.println("behavoiur 2"); + } + + public static void f(Integer val) { + System.out.println("behavoiur 1"); + } + + public static void f(int val) { + System.out.println("behavoiur 2"); + } + + public IntIntegerTest() { + } + + public void test() { + new IntIntegerTest(new Integer(1)); // <-- incorrectly triggered + f(new Integer(1)); // <-- not triggered + } } \ No newline at end of file From 11202b97d23ce5b55d0db578ad929071fad2d29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Mon, 26 May 2014 16:44:33 +0200 Subject: [PATCH 2/8] DevKit: Goto EP declaration in plugin.xml (IDEA-86100) --- plugins/devkit/resources/META-INF/plugin.xml | 2 + ...larationRelatedItemLineMarkerProvider.java | 155 ++++++++++++++++++ .../extensionPointDeclaration/MyStringEP.java | 10 ++ .../MyStringEPConstructor.java | 11 ++ .../MyStringEPViaConstant.java | 12 ++ .../extensionPointDeclaration/plugin.xml | 10 ++ ...tionRelatedItemLineMarkerProviderTest.java | 61 +++++++ 7 files changed, 261 insertions(+) create mode 100644 plugins/devkit/src/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProvider.java create mode 100644 plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEP.java create mode 100644 plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPConstructor.java create mode 100644 plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPViaConstant.java create mode 100644 plugins/devkit/testData/navigation/extensionPointDeclaration/plugin.xml create mode 100644 plugins/devkit/testSources/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProviderTest.java diff --git a/plugins/devkit/resources/META-INF/plugin.xml b/plugins/devkit/resources/META-INF/plugin.xml index 88fadf52dc42..396d6209ff3d 100644 --- a/plugins/devkit/resources/META-INF/plugin.xml +++ b/plugins/devkit/resources/META-INF/plugin.xml @@ -166,6 +166,8 @@ + diff --git a/plugins/devkit/src/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProvider.java b/plugins/devkit/src/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProvider.java new file mode 100644 index 000000000000..deb75fda4354 --- /dev/null +++ b/plugins/devkit/src/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProvider.java @@ -0,0 +1,155 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.devkit.navigation; + +import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo; +import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider; +import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder; +import com.intellij.icons.AllIcons; +import com.intellij.navigation.GotoRelatedItem; +import com.intellij.openapi.editor.markup.GutterIconRenderer; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.util.Condition; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTypesUtil; +import com.intellij.util.NotNullFunction; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.devkit.util.ExtensionPointCandidate; +import org.jetbrains.idea.devkit.util.ExtensionPointLocator; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public class ExtensionPointDeclarationRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvider { + + private static final NotNullFunction> CONVERTER = + new NotNullFunction>() { + @NotNull + @Override + public Collection fun(ExtensionPointCandidate candidate) { + return Collections.singleton(candidate.pointer.getElement()); + } + }; + + private static final NotNullFunction> RELATED_ITEM_PROVIDER = + new NotNullFunction>() { + @NotNull + @Override + public Collection fun(ExtensionPointCandidate candidate) { + return GotoRelatedItem.createItems(Collections.singleton(candidate.pointer.getElement()), "DevKit"); + } + }; + + @Override + protected void collectNavigationMarkers(@NotNull PsiElement element, Collection result) { + if (element instanceof PsiField) { + process((PsiField)element, result); + } + } + + private static void process(PsiField psiField, Collection result) { + if (!isExtensionPointNameDeclarationField(psiField)) return; + + final PsiClass epClass = resolveExtensionPointClass(psiField); + if (epClass == null) return; + + final String epName = resolveEpName(psiField); + if (epName == null) return; + + + ExtensionPointLocator locator = new ExtensionPointLocator(epClass); + List targets = + ContainerUtil.filter(locator.findDirectCandidates(), new Condition() { + @Override + public boolean value(ExtensionPointCandidate candidate) { + return epName.equals(candidate.epName); + } + }); + + final RelatedItemLineMarkerInfo info = NavigationGutterIconBuilder + .create(AllIcons.Nodes.Plugin, CONVERTER, RELATED_ITEM_PROVIDER) + .setTargets(targets) + .setPopupTitle("Choose Extension Point") + .setTooltipText("Extension Point Declaration") + .setAlignment(GutterIconRenderer.Alignment.RIGHT) + .createLineMarkerInfo(psiField.getNameIdentifier()); + result.add(info); + } + + @Nullable + private static PsiClass resolveExtensionPointClass(PsiField psiField) { + final PsiClassType type = (PsiClassType)psiField.getType(); + final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics(); + final PsiClass psiClass = resolveResult.getElement(); + if (psiClass == null) return null; + final PsiTypeParameter[] parameters = psiClass.getTypeParameters(); + if (parameters.length != 1) return null; + final PsiTypeParameter parameter = parameters[0]; + final PsiSubstitutor substitutor = resolveResult.getSubstitutor(); + final PsiType substituteType = substitutor.substitute(parameter); + return PsiTypesUtil.getPsiClass(substituteType); + } + + private static String resolveEpName(PsiField psiField) { + final PsiExpression initializer = psiField.getInitializer(); + + PsiExpressionList expressionList = null; + if (initializer instanceof PsiMethodCallExpression) { + expressionList = ((PsiMethodCallExpression)initializer).getArgumentList(); + } + else if (initializer instanceof PsiNewExpression) { + expressionList = ((PsiNewExpression)initializer).getArgumentList(); + } + if (expressionList == null) return null; + + final PsiExpression[] expressions = expressionList.getExpressions(); + if (expressions.length != 1) return null; + + final PsiExpression epNameExpression = expressions[0]; + final PsiConstantEvaluationHelper helper = JavaPsiFacade.getInstance(psiField.getProject()).getConstantEvaluationHelper(); + final Object o = helper.computeConstantExpression(epNameExpression); + return o instanceof String ? (String)o : null; + } + + private static boolean isExtensionPointNameDeclarationField(PsiField psiField) { + // *do* allow non-public + if (!psiField.hasModifierProperty(PsiModifier.FINAL) || + !psiField.hasModifierProperty(PsiModifier.STATIC) || + psiField.hasModifierProperty(PsiModifier.ABSTRACT)) { + return false; + } + + if (!psiField.hasInitializer()) { + return false; + } + + final PsiExpression initializer = psiField.getInitializer(); + if (!(initializer instanceof PsiMethodCallExpression) && + !(initializer instanceof PsiNewExpression)) { + return false; + } + + final PsiClass fieldClass = PsiTypesUtil.getPsiClass(psiField.getType()); + if (fieldClass == null) { + return false; + } + + return ExtensionPointName.class.getName().equals(fieldClass.getQualifiedName()); + } +} diff --git a/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEP.java b/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEP.java new file mode 100644 index 000000000000..23891c6d0158 --- /dev/null +++ b/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEP.java @@ -0,0 +1,10 @@ +import com.intellij.openapi.extensions.ExtensionPointName; + +import java.lang.String; + +public class MyStringEP { + + public static final ExtensionPointName EP_NAME = + ExtensionPointName.create("com.intellij.myStringEP"); + +} \ No newline at end of file diff --git a/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPConstructor.java b/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPConstructor.java new file mode 100644 index 000000000000..a0dc902ad0f8 --- /dev/null +++ b/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPConstructor.java @@ -0,0 +1,11 @@ +import com.intellij.openapi.extensions.ExtensionPointName; + +import java.lang.String; + +public class MyStringEPConstructor { + + // private is allowed + private static final ExtensionPointName EP_NAME = + new ExtensionPointName("com.intellij.myStringEP"); + +} \ No newline at end of file diff --git a/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPViaConstant.java b/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPViaConstant.java new file mode 100644 index 000000000000..15c7ea02dff4 --- /dev/null +++ b/plugins/devkit/testData/navigation/extensionPointDeclaration/MyStringEPViaConstant.java @@ -0,0 +1,12 @@ +import com.intellij.openapi.extensions.ExtensionPointName; + +import java.lang.String; + +public class MyStringEPViaConstant { + + public static final String EP_ID = "com.intellij.myStringEP"; + + public static final ExtensionPointName EP_NAME = + ExtensionPointName.create(EP_ID); + +} \ No newline at end of file diff --git a/plugins/devkit/testData/navigation/extensionPointDeclaration/plugin.xml b/plugins/devkit/testData/navigation/extensionPointDeclaration/plugin.xml new file mode 100644 index 000000000000..6de1e0e4756a --- /dev/null +++ b/plugins/devkit/testData/navigation/extensionPointDeclaration/plugin.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/plugins/devkit/testSources/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProviderTest.java b/plugins/devkit/testSources/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProviderTest.java new file mode 100644 index 000000000000..220c1959fd36 --- /dev/null +++ b/plugins/devkit/testSources/navigation/ExtensionPointDeclarationRelatedItemLineMarkerProviderTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.devkit.navigation; + +import com.intellij.codeInsight.daemon.GutterMark; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.testFramework.TestDataPath; +import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; +import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; +import com.intellij.util.PathUtil; + +@TestDataPath("$CONTENT_ROOT/testData/navigation/extensionPointDeclaration") +public class ExtensionPointDeclarationRelatedItemLineMarkerProviderTest extends JavaCodeInsightFixtureTestCase { + + @Override + protected String getBasePath() { + return PluginPathManager.getPluginHomePathRelative("devkit") + "/testData/navigation/extensionPointDeclaration"; + } + + @Override + protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) throws Exception { + String pathForClass = PathUtil.getJarPathForClass(ExtensionPointName.class); + moduleBuilder.addLibrary("extensions", pathForClass); + } + + public void testMyStringEP() { + assertSingleEPDeclaration("MyStringEP.java"); + } + + public void testMyStringEPViaConstant() { + assertSingleEPDeclaration("MyStringEPViaConstant.java"); + } + + public void testMyStringEPConstructor() { + assertSingleEPDeclaration("MyStringEPConstructor.java"); + } + + private void assertSingleEPDeclaration(String filePath) { + myFixture.configureByFile("plugin.xml"); // index + + final GutterMark gutter = myFixture.findGutter(filePath); + DevKitGutterTargetsChecker.checkGutterTargets(gutter, "Extension Point Declaration", + AllIcons.Nodes.Plugin, + "extensionPoint"); + } +} \ No newline at end of file From d0891b3ae564f7ada67df8e4ff7917fb6e38e205 Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Mon, 26 May 2014 16:23:38 +0200 Subject: [PATCH 3/8] IDEA-125580 - OpenShift: cloning application hangs if switch to another process --- .../util/CloudGitDeploymentRuntime.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java index f5b55cdf767c..74c023241847 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java @@ -144,13 +144,7 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { } public void downloadExistingApplication() throws ServerRuntimeException { - CloudGitApplication application = findApplication(); - if (application == null) { - throw new ServerRuntimeException("Can't find the application: " + getApplicationName()); - } - - new CloneJobWithRemote().cloneToModule(application.getGitUrl()); - + new CloneJobWithRemote().cloneToModule(getApplication().getGitUrl()); getRepository().update(); refreshContentRoot(); } @@ -232,8 +226,13 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { } protected void pushApplication(@NotNull CloudGitApplication application) throws ServerRuntimeException { + push(application, getRepository(), getRemoteName()); + } + + protected void push(@NotNull CloudGitApplication application, @NotNull GitRepository repository, @NotNull String remote) + throws ServerRuntimeException { GitCommandResult gitPushResult - = getGit().push(getRepository(), getRemoteName(), application.getGitUrl(), "master:master", createGitLineHandlerListener()); + = getGit().push(repository, remote, application.getGitUrl(), "master:master", createGitLineHandlerListener()); checkGitResult(gitPushResult); } @@ -250,6 +249,7 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { final VirtualFile contentRoot = getRepositoryRoot(); GitRepository repository = getRepository(); final GitLineHandler fetchHandler = new GitLineHandler(getProject(), contentRoot, GitCommand.FETCH); + fetchHandler.setUrl(getApplication().getGitUrl()); fetchHandler.setSilent(false); fetchHandler.addParameters(getRemoteName()); fetchHandler.addLineListener(createGitLineHandlerListener()); @@ -333,6 +333,11 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { }); } + public void fetchAndRefresh() throws ServerRuntimeException { + fetch(); + refreshContentRoot(); + } + private String getRemoteName() { if (myRemoteName == null) { myRemoteName = myDefaultRemoteName; @@ -354,6 +359,14 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime { }); } + protected CloudGitApplication getApplication() throws ServerRuntimeException { + CloudGitApplication application = findApplication(); + if (application == null) { + throw new ServerRuntimeException("Can't find the application: " + getApplicationName()); + } + return application; + } + protected CloudGitApplication createApplication() throws ServerRuntimeException { return getAgentTaskExecutor().execute(new Computable() { From 740b6b193732e6ef8fe240376e4bdcdf17571e95 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Mon, 26 May 2014 18:59:33 +0400 Subject: [PATCH 4/8] [log] IDEA-125578 Handle empty permanent graph --- .../com/intellij/vcs/log/data/DataPack.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java index a3cb610d42d6..48b25be01ab9 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/DataPack.java @@ -26,20 +26,10 @@ public class DataPack implements VcsLogDataPack { private boolean myFull; @NotNull - static DataPack build(@NotNull List> commits, - @NotNull RefsModel refsModel, - @NotNull NotNullFunction indexGetter, - @NotNull NotNullFunction hashGetter, - @NotNull Map providers, - boolean full) { - PermanentGraph permanentGraph; - if (!commits.isEmpty()) { - permanentGraph = buildPermanentGraph(commits, refsModel, indexGetter, hashGetter, providers); - } - else { - permanentGraph = EmptyPermanentGraph.getInstance(); - } - return build(permanentGraph, providers, refsModel, full); + static DataPack build(@NotNull List> commits, @NotNull RefsModel refsModel, + @NotNull NotNullFunction indexGetter, @NotNull NotNullFunction hashGetter, + @NotNull Map providers, boolean full) { + return build(buildPermanentGraph(commits, refsModel, indexGetter, hashGetter, providers), providers, refsModel, full); } @NotNull @@ -72,6 +62,9 @@ public class DataPack implements VcsLogDataPack { @NotNull NotNullFunction indexGetter, @NotNull NotNullFunction hashGetter, @NotNull Map providers) { + if (commits.isEmpty()) { + return EmptyPermanentGraph.getInstance(); + } GraphColorManagerImpl colorManager = new GraphColorManagerImpl(refsModel, hashGetter, getRefManagerMap(providers)); Set branches = getBranchCommitHashIndexes(refsModel.getAllRefs(), indexGetter); StopWatch sw = StopWatch.start("building graph"); From c6be0ae1cecd66bf99d3c8c7524e13dd0ef463ef Mon Sep 17 00:00:00 2001 From: Vyacheslav Karpukhin Date: Mon, 26 May 2014 19:00:32 +0400 Subject: [PATCH 5/8] XBreakpointUtil.getShortText() shortens text now --- .../intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java index 47062d1834dc..7bfc31989e3b 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointUtil.java @@ -23,6 +23,7 @@ import com.intellij.openapi.editor.FoldRegion; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.xdebugger.XDebuggerManager; import com.intellij.xdebugger.XDebuggerUtil; @@ -48,7 +49,7 @@ public class XBreakpointUtil { } public static > String getShortText(B breakpoint) { - return getType(breakpoint).getShortText(breakpoint); + return StringUtil.shortenTextWithEllipsis(StringUtil.notNullize(getType(breakpoint).getShortText(breakpoint)), 70, 5); } public static > String getDisplayText(@NotNull B breakpoint) { From a41ecf9164bc6d969de2834e6e5cf3ae3ab4fe26 Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Mon, 26 May 2014 19:02:58 +0400 Subject: [PATCH 6/8] IDEA-123466 Sheet dialogs doesn't transfer focus back then closed --- .../src/com/intellij/ui/messages/SheetMessage.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java index 688c07f72062..8acfaa04edb5 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java @@ -32,6 +32,7 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -53,6 +54,8 @@ public class SheetMessage { private int imageHeight; private boolean restoreFullscreenButton; + private final WeakReference beforeShowFocusOwner; + public SheetMessage(final Window owner, final String title, final String message, @@ -62,6 +65,10 @@ public class SheetMessage { final String defaultButton, final String focusedButton) { + beforeShowFocusOwner = new WeakReference( + KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow().getMostRecentFocusOwner() + ); + myWindow = new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL); myWindow.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE); @@ -109,6 +116,7 @@ public class SheetMessage { LaterInvocator.enterModal(myWindow); myWindow.setVisible(true); LaterInvocator.leaveModal(myWindow); + beforeShowFocusOwner.get().requestFocus(); } private void setWindowOpacity(float opacity) { From fada6f1910dd1d73b7de2c030f877b14e5e361f7 Mon Sep 17 00:00:00 2001 From: Alexey Ushakov Date: Fri, 23 May 2014 11:18:37 +0400 Subject: [PATCH 7/8] Add temporary api to allow custom initialization of debug session data --- .../XDebugProcessConfiguratorStarter.java | 26 +++++++++++++++++++ .../xdebugger/impl/XDebuggerManagerImpl.java | 8 ++++++ 2 files changed, 34 insertions(+) create mode 100644 platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugProcessConfiguratorStarter.java diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugProcessConfiguratorStarter.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugProcessConfiguratorStarter.java new file mode 100644 index 000000000000..276814caf569 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugProcessConfiguratorStarter.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.impl; + +import com.intellij.xdebugger.XDebugProcessStarter; +import com.intellij.xdebugger.impl.ui.XDebugSessionData; + +/** + * Created by avu on 22/05/14. + */ +public abstract class XDebugProcessConfiguratorStarter extends XDebugProcessStarter { + public abstract void configure(XDebugSessionData data); +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index 04ab04f10600..3afd27f7f60f 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -201,7 +201,15 @@ public class XDebuggerManagerImpl extends XDebuggerManager if (oldSessionData == null) { oldSessionData = new XDebugSessionData(); } + + // Perform custom configuration of session data for XDebugProcessConfiguratorStarter classes + if (processStarter instanceof XDebugProcessConfiguratorStarter) { + session.activateSession(); + ((XDebugProcessConfiguratorStarter)processStarter).configure(oldSessionData); + } + session.init(process, oldSessionData); + mySessions.put(session.getDebugProcess().getProcessHandler(), session); return session; From c2ad3ae4f8dfdde22fe9057ac806682cf6285c22 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 26 May 2014 19:25:44 +0400 Subject: [PATCH 8/8] IDEA-119640 Problem with goto declaration of XML attribute defined in XSD --- .../daemon/XmlHighlightingTest.java | 38 +++++++++++++------ .../xml/AnyAttributeNavigation/library.xsd | 12 ++++++ .../xml/AnyAttributeNavigation/test.xml | 4 ++ .../xml/AnyAttributeNavigation/test.xsd | 15 ++++++++ .../impl/schema/XmlElementDescriptorImpl.java | 5 +++ 5 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 xml/tests/testData/xml/AnyAttributeNavigation/library.xsd create mode 100644 xml/tests/testData/xml/AnyAttributeNavigation/test.xml create mode 100644 xml/tests/testData/xml/AnyAttributeNavigation/test.xsd diff --git a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java index 774eb1a450eb..7b9cc1404d02 100644 --- a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java +++ b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java @@ -1437,7 +1437,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); configureByFiles(null, getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location)); - doDoTest(true,false); + doDoTest(true, false); } @@ -1528,7 +1528,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testEncoding() throws Exception { doTest(true); } public void testSchemaImportHighlightingAndResolve() throws Exception { - doTestWithLocations(new String[][] { {"http://www.springframework.org/schema/beans", "ComplexSchemaValidation11.xsd"} },"xsd"); + doTestWithLocations(new String[][]{{"http://www.springframework.org/schema/beans", "ComplexSchemaValidation11.xsd"}}, "xsd"); } public void testDocBookV5() throws Exception { @@ -1731,7 +1731,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { {"http://extended", testName + ".xsd"}, {"http://simple", testName + "_2.xsd"} }; - doTestWithLocations(urls,"xml"); + doTestWithLocations(urls, "xml"); } public void testComplexRedefine6() throws Exception { @@ -1839,7 +1839,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { Collection infos = doDoTest(true, false); findAndInvokeIntentionAction(infos, "Change Root Tag Name to xxx", myEditor, myFile); - checkResultByFile(BASE_PATH + testName+"_after.xml"); + checkResultByFile(BASE_PATH + testName + "_after.xml"); } public void testUnqualifiedAttributePsi() throws Exception { @@ -1847,7 +1847,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final List attrs = new ArrayList(2); myFile.acceptChildren(new XmlRecursiveElementVisitor() { - @Override public void visitXmlAttribute(final XmlAttribute attribute) { + @Override + public void visitXmlAttribute(final XmlAttribute attribute) { if (!attribute.isNamespaceDeclaration()) attrs.add(attribute); } }); @@ -1876,7 +1877,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final String testName = getTestName(false); doTest( - new VirtualFile[] { + new VirtualFile[]{ getVirtualFile(BASE_PATH + testName + ".xml"), getVirtualFile(BASE_PATH + testName + ".xsd") }, @@ -1921,7 +1922,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { } public void testProblemWithImportedNsReference() throws Exception { - doTestWithLocations(null,"xsd"); + doTestWithLocations(null, "xsd"); } public void testBadXmlns() throws Exception { @@ -1930,7 +1931,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { } public void testProblemWithMemberTypes() throws Exception { - doTestWithLocations(null,"xsd"); + doTestWithLocations(null, "xsd"); } public void testDtdHighlighting() throws Exception { @@ -1948,7 +1949,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final String testName = getTestName(false); doTest( - new VirtualFile[] { + new VirtualFile[]{ getVirtualFile(BASE_PATH + testName + ".xml"), getVirtualFile(BASE_PATH + testName + ".xsd") }, @@ -1978,13 +1979,13 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testMappedSchemaLocation() throws Exception { doTestWithLocations(new String[][]{ - { "schemas/Forms.xsd", "Forms.xsd"} + {"schemas/Forms.xsd", "Forms.xsd"} }, "xml"); } public void testMuleConfigValidation() throws Exception { doSchemaTestWithManyFilesFromSeparateDir( - new String[][] { + new String[][]{ {"http://www.springframework.org/schema/tool", "spring-tool-2.5.xsd"}, {"http://www.springframework.org/schema/beans/spring-beans-2.5.xsd", "spring-beans-2.5.xsd"}, {"http://www.mulesource.org/schema/mule/core/2.2/mule.xsd", "mule.xsd"}, @@ -2034,6 +2035,21 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { ); } + public void testAnyAttributeNavigation() throws Exception { + doTest( + new VirtualFile[] { + getVirtualFile(BASE_PATH + "AnyAttributeNavigation/test.xml"), + getVirtualFile(BASE_PATH + "AnyAttributeNavigation/test.xsd"), + getVirtualFile(BASE_PATH + "AnyAttributeNavigation/library.xsd") + }, + true, + false + ); + PsiReference at = getFile().findReferenceAt(getEditor().getCaretModel().getOffset()); + PsiElement resolve = at.resolve(); + assertTrue(resolve instanceof XmlTag); + } + @Override protected void setUp() throws Exception { super.setUp(); diff --git a/xml/tests/testData/xml/AnyAttributeNavigation/library.xsd b/xml/tests/testData/xml/AnyAttributeNavigation/library.xsd new file mode 100644 index 000000000000..22cf74a1e059 --- /dev/null +++ b/xml/tests/testData/xml/AnyAttributeNavigation/library.xsd @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/xml/tests/testData/xml/AnyAttributeNavigation/test.xml b/xml/tests/testData/xml/AnyAttributeNavigation/test.xml new file mode 100644 index 000000000000..a2f034714cfe --- /dev/null +++ b/xml/tests/testData/xml/AnyAttributeNavigation/test.xml @@ -0,0 +1,4 @@ + +z="baz"/> \ No newline at end of file diff --git a/xml/tests/testData/xml/AnyAttributeNavigation/test.xsd b/xml/tests/testData/xml/AnyAttributeNavigation/test.xsd new file mode 100644 index 000000000000..bb9e9824cf51 --- /dev/null +++ b/xml/tests/testData/xml/AnyAttributeNavigation/test.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java index b5f346142f78..083512a77b10 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/schema/XmlElementDescriptorImpl.java @@ -377,6 +377,11 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor final ComplexTypeDescriptor.CanContainAttributeType containAttributeType = descriptor.canContainAttribute(namespace, qName); if (containAttributeType != ComplexTypeDescriptor.CanContainAttributeType.CanNotContain) { + for (XmlAttributeDescriptor attributeDescriptor : descriptors) { + if (attributeDescriptor.getName().equals(attributeName)) { + return attributeDescriptor; + } + } return new AnyXmlAttributeDescriptor(attributeName, containAttributeType); } }