use of com.intellij.psi.ResolveState in project intellij-community by JetBrains.
the class PyDebugProcess method resolveInCurrentFrame.
@NotNull
private static Ref<PsiElement> resolveInCurrentFrame(final String name, XSourcePosition currentPosition, PsiFile file) {
final Ref<PsiElement> elementRef = Ref.create();
PsiElement currentElement = file.findElementAt(currentPosition.getOffset());
if (currentElement == null) {
return elementRef;
}
PyResolveUtil.scopeCrawlUp(new PsiScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if ((element instanceof PyImportElement)) {
PyImportElement importElement = (PyImportElement) element;
if (name.equals(importElement.getVisibleName())) {
if (elementRef.isNull()) {
elementRef.set(element);
}
return false;
}
return true;
} else {
if (elementRef.isNull()) {
elementRef.set(element);
}
return false;
}
}
@Nullable
@Override
public <T> T getHint(@NotNull Key<T> hintKey) {
return null;
}
@Override
public void handleEvent(@NotNull Event event, @Nullable Object associated) {
}
}, currentElement, name, null);
return elementRef;
}
use of com.intellij.psi.ResolveState in project intellij-elixir by KronicDeth.
the class Variants method lookupElementList.
/*
* Static Methods
*/
@Nullable
public static List<LookupElement> lookupElementList(@NotNull PsiElement entrance) {
Variants variants = new Variants();
Parameter parameter = Parameter.putParameterized(new Parameter(entrance));
Call entranceCallDefinitionClause = null;
if (parameter.isCallDefinitionClauseName()) {
entranceCallDefinitionClause = (Call) parameter.parameterized;
}
ResolveState resolveState = ResolveState.initial().put(ENTRANCE, entrance).put(ENTRANCE_CALL_DEFINITION_CLAUSE, entranceCallDefinitionClause);
PsiTreeUtil.treeWalkUp(variants, entrance, entrance.getContainingFile(), resolveState);
List<LookupElement> lookupElementList = new ArrayList<LookupElement>();
lookupElementList.addAll(variants.getLookupElementCollection());
return lookupElementList;
}
use of com.intellij.psi.ResolveState in project intellij-elixir by KronicDeth.
the class CallDefinitionClause method implicitImports.
private boolean implicitImports(@NotNull PsiElement element, @NotNull ResolveState state) {
Project project = element.getProject();
boolean keepProcessing = org.elixir_lang.reference.Module.forEachNavigationElement(project, KERNEL, new Function<PsiElement, Boolean>() {
@Override
public Boolean fun(PsiElement navigationElement) {
boolean keepProcessingNavigationElements = true;
if (navigationElement instanceof Call) {
Call modular = (Call) navigationElement;
keepProcessingNavigationElements = Modular.callDefinitionClauseCallWhile(modular, new Function<Call, Boolean>() {
@Override
public Boolean fun(Call callDefinitionClause) {
return executeOnCallDefinitionClause(callDefinitionClause, state);
}
});
}
return keepProcessingNavigationElements;
}
});
// the implicit `import Kernel.SpecialForms`
if (keepProcessing) {
ResolveState modularCanonicalNameState = state.put(MODULAR_CANONICAL_NAME, KERNEL_SPECIAL_FORMS);
keepProcessing = org.elixir_lang.reference.Module.forEachNavigationElement(project, KERNEL_SPECIAL_FORMS, new Function<PsiElement, Boolean>() {
@Override
public Boolean fun(PsiElement navigationElement) {
boolean keepProcessingNavigationElements = true;
if (navigationElement instanceof Call) {
Call modular = (Call) navigationElement;
keepProcessingNavigationElements = Modular.callDefinitionClauseCallWhile(modular, new Function<Call, Boolean>() {
@Override
public Boolean fun(Call callDefinitionClause) {
return executeOnCallDefinitionClause(callDefinitionClause, modularCanonicalNameState);
}
});
}
return keepProcessingNavigationElements;
}
});
}
return keepProcessing;
}
Aggregations