本文整理汇总了Java中com.intellij.psi.PsiMethodCallExpression类的典型用法代码示例。如果您正苦于以下问题:Java PsiMethodCallExpression类的具体用法?Java PsiMethodCallExpression怎么用?Java PsiMethodCallExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiMethodCallExpression类属于com.intellij.psi包,在下文中一共展示了PsiMethodCallExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitMethod
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethod(@NonNull JavaContext context, @Nullable JavaElementVisitor visitor,
@NonNull PsiMethodCallExpression node, @NonNull PsiMethod method) {
boolean isLayoutInflaterCall = isLayoutInflaterCall(context, node, method);
boolean isViewInflateCall = isInViewCall(context, node, method);
String name = method.getName();
boolean fromMethod = LAYOUTINFLATER_FROM.equals(name);
boolean viewInflateMethod = VIEW_INFLATE.equals(name);
if (isLayoutInflaterCall && fromMethod) {
context.report(ISSUE_LAYOUTINFLATER, node, context.getLocation(node),
"error use system LayoutInflater,should use LayoutInflaterWrapper.");
return;
}
if (viewInflateMethod && isViewInflateCall) {
context.report(ISSUE_VIEW_INFLATE, node, context.getLocation(node),
"error use View.inflate(),should use LayoutInflaterWrapper.inflate.");
return;
}
}
示例2: visitMethod
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor,
PsiMethodCallExpression call, PsiMethod method) {
JavaEvaluator evaluator = context.getEvaluator();
if (evaluator.getParameterCount(method) == 0) {
PsiMethod parent = PsiTreeUtil.getParentOfType(call, PsiMethod.class);
if (parent != null) {
if (evaluator.isMemberInClass(method, CLASS_DIRECTOR) &&
evaluator.isMemberInSubClassOf(parent, CLASS_DIRECTOR_BACK_HANDLER, false)) {
context.report(ISSUE, call, context.getLocation(call),
"Can't call Stage.handleBack() in Stage.BackHandler.handleBack()");
} else if (evaluator.isMemberInClass(method, CLASS_STAGE) &&
evaluator.isMemberInSubClassOf(parent, CLASS_STAGE_BACK_HANDLER, false)) {
context.report(ISSUE, call, context.getLocation(call),
"Can't call Director.handleBack() in Director.BackHandler.handleBack()");
}
}
}
}
示例3: visitMethod
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor, PsiMethodCallExpression call, PsiMethod method) {
super.visitMethod(context, visitor, call, method);
if (isRxSubscribeableClass(method.getContainingClass()) && !PsiType.VOID.equals(method.getReturnType())) {
PsiElement element = LintUtils.skipParentheses(call.getParent());
if (element instanceof PsiExpressionStatement) {
String message;
if (isRx2(method.getContainingClass())) {
message = "No reference to the disposable is kept";
} else {
message = "No reference to the subscription is kept";
}
context.report(ISSUE, call, context.getLocation(call), message);
}
}
}
示例4: findArgPos
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private int findArgPos( PsiMethodCallExpression methodCall, PsiElement firstElem )
{
PsiExpression[] args = methodCall.getArgumentList().getExpressions();
for( int i = 0; i < args.length; i++ )
{
PsiExpression arg = args[i];
PsiElement csr = firstElem;
while( csr != null && csr != firstElem )
{
csr = csr.getParent();
}
if( csr == firstElem )
{
return i;
}
}
throw new IllegalStateException();
}
示例5: isBuildingChildScope
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private PsiElement isBuildingChildScope(PsiMethodCallExpression call) {
try {
// Dot
PsiElement nextSibling = call.getNextSibling();
// Parenthesis
nextSibling = nextSibling.getNextSibling();
// Chained method name
nextSibling = nextSibling.getParent();
// Chained method
PsiElement chainedMethod = nextSibling.getParent();
if (chainedMethod instanceof PsiMethodCallExpression) {
PsiExpressionList list = ((PsiMethodCallExpression) chainedMethod).getArgumentList();
// If chained method is taking an argument that returns an instance of something
// (such as a new Module), it is probably safe to assume that the user is building a
// child scope
if (list.getFirstChild() != null
&& list.getFirstChild().getNextSibling() instanceof PsiNewExpression) {
return chainedMethod;
}
}
} catch (Exception e) {
// A for effort
}
return null;
}
示例6: checkNestedStringFormat
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
/**
* Reports issue if this call is inside PLog.x().
* Calling this method assumes actual calling method is 'String#format'.
*
* @see #ISSUE_NESTED_FORMAT
*/
private static void checkNestedStringFormat(JavaContext context, PsiMethodCallExpression call) {
PsiElement current = call;
while (true) {
current = LintUtils.skipParentheses(current.getParent());
if (current == null || current instanceof PsiCodeBlock) {
// Reached AST root or code block node; String.format not inside PLog.X(..).
return;
}
if (current instanceof PsiMethodCallExpression) {
PsiMethodCallExpression expression = (PsiMethodCallExpression) current;
if (Pattern.matches("org\\.mym\\.plog\\.PLog\\.(v|d|i|w|e)",
expression.getMethodExpression().getQualifiedName())) {
sHelper.reportIssue(context, ISSUE_NESTED_FORMAT, call);
return;
}
}
}
}
示例7: visitMethod
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor,
PsiMethodCallExpression call, PsiMethod method) {
PsiReferenceExpression methodExpression = call.getMethodExpression();
String fullyQualifiedMethodName = methodExpression.getQualifiedName();
if (fullyQualifiedMethodName.startsWith("android.util.Log")
//Handle multiple overloaded out.print(and println, etc) methods.
|| fullyQualifiedMethodName.startsWith("java.lang.System.out.print")) {
sHelper.reportIssue(context, ISSUE_LOG_CLASS, methodExpression);
return;
}
if (fullyQualifiedMethodName.equals("java.lang.String.format")) {
checkNestedStringFormat(context, call);
return;
}
}
示例8: findJavaElement
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
/**
* Further refine search in order to match the exact Java Camel route.
* Checks if the given {@link PsiElement} contains a 'to' method that points to the give route.
*
* @param route the complete Camel route to search for
* @param psiElement the {@link PsiElement} that might contain the complete route definition
* @return the {@link PsiElement} that contains the exact match of the Camel route, null if there is no exact match
*/
private PsiElement findJavaElement(String route, PsiElement psiElement) {
Object value;
if (psiElement instanceof PsiLiteralValue) {
value = ((PsiLiteralValue) psiElement).getValue();
} else {
value = psiElement.getText();
}
if (route.equals(value)) {
//the method 'to' is a PsiIdentifier not a PsiMethodCallExpression because it's part of method invocation chain
PsiMethodCallExpression methodCall = PsiTreeUtil.getParentOfType(psiElement, PsiMethodCallExpression.class);
if (methodCall != null) {
if (Arrays.stream(JAVA_ROUTE_CALL).anyMatch(s -> s.equals(methodCall.getMethodExpression().getReferenceName()))) {
return psiElement;
}
}
}
return null;
}
示例9: withArguments
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
public PsiMethodCallPattern withArguments(final ElementPattern<? extends PsiExpression>... arguments) {
return with(new PatternCondition<PsiMethodCallExpression>("withArguments") {
@Override
public boolean accepts(@NotNull PsiMethodCallExpression callExpression, ProcessingContext context) {
final PsiExpression[] actualArguments = callExpression.getArgumentList().getExpressions();
if (arguments.length != actualArguments.length) {
return false;
}
for (int i = 0; i < actualArguments.length; i++) {
if (!arguments[i].accepts(actualArguments[i], context)) {
return false;
}
}
return true;
}
});
}
示例10: getElement
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
protected PsiElement getElement() {
if (!myReferenceExpression.isValid() || !myReferenceExpression.getManager().isInProject(myReferenceExpression)) return null;
PsiElement parent = myReferenceExpression.getParent();
if (parent instanceof PsiMethodCallExpression) return null;
if (myReferenceExpression.getReferenceNameElement() != null) {
if (!CreateFromUsageUtils.isValidReference(myReferenceExpression, false)) {
return myReferenceExpression;
}
}
return null;
}
示例11: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
if (!MethodCallUtils.isCallToMethod(expression, null, PsiType.VOID,
HardcodedMethodConstants.FINALIZE)) {
return;
}
final PsiMethod containingMethod =
PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
if (containingMethod == null) {
return;
}
if (MethodUtils.methodMatches(containingMethod, null, PsiType.VOID,
HardcodedMethodConstants.FINALIZE)) {
return;
}
registerMethodCallError(expression);
}
示例12: isSetSecurityManager
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private static boolean isSetSecurityManager(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
@NonNls final String methodName =
methodExpression.getReferenceName();
if (!"setSecurityManager".equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.lang.System".equals(className);
}
示例13: isDriverManagerGetConnection
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private static boolean isDriverManagerGetConnection(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (!HardcodedMethodConstants.GET_CONNECTION.equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.sql.DriverManager".equals(className);
}
示例14: isResourceCreation
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
protected boolean isResourceCreation(PsiExpression expression) {
if (expression instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
@NonNls final String methodName = methodExpression.getReferenceName();
if (!"accept".equals(methodName)) {
return false;
}
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier == null || !TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.net.ServerSocket")) {
return false;
}
return TypeUtils.expressionHasTypeOrSubtype(methodCallExpression, "java.net.Socket");
}
else if (expression instanceof PsiNewExpression) {
return TypeUtils.expressionHasTypeOrSubtype(expression, "java.net.Socket", "java.net.DatagramSocket", "java.net.ServerSocket") != null;
}
return false;
}
示例15: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
@NonNls final String exec = "exec";
if (!exec.equals(methodName)) {
return;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return;
}
final String className = aClass.getQualifiedName();
if (!"java.lang.Runtime".equals(className)) {
return;
}
registerMethodCallError(expression);
}