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

项目:intellij-ce-playground    文件:ClsAnnotationImpl.java   
public ClsAnnotationImpl(final PsiAnnotationStub stub) {
  super(stub);
  myReferenceElement = new AtomicNotNullLazyValue<ClsJavaCodeReferenceElementImpl>() {
    @NotNull
    @Override
    protected ClsJavaCodeReferenceElementImpl compute() {
      String annotationText = getStub().getText();
      int index = annotationText.indexOf('(');
      String refText = index > 0 ? annotationText.substring(1, index) : annotationText.substring(1);
      return new ClsJavaCodeReferenceElementImpl(ClsAnnotationImpl.this, refText);
    }
  };
  myParameterList = new AtomicNotNullLazyValue<ClsAnnotationParameterListImpl>() {
    @NotNull
    @Override
    protected ClsAnnotationParameterListImpl compute() {
      PsiNameValuePair[] attrs = getStub().getText().indexOf('(') > 0
          ? PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class).getAttributes()
          : PsiNameValuePair.EMPTY_ARRAY;
      return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, attrs);
    }
  };
}
项目:intellij-ce-playground    文件:TypeInfo.java   
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) {
  PsiModifierListStub modifierList = (PsiModifierListStub)owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
  if (modifierList == null) return this;

  List<PsiAnnotationStub> annotationStubs = null;
  for (StubElement child : modifierList.getChildrenStubs()) {
    if (!(child instanceof PsiAnnotationStub)) continue;
    PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
    if (PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement())) {
      if (annotationStubs == null) annotationStubs = new SmartList<PsiAnnotationStub>();
      annotationStubs.add(annotationStub);
    }
  }

  PsiAnnotationStub[] stubArray = PsiAnnotationStub.EMPTY_ARRAY;
  if (annotationStubs != null) stubArray = annotationStubs.toArray(new PsiAnnotationStub[annotationStubs.size()]);
  return new TypeInfo(text, arrayCount, isEllipsis, stubArray);
}
项目:tools-idea    文件:ClsAnnotationImpl.java   
public ClsAnnotationImpl(final PsiAnnotationStub stub) {
  super(stub);
  myReferenceElement = new AtomicNotNullLazyValue<ClsJavaCodeReferenceElementImpl>() {
    @NotNull
    @Override
    protected ClsJavaCodeReferenceElementImpl compute() {
      String text = PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiJavaCodeReferenceElement.class).getText();
      return new ClsJavaCodeReferenceElementImpl(ClsAnnotationImpl.this, text);
    }
  };
  myParameterList = new AtomicNotNullLazyValue<ClsAnnotationParameterListImpl>() {
    @NotNull
    @Override
    protected ClsAnnotationParameterListImpl compute() {
      PsiAnnotationParameterList paramList = PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class);
      return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, paramList.getAttributes());
    }
  };
}
项目:consulo-java    文件:TypeInfo.java   
@NotNull
public static TypeInfo readTYPE(@NotNull StubInputStream record) throws IOException
{
    int flags = 0xFF & record.readByte();
    if(flags == FREQUENT_INDEX_MASK)
    {
        return NULL;
    }

    int frequentIndex = FREQUENT_INDEX_MASK & flags;
    byte arrayCount = isSet(flags, HAS_ARRAY_COUNT) ? record.readByte() : 0;
    boolean hasEllipsis = isSet(flags, HAS_ELLIPSIS);

    String text = frequentIndex == 0 ? StringRef.toString(record.readName()) : ourIndexFrequentType[frequentIndex];

    return new TypeInfo(text, arrayCount, hasEllipsis, PsiAnnotationStub.EMPTY_ARRAY);
}
项目:intellij-ce-playground    文件:PsiTypeParameterStubImpl.java   
@Override
@NotNull
public List<PsiAnnotationStub> getAnnotations() {
  List<StubElement> children = getChildrenStubs();

  return ContainerUtil.mapNotNull(children, new Function<StubElement, PsiAnnotationStub>() {
    @Override
    public PsiAnnotationStub fun(StubElement stubElement) {
      return stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null;
    }
  });
}
项目:intellij-ce-playground    文件:TypeInfo.java   
@NotNull
public static TypeInfo readTYPE(@NotNull StubInputStream record) throws IOException {
  int flags = 0xFF & record.readByte();
  if (flags == FREQUENT_INDEX_MASK) {
    return NULL;
  }

  int frequentIndex = FREQUENT_INDEX_MASK & flags;
  byte arrayCount = isSet(flags, HAS_ARRAY_COUNT) ? record.readByte() : 0;
  boolean hasEllipsis = isSet(flags, HAS_ELLIPSIS);

  String text = frequentIndex == 0 ? StringRef.toString(record.readName()) : ourIndexFrequentType[frequentIndex];

  return new TypeInfo(text, arrayCount, hasEllipsis, PsiAnnotationStub.EMPTY_ARRAY);
}
项目:intellij-ce-playground    文件:PsiAnnotationImpl.java   
@Override
public PsiJavaCodeReferenceElement getNameReferenceElement() {
  PsiAnnotationStub stub = getStub();
  if (stub != null) {
    return PsiTreeUtil.getRequiredChildOfType(stub.getPsiElement(), PsiJavaCodeReferenceElement.class);
  }

  return PsiTreeUtil.getChildOfType(this, PsiJavaCodeReferenceElement.class);
}
项目:tools-idea    文件:PsiTypeParameterStubImpl.java   
@Override
@NotNull
public List<PsiAnnotationStub> getAnnotations() {
  List<StubElement> children = getChildrenStubs();

  return ContainerUtil.mapNotNull(children, new Function<StubElement, PsiAnnotationStub>() {
    @Override
    public PsiAnnotationStub fun(StubElement stubElement) {
      return stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null;
    }
  });
}
项目:tools-idea    文件:TypeInfo.java   
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) {
  PsiModifierListStub modifierList = (PsiModifierListStub)owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
  if (modifierList == null) return this;

  List<PsiAnnotationStub> annotationStubs = ContainerUtil.newArrayList();
  for (StubElement child : modifierList.getChildrenStubs()) {
    if (!(child instanceof PsiAnnotationStub)) continue;
    PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
    if (PsiImplUtil.findApplicableTarget(annotationStub.getPsiElement(), TargetType.TYPE_USE) == TargetType.TYPE_USE) {
      annotationStubs.add(annotationStub);
    }
  }
  return new TypeInfo(text, arrayCount, isEllipsis, annotationStubs);
}
项目:tools-idea    文件:TypeInfo.java   
@NotNull
public static TypeInfo readTYPE(@NotNull StubInputStream record) throws IOException {
  int flags = 0xFF & record.readByte();
  if (flags == FREQUENT_INDEX_MASK) {
    return NULL;
  }

  int frequentIndex = FREQUENT_INDEX_MASK & flags;
  byte arrayCount = isSet(flags, HAS_ARRAY_COUNT) ? record.readByte() : 0;
  boolean hasEllipsis = isSet(flags, HAS_ELLIPSIS);

  StringRef text = frequentIndex == 0 ? record.readName() : StringRef.fromString(ourIndexFrequentType[frequentIndex]);

  return new TypeInfo(text, arrayCount, hasEllipsis, ContainerUtil.<PsiAnnotationStub>emptyList());
}
项目:tools-idea    文件:PsiAnnotationImpl.java   
@Override
public PsiJavaCodeReferenceElement getNameReferenceElement() {
  PsiAnnotationStub stub = getStub();
  if (stub != null) {
    return PsiTreeUtil.getRequiredChildOfType(stub.getPsiElement(), PsiJavaCodeReferenceElement.class);
  }

  return PsiTreeUtil.getChildOfType(this, PsiJavaCodeReferenceElement.class);
}
项目:consulo-java    文件:PsiTypeParameterStubImpl.java   
@Override
@NotNull
public List<PsiAnnotationStub> getAnnotations() {
  List<StubElement> children = getChildrenStubs();

  return ContainerUtil.mapNotNull(children, new Function<StubElement, PsiAnnotationStub>() {
    @Override
    public PsiAnnotationStub fun(StubElement stubElement) {
      return stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null;
    }
  });
}
项目:consulo-java    文件:ClsAnnotationImpl.java   
public ClsAnnotationImpl(final PsiAnnotationStub stub)
{
    super(stub);
    myReferenceElement = new AtomicNotNullLazyValue<ClsJavaCodeReferenceElementImpl>()
    {
        @NotNull
        @Override
        protected ClsJavaCodeReferenceElementImpl compute()
        {
            String annotationText = getStub().getText();
            int index = annotationText.indexOf('(');
            String refText = index > 0 ? annotationText.substring(1, index) : annotationText.substring(1);
            return new ClsJavaCodeReferenceElementImpl(ClsAnnotationImpl.this, refText);
        }
    };
    myParameterList = new AtomicNotNullLazyValue<ClsAnnotationParameterListImpl>()
    {
        @NotNull
        @Override
        protected ClsAnnotationParameterListImpl compute()
        {
            PsiNameValuePair[] attrs = getStub().getText().indexOf('(') > 0 ? PsiTreeUtil.getRequiredChildOfType(getStub().getPsiElement(), PsiAnnotationParameterList.class).getAttributes() :
                    PsiNameValuePair.EMPTY_ARRAY;
            return new ClsAnnotationParameterListImpl(ClsAnnotationImpl.this, attrs);
        }
    };
}
项目:consulo-java    文件:TypeInfo.java   
public TypeInfo(String text, byte arrayCount, boolean ellipsis, @NotNull PsiAnnotationStub[] annotationStubs)
{
    this.text = text == null ? null : internFrequentType(text);
    this.arrayCount = arrayCount;
    this.isEllipsis = ellipsis;
    myAnnotationStubs = annotationStubs;
}
项目:consulo-java    文件:TypeInfo.java   
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner)
{
    PsiModifierListStub modifierList = (PsiModifierListStub) owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
    if(modifierList == null)
    {
        return this;
    }

    List<PsiAnnotationStub> annotationStubs = null;
    for(StubElement child : modifierList.getChildrenStubs())
    {
        if(!(child instanceof PsiAnnotationStub))
        {
            continue;
        }
        PsiAnnotationStub annotationStub = (PsiAnnotationStub) child;
        if(PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement()))
        {
            if(annotationStubs == null)
            {
                annotationStubs = new SmartList<PsiAnnotationStub>();
            }
            annotationStubs.add(annotationStub);
        }
    }

    PsiAnnotationStub[] stubArray = PsiAnnotationStub.EMPTY_ARRAY;
    if(annotationStubs != null)
    {
        stubArray = annotationStubs.toArray(new PsiAnnotationStub[annotationStubs.size()]);
    }
    return new TypeInfo(text, arrayCount, isEllipsis, stubArray);
}
项目:intellij-ce-playground    文件:TypeInfo.java   
public TypeInfo(String text, byte arrayCount, boolean ellipsis, @NotNull PsiAnnotationStub[] annotationStubs) {
  this.text = text == null ? null : internFrequentType(text);
  this.arrayCount = arrayCount;
  this.isEllipsis = ellipsis;
  myAnnotationStubs = annotationStubs;
}
项目:intellij-ce-playground    文件:PsiAnnotationImpl.java   
public PsiAnnotationImpl(final PsiAnnotationStub stub) {
  super(stub, JavaStubElementTypes.ANNOTATION);
}
项目:tools-idea    文件:TypeInfo.java   
public TypeInfo(String text, byte arrayCount, boolean ellipsis, @NotNull List<PsiAnnotationStub> annotationStubs) {
  this(StringRef.fromString(text == null ? null : internFrequentType(text)), arrayCount, ellipsis, annotationStubs);
}
项目:tools-idea    文件:TypeInfo.java   
private TypeInfo(StringRef text, byte arrayCount, boolean isEllipsis, @NotNull List<PsiAnnotationStub> annotationStubs) {
  this.text = text;
  this.arrayCount = arrayCount;
  this.isEllipsis = isEllipsis;
  myAnnotationStubs = annotationStubs;
}
项目:tools-idea    文件:PsiAnnotationImpl.java   
public PsiAnnotationImpl(final PsiAnnotationStub stub) {
  super(stub, JavaStubElementTypes.ANNOTATION);
}
项目:consulo-java    文件:PsiAnnotationImpl.java   
public PsiAnnotationImpl(final PsiAnnotationStub stub)
{
    super(stub, JavaStubElementTypes.ANNOTATION);
}
项目:consulo-java    文件:PsiAnnotationImpl.java   
@Override
public PsiJavaCodeReferenceElement getNameReferenceElement()
{
    PsiAnnotationStub stub = getStub();
    return PsiTreeUtil.getChildOfType(stub != null ? stub.getPsiElement() : this, PsiJavaCodeReferenceElement.class);
}