本文整理汇总了Java中com.intellij.psi.infos.MethodCandidateInfo.getSubstitutor方法的典型用法代码示例。如果您正苦于以下问题:Java MethodCandidateInfo.getSubstitutor方法的具体用法?Java MethodCandidateInfo.getSubstitutor怎么用?Java MethodCandidateInfo.getSubstitutor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.infos.MethodCandidateInfo
的用法示例。
在下文中一共展示了MethodCandidateInfo.getSubstitutor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAmbiguousMethodHtmlTooltipMethodRow
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Language("HTML")
private static String createAmbiguousMethodHtmlTooltipMethodRow(final MethodCandidateInfo methodCandidate) {
PsiMethod method = methodCandidate.getElement();
PsiParameter[] parameters = method.getParameterList().getParameters();
PsiSubstitutor substitutor = methodCandidate.getSubstitutor();
@NonNls @Language("HTML") String ms = "<td><b>" + method.getName() + "</b></td>";
for (int j = 0; j < parameters.length; j++) {
PsiParameter parameter = parameters[j];
PsiType type = substitutor.substitute(parameter.getType());
ms += "<td><b>" + (j == 0 ? "(" : "") +
XmlStringUtil.escapeString(type.getPresentableText())
+ (j == parameters.length - 1 ? ")" : ",") + "</b></td>";
}
if (parameters.length == 0) {
ms += "<td><b>()</b></td>";
}
return ms;
}
示例2: registerSwapFixes
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static void registerSwapFixes(final PsiExpression[] expressions, final PsiCall callExpression, final List<PsiCall> permutations,
MethodCandidateInfo candidate, final int incompatibilitiesCount, final int minIncompatibleIndex,
final int maxIncompatibleIndex) throws IncorrectOperationException {
PsiMethod method = candidate.getElement();
PsiSubstitutor substitutor = candidate.getSubstitutor();
if (incompatibilitiesCount >= 3) return; // no way we can fix it by swapping
for (int i = minIncompatibleIndex; i < maxIncompatibleIndex; i++) {
for (int j = i+1; j <= maxIncompatibleIndex; j++) {
ArrayUtil.swap(expressions, i, j);
if (PsiUtil.isApplicable(method, substitutor, expressions)) {
PsiCall copy = (PsiCall)callExpression.copy();
PsiExpression[] copyExpressions = copy.getArgumentList().getExpressions();
copyExpressions[i].replace(expressions[i]);
copyExpressions[j].replace(expressions[j]);
JavaResolveResult result = copy.resolveMethodGenerics();
if (result.getElement() != null && result.isValidResult()) {
permutations.add(copy);
if (permutations.size() > 1) return;
}
}
ArrayUtil.swap(expressions, i, j);
}
}
}
示例3: createAmbiguousMethodHtmlTooltipMethodRow
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Language("HTML")
private static String createAmbiguousMethodHtmlTooltipMethodRow(final MethodCandidateInfo methodCandidate)
{
PsiMethod method = methodCandidate.getElement();
PsiParameter[] parameters = method.getParameterList().getParameters();
PsiSubstitutor substitutor = methodCandidate.getSubstitutor();
@NonNls @Language("HTML") String ms = "<td><b>" + method.getName() + "</b></td>";
for(int j = 0; j < parameters.length; j++)
{
PsiParameter parameter = parameters[j];
PsiType type = substitutor.substitute(parameter.getType());
ms += "<td><b>" + (j == 0 ? "(" : "") + XmlStringUtil.escapeString(type.getPresentableText()) + (j == parameters.length - 1 ? ")" : ",") + "</b></td>";
}
if(parameters.length == 0)
{
ms += "<td><b>()</b></td>";
}
return ms;
}
示例4: buildOneLineMismatchDescription
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String buildOneLineMismatchDescription(@NotNull PsiExpressionList list,
@NotNull MethodCandidateInfo candidateInfo,
@NotNull Ref<PsiElement> elementToHighlight) {
final PsiExpression[] expressions = list.getExpressions();
final PsiMethod resolvedMethod = candidateInfo.getElement();
final PsiSubstitutor substitutor = candidateInfo.getSubstitutor();
final PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters();
if (expressions.length == parameters.length && parameters.length > 1) {
int idx = -1;
for (int i = 0; i < expressions.length; i++) {
PsiExpression expression = expressions[i];
if (!TypeConversionUtil.areTypesAssignmentCompatible(substitutor.substitute(parameters[i].getType()), expression)) {
if (idx != -1) {
idx = -1;
break;
}
else {
idx = i;
}
}
}
if (idx > -1) {
final PsiExpression wrongArg = expressions[idx];
final PsiType argType = wrongArg.getType();
if (argType != null) {
elementToHighlight.set(wrongArg);
final String message = JavaErrorMessages
.message("incompatible.call.types", idx + 1, substitutor.substitute(parameters[idx].getType()).getCanonicalText(), argType.getCanonicalText());
return XmlStringUtil.wrapInHtml("<body>" + XmlStringUtil.escapeString(message) +
" <a href=\"#assignment/" + XmlStringUtil.escapeString(createMismatchedArgumentsHtmlTooltip(candidateInfo, list)) + "\"" +
(UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "") +
">" + DaemonBundle.message("inspection.extended.description") + "</a></body>");
}
}
}
return null;
}
示例5: createMismatchedArgumentsHtmlTooltip
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String createMismatchedArgumentsHtmlTooltip(MethodCandidateInfo info, PsiExpressionList list) {
PsiMethod method = info.getElement();
PsiSubstitutor substitutor = info.getSubstitutor();
PsiClass aClass = method.getContainingClass();
PsiParameter[] parameters = method.getParameterList().getParameters();
String methodName = method.getName();
return createMismatchedArgumentsHtmlTooltip(list, parameters, methodName, substitutor, aClass);
}
示例6: registerFix
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static void registerFix(HighlightInfo info, PsiCall callExpression, final CandidateInfo[] candidates, final TextRange fixRange) {
PsiExpression[] expressions = callExpression.getArgumentList().getExpressions();
if (expressions.length < 2) return;
List<PsiCall> permutations = new ArrayList<PsiCall>();
for (CandidateInfo candidate : candidates) {
if (candidate instanceof MethodCandidateInfo) {
MethodCandidateInfo methodCandidate = (MethodCandidateInfo)candidate;
PsiMethod method = methodCandidate.getElement();
PsiSubstitutor substitutor = methodCandidate.getSubstitutor();
PsiParameter[] parameters = method.getParameterList().getParameters();
if (expressions.length != parameters.length || parameters.length ==0) continue;
int minIncompatibleIndex = parameters.length;
int maxIncompatibleIndex = 0;
int incompatibilitiesCount = 0;
for (int i = 0; i < parameters.length; i++) {
PsiParameter parameter = parameters[i];
PsiType type = substitutor.substitute(parameter.getType());
if (TypeConversionUtil.areTypesAssignmentCompatible(type, expressions[i])) continue;
if (minIncompatibleIndex == parameters.length) minIncompatibleIndex = i;
maxIncompatibleIndex = i;
incompatibilitiesCount++;
}
try {
registerSwapFixes(expressions, callExpression, permutations, methodCandidate, incompatibilitiesCount, minIncompatibleIndex, maxIncompatibleIndex);
registerShiftFixes(expressions, callExpression, permutations, methodCandidate, minIncompatibleIndex, maxIncompatibleIndex);
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
}
if (permutations.size() == 1) {
PermuteArgumentsFix fix = new PermuteArgumentsFix(callExpression, permutations.get(0));
QuickFixAction.registerQuickFixAction(info, fixRange, fix);
}
}
示例7: createMismatchedArgumentsHtmlTooltip
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String createMismatchedArgumentsHtmlTooltip(MethodCandidateInfo info, PsiExpressionList list)
{
PsiMethod method = info.getElement();
PsiSubstitutor substitutor = info.getSubstitutor();
PsiClass aClass = method.getContainingClass();
PsiParameter[] parameters = method.getParameterList().getParameters();
String methodName = method.getName();
return createMismatchedArgumentsHtmlTooltip(list, info, parameters, methodName, substitutor, aClass);
}
示例8: isApplicable
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Override
protected boolean isApplicable(PsiMethod method, PsiElement place)
{
final PsiExpressionList argumentList = ((PsiMethodCallExpression) place).getArgumentList();
final MethodCandidateInfo candidateInfo = new MethodCandidateInfo(method, PsiSubstitutor.EMPTY, false, false, argumentList, null, argumentList.getExpressionTypes(), null);
PsiSubstitutor substitutorForMethod = candidateInfo.getSubstitutor();
if(PsiUtil.isApplicable(method, substitutorForMethod, argumentList))
{
final PsiType returnType = substitutorForMethod.substitute(method.getReturnType());
final PsiType expectedType = getExpectedType();
return expectedType == null || returnType == null || TypeConversionUtil.isAssignable(expectedType, returnType);
}
return false;
}
示例9: guardedOverloadResolution
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Nullable
protected CandidateInfo guardedOverloadResolution(@NotNull List<CandidateInfo> conflicts) {
if (conflicts.isEmpty()) return null;
if (conflicts.size() == 1) return conflicts.get(0);
boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParametersLength(), true);
if (conflicts.size() == 1) return conflicts.get(0);
final FactoryMap<MethodCandidateInfo, PsiSubstitutor> map = new FactoryMap<MethodCandidateInfo, PsiSubstitutor>() {
@Nullable
@Override
protected PsiSubstitutor create(MethodCandidateInfo key) {
return key.getSubstitutor(false);
}
};
checkSameSignatures(conflicts, map);
if (conflicts.size() == 1) return conflicts.get(0);
checkAccessStaticLevels(conflicts, true);
if (conflicts.size() == 1) return conflicts.get(0);
checkParametersNumber(conflicts, getActualParametersLength(), false);
if (conflicts.size() == 1) return conflicts.get(0);
checkStaticMethodsOfInterfaces(conflicts);
if (conflicts.size() == 1) return conflicts.get(0);
final int applicabilityLevel = checkApplicability(conflicts);
if (conflicts.size() == 1) return conflicts.get(0);
// makes no sense to do further checks, because if no one candidate matches by parameters count
// then noone can be more specific
if (!atLeastOneMatch) return null;
checkSpecifics(conflicts, applicabilityLevel, map, myLanguageLevel);
if (conflicts.size() == 1) return conflicts.get(0);
checkPrimitiveVarargs(conflicts, getActualParametersLength());
if (conflicts.size() == 1) return conflicts.get(0);
checkAccessStaticLevels(conflicts, false);
if (conflicts.size() == 1) return conflicts.get(0);
Set<CandidateInfo> uniques = new THashSet<CandidateInfo>(conflicts);
if (uniques.size() == 1) return uniques.iterator().next();
return null;
}
示例10: getSubstitutor
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@NotNull
private static PsiSubstitutor getSubstitutor(MethodCandidateInfo existing, FactoryMap<MethodCandidateInfo, PsiSubstitutor> map) {
return map != null ? map.get(existing) : existing.getSubstitutor(false);
}
示例11: getSubstitutor
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@NotNull
private static PsiSubstitutor getSubstitutor(MethodCandidateInfo existing, FactoryMap<MethodCandidateInfo, PsiSubstitutor> map)
{
return map != null ? map.get(existing) : existing.getSubstitutor(false);
}
示例12: buildOneLineMismatchDescription
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String buildOneLineMismatchDescription(@NotNull PsiExpressionList list, @NotNull MethodCandidateInfo candidateInfo, @NotNull Ref<PsiElement> elementToHighlight)
{
final PsiExpression[] expressions = list.getExpressions();
final PsiMethod resolvedMethod = candidateInfo.getElement();
final PsiSubstitutor substitutor = candidateInfo.getSubstitutor();
final PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters();
if(expressions.length == parameters.length && parameters.length > 1)
{
int idx = -1;
for(int i = 0; i < expressions.length; i++)
{
PsiExpression expression = expressions[i];
if(expression instanceof PsiMethodCallExpression)
{
final JavaResolveResult result = ((PsiCallExpression) expression).resolveMethodGenerics();
if(result instanceof MethodCandidateInfo && PsiUtil.isLanguageLevel8OrHigher(list) && ((MethodCandidateInfo) result).isToInferApplicability() && ((MethodCandidateInfo) result)
.getInferenceErrorMessage() == null)
{
continue;
}
}
if(!TypeConversionUtil.areTypesAssignmentCompatible(substitutor.substitute(parameters[i].getType()), expression))
{
if(idx != -1)
{
idx = -1;
break;
}
else
{
idx = i;
}
}
}
if(idx > -1)
{
final PsiExpression wrongArg = expressions[idx];
final PsiType argType = wrongArg.getType();
if(argType != null)
{
elementToHighlight.set(wrongArg);
final String message = JavaErrorMessages.message("incompatible.call.types", idx + 1, substitutor.substitute(parameters[idx].getType()).getCanonicalText(), argType
.getCanonicalText());
return XmlStringUtil.wrapInHtml("<body>" + XmlStringUtil.escapeString(message) + " <a href=\"#assignment/" + XmlStringUtil.escapeString(createMismatchedArgumentsHtmlTooltip
(candidateInfo, list)) + "\"" + (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "") + ">" + DaemonBundle.message("inspection.extended.description") + "</a></body>");
}
}
}
return null;
}