mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -107,7 +107,7 @@ public class BasicExpressionCompletionContributor {
|
||||
|
||||
PsiScopesUtil.treeWalkUp(new BaseScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiLocalVariable) {
|
||||
if (!matcher.prefixMatches(((PsiLocalVariable)element).getName())) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -303,7 +303,7 @@ public class JavaCompletionUtil {
|
||||
final Ref<PsiSubstitutor> subst = Ref.create(PsiSubstitutor.EMPTY);
|
||||
class MyProcessor extends BaseScopeProcessor implements NameHint, ElementClassHint {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element == member) {
|
||||
subst.set(state.get(PsiSubstitutor.KEY));
|
||||
}
|
||||
@@ -311,7 +311,7 @@ public class JavaCompletionUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(ResolveState state) {
|
||||
public String getName(@NotNull ResolveState state) {
|
||||
return member.getName();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -66,7 +66,7 @@ public class VariablesProcessor
|
||||
|
||||
/** Always return true since we wanna get all vars in scope */
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement pe, ResolveState state){
|
||||
public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state){
|
||||
if(pe instanceof PsiVariable){
|
||||
final PsiVariable pvar = (PsiVariable)pe;
|
||||
final String pvar_name = pvar.getName();
|
||||
@@ -81,7 +81,7 @@ public class VariablesProcessor
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleEvent(Event event, Object associated){
|
||||
public final void handleEvent(@NotNull Event event, Object associated){
|
||||
if(event == JavaScopeProcessorEvent.START_STATIC)
|
||||
myStaticScopeFlag = true;
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -77,7 +77,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
|
||||
private final Condition<String> myMatcher;
|
||||
private final Options myOptions;
|
||||
private final Set<PsiField> myNonInitializedFields = new HashSet<PsiField>();
|
||||
private boolean myAllowStaticWithInstanceQualifier;
|
||||
private final boolean myAllowStaticWithInstanceQualifier;
|
||||
|
||||
public JavaCompletionProcessor(@NotNull PsiElement element, ElementFilter filter, Options options, @NotNull Condition<String> nameCondition) {
|
||||
myOptions = options;
|
||||
@@ -196,7 +196,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated){
|
||||
public void handleEvent(@NotNull Event event, Object associated){
|
||||
if(event == JavaScopeProcessorEvent.START_STATIC){
|
||||
myStatic = true;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
//noinspection SuspiciousMethodCalls
|
||||
if (myNonInitializedFields.contains(element)) {
|
||||
return true;
|
||||
|
||||
+1
-1
@@ -523,7 +523,7 @@ public class CreateFromUsageUtils {
|
||||
final List<PsiVariable> list = new ArrayList<PsiVariable>();
|
||||
VariablesProcessor varproc = new VariablesProcessor("", true, list){
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if(!(element instanceof PsiField) ||
|
||||
JavaPsiFacade.getInstance(element.getProject()).getResolveHelper().isAccessible((PsiField)element, expression, null)) {
|
||||
return super.execute(element, state);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -160,7 +160,7 @@ public class RenameWrongRefFix implements IntentionAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiNamedElement
|
||||
&& element instanceof PsiModifierListOwner
|
||||
&& myFilterMethods == element instanceof PsiMethod) {
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.generation;
|
||||
|
||||
import com.intellij.psi.PsiDocCommentOwner;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -24,7 +25,7 @@ import javax.swing.*;
|
||||
* @author peter
|
||||
*/
|
||||
public class PsiDocCommentOwnerMemberChooserObject extends PsiElementMemberChooserObject {
|
||||
public PsiDocCommentOwnerMemberChooserObject(final PsiDocCommentOwner owner, final String text, Icon icon) {
|
||||
public PsiDocCommentOwnerMemberChooserObject(@NotNull PsiDocCommentOwner owner, final String text, Icon icon) {
|
||||
super(owner, text, icon);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiDocCommentOwner;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -29,17 +30,18 @@ public abstract class PsiElementClassMember<T extends PsiDocCommentOwner> extend
|
||||
private final T myPsiMember;
|
||||
private PsiSubstitutor mySubstitutor;
|
||||
|
||||
protected PsiElementClassMember(final T psiMember, String text) {
|
||||
protected PsiElementClassMember(@NotNull T psiMember, String text) {
|
||||
this(psiMember, PsiSubstitutor.EMPTY, text);
|
||||
}
|
||||
|
||||
protected PsiElementClassMember(final T psiMember, final PsiSubstitutor substitutor, String text) {
|
||||
protected PsiElementClassMember(@NotNull T psiMember, @NotNull PsiSubstitutor substitutor, String text) {
|
||||
super(psiMember, text, psiMember.getIcon(Iconable.ICON_FLAG_VISIBILITY));
|
||||
myPsiMember = psiMember;
|
||||
mySubstitutor = substitutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public T getElement() {
|
||||
return myPsiMember;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.generation;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,11 +34,11 @@ import java.util.List;
|
||||
public class PsiFieldMember extends PsiElementClassMember<PsiField> implements PropertyClassMember {
|
||||
private static final int FIELD_OPTIONS = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.TYPE_AFTER;
|
||||
|
||||
public PsiFieldMember(final PsiField field) {
|
||||
public PsiFieldMember(@NotNull PsiField field) {
|
||||
super(field, PsiFormatUtil.formatVariable(field, FIELD_OPTIONS, PsiSubstitutor.EMPTY));
|
||||
}
|
||||
|
||||
public PsiFieldMember(PsiField psiMember, PsiSubstitutor substitutor) {
|
||||
public PsiFieldMember(@NotNull PsiField psiMember, PsiSubstitutor substitutor) {
|
||||
super(psiMember, substitutor, PsiFormatUtil.formatVariable(psiMember, FIELD_OPTIONS, PsiSubstitutor.EMPTY));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -28,15 +29,15 @@ public class PsiMethodMember extends PsiElementClassMember<PsiMethod>{
|
||||
private static final int PARAM_OPTIONS = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.TYPE_AFTER;
|
||||
private static final int METHOD_OPTIONS = PARAM_OPTIONS | PsiFormatUtilBase.SHOW_PARAMETERS;
|
||||
|
||||
public PsiMethodMember(final PsiMethod method) {
|
||||
public PsiMethodMember(@NotNull PsiMethod method) {
|
||||
this(method, PsiSubstitutor.EMPTY);
|
||||
}
|
||||
|
||||
public PsiMethodMember(CandidateInfo info) {
|
||||
public PsiMethodMember(@NotNull CandidateInfo info) {
|
||||
this((PsiMethod)info.getElement(), info.getSubstitutor());
|
||||
}
|
||||
|
||||
public PsiMethodMember(final PsiMethod method, final PsiSubstitutor substitutor) {
|
||||
public PsiMethodMember(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor) {
|
||||
super(method, substitutor, PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, METHOD_OPTIONS, PARAM_OPTIONS));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -164,7 +164,7 @@ public class MacroUtil {
|
||||
final List<PsiVariable> list = new ArrayList<PsiVariable>();
|
||||
VariablesProcessor varproc = new VariablesProcessor(prefix, true, list) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement pe, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state) {
|
||||
if (pe instanceof PsiVariable) {
|
||||
if (!usedNames.add(((PsiVariable)pe).getName())) {
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -249,7 +249,7 @@ public abstract class AbstractQualifiedReference<T extends AbstractQualifiedRefe
|
||||
private final Set<ResolveResult> myResults = new LinkedHashSet<ResolveResult>();
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull final PsiElement element, final ResolveState state) {
|
||||
public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) {
|
||||
if (isFound()) return false;
|
||||
process(element);
|
||||
return true;
|
||||
@@ -264,7 +264,7 @@ public abstract class AbstractQualifiedReference<T extends AbstractQualifiedRefe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(final Event event, final Object associated) {
|
||||
public void handleEvent(@NotNull final Event event, final Object associated) {
|
||||
if ((event == JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT || event == Event.SET_DECLARATION_HOLDER) && !myResults.isEmpty()) {
|
||||
setFound();
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -118,7 +118,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer
|
||||
}
|
||||
processorToUse = new PsiScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
return !(element instanceof PsiClass || element instanceof PsiPackage) || processor.execute(element, state);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
processor.handleEvent(event, associated);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -54,7 +54,7 @@ public class JavaMethodResolveHelper {
|
||||
languageLevel);
|
||||
myProcessor = new MethodResolverProcessor(argumentList, containingFile, new PsiConflictResolver[]{resolver}) {
|
||||
@Override
|
||||
protected MethodCandidateInfo createCandidateInfo(final PsiMethod method, final PsiSubstitutor substitutor,
|
||||
protected MethodCandidateInfo createCandidateInfo(@NotNull final PsiMethod method, @NotNull final PsiSubstitutor substitutor,
|
||||
final boolean staticProblem,
|
||||
final boolean accessible, final boolean varargs) {
|
||||
return JavaMethodResolveHelper.this
|
||||
@@ -69,7 +69,7 @@ public class JavaMethodResolveHelper {
|
||||
};
|
||||
}
|
||||
|
||||
protected MethodCandidateInfo createCandidateInfo(PsiMethod method,
|
||||
protected MethodCandidateInfo createCandidateInfo(@NotNull PsiMethod method,
|
||||
PsiSubstitutor substitutor,
|
||||
boolean staticProblem,
|
||||
PsiElement currentFileContext,
|
||||
@@ -81,7 +81,7 @@ public class JavaMethodResolveHelper {
|
||||
PsiType.EMPTY_ARRAY, languageLevel);
|
||||
}
|
||||
|
||||
public void addMethod(PsiMethod method, PsiSubstitutor substitutor, boolean staticError) {
|
||||
public void addMethod(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, boolean staticError) {
|
||||
if (myDuplicates.add(method.getSignature(substitutor))) {
|
||||
myProcessor.addMethod(method, substitutor, staticError);
|
||||
}
|
||||
|
||||
+14
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -62,6 +62,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
return element.getLanguage() == StdLanguages.JAVA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsageInfo[] findUsages(ChangeInfo info) {
|
||||
if (info instanceof JavaChangeInfo) {
|
||||
return new JavaChangeSignatureUsageSearcher((JavaChangeInfo)info).findUsages();
|
||||
@@ -71,6 +72,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiMap<PsiElement, String> findConflicts(ChangeInfo info, Ref<UsageInfo[]> refUsages) {
|
||||
if (info instanceof JavaChangeInfo) {
|
||||
return new ConflictSearcher((JavaChangeInfo)info).findConflicts(refUsages);
|
||||
@@ -80,6 +82,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processUsage(ChangeInfo changeInfo, UsageInfo usage, boolean beforeMethodChange, UsageInfo[] usages) {
|
||||
if (!isJavaUsage(usage)) return false;
|
||||
if (!(changeInfo instanceof JavaChangeInfo)) return false;
|
||||
@@ -510,6 +513,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(list.getProject()).getResolveHelper();
|
||||
final PsiType type = info.getTypeWrapper().getType(changeInfo.getMethod(), list.getManager());
|
||||
final VariablesProcessor processor = new VariablesProcessor(false) {
|
||||
@Override
|
||||
protected boolean check(PsiVariable var, ResolveState state) {
|
||||
if (var instanceof PsiField && !resolveHelper.isAccessible((PsiField)var, list, null)) return false;
|
||||
if (var instanceof PsiLocalVariable && list.getTextRange().getStartOffset() <= var.getTextRange().getStartOffset()) return false;
|
||||
@@ -518,7 +522,8 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
return type.isAssignableFrom(varType);
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull PsiElement pe, ResolveState state) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state) {
|
||||
super.execute(pe, state);
|
||||
return size() < 2;
|
||||
}
|
||||
@@ -549,10 +554,12 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
}
|
||||
final PsiCallExpression callExpression = PsiTreeUtil.getParentOfType(list, PsiCallExpression.class);
|
||||
final String defaultValue = info.getDefaultValue();
|
||||
return callExpression != null ? info.getValue(callExpression) : defaultValue.length() > 0 ? factory.createExpressionFromText(defaultValue, list) : null;
|
||||
return callExpression != null ? info.getValue(callExpression) : !defaultValue.isEmpty()
|
||||
? factory.createExpressionFromText(defaultValue, list) : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean processPrimaryMethod(ChangeInfo changeInfo) {
|
||||
if (!StdLanguages.JAVA.equals(changeInfo.getLanguage()) || !(changeInfo instanceof JavaChangeInfo)) return false;
|
||||
final PsiElement element = changeInfo.getMethod();
|
||||
@@ -564,6 +571,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPreviewUsages(ChangeInfo changeInfo, UsageInfo[] usages) {
|
||||
return false;
|
||||
}
|
||||
@@ -869,6 +877,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
private static class ParameterList implements ChangeSignatureUtil.ChildrenGenerator<PsiParameterList, PsiParameter> {
|
||||
public static final ParameterList INSTANCE = new ParameterList();
|
||||
|
||||
@Override
|
||||
public List<PsiParameter> getChildren(PsiParameterList psiParameterList) {
|
||||
return Arrays.asList(psiParameterList.getParameters());
|
||||
}
|
||||
@@ -877,6 +886,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
private static class ThrowsList implements ChangeSignatureUtil.ChildrenGenerator<PsiReferenceList, PsiJavaCodeReferenceElement> {
|
||||
public static final ThrowsList INSTANCE = new ThrowsList();
|
||||
|
||||
@Override
|
||||
public List<PsiJavaCodeReferenceElement> getChildren(PsiReferenceList throwsList) {
|
||||
return Arrays.asList(throwsList.getReferenceElements());
|
||||
}
|
||||
@@ -1013,6 +1023,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
private static class ExpressionList implements ChangeSignatureUtil.ChildrenGenerator<PsiExpressionList, PsiExpression> {
|
||||
public static final ExpressionList INSTANCE = new ExpressionList();
|
||||
|
||||
@Override
|
||||
public List<PsiExpression> getChildren(PsiExpressionList psiExpressionList) {
|
||||
return Arrays.asList(psiExpressionList.getExpressions());
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp
|
||||
@NonNls private static final String ARRAY_PREFIX = "[L";
|
||||
private static final JavaClassReferenceProvider CLASS_REFERENCE_PROVIDER = new JavaClassReferenceProvider();
|
||||
|
||||
@Override
|
||||
public PsiType fromString(final String s, final ConvertContext context) {
|
||||
if (s == null) return null;
|
||||
try {
|
||||
@@ -47,10 +48,12 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final PsiType t, final ConvertContext context) {
|
||||
return t == null ? null : t.getCanonicalText();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiReference[] createReferences(final GenericDomValue<PsiType> genericDomValue, final PsiElement element, ConvertContext context) {
|
||||
final String typeText = genericDomValue.getStringValue();
|
||||
@@ -60,7 +63,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp
|
||||
return getReferences(genericDomValue.getValue(), typeText, 0, element);
|
||||
}
|
||||
|
||||
public PsiReference[] getReferences(@Nullable PsiType type, String typeText, int startOffsetInText, final PsiElement element) {
|
||||
public PsiReference[] getReferences(@Nullable PsiType type, String typeText, int startOffsetInText, @NotNull final PsiElement element) {
|
||||
final ElementManipulator<PsiElement> manipulator = ElementManipulators.getManipulator(element);
|
||||
assert manipulator != null;
|
||||
String trimmed = typeText.trim();
|
||||
@@ -80,13 +83,16 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp
|
||||
final boolean isPrimitiveType = type instanceof PsiPrimitiveType;
|
||||
|
||||
return new JavaClassReferenceSet(trimmed, element, offset, false, CLASS_REFERENCE_PROVIDER) {
|
||||
@Override
|
||||
@NotNull
|
||||
protected JavaClassReference createReference(int refIndex, @NotNull String subRefText, @NotNull TextRange textRange, boolean staticImport) {
|
||||
return new JavaClassReference(this, textRange, refIndex, subRefText, staticImport) {
|
||||
@Override
|
||||
public boolean isSoft() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaResolveResult advancedResolve(final boolean incompleteCode) {
|
||||
if (isPrimitiveType) {
|
||||
@@ -96,6 +102,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp
|
||||
return super.advancedResolve(incompleteCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVariants(@NotNull final PsiScopeProcessor processor) {
|
||||
if (processor instanceof JavaCompletionProcessor) {
|
||||
((JavaCompletionProcessor)processor).setCompletionElements(getVariants());
|
||||
@@ -104,6 +111,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Object[] getVariants() {
|
||||
final Object[] variants = super.getVariants();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.infos;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JavaVersionService;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -28,14 +29,14 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
|
||||
private final PsiElement myPlace;
|
||||
private final PsiClass myAccessClass;
|
||||
private final PsiElement myCandidate;
|
||||
@NotNull private final PsiElement myCandidate;
|
||||
private final boolean myStaticsProblem;
|
||||
protected final PsiSubstitutor mySubstitutor;
|
||||
private final PsiElement myCurrentFileResolveContext;
|
||||
private final boolean myPackagePrefixPackageReference;
|
||||
private Boolean myAccessible; // benign datarace
|
||||
|
||||
private CandidateInfo(PsiElement candidate,
|
||||
private CandidateInfo(@NotNull PsiElement candidate,
|
||||
@NotNull PsiSubstitutor substitutor,
|
||||
Boolean accessible,
|
||||
boolean staticsProblem,
|
||||
@@ -52,15 +53,15 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
myPlace = place;
|
||||
myPackagePrefixPackageReference = packagePrefixPackageReference;
|
||||
}
|
||||
public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem, PsiElement currFileContext) {
|
||||
public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem, PsiElement currFileContext) {
|
||||
this(candidate, substitutor, !accessProblem, staticsProblem, currFileContext, null, null, false);
|
||||
}
|
||||
|
||||
public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem){
|
||||
public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem){
|
||||
this(candidate, substitutor, accessProblem, staticsProblem, null);
|
||||
}
|
||||
|
||||
public CandidateInfo(PsiElement candidate,
|
||||
public CandidateInfo(@NotNull PsiElement candidate,
|
||||
@NotNull PsiSubstitutor substitutor,
|
||||
PsiElement place,
|
||||
PsiClass accessClass,
|
||||
@@ -69,15 +70,15 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
this(candidate, substitutor, null, staticsProblem, currFileContext, place, accessClass, false);
|
||||
}
|
||||
|
||||
public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor, PsiElement place, boolean staticsProblem){
|
||||
public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, PsiElement place, boolean staticsProblem){
|
||||
this(candidate, substitutor, place, null, staticsProblem, null);
|
||||
}
|
||||
|
||||
public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor){
|
||||
public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor){
|
||||
this(candidate, substitutor, null, null, false, null);
|
||||
}
|
||||
|
||||
public CandidateInfo(CandidateInfo candidate, @NotNull PsiSubstitutor newSubstitutor){
|
||||
public CandidateInfo(@NotNull CandidateInfo candidate, @NotNull PsiSubstitutor newSubstitutor){
|
||||
this(candidate.myCandidate, newSubstitutor, candidate.myAccessible, candidate.myStaticsProblem, candidate.myCurrentFileResolveContext, candidate.myPlace,
|
||||
null, false);
|
||||
}
|
||||
@@ -93,6 +94,7 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement getElement(){
|
||||
return myCandidate;
|
||||
}
|
||||
@@ -160,7 +162,7 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
if (myStaticsProblem != that.myStaticsProblem) return false;
|
||||
if (myAccessClass != null ? !myAccessClass.equals(that.myAccessClass) : that.myAccessClass != null) return false;
|
||||
if (isAccessible() != that.isAccessible()) return false;
|
||||
if (myCandidate != null ? !myCandidate.equals(that.myCandidate) : that.myCandidate != null) return false;
|
||||
if (!myCandidate.equals(that.myCandidate)) return false;
|
||||
if (myCurrentFileResolveContext != null
|
||||
? !myCurrentFileResolveContext.equals(that.myCurrentFileResolveContext)
|
||||
: that.myCurrentFileResolveContext != null) {
|
||||
@@ -174,7 +176,7 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
public int hashCode() {
|
||||
int result = myPlace != null ? myPlace.hashCode() : 0;
|
||||
result = 31 * result + (myAccessClass != null ? myAccessClass.hashCode() : 0);
|
||||
result = 31 * result + (myCandidate != null ? myCandidate.hashCode() : 0);
|
||||
result = 31 * result + myCandidate.hashCode();
|
||||
result = 31 * result + (isAccessible() ? 1 : 0);
|
||||
result = 31 * result + (myStaticsProblem ? 1 : 0);
|
||||
result = 31 * result + mySubstitutor.hashCode();
|
||||
@@ -185,5 +187,5 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
|
||||
@NotNull
|
||||
public static final JavaResolveResult[] RESOLVE_RESULT_FOR_PACKAGE_PREFIX_PACKAGE =
|
||||
{new CandidateInfo(null, PsiSubstitutor.EMPTY, Boolean.TRUE, false, null, null, null, true)};
|
||||
{new CandidateInfo(PsiUtilCore.NULL_PSI_ELEMENT, PsiSubstitutor.EMPTY, Boolean.TRUE, false, null, null, null, true)};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.infos;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -27,14 +28,15 @@ import com.intellij.psi.PsiSubstitutor;
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class ClassCandidateInfo extends CandidateInfo{
|
||||
public ClassCandidateInfo(PsiElement candidate, PsiSubstitutor substitutor, boolean accessProblem, PsiElement currFileContext){
|
||||
public ClassCandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, PsiElement currFileContext){
|
||||
super(candidate, substitutor, accessProblem, false, currFileContext);
|
||||
}
|
||||
|
||||
public ClassCandidateInfo(PsiElement candidate, PsiSubstitutor substitutor){
|
||||
public ClassCandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor){
|
||||
super(candidate, substitutor, false, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiClass getElement(){
|
||||
return (PsiClass)super.getElement();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -47,7 +47,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
private PsiSubstitutor myCalcedSubstitutor; // benign race
|
||||
private final LanguageLevel myLanguageLevel;
|
||||
|
||||
public MethodCandidateInfo(PsiElement candidate,
|
||||
public MethodCandidateInfo(@NotNull PsiElement candidate,
|
||||
PsiSubstitutor substitutor,
|
||||
boolean accessProblem,
|
||||
boolean staticsProblem,
|
||||
@@ -59,8 +59,8 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
PsiUtil.getLanguageLevel(argumentList));
|
||||
}
|
||||
|
||||
public MethodCandidateInfo(PsiElement candidate,
|
||||
PsiSubstitutor substitutor,
|
||||
public MethodCandidateInfo(@NotNull PsiElement candidate,
|
||||
@NotNull PsiSubstitutor substitutor,
|
||||
boolean accessProblem,
|
||||
boolean staticsProblem,
|
||||
PsiElement argumentList,
|
||||
@@ -155,11 +155,9 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
|
||||
if (myTypeArguments != null) {
|
||||
PsiMethod method = getElement();
|
||||
if (method != null) {
|
||||
PsiTypeParameter[] typeParams = method.getTypeParameters();
|
||||
for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
|
||||
incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
|
||||
}
|
||||
PsiTypeParameter[] typeParams = method.getTypeParameters();
|
||||
for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
|
||||
incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
|
||||
}
|
||||
}
|
||||
return incompleteSubstitutor;
|
||||
@@ -216,7 +214,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
}
|
||||
|
||||
protected PsiElement getParent() {
|
||||
return myArgumentList != null ? myArgumentList.getParent() : myArgumentList;
|
||||
return myArgumentList != null ? myArgumentList.getParent() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,6 +222,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
return super.isValidResult() && isApplicable();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiMethod getElement(){
|
||||
return (PsiMethod)super.getElement();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -225,7 +225,7 @@ public class PsiClassImplUtil {
|
||||
FilterScopeProcessor<MethodCandidateInfo> processor = new FilterScopeProcessor<MethodCandidateInfo>(
|
||||
new OrFilter(ElementClassFilter.METHOD, ElementClassFilter.FIELD, ElementClassFilter.CLASS)) {
|
||||
@Override
|
||||
protected void add(PsiElement element, PsiSubstitutor substitutor) {
|
||||
protected void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) {
|
||||
if (element instanceof PsiMethod) {
|
||||
methods.add(Pair.create((PsiMember)element, substitutor));
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -95,14 +95,14 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P
|
||||
@Override
|
||||
public JavaResolveResult[] resolve(@NotNull ClsJavaCodeReferenceElementImpl ref, boolean incompleteCode) {
|
||||
final JavaResolveResult resolveResult = ref.advancedResolveImpl();
|
||||
return resolveResult.getElement() == null ? JavaResolveResult.EMPTY_ARRAY : new JavaResolveResult[] {resolveResult};
|
||||
return resolveResult == null ? JavaResolveResult.EMPTY_ARRAY : new JavaResolveResult[] {resolveResult};
|
||||
}
|
||||
}
|
||||
|
||||
private JavaResolveResult advancedResolveImpl() {
|
||||
PsiTypeElement[] typeElements = myRefParameterList == null ? PsiTypeElement.EMPTY_ARRAY : myRefParameterList.getTypeParameterElements();
|
||||
PsiElement resolve = resolveElement();
|
||||
|
||||
if (resolve == null) return null;
|
||||
if (resolve instanceof PsiClass) {
|
||||
Map<PsiTypeParameter, PsiType> substitutionMap = new HashMap<PsiTypeParameter, PsiType>();
|
||||
int index = 0;
|
||||
@@ -129,7 +129,7 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P
|
||||
}
|
||||
index++;
|
||||
}
|
||||
collectOuterClassTypeArgs(((PsiClass)resolve), myCanonicalText, substitutionMap);
|
||||
collectOuterClassTypeArgs((PsiClass)resolve, myCanonicalText, substitutionMap);
|
||||
return new CandidateInfo(resolve, PsiSubstitutorImpl.createSubstitutor(substitutionMap));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -24,12 +24,12 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LightMemberReference extends LightElement implements PsiJavaCodeReferenceElement {
|
||||
private final PsiMember myRefMember;
|
||||
@NotNull private final PsiMember myRefMember;
|
||||
private final PsiSubstitutor mySubstitutor;
|
||||
|
||||
private LightReferenceParameterList myParameterList;
|
||||
|
||||
public LightMemberReference(PsiManager manager, PsiMember refClass, PsiSubstitutor substitutor) {
|
||||
public LightMemberReference(PsiManager manager, @NotNull PsiMember refClass, PsiSubstitutor substitutor) {
|
||||
super(manager, JavaLanguage.INSTANCE);
|
||||
myRefMember = refClass;
|
||||
|
||||
@@ -37,6 +37,7 @@ public class LightMemberReference extends LightElement implements PsiJavaCodeRef
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement resolve() {
|
||||
return myRefMember;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -52,7 +52,8 @@ public class LightPackageReference extends LightElement implements PsiJavaCodeRe
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaResolveResult advancedResolve(boolean incompleteCode){
|
||||
return new CandidateInfo(resolve(), PsiSubstitutor.EMPTY);
|
||||
PsiElement resolve = resolve();
|
||||
return resolve == null ? JavaResolveResult.EMPTY : new CandidateInfo(resolve, PsiSubstitutor.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -242,7 +242,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(final Event event, final Object associated) {
|
||||
public void handleEvent(@NotNull final Event event, final Object associated) {
|
||||
if (JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT.equals(event) && associated instanceof PsiImportStaticStatement) {
|
||||
final PsiImportStaticStatement importStaticStatement = (PsiImportStaticStatement)associated;
|
||||
myIsProcessingOnDemand = importStaticStatement.isOnDemand();
|
||||
@@ -254,7 +254,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull final PsiElement element, final ResolveState state) {
|
||||
public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) {
|
||||
if (element instanceof PsiModifierListOwner && ((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (element instanceof PsiNamedElement && myIsProcessingOnDemand) {
|
||||
final String name = ((PsiNamedElement)element).getName();
|
||||
@@ -290,7 +290,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
|
||||
return processDeclarationsNoGuess(processor, state, lastParent, place);
|
||||
}
|
||||
|
||||
private boolean processDeclarationsNoGuess(PsiScopeProcessor processor, ResolveState state, PsiElement lastParent, PsiElement place) {
|
||||
private boolean processDeclarationsNoGuess(PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, PsiElement place) {
|
||||
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
|
||||
final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
|
||||
final NameHint nameHint = processor.getHint(NameHint.KEY);
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -83,7 +83,7 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(ResolveState state) {
|
||||
public String getName(@NotNull ResolveState state) {
|
||||
return myClassName;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(PsiScopeProcessor.Event event, Object associated) {
|
||||
public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) {
|
||||
if (event == JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT) {
|
||||
myCurrentFileContext = (PsiElement)associated;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (!(element instanceof PsiClass)) return true;
|
||||
final PsiClass aClass = (PsiClass)element;
|
||||
final String name = aClass.getName();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -101,7 +101,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiVariable resolveVar(final String referenceText, final PsiElement context, final boolean[] problemWithAccess) {
|
||||
private PsiVariable resolveVar(@NotNull String referenceText, final PsiElement context, final boolean[] problemWithAccess) {
|
||||
final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(myManager.getProject()).getParserFacade();
|
||||
try {
|
||||
final PsiJavaCodeReferenceElement ref = parserFacade.createReferenceFromText(referenceText, context);
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -33,13 +33,13 @@ public class StaticImportResolveProcessor extends BaseScopeProcessor implements
|
||||
private final List<JavaResolveResult> myClassResult = new SmartList<JavaResolveResult>();
|
||||
private final List<JavaResolveResult> myResults = new SmartList<JavaResolveResult>();
|
||||
|
||||
public StaticImportResolveProcessor(final PsiImportStaticReferenceElement reference) {
|
||||
public StaticImportResolveProcessor(@NotNull PsiImportStaticReferenceElement reference) {
|
||||
myReference = reference;
|
||||
myName = myReference.getReferenceName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull final PsiElement candidate, final ResolveState state) {
|
||||
public boolean execute(@NotNull final PsiElement candidate, @NotNull final ResolveState state) {
|
||||
if (candidate instanceof PsiMember && ((PsiModifierListOwner)candidate).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (candidate instanceof PsiField) {
|
||||
if (checkDomination((PsiMember)candidate, myFieldResults)) return true;
|
||||
@@ -86,7 +86,7 @@ public class StaticImportResolveProcessor extends BaseScopeProcessor implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(final ResolveState state) {
|
||||
public String getName(@NotNull final ResolveState state) {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class StaticImportResolveProcessor extends BaseScopeProcessor implements
|
||||
private static class OurResolveResult extends CandidateInfo {
|
||||
private final PsiImportStaticReferenceElement myReference;
|
||||
|
||||
public OurResolveResult(final PsiElement candidate, final PsiImportStaticReferenceElement reference) {
|
||||
public OurResolveResult(@NotNull PsiElement candidate, final PsiImportStaticReferenceElement reference) {
|
||||
super(candidate, PsiSubstitutor.EMPTY);
|
||||
myReference = reference;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -43,14 +43,14 @@ public class SymbolCollectingProcessor extends BaseScopeProcessor implements Ele
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(PsiScopeProcessor.Event event, Object associated) {
|
||||
public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) {
|
||||
if (event == JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT) {
|
||||
myCurrentFileContext = (PsiElement)associated;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiNamedElement) {
|
||||
PsiNamedElement named = (PsiNamedElement)element;
|
||||
String name = named.getName();
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -69,7 +69,7 @@ public class VariableResolverProcessor extends ConflictFilterProcessor implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleEvent(PsiScopeProcessor.Event event, Object associated) {
|
||||
public final void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) {
|
||||
super.handleEvent(event, associated);
|
||||
if(event == JavaScopeProcessorEvent.START_STATIC){
|
||||
myStaticScopeFlag = true;
|
||||
@@ -80,7 +80,7 @@ public class VariableResolverProcessor extends ConflictFilterProcessor implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(PsiElement element, PsiSubstitutor substitutor) {
|
||||
public void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) {
|
||||
final boolean staticProblem = myStaticScopeFlag && !((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC);
|
||||
add(new CandidateInfo(element, substitutor, myPlace, myAccessClass, staticProblem, myCurrentFileContext));
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class VariableResolverProcessor extends ConflictFilterProcessor implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (!(element instanceof PsiField) && (myName == null || PsiUtil.checkName(element, myName, myPlace))) {
|
||||
super.execute(element, state);
|
||||
return myResults.isEmpty();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -102,7 +102,7 @@ public class PsiCodeBlockImpl extends LazyParseablePsiElement implements PsiCode
|
||||
final Ref<Boolean> conflict = new Ref<Boolean>(Boolean.FALSE);
|
||||
PsiScopesUtil.walkChildrenScopes(this, new BaseScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiLocalVariable) {
|
||||
final PsiLocalVariable variable = (PsiLocalVariable)element;
|
||||
final String name = variable.getName();
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -451,8 +451,8 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MethodCandidateInfo createCandidateInfo(final PsiMethod method,
|
||||
final PsiSubstitutor substitutor,
|
||||
protected MethodCandidateInfo createCandidateInfo(@NotNull final PsiMethod method,
|
||||
@NotNull final PsiSubstitutor substitutor,
|
||||
final boolean staticProblem,
|
||||
final boolean accessible,
|
||||
final boolean varargs) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -491,7 +491,7 @@ public class PsiReferenceExpressionImpl extends PsiReferenceExpressionBase imple
|
||||
private final Set<String> myVarNames = new THashSet<String>();
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull final PsiElement element, final ResolveState state) {
|
||||
public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) {
|
||||
if (element instanceof PsiLocalVariable || element instanceof PsiParameter) {
|
||||
myVarNames.add(((PsiVariable) element).getName());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,11 +17,12 @@ package com.intellij.psi.scope;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.ResolveState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface NameHint {
|
||||
Key<NameHint> KEY = Key.create("NameHint");
|
||||
|
||||
@Nullable
|
||||
String getName(ResolveState state);
|
||||
String getName(@NotNull ResolveState state);
|
||||
}
|
||||
|
||||
+12
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -34,7 +34,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ConflictFilterProcessor extends FilterScopeProcessor<CandidateInfo> implements NameHint {
|
||||
private final PsiConflictResolver[] myResolvers;
|
||||
private JavaResolveResult[] myCachedResult = null;
|
||||
private JavaResolveResult[] myCachedResult;
|
||||
protected String myName;
|
||||
protected final PsiElement myPlace;
|
||||
protected final PsiFile myPlaceFile;
|
||||
@@ -53,8 +53,9 @@ public class ConflictFilterProcessor extends FilterScopeProcessor<CandidateInfo>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
if (myCachedResult != null && myCachedResult.length == 1 && myCachedResult[0].isAccessible()) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
JavaResolveResult[] cachedResult = myCachedResult;
|
||||
if (cachedResult != null && cachedResult.length == 1 && cachedResult[0].isAccessible()) {
|
||||
return false;
|
||||
}
|
||||
if (myName == null || PsiUtil.checkName(element, myName, myPlace)) {
|
||||
@@ -64,7 +65,7 @@ public class ConflictFilterProcessor extends FilterScopeProcessor<CandidateInfo>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void add(PsiElement element, PsiSubstitutor substitutor) {
|
||||
protected void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) {
|
||||
add(new CandidateInfo(element, substitutor));
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ public class ConflictFilterProcessor extends FilterScopeProcessor<CandidateInfo>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(PsiScopeProcessor.Event event, Object associated) {
|
||||
public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) {
|
||||
if (event == JavaScopeProcessorEvent.CHANGE_LEVEL && myName != null) {
|
||||
getResult();
|
||||
}
|
||||
@@ -82,7 +83,8 @@ public class ConflictFilterProcessor extends FilterScopeProcessor<CandidateInfo>
|
||||
|
||||
@NotNull
|
||||
public JavaResolveResult[] getResult() {
|
||||
if (myCachedResult == null) {
|
||||
JavaResolveResult[] cachedResult = myCachedResult;
|
||||
if (cachedResult == null) {
|
||||
final List<CandidateInfo> conflicts = getResults();
|
||||
for (PsiConflictResolver resolver : myResolvers) {
|
||||
CandidateInfo candidate = resolver.resolveConflict(conflicts);
|
||||
@@ -92,14 +94,14 @@ public class ConflictFilterProcessor extends FilterScopeProcessor<CandidateInfo>
|
||||
break;
|
||||
}
|
||||
}
|
||||
myCachedResult = conflicts.toArray(new JavaResolveResult[conflicts.size()]);
|
||||
myCachedResult = cachedResult = conflicts.toArray(new JavaResolveResult[conflicts.size()]);
|
||||
}
|
||||
|
||||
return myCachedResult;
|
||||
return cachedResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(ResolveState state) {
|
||||
public String getName(@NotNull ResolveState state) {
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -57,7 +57,7 @@ public class FilterScopeProcessor<T> extends BaseScopeProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(PsiScopeProcessor.Event event, Object associated) {
|
||||
public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) {
|
||||
if (myProcessor != null) {
|
||||
myProcessor.handleEvent(event, associated);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class FilterScopeProcessor<T> extends BaseScopeProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (myFilter.isAcceptable(element, myCurrentDeclarationHolder)) {
|
||||
if (myProcessor != null) {
|
||||
return myProcessor.execute(element, state);
|
||||
@@ -77,13 +77,13 @@ public class FilterScopeProcessor<T> extends BaseScopeProcessor {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void add(PsiElement element, PsiSubstitutor substitutor) {
|
||||
protected void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) {
|
||||
//noinspection unchecked
|
||||
myResults.add((T)element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getHint(@NotNull Key<T> hintKey) {
|
||||
public <K> K getHint(@NotNull Key<K> hintKey) {
|
||||
if (myProcessor != null) {
|
||||
return myProcessor.getHint(hintKey);
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -43,14 +43,14 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(PsiElement element, PsiSubstitutor substitutor) {
|
||||
public void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) {
|
||||
if (element instanceof PsiMethod) {
|
||||
final PsiMethod method = (PsiMethod)element;
|
||||
addMethod(method, substitutor, isInStaticScope() && !method.hasModifierProperty(PsiModifier.STATIC));
|
||||
}
|
||||
}
|
||||
|
||||
public void addMethod(final PsiMethod method, final PsiSubstitutor substitutor, final boolean staticProblem) {
|
||||
public void addMethod(@NotNull PsiMethod method, final PsiSubstitutor substitutor, final boolean staticProblem) {
|
||||
final boolean isAccessible = JavaResolveUtil.isAccessible(method, method.getContainingClass(), method.getModifierList(),
|
||||
myPlace, myAccessClass, myCurrentFileContext, myPlaceFile) &&
|
||||
!isShadowed(method);
|
||||
@@ -67,7 +67,7 @@ public class MethodCandidatesProcessor extends MethodsProcessor{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected MethodCandidateInfo createCandidateInfo(final PsiMethod method, final PsiSubstitutor substitutor,
|
||||
protected MethodCandidateInfo createCandidateInfo(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor,
|
||||
final boolean staticProblem, final boolean accessible, final boolean varargs) {
|
||||
final PsiExpressionList argumentList = getArgumentList();
|
||||
return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
|
||||
|
||||
+17
-13
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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
|
||||
* 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
|
||||
* 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.
|
||||
* 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.psi.scope.processor;
|
||||
@@ -51,13 +51,15 @@ public class MethodResolveProcessor implements PsiScopeProcessor, ElementClassHi
|
||||
return myMethods.toArray(new PsiMethod[myMethods.size()]);
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiMethod) {
|
||||
ContainerUtil.addIfNotNull(myMethods, (PsiMethod)element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getHint(@NotNull Key<T> hintKey) {
|
||||
if (hintKey == ElementClassHint.KEY) {
|
||||
return (T)this;
|
||||
@@ -68,9 +70,11 @@ public class MethodResolveProcessor implements PsiScopeProcessor, ElementClassHi
|
||||
return null;
|
||||
}
|
||||
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
@Override
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcess(DeclarationKind kind) {
|
||||
return kind == DeclarationKind.METHOD;
|
||||
}
|
||||
@@ -90,7 +94,7 @@ public class MethodResolveProcessor implements PsiScopeProcessor, ElementClassHi
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getName(ResolveState state) {
|
||||
public String getName(@NotNull ResolveState state) {
|
||||
return myNameHint;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -52,7 +52,7 @@ public class MethodResolverProcessor extends MethodCandidatesProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
if (event == JavaScopeProcessorEvent.CHANGE_LEVEL) {
|
||||
if (myHasAccessibleStaticCorrectCandidate) myStopAcceptingCandidates = true;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class MethodResolverProcessor extends MethodCandidatesProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
return !myStopAcceptingCandidates && super.execute(element, state);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -89,7 +89,7 @@ public abstract class MethodsProcessor extends ConflictFilterProcessor implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
if (event == JavaScopeProcessorEvent.START_STATIC) {
|
||||
myStaticScopeFlag = true;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public abstract class MethodsProcessor extends ConflictFilterProcessor implement
|
||||
this.myIsConstructor = myIsConstructor;
|
||||
}
|
||||
|
||||
public void forceAddResult(PsiMethod method) {
|
||||
public void forceAddResult(@NotNull PsiMethod method) {
|
||||
add(new CandidateInfo(method, PsiSubstitutor.EMPTY, false, false, myCurrentFileContext));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -53,7 +53,7 @@ public abstract class VariablesProcessor extends BaseScopeProcessor implements E
|
||||
|
||||
/** Always return true since we wanna get all vars in scope */
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement pe, ResolveState state){
|
||||
public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state){
|
||||
if(pe instanceof PsiVariable){
|
||||
final PsiVariable pvar = (PsiVariable)pe;
|
||||
if(!myStaticSensitiveFlag || !myStaticScopeFlag || pvar.hasModifierProperty(PsiModifier.STATIC)){
|
||||
@@ -66,7 +66,7 @@ public abstract class VariablesProcessor extends BaseScopeProcessor implements E
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleEvent(Event event, Object associated){
|
||||
public final void handleEvent(@NotNull Event event, Object associated){
|
||||
if(event == JavaScopeProcessorEvent.START_STATIC)
|
||||
myStaticScopeFlag = true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class AddAllMembersProcessor extends BaseScopeProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
PsiMember member = (PsiMember)element;
|
||||
if (!isInteresting(element)) return true;
|
||||
if (myPsiClass.isInterface() && isObjectMember(element)) return true;
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -120,6 +120,7 @@ public class IntObjectPersistentMaplet<V> extends IntObjectMaplet<V>{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush(boolean memoryCachesOnly) {
|
||||
if (memoryCachesOnly) {
|
||||
if (myMap.isDirty()) {
|
||||
@@ -139,7 +140,7 @@ public class IntObjectPersistentMaplet<V> extends IntObjectMaplet<V>{
|
||||
public boolean process(Integer key) {
|
||||
try {
|
||||
final V value = myMap.get(key);
|
||||
return value == null? proc.execute(key, null) : proc.execute(key, value);
|
||||
return proc.execute(key, value);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new BuildDataCorruptedException(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -22,6 +22,7 @@ package com.intellij.psi;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.KeyWithDefaultValue;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -29,15 +30,17 @@ import java.util.Map;
|
||||
public class ResolveState {
|
||||
private static final ResolveState ourInitialState = new ResolveState();
|
||||
|
||||
@NotNull
|
||||
public static ResolveState initial() {
|
||||
return ourInitialState;
|
||||
}
|
||||
|
||||
public <T> ResolveState put(Key<T> key, T value) {
|
||||
@NotNull
|
||||
public <T> ResolveState put(@NotNull Key<T> key, T value) {
|
||||
return new OneElementResolveState(key, value);
|
||||
}
|
||||
|
||||
public <T> T get(Key<T> key) {
|
||||
public <T> T get(@NotNull Key<T> key) {
|
||||
if (key instanceof KeyWithDefaultValue) {
|
||||
return ((KeyWithDefaultValue<T>)key).getDefaultValue();
|
||||
}
|
||||
@@ -45,16 +48,18 @@ public class ResolveState {
|
||||
}
|
||||
|
||||
private static class OneElementResolveState extends ResolveState {
|
||||
final Key myKey;
|
||||
final Object myValue;
|
||||
@NotNull
|
||||
private final Key myKey;
|
||||
private final Object myValue;
|
||||
|
||||
OneElementResolveState(Key key, Object value) {
|
||||
private OneElementResolveState(@NotNull Key key, Object value) {
|
||||
myKey = key;
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> ResolveState put(Key<T> key, T value) {
|
||||
public <T> ResolveState put(@NotNull Key<T> key, T value) {
|
||||
if (myKey.equals(key)) {
|
||||
return new OneElementResolveState(key, value);
|
||||
}
|
||||
@@ -63,7 +68,7 @@ public class ResolveState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Key<T> key) {
|
||||
public <T> T get(@NotNull Key<T> key) {
|
||||
Object value = myKey.equals(key) ? myValue : null;
|
||||
if (value == null && key instanceof KeyWithDefaultValue) {
|
||||
return ((KeyWithDefaultValue<T>)key).getDefaultValue();
|
||||
@@ -73,20 +78,21 @@ public class ResolveState {
|
||||
}
|
||||
|
||||
private static class TwoElementResolveState extends ResolveState {
|
||||
final Key myKey1;
|
||||
final Object myValue1;
|
||||
final Key myKey2;
|
||||
final Object myValue2;
|
||||
@NotNull private final Key myKey1;
|
||||
private final Object myValue1;
|
||||
@NotNull private final Key myKey2;
|
||||
private final Object myValue2;
|
||||
|
||||
TwoElementResolveState(Key key1, Object value1, Key key2, Object value2) {
|
||||
TwoElementResolveState(@NotNull Key key1, Object value1, @NotNull Key key2, Object value2) {
|
||||
myKey1 = key1;
|
||||
myValue1 = value1;
|
||||
myKey2 = key2;
|
||||
myValue2 = value2;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> ResolveState put(Key<T> key, T value) {
|
||||
public <T> ResolveState put(@NotNull Key<T> key, T value) {
|
||||
if (myKey1.equals(key)) {
|
||||
return new TwoElementResolveState(key, value, myKey2, myValue2);
|
||||
}
|
||||
@@ -98,7 +104,7 @@ public class ResolveState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Key<T> key) {
|
||||
public <T> T get(@NotNull Key<T> key) {
|
||||
Object value;
|
||||
if (myKey1.equals(key)) {
|
||||
value = myValue1;
|
||||
@@ -118,27 +124,27 @@ public class ResolveState {
|
||||
}
|
||||
|
||||
private static class ManyElementResolveState extends ResolveState {
|
||||
|
||||
private final Map<Object, Object> myValues = new THashMap<Object, Object>();
|
||||
|
||||
ManyElementResolveState(ManyElementResolveState parent, Key key, Object value) {
|
||||
ManyElementResolveState(@NotNull ManyElementResolveState parent, @NotNull Key key, Object value) {
|
||||
myValues.putAll(parent.myValues);
|
||||
myValues.put(key, value);
|
||||
}
|
||||
|
||||
ManyElementResolveState(TwoElementResolveState twoState, Key key, Object value) {
|
||||
ManyElementResolveState(@NotNull TwoElementResolveState twoState, @NotNull Key key, Object value) {
|
||||
myValues.put(twoState.myKey1, twoState.myValue1);
|
||||
myValues.put(twoState.myKey2, twoState.myValue2);
|
||||
myValues.put(key, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> ResolveState put(Key<T> key, T value) {
|
||||
public <T> ResolveState put(@NotNull Key<T> key, T value) {
|
||||
return new ManyElementResolveState(this, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Key<T> key) {
|
||||
public <T> T get(@NotNull Key<T> key) {
|
||||
final T value = (T)myValues.get(key);
|
||||
if (value == null && key instanceof KeyWithDefaultValue) {
|
||||
return ((KeyWithDefaultValue<T>) key).getDefaultValue();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -31,10 +31,10 @@ public interface PsiScopeProcessor {
|
||||
* @param state current state of resolver.
|
||||
* @return false to stop processing.
|
||||
*/
|
||||
boolean execute(@NotNull PsiElement element, ResolveState state);
|
||||
boolean execute(@NotNull PsiElement element, @NotNull ResolveState state);
|
||||
|
||||
@Nullable
|
||||
<T> T getHint(@NotNull Key<T> hintKey);
|
||||
|
||||
void handleEvent(Event event, @Nullable Object associated);
|
||||
void handleEvent(@NotNull Event event, @Nullable Object associated);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -44,7 +44,7 @@ public abstract class ResolveScopeManager {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static GlobalSearchScope getElementResolveScope(PsiElement element) {
|
||||
public static GlobalSearchScope getElementResolveScope(@NotNull PsiElement element) {
|
||||
return getInstance(element.getProject()).getResolveScope(element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -25,6 +25,6 @@ public abstract class BaseScopeProcessor implements PsiScopeProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -30,11 +30,12 @@ public class PsiElementMemberChooserObject extends MemberChooserObjectBase {
|
||||
myPsiElement = psiElement;
|
||||
}
|
||||
|
||||
public PsiElementMemberChooserObject(final PsiElement psiElement, final String text, @Nullable final Icon icon) {
|
||||
public PsiElementMemberChooserObject(@NotNull PsiElement psiElement, final String text, @Nullable final Icon icon) {
|
||||
super(text, icon);
|
||||
myPsiElement = psiElement;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiElement getPsiElement() {
|
||||
return myPsiElement;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.psi.scope;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -12,12 +27,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class DelegatingScopeProcessor implements PsiScopeProcessor {
|
||||
private final PsiScopeProcessor myDelegate;
|
||||
|
||||
public DelegatingScopeProcessor(PsiScopeProcessor delegate) {
|
||||
public DelegatingScopeProcessor(@NotNull PsiScopeProcessor delegate) {
|
||||
myDelegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
return myDelegate.execute(element, state);
|
||||
}
|
||||
|
||||
@@ -28,7 +43,7 @@ public abstract class DelegatingScopeProcessor implements PsiScopeProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
myDelegate.handleEvent(event, associated);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -45,7 +45,7 @@ public class GradleConfigurationsNonCodeMembersContributor extends NonCodeMember
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
if (place == null || aClass == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -37,7 +37,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class GradleScriptContributor extends NonCodeMembersContributor {
|
||||
|
||||
public final static Set<String> BUILD_PROJECT_SCRIPT_BLOCKS = ContainerUtil.newHashSet(
|
||||
public static final Set<String> BUILD_PROJECT_SCRIPT_BLOCKS = ContainerUtil.newHashSet(
|
||||
"project",
|
||||
"configure",
|
||||
"subprojects",
|
||||
@@ -51,7 +51,7 @@ public class GradleScriptContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
if (place == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -34,7 +34,7 @@ public class GradleSettingsScriptContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
if (place == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.actions.generate.GroovyGenerationInfo;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
@@ -35,10 +36,11 @@ import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
|
||||
public class GrFieldMember extends PsiElementClassMember<PsiField> implements EncapsulatableClassMember {
|
||||
private static final int FIELD_OPTIONS = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.TYPE_AFTER;
|
||||
|
||||
protected GrFieldMember(final PsiField field) {
|
||||
protected GrFieldMember(@NotNull PsiField field) {
|
||||
super(field, PsiFormatUtil.formatVariable(field, FIELD_OPTIONS, PsiSubstitutor.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public GroovyGenerationInfo<GrMethod> generateGetter() {
|
||||
PsiField field = getElement();
|
||||
@@ -52,6 +54,7 @@ public class GrFieldMember extends PsiElementClassMember<PsiField> implements En
|
||||
return existing == null || existing instanceof GrAccessorMethod ? template : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public GroovyGenerationInfo<GrMethod> generateSetter() {
|
||||
PsiField field = getElement();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -31,7 +31,7 @@ public class DynamicMembersContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
if (aClass == null) return;
|
||||
|
||||
final DynamicManager manager = DynamicManager.getInstance(place.getProject());
|
||||
|
||||
+2
-2
@@ -384,7 +384,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
final Ref<Boolean> result = new Ref<Boolean>(false);
|
||||
PsiScopeProcessor processor = new PsiScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiMethod &&
|
||||
name.equals(((PsiMethod)element).getName()) &&
|
||||
patternMethod.getParameterList().getParametersCount() == ((PsiMethod)element).getParameterList().getParametersCount() &&
|
||||
@@ -402,7 +402,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, @Nullable Object associated) {
|
||||
public void handleEvent(@NotNull Event event, @Nullable Object associated) {
|
||||
}
|
||||
};
|
||||
ResolveUtil.treeWalkUp(container, processor, true);
|
||||
|
||||
+19
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -65,14 +65,17 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme
|
||||
((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThisType(PsiType thisType) {
|
||||
myThisType = thisType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getSuperType() {
|
||||
return mySuperType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSuperType(PsiType superType) {
|
||||
mySuperType = superType;
|
||||
}
|
||||
@@ -94,6 +97,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme
|
||||
/**
|
||||
* @return list of imports in format "qname[:imported_name](,qname[:imported_name])*"
|
||||
*/
|
||||
@Override
|
||||
public String importsToString() {
|
||||
if (myPseudoImports.isEmpty()) return "";
|
||||
|
||||
@@ -122,6 +126,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addImportsFromString(String imports) {
|
||||
for (String anImport : imports.split(",")) {
|
||||
int colon = anImport.indexOf(':');
|
||||
@@ -137,48 +142,58 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibilityChecker(JavaCodeFragment.VisibilityChecker checker) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisibilityChecker getVisibilityChecker() {
|
||||
return VisibilityChecker.EVERYTHING_VISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExceptionHandler(ExceptionHandler checker) {
|
||||
myExceptionChecker = checker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExceptionHandler getExceptionHandler() {
|
||||
return myExceptionChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntentionActionsFilter(@NotNull IntentionActionsFilter filter) {
|
||||
myFilter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntentionActionsFilter getIntentionActionsFilter() {
|
||||
return myFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceResolveScope(GlobalSearchScope scope) {
|
||||
myResolveScope = scope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalSearchScope getForcedResolveScope() {
|
||||
return myResolveScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean importClass(PsiClass aClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getThisType() {
|
||||
return myThisType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processImports(PsiScopeProcessor processor,
|
||||
ResolveState state,
|
||||
@NotNull ResolveState state,
|
||||
PsiElement lastParent,
|
||||
PsiElement place,
|
||||
GrImportStatement[] importStatements,
|
||||
@@ -209,7 +224,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme
|
||||
}
|
||||
|
||||
protected boolean processPseudoImports(PsiScopeProcessor processor,
|
||||
ResolveState state,
|
||||
@NotNull ResolveState state,
|
||||
PsiElement lastParent,
|
||||
PsiElement place,
|
||||
boolean onDemand) {
|
||||
@@ -235,7 +250,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean processSingleImports(PsiScopeProcessor processor, ResolveState state, PsiElement lastParent, PsiElement place) {
|
||||
private boolean processSingleImports(PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, PsiElement place) {
|
||||
NameHint nameHint = processor.getHint(NameHint.KEY);
|
||||
String name = nameHint != null ? nameHint.getName(state) : null;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -38,7 +38,7 @@ public class DGMMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
Project project = place.getProject();
|
||||
GlobalSearchScope resolveScope = place.getResolveScope();
|
||||
GroovyPsiManager groovyPsiManager = GroovyPsiManager.getInstance(project);
|
||||
@@ -54,7 +54,7 @@ public class DGMMemberContributor extends NonCodeMembersContributor {
|
||||
|
||||
private static boolean processCategories(PsiType qualifierType,
|
||||
PsiScopeProcessor processor,
|
||||
ResolveState state,
|
||||
@NotNull ResolveState state,
|
||||
Project project,
|
||||
GlobalSearchScope resolveScope,
|
||||
GroovyPsiManager groovyPsiManager, List<String> instanceCategories,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -39,8 +39,8 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class GdkMethodHolder {
|
||||
private static Key<CachedValue<GdkMethodHolder>> CACHED_NON_STATIC = Key.create("Cached instance gdk method holder");
|
||||
private static Key<CachedValue<GdkMethodHolder>> CACHED_STATIC = Key.create("Cached static gdk method holder");
|
||||
private static final Key<CachedValue<GdkMethodHolder>> CACHED_NON_STATIC = Key.create("Cached instance gdk method holder");
|
||||
private static final Key<CachedValue<GdkMethodHolder>> CACHED_STATIC = Key.create("Cached static gdk method holder");
|
||||
|
||||
|
||||
private final ConcurrentFactoryMap<String, MultiMap<String, PsiMethod>> myOriginalMethodsByNameAndType;
|
||||
@@ -90,7 +90,7 @@ public class GdkMethodHolder {
|
||||
return TypesUtil.boxPrimitiveType(TypeConversionUtil.erasure(parameterType), myPsiManager, myScope);
|
||||
}
|
||||
|
||||
public boolean processMethods(PsiScopeProcessor processor, ResolveState state, PsiType qualifierType, Project project) {
|
||||
public boolean processMethods(PsiScopeProcessor processor, @NotNull ResolveState state, PsiType qualifierType, Project project) {
|
||||
if (qualifierType == null) return true;
|
||||
|
||||
NameHint nameHint = processor.getHint(NameHint.KEY);
|
||||
|
||||
@@ -309,7 +309,7 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
|
||||
final DelegatingScopeProcessor nameChecker = new DelegatingScopeProcessor(processor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) {
|
||||
return processor.execute(element, state);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -48,7 +48,7 @@ public class GroovyImportHelper {
|
||||
}
|
||||
}
|
||||
for (String pkg : getImplicitlyImportedPackages(file)) {
|
||||
if (qname.equals(pkg + "." + expectedName) || pkg.length() == 0 && qname.equals(expectedName)) {
|
||||
if (qname.equals(pkg + "." + expectedName) || pkg.isEmpty() && qname.equals(expectedName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class GroovyImportHelper {
|
||||
|
||||
final DelegatingScopeProcessor packageSkipper = new DelegatingScopeProcessor(processor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiPackage) return true;
|
||||
return super.execute(element, state);
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -391,7 +391,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void processImplicitConstructorCall(final PsiMember usage,
|
||||
private static void processImplicitConstructorCall(@NotNull final PsiMember usage,
|
||||
final Processor<PsiReference> processor,
|
||||
final PsiMethod constructor) {
|
||||
if (constructor instanceof GrMethod) {
|
||||
@@ -404,10 +404,12 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase<PsiRefere
|
||||
PsiManager manager = constructor.getManager();
|
||||
if (manager.areElementsEquivalent(usage, constructor) || manager.areElementsEquivalent(constructor.getContainingClass(), usage.getContainingClass())) return;
|
||||
processor.process(new LightMemberReference(manager, usage, PsiSubstitutor.EMPTY) {
|
||||
@Override
|
||||
public PsiElement getElement() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getRangeInElement() {
|
||||
if (usage instanceof PsiClass) {
|
||||
PsiIdentifier identifier = ((PsiClass)usage).getNameIdentifier();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -43,7 +43,7 @@ public class GantMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
if (aClass != null && TypesUtil.getSuperClassesWithCache(aClass).containsKey("groovy.util.AntBuilder")) {
|
||||
processAntTasks(processor, place, state);
|
||||
return;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -39,7 +39,7 @@ public class GebBrowserMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
PsiClass pageClass = GroovyPsiManager.getInstance(aClass.getProject()).findClassWithCache("geb.Page", place.getResolveScope());
|
||||
|
||||
if (pageClass != null) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -38,7 +38,7 @@ public class GebJUnitTestMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
GebUtil.contributeMembersInsideTest(processor, place, state);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -43,7 +43,7 @@ public class GebPageMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
ClassHint classHint = processor.getHint(ClassHint.KEY);
|
||||
if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) return;
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -38,7 +38,7 @@ public class GebSpockTestMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
GebUtil.contributeMembersInsideTest(processor, place, state);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -38,7 +38,7 @@ public class GebTestNGTestMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
GebUtil.contributeMembersInsideTest(processor, place, state);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -169,12 +169,12 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP
|
||||
return false;
|
||||
}
|
||||
|
||||
private static abstract class MyPsiScopeProcessor implements PsiScopeProcessor, NameHint, ClassHint, ElementClassHint {
|
||||
private abstract static class MyPsiScopeProcessor implements PsiScopeProcessor, NameHint, ClassHint, ElementClassHint {
|
||||
private String myNameHint;
|
||||
private EnumSet<ResolveKind> myResolveTargetKinds;
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiMethod || element instanceof PsiField) {
|
||||
String propertyName;
|
||||
PsiType type;
|
||||
@@ -225,7 +225,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(ResolveState state) {
|
||||
public String getName(@NotNull ResolveState state) {
|
||||
return myNameHint;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -76,7 +76,7 @@ public class GdslClosureCompleter extends ClosureCompleter {
|
||||
private static void processExecutors(PsiType qtype, GrReferenceExpression ref, final ArrayList<ClosureDescriptor> descriptors) {
|
||||
GroovyDslFileIndex.processExecutors(qtype, ref, new BaseScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof ClosureDescriptor) {
|
||||
descriptors.add((ClosureDescriptor)element);
|
||||
}
|
||||
|
||||
+5
-3
@@ -115,7 +115,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
final PsiManager manager = file.getManager();
|
||||
PsiScopeProcessor processor = new PsiScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
return !manager.areElementsEquivalent(element, member);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -447,6 +447,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
|
||||
final List<LookupElement> zeroPriority = newArrayList();
|
||||
reference.processVariants(matcher, parameters, new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement lookupElement) {
|
||||
Object object = lookupElement.getObject();
|
||||
if (object instanceof GroovyResolveResult) {
|
||||
@@ -666,6 +667,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
|
||||
private static final String DUMMY_IDENTIFIER_DECAPITALIZED = StringUtil.decapitalize(CompletionUtil.DUMMY_IDENTIFIER);
|
||||
|
||||
@Override
|
||||
public void beforeCompletion(@NotNull final CompletionInitializationContext context) {
|
||||
final String identifier = getIdentifier(context);
|
||||
if (identifier != null) {
|
||||
@@ -729,7 +731,7 @@ public class GroovyCompletionContributor extends CompletionContributor {
|
||||
if (element == null) return DUMMY_IDENTIFIER_DECAPITALIZED;
|
||||
|
||||
final String text = element.getText();
|
||||
if (text.length() == 0) return DUMMY_IDENTIFIER_DECAPITALIZED;
|
||||
if (text.isEmpty()) return DUMMY_IDENTIFIER_DECAPITALIZED;
|
||||
|
||||
return Character.isUpperCase(text.charAt(0)) ? CompletionInitializationContext.DUMMY_IDENTIFIER : DUMMY_IDENTIFIER_DECAPITALIZED;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -100,6 +100,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
super(viewProvider, GroovyFileType.GROOVY_LANGUAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPackageName() {
|
||||
GrPackageDefinition packageDef = getPackageDefinition();
|
||||
@@ -112,6 +113,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrPackageDefinition getPackageDefinition() {
|
||||
final StubElement<?> stub = getStub();
|
||||
if (stub != null) {
|
||||
@@ -138,6 +140,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return mySyntheticArgsParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDeclarations(@NotNull final PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
PsiElement lastParent,
|
||||
@@ -205,7 +208,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
}
|
||||
|
||||
protected boolean processImports(PsiScopeProcessor processor,
|
||||
ResolveState state,
|
||||
@NotNull ResolveState state,
|
||||
PsiElement lastParent,
|
||||
PsiElement place,
|
||||
GrImportStatement[] importStatements,
|
||||
@@ -262,7 +265,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
PsiPackage aPackage = facade.findPackage(packageName);
|
||||
if (aPackage != null && !aPackage.processDeclarations(new DelegatingScopeProcessor(processor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiPackage) return true;
|
||||
return super.execute(element, state);
|
||||
}
|
||||
@@ -294,6 +297,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return !(run instanceof GrTopLevelDefinition || run instanceof GrImportStatement || lastParent instanceof GrMember);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrImportStatement[] getImportStatements() {
|
||||
final StubElement<?> stub = getStub();
|
||||
if (stub != null) {
|
||||
@@ -303,12 +307,14 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return calcTreeElement().getChildrenAsPsiElements(GroovyElementTypes.IMPORT_STATEMENT, GrImportStatement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Icon getIcon(int flags) {
|
||||
final Icon baseIcon = isScript() ? GroovyScriptTypeDetector.getScriptType(this).getScriptIcon() : JetgroovyIcons.Groovy.Groovy_16x16;
|
||||
return ElementBase.createLayeredIcon(this, baseIcon, ElementBase.transformFlags(this, flags));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrImportStatement addImportForClass(PsiClass aClass) {
|
||||
try {
|
||||
// Calculating position
|
||||
@@ -367,6 +373,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return anchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrImportStatement addImport(GrImportStatement statement) throws IncorrectOperationException {
|
||||
PsiElement anchor = getAnchorToInsertImportAfter(statement);
|
||||
final PsiElement result = addAfter(statement, anchor);
|
||||
@@ -377,6 +384,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return gImport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScript() {
|
||||
final StubElement stub = getStub();
|
||||
if (stub instanceof GrFileStub) {
|
||||
@@ -418,6 +426,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
super.subtreeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroovyScriptClass getScriptClass() {
|
||||
if (isScript()) {
|
||||
if (myScriptClass == null) {
|
||||
@@ -435,11 +444,12 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPackageName(String packageName) {
|
||||
final ASTNode fileNode = getNode();
|
||||
assert fileNode != null;
|
||||
final GrPackageDefinition currentPackage = getPackageDefinition();
|
||||
if (packageName == null || packageName.length() == 0) {
|
||||
if (packageName == null || packageName.isEmpty()) {
|
||||
if (currentPackage != null) {
|
||||
final ASTNode currNode = currentPackage.getNode();
|
||||
fileNode.removeChild(currNode);
|
||||
@@ -511,6 +521,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCaches() {
|
||||
super.clearCaches();
|
||||
synchronized (lock) {
|
||||
@@ -519,6 +530,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getContext() {
|
||||
if (myContext != null) {
|
||||
return myContext;
|
||||
@@ -526,6 +538,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return super.getContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"})
|
||||
protected GroovyFileImpl clone() {
|
||||
GroovyFileImpl clone = (GroovyFileImpl)super.clone();
|
||||
@@ -543,6 +556,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiClass[] getClasses() {
|
||||
final PsiClass[] declaredDefs = super.getClasses();
|
||||
@@ -554,6 +568,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getOriginalElement() {
|
||||
final PsiClass scriptClass = getScriptClass();
|
||||
if (scriptClass != null) {
|
||||
|
||||
+10
-2
@@ -65,6 +65,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return getParentByStub();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitImportStatement(this);
|
||||
}
|
||||
@@ -73,6 +74,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return "Import statement";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
@Nullable PsiElement lastParent,
|
||||
@@ -101,7 +103,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean processDeclarationsForSingleElement(PsiScopeProcessor processor, ResolveState state) {
|
||||
private boolean processDeclarationsForSingleElement(PsiScopeProcessor processor, @NotNull ResolveState state) {
|
||||
String name = getImportedName();
|
||||
if (name == null) return true;
|
||||
|
||||
@@ -160,7 +162,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
}
|
||||
|
||||
private boolean processSingleStaticImport(PsiScopeProcessor processor,
|
||||
ResolveState state,
|
||||
@NotNull ResolveState state,
|
||||
String importedName,
|
||||
NameHint nameHint,
|
||||
GrCodeReferenceElement ref) {
|
||||
@@ -261,6 +263,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrCodeReferenceElement getImportReference() {
|
||||
GrImportStatementStub stub = getStub();
|
||||
if (stub != null) {
|
||||
@@ -275,6 +278,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return (GrCodeReferenceElement)findChildByType(GroovyElementTypes.REFERENCE_ELEMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getImportedName() {
|
||||
if (isOnDemand()) return null;
|
||||
@@ -302,6 +306,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return ref == null ? null : ref.getReferenceName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
GrImportStatementStub stub = getStub();
|
||||
if (stub != null) {
|
||||
@@ -311,6 +316,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return findChildByType(GroovyTokenTypes.kSTATIC) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAliasedImport() {
|
||||
GrImportStatementStub stub = getStub();
|
||||
if (stub != null) {
|
||||
@@ -319,6 +325,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return getAliasNameElement() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnDemand() {
|
||||
GrImportStatementStub stub = getStub();
|
||||
if (stub != null) {
|
||||
@@ -327,6 +334,7 @@ public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementSt
|
||||
return findChildByType(GroovyTokenTypes.mSTAR) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public GrModifierList getAnnotationList() {
|
||||
GrImportStatementStub stub = getStub();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class GdkMethodUtil {
|
||||
@NotNull final PsiClass categoryClass) {
|
||||
final DelegatingScopeProcessor delegate = new DelegatingScopeProcessor(processor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState delegateState) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState delegateState) {
|
||||
if (element instanceof PsiMethod && isCategoryMethod((PsiMethod)element, null, null, null)) {
|
||||
PsiMethod method = (PsiMethod)element;
|
||||
return processor.execute(GrGdkMethodImpl.createGdkMethod(method, false, generateOriginInfo(method)), delegateState);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -202,7 +202,7 @@ class DeclarationCacheKey {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
declarations.add(Pair.create(element, state));
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -52,7 +52,7 @@ public abstract class NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
processDynamicElements(qualifierType, processor, place, state);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public abstract class NonCodeMembersContributor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (!wantMore) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -789,7 +789,7 @@ public class ResolveUtil {
|
||||
ContainerUtil.addAll(allCandidates, applicable);
|
||||
}
|
||||
|
||||
if (allCandidates.size() > 0) {
|
||||
if (!allCandidates.isEmpty()) {
|
||||
return allCandidates.toArray(new GroovyResolveResult[allCandidates.size()]);
|
||||
}
|
||||
else if (!hasApplicableMethods) {
|
||||
@@ -960,7 +960,7 @@ public class ResolveUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (myBorderPassed) {
|
||||
return false;
|
||||
}
|
||||
@@ -972,7 +972,7 @@ public class ResolveUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
if (event == DECLARATION_SCOPE_PASSED) {
|
||||
myBorderPassed = true;
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -41,11 +41,11 @@ public class GrCollectionTypeMembersProvider extends NonCodeMembersContributor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processDynamicElements(final @NotNull PsiType qualifierType,
|
||||
public void processDynamicElements(@NotNull final PsiType qualifierType,
|
||||
PsiClass aClass,
|
||||
final PsiScopeProcessor processor,
|
||||
final PsiElement place,
|
||||
final ResolveState state) {
|
||||
@NotNull final ResolveState state) {
|
||||
final PsiType collectionType = PsiUtil.extractIterableTypeParameter(qualifierType, true);
|
||||
if (collectionType == null) return;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class GrCollectionTypeMembersProvider extends NonCodeMembersContributor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiField) {
|
||||
final PsiType type = ((PsiField)element).getType();
|
||||
final String typeText =
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -146,7 +146,7 @@ public class MixinMemberContributor extends NonCodeMembersContributor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiMethod && GdkMethodUtil.isCategoryMethod((PsiMethod)element, myType, myPlace, state.get(PsiSubstitutor.KEY))) {
|
||||
PsiMethod method = (PsiMethod)element;
|
||||
String originInfo = getOriginInfoForCategory(method);
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -34,7 +34,8 @@ public class CompletionProcessor extends ResolverProcessor {
|
||||
super(name, resolveTargets, place, PsiType.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState substitutor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) {
|
||||
if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) {
|
||||
return true;
|
||||
}
|
||||
@@ -54,6 +55,7 @@ public class CompletionProcessor extends ResolverProcessor {
|
||||
return new CompletionProcessor(place, RESOLVE_KINDS_CLASS_PACKAGE, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public GroovyResolveResult[] getCandidates() {
|
||||
if (!super.hasCandidates()) return GroovyResolveResult.EMPTY_ARRAY;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -37,7 +37,7 @@ public class JavaResolverProcessor extends DelegatingScopeProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (myHint != null && element instanceof PsiNamedElement) {
|
||||
final String expectedName = myHint.getName(state);
|
||||
final String elementName = ((PsiNamedElement)element).getName();
|
||||
|
||||
+1
-1
@@ -377,7 +377,7 @@ public class MethodResolverProcessor extends ResolverProcessor implements GrMeth
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
super.handleEvent(event, associated);
|
||||
if (JavaScopeProcessorEvent.CHANGE_LEVEL == event && super.hasCandidates()) {
|
||||
myStopExecuting = true;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -36,7 +36,7 @@ public class PropertyResolverProcessor extends ResolverProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
return super.execute(element, state) || element instanceof PsiField;
|
||||
}
|
||||
|
||||
|
||||
+9
-4
@@ -54,8 +54,7 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint
|
||||
private final EnumSet<ResolveKind> myResolveTargetKinds;
|
||||
private Set<String> myProcessedClasses;
|
||||
protected PsiElement myPlace;
|
||||
private
|
||||
@NotNull final PsiType[] myTypeArguments;
|
||||
@NotNull private final PsiType[] myTypeArguments;
|
||||
|
||||
private List<GroovyResolveResult> myCandidates;
|
||||
|
||||
@@ -69,6 +68,7 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint
|
||||
myTypeArguments = typeArguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiLocalVariableImpl) { //todo a better hack
|
||||
return true; // the debugger creates a Java code block context and our expressions to evaluate resolve there
|
||||
@@ -173,6 +173,7 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint
|
||||
return myCandidates.toArray(new GroovyResolveResult[myCandidates.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public <T> T getHint(@NotNull Key<T> hintKey) {
|
||||
if ((NameHint.KEY == hintKey && myName != null) || ClassHint.KEY == hintKey || ElementClassHint.KEY == hintKey) {
|
||||
@@ -182,17 +183,20 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint
|
||||
return null;
|
||||
}
|
||||
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
@Override
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcess(ResolveKind resolveKind) {
|
||||
return myResolveTargetKinds.contains(resolveKind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcess(DeclarationKind kind) {
|
||||
switch (kind) {
|
||||
case CLASS:
|
||||
@@ -226,7 +230,8 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName(ResolveState state) {
|
||||
@Override
|
||||
public String getName(@NotNull ResolveState state) {
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -40,7 +40,7 @@ public class XmlMarkupBuilderNonCodeMemberContributor extends NonCodeMembersCont
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
String nameHint = ResolveUtil.getNameHint(processor);
|
||||
|
||||
if (nameHint == null) return;
|
||||
|
||||
+15
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -89,6 +89,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
private static final Logger LOG =
|
||||
Logger.getInstance("#org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureUsageProcessor");
|
||||
|
||||
@Override
|
||||
public UsageInfo[] findUsages(ChangeInfo info) {
|
||||
if (info instanceof JavaChangeInfo) {
|
||||
return new GrChageSignatureUsageSearcher((JavaChangeInfo)info).findUsages();
|
||||
@@ -96,6 +97,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
return UsageInfo.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiMap<PsiElement, String> findConflicts(ChangeInfo info, Ref<UsageInfo[]> refUsages) {
|
||||
if (info instanceof JavaChangeInfo) {
|
||||
return new GrChangeSignatureConflictSearcher((JavaChangeInfo)info).findConflicts(refUsages);
|
||||
@@ -105,6 +107,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processPrimaryMethod(ChangeInfo changeInfo) {
|
||||
if (!(changeInfo instanceof GrChangeInfoImpl)) return false;
|
||||
|
||||
@@ -117,6 +120,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
return processPrimaryMethodInner(grInfo, method, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPreviewUsages(ChangeInfo changeInfo, UsageInfo[] usages) {
|
||||
if (!StringUtil.isJavaIdentifier(changeInfo.getNewName())) return true;
|
||||
|
||||
@@ -397,6 +401,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processUsage(ChangeInfo changeInfo, UsageInfo usageInfo, boolean beforeMethodChange, UsageInfo[] usages) {
|
||||
if (!(changeInfo instanceof JavaChangeInfo)) return false;
|
||||
|
||||
@@ -532,7 +537,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
GrClosureSignatureUtil.ArgInfo<PsiElement> argInfo = map[index];
|
||||
List<PsiElement> arguments = argInfo.args;
|
||||
if (argInfo.isMultiArg) { //arguments for Map and varArg
|
||||
if ((i != 0 || !(arguments.size() > 0 && arguments.iterator().next() instanceof GrNamedArgument)) &&
|
||||
if ((i != 0 || !(!arguments.isEmpty() && arguments.iterator().next() instanceof GrNamedArgument)) &&
|
||||
(i != parameters.length - 1 || !parameter.isVarargType())) {
|
||||
final PsiType type = parameter.createType(changeInfo.getMethod().getParameterList(), argumentList.getManager());
|
||||
final GrExpression arg = GroovyRefactoringUtil.generateArgFromMultiArg(substitutor, arguments, type, element.getProject());
|
||||
@@ -605,7 +610,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
}
|
||||
|
||||
GrCall call = GroovyRefactoringUtil.getCallExpressionByMethodReference(element);
|
||||
if (argumentList.getText().trim().length() == 0 && (call == null || !PsiImplUtil.hasClosureArguments(call))) {
|
||||
if (argumentList.getText().trim().isEmpty() && (call == null || !PsiImplUtil.hasClosureArguments(call))) {
|
||||
argumentList = argumentList.replaceWithArgumentList(factory.createArgumentList());
|
||||
}
|
||||
CodeStyleManager.getInstance(argumentList.getProject()).reformat(argumentList);
|
||||
@@ -627,6 +632,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(list.getProject()).getResolveHelper();
|
||||
final PsiType type = info.getTypeWrapper().getType(changeInfo.getMethod(), list.getManager());
|
||||
final VariablesProcessor processor = new VariablesProcessor(false) {
|
||||
@Override
|
||||
protected boolean check(PsiVariable var, ResolveState state) {
|
||||
if (var instanceof PsiField && !resolveHelper.isAccessible((PsiField)var, list, null)) return false;
|
||||
if (var instanceof GrVariable &&
|
||||
@@ -640,7 +646,8 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
return type.isAssignableFrom(varType);
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull PsiElement pe, ResolveState state) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state) {
|
||||
super.execute(pe, state);
|
||||
return size() < 2;
|
||||
}
|
||||
@@ -696,6 +703,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
else if (context instanceof GrTryCatchStatement) {
|
||||
final GrCatchClause[] catchClauses = ((GrTryCatchStatement)context).getCatchClauses();
|
||||
List<PsiClassType> referencedTypes = ContainerUtil.map(catchClauses, new Function<GrCatchClause, PsiClassType>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiClassType fun(GrCatchClause grCatchClause) {
|
||||
final GrParameter grParameter = grCatchClause.getParameter();
|
||||
@@ -738,6 +746,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
|
||||
final GrCatchClause[] clauses = tryCatch.getCatchClauses();
|
||||
List<String> restricted = ContainerUtil.map(clauses, new Function<GrCatchClause, String>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public String fun(GrCatchClause grCatchClause) {
|
||||
final GrParameter grParameter = grCatchClause.getParameter();
|
||||
@@ -764,6 +773,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
final GroovyPsiElement context,
|
||||
final PsiClassType[] handledExceptions) {
|
||||
return ContainerUtil.findAll(exceptions, new Condition<PsiClassType>() {
|
||||
@Override
|
||||
public boolean value(PsiClassType o) {
|
||||
if (!InheritanceUtil.isInheritor(o, CommonClassNames.JAVA_LANG_EXCEPTION)) return false;
|
||||
for (PsiClassType type : handledExceptions) {
|
||||
@@ -776,6 +786,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc
|
||||
|
||||
private static PsiClassType[] getExceptions(ThrownExceptionInfo[] infos, final PsiElement context, final PsiManager manager) {
|
||||
return ContainerUtil.map(infos, new Function<ThrownExceptionInfo, PsiClassType>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiClassType fun(ThrownExceptionInfo thrownExceptionInfo) {
|
||||
return (PsiClassType)thrownExceptionInfo.createType(context, manager);
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -94,8 +94,8 @@ import static org.jetbrains.plugins.groovy.refactoring.convertToJava.TypeWriter.
|
||||
public class ExpressionGenerator extends Generator {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.refactoring.convertToJava.ExpressionGenerator");
|
||||
|
||||
private StringBuilder builder;
|
||||
private GroovyPsiElementFactory factory;
|
||||
private final StringBuilder builder;
|
||||
private final GroovyPsiElementFactory factory;
|
||||
|
||||
private final ExpressionContext context;
|
||||
|
||||
@@ -129,6 +129,7 @@ public class ExpressionGenerator extends Generator {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void visitExpression(GrExpression expression) {
|
||||
LOG.error("this method should not be invoked");
|
||||
}
|
||||
@@ -1411,7 +1412,7 @@ public class ExpressionGenerator extends Generator {
|
||||
final CheckProcessElement processor = new CheckProcessElement(method);
|
||||
ResolveUtil.processAllDeclarationsSeparately(conjunct, processor, new BaseScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
return false;
|
||||
}
|
||||
}, ResolveState.initial(), context);
|
||||
|
||||
+5
-26
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -59,27 +59,6 @@ import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBAND;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBAND_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBOR;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBOR_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBSR_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBXOR;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBXOR_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDIV;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDIV_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMINUS;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMINUS_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMOD;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMOD_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mPLUS;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mPLUS_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSL_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSR_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR_STAR;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR_STAR_ASSIGN;
|
||||
import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*;
|
||||
import static org.jetbrains.plugins.groovy.refactoring.convertToJava.TypeWriter.writeType;
|
||||
|
||||
@@ -226,7 +205,7 @@ public class GenerationUtil {
|
||||
}
|
||||
else {
|
||||
addParentheses =
|
||||
context != null && (context.shouldInsertCurlyBrackets() || context.myStatements.size() > 0) && parent instanceof GrControlStatement;
|
||||
context != null && (context.shouldInsertCurlyBrackets() || !context.myStatements.isEmpty()) && parent instanceof GrControlStatement;
|
||||
}
|
||||
|
||||
if (addParentheses) {
|
||||
@@ -541,7 +520,7 @@ public class GenerationUtil {
|
||||
final CheckProcessElement checker = new CheckProcessElement(member);
|
||||
ResolveUtil.processAllDeclarationsSeparately(declared, checker, new BaseScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
return false;
|
||||
}
|
||||
}, ResolveState.initial(), qualifier);
|
||||
@@ -561,7 +540,7 @@ public class GenerationUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (myManager.areElementsEquivalent(element, myMember)) {
|
||||
myResult = true;
|
||||
return false;
|
||||
@@ -575,7 +554,7 @@ public class GenerationUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
}
|
||||
|
||||
public boolean isFound() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -40,7 +40,7 @@ public class SpockMemberContributor extends NonCodeMembersContributor {
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
ClassHint classHint = processor.getHint(ClassHint.KEY);
|
||||
if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) {
|
||||
GrMethod method = PsiTreeUtil.getParentOfType(place, GrMethod.class);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -833,7 +833,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
ClassHint classHint = processor.getHint(ClassHint.KEY);
|
||||
if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -287,7 +287,7 @@ public class JavaI18nUtil extends I18nUtil {
|
||||
private static void addAvailableMethodsOfType(final PsiClassType type, final PsiLiteralExpression context, final Collection<String> result) {
|
||||
PsiScopesUtil.treeWalkUp(new PsiScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod)element;
|
||||
PsiType returnType = method.getReturnType();
|
||||
@@ -305,7 +305,7 @@ public class JavaI18nUtil extends I18nUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
|
||||
}
|
||||
}, context, null);
|
||||
|
||||
+16
-1
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.maven.plugins.groovy;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
@@ -36,7 +51,7 @@ public class MavenGroovyPomScriptMemberContributor extends NonCodeMembersContrib
|
||||
PsiClass aClass,
|
||||
PsiScopeProcessor processor,
|
||||
PsiElement place,
|
||||
ResolveState state) {
|
||||
@NotNull ResolveState state) {
|
||||
PsiElement pomElement = aClass.getContainingFile().getContext();
|
||||
if (pomElement == null) return;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -45,7 +45,7 @@ public class PyDunderAllReference extends PsiReferenceBase<PyStringLiteralExpres
|
||||
public PyDunderAllReference(@NotNull PyStringLiteralExpression element) {
|
||||
super(element);
|
||||
final List<TextRange> ranges = element.getStringValueTextRanges();
|
||||
if (ranges.size() > 0) {
|
||||
if (!ranges.isEmpty()) {
|
||||
setRangeInElement(ranges.get(0));
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class PyDunderAllReference extends PsiReferenceBase<PyStringLiteralExpres
|
||||
}
|
||||
containingFile.processDeclarations(new PsiScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiNamedElement && !(element instanceof LightNamedElement)) {
|
||||
final String name = ((PsiNamedElement)element).getName();
|
||||
if (name != null && PyUtil.getInitialUnderscores(name) == 0 && !seenNames.contains(name)) {
|
||||
@@ -94,7 +94,7 @@ public class PyDunderAllReference extends PsiReferenceBase<PyStringLiteralExpres
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, @Nullable Object associated) {
|
||||
public void handleEvent(@NotNull Event event, @Nullable Object associated) {
|
||||
}
|
||||
}, ResolveState.initial(), null, containingFile);
|
||||
return ArrayUtil.toObjectArray(result);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -62,7 +62,7 @@ import java.util.*;
|
||||
|
||||
public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
protected PyType myType;
|
||||
private ThreadLocal<List<String>> myFindExportedNameStack = new ArrayListThreadLocal();
|
||||
private final ThreadLocal<List<String>> myFindExportedNameStack = new ArrayListThreadLocal();
|
||||
|
||||
//private volatile Boolean myAbsoluteImportEnabled;
|
||||
private final Map<FutureFeature, Boolean> myFutureFeatures;
|
||||
@@ -251,6 +251,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
myModificationTracker = PsiModificationTracker.SERVICE.getInstance(getProject());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public FileType getFileType() {
|
||||
return PythonFileType.INSTANCE;
|
||||
@@ -260,14 +261,17 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return "PyFile:" + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyFunction findTopLevelFunction(String name) {
|
||||
return findByName(name, getTopLevelFunctions());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyClass findTopLevelClass(String name) {
|
||||
return findByName(name, getTopLevelClasses());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PyTargetExpression findTopLevelAttribute(String name) {
|
||||
return findByName(name, getTopLevelAttributes());
|
||||
}
|
||||
@@ -282,6 +286,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LanguageLevel getLanguageLevel() {
|
||||
if (myOriginalFile != null) {
|
||||
return ((PyFileImpl) myOriginalFile).getLanguageLevel();
|
||||
@@ -297,10 +302,12 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return PyUtil.getLanguageLevelForVirtualFile(getProject(), virtualFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int flags) {
|
||||
return PythonFileType.INSTANCE.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (isAcceptedFor(visitor.getClass())) {
|
||||
if (visitor instanceof PyElementVisitor) {
|
||||
@@ -334,7 +341,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
final List<String> remainingDunderAll = dunderAll == null ? null : new ArrayList<String>(dunderAll);
|
||||
PsiScopeProcessor wrapper = new PsiScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (!processor.execute(element, state)) return false;
|
||||
if (remainingDunderAll != null && element instanceof PyElement) {
|
||||
remainingDunderAll.remove(((PyElement) element).getName());
|
||||
@@ -348,7 +355,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, @Nullable Object associated) {
|
||||
public void handleEvent(@NotNull Event event, @Nullable Object associated) {
|
||||
processor.handleEvent(event, associated);
|
||||
}
|
||||
};
|
||||
@@ -394,6 +401,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PyStatement> getStatements() {
|
||||
List<PyStatement> stmts = new ArrayList<PyStatement>();
|
||||
for (PsiElement child : getChildren()) {
|
||||
@@ -405,14 +413,17 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return stmts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PyClass> getTopLevelClasses() {
|
||||
return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.CLASS_DECLARATION, PyClass.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PyFunction> getTopLevelFunctions() {
|
||||
return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.FUNCTION_DECLARATION, PyFunction.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PyTargetExpression> getTopLevelAttributes() {
|
||||
return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.TARGET_EXPRESSION, PyTargetExpression.class);
|
||||
}
|
||||
@@ -502,6 +513,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiElement getElementNamed(String name) {
|
||||
PsiElement exportedName = findExportedName(name);
|
||||
@@ -518,6 +530,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return exportedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Iterable<PyElement> iterateNames() {
|
||||
final List<PyElement> result = new ArrayList<PyElement>();
|
||||
@@ -535,10 +548,12 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mustResolveOutside() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<PyImportElement> getImportTargets() {
|
||||
List<PyImportElement> ret = new ArrayList<PyImportElement>();
|
||||
@@ -549,6 +564,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<PyFromImportStatement> getFromImports() {
|
||||
return PyPsiUtils.collectStubChildren(this, getStub(), PyElementTypes.FROM_IMPORT_STATEMENT, PyFromImportStatement.class);
|
||||
@@ -581,7 +597,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
private boolean myFoundDunderAll = false;
|
||||
|
||||
// hashlib builds __all__ by concatenating multiple lists of strings, and we want to understand this
|
||||
private Map<String, List<String>> myDunderLike = new HashMap<String, List<String>>();
|
||||
private final Map<String, List<String>> myDunderLike = new HashMap<String, List<String>>();
|
||||
|
||||
@Override
|
||||
public void visitPyTargetExpression(PyTargetExpression node) {
|
||||
@@ -654,6 +670,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasImportFromFuture(FutureFeature feature) {
|
||||
final StubElement stub = getStub();
|
||||
if (stub instanceof PyFileStub) {
|
||||
@@ -718,6 +735,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PyType getType(@NotNull TypeEvalContext context, @NotNull TypeEvalContext.Key key) {
|
||||
if (myType == null) myType = new PyModuleType(this);
|
||||
return myType;
|
||||
@@ -741,6 +759,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
|
||||
return DocStringUtil.findDocStringExpression(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subtreeChanged() {
|
||||
super.subtreeChanged();
|
||||
ControlFlowCache.clear(this);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -49,7 +49,8 @@ public class AssignmentCollectProcessor implements PsiScopeProcessor {
|
||||
mySeenNames = new HashSet<String>();
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull final PsiElement element, final ResolveState state) {
|
||||
@Override
|
||||
public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) {
|
||||
if (element instanceof PyAssignmentStatement) {
|
||||
final PyAssignmentStatement assignment = (PyAssignmentStatement)element;
|
||||
for (PyExpression ex : assignment.getTargets()) {
|
||||
@@ -81,11 +82,13 @@ public class AssignmentCollectProcessor implements PsiScopeProcessor {
|
||||
return myResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getHint(@NotNull final Key<T> hintKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void handleEvent(final Event event, final Object associated) {
|
||||
@Override
|
||||
public void handleEvent(@NotNull final Event event, final Object associated) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -70,7 +70,8 @@ public class ResolveProcessor implements PsiScopeProcessor {
|
||||
return PyUtil.nvl(myName) + ", " + PyUtil.nvl(myResult);
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState substitutor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) {
|
||||
if (element instanceof PyFile) {
|
||||
final VirtualFile file = ((PyFile)element).getVirtualFile();
|
||||
if (file != null) {
|
||||
@@ -173,12 +174,14 @@ public class ResolveProcessor implements PsiScopeProcessor {
|
||||
return definer.getElementNamed(myName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getHint(@NotNull Key<T> hintKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
@Override
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
}
|
||||
|
||||
private boolean setResult(PsiElement result, @Nullable PsiElement definer) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -60,7 +60,8 @@ public abstract class VariantsProcessor implements PsiScopeProcessor {
|
||||
}
|
||||
|
||||
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState substitutor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) {
|
||||
if (myNodeFilter != null && !myNodeFilter.value(element)) return true; // skip whatever the filter rejects
|
||||
// TODO: refactor to look saner; much code duplication
|
||||
if (element instanceof PsiNamedElement) {
|
||||
@@ -141,12 +142,14 @@ public abstract class VariantsProcessor implements PsiScopeProcessor {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getHint(@NotNull Key<T> hintKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void handleEvent(Event event, Object associated) {
|
||||
@Override
|
||||
public void handleEvent(@NotNull Event event, Object associated) {
|
||||
}
|
||||
|
||||
public void setAllowedNames(List<String> namesFilter) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -218,7 +218,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
final List<PyImportElement> visibleImports = new ArrayList<PyImportElement>();
|
||||
PyResolveUtil.scopeCrawlUp(new PsiScopeProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState state) {
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PyImportElement) {
|
||||
visibleImports.add((PyImportElement)element);
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event, @Nullable Object associated) {
|
||||
public void handleEvent(@NotNull Event event, @Nullable Object associated) {
|
||||
}
|
||||
}, owner, null, null);
|
||||
return visibleImports;
|
||||
|
||||
@@ -65,12 +65,14 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getPrefix() {
|
||||
final String[] parts = EscapeUtil.unescapeText(getNode()).split(":", 2);
|
||||
return parts.length == 2 ? parts[0] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getLocalPart() {
|
||||
final String[] parts = EscapeUtil.unescapeText(getNode()).split(":", 2);
|
||||
@@ -87,14 +89,17 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference
|
||||
return getPrefix() == null ? null : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getElement() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getRangeInElement() {
|
||||
return TextRange.from(0, getText().indexOf(':'));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiElement resolve() {
|
||||
final MyResolver resolver = new MyResolver(getPrefix(), getKind());
|
||||
@@ -111,11 +116,13 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getCanonicalText() {
|
||||
return getRangeInElement().substring(getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
|
||||
final ASTNode node = getNode();
|
||||
final ASTNode child = RenameUtil.createPrefixedNode(getManager(), newElementName, getLocalPart());
|
||||
@@ -123,24 +130,29 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference
|
||||
return child.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReferenceTo(PsiElement element) {
|
||||
return element instanceof RncElement && Comparing.equal(resolve(), element);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Object[] getVariants() {
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSoft() {
|
||||
final String prefix = getPrefix();
|
||||
return "xsd".equals(prefix) || "xml".equals(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getUnresolvedMessagePattern() {
|
||||
return "Unresolved namespace prefix ''{0}''";
|
||||
@@ -165,7 +177,8 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference
|
||||
myKind = kind;
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull PsiElement element, ResolveState substitutor) {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) {
|
||||
final ASTNode node = element.getNode();
|
||||
if (node == null) return true;
|
||||
|
||||
@@ -203,11 +216,13 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference
|
||||
myReference = reference;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return getFamilyName() + " '" + myReference.getPrefix() + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return "Create " + myReference.getKind().name().toLowerCase() + " declaration";
|
||||
@@ -265,14 +280,17 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference
|
||||
final Template t = manager.createTemplate("", "");
|
||||
t.addTextSegment(" \"");
|
||||
final Expression expression = new Expression() {
|
||||
@Override
|
||||
public Result calculateResult(ExpressionContext context) {
|
||||
return new TextResult("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result calculateQuickResult(ExpressionContext context) {
|
||||
return calculateResult(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LookupItem[] calculateLookupItems(ExpressionContext context) {
|
||||
return LookupItem.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user