Java 类com.intellij.psi.impl.java.stubs.PsiTypeParameterListStub 实例源码

项目:intellij-ce-playground    文件:PsiTypeParameterImpl.java   
@Override
public int getIndex() {
  final PsiTypeParameterStub stub = getStub();
  if (stub != null) {
    final PsiTypeParameterListStub parentStub = (PsiTypeParameterListStub)stub.getParentStub();
    return parentStub.getChildrenStubs().indexOf(stub);
  }

  int ret = 0;
  PsiElement element = getPrevSibling();
  while (element != null) {
    if (element instanceof PsiTypeParameter) {
      ret++;
    }
    element = element.getPrevSibling();
  }
  return ret;
}
项目:tools-idea    文件:PsiTypeParameterImpl.java   
@Override
public int getIndex() {
  final PsiTypeParameterStub stub = getStub();
  if (stub != null) {
    final PsiTypeParameterListStub parentStub = (PsiTypeParameterListStub)stub.getParentStub();
    return parentStub.getChildrenStubs().indexOf(stub);
  }

  int ret = 0;
  PsiElement element = getPrevSibling();
  while (element != null) {
    if (element instanceof PsiTypeParameter) {
      ret++;
    }
    element = element.getPrevSibling();
  }
  return ret;
}
项目:consulo-java    文件:PsiTypeParameterImpl.java   
@Override
public int getIndex() {
  final PsiTypeParameterStub stub = getStub();
  if (stub != null) {
    final PsiTypeParameterListStub parentStub = (PsiTypeParameterListStub)stub.getParentStub();
    return parentStub.getChildrenStubs().indexOf(stub);
  }

  int ret = 0;
  PsiElement element = getPrevSibling();
  while (element != null) {
    if (element instanceof PsiTypeParameter) {
      ret++;
    }
    element = element.getPrevSibling();
  }
  return ret;
}
项目:intellij-ce-playground    文件:SignatureParsing.java   
public static PsiTypeParameterListStub parseTypeParametersDeclaration(CharacterIterator iterator, StubElement parentStub) throws ClsFormatException {
  PsiTypeParameterListStub list = new PsiTypeParameterListStubImpl(parentStub);

  if (iterator.current() == '<') {
    iterator.next();
    while (iterator.current() != '>') {
      parseTypeParameter(iterator, list);
    }
    iterator.next();
  }

  return list;
}
项目:intellij-ce-playground    文件:SignatureParsing.java   
private static PsiTypeParameterStub parseTypeParameter(CharacterIterator iterator, PsiTypeParameterListStub parent) throws ClsFormatException {
  StringBuilder name = new StringBuilder();
  while (iterator.current() != ':' && iterator.current() != CharacterIterator.DONE) {
    name.append(iterator.current());
    iterator.next();
  }
  if (iterator.current() == CharacterIterator.DONE) {
    throw new ClsFormatException();
  }

  //todo parse annotations on type param
  PsiTypeParameterStub parameterStub = new PsiTypeParameterStubImpl(parent, StringRef.fromString(name.toString()));

  // postpone list allocation till a second bound is seen; ignore sole Object bound
  List<String> bounds = null;
  boolean jlo = false;
  while (iterator.current() == ':') {
    iterator.next();
    String bound = parseTopLevelClassRefSignature(iterator);
    if (bound == null) continue;
    if (bounds == null) {
      if (CommonClassNames.JAVA_LANG_OBJECT.equals(bound)) {
        jlo = true;
        continue;
      }
      bounds = ContainerUtil.newSmartList();
      if (jlo) {
        bounds.add(CommonClassNames.JAVA_LANG_OBJECT);
      }
    }
    bounds.add(bound);
  }

  StubBuildingVisitor.newReferenceList(JavaStubElementTypes.EXTENDS_BOUND_LIST, parameterStub, ArrayUtil.toStringArray(bounds));

  return parameterStub;
}
项目:tools-idea    文件:SignatureParsing.java   
public static PsiTypeParameterListStub parseTypeParametersDeclaration(CharacterIterator signatureIterator, StubElement parentStub)
    throws ClsFormatException {
  PsiTypeParameterListStub list = new PsiTypeParameterListStubImpl(parentStub);
  if (signatureIterator.current() == '<') {
    signatureIterator.next();
    while (signatureIterator.current() != '>') {
      parseTypeParameter(signatureIterator, list);
    }
    signatureIterator.next();
  }

  return list;
}
项目:tools-idea    文件:SignatureParsing.java   
private static PsiTypeParameterStub parseTypeParameter(CharacterIterator signatureIterator, PsiTypeParameterListStub parent)
    throws ClsFormatException {
  StringBuilder name = new StringBuilder();
  while (signatureIterator.current() != ':' && signatureIterator.current() != CharacterIterator.DONE) {
    name.append(signatureIterator.current());
    signatureIterator.next();
  }
  if (signatureIterator.current() == CharacterIterator.DONE) {
    throw new ClsFormatException();
  }

  //todo parse annotations on type param
  PsiTypeParameterStub parameterStub = new PsiTypeParameterStubImpl(parent, StringRef.fromString(name.toString()));

  ArrayList<String> bounds = null;
  while (signatureIterator.current() == ':') {
    signatureIterator.next();
    String bound = parseTopLevelClassRefSignature(signatureIterator);
    if (bound != null && !bound.equals(CommonClassNames.JAVA_LANG_OBJECT)) {
      if (bounds == null) bounds = new ArrayList<String>();
      bounds.add(bound);
    }
  }

  StubBuildingVisitor.newReferenceList(JavaStubElementTypes.EXTENDS_BOUND_LIST, parameterStub, ArrayUtil.toStringArray(bounds));

  return parameterStub;
}
项目:intellij-ce-playground    文件:ClsTypeParametersListImpl.java   
public ClsTypeParametersListImpl(@NotNull PsiTypeParameterListStub stub) {
  super(stub);
}
项目:intellij-ce-playground    文件:PsiTypeParameterListImpl.java   
public PsiTypeParameterListImpl(final PsiTypeParameterListStub stub) {
  super(stub, JavaStubElementTypes.TYPE_PARAMETER_LIST);
}
项目:tools-idea    文件:ClsTypeParametersListImpl.java   
public ClsTypeParametersListImpl(@NotNull PsiTypeParameterListStub stub) {
  super(stub);
}
项目:tools-idea    文件:PsiTypeParameterListImpl.java   
public PsiTypeParameterListImpl(final PsiTypeParameterListStub stub) {
  super(stub, JavaStubElementTypes.TYPE_PARAMETER_LIST);
}
项目:consulo-java    文件:StubBuildingVisitor.java   
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
{
    myInternalName = name;
    String parentName = myParent instanceof PsiClassStub ? ((PsiClassStub) myParent).getQualifiedName() : myParent instanceof PsiJavaFileStub ? ((PsiJavaFileStub) myParent).getPackageName() :
            null;
    String fqn = getFqn(name, myShortName, parentName);
    String shortName = myShortName != null && name.endsWith(myShortName) ? myShortName : PsiNameHelper.getShortClassName(fqn);

    int flags = myAccess | access;
    boolean isDeprecated = isSet(flags, Opcodes.ACC_DEPRECATED);
    boolean isInterface = isSet(flags, Opcodes.ACC_INTERFACE);
    boolean isEnum = isSet(flags, Opcodes.ACC_ENUM);
    boolean isAnnotationType = isSet(flags, Opcodes.ACC_ANNOTATION);
    byte stubFlags = PsiClassStubImpl.packFlags(isDeprecated, isInterface, isEnum, false, false, isAnnotationType, false, false);
    myResult = new PsiClassStubImpl(JavaStubElementTypes.CLASS, myParent, fqn, shortName, null, stubFlags);

    myModList = new PsiModifierListStubImpl(myResult, packClassFlags(flags));

    ClassInfo info = null;
    if(signature != null)
    {
        try
        {
            info = parseClassSignature(signature);
        }
        catch(ClsFormatException e)
        {
            if(LOG.isDebugEnabled())
            {
                LOG.debug("source=" + mySource + " signature=" + signature, e);
            }
        }
    }
    if(info == null)
    {
        info = parseClassDescription(superName, interfaces);
    }

    PsiTypeParameterListStub typeParameterList = new PsiTypeParameterListStubImpl(myResult);
    for(Pair<String, String[]> parameter : info.typeParameters)
    {
        PsiTypeParameterStub parameterStub = new PsiTypeParameterStubImpl(typeParameterList, StringRef.fromString(parameter.first));
        newReferenceList(JavaStubElementTypes.EXTENDS_BOUND_LIST, parameterStub, parameter.second);
    }

    if(myResult.isInterface())
    {
        if(info.interfaceNames != null && myResult.isAnnotationType())
        {
            info.interfaceNames.remove(CommonClassNames.JAVA_LANG_ANNOTATION_ANNOTATION);
        }
        newReferenceList(JavaStubElementTypes.EXTENDS_LIST, myResult, ArrayUtil.toStringArray(info.interfaceNames));
        newReferenceList(JavaStubElementTypes.IMPLEMENTS_LIST, myResult, ArrayUtil.EMPTY_STRING_ARRAY);
    }
    else
    {
        if(info.superName == null || "java/lang/Object".equals(superName) || myResult.isEnum() && "java/lang/Enum".equals(superName))
        {
            newReferenceList(JavaStubElementTypes.EXTENDS_LIST, myResult, ArrayUtil.EMPTY_STRING_ARRAY);
        }
        else
        {
            newReferenceList(JavaStubElementTypes.EXTENDS_LIST, myResult, new String[]{info.superName});
        }
        newReferenceList(JavaStubElementTypes.IMPLEMENTS_LIST, myResult, ArrayUtil.toStringArray(info.interfaceNames));
    }
}
项目:consulo-java    文件:ClsTypeParametersListImpl.java   
public ClsTypeParametersListImpl(@NotNull PsiTypeParameterListStub stub) {
  super(stub);
}
项目:consulo-java    文件:PsiTypeParameterListImpl.java   
public PsiTypeParameterListImpl(final PsiTypeParameterListStub stub) {
  super(stub, JavaStubElementTypes.TYPE_PARAMETER_LIST);
}