diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index 111b3b491f5a..14bdbf34a914 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -206,16 +206,9 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh // in JSP, XmlAttributeValue may contain java references try { for (PsiReference reference : element.getReferences()) { - if (reference instanceof PsiJavaReference) { - PsiJavaReference psiJavaReference = (PsiJavaReference)reference; - myRefCountHolder.registerReference(psiJavaReference, psiJavaReference.advancedResolve(false)); - } - else if (reference instanceof PsiPolyVariantReference && - reference instanceof ResolvingHint && ((ResolvingHint)reference).canResolveTo(PsiClass.class)) { - ResolveResult[] resolve = ((PsiPolyVariantReference)reference).multiResolve(false); - if (resolve.length == 1 && resolve[0] instanceof JavaResolveResult) { - myRefCountHolder.registerReference(reference, (JavaResolveResult)resolve[0]); - } + JavaResolveResult result = resolveJavaReference(reference); + if (result != null) { + myRefCountHolder.registerReference(reference, result); } } } @@ -227,6 +220,22 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh } } + @Nullable + public static JavaResolveResult resolveJavaReference(PsiReference reference) { + if (reference instanceof PsiJavaReference) { + PsiJavaReference psiJavaReference = (PsiJavaReference)reference; + return psiJavaReference.advancedResolve(false); + } + else if (reference instanceof PsiPolyVariantReference && + reference instanceof ResolvingHint && ((ResolvingHint)reference).canResolveTo(PsiClass.class)) { + ResolveResult[] resolve = ((PsiPolyVariantReference)reference).multiResolve(false); + if (resolve.length == 1 && resolve[0] instanceof JavaResolveResult) { + return (JavaResolveResult)resolve[0]; + } + } + return null; + } + @Override public void visitAnnotation(PsiAnnotation annotation) { super.visitAnnotation(annotation); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java index d5f410b55bbe..b93e21a7e1cc 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java @@ -16,6 +16,7 @@ package com.intellij.psi.impl.source.codeStyle; import com.intellij.codeInsight.ImportFilter; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl; import com.intellij.lang.ASTNode; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.diagnostic.Logger; @@ -884,22 +885,26 @@ public class ImportHelper{ ContainerUtil.addAll(stack, child.getChildren()); for (final PsiReference reference : child.getReferences()) { - if (!(reference instanceof PsiJavaReference)) continue; - final PsiJavaReference javaReference = (PsiJavaReference)reference; - if (javaReference instanceof JavaClassReference && ((JavaClassReference)javaReference).getContextReference() != null) continue; + JavaResolveResult resolveResult = HighlightVisitorImpl.resolveJavaReference(reference); + if (resolveResult == null) continue; + PsiJavaCodeReferenceElement referenceElement = null; - if (reference instanceof PsiJavaCodeReferenceElement) { - referenceElement = (PsiJavaCodeReferenceElement)child; - if (referenceElement.getQualifier() != null) { - continue; - } - if (reference instanceof PsiJavaCodeReferenceElementImpl - && ((PsiJavaCodeReferenceElementImpl)reference).getKindEnum(((PsiJavaCodeReferenceElementImpl)reference).getContainingFile()) == PsiJavaCodeReferenceElementImpl.Kind.CLASS_IN_QUALIFIED_NEW_KIND) { - continue; + if (reference instanceof PsiJavaReference) { + final PsiJavaReference javaReference = (PsiJavaReference)reference; + if (javaReference instanceof JavaClassReference && ((JavaClassReference)javaReference).getContextReference() != null) continue; + referenceElement = null; + if (reference instanceof PsiJavaCodeReferenceElement) { + referenceElement = (PsiJavaCodeReferenceElement)child; + if (referenceElement.getQualifier() != null) { + continue; + } + if (reference instanceof PsiJavaCodeReferenceElementImpl + && ((PsiJavaCodeReferenceElementImpl)reference).getKindEnum(((PsiJavaCodeReferenceElementImpl)reference).getContainingFile()) == PsiJavaCodeReferenceElementImpl.Kind.CLASS_IN_QUALIFIED_NEW_KIND) { + continue; + } } } - final JavaResolveResult resolveResult = javaReference.advancedResolve(true); PsiElement refElement = resolveResult.getElement(); if (refElement == null && referenceElement != null) { refElement = ResolveClassUtil.resolveClass(referenceElement, referenceElement.getContainingFile()); // might be uncomplete code diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java index 9d7990591539..961f8afa8814 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/DefaultActionGroup.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.actionSystem; import com.intellij.openapi.diagnostic.Logger; @@ -237,10 +223,13 @@ public class DefaultActionGroup extends ActionGroup { * @param action Action to be removed */ public final void remove(AnAction action) { - if (!mySortedChildren.remove(action)) { + String id = ActionManager.getInstance().getId(action); + if (!mySortedChildren.remove(action) && + !mySortedChildren.removeIf(oldAction -> + oldAction instanceof ActionStub && ((ActionStub) oldAction).getId().equals(id))) { for (int i = 0; i < myPairs.size(); i++) { Pair pair = myPairs.get(i); - if (pair.first.equals(action)) { + if (pair.first.equals(action) || (pair.first instanceof ActionStub && ((ActionStub) pair.first).getId().equals(id))) { myPairs.remove(i); break; } diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java index dbb3d98917b9..6266029abb2f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java @@ -506,7 +506,9 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab @Override public String getId(@NotNull AnAction action) { - LOG.assertTrue(!(action instanceof ActionStub)); + if (action instanceof ActionStub) { + return ((ActionStub) action).getId(); + } synchronized (myLock) { return myAction2Id.get(action); } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java index 7deaf8480f49..68ade0ccf927 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCompletionContributor.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.completion; import com.intellij.codeInsight.lookup.InsertHandlerDecorator; @@ -210,12 +196,12 @@ public class XmlCompletionContributor extends CompletionContributor { static void completeTagName(CompletionParameters parameters, CompletionResultSet result) { PsiElement element = parameters.getPosition(); if (!isXmlNameCompletion(parameters)) return; - result.stopHere(); PsiElement parent = element.getParent(); if (!(parent instanceof XmlTag) || !(parameters.getOriginalFile() instanceof XmlFile)) { return; } + result.stopHere(); final XmlTag tag = (XmlTag)parent; final String namespace = tag.getNamespace(); final String prefix = result.getPrefixMatcher().getPrefix();