本文整理汇总了Java中com.intellij.psi.PsiExpressionList.getExpressions方法的典型用法代码示例。如果您正苦于以下问题:Java PsiExpressionList.getExpressions方法的具体用法?Java PsiExpressionList.getExpressions怎么用?Java PsiExpressionList.getExpressions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiExpressionList
的用法示例。
在下文中一共展示了PsiExpressionList.getExpressions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitMethodCallExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
if (!MethodCallUtils.isEqualsCall(expression)) {
return;
}
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier == null) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return;
}
final PsiExpression argument = arguments[0];
if (!EquivalenceChecker.expressionsAreEquivalent(qualifier, argument) ||
SideEffectChecker.mayHaveSideEffects(qualifier)) {
return;
}
registerMethodCallError(expression);
}
示例2: visitMethodCallExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final String methodName = MethodCallUtils.getMethodName(expression);
if (!HardcodedMethodConstants.TO_STRING.equals(methodName)) {
return;
}
final PsiType targetType = MethodCallUtils.getTargetType(expression);
if (!TypeUtils.typeEquals(CommonClassNames.JAVA_UTIL_DATE,
targetType)) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (argumentList.getExpressions().length != 0) {
return;
}
if (NonNlsUtils.isNonNlsAnnotatedUse(expression)) {
return;
}
registerMethodCallError(expression);
}
示例3: visitNewExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression) {
super.visitNewExpression(expression);
if (!ExpressionUtils.hasType(expression, "java.text.SimpleDateFormat")) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (argumentList == null) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (ExpressionUtils.hasType(argument, "java.util.Locale")) {
return;
}
}
registerNewExpressionError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SimpleDateFormatWithoutLocaleInspection.java
示例4: visitMethodCallExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final String name = methodExpression.getReferenceName();
if (!"setScale".equals(name) && !"divide".equals(name)) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (PsiUtilCore.hasErrorElementChild(argumentList)) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return;
}
if (!TypeUtils.expressionHasTypeOrSubtype(expression, "java.math.BigDecimal")) {
return;
}
registerMethodCallError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:BigDecimalMethodWithoutRoundingCalledInspection.java
示例5: visitNewExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression) {
super.visitNewExpression(expression);
final PsiType type = expression.getType();
if (type == null) {
return;
}
if (!CollectionUtils.isCollectionWithInitialCapacity(type)) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (argumentList == null) {
return;
}
final PsiExpression[] parameters = argumentList.getExpressions();
if (parameters.length != 0) {
return;
}
registerError(expression);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:CollectionsMustHaveInitialCapacityInspection.java
示例6: visitNewExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression) {
super.visitNewExpression(expression);
if (!ExpressionUtils.hasType(expression, "java.text.SimpleDateFormat")) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (argumentList == null) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (ExpressionUtils.hasType(argument, "java.util.Locale")) {
return;
}
}
registerError(expression);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:SimpleDateFormatWithoutLocaleInspection.java
示例7: visitMethodCallExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
/**
* Check MethodCallExpressions for calls for default (argument less) constructor
* Produce an error if resolved constructor method is build by lombok and contains some arguments
*/
@Override
public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
super.visitMethodCallExpression(methodCall);
PsiExpressionList list = methodCall.getArgumentList();
PsiReferenceExpression referenceToMethod = methodCall.getMethodExpression();
boolean isThisOrSuper = referenceToMethod.getReferenceNameElement() instanceof PsiKeyword;
final int parameterCount = list.getExpressions().length;
if (isThisOrSuper && parameterCount == 0) {
JavaResolveResult[] results = referenceToMethod.multiResolve(true);
JavaResolveResult resolveResult = results.length == 1 ? results[0] : JavaResolveResult.EMPTY;
PsiElement resolved = resolveResult.getElement();
if (resolved instanceof LombokLightMethodBuilder && ((LombokLightMethodBuilder) resolved).getParameterList().getParameters().length != 0) {
holder.registerProblem(methodCall, "Default constructor doesn't exist", ProblemHighlightType.ERROR);
}
}
}
示例8: applyFix
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor)
{
final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethodCallExpression.class);
if(methodCallExpression != null)
{
ExpressionUtils.bindCallTo(methodCallExpression, myTargetMethodName);
if(myClearArguments)
{
PsiExpressionList argList = methodCallExpression.getArgumentList();
PsiExpression[] args = argList.getExpressions();
if(args.length > 0)
{
argList.deleteChildRange(args[0], args[args.length - 1]);
}
}
}
}
示例9: visitNewExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression newExpression) {
if (passed) {
return;
}
super.visitNewExpression(newExpression);
final PsiExpressionList argumentList = newExpression.getArgumentList();
if (argumentList == null) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (VariableAccessUtils.mayEvaluateToVariable(argument, variable)) {
passed = true;
break;
}
}
}
示例10: visitMethodCallExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
if (passed) {
return;
}
super.visitMethodCallExpression(call);
final PsiExpressionList argumentList = call.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (!VariableAccessUtils.mayEvaluateToVariable(argument, variable, myBuilderPattern)) {
continue;
}
final PsiMethod method = call.resolveMethod();
if (method != null) {
final PsiClass aClass = method.getContainingClass();
if (aClass != null) {
final String name = aClass.getQualifiedName();
if (excludes.contains(name)) {
continue;
}
}
}
passed = true;
}
}
示例11: visitNewExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression)
{
super.visitNewExpression(expression);
if(myIgnoreFields && expression.getParent() instanceof PsiField)
{
return;
}
final PsiType type = expression.getType();
if(!isCollectionWithInitialCapacity(type))
{
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if(argumentList == null || argumentList.getExpressions().length != 0)
{
return;
}
registerNewExpressionError(expression);
}
示例12: getQuickNavigateInfo
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Nullable
@Override
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
if (ServiceManager.getService(element.getProject(), CamelService.class).isCamelPresent()) {
PsiExpressionList exps = PsiTreeUtil.getNextSiblingOfType(originalElement, PsiExpressionList.class);
if (exps != null) {
if (exps.getExpressions().length >= 1) {
// grab first string parameter (as the string would contain the camel endpoint uri
final PsiClassType stringType = PsiType.getJavaLangString(element.getManager(), element.getResolveScope());
PsiExpression exp = Arrays.stream(exps.getExpressions()).filter(
e -> e.getType() != null && stringType.isAssignableFrom(e.getType()))
.findFirst().orElse(null);
if (exp instanceof PsiLiteralExpression) {
Object o = ((PsiLiteralExpression) exp).getValue();
String val = o != null ? o.toString() : null;
// okay only allow this popup to work when its from a RouteBuilder class
PsiClass clazz = PsiTreeUtil.getParentOfType(originalElement, PsiClass.class);
if (clazz != null) {
PsiClassType[] types = clazz.getExtendsListTypes();
boolean found = Arrays.stream(types).anyMatch(p -> p.getClassName().equals("RouteBuilder"));
if (found) {
String componentName = StringUtils.asComponentName(val);
if (componentName != null) {
// the quick info cannot be so wide so wrap at 120 chars
return generateCamelComponentDocumentation(componentName, val, 120, element.getProject());
}
}
}
}
}
}
}
return null;
}
示例13: getFlags
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public int getFlags(PsiElement elementInHost, PsiFile regexp) {
final PsiExpressionList list = PsiTreeUtil.getParentOfType(elementInHost, PsiExpressionList.class);
if (list != null && list.getExpressions().length == 2 && list.getExpressionTypes()[1] == PsiType.INT) {
final Object result = JavaConstantExpressionEvaluator.computeConstantExpression(list.getExpressions()[1], false);
if (result instanceof Integer) {
//noinspection MagicConstant
return ((Integer)result).intValue();
}
}
return 0;
}
示例14: visitMethodCallExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
@NonNls final String methodName = methodExpression.getReferenceName();
if (methodName == null) {
return;
}
final boolean resultSet;
if (methodName.startsWith("get") || methodName.startsWith("update")) {
resultSet = true;
} else if (methodName.startsWith("set")) {
resultSet = false;
} else {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length == 0) {
return;
}
final PsiExpression argument = arguments[0];
final Object val = ExpressionUtils.computeConstantExpression(argument);
if (!(val instanceof Integer) || ((Integer)val).intValue() != 0) {
return;
}
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (resultSet) {
if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.ResultSet")) {
registerError(argument, Boolean.TRUE);
}
} else if (arguments.length > 1) {
if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.PreparedStatement")) {
registerError(argument, Boolean.FALSE);
}
}
}
示例15: visitMethodCallExpression
import com.intellij.psi.PsiExpressionList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression call) {
super.visitMethodCallExpression(call);
if (!MethodCallUtils.isEqualsCall(call)) {
return;
}
final PsiExpressionList argumentList = call.getArgumentList();
final PsiExpression[] args = argumentList.getExpressions();
if (args.length == 0 || !ExpressionUtils.isNullLiteral(args[0])) {
return;
}
registerError(args[0]);
}