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


Java PsiMethod.getReturnType方法代码示例

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


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

示例1: isPsiMethodCamelLanguage

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private boolean isPsiMethodCamelLanguage(PsiMethod method) {
    PsiType type = method.getReturnType();
    if (type != null && type instanceof PsiClassReferenceType) {
        PsiClassReferenceType clazz = (PsiClassReferenceType) type;
        PsiClass resolved = clazz.resolve();
        if (resolved != null) {
            boolean language = getCamelIdeaUtils().isCamelExpressionOrLanguage(resolved);
            // try parent using some weird/nasty stub stuff which is how complex IDEA AST
            // is when its parsing the Camel route builder
            if (!language) {
                PsiElement elem = resolved.getParent();
                if (elem instanceof PsiTypeParameterList) {
                    elem = elem.getParent();
                }
                if (elem instanceof PsiClass) {
                    language = getCamelIdeaUtils().isCamelExpressionOrLanguage((PsiClass) elem);
                }
            }
            return language;
        }
    }

    return false;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:25,代码来源:CamelDocumentationProvider.java

示例2: doFix

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final PsiMethod method = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethod.class);
  if (method != null) {
    final PsiModifierList modifierList = method.getModifierList();
    if (!modifierList.hasModifierProperty(PsiModifier.PUBLIC)) {
      modifierList.setModifierProperty(PsiModifier.PUBLIC, true);
    }
    if (!modifierList.hasModifierProperty(PsiModifier.STATIC)) {
      modifierList.setModifierProperty(PsiModifier.STATIC, true);
    }

    if (method.getReturnType() != PsiType.VOID) {
      ChangeSignatureProcessor csp =
        new ChangeSignatureProcessor(project, method, false, PsiModifier.PUBLIC, method.getName(), PsiType.VOID,
                                     new ParameterInfoImpl[0]);
      csp.run();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspection.java

示例3: isValidInContext

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public boolean isValidInContext(PsiElement element) {
  if (!(element instanceof PsiMethod)) return false;
  PsiMethod method = (PsiMethod)element;
  final PsiType type = method.getReturnType();
  if (type == null) return false;
  return type != PsiType.VOID;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ReturnDocTagInfo.java

示例4: methodMatches

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public boolean methodMatches(@NotNull PsiMethod method) {
  final String methodName = method.getName();
  final Pattern methodNamePattern = getMethodNamePattern();
  if ((methodNamePattern != null) && methodNamePattern.matcher(methodName).matches()) {
    return true;
  }
  final PsiType returnType = method.getReturnType();
  if (returnType == null) {
    return false;
  }
  final Pattern patternTypePattern = getMethodTypePattern();
  final String methodType = returnType.getCanonicalText();
  return (patternTypePattern != null) && methodTypePattern.matcher(methodType).matches();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:FilterPattern.java

示例5: removeReferences

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static void removeReferences(PsiParameter parameter) {
  PsiMethod method = (PsiMethod) parameter.getDeclarationScope();
  ChangeSignatureProcessor processor = new ChangeSignatureProcessor(parameter.getProject(),
                                                                    method,
                                                                    false, null,
                                                                    method.getName(),
                                                                    method.getReturnType(),
                                                                    getNewParametersInfo(method, parameter));
  processor.run();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:RemoveUnusedParameterFix.java

示例6: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  //note: no call to super;
  if (method.isConstructor()) {
    return;
  }
  if (!TestUtils.isJUnit3TestMethod(method) && !TestUtils.isJUnit4TestMethod(method)) {
    return;
  }
  final PsiType returnType = method.getReturnType();
  final PsiParameterList parameterList = method.getParameterList();
  final boolean takesArguments;
  final boolean isStatic;
  if (parameterList.getParametersCount() == 0) {
    takesArguments = false;
    isStatic = method.hasModifierProperty(PsiModifier.STATIC);
    if (!isStatic && PsiType.VOID.equals(returnType) && method.hasModifierProperty(PsiModifier.PUBLIC)) {
      return;
    }
  }
  else {
    isStatic = false;
    takesArguments = true;
  }
  registerMethodError(method, Boolean.valueOf(takesArguments),
                      Boolean.valueOf(isStatic));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:TestMethodIsPublicVoidNoArgInspection.java

示例7: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  final PsiType returnType = method.getReturnType();
  if (returnType == null) {
    return;
  }
  else if (!returnType.equals(PsiType.BOOLEAN)) {
    if (ignoreBooleanMethods || !returnType.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN)) {
      return;
    }
  }
  if (ignoreInAnnotationInterface) {
    final PsiClass containingClass = method.getContainingClass();
    if (containingClass != null && containingClass.isAnnotationType()) {
      return;
    }
  }
  final String name = method.getName();
  for (String question : questionList) {
    if (name.startsWith(question)) {
      return;
    }
  }
  if (onlyWarnOnBaseMethods) {
    if (MethodUtils.hasSuper(method)) {
      return;
    }
  }
  else if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:BooleanMethodNameMustStartWithQuestionInspectionBase.java

示例8: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  final PsiType returnType = method.getReturnType();
  if (returnType == null || returnType.equals(PsiType.BOOLEAN)) {
    return;
  }
  if (ignoreBooleanMethods && returnType.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN)) {
    return;
  }
  final String name = method.getName();
  boolean startsWithQuestionWord = false;
  for (String question : questionList) {
    if (name.startsWith(question)) {
      if (name.length() == question.length()) {
        startsWithQuestionWord = true;
        break;
      }
      final char nextChar = name.charAt(question.length());
      if (Character.isUpperCase(nextChar) || nextChar == '_') {
        startsWithQuestionWord = true;
        break;
      }
    }
  }
  if (!startsWithQuestionWord) {
    return;
  }
  if (onlyWarnOnBaseMethods) {
    if (MethodUtils.hasSuper(method)) {
      return;
    }
  }
  else if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:NonBooleanMethodNameMayNotStartWithQuestionInspectionBase.java

示例9: mayFallThroughBottom

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private boolean mayFallThroughBottom(PsiMethod method) {
  if (method.isConstructor()) {
    return true;
  }
  final PsiType returnType = method.getReturnType();
  return PsiType.VOID.equals(returnType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:MultipleReturnPointsPerMethodInspection.java

示例10: shouldBeGenerated

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static boolean shouldBeGenerated(PsiMethod method) {
  for (PsiMethod psiMethod : method.findSuperMethods()) {
    if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
      final PsiType type = method.getReturnType();
      final PsiType superType = psiMethod.getReturnType();
      if (type != null && superType != null && !superType.isAssignableFrom(type)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ClassGenerator.java

示例11: getPriority

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static int getPriority(LookupElement element) {
  PsiMethod method = assertNotNull(getItemMethod(element));
  return (method.getReturnType() == PsiType.VOID ? 0 : 1) +
         (method.getParameterList().getParametersCount() > 0 ? 2 : 0);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:JavaMethodMergingContributor.java

示例12: getTableCellEditorComponent

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public Component getTableCellEditorComponent(
  final JTable table,
  final Object value,
  final boolean isSelected,
  final int row,
  final int column
) {
  myEditingRow = row;
  final DefaultComboBoxModel model = (DefaultComboBoxModel)myCbx.getModel();
  model.removeAllElements();
  model.addElement(null/*<not defined>*/);

  // Fill combobox with available bean's properties
  final String[] rProps = PropertyUtil.getReadableProperties(myData.myBeanClass, true);
  final String[] wProps = PropertyUtil.getWritableProperties(myData.myBeanClass, true);
  final ArrayList<BeanProperty> rwProps = new ArrayList<BeanProperty>();

  outer: for(int i = rProps.length - 1; i >= 0; i--){
    final String propName = rProps[i];
    if(ArrayUtil.find(wProps, propName) != -1){
      LOG.assertTrue(!rwProps.contains(propName));
      final PsiMethod getter = PropertyUtil.findPropertyGetter(myData.myBeanClass, propName, false, true);
      if (getter == null) {
        // possible if the getter is static: getReadableProperties() does not filter out static methods, and
        // findPropertyGetter() checks for static/non-static
        continue;
      }
      final PsiType returnType = getter.getReturnType();
      LOG.assertTrue(returnType != null);

      // There are two possible types: boolean and java.lang.String
      @NonNls final String typeName = returnType.getCanonicalText();
      LOG.assertTrue(typeName != null);
      if(!"boolean".equals(typeName) && !"java.lang.String".equals(typeName)){
        continue;
      }

      // Check that the property is not in use yet
      for(int j = myData.myBindings.length - 1; j >= 0; j--){
        final BeanProperty _property = myData.myBindings[j].myBeanProperty;
        if(j != row && _property != null && propName.equals(_property.myName)){
          continue outer;
        }
      }

      // Check that we conver types
      if(
        !canConvert(
          myData.myBindings[row].myFormProperty.getComponentPropertyClassName(),
          typeName
        )
      ){
        continue;
      }

      rwProps.add(new BeanProperty(propName, typeName));
    }
  }

  Collections.sort(rwProps);

  for (BeanProperty rwProp : rwProps) {
    model.addElement(rwProp);
  }

  // Set initially selected item
  if(myData.myBindings[row].myBeanProperty != null){
    myCbx.setSelectedItem(myData.myBindings[row].myBeanProperty);
  }
  else{
    myCbx.setSelectedIndex(0/*<not defined>*/);
  }

  return myCbx;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:76,代码来源:BindToExistingBeanStep.java


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