Merge remote-tracking branch 'origin/master'

This commit is contained in:
graann
2018-04-18 18:39:23 +03:00
5 changed files with 47 additions and 56 deletions
@@ -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);
@@ -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
@@ -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<AnAction, Constraints> 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;
}
@@ -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);
}
@@ -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();