Java 类com.intellij.psi.impl.compiled.ClsMethodImpl 实例源码

项目:intellij-ce-playground    文件:GroovyClsCustomNavigationPolicy.java   
@Override
@Nullable
public PsiElement getNavigationElement(@NotNull ClsMethodImpl clsMethod) {
  if (!isGroovyLanguage(clsMethod)) return null;

  PsiMethod source = clsMethod.getSourceMirrorMethod();
  if (source instanceof LightElement) {
    return source.getNavigationElement();
  }

  return null;
}
项目:intellij-ce-playground    文件:ClosureDescriptor.java   
public boolean isMethodApplicable(PsiMethod method, GroovyPsiElement place) {
  String name = String.valueOf(myMethod.get("name"));
  if (name == null || !name.equals(method.getName())) return false;

  List<PsiType> types = new ArrayList<PsiType>();
  final Object params = myMethod.get("params");
  if (params instanceof Map) {
    boolean first = true;
    for (Object paramName : ((Map)params).keySet()) {
      Object value = ((Map)params).get(paramName);
      boolean isNamed = first && value instanceof List;
      first = false;
      String typeName = isNamed ? CommonClassNames.JAVA_UTIL_MAP : String.valueOf(value);
      types.add(convertToPsiType(typeName, place));
    }
  }
  else if (params instanceof List) {
    for (Object param : ((List)params)) {
      PsiTypeParameterList typeParameterList = method.getTypeParameterList();
      types.add(convertToPsiType(String.valueOf(param), typeParameterList != null ? typeParameterList : method));
    }
  }
  final boolean isConstructor = Boolean.TRUE.equals(myMethod.get("constructor"));
  final MethodSignature signature = MethodSignatureUtil
    .createMethodSignature(name, types.toArray(PsiType.createArray(types.size())), method.getTypeParameters(), PsiSubstitutor.EMPTY, isConstructor);
  final GrClosureSignature closureSignature = GrClosureSignatureUtil.createSignature(signature);

  if (method instanceof ClsMethodImpl) method = ((ClsMethodImpl)method).getSourceMirrorMethod();
  final PsiParameter[] parameters = method.getParameterList().getParameters();
  final PsiType[] typeArray = PsiType.createArray(parameters.length);
  ContainerUtil.map(parameters, new Function<PsiParameter, PsiType>() {
    @Override
    public PsiType fun(PsiParameter parameter) {
      return parameter.getType();
    }
  }, typeArray);
  return GrClosureSignatureUtil.isSignatureApplicable(closureSignature, typeArray, place);
}
项目:intellij-ce-playground    文件:GroovyTargetElementEvaluator.java   
@Nullable
public static PsiElement correctSearchTargets(@Nullable PsiElement target) {
  if (target instanceof ClsMethodImpl) {
    PsiElement mirror = ((ClsMethodImpl)target).getSourceMirrorMethod();
    if (mirror != null) {
      return mirror.getNavigationElement();
    }
  }
  if (target != null && !(target instanceof GrAccessorMethod) && target.getUserData(NAVIGATION_ELEMENT_IS_NOT_TARGET) == null) {
    return target.getNavigationElement();
  }
  return target;
}
项目:robot-intellij-plugin    文件:RobotJavaPsiUtil.java   
public static PsiMethod wrap(PsiMethod method, boolean wrapPsiMethods) {
    if (wrapPsiMethods) {
        if (method instanceof ClsMethodImpl) {
            return new PsiMethodWithRobotName(((ClsMethodImpl) method).getStub(), method);
        }
        return new PsiMethodWithRobotName(method.getNode(), method);
    }
    return method;
}
项目:tools-idea    文件:GroovyTargetElementEvaluator.java   
@Nullable
public static PsiElement correctSearchTargets(@Nullable PsiElement target) {
  if (target instanceof ClsMethodImpl) {
    PsiElement mirror = ((ClsMethodImpl)target).getSourceMirrorMethod();
    if (mirror != null) {
      return mirror.getNavigationElement();
    }
  }
  if (target != null && !(target instanceof GrAccessorMethod) && target.getUserData(NAVIGATION_ELEMENT_IS_NOT_TARGET) == null) {
    return target.getNavigationElement();
  }
  return target;
}
项目:tools-idea    文件:GroovyClsCustomNavigationPolicy.java   
@Override
@Nullable
public PsiElement getNavigationElement(@NotNull ClsMethodImpl clsMethod) {
  PsiMethod source = clsMethod.getSourceMirrorMethod();
  if (source instanceof LightElement && source.getLanguage() == GroovyFileType.GROOVY_LANGUAGE) {
    return source.getNavigationElement();
  }

  return null;
}
项目:tools-idea    文件:ClosureDescriptor.java   
public boolean isMethodApplicable(PsiMethod method, GroovyPsiElement place) {
  String name = String.valueOf(myMethod.get("name"));
  if (name == null || !name.equals(method.getName())) return false;

  List<PsiType> types = new ArrayList<PsiType>();
  final Object params = myMethod.get("params");
  if (params instanceof Map) {
    boolean first = true;
    for (Object paramName : ((Map)params).keySet()) {
      Object value = ((Map)params).get(paramName);
      boolean isNamed = first && value instanceof List;
      first = false;
      String typeName = isNamed ? CommonClassNames.JAVA_UTIL_MAP : String.valueOf(value);
      types.add(convertToPsiType(typeName, place));
    }
  }
  else if (params instanceof List) {
    for (Object param : ((List)params)) {
      PsiTypeParameterList typeParameterList = method.getTypeParameterList();
      types.add(convertToPsiType(String.valueOf(param), typeParameterList != null ? typeParameterList : method));
    }
  }
  final boolean isConstructor = Boolean.TRUE.equals(myMethod.get("constructor"));
  final MethodSignature signature = MethodSignatureUtil
    .createMethodSignature(name, types.toArray(new PsiType[types.size()]), method.getTypeParameters(), PsiSubstitutor.EMPTY, isConstructor);
  final GrClosureSignature closureSignature = GrClosureSignatureUtil.createSignature(signature);

  if (method instanceof ClsMethodImpl) method = ((ClsMethodImpl)method).getSourceMirrorMethod();
  final PsiParameter[] parameters = method.getParameterList().getParameters();
  final PsiType[] typeArray = new PsiType[parameters.length];
  ContainerUtil.map(parameters, new Function<PsiParameter, PsiType>() {
    @Override
    public PsiType fun(PsiParameter parameter) {
      return parameter.getType();
    }
  }, typeArray);
  return GrClosureSignatureUtil.isSignatureApplicable(closureSignature, typeArray, place);
}
项目:intellij-ce-playground    文件:GroovyClsCustomNavigationPolicy.java   
private static boolean isGroovyLanguage(ClsMethodImpl method) {
  return method.getContainingFile().getNavigationElement().getLanguage() == GroovyLanguage.INSTANCE;
}