本文整理汇总了Java中com.jetbrains.python.psi.types.PyClassTypeImpl类的典型用法代码示例。如果您正苦于以下问题:Java PyClassTypeImpl类的具体用法?Java PyClassTypeImpl怎么用?Java PyClassTypeImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PyClassTypeImpl类属于com.jetbrains.python.psi.types包,在下文中一共展示了PyClassTypeImpl类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReturnType
import com.jetbrains.python.psi.types.PyClassTypeImpl; //导入依赖的package包/类
@Override
public Ref<PyType> getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) {
if (PyNames.INIT.equals(callable.getName()) && callable instanceof PyFunction) {
final PyFunction function = (PyFunction)callable;
final PyClass containingClass = function.getContainingClass();
if (containingClass != null && ourQt4Signal.equals(containingClass.getName())) {
final String classQName = containingClass.getQualifiedName();
if (classQName != null) {
final QualifiedName name = QualifiedName.fromDottedString(classQName);
final String qtVersion = name.getComponents().get(0);
final PyClass aClass = PyClassNameIndex.findClass(qtVersion + "." + ourQtBoundSignal, function.getProject());
if (aClass != null) {
final PyType type = new PyClassTypeImpl(aClass, false);
return Ref.create(type);
}
}
}
}
return null;
}
示例2: getCallableType
import com.jetbrains.python.psi.types.PyClassTypeImpl; //导入依赖的package包/类
@Nullable
@Override
public PyType getCallableType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) {
if (callable instanceof PyFunction) {
final String qualifiedName = callable.getQualifiedName();
if (qualifiedName != null && qualifiedName.startsWith("PyQt")){
final QualifiedName name = QualifiedName.fromDottedString(qualifiedName);
final String qtVersion = name.getComponents().get(0);
final String docstring = ((PyFunction)callable).getDocStringValue();
if (docstring != null && docstring.contains("[signal]")) {
final PyClass aClass = PyClassNameIndex.findClass(qtVersion + "." + ourQtBoundSignal, callable.getProject());
if (aClass != null)
return new PyClassTypeImpl(aClass, false);
}
}
}
return null;
}
示例3: analyzeContract
import com.jetbrains.python.psi.types.PyClassTypeImpl; //导入依赖的package包/类
@NotNull
private PyContractAnalysisResult analyzeContract(PyDecorator decorator) {
PyExpression contractExpression = decorator.getKeywordArgument("contract");
if (contractExpression instanceof PyReferenceExpression) {
PyReferenceExpression referenceExpression = (PyReferenceExpression)contractExpression;
PsiElement referencedElement = referenceExpression.getReference().resolve();
if (referencedElement instanceof PyClass) {
PyClass memberClass = (PyClass)referencedElement;
PyType pyType = new PyClassTypeImpl(memberClass, false);
return new PyContractAnalysisResult(pyType, false);
}
return noContractResult;
}
if (contractExpression instanceof StringLiteralExpression) {
String contract = ((StringLiteralExpression)contractExpression).getStringValue();
ContractNode parsedContract = PyContractsUtil.parse(contract);
if (parsedContract != null) {
PyType computedType = parsedContract.accept(new PyContractsTypeComputer(myPyClass));
boolean acceptNone = parsedContract.accept(new PyContractsNoneAnalyzer());
return new PyContractAnalysisResult(computedType, acceptNone);
}
}
return noContractResult;
}
示例4: isGettingCompletionVariants
import com.jetbrains.python.psi.types.PyClassTypeImpl; //导入依赖的package包/类
private static boolean isGettingCompletionVariants() {
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
for (int i = 2; i < stackTrace.length; i++) {
StackTraceElement current = stackTrace[i];
if (!PyClassTypeImpl.class.getName().equals(current.getClassName())) {
return false;
} else if ("getCompletionVariants".equals(current.getMethodName())) {
return true;
}
}
return false;
}
示例5: getClassType
import com.jetbrains.python.psi.types.PyClassTypeImpl; //导入依赖的package包/类
private static PyClassType getClassType(@NotNull final PsiElement element) {
if (element instanceof PyQualifiedExpression) {
final PyExpression qualifier = ((PyQualifiedExpression)element).getQualifier();
if (qualifier == null) return null;
final PyType type = TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).getType(qualifier);
return type instanceof PyClassType ? (PyClassType)type : null;
}
final PyClass aClass = PsiTreeUtil.getParentOfType(element, PyClass.class);
return aClass != null ? new PyClassTypeImpl(aClass, false) : null;
}
示例6: getClassType
import com.jetbrains.python.psi.types.PyClassTypeImpl; //导入依赖的package包/类
private static PyClassType getClassType(@NotNull final PsiElement problemElement) {
if ((problemElement instanceof PyQualifiedExpression)) {
final PyExpression qualifier = ((PyQualifiedExpression)problemElement).getQualifier();
if (qualifier == null) return null;
final PyType type = TypeEvalContext.userInitiated(problemElement.getProject(), problemElement.getContainingFile()).getType(qualifier);
return type instanceof PyClassType ? (PyClassType)type : null;
}
final PyClass pyClass = PsiTreeUtil.getParentOfType(problemElement, PyClass.class);
return pyClass != null ? new PyClassTypeImpl(pyClass, false) : null;
}