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


Java PsiParameter.getType方法代码示例

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


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

示例1: check

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
void check(@NonNull PsiMethod method) {
    if (mClass != null &&
            !mClassFields.isEmpty()) {

        // メソッド引数に boolean のパラメータがある場合のみ対象とする
        Map<String, PsiParameter> parameters = new HashMap<>();
        PsiParameter[] params = method.getParameterList().getParameters();
        for (PsiParameter param : params) {
            if (param.getType() != PsiType.BOOLEAN) continue;
            parameters.put(param.getName(), param);
        }
        if (parameters.isEmpty()) return;

        mMethod = method;
        mFlagMethodParameters.clear();
        mFlagMethodParameters.putAll(parameters);
        mFlagLogic = null;
    }
}
 
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:20,代码来源:MultiFunctionFlagStructureDetector.java

示例2: matchParameters

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
private static MatchResult matchParameters(final PsiMethod method, final ChainCompletionContext context, final Set<String> additionalExcludedNames) {
  int matched = 0;
  int unMatched = 0;
  boolean hasTarget = false;
  for (final PsiParameter parameter : method.getParameterList().getParameters()) {
    final PsiType type = parameter.getType();
    final String canonicalText = type.getCanonicalText();
    if (context.contains(canonicalText) || type instanceof PsiPrimitiveType) {
      matched++;
    }
    else {
      unMatched++;
    }
    if (context.getTarget().getClassQName().equals(canonicalText) || additionalExcludedNames.contains(canonicalText)) {
      hasTarget = true;
    }
  }
  return new MatchResult(matched, unMatched, hasTarget);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ParametersMatcher.java

示例3: allCaughtTypes

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@NotNull
private List<DfaTypeValue> allCaughtTypes(PsiParameter param)
{
	List<PsiType> psiTypes;
	PsiType type = param.getType();
	if(type instanceof PsiDisjunctionType)
	{
		psiTypes = ((PsiDisjunctionType) type).getDisjunctions();
	}
	else
	{
		psiTypes = Collections.singletonList(type);
	}
	List<DfaValue> result = psiTypes.stream().map(it -> myRunner.getFactory().createTypeValue(it, Nullness.NOT_NULL)).collect(Collectors.toList());
	return ContainerUtil.<DfaValue, DfaTypeValue>mapNotNull(result, dfaValue -> dfaValue instanceof DfaTypeValue ? (DfaTypeValue) dfaValue : null);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:ControlTransferHandler.java

示例4: visitMethod

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
public void visitMethod(JavaContext context, PsiMethod method) {

        boolean isPublicMethod = method.hasModifierProperty(PsiModifier.PUBLIC);
        if (!isPublicMethod) return;

        JavaEvaluator evaluator = context.getEvaluator();
        if (evaluator == null) return;

        PsiParameterList parameterList = method.getParameterList();
        PsiParameter[] psiParameters = parameterList.getParameters();

        boolean hasBeanParameter = false;
        for (PsiParameter p : psiParameters) {
            PsiType type = p.getType();

            if (!(type instanceof PsiClassType)) continue;

            PsiClassType classType = (PsiClassType) type;
            PsiClass psiCls = classType.resolve();
            if (psiCls == null) continue;

            hasBeanParameter = Utils.isCustomBean(context, psiCls);
            if (hasBeanParameter) break;
        }

        if (hasBeanParameter) {
            mMethods.add(method);
        }
    }
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:30,代码来源:AutoPointCustomViewGroupDetector.java

示例5: getRawTypeName

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@NotNull
private String getRawTypeName( PsiParameter param )
{
  PsiType type = param.getType();
  if( type instanceof PsiClassType )
  {
    type = ((PsiClassType)type).rawType();
  }
  return type.getCanonicalText();
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:11,代码来源:ExtensionClassAnnotator.java

示例6: getParameters

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@Override
public List<ParameterInfoImpl> getParameters() {
  final ArrayList<ParameterInfoImpl> result = new ArrayList<ParameterInfoImpl>();
  final PsiParameter[] parameters = myMethod.getParameterList().getParameters();
  for (int i = 0; i < parameters.length; i++) {
    PsiParameter parameter = parameters[i];
    ParameterInfoImpl info = new ParameterInfoImpl(i, parameter.getName(), parameter.getType());
    info.defaultValue = "";
    result.add(info);
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaMethodDescriptor.java

示例7: hasOnlyClosureParams

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
private static boolean hasOnlyClosureParams(PsiMethod method) {
  final PsiParameter[] params = method.getParameterList().getParameters();
  for (PsiParameter param : params) {
    final PsiType type = param.getType();
    if (!TypesUtil.isClassType(type, GroovyCommonClassNames.GROOVY_LANG_CLOSURE)) {
      return false;
    }
  }
  return params.length > 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GrMethodMergingContributor.java

示例8: getMethodWithMinNotPrimitiveParameters

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@Nullable
public static PsiMethod getMethodWithMinNotPrimitiveParameters(final @NotNull PsiMethod[] methods,
                                                               final Set<String> excludedParamsQNames) {
  PsiMethod minMethod = null;
  int minParametersCount = Integer.MAX_VALUE;
  for (final PsiMethod method : methods) {
    final PsiParameterList parameterList = method.getParameterList();
    boolean doContinue = false;
    int parametersCount = parameterList.getParametersCount();
    for (final PsiParameter p : parameterList.getParameters()) {
      if (!(p.getType() instanceof PsiPrimitiveType)) {
        if (excludedParamsQNames.contains(p.getType().getCanonicalText())) {
          doContinue = true;
          break;
        }
        parametersCount++;
      }
    }
    if (doContinue) {
      continue;
    }
    if (parametersCount < minParametersCount) {
      if (parametersCount == 0) {
        return method;
      }
      minParametersCount = parametersCount;
      minMethod = method;
    }
  }
  return minMethod;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:MethodChainsSearchUtil.java

示例9: checkForLazyOrProvider

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
public static PsiClass checkForLazyOrProvider(PsiParameter psiParameter) {
  PsiClass wrapperClass = PsiConsultantImpl.getClass(psiParameter);

  PsiType psiParameterType = psiParameter.getType();
  if (!(psiParameterType instanceof PsiClassType)) {
    return wrapperClass;
  }

  return getPsiClass(wrapperClass, psiParameterType);
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:11,代码来源:PsiConsultantImpl.java

示例10: checkMethodParameters

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@NotNull
static PsiParameter[] checkMethodParameters(PsiMethod method)
{
	if(method.getBody() == null)
	{
		return PsiParameter.EMPTY_ARRAY;
	}

	final Collection<PsiParameter> nullableParameters = new SmartList<>();
	final PsiParameter[] parameters = method.getParameterList().getParameters();
	for(int index = 0; index < parameters.length; index++)
	{
		PsiParameter parameter = parameters[index];
		if(!(parameter.getType() instanceof PsiPrimitiveType) && !NullableNotNullManager.isNotNull(parameter) && !NullableNotNullManager.isNullable(parameter) && JavaNullMethodArgumentUtil
				.hasNullArgument(method, index))
		{
			nullableParameters.add(parameter);
		}
	}
	if(nullableParameters.isEmpty())
	{
		return PsiParameter.EMPTY_ARRAY;
	}

	final NullParameterConstraintChecker checker = new NullParameterConstraintChecker(nullableParameters);
	checker.analyzeMethod(method.getBody(), new StandardInstructionVisitor());

	return checker.myPossiblyViolatedParameters.stream().filter(checker.myUsedParameters::contains).toArray(PsiParameter[]::new);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:30,代码来源:NullParameterConstraintChecker.java

示例11: looksLikeHelperMethodOrConst

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
private static boolean looksLikeHelperMethodOrConst(@NotNull PsiElement element)
{
	if(!(element instanceof PsiMethod))
	{
		return false;
	}
	PsiMethod method = (PsiMethod) element;
	if(method.isConstructor())
	{
		return false;
	}
	if(isRawDeepTypeEqualToObject(method.getReturnType()))
	{
		return true;
	}
	PsiParameter[] parameters = method.getParameterList().getParameters();
	if(parameters.length == 0)
	{
		return false;
	}
	for(PsiParameter parameter : parameters)
	{
		PsiType paramType = parameter.getType();
		if(isRawDeepTypeEqualToObject(paramType))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:PreferMostUsedWeigher.java

示例12: getParameterType

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@Nullable
private static PsiType getParameterType(@NotNull PsiParameter parameter) {
  return parameter instanceof GrParameter ? ((GrParameter)parameter).getDeclaredType() : parameter.getType();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:GrImmediateClosureParameterImpl.java

示例13: buildVisitor

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
  return new EndpointPsiElementVisitor() {
    @Override
    public void visitParameter(PsiParameter psiParameter) {
      if (!EndpointUtilities.isEndpointClass(psiParameter)) {
        return;
      }

      // Check if method is public or non-static
      PsiElement psiElement = psiParameter.getDeclarationScope();
      if (psiElement instanceof PsiMethod) {
        if (!EndpointUtilities.isApiMethod((PsiMethod) psiElement)) {
          return;
        }

        if (((PsiMethod) psiElement).isConstructor()) {
          return;
        }
      } else {
        return;
      }

      Project project;
      try {
        project = psiParameter.getContainingFile().getProject();
        if (project == null) {
          return;
        }
      } catch (PsiInvalidElementAccessException ex) {
        LOG.error("Cannot determine project with parameter " + psiParameter.getText(), ex);
        return;
      }

      // Check if parameter is an API Parameter
      PsiType psiType = psiParameter.getType();
      if (!isApiParameter(psiType, project)) {
        return;
      }

      // Check that API parameter has Named Resource (@Named)
      if (!hasParameterName(psiParameter)) {
        holder.registerProblem(
            psiParameter,
            "Missing parameter name. Parameter type ("
                + psiType.getPresentableText()
                + ") is not an entity type and thus should be annotated with @Named.",
            new MyQuickFix());
      }
    }
  };
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:54,代码来源:ApiParameterInspection.java

示例14: methodMatches

import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
/**
 * @param method              the method to compare to.
 * @param containingClassName the name of the class which contiains the
 *                            method.
 * @param returnType          the return type, specify null if any type matches
 * @param methodName          the name the method should have
 * @param parameterTypes      the type of the parameters of the method, specify
 *                            null if any number and type of parameters match or an empty array
 *                            to match zero parameters.
 * @return true, if the specified method matches the specified constraints,
 * false otherwise
 */
public static boolean methodMatches(
  @NotNull PsiMethod method,
  @NonNls @Nullable String containingClassName,
  @Nullable PsiType returnType,
  @NonNls @Nullable String methodName,
  @Nullable List<PsiType> parameterTypes) {
  final String name = method.getName();
  if (methodName != null && !methodName.equals(name)) {
    return false;
  }
  if (parameterTypes != null) {
    final PsiParameterList parameterList = method.getParameterList();
    if (parameterList.getParametersCount() != parameterTypes.size()) {
      return false;
    }
    final PsiParameter[] parameters = parameterList.getParameters();
    for (int i = 0; i < parameters.length; i++) {
      final PsiParameter parameter = parameters[i];
      final PsiType type = parameter.getType();
      final PsiType parameterType = parameterTypes.get(i);
      if (PsiType.NULL.equals(parameterType)) {
        continue;
      }
      if (parameterType != null &&
        !typesAreEquivalent(type,
          parameterType)) {
        return false;
      }
    }
  }
  if (returnType != null) {
    final PsiType methodReturnType = method.getReturnType();
    if (!typesAreEquivalent(returnType,
      methodReturnType)) {
      return false;
    }
  }
  if (containingClassName != null) {
    final PsiClass containingClass = method.getContainingClass();
    return InheritanceUtil.isInheritor(containingClass,
      containingClassName);
  }
  return true;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:57,代码来源:PsiElementUtil.java


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