mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Resolve in overlapping single and on-demand static imports fixed
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -51,6 +51,7 @@ import com.intellij.util.containers.MostlySingularMultiMap;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -187,13 +188,14 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
|
||||
private String myNameToFilter;
|
||||
private boolean myIsProcessingOnDemand;
|
||||
private final Collection<String> myHiddenNames = new HashSet<String>();
|
||||
private final Collection<PsiElement> myCollectedElements = new HashSet<PsiElement>();
|
||||
|
||||
private StaticImportFilteringProcessor(PsiScopeProcessor delegate, String nameToFilter) {
|
||||
myDelegate = delegate;
|
||||
myNameToFilter = nameToFilter;
|
||||
}
|
||||
|
||||
public void setNameToFilter(String nameToFilter) {
|
||||
public void setNameToFilter(@Nullable String nameToFilter) {
|
||||
myNameToFilter = nameToFilter;
|
||||
}
|
||||
|
||||
@@ -224,18 +226,18 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
|
||||
public boolean execute(PsiElement element, ResolveState state) {
|
||||
if (element instanceof PsiModifierListOwner && ((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (myNameToFilter != null &&
|
||||
(!(element instanceof PsiNamedElement) || !myNameToFilter.equals(((PsiNamedElement)element).getName()))) {
|
||||
return true;
|
||||
!(element instanceof PsiNamedElement && myNameToFilter.equals(((PsiNamedElement)element).getName()))) {
|
||||
return true;
|
||||
}
|
||||
if (element instanceof PsiNamedElement && myIsProcessingOnDemand) {
|
||||
final String name = ((PsiNamedElement)element).getName();
|
||||
if (myHiddenNames.contains(name)) return true;
|
||||
}
|
||||
return myDelegate.execute(element, state);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
if (myCollectedElements.add(element)) {
|
||||
return myDelegate.execute(element, state);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
import x.Base1;
|
||||
import static x.Base2.F;
|
||||
import static x.Base1.m;
|
||||
import static x.Base2.m;
|
||||
import static <error descr="Field 'IF' is ambiguous in a single static import">x.Base2.II.IF</error>;
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
*/
|
||||
import static x.Base1.*;
|
||||
import static x.Base2.*;
|
||||
|
||||
class UsageOnDemand {
|
||||
void use() {
|
||||
m(1); //Base1.m(int)
|
||||
m(1.0f); //Base2.m(float)
|
||||
}
|
||||
}
|
||||
@@ -52,4 +52,8 @@ public class AdvHighlightingJdk7Test extends DaemonAnalyzerTestCase {
|
||||
public void testStaticImportConflict() throws Exception {
|
||||
doTest(BASE_PATH + "staticImportConflict/Usage.java", BASE_PATH + "/staticImportConflict", false, false);
|
||||
}
|
||||
|
||||
public void testStaticOnDemandImportConflict() throws Exception {
|
||||
doTest(BASE_PATH + "staticImportConflict/UsageOnDemand.java", BASE_PATH + "/staticImportConflict", false, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user