use of com.jetbrains.python.codeInsight.PyCustomMember in project intellij-community by JetBrains.
the class PyStdlibModuleMembersProvider method getMembersByQName.
@Override
protected Collection<PyCustomMember> getMembersByQName(PyFile module, String qName) {
if (qName.equals("os")) {
final List<PyCustomMember> results = new ArrayList<>();
PsiElement path = null;
if (module != null) {
final String pathModuleName = SystemInfo.isWindows ? "ntpath" : "posixpath";
path = ResolveImportUtil.resolveModuleInRoots(QualifiedName.fromDottedString(pathModuleName), module);
}
results.add(new PyCustomMember("path", path));
return results;
}
return Collections.emptyList();
}
use of com.jetbrains.python.codeInsight.PyCustomMember in project intellij-community by JetBrains.
the class NumpyClassMembersProvider method getMembers.
@NotNull
@Override
public Collection<PyCustomMember> getMembers(PyClassType clazz, PsiElement location, TypeEvalContext typeEvalContext) {
if (location != null && clazz.getPyClass().isSubclass(PyNames.TYPES_FUNCTION_TYPE, typeEvalContext)) {
final PsiElement element = location.getOriginalElement();
final PsiReference reference = element.getReference();
if (reference != null) {
final PsiElement resolved = reference.resolve();
if (resolved instanceof PyFunction) {
final List<PyCustomMember> result = new ArrayList<>();
if (NumpyUfuncs.isUFunc(((PyFunction) resolved).getName()) && NumpyDocStringTypeProvider.isInsideNumPy(resolved)) {
for (String method : NumpyUfuncs.UFUNC_METHODS) {
result.add(new PyCustomMember(method, resolved));
}
return result;
}
}
}
}
return Collections.emptyList();
}
use of com.jetbrains.python.codeInsight.PyCustomMember in project intellij-community by JetBrains.
the class NumpyModuleMembersProvider method getMembersByQName.
@Override
protected Collection<PyCustomMember> getMembersByQName(PyFile module, String qName) {
if ("numpy".equals(qName)) {
final List<PyCustomMember> members = new ArrayList<>();
for (String type : NUMERIC_TYPES) {
members.add(new PyCustomMember(type, DTYPE, false));
}
for (String type : PYTHON_TYPES) {
members.add(new PyCustomMember(type, DTYPE, false));
}
addTestingModule(module, members);
return members;
}
return Collections.emptyList();
}
use of com.jetbrains.python.codeInsight.PyCustomMember in project intellij-community by JetBrains.
the class PyClassTypeImpl method getMemberNames.
@NotNull
@Override
public Set<String> getMemberNames(boolean inherited, @NotNull TypeEvalContext context) {
final Set<String> result = new LinkedHashSet<>();
for (PyFunction function : myClass.getMethods()) {
result.add(function.getName());
}
for (PyTargetExpression expression : myClass.getClassAttributes()) {
result.add(expression.getName());
}
for (PyTargetExpression expression : myClass.getInstanceAttributes()) {
result.add(expression.getName());
}
result.addAll(ObjectUtils.notNull(myClass.getSlots(context), Collections.emptyList()));
for (PyClassMembersProvider provider : Extensions.getExtensions(PyClassMembersProvider.EP_NAME)) {
for (PyCustomMember member : provider.getMembers(this, null, context)) {
result.add(member.getName());
}
}
if (inherited) {
for (PyClassLikeType type : getAncestorTypes(context)) {
if (type != null) {
final PyClassLikeType ancestorType = isDefinition() ? type : type.toInstance();
result.addAll(ancestorType.getMemberNames(false, context));
}
}
}
return result;
}
use of com.jetbrains.python.codeInsight.PyCustomMember in project intellij-community by JetBrains.
the class PyStdlibClassMembersProvider method calcMockPatchMembers.
@NotNull
private static List<PyCustomMember> calcMockPatchMembers() {
final String[] members = new String[] { "object", "dict", "multiple", "stopall", "TEST_PREFIX" };
final String moduleQName = "unittest.mock";
return ContainerUtil.map(members, member -> new PyCustomMember(member).resolvesTo(moduleQName).toAssignment("patch." + member));
}
Aggregations