本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
}
}
示例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));
}
}
}