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


Java PsiClass.getTypeParameters方法代码示例

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


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

示例1: makeSrcClass

import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
public SrcClass makeSrcClass( String fqn, PsiClass psiClass, ManModule module )
{
  SrcClass srcClass = new SrcClass( fqn, getKind( psiClass ) )
    .modifiers( getModifiers( psiClass.getModifierList() ) );
  for( PsiTypeParameter typeVar : psiClass.getTypeParameters() )
  {
    srcClass.addTypeVar( new SrcType( makeTypeVar( typeVar ) ) );
  }
  setSuperTypes( srcClass, psiClass );
  for( PsiMethod psiMethod : psiClass.getMethods() )
  {
    addMethod( srcClass, psiMethod );
  }
  for( PsiField psiField : psiClass.getFields() )
  {
    addField( srcClass, psiField );
  }
  for( PsiClass psiInnerClass : psiClass.getInnerClasses() )
  {
    addInnerClass( srcClass, psiInnerClass, module );
  }
  return srcClass;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:24,代码来源:StubBuilder.java

示例2: processTypeVars

import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
private String processTypeVars( PsiDirectory dir, String fqnExtended, Function<PsiTypeParameter,String> processor )
{
  boolean alt = false;
  DumbService dumbService = DumbService.getInstance( dir.getProject() );
  if( dumbService.isDumb() )
  {
    dumbService.setAlternativeResolveEnabled( alt = true );
  }
  try
  {
    PsiClass extendedClass = JavaPsiFacadeEx.getInstanceEx( dir.getProject() ).findClass( fqnExtended );
    if( extendedClass == null )
    {
      return "";
    }
    PsiTypeParameter[] typeParameters = extendedClass.getTypeParameters();
    if( typeParameters.length == 0 )
    {
      return "";
    }

    StringBuilder sb = new StringBuilder();
    sb.append( "<" );
    for( int i = 0; i < typeParameters.length; i++ )
    {
      PsiTypeParameter tp = typeParameters[i];
      if( i > 0 )
      {
        sb.append( ", " );
      }
      sb.append( processor.fun( tp ) );
    }
    sb.append( "> " );
    return sb.toString();
  }
  finally
  {
    if( alt )
    {
      dumbService.setAlternativeResolveEnabled( false );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:44,代码来源:CreateExtensionMethodsClassAction.java

示例3: addMethods

import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
private void addMethods( String fqn, PsiClass psiClass, List<PsiElement> augFeatures, Module start, Module module )
{
  ManModule manModule = ManProject.getModule( module );
  for( ITypeManifold sp : manModule.getTypeManifolds() )
  {
    if( sp.getProducerKind() == Supplemental )
    {
      if( sp.isType( fqn ) )
      {
        List<IFile> files = sp.findFilesForType( fqn );
        for( IFile file : files )
        {
          VirtualFile vFile = ((IjFile)file).getVirtualFile();
          if( !vFile.isValid() )
          {
            continue;
          }

          PsiFile psiFile = PsiManager.getInstance( module.getProject() ).findFile( vFile );
          PsiJavaFile psiJavaFile = (PsiJavaFile)psiFile;
          PsiClass[] classes = psiJavaFile.getClasses();
          if( classes.length > 0 )
          {
            SrcClass srcExtClass = new StubBuilder().make( classes[0].getQualifiedName(), manModule );
            SrcClass scratchClass = new SrcClass( psiClass.getQualifiedName(), psiClass.isInterface() ? SrcClass.Kind.Interface : SrcClass.Kind.Class );
            for( PsiTypeParameter tv : psiClass.getTypeParameters() )
            {
              scratchClass.addTypeVar( new SrcType( StubBuilder.makeTypeVar( tv ) ) );
            }
            for( AbstractSrcMethod m : srcExtClass.getMethods() )
            {
              SrcMethod srcMethod = addExtensionMethod( scratchClass, m, psiClass );
              if( srcMethod != null )
              {
                PsiMethod extMethod = makePsiMethod( srcMethod, psiClass );
                if( extMethod != null )
                {
                  PsiMethod plantedMethod = plantMethodInPsiClass( extMethod, psiClass, classes[0] );
                  augFeatures.add( plantedMethod );
                }
              }
            }
          }
        }
      }
    }
  }
  for( Dependency d : manModule.getDependencies() )
  {
    if( module == start || d.isExported() )
    {
      addMethods( fqn, psiClass, augFeatures, start, ((ManModule)d.getModule()).getIjModule() );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:56,代码来源:ManAugmentProvider.java

示例4: replaceTypeVariableTypeParametersWithBoundingTypes

import com.intellij.psi.PsiClass; //导入方法依赖的package包/类
public static PsiType replaceTypeVariableTypeParametersWithBoundingTypes( PsiType type, PsiType enclType )
{
  if( isTypeVariable( type ) )
  {
    PsiClass boundingType = getBoundingType( (PsiTypeParameter)((PsiClassType)type).resolve() );

    if( isRecursiveType( (PsiClassType)type, type( boundingType ) ) )
    {
      // short-circuit recursive typevar
      return ((PsiClassType)type( boundingType )).rawType();
    }

    if( enclType != null && isParameterizedType( enclType ) )
    {
      TypeVarToTypeMap map = mapTypeByVarName( enclType, enclType );
      return replaceTypeVariableTypeParametersWithBoundingTypes( getActualType( type( boundingType ), map, true ) );
    }

    return replaceTypeVariableTypeParametersWithBoundingTypes( type( boundingType ), enclType );
  }

  if( type.getArrayDimensions() > 0 )
  {
    return new PsiArrayType( replaceTypeVariableTypeParametersWithBoundingTypes( ((PsiArrayType)type).getComponentType(), enclType ) );
  }

  if( type instanceof PsiIntersectionType )
  {
    PsiType[] types = ((PsiIntersectionType)type).getConjuncts();
    Set<PsiType> newTypes = new HashSet<>();
    for( PsiType t : types )
    {
      newTypes.add( replaceTypeVariableTypeParametersWithBoundingTypes( t ) );
    }
    if( newTypes.size() == 1 )
    {
      return newTypes.iterator().next();
    }
    return PsiIntersectionType.createIntersection( new ArrayList<>( newTypes ) );
  }

  if( isParameterizedType( type ) )
  {
    PsiType[] typeParams = ((PsiClassType)type).getParameters();
    PsiType[] concreteParams = new PsiType[typeParams.length];
    for( int i = 0; i < typeParams.length; i++ )
    {
      concreteParams[i] = replaceTypeVariableTypeParametersWithBoundingTypes( typeParams[i], enclType );
    }
    type = parameterizeType( (PsiClassType)type, concreteParams );
  }
  else if( type instanceof PsiClassType )
  {
    PsiClass psiClass = ((PsiClassType)type).resolve();
    PsiTypeParameter[] typeVars = psiClass.getTypeParameters();
    PsiType[] boundingTypes = new PsiType[typeVars.length];
    for( int i = 0; i < boundingTypes.length; i++ )
    {
      boundingTypes[i] = type( getBoundingType( typeVars[i] ) );

      if( isRecursiveType( (PsiClassType)type( typeVars[i] ), boundingTypes[i] ) )
      {
        return type;
      }
    }
    for( int i = 0; i < boundingTypes.length; i++ )
    {
      boundingTypes[i] = replaceTypeVariableTypeParametersWithBoundingTypes( boundingTypes[i], enclType );
    }
    type = parameterizeType( (PsiClassType)type, boundingTypes );
  }
  else if( type instanceof PsiWildcardType )
  {
    replaceTypeVariableTypeParametersWithBoundingTypes( ((PsiWildcardType)type).getExtendsBound() );
  }
  return type;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:78,代码来源:TypeUtil.java


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