use of com.jetbrains.python.psi.resolve.CompletionVariantsProcessor in project intellij-community by JetBrains.
the class PyJavaClassType method getCompletionVariants.
public Object[] getCompletionVariants(String completionPrefix, PsiElement location, ProcessingContext context) {
final CompletionVariantsProcessor processor = new CompletionVariantsProcessor(location);
myClass.processDeclarations(processor, ResolveState.initial(), null, location);
return processor.getResult();
}
use of com.jetbrains.python.psi.resolve.CompletionVariantsProcessor in project intellij-community by JetBrains.
the class PyClassTypeImpl method addOwnClassMembers.
private void addOwnClassMembers(PsiElement expressionHook, Set<String> namesAlready, boolean suppressParentheses, List<Object> ret, @Nullable final String prefix) {
PyClass containingClass = PsiTreeUtil.getParentOfType(expressionHook, PyClass.class);
if (containingClass != null) {
containingClass = CompletionUtil.getOriginalElement(containingClass);
}
boolean withinOurClass = containingClass == getPyClass() || isInSuperCall(expressionHook);
final CompletionVariantsProcessor processor = new CompletionVariantsProcessor(expressionHook, new FilterNotInstance(myClass), null);
if (suppressParentheses) {
processor.suppressParentheses();
}
myClass.processClassLevelDeclarations(processor);
// We are here because of completion (see call stack), so we use code complete here
final TypeEvalContext context = (expressionHook != null ? TypeEvalContext.codeCompletion(myClass.getProject(), myClass.getContainingFile()) : null);
List<String> slots = myClass.isNewStyleClass(context) ? myClass.getSlots(context) : null;
if (slots != null) {
processor.setAllowedNames(slots);
}
myClass.processInstanceLevelDeclarations(processor, expressionHook);
for (LookupElement le : processor.getResultList()) {
String name = le.getLookupString();
if (namesAlready.contains(name))
continue;
if (!withinOurClass && isClassPrivate(name))
continue;
if (!withinOurClass && isClassProtected(name) && prefix == null)
continue;
namesAlready.add(name);
ret.add(le);
}
if (slots != null) {
for (String name : slots) {
if (!namesAlready.contains(name)) {
ret.add(LookupElementBuilder.create(name));
}
}
}
}
Aggregations