本文整理汇总了Java中com.siyeh.ipp.psiutils.ErrorUtil类的典型用法代码示例。如果您正苦于以下问题:Java ErrorUtil类的具体用法?Java ErrorUtil怎么用?Java ErrorUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorUtil类属于com.siyeh.ipp.psiutils包,在下文中一共展示了ErrorUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiVariable)) {
return false;
}
if (ErrorUtil.containsError(element)) {
return false;
}
final PsiVariable var = (PsiVariable)element;
final PsiTypeElement typeElement = var.getTypeElement();
if (typeElement == null) {
return false; // Could be true for enum constants.
}
final PsiType elementType = typeElement.getType();
final PsiType type = var.getType();
return elementType.getArrayDimensions() != type.getArrayDimensions();
}
示例2: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
@Override
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiBinaryExpression)) {
return false;
}
final PsiBinaryExpression expression = (PsiBinaryExpression)element;
final IElementType tokenType = expression.getOperationTokenType();
if (!tokenType.equals(JavaTokenType.EQEQ) &&
!tokenType.equals(JavaTokenType.NE)) {
return false;
}
final PsiExpression lhs = expression.getLOperand();
final PsiExpression rhs = expression.getROperand();
if (rhs == null) {
return false;
}
if (!BoolUtils.isBooleanLiteral(lhs) &&
!BoolUtils.isBooleanLiteral(rhs)) {
return false;
}
final PsiType type = expression.getType();
if (!PsiType.BOOLEAN.equals(type)) {
return false;
}
return !ErrorUtil.containsError(element);
}
示例3: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiMethodCallExpression)) {
return false;
}
final PsiMethodCallExpression expression =
(PsiMethodCallExpression)element;
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return false;
}
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final PsiExpression qualifier =
methodExpression.getQualifierExpression();
if (qualifier == null) {
return false;
}
@NonNls final String methodName = methodExpression.getReferenceName();
if (!"equals".equals(methodName)) {
return false;
}
return !ErrorUtil.containsError(element);
}
示例4: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(@NotNull PsiElement element) {
final PsiElement parent = element.getParent();
if (!(parent instanceof PsiField)) {
return false;
}
if (element instanceof PsiComment &&
element == parent.getFirstChild()) {
return false;
}
final PsiField field = (PsiField)parent;
final PsiExpression initializer = field.getInitializer();
if (initializer == null) {
return false;
}
final PsiClass containingClass = field.getContainingClass();
if (containingClass == null || containingClass.isInterface()) {
return false;
}
return !ErrorUtil.containsError(field);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:SplitDeclarationAndInitializationPredicate.java
示例5: checkSwitchStatement
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public static boolean checkSwitchStatement(@NotNull PsiSwitchStatement switchStatement) {
final PsiExpression expression = switchStatement.getExpression();
if (expression == null) {
return false;
}
final PsiCodeBlock body = switchStatement.getBody();
if (body == null) {
return false;
}
if (ErrorUtil.containsError(switchStatement)) {
return false;
}
boolean hasLabel = false;
final PsiStatement[] statements = body.getStatements();
for (PsiStatement statement : statements) {
if (statement instanceof PsiSwitchLabelStatement) {
hasLabel = true;
break;
}
}
return hasLabel;
}
示例6: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiJavaToken)) {
return false;
}
final PsiJavaToken token = (PsiJavaToken)element;
if (token.getTokenType() != JavaTokenType.IF_KEYWORD) {
return false;
}
final PsiElement parent = element.getParent();
if (!(parent instanceof PsiIfStatement)) {
return false;
}
final PsiIfStatement statement = (PsiIfStatement)parent;
if (ErrorUtil.containsError(statement)) {
return false;
}
return SwitchUtils.getSwitchExpression(statement, 0) != null;
}
示例7: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiConditionalExpression)) {
return false;
}
final PsiConditionalExpression condition =
(PsiConditionalExpression)element;
PsiExpression thenExpression = condition.getThenExpression();
PsiExpression elseExpression = condition.getElseExpression();
if (thenExpression == null || elseExpression == null) {
return false;
}
thenExpression = ParenthesesUtils.stripParentheses(thenExpression);
elseExpression = ParenthesesUtils.stripParentheses(elseExpression);
if (thenExpression == null || elseExpression == null) {
return false;
}
@NonNls final String thenText = thenExpression.getText();
@NonNls final String elseText = elseExpression.getText();
if ("true".equals(elseText) && "false".equals(thenText)) {
return !ErrorUtil.containsError(element);
}
else if ("true".equals(thenText) && "false".equals(elseText)) {
return !ErrorUtil.containsError(element);
}
return false;
}
示例8: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiJavaToken)) {
return false;
}
final PsiJavaToken token = (PsiJavaToken)element;
final IElementType tokenType = token.getTokenType();
if (!JavaTokenType.FOR_KEYWORD.equals(tokenType)) {
return false;
}
final PsiElement parent = element.getParent();
if (!(parent instanceof PsiForeachStatement)) {
return false;
}
final PsiForeachStatement foreachStatement = (PsiForeachStatement)parent;
final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
if (iteratedValue == null) {
return false;
}
final PsiType type = iteratedValue.getType();
if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE)) {
return false;
}
return !ErrorUtil.containsError(foreachStatement);
}
示例9: processIntention
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element) {
final PsiReturnStatement returnStatement = (PsiReturnStatement)element;
final PsiExpression returnValue = returnStatement.getReturnValue();
if (returnValue == null || ErrorUtil.containsDeepError(returnValue)) {
return;
}
final String newStatementText = buildIf(returnValue, true, new StringBuilder()).toString();
final Project project = returnStatement.getProject();
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
final PsiBlockStatement blockStatement = (PsiBlockStatement)elementFactory.createStatementFromText("{" + newStatementText + "}", returnStatement);
final PsiElement parent = returnStatement.getParent();
for (PsiStatement st : blockStatement.getCodeBlock().getStatements()) {
CodeStyleManager.getInstance(project).reformat(parent.addBefore(st, returnStatement));
}
PsiReplacementUtil.replaceStatement(returnStatement, "return false;");
}
示例10: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiBinaryExpression)) {
return false;
}
final PsiBinaryExpression expression = (PsiBinaryExpression)element;
final IElementType tokenType = expression.getOperationTokenType();
if (!tokenType.equals(JavaTokenType.EQEQ) &&
!tokenType.equals(JavaTokenType.NE)) {
return false;
}
final PsiExpression lhs = expression.getLOperand();
final PsiExpression rhs = expression.getROperand();
if (rhs == null) {
return false;
}
if (!BoolUtils.isBooleanLiteral(lhs) &&
!BoolUtils.isBooleanLiteral(rhs)) {
return false;
}
final PsiType type = expression.getType();
if (!PsiType.BOOLEAN.equals(type)) {
return false;
}
return !ErrorUtil.containsError(element);
}
示例11: processIntention
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element) {
final PsiReturnStatement returnStatement = (PsiReturnStatement)element;
final PsiExpression returnValue = returnStatement.getReturnValue();
if (returnValue == null || ErrorUtil.containsDeepError(returnValue)) {
return;
}
final String newStatementText = buildIf(returnValue, new StringBuilder()).toString();
final Project project = returnStatement.getProject();
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
final PsiBlockStatement blockStatement = (PsiBlockStatement)elementFactory.createStatementFromText("{" + newStatementText + "}", returnStatement);
final PsiElement parent = returnStatement.getParent();
for (PsiStatement st : blockStatement.getCodeBlock().getStatements()) {
CodeStyleManager.getInstance(project).reformat(parent.addBefore(st, returnStatement));
}
replaceStatement("return false;", returnStatement);
}
示例12: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiJavaToken)) {
return false;
}
final PsiJavaToken token = (PsiJavaToken)element;
if (token.getTokenType() != JavaTokenType.IF_KEYWORD) {
return false;
}
final PsiElement parent = element.getParent();
if (!(parent instanceof PsiIfStatement)) {
return false;
}
final PsiIfStatement statement = (PsiIfStatement)parent;
if (ErrorUtil.containsError(statement)) {
return false;
}
return SwitchUtils.getSwitchExpression(statement) != null;
}
示例13: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiBinaryExpression)) {
return false;
}
final PsiBinaryExpression expression = (PsiBinaryExpression)element;
final PsiExpression rhs = expression.getROperand();
if (rhs == null) {
return false;
}
if (!ComparisonUtils.isComparison((PsiExpression)element)) {
return false;
}
return !ErrorUtil.containsError(element);
}
示例14: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiPolyadicExpression)) {
return false;
}
final PsiPolyadicExpression expression = (PsiPolyadicExpression)element;
final IElementType tokenType = expression.getOperationTokenType();
if (!tokenType.equals(JavaTokenType.ANDAND) &&
!tokenType.equals(JavaTokenType.OROR)) {
return false;
}
return !ErrorUtil.containsError(element);
}
示例15: satisfiedBy
import com.siyeh.ipp.psiutils.ErrorUtil; //导入依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiMethodCallExpression)) {
return false;
}
final PsiMethodCallExpression expression =
(PsiMethodCallExpression)element;
final PsiExpressionList args = expression.getArgumentList();
final int numExpressions = args.getExpressions().length;
if (numExpressions < 1 || numExpressions > 2) {
return false;
}
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
@NonNls final String methodName = methodExpression.getReferenceName();
if (!("assertTrue".equals(methodName) ||
"assertFalse".equals(methodName) ||
"assertNull".equals(methodName))) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass targetClass = method.getContainingClass();
if (targetClass == null) {
return false;
}
final String qualifiedName = targetClass.getQualifiedName();
if (!"junit.framework.Assert".equals(qualifiedName) &&
!"org.junit.Assert".equals(qualifiedName)) {
return false;
}
return !ErrorUtil.containsError(element);
}