本文整理汇总了Java中com.intellij.psi.util.MethodSignature类的典型用法代码示例。如果您正苦于以下问题:Java MethodSignature类的具体用法?Java MethodSignature怎么用?Java MethodSignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodSignature类属于com.intellij.psi.util包,在下文中一共展示了MethodSignature类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findOverridingMethod
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
@Nullable
private static PsiMethod findOverridingMethod(PsiClass inheritor, @NotNull PsiClass parentClass, PsiMethod method) {
String name = method.getName();
if (inheritor.findMethodsByName(name, false).length > 0) {
PsiMethod found = MethodSignatureUtil.findMethodBySuperSignature(inheritor, getSuperSignature(inheritor, parentClass, method), false);
if (found != null && isAcceptable(found, method)) {
return found;
}
}
if (parentClass.isInterface() && !inheritor.isInterface()) { //check for sibling implementation
final PsiClass superClass = inheritor.getSuperClass();
if (superClass != null && !superClass.isInheritor(parentClass, true) && superClass.findMethodsByName(name, true).length > 0) {
MethodSignature signature = getSuperSignature(inheritor, parentClass, method);
PsiMethod derived = MethodSignatureUtil.findMethodInSuperClassBySignatureInDerived(inheritor, superClass, signature, true);
if (derived != null && isAcceptable(derived, method)) {
return derived;
}
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaOverridingMethodsSearcher.java
示例2: checkReturnTypeApplicable
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static boolean checkReturnTypeApplicable(PsiClassType.ClassResolveResult resolveResult, final PsiClass aClass) {
final MethodSignature methodSignature = LambdaUtil.getFunction(aClass);
if (methodSignature == null) return false;
for (PsiTypeParameter parameter : aClass.getTypeParameters()) {
if (parameter.getExtendsListTypes().length == 0) continue;
final PsiType substitution = resolveResult.getSubstitutor().substitute(parameter);
if (substitution instanceof PsiWildcardType && !((PsiWildcardType)substitution).isBounded()) {
boolean depends = false;
for (PsiType paramType : methodSignature.getParameterTypes()) {
if (LambdaUtil.depends(paramType, new LambdaUtil.TypeParamsChecker((PsiMethod)null, aClass) {
@Override
public boolean startedInference() {
return true;
}
}, parameter)) {
depends = true;
break;
}
}
if (!depends) return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:LambdaHighlightingUtil.java
示例3: canImplementOverride
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static boolean canImplementOverride(final MethodHierarchyNodeDescriptor descriptor, final MethodHierarchyBrowser methodHierarchyBrowser, final boolean toImplement) {
final PsiElement psiElement = descriptor.getPsiClass();
if (!(psiElement instanceof PsiClass)) return false;
final PsiClass psiClass = (PsiClass)psiElement;
if (psiClass instanceof PsiSyntheticClass) return false;
final PsiMethod baseMethod = methodHierarchyBrowser.getBaseMethod();
if (baseMethod == null) return false;
final MethodSignature signature = baseMethod.getSignature(PsiSubstitutor.EMPTY);
Collection<MethodSignature> allOriginalSignatures = toImplement
? OverrideImplementUtil.getMethodSignaturesToImplement(psiClass)
: OverrideImplementUtil.getMethodSignaturesToOverride(psiClass);
for (final MethodSignature originalSignature : allOriginalSignatures) {
if (originalSignature.equals(signature)) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:OverrideImplementMethodAction.java
示例4: findSubmemberHidesMemberCollisions
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static void findSubmemberHidesMemberCollisions(final PsiMethod method, final String newName, final List<UsageInfo> result) {
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) return;
if (method.hasModifierProperty(PsiModifier.PRIVATE)) return;
Collection<PsiClass> inheritors = ClassInheritorsSearch.search(containingClass, true).findAll();
MethodSignature oldSignature = method.getSignature(PsiSubstitutor.EMPTY);
MethodSignature newSignature = MethodSignatureUtil.createMethodSignature(newName, oldSignature.getParameterTypes(),
oldSignature.getTypeParameters(),
oldSignature.getSubstitutor(),
method.isConstructor());
for (PsiClass inheritor : inheritors) {
PsiSubstitutor superSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(containingClass, inheritor, PsiSubstitutor.EMPTY);
final PsiMethod[] methodsByName = inheritor.findMethodsByName(newName, false);
for (PsiMethod conflictingMethod : methodsByName) {
if (newSignature.equals(conflictingMethod.getSignature(superSubstitutor))) {
result.add(new SubmemberHidesMemberUsageInfo(conflictingMethod, method));
break;
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RenameJavaMethodProcessor.java
示例5: isMemberEnabled
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
@Override
public boolean isMemberEnabled(MemberInfo member) {
final PsiClass currentSuperClass = getSuperClass();
if(currentSuperClass == null) return true;
if (myMemberInfoStorage.getDuplicatedMemberInfos(currentSuperClass).contains(member)) return false;
if (myMemberInfoStorage.getExtending(currentSuperClass).contains(member.getMember())) return false;
final boolean isInterface = currentSuperClass.isInterface();
if (!isInterface) return true;
PsiElement element = member.getMember();
if (element instanceof PsiClass && ((PsiClass) element).isInterface()) return true;
if (element instanceof PsiField) {
return ((PsiModifierListOwner) element).hasModifierProperty(PsiModifier.STATIC);
}
if (element instanceof PsiMethod) {
final PsiSubstitutor superSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(currentSuperClass, myClass, PsiSubstitutor.EMPTY);
final MethodSignature signature = ((PsiMethod) element).getSignature(superSubstitutor);
final PsiMethod superClassMethod = MethodSignatureUtil.findMethodBySignature(currentSuperClass, signature, false);
if (superClassMethod != null && !PsiUtil.isLanguageLevel8OrHigher(currentSuperClass)) return false;
return !((PsiModifierListOwner) element).hasModifierProperty(PsiModifier.STATIC) || PsiUtil.isLanguageLevel8OrHigher(currentSuperClass);
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PullUpDialog.java
示例6: visitClass
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
@Override
public void visitClass(PsiClass aClass) {
super.visitClass(aClass);
if (!aClass.isInterface() || AnnotationUtil.isAnnotated(aClass, "java.lang.FunctionalInterface", false)) {
return;
}
if (LambdaHighlightingUtil.checkInterfaceFunctional(aClass) != null) {
return;
}
final List<HierarchicalMethodSignature> candidates = LambdaUtil.findFunctionCandidates(aClass);
if (candidates == null || candidates.size() != 1) {
return;
}
final MethodSignature signature = candidates.get(0);
if (signature.getTypeParameters().length > 0) {
return;
}
registerClassError(aClass, aClass);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:InterfaceMayBeAnnotatedFunctionalInspection.java
示例7: isSuperMethod
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
public boolean isSuperMethod(PsiMethod superMethodCandidate,
PsiMethod derivedMethod) {
final PsiClass superClassCandidate =
superMethodCandidate.getContainingClass();
final PsiClass derivedClass = derivedMethod.getContainingClass();
if (derivedClass == null || superClassCandidate == null) {
return false;
}
if (!derivedClass.isInheritor(superClassCandidate, false)) {
return false;
}
final PsiSubstitutor superSubstitutor =
TypeConversionUtil.getSuperClassSubstitutor(
superClassCandidate, derivedClass,
PsiSubstitutor.EMPTY);
final MethodSignature superSignature =
superMethodCandidate.getSignature(superSubstitutor);
final MethodSignature derivedSignature =
derivedMethod.getSignature(PsiSubstitutor.EMPTY);
return MethodSignatureUtil.isSubsignature(superSignature,
derivedSignature);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:UnnecessaryJavaDocLinkInspection.java
示例8: blockAssignsVariable
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private boolean blockAssignsVariable(@Nullable PsiCodeBlock block, @NotNull PsiVariable variable,
int stamp, @NotNull Set<MethodSignature> checkedMethods) {
if (counter != stamp) {
return true;
}
if (block == null) {
return false;
}
final PsiStatement[] statements = block.getStatements();
for (final PsiStatement statement : statements) {
if (statementAssignsVariable(statement, variable, stamp, checkedMethods)) {
return true;
}
if (counter != stamp) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UninitializedReadCollector.java
示例9: tryStatementAssignsVariable
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private boolean tryStatementAssignsVariable(@NotNull PsiTryStatement tryStatement, @NotNull PsiVariable variable,
int stamp, @NotNull Set<MethodSignature> checkedMethods) {
final PsiResourceList resourceList = tryStatement.getResourceList();
if (resourceList != null) {
for (PsiResourceListElement resource : resourceList) {
if (resource instanceof PsiResourceVariable) {
final PsiExpression initializer = ((PsiResourceVariable)resource).getInitializer();
if (expressionAssignsVariable(initializer, variable, stamp, checkedMethods)) {
return true;
}
}
}
}
final PsiCodeBlock tryBlock = tryStatement.getTryBlock();
boolean initializedInTryOrCatch = blockAssignsVariable(tryBlock, variable, stamp, checkedMethods);
final PsiCodeBlock[] catchBlocks = tryStatement.getCatchBlocks();
for (final PsiCodeBlock catchBlock : catchBlocks) {
initializedInTryOrCatch &= blockAssignsVariable(catchBlock, variable, stamp, checkedMethods);
}
if (initializedInTryOrCatch) {
return true;
}
final PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock();
return blockAssignsVariable(finallyBlock, variable, stamp, checkedMethods);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:UninitializedReadCollector.java
示例10: forStatementAssignsVariable
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private boolean forStatementAssignsVariable(@NotNull PsiForStatement forStatement, @NotNull PsiVariable variable,
int stamp, @NotNull Set<MethodSignature> checkedMethods) {
final PsiStatement initialization = forStatement.getInitialization();
if (statementAssignsVariable(initialization, variable, stamp, checkedMethods)) {
return true;
}
final PsiExpression condition = forStatement.getCondition();
if (expressionAssignsVariable(condition, variable, stamp, checkedMethods)) {
return true;
}
if (BoolUtils.isTrue(condition)) {
final PsiStatement body = forStatement.getBody();
if (statementAssignsVariable(body, variable, stamp, checkedMethods)) {
return true;
}
final PsiStatement update = forStatement.getUpdate();
if (statementAssignsVariable(update, variable, stamp, checkedMethods)) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:UninitializedReadCollector.java
示例11: assignmentExpressionAssignsVariable
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private boolean assignmentExpressionAssignsVariable(@NotNull PsiAssignmentExpression assignment, @NotNull PsiVariable variable,
int stamp, @NotNull Set<MethodSignature> checkedMethods) {
final PsiExpression lhs = assignment.getLExpression();
if (expressionAssignsVariable(lhs, variable, stamp, checkedMethods)) {
return true;
}
final PsiExpression rhs = assignment.getRExpression();
if (expressionAssignsVariable(rhs, variable, stamp, checkedMethods)) {
return true;
}
if (lhs instanceof PsiReferenceExpression) {
final PsiElement element = ((PsiReference)lhs).resolve();
if (element != null && element.equals(variable)) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:UninitializedReadCollector.java
示例12: referenceExpressionAssignsVariable
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private boolean referenceExpressionAssignsVariable(@NotNull PsiReferenceExpression referenceExpression, @NotNull PsiVariable variable,
int stamp, @NotNull Set<MethodSignature> checkedMethods) {
final PsiExpression qualifierExpression = referenceExpression.getQualifierExpression();
if (expressionAssignsVariable(qualifierExpression, variable, stamp, checkedMethods)) {
return true;
}
if (variable.equals(referenceExpression.resolve())) {
final PsiElement parent = referenceExpression.getParent();
if (parent instanceof PsiAssignmentExpression) {
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)parent;
final PsiExpression rhs = assignmentExpression.getRExpression();
if (rhs != null && rhs.equals(referenceExpression)) {
checkReferenceExpression(referenceExpression, variable, qualifierExpression);
}
}
else {
checkReferenceExpression(referenceExpression, variable, qualifierExpression);
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:UninitializedReadCollector.java
示例13: newExpressionAssignsVariable
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private boolean newExpressionAssignsVariable(@NotNull PsiNewExpression newExpression, @NotNull PsiVariable variable,
int stamp, @NotNull Set<MethodSignature> checkedMethods) {
final PsiExpressionList argumentList = newExpression.getArgumentList();
if (argumentList != null) {
final PsiExpression[] args = argumentList.getExpressions();
for (final PsiExpression arg : args) {
if (expressionAssignsVariable(arg, variable, stamp, checkedMethods)) {
return true;
}
}
}
final PsiArrayInitializerExpression arrayInitializer = newExpression.getArrayInitializer();
if (expressionAssignsVariable(arrayInitializer, variable, stamp, checkedMethods)) {
return true;
}
final PsiExpression[] arrayDimensions = newExpression.getArrayDimensions();
for (final PsiExpression dim : arrayDimensions) {
if (expressionAssignsVariable(dim, variable, stamp, checkedMethods)) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:UninitializedReadCollector.java
示例14: blockAssignsVariableOrFails
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static boolean blockAssignsVariableOrFails(@Nullable PsiCodeBlock block, @NotNull PsiVariable variable,
@NotNull Set<MethodSignature> checkedMethods, boolean strict) {
if (block == null) {
return false;
}
int assignmentCount = 0;
for (final PsiStatement statement : block.getStatements()) {
if (statementAssignsVariableOrFails(statement, variable, checkedMethods, strict)) {
if (strict) {
assignmentCount++;
}
else {
return true;
}
}
}
return assignmentCount == 1;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:InitializationUtils.java
示例15: tryStatementAssignsVariableOrFails
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static boolean tryStatementAssignsVariableOrFails(@NotNull PsiTryStatement tryStatement, PsiVariable variable,
@NotNull Set<MethodSignature> checkedMethods, boolean strict) {
final PsiResourceList resourceList = tryStatement.getResourceList();
if (resourceList != null) {
for (PsiResourceListElement resource : resourceList) {
if (resource instanceof PsiResourceVariable) {
final PsiExpression initializer = ((PsiResourceVariable)resource).getInitializer();
if (expressionAssignsVariableOrFails(initializer, variable, checkedMethods, strict)) {
return true;
}
}
}
}
boolean initializedInTryAndCatch = blockAssignsVariableOrFails(tryStatement.getTryBlock(), variable, checkedMethods, strict);
final PsiCodeBlock[] catchBlocks = tryStatement.getCatchBlocks();
for (final PsiCodeBlock catchBlock : catchBlocks) {
if (strict) {
initializedInTryAndCatch &= ExceptionUtils.blockThrowsException(catchBlock);
}
else {
initializedInTryAndCatch &= blockAssignsVariableOrFails(catchBlock, variable, checkedMethods, strict);
}
}
return initializedInTryAndCatch || blockAssignsVariableOrFails(tryStatement.getFinallyBlock(), variable, checkedMethods, strict);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:InitializationUtils.java
示例16: ifStatementAssignsVariableOrFails
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static boolean ifStatementAssignsVariableOrFails(@NotNull PsiIfStatement ifStatement, PsiVariable variable,
@NotNull Set<MethodSignature> checkedMethods, boolean strict) {
final PsiExpression condition = ifStatement.getCondition();
if (expressionAssignsVariableOrFails(condition, variable, checkedMethods, strict)) {
return true;
}
final PsiStatement thenBranch = ifStatement.getThenBranch();
if (BoolUtils.isTrue(condition)) {
return statementAssignsVariableOrFails(thenBranch, variable, checkedMethods, strict);
}
final PsiStatement elseBranch = ifStatement.getElseBranch();
if (BoolUtils.isFalse(condition)) {
return statementAssignsVariableOrFails(elseBranch, variable, checkedMethods, strict);
}
return statementAssignsVariableOrFails(thenBranch, variable, checkedMethods, strict) &&
statementAssignsVariableOrFails(elseBranch, variable, checkedMethods, strict);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:InitializationUtils.java
示例17: forStatementAssignsVariableOrFails
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static boolean forStatementAssignsVariableOrFails(@NotNull PsiForStatement forStatement, PsiVariable variable,
@NotNull Set<MethodSignature> checkedMethods, boolean strict) {
if (statementAssignsVariableOrFails(forStatement.getInitialization(), variable, checkedMethods, strict)) {
return true;
}
final PsiExpression condition = forStatement.getCondition();
if (expressionAssignsVariableOrFails(condition, variable, checkedMethods, strict)) {
return true;
}
if (BoolUtils.isTrue(condition)) {
if (statementAssignsVariableOrFails(forStatement.getBody(), variable, checkedMethods, strict)) {
return true;
}
if (statementAssignsVariableOrFails(forStatement.getUpdate(), variable, checkedMethods, strict)) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:InitializationUtils.java
示例18: newExpressionAssignsVariableOrFails
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
private static boolean newExpressionAssignsVariableOrFails(@NotNull PsiNewExpression newExpression, PsiVariable variable,
@NotNull Set<MethodSignature> checkedMethods, boolean strict) {
final PsiExpressionList argumentList = newExpression.getArgumentList();
if (argumentList != null) {
for (final PsiExpression argument : argumentList.getExpressions()) {
if (expressionAssignsVariableOrFails(argument, variable, checkedMethods, strict)) {
return true;
}
}
}
if (expressionAssignsVariableOrFails(newExpression.getArrayInitializer(), variable, checkedMethods, strict)) {
return true;
}
for (final PsiExpression dimension : newExpression.getArrayDimensions()) {
if (expressionAssignsVariableOrFails(dimension, variable, checkedMethods, strict)) {
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:InitializationUtils.java
示例19: collectMethods
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
@Override
public void collectMethods(@NotNull final GrTypeDefinition clazz, @NotNull Collection<PsiMethod> collector) {
Set<PsiClass> processed = new HashSet<PsiClass>();
if (!checkForDelegate(clazz)) return;
Map<MethodSignature, PsiMethod> signatures = new THashMap<MethodSignature, PsiMethod>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
initializeSignatures(clazz, PsiSubstitutor.EMPTY, signatures, processed);
List<PsiMethod> methods = new ArrayList<PsiMethod>();
process(clazz, PsiSubstitutor.EMPTY, true, new HashSet<PsiClass>(), processed, methods, clazz, false);
final Set<PsiMethod> result = new LinkedHashSet<PsiMethod>();
for (PsiMethod method : methods) {
addMethodChecked(signatures, method, PsiSubstitutor.EMPTY, result);
}
collector.addAll(result);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:DelegatedMethodsContributor.java
示例20: addMethodChecked
import com.intellij.psi.util.MethodSignature; //导入依赖的package包/类
/**
* Adds 'method' to 'signatures' if it doesn't yet contain any method with the same signature or replaces abstract methods
*/
private static void addMethodChecked(Map<MethodSignature, PsiMethod> signatures,
PsiMethod method,
PsiSubstitutor substitutor,
@Nullable Set<PsiMethod> resultSet) {
if (method.isConstructor()) return;
if (method.hasModifierProperty(PsiModifier.STATIC)) return;
final MethodSignature signature = method.getSignature(substitutor);
final PsiMethod old = signatures.get(signature);
if (old != null) {
//if (method.hasModifierProperty(PsiModifier.ABSTRACT)) return;
if (!old.hasModifierProperty(PsiModifier.ABSTRACT)) return;
if (resultSet != null) resultSet.remove(old);
}
signatures.put(signature, method);
if (resultSet != null) resultSet.add(method);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DelegatedMethodsContributor.java
注:本文中的com.intellij.psi.util.MethodSignature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论