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


Java PsiParameter类代码示例

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


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

示例1: checkMethodSignature

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
private boolean checkMethodSignature(PsiMethod method) {
    // subscribe() calls that have no return type are custom Observers whose error handling we cannot check
    if (PsiType.VOID.equals(method.getReturnType())) {
        return false;
    }
    int argCount = method.getParameterList().getParametersCount();
    // when more than one argument is given, there is usually one error callback included
    if (argCount > 1) {
        return false;
    }
    // no arguments, no error handling
    if (argCount == 0) {
        return true;
    }
    // if we have only one argument, check that it's not a BiConsumer
    PsiParameter parameter = method.getParameterList().getParameters()[0];
    return !"io.reactivex.functions.BiConsumer".equals(parameter.getType().getCanonicalText());
}
 
开发者ID:IlyaGulya,项目名称:rxlint,代码行数:19,代码来源:RxJava2SubscriberCheck.java

示例2: findExtensionMethodNavigationElement

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
private PsiElement findExtensionMethodNavigationElement( PsiClass extClass, PsiMethod plantedMethod )
{
  PsiMethod[] found = extClass.findMethodsByName( plantedMethod.getName(), false );
  outer:
  for( PsiMethod m : found )
  {
    PsiParameter[] extParams = m.getParameterList().getParameters();
    PsiParameter[] plantedParams = plantedMethod.getParameterList().getParameters();
    if( extParams.length - 1 == plantedParams.length )
    {
      for( int i = 1; i < extParams.length; i++ )
      {
        PsiParameter extParam = extParams[i];
        PsiParameter plantedParam = plantedParams[i - 1];
        PsiType extErased = TypeConversionUtil.erasure( extParam.getType() );
        PsiType plantedErased = TypeConversionUtil.erasure( plantedParam.getType() );
        if( !extErased.toString().equals( plantedErased.toString() ) )
        {
          continue outer;
        }
      }
      return m.getNavigationElement();
    }
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:27,代码来源:ManAugmentProvider.java

示例3: inferType

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
@Nullable
public PsiType inferType( PsiTypeElement typeElement )
{
  PsiType psiType = null;

  final PsiElement parent = typeElement.getParent();
  if( (parent instanceof PsiLocalVariable && isVar( (PsiLocalVariable)parent )) ||
      (parent instanceof PsiParameter && isVarForEach( (PsiParameter)parent )) )
  {

    if( parent instanceof PsiLocalVariable )
    {
      psiType = processLocalVariableInitializer( ((PsiLocalVariable)parent).getInitializer() );
    }
    else
    {
      psiType = processForeach( ((PsiParameter)parent).getDeclarationScope() );
    }

    if( null == psiType )
    {
      psiType = PsiType.getJavaLangObject( typeElement.getManager(), GlobalSearchScope.allScope( typeElement.getProject() ) );
    }
  }
  return psiType;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:27,代码来源:VarHandler.java

示例4: 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

示例5: seekChildren

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
private static void seekChildren(PsiElement element, PsiIdentifier target, Find find) {
    for (PsiElement child : element.getChildren()) {
        if (child instanceof PsiLocalVariable) {
            PsiLocalVariable localVariable = (PsiLocalVariable) child;
            if (isSameName(target, localVariable.getNameIdentifier())) {
                find.findLocalVariable = localVariable;
                return;
            }
        }
        if (child instanceof PsiParameter) {
            PsiParameter parameter = (PsiParameter) child;
            if (isSameName(target, parameter.getNameIdentifier())) {
                find.findParameter = parameter;
                return;
            }
        }
        seekChildren(child, target, find);
        if (!find.isEmpty()) return;
    }
}
 
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:21,代码来源:ElementUtil.java

示例6: generateFieldInitialization

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
@Override
public void generateFieldInitialization(@NotNull StringBuilder buffer,
                                        @NotNull PsiField[] fields,
                                        @NotNull PsiParameter[] parameters) {
  for (int i = 0, length = fields.length; i < length; i++) {
    String fieldName = fields[i].getName();
    String paramName = parameters[i].getName();
    if (fieldName.equals(paramName)) {
      buffer.append("this.");
    }
    buffer.append(fieldName);
    buffer.append("=");
    buffer.append(paramName);
    buffer.append(";\n");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaConstructorBodyWithSuperCallGenerator.java

示例7: apply

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
  if (psiElement instanceof PsiParameterList) {
    String text = psiElement.getText();
    if (StringUtil.startsWithChar(text, '(') && !StringUtil.endsWithChar(text, ')')) {
      PsiParameter[] params = ((PsiParameterList)psiElement).getParameters();
      int offset;
      if (params.length == 0) {
        offset = psiElement.getTextRange().getStartOffset() + 1;
      }
      else {
        offset = params[params.length - 1].getTextRange().getEndOffset();
      }
      editor.getDocument().insertString(offset, ")");
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ParameterListFixer.java

示例8: appendAccessors

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
private void appendAccessors(final Set<PsiParameter> params, boolean isGetter) {
  final PsiElement element = getElement();
  if (element != null) {
    for (PsiParameter parameter : params) {
      final IntroduceParameterObjectProcessor.ParameterChunk parameterChunk =
        IntroduceParameterObjectProcessor.ParameterChunk.getChunkByParameter(parameter, parameters);
      LOGGER.assertTrue(parameterChunk != null);
      final PsiField field = parameterChunk.getField();
      if (field != null) {
        element.add(isGetter
                    ? GenerateMembersUtil.generateGetterPrototype(field)
                    : GenerateMembersUtil.generateSetterPrototype(field));
      }

    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AppendAccessorsUsageInfo.java

示例9: appendConflicts

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
private void appendConflicts(StringBuffer buf, final Set<PsiParameter> paramsNeeding) {
  if (!paramsNeeding.isEmpty()) {
    buf.append(paramsNeeding == paramsNeedingGetters ? "Getters" : "Setters");
    buf.append(" for the following fields are required:\n");
    buf.append(StringUtil.join(paramsNeeding, new Function<PsiParameter, String>() {
      public String fun(PsiParameter psiParameter) {
        final IntroduceParameterObjectProcessor.ParameterChunk chunk =
          IntroduceParameterObjectProcessor.ParameterChunk.getChunkByParameter(psiParameter, parameters);
        if (chunk != null) {
          final PsiField field = chunk.getField();
          if (field != null) {
            return field.getName();
          }
        }
        return psiParameter.getName();
      }
    }, ", "));
    buf.append(".\n");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AppendAccessorsUsageInfo.java

示例10: AutomaticParametersRenamer

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
public AutomaticParametersRenamer(PsiParameter param, String newParamName) {
  final PsiElement scope = param.getDeclarationScope();
  if (scope instanceof PsiMethod) {
    final PsiMethod method = (PsiMethod)scope;
    final int parameterIndex = method.getParameterList().getParameterIndex(param);
    if (parameterIndex < 0) return;
    for (PsiMethod overrider : OverridingMethodsSearch.search(method)) {
      final PsiParameter[] parameters = overrider.getParameterList().getParameters();
      if (parameterIndex >= parameters.length) continue;
      final PsiParameter inheritedParam = parameters[parameterIndex];
      if (!Comparing.strEqual(inheritedParam.getName(), newParamName)) {
        myElements.add(inheritedParam);
        suggestAllNames(inheritedParam.getName(), newParamName);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AutomaticParametersRenamer.java

示例11: IntroduceParameterSettingsUI

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
public IntroduceParameterSettingsUI(PsiLocalVariable onLocalVariable,
                                    PsiExpression onExpression,
                                    PsiMethod methodToReplaceIn,
                                    TIntArrayList parametersToRemove) {
  myHasInitializer = onLocalVariable != null && onLocalVariable.getInitializer() != null;
  myIsInvokedOnDeclaration = onExpression == null;
  final PsiParameter[] parameters = methodToReplaceIn.getParameterList().getParameters();
  myParametersToRemove = new PsiParameter[parameters.length];
  myParametersToRemoveChecked = new boolean[parameters.length];
  parametersToRemove.forEach(new TIntProcedure() {
    public boolean execute(final int paramNum) {
      myParametersToRemove[paramNum] = parameters[paramNum];
      return true;
    }
  });
  myIsLocalVariable = onLocalVariable != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:IntroduceParameterSettingsUI.java

示例12: MethodJavaDocHelper

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
public MethodJavaDocHelper(PsiMethod method) {
  myMethod = method;
  myDocComment = myMethod.getDocComment();
  if (myDocComment == null) {
    myDoCorrectJavaDoc = false;
    return;
  }
  final PsiParameter[] parameters = myMethod.getParameterList().getParameters();
  if (parameters.length != 0) {
    final PsiDocTag[] paramTags = myDocComment.findTagsByName("param");
    if (paramTags.length > 0) {
      myDoCorrectJavaDoc = true;
    } else {
      myDoCorrectJavaDoc = false;
    }
  } else {
    myDoCorrectJavaDoc = true;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MethodJavaDocHelper.java

示例13: fillMethodParameters

import com.intellij.psi.PsiParameter; //导入依赖的package包/类
public static String fillMethodParameters(final PsiMethod method, @Nullable final TIntObjectHashMap<SubLookupElement> replaceElements) {
  final TIntObjectHashMap<SubLookupElement> notNullReplaceElements = replaceElements == null ?
      new TIntObjectHashMap<SubLookupElement>(0) :
      replaceElements;

  final PsiParameter[] parameters = method.getParameterList().getParameters();
  final StringBuilder sb = new StringBuilder();
  for (int i = 0; i < parameters.length; i++) {
    if (i != 0) {
      sb.append(", ");
    }
    final PsiParameter parameter = parameters[i];
    final SubLookupElement replaceElement = notNullReplaceElements.get(i);
    if (replaceElement != null) {
      sb.append(replaceElement.getInsertString());
    } else {
      sb.append(parameter.getName());
    }
  }
  return sb.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ChainCompletionLookupElementUtil.java

示例14: 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

示例15: visitMethod

import com.intellij.psi.PsiParameter; //导入依赖的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


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