本文整理汇总了Java中com.intellij.psi.util.MethodSignatureBackedByPsiMethod.getMethod方法的典型用法代码示例。如果您正苦于以下问题:Java MethodSignatureBackedByPsiMethod.getMethod方法的具体用法?Java MethodSignatureBackedByPsiMethod.getMethod怎么用?Java MethodSignatureBackedByPsiMethod.getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.MethodSignatureBackedByPsiMethod
的用法示例。
在下文中一共展示了MethodSignatureBackedByPsiMethod.getMethod方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMethodOverridesDeprecated
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
static void checkMethodOverridesDeprecated(MethodSignatureBackedByPsiMethod methodSignature,
List<MethodSignatureBackedByPsiMethod> superMethodSignatures,
boolean ignoreAbstractDeprecatedOverrides, ProblemsHolder holder) {
PsiMethod method = methodSignature.getMethod();
PsiElement methodName = method.getNameIdentifier();
for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) {
PsiMethod superMethod = superMethodSignature.getMethod();
PsiClass aClass = superMethod.getContainingClass();
if (aClass == null) continue;
// do not show deprecated warning for class implementing deprecated methods
if (ignoreAbstractDeprecatedOverrides && !aClass.isDeprecated() && superMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue;
if (superMethod.isDeprecated()) {
String description = JavaErrorMessages.message("overrides.deprecated.method",
HighlightMessageUtil.getSymbolName(aClass, PsiSubstitutor.EMPTY));
holder.registerProblem(methodName, description, ProblemHighlightType.LIKE_DEPRECATED);
}
}
}
示例2: visitMethod
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() == 0) {
return;
}
final Query<MethodSignatureBackedByPsiMethod> query =
SuperMethodsSearch.search(
method, method.getContainingClass(), true, false);
final MethodSignatureBackedByPsiMethod methodSignature =
query.findFirst();
if (methodSignature == null) {
return;
}
final PsiMethod superMethod = methodSignature.getMethod();
final PsiParameter[] parameters = parameterList.getParameters();
checkParameters(superMethod, parameters);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ParameterNameDiffersFromOverriddenParameterInspectionBase.java
示例3: hasAnnotationInHierarchy
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
private boolean hasAnnotationInHierarchy(int parameter,
List<MethodSignatureBackedByPsiMethod> superMethodSignatures) {
for (MethodSignatureBackedByPsiMethod methodSignature : superMethodSignatures) {
PsiMethod superMethod = methodSignature.getMethod();
PsiParameter[] superParameters = superMethod.getParameterList().getParameters();
PsiParameter superParameter = superParameters[parameter];
if (hasAnnotation(superParameter)) {
return true;
}
}
return false;
}
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:13,代码来源:NullabilityAnnotationsInspection.java
示例4: getLocationString
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public String getLocationString() {
if (!Registry.is("show.method.base.class.in.java.file.structure")) return null;
final PsiMethod method = getElement();
if (myLocation == null && method != null && !DumbService.isDumb(method.getProject())) {
if (isInherited()) {
return super.getLocationString();
} else {
try {
final MethodSignatureBackedByPsiMethod baseMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (baseMethod != null && !method.isEquivalentTo(baseMethod.getMethod())) {
PsiMethod base = baseMethod.getMethod();
PsiClass baseClass = base.getContainingClass();
if (baseClass != null /*&& !CommonClassNames.JAVA_LANG_OBJECT.equals(baseClass.getQualifiedName())*/) {
if (baseClass.getMethods().length > 1) {
myLocation = baseClass.getName();
}
}
}
}
catch (IndexNotReadyException e) {
//some searchers (EJB) require indices. What shall we do?
}
if (StringUtil.isEmpty(myLocation)) {
myLocation = "";
} else {
char upArrow = '\u2191';
myLocation = UIUtil.getLabelFont().canDisplay(upArrow) ? upArrow + myLocation : myLocation;
}
}
}
return StringUtil.isEmpty(myLocation) ? null : myLocation;
}
示例5: visitMethod
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
super.visitMethod(method);
final PsiCodeBlock body = method.getBody();
if (body == null) {
return;
}
if (method.getNameIdentifier() == null) {
return;
}
final Query<MethodSignatureBackedByPsiMethod> superMethodQuery =
SuperMethodsSearch.search(method, null, true, false);
final MethodSignatureBackedByPsiMethod signature =
superMethodQuery.findFirst();
if (signature == null) {
return;
}
final PsiMethod superMethod = signature.getMethod();
final PsiCodeBlock superBody = superMethod.getBody();
if (superBody == null) {
return;
}
if (!modifierListsAreEquivalent(method.getModifierList(), superMethod.getModifierList())) {
return;
}
final PsiType superReturnType = superMethod.getReturnType();
if (superReturnType == null || !superReturnType.equals(method.getReturnType())) {
return;
}
if (!EquivalenceChecker.codeBlocksAreEquivalent(body, superBody)) {
return;
}
registerMethodError(method);
}
示例6: visitMethod
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
if (!CloneUtils.isClone(method)) {
return;
}
if (method.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
if (onlyWarnOnProtectedClone && method.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) {
return;
}
if (containingClass.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
if (MethodUtils.hasInThrows(method, "java.lang.CloneNotSupportedException")) {
return;
}
final MethodSignatureBackedByPsiMethod signature = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (signature == null) {
return;
}
final PsiMethod superMethod = signature.getMethod();
if (!MethodUtils.hasInThrows(superMethod, "java.lang.CloneNotSupportedException")) {
return;
}
registerMethodError(method);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:CloneDeclaresCloneNotSupportedInspection.java
示例7: getLocationString
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public String getLocationString() {
if (!Registry.is("show.method.base.class.in.java.file.structure")) return null;
final PsiMethod method = getElement();
if (myLocation == null) {
if (isInherited()) {
return super.getLocationString();
} else {
try {
final MethodSignatureBackedByPsiMethod baseMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (baseMethod != null && !method.isEquivalentTo(baseMethod.getMethod())) {
PsiMethod base = baseMethod.getMethod();
PsiClass baseClass = base.getContainingClass();
if (baseClass != null /*&& !CommonClassNames.JAVA_LANG_OBJECT.equals(baseClass.getQualifiedName())*/) {
if (baseClass.getMethods().length > 1) {
myLocation = baseClass.getName();
}
}
}
}
catch (IndexNotReadyException e) {
//some searchers (EJB) require indices. What shall we do?
}
if (StringUtil.isEmpty(myLocation)) {
myLocation = "";
} else {
char upArrow = '\u2191';
myLocation = UIUtil.getLabelFont().canDisplay(upArrow) ? upArrow + myLocation : myLocation;
}
}
}
return StringUtil.isEmpty(myLocation) ? null : myLocation;
}
示例8: visitMethod
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
if (!CloneUtils.isClone(method)) {
return;
}
if (method.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) {
return;
}
if (containingClass.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
if (MethodUtils.hasInThrows(method, "java.lang.CloneNotSupportedException")) {
return;
}
final MethodSignatureBackedByPsiMethod signature = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (signature == null) {
return;
}
final PsiMethod superMethod = signature.getMethod();
if (!MethodUtils.hasInThrows(superMethod, "java.lang.CloneNotSupportedException")) {
return;
}
registerMethodError(method);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:CloneDeclaresCloneNotSupportedInspection.java
示例9: checkMethodOverridesDeprecated
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
static void checkMethodOverridesDeprecated(MethodSignatureBackedByPsiMethod methodSignature,
List<MethodSignatureBackedByPsiMethod> superMethodSignatures,
boolean ignoreAbstractDeprecatedOverrides,
ProblemsHolder holder)
{
PsiMethod method = methodSignature.getMethod();
PsiElement methodName = method.getNameIdentifier();
for(MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures)
{
PsiMethod superMethod = superMethodSignature.getMethod();
PsiClass aClass = superMethod.getContainingClass();
if(aClass == null)
{
continue;
}
// do not show deprecated warning for class implementing deprecated methods
if(ignoreAbstractDeprecatedOverrides && !aClass.isDeprecated() && superMethod.hasModifierProperty(PsiModifier.ABSTRACT))
{
continue;
}
if(superMethod.isDeprecated())
{
String description = JavaErrorMessages.message("overrides.deprecated.method", HighlightMessageUtil.getSymbolName(aClass,
PsiSubstitutor.EMPTY));
holder.registerProblem(methodName, description, ProblemHighlightType.LIKE_DEPRECATED);
}
}
}
示例10: getSuper
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Nullable
public static PsiMethod getSuper(@NotNull PsiMethod method)
{
final MethodSignatureBackedByPsiMethod signature = getSuperMethodSignature(method);
if(signature == null)
{
return null;
}
return signature.getMethod();
}
示例11: getLocationString
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public String getLocationString() {
final PsiMethod method = getElement();
if (myLocation == null) {
if (isInherited()) {
return super.getLocationString();
} else {
try {
final MethodSignatureBackedByPsiMethod baseMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (baseMethod != null && !method.isEquivalentTo(baseMethod.getMethod())) {
PsiMethod base = baseMethod.getMethod();
PsiClass baseClass = base.getContainingClass();
if (baseClass != null /*&& !CommonClassNames.JAVA_LANG_OBJECT.equals(baseClass.getQualifiedName())*/) {
if (baseClass.getMethods().length > 1) {
myLocation = baseClass.getName();
}
}
}
}
catch (IndexNotReadyException e) {
//some searchers (EJB) require indices. What shall we do?
}
if (StringUtil.isEmpty(myLocation)) {
myLocation = "";
} else {
char upArrow = '\u2191';
myLocation = UIUtil.getLabelFont().canDisplay(upArrow) ? upArrow + myLocation : myLocation;
}
}
}
return StringUtil.isEmpty(myLocation) ? null : myLocation;
}
示例12: HierarchicalMethodSignature
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
public HierarchicalMethodSignature(@NotNull MethodSignatureBackedByPsiMethod signature) {
super(signature.getMethod(), signature.getSubstitutor(), signature.isRaw(),
getParameterTypes(signature.getMethod()), signature.getTypeParameters());
}
示例13: visitMethod
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
super.visitMethod(method);
final PsiCodeBlock body = method.getBody();
if (body == null) {
return;
}
if (method.getNameIdentifier() == null) {
return;
}
final Query<MethodSignatureBackedByPsiMethod> superMethodQuery =
SuperMethodsSearch.search(method, null, true, false);
final MethodSignatureBackedByPsiMethod signature =
superMethodQuery.findFirst();
if (signature == null) {
return;
}
final PsiMethod superMethod = signature.getMethod();
final PsiCodeBlock superBody = superMethod.getBody();
if (superBody == null) {
return;
}
final PsiModifierList superModifierList =
superMethod.getModifierList();
final PsiModifierList modifierList = method.getModifierList();
if (!EquivalenceChecker.modifierListsAreEquivalent(
modifierList, superModifierList)) {
return;
}
final PsiType superReturnType = superMethod.getReturnType();
if (superReturnType == null) {
return;
}
final PsiType returnType = method.getReturnType();
if (!superReturnType.equals(returnType)) {
return;
}
if (!EquivalenceChecker.codeBlocksAreEquivalent(body, superBody)) {
return;
}
registerMethodError(method);
}
示例14: visitMethod
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method)
{
super.visitMethod(method);
if(IGNORE_UNCHECKED_OVERRIDING)
{
return;
}
if(!method.isConstructor())
{
List<HierarchicalMethodSignature> superMethodSignatures = method.getHierarchicalMethodSignature().getSuperSignatures();
if(!superMethodSignatures.isEmpty() && !method.hasModifierProperty(PsiModifier.STATIC))
{
final MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
for(MethodSignatureBackedByPsiMethod superSignature : superMethodSignatures)
{
PsiMethod baseMethod = superSignature.getMethod();
PsiSubstitutor substitutor = MethodSignatureUtil.getSuperMethodSignatureSubstitutor(signature, superSignature);
if(substitutor == null)
{
substitutor = superSignature.getSubstitutor();
}
if(PsiUtil.isRawSubstitutor(baseMethod, superSignature.getSubstitutor()))
{
continue;
}
final PsiType baseReturnType = substitutor.substitute(baseMethod.getReturnType());
final PsiType overriderReturnType = method.getReturnType();
if(baseReturnType == null || overriderReturnType == null)
{
return;
}
if(JavaGenericsUtil.isRawToGeneric(baseReturnType, overriderReturnType))
{
final String message = JavaErrorMessages.message("unchecked.overriding.incompatible.return.type", JavaHighlightUtil.formatType(overriderReturnType), JavaHighlightUtil
.formatType(baseReturnType));
final PsiTypeElement returnTypeElement = method.getReturnTypeElement();
LOG.assertTrue(returnTypeElement != null);
registerProblem(message, null, returnTypeElement, LocalQuickFix.EMPTY_ARRAY);
}
}
}
}
}