本文整理汇总了Java中com.intellij.psi.util.PsiUtil.findReturnStatements方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtil.findReturnStatements方法的具体用法?Java PsiUtil.findReturnStatements怎么用?Java PsiUtil.findReturnStatements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtil
的用法示例。
在下文中一共展示了PsiUtil.findReturnStatements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValueCompatible
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isValueCompatible() {
final PsiElement body = getBody();
if (body instanceof PsiCodeBlock) {
try {
ControlFlow controlFlow = ControlFlowFactory.getInstance(getProject()).getControlFlow(body, ourPolicy, false, false);
int startOffset = controlFlow.getStartOffset(body);
int endOffset = controlFlow.getEndOffset(body);
if (startOffset != -1 && endOffset != -1 && ControlFlowUtil.canCompleteNormally(controlFlow, startOffset, endOffset)) {
return false;
}
}
//error would be shown inside body
catch (AnalysisCanceledException ignore) {}
for (PsiReturnStatement statement : PsiUtil.findReturnStatements((PsiCodeBlock)body)) {
if (statement.getReturnValue() == null) {
return false;
}
}
}
return true;
}
示例2: getReturnTypeCandidates
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static PsiType[] getReturnTypeCandidates(@NotNull PsiMethod method) {
PsiType lub = null;
boolean hasVoid = false;
for (PsiReturnStatement statement : PsiUtil.findReturnStatements(method)) {
PsiExpression value = statement.getReturnValue();
if (value == null) {
hasVoid = true;
}
else {
PsiType type = value.getType();
if (lub == null) {
lub = type;
}
else if (type != null) {
lub = GenericsUtil.getLeastUpperBound(lub, type, method.getManager());
}
}
}
if (hasVoid && lub == null) {
lub = PsiType.VOID;
}
if (lub instanceof PsiIntersectionType) {
return ((PsiIntersectionType)lub).getConjuncts();
}
return lub == null ? PsiType.EMPTY_ARRAY : new PsiType[]{lub};
}
示例3: isVoidCompatible
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isVoidCompatible() {
final PsiElement body = getBody();
if (body instanceof PsiCodeBlock) {
for (PsiReturnStatement statement : PsiUtil.findReturnStatements((PsiCodeBlock)body)) {
if (statement.getReturnValue() != null) {
return false;
}
}
}
return true;
}