private PsiType findInitializerType( PsiElement firstElem ) { PsiElement csr = firstElem; while( csr != null && !(csr instanceof PsiLocalVariableImpl) ) { csr = csr.getParent(); } if( csr instanceof PsiLocalVariableImpl ) { PsiExpression initializer = ((PsiLocalVariableImpl)csr).getInitializer(); return initializer == null ? null : initializer.getType(); } return null; }
@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 } if (myResolveTargetKinds.contains(getResolveKind(element))) { //hack for resolve of java local vars and parameters //don't check field for name because they can be aliased imported if (element instanceof PsiVariable && !(element instanceof PsiField) && getName() != null && !getName().equals(((PsiVariable)element).getName())) { return true; } PsiNamedElement namedElement = (PsiNamedElement)element; PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY); if (substitutor == null) substitutor = PsiSubstitutor.EMPTY; if (myTypeArguments.length > 0 && namedElement instanceof PsiClass) { substitutor = substitutor.putAll((PsiClass)namedElement, myTypeArguments); } if (namedElement instanceof PsiClass && !(namedElement instanceof PsiTypeParameter)) { final PsiClass aClass = (PsiClass)namedElement; if (myProcessedClasses == null) myProcessedClasses = new HashSet<String>(); if (!myProcessedClasses.add(aClass.getQualifiedName())) { return true; } } boolean isAccessible = isAccessible(namedElement); final PsiElement resolveContext = state.get(RESOLVE_CONTEXT); final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE); boolean isStaticsOK = isStaticsOK(namedElement, resolveContext, false); addCandidate(new GroovyResolveResultImpl(namedElement, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK)); return !(isAccessible && isStaticsOK); } return true; }
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 } if (myResolveTargetKinds.contains(getResolveKind(element))) { //hack for resolve of java local vars and parameters //don't check field for name because they can be aliased imported if (element instanceof PsiVariable && !(element instanceof PsiField) && myName != null && !myName.equals(((PsiVariable)element).getName())) { return true; } PsiNamedElement namedElement = (PsiNamedElement)element; PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY); if (substitutor == null) substitutor = PsiSubstitutor.EMPTY; if (myTypeArguments.length > 0 && namedElement instanceof PsiClass) { substitutor = substitutor.putAll((PsiClass)namedElement, myTypeArguments); } if (namedElement instanceof PsiClass && !(namedElement instanceof PsiTypeParameter)) { final PsiClass aClass = (PsiClass)namedElement; if (myProcessedClasses == null) myProcessedClasses = new HashSet<String>(); if (!myProcessedClasses.add(aClass.getQualifiedName())) { return true; } } boolean isAccessible = isAccessible(namedElement); final PsiElement resolveContext = state.get(RESOLVE_CONTEXT); final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE); boolean isStaticsOK = isStaticsOK(namedElement, resolveContext, true); addCandidate(new GroovyResolveResultImpl(namedElement, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK)); return !(isAccessible && isStaticsOK); } return true; }