当前位置: 首页>>代码示例>>Java>>正文


Java PsiReferenceExpression.getReferenceName方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiReferenceExpression.getReferenceName方法的典型用法代码示例。如果您正苦于以下问题:Java PsiReferenceExpression.getReferenceName方法的具体用法?Java PsiReferenceExpression.getReferenceName怎么用?Java PsiReferenceExpression.getReferenceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiReferenceExpression的用法示例。


在下文中一共展示了PsiReferenceExpression.getReferenceName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isSetSecurityManager

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SystemSetSecurityManagerInspection.java

示例2: isDriverManagerGetConnection

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DriverManagerGetConnectionInspection.java

示例3: isResourceCreation

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:SocketResourceInspection.java

示例4: visitMethodCallExpression

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:RuntimeExecInspection.java

示例5: isThreadYield

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
private static boolean isThreadYield(
  PsiMethodCallExpression expression) {
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  @NonNls final String methodName =
    methodExpression.getReferenceName();
  if (!"yield".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.Thread".equals(className);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ThreadYieldInspection.java

示例6: isStopSuspendOrResume

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
private static boolean isStopSuspendOrResume(
  PsiMethodCallExpression expression) {
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  @NonNls final String methodName =
    methodExpression.getReferenceName();
  if (!("stop".equals(methodName) || "suspend".equals(methodName) ||
        "resume".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.Thread".equals(className);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ThreadStopSuspendResumeInspection.java

示例7: visitMethodCallExpression

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  if (!HardcodedMethodConstants.NOTIFY.equals(methodName) &&
      !HardcodedMethodConstants.NOTIFY_ALL.equals(methodName)) {
    return;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiParameterList parameterList = method.getParameterList();
  if (parameterList.getParametersCount() != 0) {
    return;
  }
  if (SynchronizationUtil.isInSynchronizedContext(expression)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:NotifyNotInSynchronizedContextInspection.java

示例8: isRunFinalizersOnExit

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
private static boolean isRunFinalizersOnExit(
  PsiMethodCallExpression expression) {
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  @NonNls final String runFinalizers = "runFinalizersOnExit";
  if (!runFinalizers.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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SystemRunFinalizersOnExitInspection.java

示例9: visitReferenceExpression

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
@Override
public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
  super.visitReferenceExpression(expression);
  final String name = expression.getReferenceName();
  if (!HardcodedMethodConstants.OUT.equals(name) &&
      !HardcodedMethodConstants.ERR.equals(name)) {
    return;
  }
  final PsiElement referent = expression.resolve();
  if (!(referent instanceof PsiField)) {
    return;
  }
  final PsiField field = (PsiField)referent;
  final PsiClass containingClass = field.getContainingClass();
  if (containingClass == null) {
    return;
  }
  final String className = containingClass.getQualifiedName();
  if (!"java.lang.System".equals(className)) {
    return;
  }
  registerError(expression, expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SystemOutErrInspectionBase.java

示例10: visitMethodCallExpression

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的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

示例11: visitReferenceExpression

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
@Override
public void visitReferenceExpression(
  @NotNull PsiReferenceExpression expression) {
  super.visitReferenceExpression(expression);
  final String name = expression.getReferenceName();
  if (!HardcodedMethodConstants.OUT.equals(name) &&
      !HardcodedMethodConstants.ERR.equals(name)) {
    return;
  }
  final PsiElement referent = expression.resolve();
  if (!(referent instanceof PsiField)) {
    return;
  }
  final PsiField field = (PsiField)referent;
  final PsiClass containingClass = field.getContainingClass();
  if (containingClass == null) {
    return;
  }
  final String className = containingClass.getQualifiedName();
  if (!"java.lang.System".equals(className)) {
    return;
  }
  registerError(expression);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:SystemOutErrInspection.java

示例12: getMembersToImport

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
@NotNull
@Override
protected List<PsiMethod> getMembersToImport(boolean applicableOnly)
{
	final Project project = myMethodCall.getProject();
	PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
	final PsiMethodCallExpression element = myMethodCall.getElement();
	PsiReferenceExpression reference = element == null ? null : element.getMethodExpression();
	String name = reference == null ? null : reference.getReferenceName();
	if(name == null)
	{
		return Collections.emptyList();
	}
	final StaticMembersProcessor<PsiMethod> processor = new MyStaticMethodProcessor(element);
	cache.processMethodsWithName(name, element.getResolveScope(), processor);
	return processor.getMembersToImport(applicableOnly);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:StaticImportMethodFix.java

示例13: isResourceCreation

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的package包/类
protected boolean isResourceCreation(PsiExpression expression) {
  if (!(expression instanceof PsiMethodCallExpression)) {
    return false;
  }
  final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
  final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  if (!HardcodedMethodConstants.OPEN_SESSION.equals(methodName)) {
    return false;
  }
  final PsiExpression qualifier = methodExpression.getQualifierExpression();
  return qualifier != null && TypeUtils.expressionHasTypeOrSubtype(qualifier, "org.hibernate.SessionFactory");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:HibernateResourceInspection.java

示例14: visitMethodCallExpression

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:ResultSetIndexZeroInspection.java

示例15: visitMethodCallExpression

import com.intellij.psi.PsiReferenceExpression; //导入方法依赖的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.valueOf(resultSet));
    }
  } else {
    if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.PreparedStatement")) {
      registerError(argument, Boolean.valueOf(resultSet));
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:ResultSetIndexZeroInspection.java


注:本文中的com.intellij.psi.PsiReferenceExpression.getReferenceName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。